-
Notifications
You must be signed in to change notification settings - Fork 230
fix: after mapping of stock entry map correct addresses and gstin #3998
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
base: develop
Are you sure you want to change the base?
Changes from all commits
0da3520
4a37981
0aaaa87
1b9bfbc
0cd0f19
6a3b855
dd22e8f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -79,16 +79,77 @@ def after_mapping_stock_entry(doc, method, source_doc): | |
| doc.taxes_and_charges = "" | ||
| doc.taxes = [] | ||
|
|
||
| if doc.purpose != "Material Transfer" or not doc.is_return: | ||
| set_item_tax_template(doc, source_doc) | ||
|
|
||
| address_map = _get_fields_mapping(doc, source_doc) | ||
|
|
||
| if not address_map: | ||
| return | ||
|
|
||
| doc.bill_to_address = source_doc.billing_address | ||
| doc.bill_from_address = source_doc.supplier_address | ||
| doc.bill_to_gstin = source_doc.company_gstin | ||
| doc.bill_from_gstin = source_doc.supplier_gstin | ||
| (bill_from_address, bill_from_gstin), (bill_to_address, bill_to_gstin) = address_map | ||
|
|
||
| doc.bill_from_address = source_doc.get(bill_from_address) | ||
| doc.bill_from_gstin = source_doc.get(bill_from_gstin) | ||
| doc.bill_to_address = source_doc.get(bill_to_address) | ||
| doc.bill_to_gstin = source_doc.get(bill_to_gstin) | ||
|
|
||
| set_address_display(doc) | ||
|
|
||
|
|
||
| def _get_fields_mapping(doc, source_doc): | ||
| from_fields = ("billing_address", "company_gstin") | ||
| to_fields = ("supplier_address", "supplier_gstin") | ||
|
|
||
| if source_doc.doctype == "Subcontracting Order": | ||
| if doc.purpose == "Send to Subcontractor": | ||
| return from_fields, to_fields | ||
|
|
||
| elif doc.purpose == "Material Transfer" and doc.is_return: | ||
| return to_fields, from_fields | ||
|
|
||
| elif ( | ||
| source_doc.doctype == "Purchase Receipt" and doc.purpose == "Material Transfer" and not doc.is_return | ||
| ): | ||
| return from_fields, to_fields | ||
|
|
||
| elif source_doc.doctype == "Stock Entry" and doc.purpose == "Material Transfer" and not doc.is_return: | ||
| from_fields = ("bill_from_address", "bill_from_gstin") | ||
| to_fields = ("bill_to_address", "bill_to_gstin") | ||
|
|
||
| return from_fields, to_fields | ||
|
|
||
| return None | ||
|
|
||
|
|
||
| def set_item_tax_template(doc, source_doc): | ||
| if source_doc.doctype not in ("Subcontracting Order", "Purchase Order"): | ||
| return | ||
|
|
||
| rm_detail_field = None | ||
| if source_doc.doctype == "Subcontracting Order": | ||
| rm_detail_field = "sco_rm_detail" | ||
|
|
||
| elif source_doc.doctype == "Purchase Order": | ||
| rm_detail_field = "po_detail" | ||
|
|
||
| item_tax_template_map = frappe._dict() | ||
| for supplied_item in source_doc.supplied_items: | ||
| item_tax_template = next( | ||
| ( | ||
| item.item_tax_template | ||
| for item in source_doc.items | ||
| if supplied_item.get("reference_name") == item.name | ||
| ), | ||
| None, | ||
| ) | ||
|
|
||
| if item_tax_template: | ||
| item_tax_template_map[supplied_item.name] = item_tax_template | ||
|
|
||
| for item in doc.items: | ||
| item.item_tax_template = item_tax_template_map.get(item.get(rm_detail_field)) | ||
karm1000 marked this conversation as resolved.
Show resolved
Hide resolved
karm1000 marked this conversation as resolved.
Show resolved
Hide resolved
Comment on lines
+149
to
+150
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Consider only overwriting when a real value is found: for item in doc.items:
template = item_tax_template_map.get(item.get(rm_detail_field))
if template:
item.item_tax_template = templateThis preserves any template that was already correctly set on items that lack a lookup match. |
||
|
|
||
|
|
||
| def before_mapping_subcontracting_receipt(doc, method, source_doc, table_maps): | ||
| table_maps["India Compliance Taxes and Charges"] = { | ||
| "doctype": "India Compliance Taxes and Charges", | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.