Skip to content

Commit

Permalink
fix: override taxes when behaviour different from mapped doc
Browse files Browse the repository at this point in the history
  • Loading branch information
Ninad1306 committed Aug 8, 2024
1 parent a0108de commit 736cccf
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 1 deletion.
15 changes: 14 additions & 1 deletion india_compliance/gst_india/overrides/purchase_invoice.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,24 @@
from india_compliance.gst_india.overrides.sales_invoice import (
update_dashboard_with_gst_logs,
)
from india_compliance.gst_india.overrides.transaction import validate_transaction
from india_compliance.gst_india.overrides.transaction import (
ignore_gst_validations,
is_inter_state_supply,
validate_transaction,
)
from india_compliance.gst_india.utils import is_api_enabled
from india_compliance.gst_india.utils.e_waybill import get_e_waybill_info


def before_mapping(doc, method, source_doc, table_maps):
if ignore_gst_validations(doc) or not doc.place_of_supply:
return

if is_inter_state_supply(doc) != is_inter_state_supply(source_doc):
table_maps["Purchase Taxes and Charges"]["add_if_empty"] = False
doc.taxes = []


def onload(doc, method=None):
if doc.docstatus != 1:
return
Expand Down
13 changes: 13 additions & 0 deletions india_compliance/gst_india/overrides/sales_invoice.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from india_compliance.gst_india.overrides.payment_entry import get_taxes_summary
from india_compliance.gst_india.overrides.transaction import (
ignore_gst_validations,
is_inter_state_supply,
validate_backdated_transaction,
validate_mandatory_fields,
validate_transaction,
Expand All @@ -30,6 +31,18 @@
)


def before_mapping(doc, method, source_doc, table_maps):
if source_doc.doctype == "Purchase Order":
return

if ignore_gst_validations(doc) or not doc.place_of_supply:
return

if is_inter_state_supply(doc) != is_inter_state_supply(source_doc):
table_maps["Sales Taxes and Charges"]["add_if_empty"] = False
doc.taxes = []


def onload(doc, method=None):
if not doc.get("ewaybill"):
if doc.gst_category == "Overseas" and is_e_waybill_applicable(doc):
Expand Down
6 changes: 6 additions & 0 deletions india_compliance/hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@
"validate": (
"india_compliance.gst_india.overrides.transaction.validate_transaction"
),
"before_mapping": "india_compliance.gst_india.overrides.sales_invoice.before_mapping",
},
"Email Template": {
"after_rename": "india_compliance.gst_india.overrides.email_template.after_rename",
Expand Down Expand Up @@ -162,6 +163,7 @@
],
"after_mapping": "india_compliance.gst_india.overrides.transaction.after_mapping",
"on_cancel": "india_compliance.gst_india.overrides.purchase_invoice.on_cancel",
"before_mapping": "india_compliance.gst_india.overrides.purchase_invoice.before_mapping",
},
"Purchase Order": {
"onload": "india_compliance.gst_india.overrides.transaction.onload",
Expand All @@ -176,6 +178,7 @@
"before_save": "india_compliance.gst_india.overrides.transaction.update_gst_details",
"before_submit": "india_compliance.gst_india.overrides.transaction.update_gst_details",
"before_update_after_submit": "india_compliance.gst_india.overrides.transaction.before_update_after_submit",
"before_mapping": "india_compliance.gst_india.overrides.purchase_invoice.before_mapping",
},
"Purchase Order Item": {
"on_change": "india_compliance.gst_india.overrides.transaction.on_change_item",
Expand All @@ -195,6 +198,7 @@
"before_submit": [
"india_compliance.gst_india.overrides.transaction.update_gst_details",
],
"before_mapping": "india_compliance.gst_india.overrides.purchase_invoice.before_mapping",
},
"Sales Invoice": {
"onload": [
Expand All @@ -216,6 +220,7 @@
"india_compliance.gst_india.overrides.sales_invoice.before_cancel"
],
"after_mapping": "india_compliance.gst_india.overrides.transaction.after_mapping",
"before_mapping": "india_compliance.gst_india.overrides.sales_invoice.before_mapping",
},
"Sales Order": {
"onload": "india_compliance.gst_india.overrides.transaction.onload",
Expand All @@ -227,6 +232,7 @@
"before_save": "india_compliance.gst_india.overrides.transaction.update_gst_details",
"before_submit": "india_compliance.gst_india.overrides.transaction.update_gst_details",
"before_update_after_submit": "india_compliance.gst_india.overrides.transaction.before_update_after_submit",
"before_mapping": "india_compliance.gst_india.overrides.sales_invoice.before_mapping",
},
"Sales Order Item": {
"on_change": "india_compliance.gst_india.overrides.transaction.on_change_item",
Expand Down

0 comments on commit 736cccf

Please sign in to comment.