From 30c494f15210f889ec628679287e97a2e4f78375 Mon Sep 17 00:00:00 2001 From: ljain112 Date: Wed, 31 Jan 2024 20:27:29 +0530 Subject: [PATCH] fix: get correct POS in Payment Entry Doctype (cherry picked from commit 16d5ea02f1bed8b64a7fbb0bfda99569903681a3) --- .../gst_india/client_scripts/payment_entry.js | 4 ++- .../gst_india/overrides/payment_entry.py | 30 ++++++++----------- 2 files changed, 15 insertions(+), 19 deletions(-) diff --git a/india_compliance/gst_india/client_scripts/payment_entry.js b/india_compliance/gst_india/client_scripts/payment_entry.js index a0c056cc7..5d54ac0bb 100644 --- a/india_compliance/gst_india/client_scripts/payment_entry.js +++ b/india_compliance/gst_india/client_scripts/payment_entry.js @@ -35,7 +35,9 @@ frappe.ui.form.on("Payment Entry", { ); }, - customer_address: update_gst_details, + customer_address(frm) { + update_gst_details(frm); + }, }); function override_get_outstanding_documents(frm) { diff --git a/india_compliance/gst_india/overrides/payment_entry.py b/india_compliance/gst_india/overrides/payment_entry.py index e55184898..0038d3ee4 100644 --- a/india_compliance/gst_india/overrides/payment_entry.py +++ b/india_compliance/gst_india/overrides/payment_entry.py @@ -2,7 +2,7 @@ from frappe import _ from frappe.contacts.doctype.address.address import get_default_address from frappe.query_builder.functions import Sum -from frappe.utils import cstr, flt, getdate +from frappe.utils import flt, getdate from erpnext.accounts.general_ledger import make_gl_entries from erpnext.accounts.utils import create_payment_ledger_entry from erpnext.controllers.accounts_controller import get_advance_payment_entries @@ -107,6 +107,17 @@ def update_party_details(party_details, doctype, company): address = get_default_address("Customer", party_details.get("customer")) party_details.update(customer_address=address) + # update gst details + if address: + party_details.update( + frappe.db.get_value( + "Address", + address, + ["gstin as billing_address_gstin"], + as_dict=1, + ) + ) + # Update address for update response = { "customer_address": address, # should be set first as gst_category and gstin is fetched from address @@ -116,23 +127,6 @@ def update_party_details(party_details, doctype, company): return response -def update_place_of_supply(doc): - country = frappe.get_cached_value("Company", doc.company, "country") - if country != "India": - return - - address = frappe.db.get_value( - "Address", - doc.get("customer_address"), - ["gst_state", "gst_state_number"], - as_dict=1, - ) - if address and address.gst_state and address.gst_state_number: - doc.place_of_supply = ( - cstr(address.gst_state_number) + "-" + cstr(address.gst_state) - ) - - def make_gst_revesal_entry_from_advance_payment(doc): """ This functionality aims to create a GST reversal entry where GST was paid in advance