mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-25 16:04:46 +00:00
Merge branch 'develop' into subcontracting
This commit is contained in:
@@ -27,7 +27,8 @@ frappe.ui.form.on(cur_frm.doctype, {
|
||||
query: "erpnext.controllers.queries.tax_account_query",
|
||||
filters: {
|
||||
"account_type": account_type,
|
||||
"company": doc.company
|
||||
"company": doc.company,
|
||||
"disabled": 0
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -90,7 +90,7 @@ erpnext.buying.BuyingController = class BuyingController extends erpnext.Transac
|
||||
else {
|
||||
return{
|
||||
query: "erpnext.controllers.queries.item_query",
|
||||
filters: { 'supplier': me.frm.doc.supplier, 'is_purchase_item': 1 }
|
||||
filters: { 'supplier': me.frm.doc.supplier, 'is_purchase_item': 1, 'has_variants': 0}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -34,12 +34,12 @@ erpnext.taxes_and_totals = class TaxesAndTotals extends erpnext.payments {
|
||||
frappe.model.set_value(item.doctype, item.name, "rate", item_rate);
|
||||
}
|
||||
|
||||
calculate_taxes_and_totals(update_paid_amount) {
|
||||
async calculate_taxes_and_totals(update_paid_amount) {
|
||||
this.discount_amount_applied = false;
|
||||
this._calculate_taxes_and_totals();
|
||||
this.calculate_discount_amount();
|
||||
|
||||
this.calculate_shipping_charges();
|
||||
await this.calculate_shipping_charges();
|
||||
|
||||
// Advance calculation applicable to Sales /Purchase Invoice
|
||||
if(in_list(["Sales Invoice", "POS Invoice", "Purchase Invoice"], this.frm.doc.doctype)
|
||||
@@ -273,10 +273,14 @@ erpnext.taxes_and_totals = class TaxesAndTotals extends erpnext.payments {
|
||||
}
|
||||
|
||||
calculate_shipping_charges() {
|
||||
// Do not apply shipping rule for POS
|
||||
if (this.frm.doc.is_pos) {
|
||||
return;
|
||||
}
|
||||
|
||||
frappe.model.round_floats_in(this.frm.doc, ["total", "base_total", "net_total", "base_net_total"]);
|
||||
if (frappe.meta.get_docfield(this.frm.doc.doctype, "shipping_rule", this.frm.doc.name)) {
|
||||
this.shipping_rule();
|
||||
this._calculate_taxes_and_totals();
|
||||
return this.shipping_rule();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -403,17 +403,6 @@ erpnext.TransactionController = class TransactionController extends erpnext.taxe
|
||||
var sms_man = new erpnext.SMSManager(this.frm.doc);
|
||||
}
|
||||
|
||||
barcode(doc, cdt, cdn) {
|
||||
const d = locals[cdt][cdn];
|
||||
if (!d.barcode) {
|
||||
// barcode cleared, remove item
|
||||
d.item_code = "";
|
||||
}
|
||||
// flag required for circular triggers
|
||||
d._triggerd_from_barcode = true;
|
||||
this.item_code(doc, cdt, cdn);
|
||||
}
|
||||
|
||||
item_code(doc, cdt, cdn) {
|
||||
var me = this;
|
||||
var item = frappe.get_doc(cdt, cdn);
|
||||
@@ -431,9 +420,7 @@ erpnext.TransactionController = class TransactionController extends erpnext.taxe
|
||||
this.frm.doc.doctype === 'Delivery Note') {
|
||||
show_batch_dialog = 1;
|
||||
}
|
||||
if (!item._triggerd_from_barcode) {
|
||||
item.barcode = null;
|
||||
}
|
||||
item.barcode = null;
|
||||
|
||||
|
||||
if(item.item_code || item.barcode || item.serial_no) {
|
||||
@@ -539,6 +526,12 @@ erpnext.TransactionController = class TransactionController extends erpnext.taxe
|
||||
if(!d[k]) d[k] = v;
|
||||
});
|
||||
|
||||
if (d.__disable_batch_serial_selector) {
|
||||
// reset for future use.
|
||||
d.__disable_batch_serial_selector = false;
|
||||
return;
|
||||
}
|
||||
|
||||
if (d.has_batch_no && d.has_serial_no) {
|
||||
d.batch_no = undefined;
|
||||
}
|
||||
@@ -930,12 +923,12 @@ erpnext.TransactionController = class TransactionController extends erpnext.taxe
|
||||
}
|
||||
|
||||
currency() {
|
||||
/* manqala 19/09/2016: let the translation date be whichever of the transaction_date or posting_date is available */
|
||||
var transaction_date = this.frm.doc.transaction_date || this.frm.doc.posting_date;
|
||||
/* end manqala */
|
||||
var me = this;
|
||||
// The transaction date be either transaction_date (from orders) or posting_date (from invoices)
|
||||
let transaction_date = this.frm.doc.transaction_date || this.frm.doc.posting_date;
|
||||
|
||||
let me = this;
|
||||
this.set_dynamic_labels();
|
||||
var company_currency = this.get_company_currency();
|
||||
let company_currency = this.get_company_currency();
|
||||
// Added `ignore_price_list` to determine if document is loading after mapping from another doc
|
||||
if(this.frm.doc.currency && this.frm.doc.currency !== company_currency
|
||||
&& !(this.frm.doc.__onload && this.frm.doc.__onload.ignore_price_list)) {
|
||||
@@ -949,7 +942,9 @@ erpnext.TransactionController = class TransactionController extends erpnext.taxe
|
||||
}
|
||||
});
|
||||
} else {
|
||||
this.conversion_rate();
|
||||
// company currency and doc currency is same
|
||||
// this will prevent unnecessary conversion rate triggers
|
||||
this.frm.set_value("conversion_rate", 1.0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -981,6 +976,9 @@ erpnext.TransactionController = class TransactionController extends erpnext.taxe
|
||||
return this.frm.call({
|
||||
doc: this.frm.doc,
|
||||
method: "apply_shipping_rule",
|
||||
callback: function(r) {
|
||||
me._calculate_taxes_and_totals();
|
||||
}
|
||||
}).fail(() => this.frm.set_value('shipping_rule', ''));
|
||||
}
|
||||
}
|
||||
@@ -1388,7 +1386,15 @@ erpnext.TransactionController = class TransactionController extends erpnext.taxe
|
||||
var me = this;
|
||||
var args = this._get_args(item);
|
||||
if (!(args.items && args.items.length)) {
|
||||
if(calculate_taxes_and_totals) me.calculate_taxes_and_totals();
|
||||
if (calculate_taxes_and_totals) me.calculate_taxes_and_totals();
|
||||
return;
|
||||
}
|
||||
|
||||
// Target doc created from a mapped doc
|
||||
if (this.frm.doc.__onload && this.frm.doc.__onload.ignore_price_list) {
|
||||
// Calculate totals even though pricing rule is not applied.
|
||||
// `apply_pricing_rule` is triggered due to change in data which most likely contributes to Total.
|
||||
if (calculate_taxes_and_totals) me.calculate_taxes_and_totals();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1508,7 +1514,7 @@ erpnext.TransactionController = class TransactionController extends erpnext.taxe
|
||||
me.remove_pricing_rule(frappe.get_doc(d.doctype, d.name));
|
||||
}
|
||||
|
||||
if (d.free_item_data) {
|
||||
if (d.free_item_data.length > 0) {
|
||||
me.apply_product_discount(d);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user