Skip to content

Commit

Permalink
fix: appropriate negative other charges upto 0.1 to rounding adjust…
Browse files Browse the repository at this point in the history
…ment (#351) (#352)

(cherry picked from commit 5dfa43a)

Co-authored-by: Sagar Vora <sagar@resilient.tech>
  • Loading branch information
mergify[bot] and sagarvora authored Nov 24, 2022
1 parent 3412db7 commit 6bf6a2e
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion india_compliance/gst_india/utils/transaction_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,17 @@ def update_transaction_tax_details(self):
for total in ["base_total", "rounding_adjustment", *tax_totals]:
current_total += self.transaction_details.get(total)

self.transaction_details.other_charges = self.rounded(
other_charges = self.rounded(
(self.transaction_details.base_grand_total - current_total)
)

if 0 < other_charges < -0.1:
# other charges cannot be negative
# handle cases where user has higher precision than 2
self.transaction_details.rounding_adjustment += other_charges
else:
self.transaction_details.other_charges = other_charges

def validate_mode_of_transport(self, throw=True):
def _throw(error):
if throw:
Expand Down

0 comments on commit 6bf6a2e

Please sign in to comment.