Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Correct Tax Breakup for different tax rates for same hsn code #36235

Conversation

DaizyModi
Copy link
Contributor

@DaizyModi DaizyModi commented Jul 21, 2023

Issue
In case of different tax rates for same HSN code, tax rate and taxable amount was getting overriden.

Before
image

After

image

@DaizyModi DaizyModi marked this pull request as draft July 21, 2023 12:01
@github-actions github-actions bot added accounts needs-tests This PR needs automated unit-tests. labels Jul 21, 2023
@DaizyModi DaizyModi marked this pull request as ready for review July 21, 2023 12:06
@DaizyModi DaizyModi force-pushed the fix-tax-breakup-for-diff-tax-rates branch from 99474c0 to b84deec Compare July 21, 2023 12:13
@DaizyModi DaizyModi force-pushed the fix-tax-breakup-for-diff-tax-rates branch from c91a940 to 653117c Compare July 21, 2023 12:26
@codecov
Copy link

codecov bot commented Jul 21, 2023

Codecov Report

Merging #36235 (1b8490d) into develop (34d7fb3) will increase coverage by 0.00%.
The diff coverage is 90.00%.

Additional details and impacted files
@@           Coverage Diff            @@
##           develop   #36235   +/-   ##
========================================
  Coverage    64.14%   64.14%           
========================================
  Files          784      785    +1     
  Lines        60732    60749   +17     
========================================
+ Hits         38955    38970   +15     
- Misses       21777    21779    +2     
Impacted Files Coverage Δ
...xt/assets/doctype/asset_movement/asset_movement.py 75.00% <33.33%> (ø)
...xt/accounts/doctype/payment_entry/payment_entry.py 83.37% <100.00%> (ø)
erpnext/accounts/party.py 78.15% <100.00%> (+0.05%) ⬆️
erpnext/assets/doctype/asset/asset.py 79.35% <100.00%> (+0.08%) ⬆️
erpnext/controllers/accounts_controller.py 85.60% <100.00%> (+0.02%) ⬆️
erpnext/controllers/taxes_and_totals.py 95.22% <100.00%> (+0.02%) ⬆️
erpnext/utilities/regional.py 100.00% <100.00%> (ø)

... and 1 file with indirect coverage changes

