aboutsummaryrefslogtreecommitdiff
path: root/invoice/validators.go
diff options
context:
space:
mode:
authorVidhu Kant Sharma <vidhukant@vidhukant.com>2023-10-09 21:07:20 +0530
committerVidhu Kant Sharma <vidhukant@vidhukant.com>2023-10-09 21:07:20 +0530
commit1924bfca2439829253df3598481034e5c586e3e2 (patch)
tree6b82a091ae97e1980fe0ff3f3fb3eaa726a6d6ad /invoice/validators.go
parentb643f7852f93f73843aa5f52f9b4545321713e10 (diff)
added route to add items to invoicev0.0.12
Diffstat (limited to 'invoice/validators.go')
-rw-r--r--invoice/validators.go26
1 files changed, 21 insertions, 5 deletions
diff --git a/invoice/validators.go b/invoice/validators.go
index 645bdff..9f145dc 100644
--- a/invoice/validators.go
+++ b/invoice/validators.go
@@ -18,12 +18,7 @@
package invoice
import (
- //"regexp"
- //"strings"
- //"net/mail"
- //"net/url"
"vidhukant.com/openbills/errors"
- //e "errors"
)
func (i *Invoice) validate() error {
@@ -44,6 +39,27 @@ func (i *Invoice) validate() error {
return nil
}
+func isDraft(invoiceId uint) (bool, error) {
+ var invoice Invoice
+ err := db.
+ Select("id", "is_draft").
+ Where("id = ?", invoiceId).
+ Find(&invoice).
+ Error
+
+ // TODO: handle potential errors
+ if err != nil {
+ return invoice.IsDraft, err
+ }
+
+ // invoice doesn't exist
+ if invoice.ID == 0 {
+ return invoice.IsDraft, errors.ErrNotFound
+ }
+
+ return invoice.IsDraft, nil
+}
+
func checkInvoiceOwnership(invoiceId, userId uint) error {
var invoice Invoice
err := db.