mirror of
https://gitlab.com/mbugroup/lti-api.git
synced 2026-05-20 13:31:56 +00:00
fix(BE): filter by transaction or realization in report customer payment
This commit is contained in:
@@ -582,6 +582,11 @@ func (s *repportService) processCustomerPayment(ctx context.Context, customerID
|
||||
return dto.CustomerPaymentReportItem{}, err
|
||||
}
|
||||
|
||||
filterBy := strings.ToUpper(strings.TrimSpace(params.FilterBy))
|
||||
if filterBy == "" {
|
||||
filterBy = utils.CustomerPaymentFilterByTransDate
|
||||
}
|
||||
|
||||
var startDate, endDate *time.Time
|
||||
if params.StartDate != "" {
|
||||
parsed, err := time.ParseInLocation("2006-01-02", params.StartDate, location)
|
||||
@@ -600,11 +605,20 @@ func (s *repportService) processCustomerPayment(ctx context.Context, customerID
|
||||
}
|
||||
|
||||
for _, row := range rows {
|
||||
transDate := row.TransDate.In(location)
|
||||
if startDate != nil && transDate.Before(*startDate) {
|
||||
var compareDate time.Time
|
||||
if filterBy == utils.CustomerPaymentFilterByRealizationDate {
|
||||
if row.DeliveryDate == nil {
|
||||
continue
|
||||
}
|
||||
compareDate = row.DeliveryDate.In(location)
|
||||
} else {
|
||||
compareDate = row.TransDate.In(location)
|
||||
}
|
||||
|
||||
if startDate != nil && compareDate.Before(*startDate) {
|
||||
continue
|
||||
}
|
||||
if endDate != nil && transDate.After(*endDate) {
|
||||
if endDate != nil && compareDate.After(*endDate) {
|
||||
continue
|
||||
}
|
||||
filteredRows = append(filteredRows, row)
|
||||
|
||||
Reference in New Issue
Block a user