Tax issue on Sales invoices with discount unable to submit

Information about bug

Steps :

Create a sales invoice with item
image

Add taxes

image

and check include tax in basic rate

image

add additional discount on grand total

image

save and submit

it throws following error

image

Module

accounts, stock, selling

Version

ERPNext: v15.19.1 (HEAD)

Frappe Framework: v15.20.0 (HEAD)

Frappe HR: v15.16.0 (HEAD)

Installation method

FrappeCloud

Relevant log output / Stack trace / Full Error Message.

Traceback (most recent call last):
  File "apps/frappe/frappe/app.py", line 110, in application
    response = frappe.api.handle(request)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/api/__init__.py", line 49, in handle
    data = endpoint(**arguments)
           ^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/api/v1.py", line 36, in handle_rpc_call
    return frappe.handler.handle()
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/handler.py", line 49, in handle
    data = execute_cmd(cmd)
           ^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/handler.py", line 85, in execute_cmd
    return frappe.call(method, **frappe.form_dict)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/__init__.py", line 1718, in call
    return fn(*args, **newargs)
           ^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/utils/typing_validations.py", line 31, in wrapper
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/desk/form/save.py", line 37, in savedocs
    doc.submit()
  File "apps/frappe/frappe/utils/typing_validations.py", line 31, in wrapper
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/model/document.py", line 1048, in submit
    return self._submit()
           ^^^^^^^^^^^^^^
  File "apps/frappe/frappe/model/document.py", line 1031, in _submit
    return self.save()
           ^^^^^^^^^^^
  File "apps/frappe/frappe/model/document.py", line 337, in save
    return self._save(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/model/document.py", line 390, in _save
    self.run_post_save_methods()
  File "apps/frappe/frappe/model/document.py", line 1131, in run_post_save_methods
    self.run_method("on_submit")
  File "apps/frappe/frappe/model/document.py", line 962, in run_method
    out = Document.hook(fn)(self, *args, **kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/model/document.py", line 1322, in composer
    return composed(self, method, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/model/document.py", line 1304, in runner
    add_to_return_value(self, fn(self, *args, **kwargs))
                              ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/model/document.py", line 959, in fn
    return method_object(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/erpnext/erpnext/accounts/doctype/sales_invoice/sales_invoice.py", line 458, in on_submit
    self.make_gl_entries()
  File "apps/erpnext/erpnext/accounts/doctype/sales_invoice/sales_invoice.py", line 1167, in make_gl_entries
    make_gl_entries(
  File "apps/erpnext/erpnext/accounts/general_ledger.py", line 47, in make_gl_entries
    save_entries(gl_map, adv_adj, update_outstanding, from_repost)
  File "apps/erpnext/erpnext/accounts/general_ledger.py", line 360, in save_entries
    process_debit_credit_difference(gl_map)
  File "apps/erpnext/erpnext/accounts/general_ledger.py", line 433, in process_debit_credit_difference
    raise_debit_credit_not_equal_error(debit_credit_diff, voucher_type, voucher_no)
  File "apps/erpnext/erpnext/accounts/general_ledger.py", line 470, in raise_debit_credit_not_equal_error
    frappe.throw(
  File "apps/frappe/frappe/__init__.py", line 602, in throw
    msgprint(
  File "apps/frappe/frappe/__init__.py", line 567, in msgprint
    _raise_exception()
  File "apps/frappe/frappe/__init__.py", line 518, in _raise_exception
    raise exc
frappe.exceptions.ValidationError: Debit and Credit not equal for Sales Invoice #SI0524-015. Difference is -97.99.
request.js:473:14