diff --git a/database.txt b/database.txt index a15187c..3a524c7 100644 --- a/database.txt +++ b/database.txt @@ -98,7 +98,8 @@ CREATE TABLE customer ( name VARCHAR(100), address TEXT, phone VARCHAR(20), - email VARCHAR(100) + email VARCHAR(100), + type VARCHAR(20), ); CREATE TABLE sales_order ( @@ -109,10 +110,7 @@ CREATE TABLE sales_order ( total_amount NUMERIC, note TEXT, payment_terms VARCHAR(100), - due_date DATE, - is_dp BOOLEAN, - dp_ammount NUMERIC, - dp_paid BOOLEAN + due_date DATE ); CREATE TABLE sales_order_item ( @@ -121,7 +119,6 @@ CREATE TABLE sales_order_item ( product_id INT REFERENCES master_product(id), quantity NUMERIC, unit_price NUMERIC, - discount NUMERIC, sub_total NUMERIC ); @@ -133,6 +130,7 @@ CREATE TABLE invoice ( due_date DATE, status VARCHAR(50), total_amount NUMERIC, + note TEXT, is_dp_invoice BOOLEAN, is_full_invoice BOOLEAN, parent_invoice_id INT @@ -144,16 +142,15 @@ CREATE TABLE invoice_line ( product_id INT REFERENCES master_product(id), quantity NUMERIC, unit_price NUMERIC, - discount NUMERIC, sub_total NUMERIC ); CREATE TABLE payment ( id SERIAL PRIMARY KEY, invoice_id INT REFERENCES invoice(id), - payment_date DATE, + payment_at TIMESTAMP, amount NUMERIC, payment_method VARCHAR(100), - reference_number VARCHAR(100), + file_path VARCHAR(250), notes TEXT ); \ No newline at end of file diff --git a/modules/sales/models/customer.go b/modules/sales/models/customer.go index a8eb595..df3f0ff 100644 --- a/modules/sales/models/customer.go +++ b/modules/sales/models/customer.go @@ -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"` diff --git a/modules/sales/models/invoice.go b/modules/sales/models/invoice.go index 7c53f67..2b905c6 100644 --- a/modules/sales/models/invoice.go +++ b/modules/sales/models/invoice.go @@ -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"` diff --git a/modules/sales/models/payment.go b/modules/sales/models/payment.go index f775c4f..7d8721a 100644 --- a/modules/sales/models/payment.go +++ b/modules/sales/models/payment.go @@ -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"` diff --git a/modules/sales/models/sales_order.go b/modules/sales/models/sales_order.go index c958f77..cd696f7 100644 --- a/modules/sales/models/sales_order.go +++ b/modules/sales/models/sales_order.go @@ -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"`