diff options
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 +} |