add notes

This commit is contained in:
aditya.siregar 2025-05-16 13:18:11 +07:00
parent dea7d4c2b3
commit 2b1c49ad63
7 changed files with 18 additions and 2 deletions

View File

@ -92,6 +92,7 @@ type OrderItem struct {
Product *Product `gorm:"foreignKey:ItemID;references:ID"` Product *Product `gorm:"foreignKey:ItemID;references:ID"`
ItemName string `gorm:"type:varchar;column:item_name"` ItemName string `gorm:"type:varchar;column:item_name"`
Description string `gorm:"type:varchar;column:description"` Description string `gorm:"type:varchar;column:description"`
Notes string `gorm:"type:varchar;column:notes"`
} }
func (OrderItem) TableName() string { func (OrderItem) TableName() string {
@ -118,6 +119,7 @@ type OrderItemRequest struct {
ProductID int64 `json:"product_id" validate:"required"` ProductID int64 `json:"product_id" validate:"required"`
Quantity int `json:"quantity" validate:"required"` Quantity int `json:"quantity" validate:"required"`
Description string `json:"description"` Description string `json:"description"`
Notes string `json:"notes"`
} }
type OrderExecuteRequest struct { type OrderExecuteRequest struct {

View File

@ -87,6 +87,7 @@ func (oi *OrderInquiry) AddOrderItem(item OrderItemRequest, product *Product) {
Quantity: item.Quantity, Quantity: item.Quantity,
CreatedBy: oi.CreatedBy, CreatedBy: oi.CreatedBy,
Product: product, Product: product,
Notes: item.Notes,
}) })
} }
@ -122,6 +123,7 @@ func (i *OrderInquiry) ToOrder(paymentMethod, paymentProvider string) *Order {
CreatedBy: i.CreatedBy, CreatedBy: i.CreatedBy,
CreatedAt: now, CreatedAt: now,
Product: item.Product, Product: item.Product,
Notes: item.Notes,
} }
} }

View File

@ -58,8 +58,9 @@ func (o *InquiryRequest) GetPaymentProvider() string {
} }
type OrderItemRequest struct { type OrderItemRequest struct {
ProductID int64 `json:"product_id" validate:"required"` ProductID int64 `json:"product_id" validate:"required"`
Quantity int `json:"quantity" validate:"required,min=1"` Quantity int `json:"quantity" validate:"required,min=1"`
Notes string `json:"notes"`
} }
type ExecuteRequest struct { type ExecuteRequest struct {
@ -91,6 +92,7 @@ func (h *Handler) Inquiry(c *gin.Context) {
orderItems[i] = entity.OrderItemRequest{ orderItems[i] = entity.OrderItemRequest{
ProductID: item.ProductID, ProductID: item.ProductID,
Quantity: item.Quantity, Quantity: item.Quantity,
Notes: item.Notes,
} }
} }

View File

@ -95,6 +95,7 @@ type OrderItem struct {
ProductID int64 `json:"product_id" validate:"required"` ProductID int64 `json:"product_id" validate:"required"`
Quantity int `json:"quantity" validate:"required"` Quantity int `json:"quantity" validate:"required"`
Description string `json:"description"` Description string `json:"description"`
Notes string `json:"notes"`
} }
func (o *Order) ToEntity(partnerID, createdBy int64) *entity.OrderRequest { func (o *Order) ToEntity(partnerID, createdBy int64) *entity.OrderRequest {
@ -162,6 +163,7 @@ func (o *OrderCustomer) ToEntity(partnerID, createdBy int64) *entity.OrderReques
ProductID: item.ProductID, ProductID: item.ProductID,
Quantity: item.Quantity, Quantity: item.Quantity,
Description: item.Description, Description: item.Description,
Notes: item.Notes,
} }
} }

View File

@ -28,6 +28,7 @@ type OrderItemResponse struct {
Price float64 `json:"price"` Price float64 `json:"price"`
Quantity int `json:"quantity"` Quantity int `json:"quantity"`
Subtotal float64 `json:"subtotal"` Subtotal float64 `json:"subtotal"`
Notes string `json:"notes"`
} }
func mapToOrderItemResponses(items []entity.OrderItem) []OrderItemResponse { func mapToOrderItemResponses(items []entity.OrderItem) []OrderItemResponse {
@ -113,6 +114,7 @@ func MapToOrderItemResponses(items []entity.OrderItem) []OrderItemResponse {
Price: item.Price, Price: item.Price,
Quantity: item.Quantity, Quantity: item.Quantity,
Subtotal: item.Price * float64(item.Quantity), Subtotal: item.Price * float64(item.Quantity),
Notes: item.Notes,
}) })
} }
return result return result

View File

@ -40,6 +40,7 @@ type OrderItemDB struct {
CreatedBy int64 `gorm:"column:created_by"` CreatedBy int64 `gorm:"column:created_by"`
CreatedAt time.Time `gorm:"column:created_at"` CreatedAt time.Time `gorm:"column:created_at"`
Product ProductDB `gorm:"foreignKey:ItemID;references:ID"` Product ProductDB `gorm:"foreignKey:ItemID;references:ID"`
Notes string `gorm:"column:notes"`
} }
func (OrderItemDB) TableName() string { func (OrderItemDB) TableName() string {
@ -83,6 +84,7 @@ type InquiryItemDB struct {
Quantity int `gorm:"column:quantity"` Quantity int `gorm:"column:quantity"`
CreatedBy int64 `gorm:"column:created_by"` CreatedBy int64 `gorm:"column:created_by"`
CreatedAt time.Time `gorm:"column:created_at"` CreatedAt time.Time `gorm:"column:created_at"`
Notes string `gorm:"column:notes"`
} }
func (InquiryItemDB) TableName() string { func (InquiryItemDB) TableName() string {

View File

@ -148,6 +148,7 @@ func (r *orderRepository) CreateInquiry(ctx mycontext.Context, inquiry *entity.O
Quantity: item.Quantity, Quantity: item.Quantity,
CreatedBy: item.CreatedBy, CreatedBy: item.CreatedBy,
CreatedAt: time.Now(), CreatedAt: time.Now(),
Notes: item.Notes,
}) })
} }
@ -202,6 +203,7 @@ func (r *orderRepository) FindInquiryByID(ctx mycontext.Context, id string) (*en
Quantity: itemDB.Quantity, Quantity: itemDB.Quantity,
CreatedBy: itemDB.CreatedBy, CreatedBy: itemDB.CreatedBy,
CreatedAt: itemDB.CreatedAt, CreatedAt: itemDB.CreatedAt,
Notes: itemDB.Notes,
}) })
} }
inquiry.OrderItems = orderItems inquiry.OrderItems = orderItems
@ -264,6 +266,7 @@ func (r *orderRepository) toDomainOrderModel(dbModel *models.OrderDB) *entity.Or
Quantity: itemDB.Quantity, Quantity: itemDB.Quantity,
CreatedBy: itemDB.CreatedBy, CreatedBy: itemDB.CreatedBy,
CreatedAt: itemDB.CreatedAt, CreatedAt: itemDB.CreatedAt,
Notes: itemDB.Notes,
}) })
} }
@ -300,6 +303,7 @@ func (r *orderRepository) toOrderItemDBModel(item *entity.OrderItem) models.Orde
Quantity: item.Quantity, Quantity: item.Quantity,
CreatedBy: item.CreatedBy, CreatedBy: item.CreatedBy,
CreatedAt: item.CreatedAt, CreatedAt: item.CreatedAt,
Notes: item.Notes,
} }
} }