Attached Files | issue28953posterminalQ3.diff [^] (17,166 bytes) 2015-02-19 18:14 [Show Content] [Hide Content]diff --git a/src/org/openbravo/retail/posterminal/CashCloseProcessor.java b/src/org/openbravo/retail/posterminal/CashCloseProcessor.java
--- a/src/org/openbravo/retail/posterminal/CashCloseProcessor.java
+++ b/src/org/openbravo/retail/posterminal/CashCloseProcessor.java
@@ -48,7 +48,7 @@
private Instance<CashupHook> cashupHooks;
public JSONObject processCashClose(OBPOSApplications posTerminal, JSONObject jsonCashup,
- JSONArray cashMgmtIds, Date cashUpDate) throws Exception {
+ JSONArray cashMgmtIds, Date cashUpDate, Date currentDate) throws Exception {
String cashUpId = jsonCashup.getString("id");
JSONArray cashCloseInfo = jsonCashup.getJSONArray("cashCloseInfo");
OBPOSAppCashup cashUp = createCashUp(posTerminal, cashUpId, cashUpDate);
@@ -69,12 +69,12 @@
OBPOSAppPayment paymentType = OBDal.getInstance().get(OBPOSAppPayment.class, paymentTypeId);
FIN_Reconciliation reconciliation = createReconciliation(cashCloseObj, posTerminal,
- paymentType.getFinancialAccount(), cashUpDate);
+ paymentType.getFinancialAccount(), currentDate);
FIN_FinaccTransaction diffTransaction = null;
if (!differenceToApply.equals(BigDecimal.ZERO)) {
diffTransaction = createDifferenceTransaction(posTerminal, reconciliation, paymentType,
- differenceToApply, cashUpDate);
+ differenceToApply, currentDate);
OBDal.getInstance().save(diffTransaction);
}
OBDal.getInstance().save(reconciliation);
@@ -98,11 +98,11 @@
}
if (reconciliationTotal.compareTo(BigDecimal.ZERO) != 0) {
FIN_FinaccTransaction paymentTransaction = createTotalTransferTransactionPayment(
- posTerminal, reconciliation, paymentType, reconciliationTotal, cashUpDate);
+ posTerminal, reconciliation, paymentType, reconciliationTotal, currentDate);
OBDal.getInstance().save(paymentTransaction);
FIN_FinaccTransaction depositTransaction = createTotalTransferTransactionDeposit(
- posTerminal, reconciliation, paymentType, reconciliationTotal, cashUpDate);
+ posTerminal, reconciliation, paymentType, reconciliationTotal, currentDate);
OBDal.getInstance().save(depositTransaction);
}
}
@@ -188,7 +188,7 @@
}
protected FIN_Reconciliation createReconciliation(JSONObject cashCloseObj,
- OBPOSApplications posTerminal, FIN_FinancialAccount account, Date cashUpDate)
+ OBPOSApplications posTerminal, FIN_FinancialAccount account, Date currentDate)
throws JSONException {
BigDecimal startingBalance;
@@ -209,8 +209,8 @@
reconciliation.setDocumentType(posTerminal.getObposTerminaltype()
.getDocumentTypeForReconciliations());
reconciliation.setDocumentNo(getReconciliationDocumentNo(reconciliation.getDocumentType()));
- reconciliation.setEndingDate(cashUpDate);
- reconciliation.setTransactionDate(cashUpDate);
+ reconciliation.setEndingDate(currentDate);
+ reconciliation.setTransactionDate(currentDate);
if (!cashCloseObj.getJSONObject("paymentMethod").isNull("amountToKeep")) {
reconciliation.setEndingBalance(BigDecimal.valueOf(cashCloseObj
.getJSONObject("paymentMethod").getDouble("amountToKeep")));
@@ -234,7 +234,7 @@
protected FIN_FinaccTransaction createDifferenceTransaction(OBPOSApplications terminal,
FIN_Reconciliation reconciliation, OBPOSAppPayment payment, BigDecimal difference,
- Date cashUpDate) {
+ Date currentDate) {
FIN_FinancialAccount account = payment.getFinancialAccount();
GLItem glItem = payment.getPaymentMethod().getCashDifferences();
FIN_FinaccTransaction transaction = OBProvider.getInstance().get(FIN_FinaccTransaction.class);
@@ -253,8 +253,8 @@
transaction.setTransactionType("BPW");
transaction.setStatus("RPPC");
transaction.setDescription("GL Item: " + glItem.getName());
- transaction.setDateAcct(cashUpDate);
- transaction.setTransactionDate(cashUpDate);
+ transaction.setDateAcct(currentDate);
+ transaction.setTransactionDate(currentDate);
transaction.setReconciliation(reconciliation);
return transaction;
@@ -262,7 +262,7 @@
protected FIN_FinaccTransaction createTotalTransferTransactionPayment(OBPOSApplications terminal,
FIN_Reconciliation reconciliation, OBPOSAppPayment paymentType,
- BigDecimal reconciliationTotal, Date cashUpDate) {
+ BigDecimal reconciliationTotal, Date currentDate) {
TerminalTypePaymentMethod paymentMethod = paymentType.getPaymentMethod();
FIN_FinancialAccount account = paymentType.getFinancialAccount();
GLItem glItem = paymentMethod.getGlitemDropdep();
@@ -276,8 +276,8 @@
transaction.setTransactionType("BPW");
transaction.setStatus("RPPC");
transaction.setDescription("GL Item: " + glItem.getName());
- transaction.setDateAcct(cashUpDate);
- transaction.setTransactionDate(cashUpDate);
+ transaction.setDateAcct(currentDate);
+ transaction.setTransactionDate(currentDate);
transaction.setReconciliation(reconciliation);
account.setCurrentBalance(account.getCurrentBalance().subtract(reconciliationTotal));
@@ -288,7 +288,7 @@
protected FIN_FinaccTransaction createTotalTransferTransactionDeposit(OBPOSApplications terminal,
FIN_Reconciliation reconciliation, OBPOSAppPayment paymentType,
- BigDecimal reconciliationTotal, Date cashUpDate) {
+ BigDecimal reconciliationTotal, Date currentDate) {
GLItem glItem = paymentType.getPaymentMethod().getGlitemDropdep();
if (paymentType.getObretcoCmevents() == null) {
throw new OBException("There is no close event defined for the payment method");
@@ -322,8 +322,8 @@
transaction.setTransactionType("BPW");
transaction.setStatus("RDNC");
transaction.setDescription("GL Item: " + glItem.getName());
- transaction.setDateAcct(cashUpDate);
- transaction.setTransactionDate(cashUpDate);
+ transaction.setDateAcct(currentDate);
+ transaction.setTransactionDate(currentDate);
accountTo.setCurrentBalance(accountTo.getCurrentBalance().add(reconciliationTotal));
diff --git a/src/org/openbravo/retail/posterminal/OrderGroupingProcessor.java b/src/org/openbravo/retail/posterminal/OrderGroupingProcessor.java
--- a/src/org/openbravo/retail/posterminal/OrderGroupingProcessor.java
+++ b/src/org/openbravo/retail/posterminal/OrderGroupingProcessor.java
@@ -56,7 +56,7 @@
private static final Logger log = Logger.getLogger(OrderGroupingProcessor.class);
- public JSONObject groupOrders(OBPOSApplications posTerminal, String cashUpId, Date cashUpDate)
+ public JSONObject groupOrders(OBPOSApplications posTerminal, String cashUpId, Date currentDate)
throws JSONException, SQLException {
// Obtaining order lines that have been created in current terminal and have not already been
// reconciled. This query must be kept in sync with the one in CashCloseReport
@@ -101,12 +101,12 @@
&& !posTerminal.getObposTerminaltype().isGroupingOrders()) {
// New Order. We need to finish current invoice, and create a new one
finishInvoice(invoice, totalNetAmount, invoiceTaxes, paymentSchedule,
- origPaymentSchedule, cashUpDate);
+ origPaymentSchedule, currentDate);
currentOrderId = orderId;
Order order = OBDal.getInstance().get(Order.class, orderId);
currentOrder = OBDal.getInstance().get(Order.class, orderId);
- invoice = createNewInvoice(posTerminal, currentOrder, orderLine, cashUpDate);
- paymentSchedule = createNewPaymentSchedule(invoice, cashUpDate);
+ invoice = createNewInvoice(posTerminal, currentOrder, orderLine, currentDate);
+ paymentSchedule = createNewPaymentSchedule(invoice, currentDate);
if (!posTerminal.getObposTerminaltype().isGroupingOrders()) {
String language = RequestContext.get().getVariablesSecureApp().getLanguage();
@@ -132,11 +132,11 @@
if (!bpId.equals(currentbpId) && posTerminal.getObposTerminaltype().isGroupingOrders()) {
// New business partner. We need to finish current invoice, and create a new one
finishInvoice(invoice, totalNetAmount, invoiceTaxes, paymentSchedule,
- origPaymentSchedule, cashUpDate);
+ origPaymentSchedule, currentDate);
currentbpId = bpId;
currentBp = OBDal.getInstance().get(BusinessPartner.class, bpId);
- invoice = createNewInvoice(posTerminal, currentBp, orderLine, cashUpDate);
- paymentSchedule = createNewPaymentSchedule(invoice, cashUpDate);
+ invoice = createNewInvoice(posTerminal, currentBp, orderLine, currentDate);
+ paymentSchedule = createNewPaymentSchedule(invoice, currentDate);
origPaymentSchedule = createOriginalPaymentSchedule(invoice, paymentSchedule);
invoiceTaxes = new HashMap<String, InvoiceTax>();
totalNetAmount = BigDecimal.ZERO;
@@ -223,7 +223,7 @@
orderLines.close();
}
finishInvoice(invoice, totalNetAmount, invoiceTaxes, paymentSchedule, origPaymentSchedule,
- cashUpDate);
+ currentDate);
// The commit will be done in ProcessCashClose.java (flush), Transactional process.
// OBDal.getInstance().getConnection().commit();
@@ -233,7 +233,7 @@
return jsonResponse;
}
- protected FIN_PaymentSchedule createNewPaymentSchedule(Invoice invoice, Date cashUpDate) {
+ protected FIN_PaymentSchedule createNewPaymentSchedule(Invoice invoice, Date currentDate) {
FIN_PaymentSchedule paymentScheduleInvoice = OBProvider.getInstance().get(
FIN_PaymentSchedule.class);
paymentScheduleInvoice.setCurrency(invoice.getCurrency());
@@ -242,8 +242,8 @@
paymentScheduleInvoice.setFinPaymentmethod(invoice.getPaymentMethod());
paymentScheduleInvoice.setAmount(BigDecimal.ZERO);
paymentScheduleInvoice.setOutstandingAmount(BigDecimal.ZERO);
- paymentScheduleInvoice.setDueDate(cashUpDate);
- paymentScheduleInvoice.setExpectedDate(cashUpDate);
+ paymentScheduleInvoice.setDueDate(currentDate);
+ paymentScheduleInvoice.setExpectedDate(currentDate);
if (ModelProvider.getInstance().getEntity(FIN_PaymentSchedule.class).hasProperty("origDueDate")) {
// This property is checked and set this way to force compatibility with both MP13, MP14
// and
@@ -399,7 +399,7 @@
}
protected Invoice createNewInvoice(OBPOSApplications terminal, BusinessPartner bp,
- OrderLine firstLine, Date cashUpDate) {
+ OrderLine firstLine, Date currentDate) {
Invoice invoice = OBProvider.getInstance().get(Invoice.class);
invoice.setBusinessPartner(bp);
if (bp.getBusinessPartnerLocationList().size() == 0) {
@@ -421,14 +421,14 @@
.getDocumentTypeForInvoice());
invoice.setDocumentNo(getInvoiceDocumentNo(invoice.getTransactionDocument(),
invoice.getDocumentType()));
- invoice.setAccountingDate(cashUpDate);
- invoice.setInvoiceDate(cashUpDate);
+ invoice.setAccountingDate(currentDate);
+ invoice.setInvoiceDate(currentDate);
invoice.setPriceList(firstLine.getSalesOrder().getPriceList());
return invoice;
}
protected Invoice createNewInvoice(OBPOSApplications terminal, Order order, OrderLine firstLine,
- Date cashUpDate) {
+ Date currentDate) {
Invoice invoice = OBProvider.getInstance().get(Invoice.class);
invoice.setBusinessPartner(order.getBusinessPartner());
if (order.getBusinessPartner().getBusinessPartnerLocationList().size() == 0) {
@@ -451,8 +451,8 @@
.getDocumentTypeForInvoice());
invoice.setDocumentNo(getInvoiceDocumentNo(invoice.getTransactionDocument(),
invoice.getDocumentType()));
- invoice.setAccountingDate(cashUpDate);
- invoice.setInvoiceDate(cashUpDate);
+ invoice.setAccountingDate(currentDate);
+ invoice.setInvoiceDate(currentDate);
invoice.setPriceList(firstLine.getSalesOrder().getPriceList());
invoice.setSalesOrder(order);
return invoice;
@@ -460,7 +460,7 @@
protected void finishInvoice(Invoice oriInvoice, BigDecimal totalNetAmount,
HashMap<String, InvoiceTax> invoiceTaxes, FIN_PaymentSchedule paymentSchedule,
- Fin_OrigPaymentSchedule origPaymentSchedule, Date cashUpDate) throws SQLException {
+ Fin_OrigPaymentSchedule origPaymentSchedule, Date currentDate) throws SQLException {
if (oriInvoice == null) {
return;
}
@@ -505,7 +505,7 @@
invoice.setPaymentComplete(grossamount.compareTo(totalPaid) == 0);
invoice.setTotalPaid(totalPaid);
invoice.setPercentageOverdue(new Long(0));
- invoice.setFinalSettlementDate(grossamount.compareTo(totalPaid) == 0 ? cashUpDate : null);
+ invoice.setFinalSettlementDate(grossamount.compareTo(totalPaid) == 0 ? currentDate : null);
invoice.setDaysSalesOutstanding(new Long(0));
invoice.setOutstandingAmount(grossamount.subtract(totalPaid));
diff --git a/src/org/openbravo/retail/posterminal/ProcessCashClose.java b/src/org/openbravo/retail/posterminal/ProcessCashClose.java
--- a/src/org/openbravo/retail/posterminal/ProcessCashClose.java
+++ b/src/org/openbravo/retail/posterminal/ProcessCashClose.java
@@ -1,6 +1,6 @@
/*
************************************************************************************
- * Copyright (C) 2012 Openbravo S.L.U.
+ * Copyright (C) 2012-2015 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.
@@ -8,8 +8,11 @@
*/
package org.openbravo.retail.posterminal;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
import java.util.Date;
+import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
import org.codehaus.jettison.json.JSONArray;
import org.codehaus.jettison.json.JSONObject;
@@ -41,6 +44,7 @@
JSONObject jsonData = new JSONObject();
String cashUpId = jsonCashup.getString("id");
Date cashUpDate = new Date();
+ Date currentDate = new Date();
try {
if (jsonCashup.has("cashUpDate")) {
@@ -50,6 +54,14 @@
} else {
log.error("Error processing cash close: error retrieving cashUp date. Using current date");
}
+ if (jsonCashup.has("currentDate") && jsonCashup.get("currentDate") != null
+ && StringUtils.isNotEmpty(jsonCashup.getString("currentDate"))) {
+ String strCurrentDate = (String) jsonCashup.getString("currentDate");
+ DateFormat isodatefmt = new SimpleDateFormat("dd-MM-yyyy");
+ currentDate = isodatefmt.parse(strCurrentDate);
+ } else {
+ log.debug("Error processing cash close: error retrieving current date. Using server current date");
+ }
} catch (Exception e) {
log.error("Error processing cash close: error retrieving cashUp date. Using current date");
}
@@ -94,7 +106,7 @@
try {
TriggerHandler.getInstance().disable();
- new OrderGroupingProcessor().groupOrders(posTerminal, cashUpId, cashUpDate);
+ new OrderGroupingProcessor().groupOrders(posTerminal, cashUpId, currentDate);
posTerminal = OBDal.getInstance().get(OBPOSApplications.class,
jsonCashup.getString("posTerminal"));
@@ -102,7 +114,7 @@
.getInstanceFromStaticBeanManager(CashCloseProcessor.class);
JSONArray cashMgmtIds = jsonCashup.getJSONArray("cashMgmtIds");
JSONObject result = processor.processCashClose(posTerminal, jsonCashup, cashMgmtIds,
- cashUpDate);
+ cashUpDate, currentDate);
// add the messages returned by processCashClose...
jsonData.put("messages", result.opt("messages"));
diff --git a/web/org.openbravo.retail.posterminal/js/closecash/model/cashup-model.js b/web/org.openbravo.retail.posterminal/js/closecash/model/cashup-model.js
--- a/web/org.openbravo.retail.posterminal/js/closecash/model/cashup-model.js
+++ b/web/org.openbravo.retail.posterminal/js/closecash/model/cashup-model.js
@@ -1,6 +1,6 @@
/*
************************************************************************************
- * Copyright (C) 2012 Openbravo S.L.U.
+ * Copyright (C) 2012-2015 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.
@@ -461,7 +461,8 @@
posTerminal: OB.POS.modelterminal.get('terminal').id,
id: cashUp.at(0).get('id'),
cashCloseInfo: [],
- cashUpDate: me.get('cashUpReport').at(0).get('time')
+ cashUpDate: me.get('cashUpReport').at(0).get('time'),
+ currentDate: OB.I18N.formatDate(new Date())
});
for (i = 0; i < me.additionalProperties.length; i++) {
objToSend.set(me.additionalProperties[i], me.propertyFunctions[i](OB.POS.modelterminal.get('terminal').id, cashUp.at(0)));
|