From d0a44ff5cfad5d063929426e2420f6f0d55b1dbe Mon Sep 17 00:00:00 2001 From: Vidhu Kant Sharma Date: Tue, 9 Jul 2024 07:58:34 +0530 Subject: added custom fields support --- invoice/invoice.go | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'invoice/invoice.go') diff --git a/invoice/invoice.go b/invoice/invoice.go index 4b93ee4..4397710 100644 --- a/invoice/invoice.go +++ b/invoice/invoice.go @@ -30,7 +30,7 @@ var db *gorm.DB func init() { db = d.DB - db.AutoMigrate(&Invoice{}, &InvoiceItem{}, &InvoiceBillingAddress{}, &InvoiceShippingAddress{}) + db.AutoMigrate(&Invoice{}, &InvoiceItem{}, &InvoiceBillingAddress{}, &InvoiceShippingAddress{}, &CustomField{}) } type InvoiceBillingAddress struct { @@ -46,13 +46,21 @@ type InvoiceShippingAddress struct { } type InvoiceItem struct { - gorm.Model i.Item + ID uint InvoiceID uint BrandName string Quantity string // float } +// user can add as many custom fields as they like +type CustomField struct { + ID uint + InvoiceID uint + Key string + Value string +} + type Invoice struct { gorm.Model UserID uint `json:"-"` @@ -64,6 +72,7 @@ type Invoice struct { IsDraft bool Note string Items []InvoiceItem + CustomFields []CustomField // issuer and customer details are stored here // because they are NOT intended to ever change @@ -80,7 +89,4 @@ type Invoice struct { CustomerPhone string CustomerEmail string CustomerWebsite string - - // Transporter Transporter - // TransactionID string } -- cgit v1.2.3