diff options
author | Vidhu Kant Sharma <vidhukant@vidhukant.com> | 2023-10-09 22:11:16 +0530 |
---|---|---|
committer | Vidhu Kant Sharma <vidhukant@vidhukant.com> | 2023-10-09 22:11:16 +0530 |
commit | 48845b9e703756471a98f8b1f1edaa2313763df4 (patch) | |
tree | 1883095a68148bad0d0e5daff818616e5137a3c3 /invoice/hooks.go | |
parent | 1924bfca2439829253df3598481034e5c586e3e2 (diff) |
checking user while adding and removing invoice itemsv0.0.13
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 686500a..7a59352 100644 --- a/invoice/hooks.go +++ b/invoice/hooks.go @@ -70,3 +70,18 @@ func (i *InvoiceItem) BeforeSave(tx *gorm.DB) error { return nil } + +func (i *InvoiceItem) BeforeDelete(tx *gorm.DB) error { + var err error + + isDraft, err := isDraft(i.InvoiceID) + if err != nil { + return err + } + + if !isDraft { + return errors.ErrCannotEditInvoice + } + + return nil +} |