package dto import ( "github.com/Caknoooo/go-gin-clean-starter/database/entities" pkgdto "github.com/Caknoooo/go-gin-clean-starter/pkg/dto" "github.com/google/uuid" ) const ( MESSAGE_FAILED_CREATE_INVENTORY_RECEIPT = "failed create inventory receipt" MESSAGE_FAILED_CREATE_INVENTORY_RECEIPT_LINE = "failed create inventory receipt line" MESSAGE_SUCCESS_CREATE_INVENTORY_RECEIPT = "success create inventory receipt" MESSAGE_SUCCESS_CREATE_INVENTORY_RECEIPT_LINE = "success create inventory receipt line" MESSAGE_FAILED_GET_INVENTORY_RECEIPT = "failed get inventory receipt" MESSAGE_SUCCESS_GET_INVENTORY_RECEIPT = "success get inventory receipt" MESSAGE_FAILED_UPDATE_INVENTORY_RECEIPT = "failed update inventory receipt" MESSAGE_FAILED_UPDATE_INVENTORY_RECEIPT_LINE = "failed update inventory receipt line" MESSAGE_SUCCESS_UPDATE_INVENTORY_RECEIPT = "success update inventory receipt" MESSAGE_SUCCESS_UPDATE_INVENTORY_RECEIPT_LINE = "success update inventory receipt line" MESSAGE_FAILED_DELETE_INVENTORY_RECEIPT = "failed delete inventory receipt" MESSAGE_FAILED_DELETE_INVENTORY_RECEIPT_LINE = "failed delete inventory receipt line" MESSAGE_SUCCESS_DELETE_INVENTORY_RECEIPT = "success delete inventory receipt" MESSAGE_SUCCESS_DELETE_INVENTORY_RECEIPT_LINE = "success delete inventory receipt line" MESSAGE_FAILED_GET_DATA_FROM_BODY = "failed get data from body" MESSAGE_SUCCESS_COMPLETE_INVENTORY_RECEIPT = "success complete inventory receipt" MESSAGE_FAILED_COMPLETE_INVENTORY_RECEIPT = "failed complete inventory receipt" MESSAGE_FAILED_GET_INVENTORY_RECEIPT_LINES = "failed get inventory receipt lines" MESSAGE_SUCCESS_GET_INVENTORY_RECEIPT_LINES = "success get inventory receipt lines" ) type InventoryReceiptCreateRequest struct { ReferenceNumber string `json:"reference_number"` DocumentDate string `json:"document_date"` Source string `json:"source"` QrCodeFile string `json:"qr_code_file"` ClientID string `json:"client_id" binding:"required"` Status string `json:"status"` ReceiptLines []InventoryReceiptLineCreateRequest `json:"receipt_lines,omitempty" binding:"dive"` } type InventoryReceiptLineCreateRequest struct { Quantity float64 `json:"quantity"` BatchNumber string `json:"batch_number"` RepackingSuggestion string `json:"repacking_suggestion"` RepackUomID string `json:"repack_uom_id"` RepackUomCode string `json:"repack_uom_code"` ProductID string `json:"product_id"` ProductCode string `json:"product_code"` ClientID string `json:"client_id"` } type InventoryReceiptUpdateRequest struct { ReferenceNumber string `json:"reference_number"` DocumentDate string `json:"document_date"` Source string `json:"source"` QrCodeFile string `json:"qr_code_file"` Status string `json:"status"` } type InventoryReceiptResponse struct { ID string `json:"id"` ReferenceNumber string `json:"reference_number"` DocumentNumber string `json:"document_number"` DocumentDate string `json:"document_date"` Source string `json:"source"` QrCodeFile string `json:"qr_code_file"` Status string `json:"status"` Client pkgdto.IdNameResponse `json:"client"` // ReceiptLines []InventoryReceiptLineResponse `json:"receipt_lines"` // LineCount int `json:"line_count"` Assignment *AssignmentResponse `json:"assignment"` } type AssignmentResponse struct { ID string `json:"id"` DocumentType string `json:"document_type"` DocumentID string `json:"document_id"` // Client pkgdto.IdNameResponse `json:"client"` AssignmentUsers []AssignmentUserResponse `json:"assignment_users"` } type AssignmentUserResponse struct { ID string `json:"id"` TaskType string `json:"task_type"` User pkgdto.IdNameResponse `json:"user"` Role pkgdto.IdNameResponse `json:"role"` // Client pkgdto.IdNameResponse `json:"client"` } type InventoryReceiptLineResponse struct { ID string `json:"id"` Quantity float64 `json:"quantity"` BatchNumber string `json:"batch_number"` RepackingSuggestion string `json:"repacking_suggestion"` RepackUomID *string `json:"repack_uom_id"` Product InventoryReceiptLineProductResponse `json:"product"` ClientID string `json:"client_id"` } type InventoryReceiptLineProductResponse struct { ID string `json:"id"` Name string `json:"name"` RefNumber string `json:"ref_number"` Uom pkgdto.IdNameResponse `json:"uom"` DimLength float64 `json:"dim_length"` DimWidth float64 `json:"dim_width"` DimHeight float64 `json:"dim_height"` DimUom pkgdto.IdNameResponse `json:"dim_uom"` } type InventoryReceiptLineUpdateRequest struct { Quantity *float64 `json:"quantity"` BatchNumber *string `json:"batch_number"` RepackingSuggestion *string `json:"repacking_suggestion"` RepackUomID *string `json:"repack_uom_id"` ProductID *string `json:"product_id"` } func ToInventoryReceiptLineResponse(line entities.TInventoryReceiptLineEntity) InventoryReceiptLineResponse { var repackUomID *string if line.RepackUomID != nil { tmp := line.RepackUomID.String() repackUomID = &tmp } product := InventoryReceiptLineProductResponse{} if line.Product.ID != uuid.Nil { product = InventoryReceiptLineProductResponse{ ID: line.Product.ID.String(), Name: line.Product.Name, } } return InventoryReceiptLineResponse{ ID: line.ID.String(), Quantity: line.Quantity, BatchNumber: line.BatchNumber, RepackingSuggestion: line.RepackingSuggestion, RepackUomID: repackUomID, Product: product, ClientID: line.ClientID.String(), } }