From 1924bfca2439829253df3598481034e5c586e3e2 Mon Sep 17 00:00:00 2001 From: Vidhu Kant Sharma Date: Mon, 9 Oct 2023 21:07:20 +0530 Subject: added route to add items to invoice --- invoice/hooks.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'invoice/hooks.go') diff --git a/invoice/hooks.go b/invoice/hooks.go index 3d933fb..686500a 100644 --- a/invoice/hooks.go +++ b/invoice/hooks.go @@ -55,3 +55,18 @@ func (i *Invoice) BeforeDelete(tx *gorm.DB) error { return nil } + +func (i *InvoiceItem) BeforeSave(tx *gorm.DB) error { + var err error + + isDraft, err := isDraft(i.InvoiceID) + if err != nil { + return err + } + + if !isDraft { + return errors.ErrCannotEditInvoice + } + + return nil +} -- cgit v1.2.3