diff options
| author | Vidhu Kant Sharma <vidhukant@vidhukant.com> | 2023-10-09 21:07:20 +0530 | 
|---|---|---|
| committer | Vidhu Kant Sharma <vidhukant@vidhukant.com> | 2023-10-09 21:07:20 +0530 | 
| commit | 1924bfca2439829253df3598481034e5c586e3e2 (patch) | |
| tree | 6b82a091ae97e1980fe0ff3f3fb3eaa726a6d6ad /invoice/hooks.go | |
| parent | b643f7852f93f73843aa5f52f9b4545321713e10 (diff) | |
added route to add items to invoice
Diffstat (limited to 'invoice/hooks.go')
| -rw-r--r-- | invoice/hooks.go | 15 | 
1 files changed, 15 insertions, 0 deletions
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 +}  |