feat: Inter warehouse stock transfer on valuation rate with taxation (#20083)
* fix: Validation for target warehouse
* feat: Get items on valuation rate in delivery note on Internal transfers
* fix: Create Inter company purchase receipt from delivery note
* feat: Inter company stock transfer on valuation rate with taxation
* fix: Add from warehouse in purchase invoice
* fix: Use get_value instead of get_cached_value
* fix: Get incoming rate instead of valuation rate
* fix: GL entry for from warehouse in purchase receipt
* fix: GL Entries fixes in purchase invoice
* fix: Address and tax fetching fixes
* fix: Add test case for stock transfer via purchase receipt
* fix: Code cleanup, added validations and test cases
* fix: Validation for supplier warehouse
* fix: Test Cases
* fix: Change validation condition
* fix: Address fixes while creating Purchase Receipt from delivery note
* fix: Set taxes while creating Purchase Receipt from Delivery Note
* fix: Update set_missing_value function
Co-authored-by: Nabin Hait <nabinhait@gmail.com>
diff --git a/erpnext/public/js/controllers/transaction.js b/erpnext/public/js/controllers/transaction.js
index 51ab48a..9146479 100644
--- a/erpnext/public/js/controllers/transaction.js
+++ b/erpnext/public/js/controllers/transaction.js
@@ -490,7 +490,7 @@
cost_center: item.cost_center,
tax_category: me.frm.doc.tax_category,
item_tax_template: item.item_tax_template,
- child_docname: item.name,
+ child_docname: item.name
}
},
@@ -504,7 +504,20 @@
me.apply_product_discount(d.free_item_data);
}
},
- () => me.frm.script_manager.trigger("price_list_rate", cdt, cdn),
+ () => {
+ // for internal customer instead of pricing rule directly apply valuation rate on item
+ if (me.frm.doc.is_internal_customer || me.frm.doc.is_internal_supplier) {
+ me.get_incoming_rate(item, me.frm.posting_date, me.frm.posting_time,
+ me.frm.doc.doctype, me.frm.doc.company);
+ } else {
+ me.frm.script_manager.trigger("price_list_rate", cdt, cdn);
+ }
+ },
+ () => {
+ if (me.frm.doc.is_internal_customer || me.frm.doc.is_internal_supplier) {
+ me.calculate_taxes_and_totals();
+ }
+ },
() => me.toggle_conversion_factor(item),
() => {
if(show_batch_dialog && !frappe.flags.hide_serial_batch_dialog) {
@@ -528,6 +541,31 @@
}
},
+ get_incoming_rate: function(item, posting_date, posting_time, voucher_type, company) {
+
+ let item_args = {
+ 'item_code': item.item_code,
+ 'warehouse': in_list('Purchase Receipt', 'Purchase Invoice') ? item.from_warehouse : item.warehouse,
+ 'posting_date': posting_date,
+ 'posting_time': posting_time,
+ 'qty': item.qty * item.conversion_factor,
+ 'serial_no': item.serial_no,
+ 'voucher_type': voucher_type,
+ 'company': company,
+ 'allow_zero_valuation_rate': item.allow_zero_valuation_rate
+ }
+
+ frappe.call({
+ method: 'erpnext.stock.utils.get_incoming_rate',
+ args: {
+ args: item_args
+ },
+ callback: function(r) {
+ frappe.model.set_value(item.doctype, item.name, 'rate', r.message);
+ }
+ });
+ },
+
add_taxes_from_item_tax_template: function(item_tax_map) {
let me = this;