aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/invoice/validators.go
diff options
context:
space:
mode:
Diffstat (limited to 'invoice/validators.go')
-rw-r--r--invoice/validators.go28
1 files changed, 1 insertions, 27 deletions
diff --git a/invoice/validators.go b/invoice/validators.go
index 9f145dc..1c39cbe 100644
--- a/invoice/validators.go
+++ b/invoice/validators.go
@@ -24,7 +24,7 @@ import (
func (i *Invoice) validate() error {
var count int64
err := db.Model(&Invoice{}).
- Where("user_id = ? and invoice_number = ?", i.UserID, i.InvoiceNumber).
+ Where("invoice_number = ?", i.InvoiceNumber).
Count(&count).
Error
@@ -59,29 +59,3 @@ func isDraft(invoiceId uint) (bool, error) {
return invoice.IsDraft, nil
}
-
-func checkInvoiceOwnership(invoiceId, userId uint) error {
- var invoice Invoice
- err := db.
- Select("id", "user_id").
- Where("id = ?", invoiceId).
- Find(&invoice).
- Error
-
- // TODO: handle potential errors
- if err != nil {
- return err
- }
-
- // invoice doesn't exist
- if invoice.ID == 0 {
- return errors.ErrNotFound
- }
-
- // user doesn't own this invoice
- if invoice.UserID != userId {
- return errors.ErrForbidden
- }
-
- return nil
-}