Attached Files | backout_5a86b446511dac5bd70a5c506e68af935e3f520a.diff [^] (4,130 bytes) 2016-01-18 16:03 [Show Content] [Hide Content]# HG changeset patch
# User Asier Martirena <asier.martirena@openbravo.com>
# Date 1452862476 -3600
# Fri Jan 15 13:54:36 2016 +0100
# Node ID 28dde484254df5eeaec0d2acfbaef1bca1a292eb
# Parent 22d168dadc71475402440f344fb6ecba8f4f4677
Backout for 31673 issue
diff --git a/web/org.openbravo.retail.posterminal/js/pointofsale/model/pointofsale-model.js b/web/org.openbravo.retail.posterminal/js/pointofsale/model/pointofsale-model.js
--- a/web/org.openbravo.retail.posterminal/js/pointofsale/model/pointofsale-model.js
+++ b/web/org.openbravo.retail.posterminal/js/pointofsale/model/pointofsale-model.js
@@ -407,7 +407,7 @@
});
}, this);
- receipt.on('paymentDone', function (openDrawer, doneProcessCallback) {
+ receipt.on('paymentDone', function (openDrawer) {
if (receipt.overpaymentExists()) {
var symbol = OB.MobileApp.model.get('terminal').symbol;
var symbolAtRight = OB.MobileApp.model.get('terminal').currencySymbolAtTheRight;
@@ -430,13 +430,7 @@
}
}, {
label: OB.I18N.getLabel('OBMOBC_LblCancel')
- }], {
- onHideFunction: function () {
- if (!_.isUndefined(doneProcessCallback)) {
- doneProcessCallback(false);
- }
- }
- });
+ }]);
} else if (receipt.get('orderType') === 3) {
receipt.trigger('voidLayaway');
} else if ((OB.DEC.abs(receipt.getPayment()) !== OB.DEC.abs(receipt.getGross())) && (!receipt.isLayaway() && !receipt.get('paidOnCredit'))) {
@@ -448,13 +442,7 @@
}
}, {
label: OB.I18N.getLabel('OBMOBC_LblCancel')
- }], {
- onHideFunction: function () {
- if (!_.isUndefined(doneProcessCallback)) {
- doneProcessCallback(false);
- }
- }
- });
+ }]);
} else {
if (openDrawer) {
OB.POS.hwserver.openDrawer({
diff --git a/web/org.openbravo.retail.posterminal/js/pointofsale/view/payment.js b/web/org.openbravo.retail.posterminal/js/pointofsale/view/payment.js
--- a/web/org.openbravo.retail.posterminal/js/pointofsale/view/payment.js
+++ b/web/org.openbravo.retail.posterminal/js/pointofsale/view/payment.js
@@ -885,11 +885,7 @@
if (this.drawerOpened) {
this.setDisabled(true);
enyo.$.scrim.show();
- me.owner.model.get('order').trigger('paymentDone', false, function (result) {
- if (!result) {
- me.setDisabled(false);
- }
- });
+ me.owner.model.get('order').trigger('paymentDone', false);
this.drawerOpened = false;
this.setContent(OB.I18N.getLabel('OBPOS_LblOpen'));
} else {
@@ -903,21 +899,13 @@
} else {
this.setDisabled(true);
enyo.$.scrim.show();
- me.owner.receipt.trigger('paymentDone', this.allowOpenDrawer, function (result) {
- if (!result) {
- me.setDisabled(false);
- }
- });
+ me.owner.receipt.trigger('paymentDone', this.allowOpenDrawer);
}
} else {
if (this.drawerpreference && this.allowOpenDrawer) {
if (this.drawerOpened) {
enyo.$.scrim.show();
- this.owner.model.get('multiOrders').trigger('paymentDone', false, function (result) {
- if (!result) {
- me.setDisabled(false);
- }
- });
+ this.owner.model.get('multiOrders').trigger('paymentDone', false);
this.owner.model.get('multiOrders').set('openDrawer', false);
this.drawerOpened = false;
this.setContent(OB.I18N.getLabel('OBPOS_LblOpen'));
@@ -931,11 +919,7 @@
}
} else {
enyo.$.scrim.show();
- this.owner.model.get('multiOrders').trigger('paymentDone', this.allowOpenDrawer, function (result) {
- if (!result) {
- me.setDisabled(false);
- }
- });
+ this.owner.model.get('multiOrders').trigger('paymentDone', this.allowOpenDrawer);
this.owner.model.get('multiOrders').set('openDrawer', false);
}
}
backout_a2bca65788926025e32362c85120ca7d63828f67.diff [^] (3,705 bytes) 2016-01-18 16:03 [Show Content] [Hide Content]# HG changeset patch
# User Asier Martirena <asier.martirena@openbravo.com>
# Date 1452862512 -3600
# Fri Jan 15 13:55:12 2016 +0100
# Node ID cde46b546ec1381fc08e1902addba2d2f9187bd1
# Parent 28dde484254df5eeaec0d2acfbaef1bca1a292eb
Backout for 31673 issue
diff --git a/web/org.openbravo.retail.posterminal/js/pointofsale/model/pointofsale-model.js b/web/org.openbravo.retail.posterminal/js/pointofsale/model/pointofsale-model.js
--- a/web/org.openbravo.retail.posterminal/js/pointofsale/model/pointofsale-model.js
+++ b/web/org.openbravo.retail.posterminal/js/pointofsale/model/pointofsale-model.js
@@ -416,23 +416,17 @@
label: OB.I18N.getLabel('OBMOBC_LblOk'),
isConfirmButton: true,
action: function () {
- if (receipt.get('orderType') === 3) {
- receipt.trigger('voidLayaway');
- } else {
- if (openDrawer) {
- OB.POS.hwserver.openDrawer({
- openFirst: false,
- receipt: receipt
- }, OB.MobileApp.model.get('permissions').OBPOS_timeAllowedDrawerSales);
- }
- receipt.trigger('paymentAccepted');
+ if (openDrawer) {
+ OB.POS.hwserver.openDrawer({
+ openFirst: false,
+ receipt: receipt
+ }, OB.MobileApp.model.get('permissions').OBPOS_timeAllowedDrawerSales);
}
+ receipt.trigger('paymentAccepted');
}
}, {
label: OB.I18N.getLabel('OBMOBC_LblCancel')
}]);
- } else if (receipt.get('orderType') === 3) {
- receipt.trigger('voidLayaway');
} else if ((OB.DEC.abs(receipt.getPayment()) !== OB.DEC.abs(receipt.getGross())) && (!receipt.isLayaway() && !receipt.get('paidOnCredit'))) {
OB.UTIL.showConfirmation.display(OB.I18N.getLabel('OBPOS_PaymentAmountDistinctThanReceiptAmountTitle'), OB.I18N.getLabel('OBPOS_PaymentAmountDistinctThanReceiptAmountBody'), [{
label: OB.I18N.getLabel('OBMOBC_LblOk'),
diff --git a/web/org.openbravo.retail.posterminal/js/pointofsale/view/payment.js b/web/org.openbravo.retail.posterminal/js/pointofsale/view/payment.js
--- a/web/org.openbravo.retail.posterminal/js/pointofsale/view/payment.js
+++ b/web/org.openbravo.retail.posterminal/js/pointofsale/view/payment.js
@@ -883,9 +883,13 @@
if (myModel.get('leftColumnViewManager').isOrder()) {
if (this.drawerpreference && this.allowOpenDrawer) {
if (this.drawerOpened) {
- this.setDisabled(true);
- enyo.$.scrim.show();
- me.owner.model.get('order').trigger('paymentDone', false);
+ if (this.owner.receipt.get('orderType') === 3) {
+ this.owner.receipt.trigger('voidLayaway');
+ } else {
+ this.setDisabled(true);
+ enyo.$.scrim.show();
+ me.owner.model.get('order').trigger('paymentDone', false);
+ }
this.drawerOpened = false;
this.setContent(OB.I18N.getLabel('OBPOS_LblOpen'));
} else {
@@ -897,9 +901,14 @@
this.setContent(OB.I18N.getLabel('OBPOS_LblDone'));
}
} else {
- this.setDisabled(true);
- enyo.$.scrim.show();
- me.owner.receipt.trigger('paymentDone', this.allowOpenDrawer);
+ //Void Layaway
+ if (this.owner.receipt.get('orderType') === 3) {
+ this.owner.receipt.trigger('voidLayaway');
+ } else {
+ this.setDisabled(true);
+ enyo.$.scrim.show();
+ me.owner.receipt.trigger('paymentDone', this.allowOpenDrawer);
+ }
}
} else {
if (this.drawerpreference && this.allowOpenDrawer) {
issue_31892.diff [^] (18,165 bytes) 2016-01-18 16:03 [Show Content] [Hide Content]diff --git a/src/org/openbravo/retail/posterminal/OrderLoader.java b/src/org/openbravo/retail/posterminal/OrderLoader.java
--- a/src/org/openbravo/retail/posterminal/OrderLoader.java
+++ b/src/org/openbravo/retail/posterminal/OrderLoader.java
@@ -1,6 +1,6 @@
/*
************************************************************************************
- * Copyright (C) 2012-2015 Openbravo S.L.U.
+ * Copyright (C) 2012-2016 Openbravo S.L.U.
* Licensed under the Openbravo Commercial License version 1.0
* You may obtain a copy of the License at http://www.openbravo.com/legal/obcl.html
* or in the legal folder of this module distribution.
@@ -124,13 +124,14 @@
HashMap<String, DocumentType> invoiceDocTypes = new HashMap<String, DocumentType>();
HashMap<String, DocumentType> shipmentDocTypes = new HashMap<String, DocumentType>();
String paymentDescription = null;
- boolean newLayaway = false;
- boolean notpaidLayaway = false;
- boolean creditpaidLayaway = false;
- boolean partialpaidLayaway = false;
- boolean fullypaidLayaway = false;
- boolean createShipment = true;
- Locator binForRetuns = null;
+ private boolean newLayaway = false;
+ private boolean notpaidLayaway = false;
+ private boolean creditpaidLayaway = false;
+ private boolean partialpaidLayaway = false;
+ private boolean fullypaidLayaway = false;
+ private boolean createShipment = true;
+ private Locator binForRetuns = null;
+ private boolean isQuotation = false;
@Inject
@Any
@@ -150,10 +151,15 @@
return "Order";
}
- @Override
- public JSONObject saveRecord(JSONObject jsonorder) throws Exception {
- long t0 = 0, t1 = 0, t11 = 0, t2 = 0, t3 = 0, t4 = 0, t5 = 0, t6 = 0, t111 = 0, t112 = 0, t113 = 0, t115 = 0, t116 = 0;
-
+ /**
+ * Method to initialize the global variables needed during the synchronization process
+ *
+ * @param jsonorder
+ * JSONObject which contains the order to be synchronized. This object is generated in
+ * Web POS
+ * @return
+ */
+ public void initializeVariables(JSONObject jsonorder) throws JSONException {
try {
useOrderDocumentNoForRelatedDocs = "Y".equals(Preferences.getPreferenceValue(
"OBPOS_UseOrderDocumentNoForRelatedDocs", true, OBContext.getOBContext()
@@ -165,10 +171,36 @@
}
documentNoHandlers.set(new ArrayList<OrderLoader.DocumentNoHandler>());
+
+ isQuotation = jsonorder.has("isQuotation") && jsonorder.getBoolean("isQuotation");
+
+ newLayaway = jsonorder.has("orderType") && jsonorder.getLong("orderType") == 2;
+ notpaidLayaway = (jsonorder.getBoolean("isLayaway") || jsonorder.optLong("orderType") == 2)
+ && jsonorder.getDouble("payment") < jsonorder.getDouble("gross")
+ && !jsonorder.optBoolean("paidOnCredit");
+ creditpaidLayaway = (jsonorder.getBoolean("isLayaway") || jsonorder.optLong("orderType") == 2)
+ && jsonorder.getDouble("payment") < jsonorder.getDouble("gross")
+ && jsonorder.optBoolean("paidOnCredit");
+ partialpaidLayaway = jsonorder.getBoolean("isLayaway")
+ && jsonorder.getDouble("payment") < jsonorder.getDouble("gross");
+ fullypaidLayaway = (jsonorder.getBoolean("isLayaway") || jsonorder.optLong("orderType") == 2)
+ && jsonorder.getDouble("payment") >= jsonorder.getDouble("gross");
+
+ createShipment = !isQuotation && !notpaidLayaway;
+ if (jsonorder.has("generateShipment")) {
+ createShipment &= jsonorder.getBoolean("generateShipment");
+ }
+ }
+
+ @Override
+ public JSONObject saveRecord(JSONObject jsonorder) throws Exception {
+ long t0 = 0, t1 = 0, t11 = 0, t2 = 0, t3 = 0, t4 = 0, t5 = 0, t6 = 0, t111 = 0, t112 = 0, t113 = 0, t115 = 0, t116 = 0;
+
try {
+ initializeVariables(jsonorder);
+
executeHooks(orderPreProcesses, jsonorder, null, null, null);
boolean wasPaidOnCredit = false;
- boolean isQuotation = jsonorder.has("isQuotation") && jsonorder.getBoolean("isQuotation");
if (jsonorder.getLong("orderType") != 2 && !jsonorder.getBoolean("isLayaway") && !isQuotation
&& verifyOrderExistance(jsonorder)
&& (!jsonorder.has("preserveId") || jsonorder.getBoolean("preserveId"))) {
@@ -186,17 +218,6 @@
Invoice invoice = null;
boolean createInvoice = false;
TriggerHandler.getInstance().disable();
- newLayaway = jsonorder.has("orderType") && jsonorder.getLong("orderType") == 2;
- notpaidLayaway = (jsonorder.getBoolean("isLayaway") || jsonorder.optLong("orderType") == 2)
- && jsonorder.getDouble("payment") < jsonorder.getDouble("gross")
- && !jsonorder.optBoolean("paidOnCredit");
- creditpaidLayaway = (jsonorder.getBoolean("isLayaway") || jsonorder.optLong("orderType") == 2)
- && jsonorder.getDouble("payment") < jsonorder.getDouble("gross")
- && jsonorder.optBoolean("paidOnCredit");
- partialpaidLayaway = jsonorder.getBoolean("isLayaway")
- && jsonorder.getDouble("payment") < jsonorder.getDouble("gross");
- fullypaidLayaway = (jsonorder.getBoolean("isLayaway") || jsonorder.optLong("orderType") == 2)
- && jsonorder.getDouble("payment") >= jsonorder.getDouble("gross");
try {
if (jsonorder.has("oldId") && !jsonorder.getString("oldId").equals("null")
&& jsonorder.has("isQuotation") && jsonorder.getBoolean("isQuotation")) {
@@ -226,9 +247,8 @@
|| (!isQuotation && !notpaidLayaway && (jsonorder.has("generateInvoice") && jsonorder
.getBoolean("generateInvoice")));
}
- createShipment = !isQuotation && !notpaidLayaway;
+
if (jsonorder.has("generateShipment")) {
- createShipment &= jsonorder.getBoolean("generateShipment");
createInvoice &= jsonorder.getBoolean("generateShipment");
}
@@ -1454,7 +1474,7 @@
return calculatedDueDate.getTime();
}
- protected JSONObject handlePayments(JSONObject jsonorder, Order order, Invoice invoice,
+ public JSONObject handlePayments(JSONObject jsonorder, Order order, Invoice invoice,
Boolean wasPaidOnCredit) throws Exception {
String posTerminalId = jsonorder.getString("posTerminal");
OBPOSApplications posTerminal = OBDal.getInstance().get(OBPOSApplications.class, posTerminalId);
diff --git a/src/org/openbravo/retail/posterminal/ProcessVoidLayaway.java b/src/org/openbravo/retail/posterminal/ProcessVoidLayaway.java
--- a/src/org/openbravo/retail/posterminal/ProcessVoidLayaway.java
+++ b/src/org/openbravo/retail/posterminal/ProcessVoidLayaway.java
@@ -1,6 +1,6 @@
/*
************************************************************************************
- * Copyright (C) 2012-2015 Openbravo S.L.U.
+ * Copyright (C) 2012-2016 Openbravo S.L.U.
* Licensed under the Openbravo Commercial License version 1.0
* You may obtain a copy of the License at http://www.openbravo.com/legal/obcl.html
* or in the legal folder of this module distribution.
@@ -9,12 +9,8 @@
package org.openbravo.retail.posterminal;
import java.math.BigDecimal;
-import java.math.RoundingMode;
-import java.util.ArrayList;
-import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
-import java.util.List;
import javax.enterprise.inject.Any;
import javax.enterprise.inject.Instance;
@@ -22,13 +18,10 @@
import org.codehaus.jettison.json.JSONArray;
import org.codehaus.jettison.json.JSONObject;
-import org.openbravo.advpaymentmngt.dao.TransactionsDao;
-import org.openbravo.advpaymentmngt.process.FIN_AddPayment;
import org.openbravo.advpaymentmngt.utility.FIN_Utility;
import org.openbravo.base.exception.OBException;
import org.openbravo.base.model.Entity;
-import org.openbravo.base.model.ModelProvider;
-import org.openbravo.base.provider.OBProvider;
+import org.openbravo.base.weld.WeldUtils;
import org.openbravo.client.kernel.RequestContext;
import org.openbravo.dal.core.DalUtil;
import org.openbravo.dal.core.OBContext;
@@ -44,11 +37,7 @@
import org.openbravo.model.common.order.OrderLine;
import org.openbravo.model.common.order.OrderLineOffer;
import org.openbravo.model.common.order.OrderTax;
-import org.openbravo.model.financialmgmt.payment.FIN_FinaccTransaction;
-import org.openbravo.model.financialmgmt.payment.FIN_FinancialAccount;
-import org.openbravo.model.financialmgmt.payment.FIN_Payment;
import org.openbravo.model.financialmgmt.payment.FIN_PaymentSchedule;
-import org.openbravo.model.financialmgmt.payment.FIN_PaymentScheduleDetail;
import org.openbravo.service.db.DalConnectionProvider;
import org.openbravo.service.json.JsonConstants;
@@ -105,90 +94,16 @@
orderLineTax.setTaxableAmount(BigDecimal.ZERO);
orderLineTax.setTaxAmount(BigDecimal.ZERO);
}
+
+ OrderLoader orderLoader = WeldUtils.getInstanceFromStaticBeanManager(OrderLoader.class);
+ orderLoader.initializeVariables(jsonorder);
+ orderLoader.handlePayments(jsonorder, order, null, false);
+
FIN_PaymentSchedule paymentSchedule = order.getFINPaymentScheduleList().get(0);
paymentSchedule.setAmount(BigDecimal.ZERO);
paymentSchedule.setPaidAmount(BigDecimal.ZERO);
paymentSchedule.setOutstandingAmount(BigDecimal.ZERO);
- OBPOSApplications posTerminal = OBDal.getInstance().get(OBPOSApplications.class,
- jsonorder.getString("posTerminal"));
- int stdPrecision = order.getCurrency().getStandardPrecision().intValue();
- JSONArray payments = jsonorder.getJSONArray("payments");
- for (int i = 0; i < payments.length(); i++) {
- JSONObject payment = payments.getJSONObject(i);
- OBPOSAppPayment paymentType = null;
- String paymentTypeName = payment.getString("kind");
- BigDecimal mulrate = new BigDecimal(1);
- BigDecimal amount = BigDecimal.valueOf(payment.getDouble("paid"))
- .setScale(stdPrecision, RoundingMode.HALF_UP).negate();
- BigDecimal foreignAmount = amount;
- if (payment.has("mulrate") && payment.getDouble("mulrate") != 1) {
- mulrate = BigDecimal.valueOf(payment.getDouble("mulrate"));
- foreignAmount = amount.multiply(mulrate).setScale(stdPrecision, RoundingMode.HALF_UP);
- }
-
- for (OBPOSAppPayment type : posTerminal.getOBPOSAppPaymentList()) {
- if (type.getSearchKey().equals(paymentTypeName)) {
- paymentType = type;
- }
- }
- if (paymentType.getFinancialAccount() == null) {
- continue;
- }
- FIN_FinancialAccount account = paymentType.getFinancialAccount();
-
- FIN_PaymentScheduleDetail newPaymentScheduleDetail = OBProvider.getInstance().get(
- FIN_PaymentScheduleDetail.class);
- newPaymentScheduleDetail.setOrderPaymentSchedule(paymentSchedule);
- newPaymentScheduleDetail.setAmount(amount);
- OBDal.getInstance().save(newPaymentScheduleDetail);
- List<FIN_PaymentScheduleDetail> detail = new ArrayList<FIN_PaymentScheduleDetail>();
- detail.add(newPaymentScheduleDetail);
-
- HashMap<String, BigDecimal> paymentAmount = new HashMap<String, BigDecimal>();
- paymentAmount.put(newPaymentScheduleDetail.getId(), amount);
-
- DocumentType paymentDocType = getPaymentDocumentType(order.getOrganization());
- Entity paymentEntity = ModelProvider.getInstance().getEntity(FIN_Payment.class);
- String paymentDocNo = getDocumentNo(paymentEntity, null, paymentDocType);
-
- FIN_Payment finPayment = FIN_AddPayment.savePayment(null, true, paymentDocType,
- paymentDocNo, order.getBusinessPartner(), paymentType.getPaymentMethod()
- .getPaymentMethod(), account, amount.toString(), new Date(), order
- .getOrganization(), null, detail, paymentAmount, false, false, order.getCurrency(),
- mulrate.setScale(stdPrecision, RoundingMode.HALF_UP), foreignAmount);
- String description = getPaymentDescription();
- description += ": " + order.getDocumentNo() + "\n";
- finPayment.setDescription(description);
- finPayment.setStatus("RDNC");
- finPayment.setProcessed(true);
- finPayment.setAPRMProcessPayment("RE");
-
- OBDal.getInstance().save(finPayment);
-
- FIN_FinancialAccount acc = paymentType.getFinancialAccount();
- FIN_FinaccTransaction transaction = OBProvider.getInstance().get(
- FIN_FinaccTransaction.class);
- transaction.setCurrency(acc.getCurrency());
- transaction.setAccount(acc);
- transaction.setLineNo(TransactionsDao.getTransactionMaxLineNo(account) + 10);
- transaction.setPaymentAmount(foreignAmount.negate());
- transaction.setProcessed(true);
- transaction.setTransactionType("BPW");
- transaction.setStatus("RDNC");
- if (foreignAmount != amount) {
- transaction.setForeignAmount(amount.negate());
- transaction.setForeignCurrency(order.getCurrency());
- }
- transaction.setDescription(description);
- transaction.setDateAcct(POSUtils.getCurrentDate());
- transaction.setTransactionDate(POSUtils.getCurrentDate());
- transaction.setFinPayment(finPayment);
- transaction.setBusinessPartner(order.getBusinessPartner());
- OBDal.getInstance().save(transaction);
- acc.setCurrentBalance(account.getCurrentBalance().subtract(foreignAmount.negate()));
- }
-
OBDal.getInstance().getConnection(true).commit();
} catch (Exception e) {
throw new OBException("There was an error voiding the orde Layaway: ", e);
diff --git a/web/org.openbravo.retail.posterminal/js/pointofsale/model/pointofsale-model.js b/web/org.openbravo.retail.posterminal/js/pointofsale/model/pointofsale-model.js
--- a/web/org.openbravo.retail.posterminal/js/pointofsale/model/pointofsale-model.js
+++ b/web/org.openbravo.retail.posterminal/js/pointofsale/model/pointofsale-model.js
@@ -1,6 +1,6 @@
/*
************************************************************************************
- * Copyright (C) 2012-2015 Openbravo S.L.U.
+ * Copyright (C) 2012-2016 Openbravo S.L.U.
* Licensed under the Openbravo Commercial License version 1.0
* You may obtain a copy of the License at http://www.openbravo.com/legal/obcl.html
* or in the legal folder of this module distribution.
@@ -632,36 +632,64 @@
}, this);
receipt.on('voidLayaway', function () {
- var process = new OB.DS.Process('org.openbravo.retail.posterminal.ProcessVoidLayaway');
- var auxReceipt = new OB.Model.Order();
- OB.UTIL.clone(receipt, auxReceipt);
- process.exec({
- messageId: OB.UTIL.get_UUID(),
- data: [{
- order: receipt
- }]
- }, function (data) {
- if (data && data.exception) {
- OB.UTIL.showError(OB.I18N.getLabel('OBPOS_MsgErrorVoidLayaway'));
- } else {
- auxReceipt.prepareToSend(function () {
- OB.UTIL.cashUpReport(auxReceipt);
+ var finishVoidLayaway = function () {
+ var process = new OB.DS.Process('org.openbravo.retail.posterminal.ProcessVoidLayaway');
+ var auxReceipt = new OB.Model.Order();
+ OB.UTIL.clone(receipt, auxReceipt);
+ receipt.set('obposAppCashup', OB.MobileApp.model.get('terminal').cashUpId);
+ receipt.set('timezoneOffset', new Date().getTimezoneOffset());
+ receipt.set('gross', OB.DEC.mul(receipt.get('gross'), -1));
+ receipt.get('payments').forEach(function (payment) {
+ payment.set('origAmount', OB.DEC.mul(payment.get('origAmount'), -1));
+ payment.set('paid', OB.DEC.mul(payment.get('paid'), -1));
});
- OB.Dal.remove(receipt, null, function (tx, err) {
- OB.UTIL.showError(err);
+ process.exec({
+ messageId: OB.UTIL.get_UUID(),
+ data: [{
+ order: receipt
+ }]
+ }, function (data) {
+ if (data && data.exception) {
+ OB.UTIL.showError(OB.I18N.getLabel('OBPOS_MsgErrorVoidLayaway'));
+ } else {
+ auxReceipt.prepareToSend(function () {
+ OB.UTIL.cashUpReport(auxReceipt);
+ });
+ OB.Dal.remove(receipt, null, function (tx, err) {
+ OB.UTIL.showError(err);
+ });
+ receipt.trigger('print');
+ if (receipt.get('layawayGross')) {
+ receipt.set('layawayGross', null);
+ }
+ orderList.deleteCurrent();
+ receipt.trigger('change:gross', receipt);
+
+ OB.UTIL.showSuccess(OB.I18N.getLabel('OBPOS_MsgSuccessVoidLayaway'));
+ }
+ }, function () {
+ OB.UTIL.showError(OB.I18N.getLabel('OBPOS_OfflineWindowRequiresOnline'));
});
- receipt.trigger('print');
- if (receipt.get('layawayGross')) {
- receipt.set('layawayGross', null);
}
- orderList.deleteCurrent();
- receipt.trigger('change:gross', receipt);
-
- OB.UTIL.showSuccess(OB.I18N.getLabel('OBPOS_MsgSuccessVoidLayaway'));
- }
- }, function () {
- OB.UTIL.showError(OB.I18N.getLabel('OBPOS_OfflineWindowRequiresOnline'));
- });
+
+
+
+ if (receipt.overpaymentExists()) {
+ var symbol = OB.MobileApp.model.get('terminal').symbol;
+ var symbolAtRight = OB.MobileApp.model.get('terminal').currencySymbolAtTheRight;
+ var amount = receipt.getPaymentStatus().overpayment;
+ OB.UTIL.showConfirmation.display(OB.I18N.getLabel('OBPOS_OverpaymentWarningTitle'), OB.I18N.getLabel('OBPOS_OverpaymentWarningBody', [OB.I18N.formatCurrencyWithSymbol(amount, symbol, symbolAtRight)]), [{
+ label: OB.I18N.getLabel('OBMOBC_LblOk'),
+ isConfirmButton: true,
+ action: function () {
+ finishVoidLayaway();
+ }
+ }, {
+ label: OB.I18N.getLabel('OBMOBC_LblCancel')
+ }]);
+ } else {
+ finishVoidLayaway();
+ }
}, this);
callback();
|