Skip to content

Commit

Permalink
fix: tds workflow in purchase order
Browse files Browse the repository at this point in the history
(cherry picked from commit a7888b2)
  • Loading branch information
ljain112 authored and mergify[bot] committed Sep 16, 2024
1 parent 2ad6d63 commit 11359bd
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
36 changes: 36 additions & 0 deletions erpnext/buying/doctype/purchase_order/purchase_order.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [];

Expand Down Expand Up @@ -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);
});
Expand Down
7 changes: 7 additions & 0 deletions erpnext/buying/doctype/purchase_order/purchase_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -648,6 +648,13 @@ def update_subcontracting_order_status(self):
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):
Expand Down

0 comments on commit 11359bd

Please sign in to comment.