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