Merge branch 'develop' into mergify/bp/develop/pr-30438

This commit is contained in:
Deepesh Garg
2022-04-09 20:03:23 +05:30
committed by GitHub
1486 changed files with 96181 additions and 63928 deletions

View File

@@ -81,7 +81,7 @@ erpnext.buying.BuyingController = class BuyingController extends erpnext.Transac
}
this.frm.set_query("item_code", "items", function() {
if (me.frm.doc.is_subcontracted == "Yes") {
if (me.frm.doc.is_subcontracted) {
return{
query: "erpnext.controllers.queries.item_query",
filters:{ 'supplier': me.frm.doc.supplier, 'is_sub_contracted_item': 1 }

View File

@@ -688,7 +688,12 @@ erpnext.taxes_and_totals = class TaxesAndTotals extends erpnext.payments {
}));
this.frm.doc.total_advance = flt(total_allocated_amount, precision("total_advance"));
if (this.frm.doc.write_off_outstanding_amount_automatically) {
this.frm.doc.write_off_amount = 0;
}
this.calculate_outstanding_amount(update_paid_amount);
this.calculate_write_off_amount();
}
is_internal_invoice() {
@@ -824,26 +829,23 @@ erpnext.taxes_and_totals = class TaxesAndTotals extends erpnext.payments {
var grand_total = this.frm.doc.rounded_total || this.frm.doc.grand_total;
var base_grand_total = this.frm.doc.base_rounded_total || this.frm.doc.base_grand_total;
this.frm.doc.change_amount = flt(this.frm.doc.paid_amount - grand_total +
this.frm.doc.write_off_amount, precision("change_amount"));
this.frm.doc.change_amount = flt(this.frm.doc.paid_amount - grand_total,
precision("change_amount"));
this.frm.doc.base_change_amount = flt(this.frm.doc.base_paid_amount -
base_grand_total + this.frm.doc.base_write_off_amount,
precision("base_change_amount"));
base_grand_total, precision("base_change_amount"));
}
}
}
calculate_write_off_amount(){
if(this.frm.doc.paid_amount > this.frm.doc.grand_total){
this.frm.doc.write_off_amount = flt(this.frm.doc.grand_total - this.frm.doc.paid_amount
+ this.frm.doc.change_amount, precision("write_off_amount"));
calculate_write_off_amount() {
if(this.frm.doc.write_off_outstanding_amount_automatically) {
this.frm.doc.write_off_amount = flt(this.frm.doc.outstanding_amount, precision("write_off_amount"));
this.frm.doc.base_write_off_amount = flt(this.frm.doc.write_off_amount * this.frm.doc.conversion_rate,
precision("base_write_off_amount"));
}else{
this.frm.doc.paid_amount = 0.0;
this.calculate_outstanding_amount(false);
}
this.calculate_outstanding_amount(false);
}
};

View File

@@ -239,7 +239,7 @@ erpnext.TransactionController = class TransactionController extends erpnext.taxe
() => set_value('currency', currency),
() => set_value('price_list_currency', currency),
() => set_value('status', 'Draft'),
() => set_value('is_subcontracted', 'No'),
() => set_value('is_subcontracted', 0),
() => {
if(this.frm.doc.company && !this.frm.doc.amended_from) {
this.frm.trigger("company");
@@ -345,112 +345,8 @@ erpnext.TransactionController = class TransactionController extends erpnext.taxe
}
scan_barcode() {
let me = this;
if(this.frm.doc.scan_barcode) {
frappe.call({
method: "erpnext.selling.page.point_of_sale.point_of_sale.search_for_serial_or_batch_or_barcode_number",
args: {
search_value: this.frm.doc.scan_barcode
}
}).then(r => {
const data = r && r.message;
if (!data || Object.keys(data).length === 0) {
frappe.show_alert({
message: __('Cannot find Item with this Barcode'),
indicator: 'red'
});
return;
}
me.modify_table_after_scan(data);
});
}
return false;
}
modify_table_after_scan(data) {
let scan_barcode_field = this.frm.fields_dict["scan_barcode"];
let cur_grid = this.frm.fields_dict.items.grid;
let row_to_modify = null;
// Check if batch is scanned and table has batch no field
let batch_no_scan = Boolean(data.batch_no) && frappe.meta.has_field(cur_grid.doctype, "batch_no");
if (batch_no_scan) {
row_to_modify = this.get_batch_row_to_modify(data.batch_no);
} else {
// serial or barcode scan
row_to_modify = this.get_row_to_modify_on_scan(row_to_modify, data);
}
if (!row_to_modify) {
// add new row if new item/batch is scanned
row_to_modify = frappe.model.add_child(this.frm.doc, cur_grid.doctype, 'items');
}
this.show_scan_message(row_to_modify.idx, row_to_modify.item_code);
this.set_scanned_values(row_to_modify, data, scan_barcode_field);
}
set_scanned_values(row_to_modify, data, scan_barcode_field) {
// increase qty and set scanned value and item in row
this.frm.from_barcode = this.frm.from_barcode ? this.frm.from_barcode + 1 : 1;
frappe.model.set_value(row_to_modify.doctype, row_to_modify.name, {
item_code: data.item_code,
qty: (row_to_modify.qty || 0) + 1
});
['serial_no', 'batch_no', 'barcode'].forEach(field => {
if (data[field] && frappe.meta.has_field(row_to_modify.doctype, field)) {
let is_serial_no = row_to_modify[field] && field === "serial_no";
let value = data[field];
if (is_serial_no) {
value = row_to_modify[field] + '\n' + data[field];
}
frappe.model.set_value(row_to_modify.doctype, row_to_modify.name, field, value);
}
});
scan_barcode_field.set_value('');
refresh_field("items");
}
get_row_to_modify_on_scan(row_to_modify, data) {
// get an existing item row to increment or blank row to modify
const existing_item_row = this.frm.doc.items.find(d => d.item_code === data.item_code);
const blank_item_row = this.frm.doc.items.find(d => !d.item_code);
if (existing_item_row) {
row_to_modify = existing_item_row;
} else if (blank_item_row) {
row_to_modify = blank_item_row;
}
return row_to_modify;
}
get_batch_row_to_modify(batch_no) {
// get row if batch already exists in table
const existing_batch_row = this.frm.doc.items.find(d => d.batch_no === batch_no);
return existing_batch_row || null;
}
show_scan_message (idx, exist = null) {
// show new row or qty increase toast
if (exist) {
frappe.show_alert({
message: __('Row #{0}: Qty increased by 1', [idx]),
indicator: 'green'
});
} else {
frappe.show_alert({
message: __('Row #{0}: Item added', [idx]),
indicator: 'green'
});
}
const barcode_scanner = new erpnext.utils.BarcodeScanner({frm:this.frm});
barcode_scanner.process_scan();
}
apply_default_taxes() {
@@ -507,17 +403,6 @@ erpnext.TransactionController = class TransactionController extends erpnext.taxe
var sms_man = new erpnext.SMSManager(this.frm.doc);
}
barcode(doc, cdt, cdn) {
var d = locals[cdt][cdn];
if(d.barcode=="" || d.barcode==null) {
// barcode cleared, remove item
d.item_code = "";
}
this.frm.from_barcode = this.frm.from_barcode ? this.frm.from_barcode + 1 : 1;
this.item_code(doc, cdt, cdn);
}
item_code(doc, cdt, cdn) {
var me = this;
var item = frappe.get_doc(cdt, cdn);
@@ -535,11 +420,7 @@ erpnext.TransactionController = class TransactionController extends erpnext.taxe
this.frm.doc.doctype === 'Delivery Note') {
show_batch_dialog = 1;
}
// clear barcode if setting item (else barcode will take priority)
if (this.frm.from_barcode == 0) {
item.barcode = null;
}
this.frm.from_barcode = this.frm.from_barcode - 1 >= 0 ? this.frm.from_barcode - 1 : 0;
item.barcode = null;
if(item.item_code || item.barcode || item.serial_no) {
@@ -645,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;
}