- # check if calculated is equal to stored
- if ($form->{taxincluded} && $form->{taxrate} && $withholdingrate) {
- if ($form->{"taxrate"} > 0) {
- $taxamount =
- $form->round_amount(
- ($form->{amount_1} - ($form->{amount_1} / ($form->{taxrate} + 1))),
- 2);
- } else {
- $taxamount =
- $form->round_amount(
- ($totalamount + $totaltax + $totalwithholding) * $withholdingrate /
- (1 - $withholdingrate),
- 2
- ) * $form->{"taxrate"} / $withholdingrate;
- }
- } else {
- $taxamount = $totalamount * $form->{"taxrate"};
- }