fix: serial no trim issue (#24949)

* fix: serial no trim issue

* fix: valid serial nos

* fix: sider

Co-authored-by: Marica <maricadsouza221197@gmail.com>
This commit is contained in:
Jannat Patel 2021-03-23 21:09:49 +05:30 committed by GitHub
parent 02142c41bb
commit 12f0923a61
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -738,21 +738,15 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({
} }
else { else {
var valid_serial_nos = []; var valid_serial_nos = [];
var serialnos = [];
// Replacing all occurences of comma with carriage return // Replacing all occurences of comma with carriage return
var serial_nos = item.serial_no.trim().replace(/,/g, '\n'); item.serial_no = item.serial_no.replace(/,/g, '\n');
serialnos = item.serial_no.split("\n");
serial_nos = serial_nos.trim().split('\n'); for (var i = 0; i < serialnos.length; i++) {
if (serialnos[i] != "") {
// Trim each string and push unique string to new list valid_serial_nos.push(serialnos[i]);
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.conversion_factor = item.conversion_factor || 1; item.conversion_factor = item.conversion_factor || 1;
refresh_field("serial_no", item.name, item.parentfield); refresh_field("serial_no", item.name, item.parentfield);