Merge pull request #22950 from deepeshgarg007/billing_address_fetch
fix: Add default billing address for purchase documents
diff --git a/erpnext/public/js/controllers/transaction.js b/erpnext/public/js/controllers/transaction.js
index 436a232..792235f 100644
--- a/erpnext/public/js/controllers/transaction.js
+++ b/erpnext/public/js/controllers/transaction.js
@@ -781,10 +781,23 @@
else var date = this.frm.doc.transaction_date;
if (frappe.meta.get_docfield(this.frm.doctype, "shipping_address") &&
- in_list(['Purchase Order', 'Purchase Receipt', 'Purchase Invoice'], this.frm.doctype)){
+ in_list(['Purchase Order', 'Purchase Receipt', 'Purchase Invoice'], this.frm.doctype)) {
erpnext.utils.get_shipping_address(this.frm, function(){
set_party_account(set_pricing);
})
+
+ // Get default company billing address in Purchase Invoice, Order and Receipt
+ frappe.call({
+ 'method': 'frappe.contacts.doctype.address.address.get_default_address',
+ 'args': {
+ 'doctype': 'Company',
+ 'name': this.frm.doc.company
+ },
+ 'callback': function(r) {
+ me.frm.set_value('billing_address', r.message);
+ }
+ });
+
} else {
set_party_account(set_pricing);
}