mirror of
https://gitlab.com/mbugroup/lti-api.git
synced 2026-05-20 13:31:56 +00:00
feat[BE]: add address field to CustomerRelationDTO and refactor payment report functions for improved clarity and structure
This commit is contained in:
@@ -14,6 +14,7 @@ type CustomerRelationDTO struct {
|
||||
Name string `json:"name"`
|
||||
Type string `json:"type"`
|
||||
AccountNumber string `json:"account_number"`
|
||||
Address string `json:"address,omitempty"`
|
||||
Balance float64 `json:"balance"`
|
||||
Pic *userDTO.UserRelationDTO `json:"pic,omitempty"`
|
||||
}
|
||||
@@ -52,6 +53,7 @@ func ToCustomerRelationDTO(e entity.Customer) CustomerRelationDTO {
|
||||
Name: e.Name,
|
||||
Type: e.Type,
|
||||
AccountNumber: e.AccountNumber,
|
||||
Address: e.Address,
|
||||
Balance: e.Balance,
|
||||
Pic: pic,
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"gitlab.com/mbugroup/lti-api.git/internal/entities"
|
||||
customerDTO "gitlab.com/mbugroup/lti-api.git/internal/modules/master/customers/dto"
|
||||
repportRepo "gitlab.com/mbugroup/lti-api.git/internal/modules/repports/repositories"
|
||||
)
|
||||
@@ -70,25 +71,16 @@ func ToCustomerPaymentReportRow(tx repportRepo.CustomerPaymentTransaction) Custo
|
||||
}
|
||||
}
|
||||
|
||||
func parseStringSlice(str string) []string {
|
||||
str = strings.TrimSpace(str)
|
||||
if str == "" || str == "-" {
|
||||
return []string{}
|
||||
func ToCustomerPaymentReportItem(customer entities.Customer, initialBalance float64, rows []CustomerPaymentReportRow, summary CustomerPaymentReportSummary) CustomerPaymentReportItem {
|
||||
return CustomerPaymentReportItem{
|
||||
Customer: customerDTO.ToCustomerRelationDTO(customer),
|
||||
InitialBalance: initialBalance,
|
||||
Rows: rows,
|
||||
Summary: summary,
|
||||
}
|
||||
|
||||
parts := strings.Split(str, ",")
|
||||
result := make([]string, 0, len(parts))
|
||||
for _, part := range parts {
|
||||
part = strings.TrimSpace(part)
|
||||
if part != "" {
|
||||
result = append(result, part)
|
||||
}
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
func CalculateCustomerPaymentSummary(rows []CustomerPaymentReportRow, initialBalance float64) CustomerPaymentReportSummary {
|
||||
func ToCustomerPaymentReportSummary(rows []CustomerPaymentReportRow, initialBalance float64) CustomerPaymentReportSummary {
|
||||
summary := CustomerPaymentReportSummary{}
|
||||
|
||||
for _, row := range rows {
|
||||
@@ -108,3 +100,21 @@ func CalculateCustomerPaymentSummary(rows []CustomerPaymentReportRow, initialBal
|
||||
|
||||
return summary
|
||||
}
|
||||
|
||||
func parseStringSlice(str string) []string {
|
||||
str = strings.TrimSpace(str)
|
||||
if str == "" || str == "-" {
|
||||
return []string{}
|
||||
}
|
||||
|
||||
parts := strings.Split(str, ",")
|
||||
result := make([]string, 0, len(parts))
|
||||
for _, part := range parts {
|
||||
part = strings.TrimSpace(part)
|
||||
if part != "" {
|
||||
result = append(result, part)
|
||||
}
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
@@ -19,7 +19,6 @@ import (
|
||||
expenseRepo "gitlab.com/mbugroup/lti-api.git/internal/modules/expenses/repositories"
|
||||
marketingRepo "gitlab.com/mbugroup/lti-api.git/internal/modules/marketing/repositories"
|
||||
areaDTO "gitlab.com/mbugroup/lti-api.git/internal/modules/master/areas/dto"
|
||||
customerDTO "gitlab.com/mbugroup/lti-api.git/internal/modules/master/customers/dto"
|
||||
customerRepo "gitlab.com/mbugroup/lti-api.git/internal/modules/master/customers/repositories"
|
||||
supplierDTO "gitlab.com/mbugroup/lti-api.git/internal/modules/master/suppliers/dto"
|
||||
warehouseDTO "gitlab.com/mbugroup/lti-api.git/internal/modules/master/warehouses/dto"
|
||||
@@ -473,14 +472,9 @@ func (s *repportService) processCustomerPayment(ctx context.Context, customerID
|
||||
rows = filteredRows
|
||||
}
|
||||
|
||||
summary := dto.CalculateCustomerPaymentSummary(rows, initialBalance)
|
||||
summary := dto.ToCustomerPaymentReportSummary(rows, initialBalance)
|
||||
|
||||
return dto.CustomerPaymentReportItem{
|
||||
Customer: customerDTO.ToCustomerRelationDTO(*customer),
|
||||
InitialBalance: initialBalance,
|
||||
Rows: rows,
|
||||
Summary: summary,
|
||||
}, nil
|
||||
return dto.ToCustomerPaymentReportItem(*customer, initialBalance, rows, summary), nil
|
||||
}
|
||||
|
||||
func (s *repportService) determineSalesStatusAndPaymentDate(transactions []repportRepo.CustomerPaymentTransaction, currentIndex int, previousBalance, currentBalance float64) (string, *time.Time) {
|
||||
|
||||
Reference in New Issue
Block a user