mirror of
https://gitlab.com/mbugroup/lti-api.git
synced 2026-05-24 07:15:43 +00:00
feat: refactor module adjusment stock, adjust constant, adjust table migration and create command reflow and delete module adjusment stock
This commit is contained in:
@@ -17,27 +17,49 @@ type ProductRelationDTO struct {
|
||||
ProductCategory *productCategoryDTO.ProductCategoryRelationDTO `json:"product_category,omitempty"`
|
||||
}
|
||||
|
||||
type WarehouseRelationDTO struct {
|
||||
type LocationRelationDTO struct {
|
||||
Id uint `json:"id"`
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
type ProjectFlockRelationDTO struct {
|
||||
Id uint `json:"id"`
|
||||
FlockName string `json:"flock_name"`
|
||||
Period int `json:"period"`
|
||||
}
|
||||
|
||||
type WarehouseRelationDTO struct {
|
||||
Id uint `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Location *LocationRelationDTO `json:"location,omitempty"`
|
||||
}
|
||||
|
||||
type ProductWarehouseDTO struct {
|
||||
Id uint `json:"id"`
|
||||
ProductId uint `json:"product_id"`
|
||||
WarehouseId uint `json:"warehouse_id"`
|
||||
Quantity float64 `json:"quantity"`
|
||||
Product *ProductRelationDTO `json:"product,omitempty"`
|
||||
Warehouse *WarehouseRelationDTO `json:"warehouse,omitempty"`
|
||||
Id uint `json:"id"`
|
||||
ProductId uint `json:"product_id"`
|
||||
WarehouseId uint `json:"warehouse_id"`
|
||||
Quantity float64 `json:"quantity"`
|
||||
Product *ProductRelationDTO `json:"product,omitempty"`
|
||||
Warehouse *WarehouseRelationDTO `json:"warehouse,omitempty"`
|
||||
ProjectFlock *ProjectFlockRelationDTO `json:"project_flock,omitempty"`
|
||||
}
|
||||
|
||||
type AdjustmentRelationDTO struct {
|
||||
Id uint `json:"id"`
|
||||
Increase float64 `json:"increase"`
|
||||
Decrease float64 `json:"decrease"`
|
||||
Note string `json:"note,omitempty"`
|
||||
ProductWarehouseId uint `json:"product_warehouse_id"`
|
||||
ProductWarehouse *ProductWarehouseDTO `json:"product_warehouse,omitempty"`
|
||||
Id uint `json:"id"`
|
||||
AdjNumber string `json:"adj_number"`
|
||||
TransactionType string `json:"transaction_type"`
|
||||
TransactionSubtype string `json:"transaction_subtype"`
|
||||
FunctionCode string `json:"function_code"`
|
||||
Qty float64 `json:"qty"`
|
||||
Price float64 `json:"price"`
|
||||
GrandTotal float64 `json:"grand_total"`
|
||||
Increase float64 `json:"increase"`
|
||||
Decrease float64 `json:"decrease"`
|
||||
Notes string `json:"notes,omitempty"`
|
||||
Location *LocationRelationDTO `json:"location,omitempty"`
|
||||
ProjectFlock *ProjectFlockRelationDTO `json:"project_flock,omitempty"`
|
||||
ProductWarehouseId uint `json:"product_warehouse_id"`
|
||||
ProductWarehouse *ProductWarehouseDTO `json:"product_warehouse,omitempty"`
|
||||
}
|
||||
|
||||
type AdjustmentListDTO struct {
|
||||
@@ -81,31 +103,80 @@ func ToWarehouseRelationDTO(e *entity.Warehouse) *WarehouseRelationDTO {
|
||||
return nil
|
||||
}
|
||||
return &WarehouseRelationDTO{
|
||||
Id: e.Id,
|
||||
Name: e.Name,
|
||||
Location: ToLocationRelationDTO(e.Location),
|
||||
}
|
||||
}
|
||||
|
||||
func ToLocationRelationDTO(e *entity.Location) *LocationRelationDTO {
|
||||
if e == nil {
|
||||
return nil
|
||||
}
|
||||
return &LocationRelationDTO{
|
||||
Id: e.Id,
|
||||
Name: e.Name,
|
||||
}
|
||||
}
|
||||
|
||||
func ToProjectFlockRelationDTO(e *entity.ProjectFlockKandang) *ProjectFlockRelationDTO {
|
||||
if e == nil || e.ProjectFlock.Id == 0 {
|
||||
return nil
|
||||
}
|
||||
return &ProjectFlockRelationDTO{
|
||||
Id: e.ProjectFlock.Id,
|
||||
FlockName: e.ProjectFlock.FlockName,
|
||||
Period: e.Period,
|
||||
}
|
||||
}
|
||||
|
||||
func ToProductWarehouseDTO(e *entity.ProductWarehouse) *ProductWarehouseDTO {
|
||||
if e == nil {
|
||||
return nil
|
||||
}
|
||||
return &ProductWarehouseDTO{
|
||||
Id: e.Id,
|
||||
ProductId: e.ProductId,
|
||||
WarehouseId: e.WarehouseId,
|
||||
Quantity: e.Quantity,
|
||||
Product: ToProductRelationDTO(&e.Product),
|
||||
Warehouse: ToWarehouseRelationDTO(&e.Warehouse),
|
||||
Id: e.Id,
|
||||
ProductId: e.ProductId,
|
||||
WarehouseId: e.WarehouseId,
|
||||
Quantity: e.Quantity,
|
||||
Product: ToProductRelationDTO(&e.Product),
|
||||
Warehouse: ToWarehouseRelationDTO(&e.Warehouse),
|
||||
ProjectFlock: ToProjectFlockRelationDTO(e.ProjectFlockKandang),
|
||||
}
|
||||
}
|
||||
|
||||
func ToAdjustmentRelationDTO(e *entity.AdjustmentStock) AdjustmentRelationDTO {
|
||||
note := ""
|
||||
if e.StockLog != nil {
|
||||
note = e.StockLog.Notes
|
||||
}
|
||||
|
||||
qty := e.TotalQty
|
||||
if qty <= 0 {
|
||||
qty = e.UsageQty + e.PendingQty
|
||||
}
|
||||
|
||||
var location *LocationRelationDTO
|
||||
var projectFlock *ProjectFlockRelationDTO
|
||||
if e.ProductWarehouse != nil {
|
||||
location = ToLocationRelationDTO(e.ProductWarehouse.Warehouse.Location)
|
||||
projectFlock = ToProjectFlockRelationDTO(e.ProductWarehouse.ProjectFlockKandang)
|
||||
}
|
||||
|
||||
return AdjustmentRelationDTO{
|
||||
Id: e.Id,
|
||||
Note: "",
|
||||
AdjNumber: e.AdjNumber,
|
||||
TransactionType: e.TransactionType,
|
||||
TransactionSubtype: e.FunctionCode,
|
||||
FunctionCode: e.FunctionCode,
|
||||
Qty: qty,
|
||||
Price: e.Price,
|
||||
GrandTotal: e.GrandTotal,
|
||||
Increase: e.TotalQty,
|
||||
Decrease: e.UsageQty,
|
||||
Notes: note,
|
||||
Location: location,
|
||||
ProjectFlock: projectFlock,
|
||||
ProductWarehouseId: e.ProductWarehouseId,
|
||||
ProductWarehouse: ToProductWarehouseDTO(e.ProductWarehouse),
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user