mirror of
https://github.com/frappe/erpnext.git
synced 2026-09-18 19:07:55 +00:00
Merge branch 'develop' into patch-8
This commit is contained in:
@@ -276,74 +276,3 @@ erpnext.taxes.set_conditional_mandatory_rate_or_amount = function(grid_row) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// For customizing print
|
||||
cur_frm.pformat.total = function(doc) { return ''; }
|
||||
cur_frm.pformat.discount_amount = function(doc) { return ''; }
|
||||
cur_frm.pformat.grand_total = function(doc) { return ''; }
|
||||
cur_frm.pformat.rounded_total = function(doc) { return ''; }
|
||||
cur_frm.pformat.in_words = function(doc) { return ''; }
|
||||
|
||||
cur_frm.pformat.taxes= function(doc){
|
||||
//function to make row of table
|
||||
var make_row = function(title, val, bold, is_negative) {
|
||||
var bstart = '<b>'; var bend = '</b>';
|
||||
return '<tr><td style="width:50%;">' + (bold?bstart:'') + title + (bold?bend:'') + '</td>'
|
||||
+ '<td style="width:50%;text-align:right;">' + (is_negative ? '- ' : '')
|
||||
+ format_currency(val, doc.currency) + '</td></tr>';
|
||||
}
|
||||
|
||||
function print_hide(fieldname) {
|
||||
var doc_field = frappe.meta.get_docfield(doc.doctype, fieldname, doc.name);
|
||||
return doc_field.print_hide;
|
||||
}
|
||||
|
||||
out ='';
|
||||
if (!doc.print_without_amount) {
|
||||
var cl = doc.taxes || [];
|
||||
|
||||
// outer table
|
||||
var out='<div><table class="noborder" style="width:100%"><tr><td style="width: 60%"></td><td>';
|
||||
|
||||
// main table
|
||||
|
||||
out +='<table class="noborder" style="width:100%">';
|
||||
|
||||
if(!print_hide('total')) {
|
||||
out += make_row('Total', doc.total, 1);
|
||||
}
|
||||
|
||||
// Discount Amount on net total
|
||||
if(!print_hide('discount_amount') && doc.apply_discount_on == "Net Total" && doc.discount_amount)
|
||||
out += make_row('Discount Amount', doc.discount_amount, 0, 1);
|
||||
|
||||
// add rows
|
||||
if(cl.length){
|
||||
for(var i=0;i<cl.length;i++) {
|
||||
if(cl[i].tax_amount!=0 && !cl[i].included_in_print_rate)
|
||||
out += make_row(cl[i].description, cl[i].tax_amount, 0);
|
||||
}
|
||||
}
|
||||
|
||||
// Discount Amount on grand total
|
||||
if(!print_hide('discount_amount') && doc.apply_discount_on == "Grand Total" && doc.discount_amount)
|
||||
out += make_row('Discount Amount', doc.discount_amount, 0, 1);
|
||||
|
||||
// grand total
|
||||
if(!print_hide('grand_total'))
|
||||
out += make_row('Grand Total', doc.grand_total, 1);
|
||||
|
||||
if(!print_hide('rounded_total'))
|
||||
out += make_row('Rounded Total', doc.rounded_total, 1);
|
||||
|
||||
if(doc.in_words && !print_hide('in_words')) {
|
||||
out +='</table></td></tr>';
|
||||
out += '<tr><td colspan = "2">';
|
||||
out += '<table><tr><td style="width:25%;"><b>In Words</b></td>';
|
||||
out += '<td style="width:50%;">' + doc.in_words + '</td></tr>';
|
||||
}
|
||||
out += '</table></td></tr></table></div>';
|
||||
}
|
||||
return out;
|
||||
}
|
||||
@@ -577,7 +577,7 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({
|
||||
var d = locals[cdt][cdn];
|
||||
me.add_taxes_from_item_tax_template(d.item_tax_rate);
|
||||
if (d.free_item_data) {
|
||||
me.apply_product_discount(d.free_item_data);
|
||||
me.apply_product_discount(d);
|
||||
}
|
||||
},
|
||||
() => {
|
||||
@@ -737,34 +737,34 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({
|
||||
this.frm.trigger("item_code", cdt, cdn);
|
||||
}
|
||||
else {
|
||||
var valid_serial_nos = [];
|
||||
|
||||
// Replacing all occurences of comma with carriage return
|
||||
var serial_nos = item.serial_no.trim().replace(/,/g, '\n');
|
||||
|
||||
serial_nos = serial_nos.trim().split('\n');
|
||||
|
||||
// Trim each string and push unique string to new list
|
||||
for (var x=0; x<=serial_nos.length - 1; x++) {
|
||||
if (serial_nos[x].trim() != "" && valid_serial_nos.indexOf(serial_nos[x].trim()) == -1) {
|
||||
valid_serial_nos.push(serial_nos[x].trim());
|
||||
}
|
||||
}
|
||||
|
||||
// Add the new list to the serial no. field in grid with each in new line
|
||||
item.serial_no = valid_serial_nos.join('\n');
|
||||
item.serial_no = item.serial_no.replace(/,/g, '\n');
|
||||
item.conversion_factor = item.conversion_factor || 1;
|
||||
|
||||
refresh_field("serial_no", item.name, item.parentfield);
|
||||
if(!doc.is_return && cint(user_defaults.set_qty_in_transactions_based_on_serial_no_input)) {
|
||||
frappe.model.set_value(item.doctype, item.name,
|
||||
"qty", valid_serial_nos.length / item.conversion_factor);
|
||||
frappe.model.set_value(item.doctype, item.name, "stock_qty", valid_serial_nos.length);
|
||||
if (!doc.is_return && cint(frappe.user_defaults.set_qty_in_transactions_based_on_serial_no_input)) {
|
||||
setTimeout(() => {
|
||||
me.update_qty(cdt, cdn);
|
||||
}, 10000);
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
update_qty: function(cdt, cdn) {
|
||||
var valid_serial_nos = [];
|
||||
var serialnos = [];
|
||||
var item = frappe.get_doc(cdt, cdn);
|
||||
serialnos = item.serial_no.split("\n");
|
||||
for (var i = 0; i < serialnos.length; i++) {
|
||||
if (serialnos[i] != "") {
|
||||
valid_serial_nos.push(serialnos[i]);
|
||||
}
|
||||
}
|
||||
frappe.model.set_value(item.doctype, item.name,
|
||||
"qty", valid_serial_nos.length / item.conversion_factor);
|
||||
frappe.model.set_value(item.doctype, item.name, "stock_qty", valid_serial_nos.length);
|
||||
},
|
||||
|
||||
validate: function() {
|
||||
this.calculate_taxes_and_totals(false);
|
||||
},
|
||||
@@ -1173,6 +1173,11 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({
|
||||
this.calculate_net_weight();
|
||||
}
|
||||
|
||||
// for handling customization not to fetch price list rate
|
||||
if(frappe.flags.dont_fetch_price_list_rate) {
|
||||
return
|
||||
}
|
||||
|
||||
if (!dont_fetch_price_list_rate &&
|
||||
frappe.meta.has_field(doc.doctype, "price_list_currency")) {
|
||||
this.apply_price_list(item, true);
|
||||
@@ -1204,7 +1209,7 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({
|
||||
|
||||
calculate_stock_uom_rate: function(doc, cdt, cdn) {
|
||||
let item = frappe.get_doc(cdt, cdn);
|
||||
item.stock_uom_rate = flt(item.rate)/flt(item.conversion_factor);
|
||||
item.stock_uom_rate = flt(item.rate)/flt(item.conversion_factor);
|
||||
refresh_field("stock_uom_rate", item.name, item.parentfield);
|
||||
},
|
||||
service_stop_date: function(frm, cdt, cdn) {
|
||||
@@ -1533,7 +1538,10 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({
|
||||
if(k=="price_list_rate") {
|
||||
if(flt(v) != flt(d.price_list_rate)) price_list_rate_changed = true;
|
||||
}
|
||||
frappe.model.set_value(d.doctype, d.name, k, v);
|
||||
|
||||
if (k !== 'free_item_data') {
|
||||
frappe.model.set_value(d.doctype, d.name, k, v);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1545,7 +1553,7 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({
|
||||
}
|
||||
|
||||
if (d.free_item_data) {
|
||||
me.apply_product_discount(d.free_item_data);
|
||||
me.apply_product_discount(d);
|
||||
}
|
||||
|
||||
if (d.apply_rule_on_other_items) {
|
||||
@@ -1579,20 +1587,31 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({
|
||||
}
|
||||
},
|
||||
|
||||
apply_product_discount: function(free_item_data) {
|
||||
const items = this.frm.doc.items.filter(d => (d.item_code == free_item_data.item_code
|
||||
&& d.is_free_item)) || [];
|
||||
apply_product_discount: function(args) {
|
||||
const items = this.frm.doc.items.filter(d => (d.is_free_item)) || [];
|
||||
|
||||
if (!items.length) {
|
||||
let row_to_modify = frappe.model.add_child(this.frm.doc,
|
||||
this.frm.doc.doctype + ' Item', 'items');
|
||||
const exist_items = items.map(row => (row.item_code, row.pricing_rules));
|
||||
|
||||
for (let key in free_item_data) {
|
||||
row_to_modify[key] = free_item_data[key];
|
||||
args.free_item_data.forEach(pr_row => {
|
||||
let row_to_modify = {};
|
||||
if (!items || !in_list(exist_items, (pr_row.item_code, pr_row.pricing_rules))) {
|
||||
|
||||
row_to_modify = frappe.model.add_child(this.frm.doc,
|
||||
this.frm.doc.doctype + ' Item', 'items');
|
||||
|
||||
} else if(items) {
|
||||
row_to_modify = items.filter(d => (d.item_code === pr_row.item_code
|
||||
&& d.pricing_rules === pr_row.pricing_rules))[0];
|
||||
}
|
||||
} if (items && items.length && free_item_data) {
|
||||
items[0].qty = free_item_data.qty
|
||||
}
|
||||
|
||||
for (let key in pr_row) {
|
||||
row_to_modify[key] = pr_row[key];
|
||||
}
|
||||
});
|
||||
|
||||
// free_item_data is a temporary variable
|
||||
args.free_item_data = '';
|
||||
refresh_field('items');
|
||||
},
|
||||
|
||||
apply_price_list: function(item, reset_plc_conversion) {
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user