System.out.println("[" + Shared.now() + "] UpdateStockFromSAP " + Shared.lineNumber() + " Operando");
Connection c = null;
try {
Shared.createBackup("articulo precio codigo_de_barras costo movimiento_inventario detalles_movimientos");
TotalPosWebService ws = new TotalPosWebServiceService().getTotalPosWebServicePort();
c = ConnectionDrivers.cpds.getConnection();
c.setAutoCommit(false);
if ( mode.equals("MM") || mode.equals("MMBackground") ){
String ansListMM = ws.listMMwithPrices(Shared.getConfig("storePrefix")+Shared.getConfig("storeName"), Shared.getConfig("Z"), ConnectionDrivers.getLastMM());
//String ansListMM = ws.listMM("4900458128");
System.out.println("[" + Shared.now() + "] UpdateStockFromSAP " + Shared.lineNumber() + " ansListMM = " + ansListMM );
String itemsNeeded = ConnectionDrivers.createNewMovement(c, ansListMM);
ansListMM = null;
System.out.println("[" + Shared.now() + "] UpdateStockFromSAP " + Shared.lineNumber() + " itemsNeeded = " + itemsNeeded);
// Update prices too
updatePrices(c,ws);
// flagsC
updateFlagC(c, ws);
// Descriptions
updateDescriptions(c, ws);
System.out.println("[" + Shared.now() + "] UpdateStockFromSAP " + Shared.lineNumber() + " Listo!");
}else if ( mode.equals("Prices")){
updatePrices(c,ws);
}else if ( mode.equals("initialStock") ){
String ansListMM = ws.getInitialStockWithPrices(Shared.getConfig("storePrefix")+Shared.getConfig("storeName"), Shared.getConfig("Z"));
System.out.println("[" + Shared.now() + "] UpdateStockFromSAP " + Shared.lineNumber() + " ansListMM = " + ansListMM );
ConnectionDrivers.getInitialStock(c, ansListMM);
ConnectionDrivers.disableInitialStock(c);
System.out.println("[" + Shared.now() + "] UpdateStockFromSAP " + Shared.lineNumber() + " Listo!");
}else if ( mode.equals("profitWorkers")){
System.out.println("[" + Shared.now() + "] UpdateStockFromSAP " + Shared.lineNumber() + " Profit DB Name " + Shared.getConfig("profitDatabase"));
String ans = ws.listEmployCode(Shared.getConfig("storeNameProfit"), Shared.getConfig("profitDatabase"));
System.out.println("[" + Shared.now() + "] UpdateStockFromSAP " + Shared.lineNumber() + " Ans = " + ans);
ConnectionDrivers.updateEmployees(ans);
}
System.out.println("[" + Shared.now() + "] UpdateStockFromSAP " + Shared.lineNumber() + " Haciendo el commit...");