mirror of
https://gitlab.com/mbugroup/lti-api.git
synced 2026-05-20 13:31:56 +00:00
Merge branch 'dev/teguh' into 'development'
FEAT[BE]: transfer to laying, stock transfer, refactor adjustment, fix age closing penjualan, filter transfer to laying See merge request mbugroup/lti-api!256
This commit is contained in:
@@ -8,6 +8,7 @@ import (
|
||||
customerDTO "gitlab.com/mbugroup/lti-api.git/internal/modules/master/customers/dto"
|
||||
kandangDTO "gitlab.com/mbugroup/lti-api.git/internal/modules/master/kandangs/dto"
|
||||
productDTO "gitlab.com/mbugroup/lti-api.git/internal/modules/master/products/dto"
|
||||
"gitlab.com/mbugroup/lti-api.git/internal/utils"
|
||||
)
|
||||
|
||||
// === Response DTO ===
|
||||
@@ -49,7 +50,12 @@ func ToSalesDTO(e entity.MarketingDeliveryProduct) SalesDTO {
|
||||
productFlags[i] = f.Name
|
||||
}
|
||||
|
||||
ageInDay, ageInWeeks := calculateAgeFromChickin(e.MarketingProduct.ProductWarehouse.ProjectFlockKandang, e.DeliveryDate, productFlags)
|
||||
var category string
|
||||
if e.MarketingProduct.ProductWarehouse.ProjectFlockKandang != nil {
|
||||
category = e.MarketingProduct.ProductWarehouse.ProjectFlockKandang.ProjectFlock.Category
|
||||
}
|
||||
|
||||
ageInDay, ageInWeeks := calculateAgeFromChickin(e.MarketingProduct.ProductWarehouse.ProjectFlockKandang, e.DeliveryDate, productFlags, category)
|
||||
|
||||
var product *productDTO.ProductRelationDTO
|
||||
if e.MarketingProduct.ProductWarehouse.Product.Id != 0 {
|
||||
@@ -131,14 +137,27 @@ func ToPenjualanRealisasiResponseDTO(e []entity.MarketingDeliveryProduct) Penjua
|
||||
}
|
||||
}
|
||||
|
||||
func calculateAgeFromChickin(projectFlockKandang *entity.ProjectFlockKandang, deliveryDate *time.Time, productFlags []string) (int, int) {
|
||||
func calculateAgeFromChickin(projectFlockKandang *entity.ProjectFlockKandang, deliveryDate *time.Time, productFlags []string, category 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 //
|
||||
if flag == string(utils.FlagOVK) ||
|
||||
flag == string(utils.FlagPakan) ||
|
||||
flag == string(utils.FlagPreStarter) ||
|
||||
flag == string(utils.FlagStarter) ||
|
||||
flag == string(utils.FlagFinisher) ||
|
||||
flag == string(utils.FlagObat) ||
|
||||
flag == string(utils.FlagVitamin) ||
|
||||
flag == string(utils.FlagKimia) ||
|
||||
flag == string(utils.FlagEkspedisi) ||
|
||||
flag == string(utils.FlagTelur) ||
|
||||
flag == string(utils.FlagTelurUtuh) ||
|
||||
flag == string(utils.FlagTelurPecah) ||
|
||||
flag == string(utils.FlagTelurPutih) ||
|
||||
flag == string(utils.FlagTelurRetak) {
|
||||
return 0, 0
|
||||
}
|
||||
}
|
||||
|
||||
@@ -156,8 +175,12 @@ func calculateAgeFromChickin(projectFlockKandang *entity.ProjectFlockKandang, de
|
||||
if ageInDays <= 0 {
|
||||
ageInWeeks = 0
|
||||
} else {
|
||||
|
||||
ageInWeeks = ((ageInDays - 1) / 7) + 1
|
||||
if category == string(utils.ProjectFlockCategoryLaying) {
|
||||
ageInDays = ageInDays + 119
|
||||
ageInWeeks = ((ageInDays - 1) / 7) + 1
|
||||
} else {
|
||||
ageInWeeks = ((ageInDays - 1) / 7) + 1
|
||||
}
|
||||
}
|
||||
|
||||
return ageInDays, ageInWeeks
|
||||
|
||||
Reference in New Issue
Block a user