diff options
author | Vidhu Kant Sharma <vidhukant@vidhukant.com> | 2025-10-14 07:40:58 +0530 |
---|---|---|
committer | Vidhu Kant Sharma <vidhukant@vidhukant.com> | 2025-10-14 07:40:58 +0530 |
commit | 2f239481cdd750c2cbe85b012bdeb69841298c42 (patch) | |
tree | ab2e186632777200d4ba4ccf26503b1a4baa1dbe | |
parent | 9de7dcb3b45a86ee0de0e2b6f3044a859ed5ea08 (diff) |
returning 'invalid quantity' error instead of 'invalid gst' in case of invalid quantityv0.23.1
-rw-r--r-- | errors/errors.go | 41 | ||||
-rw-r--r-- | errors/status.go | 3 | ||||
-rw-r--r-- | item/validators.go | 2 | ||||
-rw-r--r-- | main.go | 2 |
4 files changed, 25 insertions, 23 deletions
diff --git a/errors/errors.go b/errors/errors.go index 3c37e08..1858834 100644 --- a/errors/errors.go +++ b/errors/errors.go @@ -1,5 +1,5 @@ /* openbills - Server for web based Libre Billing Software - * Copyright (C) 2023-2024 Vidhu Kant Sharma <vidhukant@vidhukant.com> + * Copyright (C) 2023-2025 Vidhu Kant Sharma <vidhukant@vidhukant.com> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -26,25 +26,26 @@ var ( ErrEmptyResponse = errors.New("No Records Found") // 400 - ErrNoWhereCondition = errors.New("No Where Condition") - ErrInvalidID = errors.New("Invalid ID") - ErrEmptyContactName = errors.New("Contact Name Cannot Be Empty") - ErrInvalidGSTIN = errors.New("Invalid GSTIN") - ErrInvalidEmail = errors.New("Invalid E-Mail Address") - ErrEmptyEmail = errors.New("E-Mail Address Cannot Be Empty") - ErrInvalidUsername = errors.New("Invalid Username") - ErrEmptyUsername = errors.New("Username Cannot Be Empty") - ErrInvalidPhone = errors.New("Invalid Phone Number") - ErrInvalidWebsite = errors.New("Invalid Website URL") - ErrEmptyBrandName = errors.New("Brand Name Cannot Be Empty") - ErrInvalidUnitPrice = errors.New("Invalid Unit Price") - ErrInvalidGSTPercentage = errors.New("Invalid GST Percentage") - ErrPasswordTooShort = errors.New("Password Is Too Short") - ErrPasswordTooLong = errors.New("Password Is Too Long") - ErrUsernameTooShort = errors.New("Username Is Too Short") - ErrUsernameTooLong = errors.New("Username Is Too Long") - ErrInvalidLoginMethod = errors.New("Login Method Can Only Be 'email' Or 'username'") - ErrNoItemVariants = errors.New("An item should have at least one variant") + ErrNoWhereCondition = errors.New("No Where Condition") + ErrInvalidID = errors.New("Invalid ID") + ErrEmptyContactName = errors.New("Contact Name Cannot Be Empty") + ErrInvalidGSTIN = errors.New("Invalid GSTIN") + ErrInvalidEmail = errors.New("Invalid E-Mail Address") + ErrEmptyEmail = errors.New("E-Mail Address Cannot Be Empty") + ErrInvalidUsername = errors.New("Invalid Username") + ErrEmptyUsername = errors.New("Username Cannot Be Empty") + ErrInvalidPhone = errors.New("Invalid Phone Number") + ErrInvalidWebsite = errors.New("Invalid Website URL") + ErrEmptyBrandName = errors.New("Brand Name Cannot Be Empty") + ErrInvalidUnitPrice = errors.New("Invalid Unit Price") + ErrInvalidGSTPercentage = errors.New("Invalid GST Percentage") + ErrInvalidQuantityInStock = errors.New("Invalid Stock Quantity") + ErrPasswordTooShort = errors.New("Password Is Too Short") + ErrPasswordTooLong = errors.New("Password Is Too Long") + ErrUsernameTooShort = errors.New("Username Is Too Short") + ErrUsernameTooLong = errors.New("Username Is Too Long") + ErrInvalidLoginMethod = errors.New("Login Method Can Only Be 'email' Or 'username'") + ErrNoItemVariants = errors.New("An item should have at least one variant") // 401 ErrWrongPassword = errors.New("Wrong Password") diff --git a/errors/status.go b/errors/status.go index 0bbb7ba..708165a 100644 --- a/errors/status.go +++ b/errors/status.go @@ -1,5 +1,5 @@ /* openbills - Server for web based Libre Billing Software - * Copyright (C) 2023 Vidhu Kant Sharma <vidhukant@vidhukant.com> + * Copyright (C) 2023-2025 Vidhu Kant Sharma <vidhukant@vidhukant.com> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -42,6 +42,7 @@ func StatusCodeFromErr(err error) int { errors.Is(err, ErrPasswordTooLong) || errors.Is(err, ErrInvalidLoginMethod) || errors.Is(err, ErrNoItemVariants) || + errors.Is(err, ErrInvalidQuantityInStock) || errors.Is(err, ErrInvalidGSTPercentage) { return http.StatusBadRequest } diff --git a/item/validators.go b/item/validators.go index 1fba170..400f358 100644 --- a/item/validators.go +++ b/item/validators.go @@ -74,7 +74,7 @@ func (v *ItemVariant) validate() error { // check if QuantityInStock is float _, err = strconv.ParseFloat(v.QuantityInStock, 64) if err != nil && v.QuantityInStock != "" { - return errors.ErrInvalidGSTPercentage + return errors.ErrInvalidQuantityInStock } return nil @@ -38,7 +38,7 @@ import ( "log" ) -const OPENBILLS_VERSION = "v0.23.0" +const OPENBILLS_VERSION = "v0.23.1" func init() { if !viper.GetBool("debug_mode") { |