Commit 77ee7e89 authored by Malcolm Blaney's avatar Malcolm Blaney

When importing a single supplier list and the group pre-orders,

make everything in the list available. Also changed the way the
quantity column is used for multi supplier format, now considered
to be total quantity and if it's changed in the import data an
adjustment is created for the item.
parent 60980989
Pipeline #5151546 (#) failed with stage
in 1 minute and 24 seconds
......@@ -10,6 +10,7 @@ variables:
before_script:
- apt-get update -y
- apt-get install -y php5-mysqlnd
- service apache2 restart
- curl --location --output /usr/local/bin/phpunit https://phar.phpunit.de/phpunit.phar
- chmod +x /usr/local/bin/phpunit
......
This diff is collapsed.
......@@ -37,7 +37,7 @@ columns.push({id:"supplierAvailable",name:"S",field:"supplierAvailable",width:20
else{resetForm();}});stockGrid.onSort.subscribe(function(e,args){stock.products.sort(function(row1,row2){var field=args.sortCol.field;var sign=args.sortAsc?1:-1;var value1=row1[field];var value2=row2[field];if(field==="price"){value1=parseFloat(value1);value2=parseFloat(value2);}
if(value1===value2){return 0;}
if(value1>value2){return sign;}
else{return sign* -1;}});stockGrid.invalidate();});if($(".grid").length===2&&stock.trackQuantity){var adjustmentColumns=[{id:"product",name:"Product",field:"name",width:200,sortable:true},{id:"supplier",name:"Supplier",field:"supplier",width:130,sortable:true},{id:"date",name:"Date",field:"date",width:110,sortable:true,formatter:Slick.Formatters.Timestamp},{id:"adjustment",name:"Adjustment",field:"adjustment",width:120,sortable:true}];var adjustmentOptions={enableColumnReorder:false,forceFitColumns:true};$(adjustmentGridId).appendTo($(".stock-adjustment-grid"));$(adjustmentGridId).css("width","560px");adjustmentGrid=dobrado.grid.instance(adjustmentGridId,[],adjustmentColumns,adjustmentOptions);adjustmentGrid.setSelectionModel(new Slick.RowSelectionModel());adjustmentGrid.onClick.subscribe(function(e,item){showAdjustment(item.row);});adjustmentGrid.onSelectedRowsChanged.subscribe(function(e,item){if(item.rows.length===1){showAdjustment(item.rows[0]);}});adjustmentGrid.onSort.subscribe(function(e,args){adjustmentData.sort(function(row1,row2){var field=args.sortCol.field;var sign=args.sortAsc?1:-1;var value1=row1[field];var value2=row2[field];if(field!=="product"&&field!=="supplier"){value1=parseFloat(value1);value2=parseFloat(value2);}
else{return sign* -1;}});stockGrid.invalidate();});if($(".grid").length===2&&stock.trackQuantity){var adjustmentColumns=[{id:"product",name:"Product",field:"name",width:200,sortable:true},{id:"supplier",name:"Supplier",field:"supplier",width:130,sortable:true},{id:"date",name:"Date",field:"date",width:110,sortable:true,formatter:Slick.Formatters.Timestamp},{id:"adjustment",name:"Adjustment",field:"adjustment",width:120,sortable:true}];var adjustmentOptions={enableColumnReorder:false,forceFitColumns:true};$(adjustmentGridId).appendTo($(".stock-adjustment-grid"));$(adjustmentGridId+" .view").css("width","560px");adjustmentGrid=dobrado.grid.instance(adjustmentGridId,[],adjustmentColumns,adjustmentOptions);adjustmentGrid.setSelectionModel(new Slick.RowSelectionModel());adjustmentGrid.onClick.subscribe(function(e,item){showAdjustment(item.row);});adjustmentGrid.onSelectedRowsChanged.subscribe(function(e,item){if(item.rows.length===1){showAdjustment(item.rows[0]);}});adjustmentGrid.onSort.subscribe(function(e,args){adjustmentData.sort(function(row1,row2){var field=args.sortCol.field;var sign=args.sortAsc?1:-1;var value1=row1[field];var value2=row2[field];if(field!=="product"&&field!=="supplier"){value1=parseFloat(value1);value2=parseFloat(value2);}
if(value1===value2){return 0;}
if(value1>value2){return sign;}
else{return sign* -1;}});adjustmentGrid.invalidate();});}}
......@@ -140,10 +140,10 @@ if(importData.length===0){if(processEcoFarmsData(data)){if(importSupplier===""){
if(importData.length===0){importSupplier="";processExportData(data);}
if(importData.length===0){alert("Couldn't process data from imported file.");$("#stock-import-file").val("");}
else{dobrado.log("Importing stock list...","info");$.post("/php/request.php",{request:"stock",action:"import",data:JSON.stringify(importData),supplier:importSupplier,url:location.href,token:dobrado.token},function(response){if(dobrado.checkResponseError(response,"stock loadImportData")){return;}
stock=JSON.parse(response);$("#stock-import-file").val("");if(stock.newCount!==0){var text="<b>Import finished:</b> ";if(stock.newCount===1){text+="Showing 1 item that is now available";}
stock=JSON.parse(response);$("#stock-import-file").val("");var text="<b>Import finished:</b> Showing all items (0 new)<br>";if(stock.newCount!==0){text="<b>Import finished:</b> ";if(stock.newCount===1){text+="Showing 1 item that is now available";}
else{text+="Showing "+stock.newCount+" items that are now available";}
$(".stock-new-available").html(text);$(".stock-list-all").show();$(".stock-list-alternative").hide();$(".stock-export-available").hide();$(".stock-export-all").hide();$(".stock-show-hidden").hide();}
if(stockGrid){stockGrid.setData(stock.products);stockGrid.updateRowCount();stockGrid.render();stockGrid.setSelectedRows([]);stockGrid.scrollRowIntoView(0);}});}};reader.readAsText(file);}
$(".stock-list-all").show();$(".stock-list-alternative").hide();$(".stock-export-available").hide();$(".stock-export-all").hide();$(".stock-show-hidden").hide();}
$(".stock-new-available").html(text);if(stockGrid){stockGrid.setData(stock.products);stockGrid.updateRowCount();stockGrid.render();stockGrid.setSelectedRows([]);stockGrid.scrollRowIntoView(0);}});}};reader.readAsText(file);}
function processFoodConnectData(data){var headerFound=false;var headerCheck=0;var emptyLineCount=0;importSupplier=$("#stock-user-input").val();$.each(data,function(i,item){item=item.replace(/\".*?\"/g,function(match){match=match.replace(/,/g,"");return match.replace(/\"/g,"");});var re=/^,?(.*),*[\r\n]*$/;var match=item.match(re);var row=[];if(match.length===2){row=match[1].split(",");}
if(row.length>=9){if(!headerFound){if(row[0].trim().toLowerCase()==="product"&&(row[1].substring(0,11)==="Description"||row[2].substring(0,8)==="Quantity"||row[3]==="Pack Size"||row[4]==="Unit"||row[5]==="Unit Price"||row[6]==="Total"||row[7].substring(0,3)==="GST"||row[8].substring(0,6)==="Grower")){headerFound=true;if(importSupplier===""){return false;}}
else if(headerCheck>40){return false;}
......
......@@ -254,7 +254,7 @@ if (!this.dobrado.stock) {
// Want the grid module to be part of the dialog, so move it.
$(adjustmentGridId).appendTo($(".stock-adjustment-grid"));
$(adjustmentGridId).css("width", "560px");
$(adjustmentGridId + " .view").css("width", "560px");
adjustmentGrid = dobrado.grid.instance(adjustmentGridId, [],
adjustmentColumns,
adjustmentOptions);
......@@ -1229,8 +1229,9 @@ if (!this.dobrado.stock) {
}
stock = JSON.parse(response);
$("#stock-import-file").val("");
var text = "<b>Import finished:</b> Showing all items (0 new)<br>";
if (stock.newCount !== 0) {
var text = "<b>Import finished:</b> ";
text = "<b>Import finished:</b> ";
if (stock.newCount === 1) {
text += "Showing 1 item that is now available";
}
......@@ -1238,13 +1239,13 @@ if (!this.dobrado.stock) {
text += "Showing " + stock.newCount +
" items that are now available";
}
$(".stock-new-available").html(text);
$(".stock-list-all").show();
$(".stock-list-alternative").hide();
$(".stock-export-available").hide();
$(".stock-export-all").hide();
$(".stock-show-hidden").hide();
}
$(".stock-new-available").html(text);
if (stockGrid) {
stockGrid.setData(stock.products);
stockGrid.updateRowCount();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment