mirror of
https://gitlab.com/mbugroup/lti-api.git
synced 2026-05-25 07:45:44 +00:00
Fix adjusment stock chickin, transfer to laying and chickin
This commit is contained in:
@@ -152,6 +152,46 @@ func ToLayingTransferSourceDTOs(sources []entity.LayingTransferSource) []LayingT
|
||||
return result
|
||||
}
|
||||
|
||||
func toLayingTransferSourceDTOsFromTransfer(e entity.LayingTransfer) []LayingTransferSourceDTO {
|
||||
if len(e.Sources) > 0 {
|
||||
return ToLayingTransferSourceDTOs(e.Sources)
|
||||
}
|
||||
if e.SourceProjectFlockKandangId == nil || *e.SourceProjectFlockKandangId == 0 {
|
||||
return []LayingTransferSourceDTO{}
|
||||
}
|
||||
|
||||
displayQty := e.SourceRequestedQty
|
||||
if e.SourceUsageQty > 0 {
|
||||
displayQty = e.SourceUsageQty
|
||||
}
|
||||
|
||||
pfkDTO := &ProjectFlockKandangWithKandangDTO{
|
||||
Id: *e.SourceProjectFlockKandangId,
|
||||
}
|
||||
if e.SourceProjectFlockKandang != nil && e.SourceProjectFlockKandang.Id != 0 {
|
||||
pfkDTO.KandangId = e.SourceProjectFlockKandang.KandangId
|
||||
pfkDTO.ProjectFlockId = e.SourceProjectFlockKandang.ProjectFlockId
|
||||
if e.SourceProjectFlockKandang.Kandang.Id != 0 {
|
||||
kandangMapped := kandangDTO.ToKandangRelationDTO(e.SourceProjectFlockKandang.Kandang)
|
||||
pfkDTO.Kandang = &kandangMapped
|
||||
}
|
||||
}
|
||||
|
||||
var pwDTO *productWarehouseDTO.ProductWarehouseRelationDTO
|
||||
if e.SourceProductWarehouse != nil && e.SourceProductWarehouse.Id != 0 {
|
||||
mapped := productWarehouseDTO.ToProductWarehouseRelationDTO(*e.SourceProductWarehouse)
|
||||
pwDTO = &mapped
|
||||
}
|
||||
|
||||
return []LayingTransferSourceDTO{
|
||||
{
|
||||
SourceProjectFlockKandang: pfkDTO,
|
||||
Qty: displayQty,
|
||||
ProductWarehouse: pwDTO,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func ToLayingTransferTargetDTO(target entity.LayingTransferTarget) LayingTransferTargetDTO {
|
||||
var pfkDTO *ProjectFlockKandangWithKandangDTO
|
||||
if target.TargetProjectFlockKandang != nil && target.TargetProjectFlockKandang.Id != 0 {
|
||||
@@ -256,7 +296,7 @@ func ToTransferLayingDetailDTO(e entity.LayingTransfer, approvals []entity.Appro
|
||||
|
||||
return TransferLayingDetailDTO{
|
||||
TransferLayingListDTO: ToTransferLayingListDTO(e),
|
||||
Sources: ToLayingTransferSourceDTOs(e.Sources),
|
||||
Sources: toLayingTransferSourceDTOsFromTransfer(e),
|
||||
Targets: ToLayingTransferTargetDTOs(e.Targets),
|
||||
Approval: latestApproval,
|
||||
}
|
||||
@@ -278,7 +318,7 @@ func ToTransferLayingDetailDTOWithSingleApproval(e entity.LayingTransfer, approv
|
||||
|
||||
return TransferLayingDetailDTO{
|
||||
TransferLayingListDTO: ToTransferLayingListDTO(e),
|
||||
Sources: ToLayingTransferSourceDTOs(e.Sources),
|
||||
Sources: toLayingTransferSourceDTOsFromTransfer(e),
|
||||
Targets: ToLayingTransferTargetDTOs(e.Targets),
|
||||
Approval: mappedApproval,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user