@DaizyModi DaizyModi force-pushed the fix-tax-breakup-for-diff-tax-rates branch from c931e6d to 1799ffc Compare July 24, 2023 07:09
@DaizyModi DaizyModi force-pushed the fix-tax-breakup-for-diff-tax-rates branch from f55c4b0 to 6f376cf Compare July 24, 2023 12:32
@DaizyModi DaizyModi marked this pull request as draft July 24, 2023 12:37
@DaizyModi DaizyModi marked this pull request as ready for review July 24, 2023 13:08
@deepeshgarg007 deepeshgarg007 added the backport version-14-hotfix backport to version 14 label Jul 24, 2023
@deepeshgarg007 deepeshgarg007 merged commit 3055430 into frappe:develop Jul 24, 2023
13 checks passed
deepeshgarg007 added a commit that referenced this pull request Jul 25, 2023
fix: Correct Tax Breakup for different tax rates for same hsn code (#36235)
@precihole
Copy link

precihole commented Jul 26, 2023

Hello,

We are getting issue because of this PR in Purchase Order when we do Get Items From Supplier Quotation.
Kindly resolve this on urgent basis.
@deepeshgarg007 @DaizyModi @vorasmit @sagarvora

image

App Versions

{
	"erpnext": "14.32.1",
	"erpnext_telegram_integration": "1.2.0",
	"frappe": "14.42.0",
	"hrms": "14.8.0",
	"india_compliance": "14.13.0",
	"insights": "0.10.0",
	"pl_accounts": "0.0.1",
	"preciholesports": "0.0.1"
}

Route

Form/Purchase Order/new-purchase-order-1

Traceback

Traceback (most recent call last):
  File "apps/frappe/frappe/app.py", line 94, in application
    response = frappe.api.handle()
  File "apps/frappe/frappe/api.py", line 54, in handle
    return frappe.handler.handle()
  File "apps/frappe/frappe/handler.py", line 47, 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 1619, in call
    return fn(*args, **newargs)
  File "apps/frappe/frappe/model/mapper.py", line 53, in map_docs
    target_doc = method(*_args)
  File "apps/erpnext/erpnext/buying/doctype/supplier_quotation/supplier_quotation.py", line 142, in make_purchase_order
    doclist = get_mapped_doc(
  File "apps/frappe/frappe/model/mapper.py", line 148, in get_mapped_doc
    postprocess(source_doc, target_doc)
  File "apps/erpnext/erpnext/buying/doctype/supplier_quotation/supplier_quotation.py", line 137, in set_missing_values
    target.run_method("calculate_taxes_and_totals")
  File "apps/frappe/frappe/model/document.py", line 914, in run_method
    out = Document.hook(fn)(self, *args, **kwargs)
  File "apps/frappe/frappe/model/document.py", line 1267, in composer
    return composed(self, method, *args, **kwargs)
  File "apps/frappe/frappe/model/document.py", line 1249, in runner
    add_to_return_value(self, fn(self, *args, **kwargs))
  File "apps/frappe/frappe/model/document.py", line 911, in fn
    return method_object(*args, **kwargs)
  File "apps/erpnext/erpnext/controllers/accounts_controller.py", line 348, in calculate_taxes_and_totals
    calculate_taxes_and_totals(self)
  File "apps/erpnext/erpnext/controllers/taxes_and_totals.py", line 32, in __init__
    self.calculate()
  File "apps/erpnext/erpnext/controllers/taxes_and_totals.py", line 62, in calculate
    self.set_item_wise_tax_breakup()
  File "apps/erpnext/erpnext/controllers/taxes_and_totals.py", line 912, in set_item_wise_tax_breakup
    self.doc.other_charges_calculation = get_itemised_tax_breakup_html(self.doc)
  File "apps/erpnext/erpnext/controllers/taxes_and_totals.py", line 958, in get_itemised_tax_breakup_html
    get_rounded_tax_amount(itemised_tax_data, doc.precision("tax_amount", "taxes"))
  File "apps/erpnext/erpnext/controllers/taxes_and_totals.py", line 1056, in get_rounded_tax_amount
    if isinstance(row, dict) and isinstance(row["tax_amount"], float):
KeyError: 'tax_amount'

Request Data

{
	"type": "POST",
	"args": {
		"method": "erpnext.buying.doctype.supplier_quotation.supplier_quotation.make_purchase_order",
		"source_names": "[\"PUR-GR2324-0214\"]",
		"target_doc": "{\"docstatus\":0,\"doctype\":\"Purchase Order\",\"name\":\"new-purchase-order-1\",\"__islocal\":1,\"__unsaved\":1,\"owner\":\"rehan@preciholesports.com\",\"title\":\"{supplier_name}\",\"naming_series\":\"PO-JW.FY.-.####\",\"material_request_type\":\"\",\"transaction_date\":\"2023-07-26\",\"company\":\"Precihole Sports Pvt. Ltd.\",\"apply_tds\":0,\"is_reverse_charge\":0,\"purpose\":\"\",\"is_subcontracted\":0,\"currency\":\"INR\",\"buying_price_list\":\"Supplier Rates\",\"price_list_currency\":\"INR\",\"ignore_pricing_rule\":0,\"set_warehouse\":\"Stores A197 (Material In) - PSPL\",\"tax_withholding_net_total\":0,\"set_reserve_warehouse\":\"Reserve - PSPL\",\"disable_rounded_total\":0,\"apply_discount_on\":\"Grand Total\",\"status\":\"Draft\",\"letter_head\":\"No Letterhead\",\"group_same_items\":0,\"is_internal_supplier\":0,\"party_account_currency\":\"INR\",\"is_old_subcontracting_flow\":0,\"items\":[],\"workflow_state\":\"Draft\",\"advance_paid\":0,\"conversion_rate\":1,\"plc_conversion_rate\":1,\"shipping_address\":\"PSPL Warehouse - 197 - Shipping\",\"shipping_address_display\":\"Plot No. A-197, Road No 16A, Wagle Estate, <br>Thane (W)  Maharashtra 400604<br>Thane,PIN: 400604,<br>Maharashtra, State Code: 27,India<br>\\n<b>Phone:</b> 8879320376 / 77&ensp;<br><b>Email:</b> info@preciholesports.com<br><b>GSTIN:</b> 27AAGCP5774K1ZT\",\"destination\":\"Thane\",\"base_net_total\":0,\"net_total\":0,\"base_total\":0,\"total\":0,\"total_qty\":0,\"rounding_adjustment\":0,\"grand_total\":0,\"taxes_and_charges_deducted\":0,\"taxes_and_charges_added\":0,\"base_grand_total\":0,\"base_taxes_and_charges_added\":0,\"base_taxes_and_charges_deducted\":0,\"total_taxes_and_charges\":0,\"base_total_taxes_and_charges\":0,\"base_rounding_adjustment\":0,\"rounded_total\":0,\"base_rounded_total\":0,\"in_words\":\"\",\"base_in_words\":\"\",\"base_discount_amount\":0}"
	},
	"headers": {},
	"error_handlers": {},
	"url": "/api/method/frappe.model.mapper.map_docs"
}

Response Data

{
	"exception": "KeyError: 'tax_amount'"
}

@vorasmit vorasmit deleted the fix-tax-breakup-for-diff-tax-rates branch July 26, 2023 09:33
@precihole
Copy link

precihole commented Jul 26, 2023

Hello,

Our ERP Site is stuck becuase of this what to do for now? @vorasmit

@vorasmit
Copy link
Collaborator

Hello,

I request you to upgrade the version of India Compliance to v.14.14.0 and the issue will be resolved for you.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
accounts backport version-14-hotfix backport to version 14 needs-tests This PR needs automated unit-tests.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants