mirror of
https://gitlab.com/mbugroup/lti-api.git
synced 2026-05-20 13:31:56 +00:00
FIX[BE]: fixing umur on closing penjualan for penjualan OVK and PAKAN
This commit is contained in:
@@ -44,7 +44,12 @@ type PenjualanRealisasiResponseDTO struct {
|
||||
|
||||
func ToSalesDTO(e entity.MarketingDeliveryProduct) SalesDTO {
|
||||
|
||||
ageInDay, ageInWeeks := calculateAgeFromChickin(e.MarketingProduct.ProductWarehouse.ProjectFlockKandang, e.DeliveryDate)
|
||||
productFlags := make([]string, len(e.MarketingProduct.ProductWarehouse.Product.Flags))
|
||||
for i, f := range e.MarketingProduct.ProductWarehouse.Product.Flags {
|
||||
productFlags[i] = f.Name
|
||||
}
|
||||
|
||||
ageInDay, ageInWeeks := calculateAgeFromChickin(e.MarketingProduct.ProductWarehouse.ProjectFlockKandang, e.DeliveryDate, productFlags)
|
||||
|
||||
var product *productDTO.ProductRelationDTO
|
||||
if e.MarketingProduct.ProductWarehouse.Product.Id != 0 {
|
||||
@@ -126,11 +131,17 @@ func ToPenjualanRealisasiResponseDTO(e []entity.MarketingDeliveryProduct) Penjua
|
||||
}
|
||||
}
|
||||
|
||||
func calculateAgeFromChickin(projectFlockKandang *entity.ProjectFlockKandang, deliveryDate *time.Time) (int, int) {
|
||||
func calculateAgeFromChickin(projectFlockKandang *entity.ProjectFlockKandang, deliveryDate *time.Time, productFlags []string) (int, int) {
|
||||
if projectFlockKandang == nil || deliveryDate == nil || len(projectFlockKandang.Chickins) == 0 {
|
||||
return 0, 0
|
||||
}
|
||||
|
||||
for _, flag := range productFlags {
|
||||
if flag == "OVK" || flag == "PAKAN" {
|
||||
return 0, 0 //
|
||||
}
|
||||
}
|
||||
|
||||
earliestChickinDate := projectFlockKandang.Chickins[0].ChickInDate
|
||||
for _, chickin := range projectFlockKandang.Chickins {
|
||||
if chickin.ChickInDate.Before(earliestChickinDate) {
|
||||
|
||||
Reference in New Issue
Block a user