101 lines
3.9 KiB
Go
101 lines
3.9 KiB
Go
package dto
|
|
|
|
import (
|
|
"errors"
|
|
|
|
"github.com/Caknoooo/go-gin-clean-starter/database/entities"
|
|
pkgdto "github.com/Caknoooo/go-gin-clean-starter/pkg/dto"
|
|
"github.com/Caknoooo/go-gin-clean-starter/pkg/utils"
|
|
)
|
|
|
|
const (
|
|
MESSAGE_FAILED_CREATE_INVENTORY_TRANSACTION = "failed create inventory transaction"
|
|
MESSAGE_SUCCESS_CREATE_INVENTORY_TRANSACTION = "success create inventory transaction"
|
|
MESSAGE_FAILED_GET_INVENTORY_TRANSACTION = "failed get inventory transaction"
|
|
MESSAGE_SUCCESS_GET_INVENTORY_TRANSACTION = "success get inventory transaction"
|
|
MESSAGE_FAILED_UPDATE_INVENTORY_TRANSACTION = "failed update inventory transaction"
|
|
MESSAGE_SUCCESS_UPDATE_INVENTORY_TRANSACTION = "success update inventory transaction"
|
|
MESSAGE_FAILED_DELETE_INVENTORY_TRANSACTION = "failed delete inventory transaction"
|
|
MESSAGE_SUCCESS_DELETE_INVENTORY_TRANSACTION = "success delete inventory transaction"
|
|
MESSAGE_FAILED_GET_DATA_FROM_BODY = "failed get data from body"
|
|
)
|
|
|
|
var (
|
|
ErrCreateInventoryTransaction = errors.New("failed to create inventory transaction")
|
|
ErrGetInventoryTransactionById = errors.New("failed to get inventory transaction by id")
|
|
ErrUpdateInventoryTransaction = errors.New("failed to update inventory transaction")
|
|
ErrDeleteInventoryTransaction = errors.New("failed to delete inventory transaction")
|
|
)
|
|
|
|
type InventoryTransactionCreateRequest struct {
|
|
TransactionType string `json:"transaction_type" binding:"required"`
|
|
TransactionDate string `json:"transaction_date" binding:"required"`
|
|
ProductID string `json:"product_id" binding:"required"`
|
|
AisleID string `json:"aisle_id"`
|
|
ClientID string `json:"client_id" binding:"required"`
|
|
InvReceiptID string `json:"inv_receipt_id"`
|
|
InvIssueID string `json:"inv_issue_id"`
|
|
InvMoveID string `json:"inv_move_id"`
|
|
}
|
|
|
|
type InventoryTransactionUpdateRequest struct {
|
|
TransactionType string `json:"transaction_type"`
|
|
TransactionDate string `json:"transaction_date"`
|
|
ProductID string `json:"product_id"`
|
|
AisleID string `json:"aisle_id"`
|
|
InvReceiptID string `json:"inv_receipt_id"`
|
|
InvIssueID string `json:"inv_issue_id"`
|
|
InvMoveID string `json:"inv_move_id"`
|
|
}
|
|
|
|
type InventoryTransactionResponse struct {
|
|
ID string `json:"id"`
|
|
TransactionType string `json:"transaction_type"`
|
|
TransactionDate string `json:"transaction_date"`
|
|
Product InvTransactionProductResponse `json:"product"`
|
|
Aisle pkgdto.IdNameResponse `json:"aisle"`
|
|
InvReceipt pkgdto.InventoryResponse `json:"inv_receipt"`
|
|
InvIssue pkgdto.InventoryResponse `json:"inv_issue"`
|
|
InvMove pkgdto.InventoryResponse `json:"inv_move"`
|
|
Client pkgdto.IdNameResponse `json:"client"`
|
|
}
|
|
|
|
type InvTransactionProductResponse struct {
|
|
ID string `json:"id"`
|
|
RefNumber string `json:"ref_number"`
|
|
Name string `json:"name"`
|
|
}
|
|
|
|
func ToInventoryTransactionResponse(e entities.InventoryTransactionEntity) InventoryTransactionResponse {
|
|
return InventoryTransactionResponse{
|
|
ID: e.ID.String(),
|
|
TransactionType: e.TransactionType,
|
|
TransactionDate: utils.DateTimeToString(e.TransactionDate),
|
|
Product: InvTransactionProductResponse{
|
|
ID: e.Product.ID.String(),
|
|
RefNumber: e.Product.RefNumber,
|
|
Name: e.Product.Name,
|
|
},
|
|
Aisle: pkgdto.IdNameResponse{
|
|
ID: e.Aisle.ID.String(),
|
|
Name: e.Aisle.Name,
|
|
},
|
|
Client: pkgdto.IdNameResponse{
|
|
ID: e.Client.ID.String(),
|
|
Name: e.Client.Name,
|
|
},
|
|
InvReceipt: pkgdto.InventoryResponse{
|
|
ID: e.InvReceipt.ID.String(),
|
|
DocumentNumber: e.InvReceipt.DocumentNumber,
|
|
},
|
|
InvIssue: pkgdto.InventoryResponse{
|
|
ID: e.InvIssue.ID.String(),
|
|
DocumentNumber: e.InvIssue.DocumentNumber,
|
|
},
|
|
InvMove: pkgdto.InventoryResponse{
|
|
ID: e.InvMove.ID.String(),
|
|
DocumentNumber: e.InvMove.MovementNumber,
|
|
},
|
|
}
|
|
}
|