fix(BE-273): add object nonstock and supplier in response get one and fix name base to relation in dto

This commit is contained in:
Hafizh A. Y
2025-11-20 14:59:50 +07:00
parent b4b860b9d4
commit 228aedc215
64 changed files with 964 additions and 3576 deletions
+14 -14
View File
@@ -9,7 +9,7 @@ import (
// === DTO Structs ===
type ExpenseBaseDTO struct {
type ExpenseRelationDTO struct {
Id uint64 `json:"id"`
PoNumber string `json:"po_number"`
ExpenseDate time.Time `json:"expense_date"`
@@ -17,21 +17,21 @@ type ExpenseBaseDTO struct {
}
type ExpenseListDTO struct {
Id uint64 `json:"id"`
ReferenceNumber string `json:"reference_number"`
PoNumber string `json:"po_number"`
Category string `json:"category"`
ExpenseDate time.Time `json:"expense_date"`
GrandTotal float64 `json:"grand_total"`
CreatedUser *userDTO.UserBaseDTO `json:"created_user,omitempty"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
Id uint64 `json:"id"`
ReferenceNumber string `json:"reference_number"`
PoNumber string `json:"po_number"`
Category string `json:"category"`
ExpenseDate time.Time `json:"expense_date"`
GrandTotal float64 `json:"grand_total"`
CreatedUser *userDTO.UserRelationDTO `json:"created_user,omitempty"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
// === Mapper Functions ===
func ToExpenseBaseDTO(e entity.Expense) ExpenseBaseDTO {
return ExpenseBaseDTO{
func ToExpenseRelationDTO(e entity.Expense) ExpenseRelationDTO {
return ExpenseRelationDTO{
Id: e.Id,
PoNumber: e.PoNumber,
ExpenseDate: e.ExpenseDate,
@@ -40,9 +40,9 @@ func ToExpenseBaseDTO(e entity.Expense) ExpenseBaseDTO {
}
func ToExpenseListDTO(e entity.Expense) ExpenseListDTO {
var createdUser *userDTO.UserBaseDTO
var createdUser *userDTO.UserRelationDTO
if e.CreatedUser.Id != 0 {
mapped := userDTO.ToUserBaseDTO(*e.CreatedUser)
mapped := userDTO.ToUserRelationDTO(*e.CreatedUser)
createdUser = &mapped
}