fix: tds workflow in purchase order

(cherry picked from commit a7888b26a7)
This commit is contained in:
ljain112
2024-08-23 12:34:07 +05:30
committed by Mergify
parent 2ad6d637ee
commit 11359bd235
2 changed files with 43 additions and 0 deletions

View File

@@ -65,6 +65,33 @@ frappe.ui.form.on("Purchase Order", {
}
},
supplier: function (frm) {
// Do not update if inter company reference is there as the details will already be updated
if (frm.updating_party_details || frm.doc.inter_company_invoice_reference) return;
if (frm.doc.__onload && frm.doc.__onload.load_after_mapping) return;
erpnext.utils.get_party_details(
frm,
"erpnext.accounts.party.get_party_details",
{
posting_date: frm.doc.transaction_date,
bill_date: frm.doc.bill_date,
party: frm.doc.supplier,
party_type: "Supplier",
account: frm.doc.credit_to,
price_list: frm.doc.buying_price_list,
fetch_payment_terms_template: cint(!frm.doc.ignore_default_payment_terms_template),
},
function () {
frm.doc.apply_tds = frm.supplier_tds ? 1 : 0;
frm.doc.tax_withholding_category = frm.supplier_tds;
frm.set_df_property("apply_tds", "read_only", frm.supplier_tds ? 0 : 1);
frm.set_df_property("tax_withholding_category", "hidden", frm.supplier_tds ? 0 : 1);
}
);
},
get_materials_from_supplier: function (frm) {
let po_details = [];
@@ -108,6 +135,15 @@ frappe.ui.form.on("Purchase Order", {
frm.set_value("transaction_date", frappe.datetime.get_today());
}
if (frm.doc.__onload && frm.is_new()) {
if (frm.doc.supplier) {
frm.doc.apply_tds = frm.doc.__onload.supplier_tds ? 1 : 0;
}
if (!frm.doc.__onload.supplier_tds) {
frm.set_df_property("apply_tds", "read_only", 1);
}
}
erpnext.queries.setup_queries(frm, "Warehouse", function () {
return erpnext.queries.warehouse(frm.doc);
});

View File

@@ -648,6 +648,13 @@ class PurchaseOrder(BuyingController):
if sco:
update_sco_status(sco, "Closed" if self.status == "Closed" else None)
def set_missing_values(self, for_validate=False):
tds_category = frappe.db.get_value("Supplier", self.supplier, "tax_withholding_category")
if tds_category and not for_validate:
self.apply_tds = 1
self.tax_withholding_category = tds_category
self.set_onload("supplier_tds", tds_category)
@frappe.request_cache
def item_last_purchase_rate(name, conversion_rate, item_code, conversion_factor=1.0):