mirror of
https://gitlab.com/mbugroup/lti-api.git
synced 2026-05-20 13:31:56 +00:00
[FEAT/BE]Fix remove fcr master data and changes to standart production
This commit is contained in:
@@ -1352,10 +1352,12 @@ func buildDebtSupplierRow(purchase entity.Purchase, now time.Time, loc *time.Loc
|
||||
poNumber = *purchase.PoNumber
|
||||
}
|
||||
|
||||
prDate := purchase.CreatedAt.In(loc)
|
||||
startDate := time.Date(prDate.Year(), prDate.Month(), prDate.Day(), 0, 0, 0, 0, loc)
|
||||
startDate := resolveDebtSupplierReceivedDate(purchase, loc)
|
||||
endDate := time.Date(now.Year(), now.Month(), now.Day(), 0, 0, 0, 0, loc)
|
||||
aging := int(endDate.Sub(startDate).Hours() / 24)
|
||||
aging := 0
|
||||
if !startDate.IsZero() {
|
||||
aging = int(endDate.Sub(startDate).Hours() / 24)
|
||||
}
|
||||
|
||||
totalPrice := 0.0
|
||||
travelNumber := "-"
|
||||
@@ -1525,8 +1527,10 @@ func isDebtSupplierPaid(totalPrice, paymentTotal float64) bool {
|
||||
}
|
||||
|
||||
func calculateDebtSupplierAging(purchase entity.Purchase, endDate time.Time, loc *time.Location) int {
|
||||
prDate := purchase.CreatedAt.In(loc)
|
||||
startDate := time.Date(prDate.Year(), prDate.Month(), prDate.Day(), 0, 0, 0, 0, loc)
|
||||
startDate := resolveDebtSupplierReceivedDate(purchase, loc)
|
||||
if startDate.IsZero() {
|
||||
return 0
|
||||
}
|
||||
stopDate := time.Date(endDate.Year(), endDate.Month(), endDate.Day(), 0, 0, 0, 0, loc)
|
||||
if stopDate.Before(startDate) {
|
||||
return 0
|
||||
@@ -1534,6 +1538,23 @@ func calculateDebtSupplierAging(purchase entity.Purchase, endDate time.Time, loc
|
||||
return int(stopDate.Sub(startDate).Hours() / 24)
|
||||
}
|
||||
|
||||
func resolveDebtSupplierReceivedDate(purchase entity.Purchase, loc *time.Location) time.Time {
|
||||
earliest := time.Time{}
|
||||
for _, item := range purchase.Items {
|
||||
if item.ReceivedDate == nil || item.ReceivedDate.IsZero() {
|
||||
continue
|
||||
}
|
||||
received := item.ReceivedDate.In(loc)
|
||||
if earliest.IsZero() || received.Before(earliest) {
|
||||
earliest = received
|
||||
}
|
||||
}
|
||||
if earliest.IsZero() {
|
||||
return time.Time{}
|
||||
}
|
||||
return time.Date(earliest.Year(), earliest.Month(), earliest.Day(), 0, 0, 0, 0, loc)
|
||||
}
|
||||
|
||||
func (s *repportService) GetHppPerKandang(ctx *fiber.Ctx) (*dto.HppPerKandangResponseData, *dto.HppPerKandangMetaDTO, error) {
|
||||
params, filters, err := s.parseHppPerKandangQuery(ctx)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user