fix: Item valuation for internal stock transfers (#24200)
* fix: Item valuation for internal stocktransfers * fix: Consider conversion factor for invoices * fix: Add missing set warehouse fields * fix: Add validations and other fixes * fix: Fixes in flow * fix: Internal sales item link in Purchase Invoice * fix: Debugging * fix: Debug travis * fix: Remove commented code * fix: Rate forcing in sales order * fix: Unreallized profit in Sales Register * fix: Item wise gst sales register fix * fix: From warehouse in Purchase Order * fix: Target field in Sales Invoice * fix: remove self * fix: GST Purchasse register and other fixes * fix: Add shipping_address to no field map * fix: Ref doc map * fix: Test Cases * fix: address mapping between sales and purchase document * fix: Import Error * fix: Tax updation for internal invoices * fix: Purchase Order and Invoice linking * fix: Internal Party validation fix * fix: validation * fix(india): GST Taxes for intra state transfer * fix(india): GST Taxes for intra state transfer Co-authored-by: Nabin Hait <nabinhait@gmail.com>
This commit is contained in:
@@ -105,10 +105,18 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({
|
||||
frappe.ui.form.on(this.frm.doctype + " Item", {
|
||||
items_add: function(frm, cdt, cdn) {
|
||||
var item = frappe.get_doc(cdt, cdn);
|
||||
if(!item.warehouse && frm.doc.set_warehouse) {
|
||||
if (!item.warehouse && frm.doc.set_warehouse) {
|
||||
item.warehouse = frm.doc.set_warehouse;
|
||||
}
|
||||
|
||||
if (!item.target_warehouse && frm.doc.set_target_warehouse) {
|
||||
item.target_warehouse = frm.doc.set_target_warehouse;
|
||||
}
|
||||
|
||||
if (!item.from_warehouse && frm.doc.set_from_warehouse) {
|
||||
item.from_warehouse = frm.doc.set_from_warehouse;
|
||||
}
|
||||
|
||||
erpnext.accounts.dimensions.copy_dimension_from_first_row(frm, cdt, cdn, 'items');
|
||||
}
|
||||
});
|
||||
@@ -227,6 +235,8 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({
|
||||
}
|
||||
};
|
||||
|
||||
this.frm.trigger('set_default_internal_warehouse');
|
||||
|
||||
return frappe.run_serially([
|
||||
() => set_value('currency', currency),
|
||||
() => set_value('price_list_currency', currency),
|
||||
@@ -658,7 +668,7 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({
|
||||
args: item_args
|
||||
},
|
||||
callback: function(r) {
|
||||
frappe.model.set_value(item.doctype, item.name, 'rate', r.message);
|
||||
frappe.model.set_value(item.doctype, item.name, 'rate', r.message * item.conversion_factor);
|
||||
}
|
||||
});
|
||||
},
|
||||
@@ -724,6 +734,31 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({
|
||||
this.calculate_taxes_and_totals(false);
|
||||
},
|
||||
|
||||
update_stock: function() {
|
||||
this.frm.trigger('set_default_internal_warehouse');
|
||||
},
|
||||
|
||||
set_default_internal_warehouse: function() {
|
||||
let me = this;
|
||||
if ((this.frm.doc.doctype === 'Sales Invoice' && me.frm.doc.update_stock)
|
||||
|| this.frm.doc.doctype == 'Delivery Note') {
|
||||
if (this.frm.doc.is_internal_customer && this.frm.doc.company === this.frm.doc.represents_company) {
|
||||
frappe.db.get_value('Company', this.frm.doc.company, 'default_in_transit_warehouse', function(value) {
|
||||
me.frm.set_value('set_target_warehouse', value.default_in_transit_warehouse);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if ((this.frm.doc.doctype === 'Purchase Invoice' && me.frm.doc.update_stock)
|
||||
|| this.frm.doc.doctype == 'Purchase Receipt') {
|
||||
if (this.frm.doc.is_internal_supplier && this.frm.doc.company === this.frm.doc.represents_company) {
|
||||
frappe.db.get_value('Company', this.frm.doc.company, 'default_in_transit_warehouse', function(value) {
|
||||
me.frm.set_value('set_from_warehouse', value.default_in_transit_warehouse);
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
company: function() {
|
||||
var me = this;
|
||||
var set_pricing = function() {
|
||||
@@ -810,7 +845,7 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({
|
||||
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({
|
||||
@@ -1977,6 +2012,14 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({
|
||||
this.autofill_warehouse(this.frm.doc.items, "warehouse", this.frm.doc.set_warehouse);
|
||||
},
|
||||
|
||||
set_target_warehouse: function() {
|
||||
this.autofill_warehouse(this.frm.doc.items, "target_warehouse", this.frm.doc.set_target_warehouse);
|
||||
},
|
||||
|
||||
set_from_warehouse: function() {
|
||||
this.autofill_warehouse(this.frm.doc.items, "from_warehouse", this.frm.doc.set_from_warehouse);
|
||||
},
|
||||
|
||||
autofill_warehouse : function (child_table, warehouse_field, warehouse) {
|
||||
if (warehouse && child_table && child_table.length) {
|
||||
let doctype = child_table[0].doctype;
|
||||
|
||||
Reference in New Issue
Block a user