Update API Sales

This commit is contained in:
ahmadafriadi 2025-06-23 15:32:27 +07:00
parent dc8aafbbc1
commit 997c2b624f
5 changed files with 26 additions and 24 deletions

View File

@ -98,7 +98,8 @@ CREATE TABLE customer (
name VARCHAR(100), name VARCHAR(100),
address TEXT, address TEXT,
phone VARCHAR(20), phone VARCHAR(20),
email VARCHAR(100) email VARCHAR(100),
type VARCHAR(20),
); );
CREATE TABLE sales_order ( CREATE TABLE sales_order (
@ -109,10 +110,7 @@ CREATE TABLE sales_order (
total_amount NUMERIC, total_amount NUMERIC,
note TEXT, note TEXT,
payment_terms VARCHAR(100), payment_terms VARCHAR(100),
due_date DATE, due_date DATE
is_dp BOOLEAN,
dp_ammount NUMERIC,
dp_paid BOOLEAN
); );
CREATE TABLE sales_order_item ( CREATE TABLE sales_order_item (
@ -121,7 +119,6 @@ CREATE TABLE sales_order_item (
product_id INT REFERENCES master_product(id), product_id INT REFERENCES master_product(id),
quantity NUMERIC, quantity NUMERIC,
unit_price NUMERIC, unit_price NUMERIC,
discount NUMERIC,
sub_total NUMERIC sub_total NUMERIC
); );
@ -133,6 +130,7 @@ CREATE TABLE invoice (
due_date DATE, due_date DATE,
status VARCHAR(50), status VARCHAR(50),
total_amount NUMERIC, total_amount NUMERIC,
note TEXT,
is_dp_invoice BOOLEAN, is_dp_invoice BOOLEAN,
is_full_invoice BOOLEAN, is_full_invoice BOOLEAN,
parent_invoice_id INT parent_invoice_id INT
@ -144,16 +142,15 @@ CREATE TABLE invoice_line (
product_id INT REFERENCES master_product(id), product_id INT REFERENCES master_product(id),
quantity NUMERIC, quantity NUMERIC,
unit_price NUMERIC, unit_price NUMERIC,
discount NUMERIC,
sub_total NUMERIC sub_total NUMERIC
); );
CREATE TABLE payment ( CREATE TABLE payment (
id SERIAL PRIMARY KEY, id SERIAL PRIMARY KEY,
invoice_id INT REFERENCES invoice(id), invoice_id INT REFERENCES invoice(id),
payment_date DATE, payment_at TIMESTAMP,
amount NUMERIC, amount NUMERIC,
payment_method VARCHAR(100), payment_method VARCHAR(100),
reference_number VARCHAR(100), file_path VARCHAR(250),
notes TEXT notes TEXT
); );

View File

@ -8,6 +8,7 @@ type Customer struct {
Address string `json:"address"` Address string `json:"address"`
Phone string `json:"phone"` Phone string `json:"phone"`
Email string `json:"email"` Email string `json:"email"`
Type string `json:"type"`
CreatedAt time.Time `json:"created_at"` CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"` UpdatedAt time.Time `json:"updated_at"`

View File

@ -5,11 +5,16 @@ import "time"
type Invoice struct { type Invoice struct {
ID uint `gorm:"primaryKey" json:"id"` ID uint `gorm:"primaryKey" json:"id"`
SalesOrderID uint `json:"sales_order_id"` SalesOrderID uint `json:"sales_order_id"`
InvoiceNumber string `gorm:"not null;unique" json:"invoice_number"`
InvoiceDate time.Time `json:"invoice_date"` InvoiceDate time.Time `json:"invoice_date"`
DueDate time.Time `json:"due_date"` DueDate time.Time `json:"due_date"`
TotalAmount float64 `json:"total_amount"` TotalAmount float64 `json:"total_amount"`
Status string `json:"status"` // contoh: unpaid, partial, paid Status string `json:"status"` // contoh: unpaid, partial, paid
Note string `json:"note"` 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"` CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"` UpdatedAt time.Time `json:"updated_at"`

View File

@ -6,8 +6,9 @@ type Payment struct {
ID uint `gorm:"primaryKey" json:"id"` ID uint `gorm:"primaryKey" json:"id"`
InvoiceID uint `json:"invoice_id"` InvoiceID uint `json:"invoice_id"`
Amount float64 `json:"amount"` Amount float64 `json:"amount"`
PaidAt time.Time `json:"paid_at"` PaymentAt time.Time `json:"payment_at"`
Method string `json:"method"` // contoh: cash, bank transfer, credit card 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"` Note string `json:"note"`
CreatedAt time.Time `json:"created_at"` CreatedAt time.Time `json:"created_at"`

View File

@ -11,8 +11,6 @@ type SalesOrder struct {
Note string `json:"note"` Note string `json:"note"`
PaymentTerms string `json:"payment_terms"` PaymentTerms string `json:"payment_terms"`
DueDate time.Time `json:"due_date"` DueDate time.Time `json:"due_date"`
DPAmount float64 `json:"dp_amount"`
DPPaid float64 `json:"dp_paid"`
CreatedAt time.Time `json:"created_at"` CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"` UpdatedAt time.Time `json:"updated_at"`