Update API Sales

This commit is contained in:
2025-06-23 15:32:27 +07:00
parent dc8aafbbc1
commit 997c2b624f
5 changed files with 26 additions and 24 deletions
+1
View File
@@ -8,6 +8,7 @@ type Customer struct {
Address string `json:"address"`
Phone string `json:"phone"`
Email string `json:"email"`
Type string `json:"type"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
+12 -7
View File
@@ -3,13 +3,18 @@ package models
import "time"
type Invoice struct {
ID uint `gorm:"primaryKey" json:"id"`
SalesOrderID uint `json:"sales_order_id"`
InvoiceDate time.Time `json:"invoice_date"`
DueDate time.Time `json:"due_date"`
TotalAmount float64 `json:"total_amount"`
Status string `json:"status"` // contoh: unpaid, partial, paid
Note string `json:"note"`
ID uint `gorm:"primaryKey" json:"id"`
SalesOrderID uint `json:"sales_order_id"`
InvoiceNumber string `gorm:"not null;unique" json:"invoice_number"`
InvoiceDate time.Time `json:"invoice_date"`
DueDate time.Time `json:"due_date"`
TotalAmount float64 `json:"total_amount"`
Status string `json:"status"` // contoh: unpaid, partial, paid
Note string `json:"note"`
IsDpInvoice bool `json:"is_dp_invoice"` // Apakah ini invoice DP (Down Payment)
Amount float64 `json:"amount"` // Jumlah DP jika ada
ParentInvoiceID uint `json:"parent_invoice_id,omitempty"` // ID invoice induk jika ini adalah invoice lanjutan
ParentInvoice *Invoice `gorm:"foreignKey:ParentInvoiceID" json:"parent_invoice,omitempty"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
+7 -6
View File
@@ -3,12 +3,13 @@ package models
import "time"
type Payment struct {
ID uint `gorm:"primaryKey" json:"id"`
InvoiceID uint `json:"invoice_id"`
Amount float64 `json:"amount"`
PaidAt time.Time `json:"paid_at"`
Method string `json:"method"` // contoh: cash, bank transfer, credit card
Note string `json:"note"`
ID uint `gorm:"primaryKey" json:"id"`
InvoiceID uint `json:"invoice_id"`
Amount float64 `json:"amount"`
PaymentAt time.Time `json:"payment_at"`
PaymentMethod string `json:"payment_method"` // contoh: cash, bank transfer, credit card
FilePath string `json:"file_path"` // Path ke file bukti pembayaran
Note string `json:"note"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
-2
View File
@@ -11,8 +11,6 @@ type SalesOrder struct {
Note string `json:"note"`
PaymentTerms string `json:"payment_terms"`
DueDate time.Time `json:"due_date"`
DPAmount float64 `json:"dp_amount"`
DPPaid float64 `json:"dp_paid"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`