Project:
View Issue Details[ Jump to Notes ] | [ Issue History ] [ Print ] | |||||||
ID | ||||||||
0053473 | ||||||||
Type | Category | Severity | Reproducibility | Date Submitted | Last Update | |||
defect | [POS2] POS | major | always | 2023-09-18 14:14 | 2023-09-29 14:13 | |||
Reporter | ranjith_qualiantech_com | View Status | public | |||||
Assigned To | ranjith_qualiantech_com | |||||||
Priority | high | Resolution | fixed | Fixed in Version | ||||
Status | closed | Fix in branch | Fixed in SCM revision | |||||
Projection | none | ETA | none | Target Version | ||||
OS | Any | Database | Any | Java version | ||||
OS Version | Database version | Ant version | ||||||
Product Version | SCM revision | |||||||
Review Assigned To | ||||||||
Regression level | ||||||||
Regression date | ||||||||
Regression introduced in release | ||||||||
Regression introduced by commit | ||||||||
Triggers an Emergency Pack | No | |||||||
Summary | 0053473: Cashup properties was missed in the mitigation process (Validating draft ticket in backoffice) | |||||||
Description | New mitigation process added in the issue https://issues.openbravo.com/view.php?id=52864. [^] When the ticket is processed in backoffice, but not removed from POS State, then ticket will be removed from state and Cashup will be updated from backoffice during reload POS application. In the above process, When updating Cashup from backoffice, few properties like totalStartings, usedInCurrentTrx, and few more are missed | |||||||
Steps To Reproduce | - | |||||||
Tags | No tags attached. | |||||||
Attached Files | 53473_21Q4_posterminal.diff [^] (19,298 bytes) 2023-09-29 14:12 [Show Content] [Hide Content]diff --git a/src/org/openbravo/retail/posterminal/UpdateCashup.java b/src/org/openbravo/retail/posterminal/UpdateCashup.java index 14cb95a0e..bf49961f5 100644 --- a/src/org/openbravo/retail/posterminal/UpdateCashup.java +++ b/src/org/openbravo/retail/posterminal/UpdateCashup.java @@ -1,6 +1,6 @@ /* ************************************************************************************ - * Copyright (C) 2016-2021 Openbravo S.L.U. + * Copyright (C) 2016-2023 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. @@ -78,7 +78,7 @@ public class UpdateCashup { } else if (cashUpReportString.lastIndexOf("Z") != -1) { cashUpReportDate = (Date) JsonToDataConverter.convertJsonToPropertyValue( PropertyByType.DATETIME, - (cashUpReportString).subSequence(0, (cashUpReportString).lastIndexOf("Z")) + ":00"); + (cashUpReportString).subSequence(0, (cashUpReportString).lastIndexOf("Z"))); } else { cashUpReportDate = (Date) JsonToDataConverter .convertJsonToPropertyValue(PropertyByType.DATETIME, cashUpReportString); diff --git a/src/org/openbravo/retail/posterminal/master/Cashup.java b/src/org/openbravo/retail/posterminal/master/Cashup.java index e5fa7cc04..c89971ec0 100644 --- a/src/org/openbravo/retail/posterminal/master/Cashup.java +++ b/src/org/openbravo/retail/posterminal/master/Cashup.java @@ -1,6 +1,6 @@ /* ************************************************************************************ - * Copyright (C) 2014-2021 Openbravo S.L.U. + * Copyright (C) 2014-2023 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. @@ -49,6 +49,7 @@ import org.openbravo.service.json.JsonConstants; public class Cashup extends JSONProcessSimple { private static final Logger log = LogManager.getLogger(); + private static final DateFormat dateFormatUTC = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'"); @Inject @Any @@ -97,6 +98,9 @@ public class Cashup extends JSONProcessSimple { return result; } + final TimeZone tz = TimeZone.getTimeZone("UTC"); + dateFormatUTC.setTimeZone(tz); + String isprocessed; if (jsonsent.has("isprocessed")) { isprocessed = jsonsent.getString("isprocessed"); @@ -141,13 +145,9 @@ public class Cashup extends JSONProcessSimple { cashupJSON.put("netReturns", cashup[3]); cashupJSON.put("grossReturns", cashup[4]); cashupJSON.put("totalRetailTransactions", cashup[5]); - TimeZone tz = TimeZone.getTimeZone("UTC"); - DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm'Z'"); - df.setTimeZone(tz); - String nowAsISO = df.format(cashup[6]); - cashupJSON.put("creationDate", nowAsISO); + cashupJSON.put("creationDate", dateFormatUTC.format(cashup[6])); cashupJSON.put("userId", cashup[7]); - cashupJSON.put("isprocessed", ((Boolean) cashup[8]) ? "Y" : "N"); + cashupJSON.put("isprocessed", (Boolean) cashup[8]); cashupJSON.put("posterminal", cashup[9]); cashupJSON.put("organization", cashup[10]); @@ -335,14 +335,16 @@ public class Cashup extends JSONProcessSimple { // Set the cashManagement data result.put("id", cashMgmtJSON.get("id")); result.put("description", cashMgmtJSON.get("description")); - result.put("amount", totalamt.toString()); - result.put("origAmount", totalamt.toString()); + result.put("amount", totalamt); + result.put("origAmount", totalamt); result.put("type", cashMgmtJSON.get("paymentAmount").toString().equals("0") ? "deposit" : "drop"); result.put("reasonId", reasonId); result.put("paymentMethodId", paymentmethodId); - result.put("creationDate", cashMgmtJSON.get("creationDate").toString()); + result.put("creationDate", + dateFormatUTC.format(((FIN_FinaccTransaction) cashMgmt).getCreationDate())); result.put("timezoneOffset", "0"); + result.put("posTerminal", posId); result.put("userId", cashMgmtJSON.get("createdBy")); result.put("user", cashMgmtJSON.get("createdBy$_identifier")); result.put("isocode", cashMgmtJSON.get("currency$_identifier")); diff --git a/src/org/openbravo/retail/posterminal/term/Payments.java b/src/org/openbravo/retail/posterminal/term/Payments.java index 3bd1fa1c5..ea3c5726b 100644 --- a/src/org/openbravo/retail/posterminal/term/Payments.java +++ b/src/org/openbravo/retail/posterminal/term/Payments.java @@ -61,7 +61,8 @@ public class Payments extends JSONTerminalProperty { + " providerGroupImage.bindaryData as pgimage, providerGroupImage.mimetype as pgmimetype, " + " paymentType, " + " color.hexColor as color, " - + " pmg_color.hexColor as pmg_color " + + " pmg_color.hexColor as pmg_color, " + + " p.line as lineNo " + "from OBPOS_App_Payment as p " + " left join p.financialAccount as f " + " left join f.currency as c " @@ -165,6 +166,7 @@ public class Payments extends JSONTerminalProperty { } payment.put("color", objPayment[15]); payment.put("imageClass", ttPaymentMethod.getImageClass()); + payment.put("lineNo", objPayment[17]); // If the Payment Method is cash, load the rounding properties of the currency if (appPayment.getPaymentMethod().isCash()) { diff --git a/web-test/model/business-object/cashup/Cashup-initCashup-StateAction-fromBackend.test.js b/web-test/model/business-object/cashup/Cashup-initCashup-StateAction-fromBackend.test.js index cda2576d4..eda3f8746 100644 --- a/web-test/model/business-object/cashup/Cashup-initCashup-StateAction-fromBackend.test.js +++ b/web-test/model/business-object/cashup/Cashup-initCashup-StateAction-fromBackend.test.js @@ -1,6 +1,6 @@ /* ************************************************************************************ - * Copyright (C) 2020 Openbravo S.L.U. + * Copyright (C) 2020-2023 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. @@ -64,7 +64,7 @@ describe('Cashup - init cashup State Action - from backend', () => { }; deepfreeze(expectedState); const result = initCashup(initialState, payloadInitFromBackend); - expect(result).toEqual(expectedState); + expect(result).toEqual(expect.objectContaining(expectedState)); }); it('initialize cashup from backend - without cashPaymentMethodInfo', () => { @@ -92,6 +92,6 @@ describe('Cashup - init cashup State Action - from backend', () => { initialState, payloadWithoutCashPaymentMethodInfo ); - expect(result).toEqual(expectedState); + expect(result).toEqual(expect.objectContaining(expectedState)); }); }); diff --git a/web-test/model/business-object/cashup/test-data/cashupAfterComplete.js b/web-test/model/business-object/cashup/test-data/cashupAfterComplete.js index fb757f1d3..329fce517 100644 --- a/web-test/model/business-object/cashup/test-data/cashupAfterComplete.js +++ b/web-test/model/business-object/cashup/test-data/cashupAfterComplete.js @@ -1,6 +1,6 @@ /* ************************************************************************************ - * Copyright (C) 2020 Openbravo S.L.U. + * Copyright (C) 2020-2023 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. @@ -16,7 +16,7 @@ module.exports = { netReturns: 0, grossReturns: 0, totalRetailTransactions: 0, - totalStartings: 250, + totalStartings: 238.04, creationDate: '2020-06-26T14:36:53.173Z', userId: '3073EDF96A3C42CC86C7069E379522D2', posterminal: '9104513C2D0741D4850AE8493998A7C8', diff --git a/web-test/model/business-object/cashup/test-data/cashupAfterLoadCashupFromBackend.js b/web-test/model/business-object/cashup/test-data/cashupAfterLoadCashupFromBackend.js index f92b164cc..b42dc0d38 100644 --- a/web-test/model/business-object/cashup/test-data/cashupAfterLoadCashupFromBackend.js +++ b/web-test/model/business-object/cashup/test-data/cashupAfterLoadCashupFromBackend.js @@ -1,6 +1,6 @@ /* ************************************************************************************ - * Copyright (C) 2020 Openbravo S.L.U. + * Copyright (C) 2020-2023 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. @@ -19,6 +19,7 @@ module.exports = { totalStartings: 0, creationDate: '2020-06-24T07:45Z', userId: '3073EDF96A3C42CC86C7069E379522D2', + cashCloseInfo: [], cashTaxInfo: [ { id: 'E44EB6A6CF2D362EA88FAC723638CDA6', @@ -41,6 +42,7 @@ module.exports = { rate: 1, isocode: 'EUR', newPaymentMethod: false, + usedInCurrentTrx: false, cashManagements: [] }, { @@ -56,6 +58,7 @@ module.exports = { rate: 1, isocode: 'EUR', newPaymentMethod: false, + usedInCurrentTrx: true, cashManagements: [] }, { @@ -71,6 +74,7 @@ module.exports = { rate: 0.76082, isocode: 'USD', newPaymentMethod: false, + usedInCurrentTrx: false, cashManagements: [] }, { @@ -86,6 +90,7 @@ module.exports = { rate: 1, isocode: 'EUR', newPaymentMethod: false, + usedInCurrentTrx: false, cashManagements: [] } ], diff --git a/web-test/model/business-object/cashup/test-data/cashupAfterLoadCashupFromBackendWithoutPayments.js b/web-test/model/business-object/cashup/test-data/cashupAfterLoadCashupFromBackendWithoutPayments.js index 2f04ea35e..4ec331d10 100644 --- a/web-test/model/business-object/cashup/test-data/cashupAfterLoadCashupFromBackendWithoutPayments.js +++ b/web-test/model/business-object/cashup/test-data/cashupAfterLoadCashupFromBackendWithoutPayments.js @@ -1,6 +1,6 @@ /* ************************************************************************************ - * Copyright (C) 2020 Openbravo S.L.U. + * Copyright (C) 2020-2023 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. @@ -19,7 +19,7 @@ module.exports = { totalStartings: 0, creationDate: '2020-06-24T07:45Z', userId: '3073EDF96A3C42CC86C7069E379522D2', - cashCloseInfo: undefined, + cashCloseInfo: [], cashTaxInfo: [ { id: 'E44EB6A6CF2D362EA88FAC723638CDA6', diff --git a/web-test/model/business-object/cashup/test-data/messagesAfterCompleteCashupSharedPayments.js b/web-test/model/business-object/cashup/test-data/messagesAfterCompleteCashupSharedPayments.js index 7c8080f2b..d6bcae72a 100644 --- a/web-test/model/business-object/cashup/test-data/messagesAfterCompleteCashupSharedPayments.js +++ b/web-test/model/business-object/cashup/test-data/messagesAfterCompleteCashupSharedPayments.js @@ -1,6 +1,6 @@ /* ************************************************************************************ - * Copyright (C) 2020-2021 Openbravo S.L.U. + * Copyright (C) 2020-2023 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. @@ -2016,7 +2016,7 @@ module.exports = [ netReturns: 0, grossReturns: 0, totalRetailTransactions: 0, - totalStartings: 250, + totalStartings: 238.04, creationDate: '2020-06-26T14:36:53.173Z', userId: '3073EDF96A3C42CC86C7069E379522D2', posterminal: '9104513C2D0741D4850AE8493998A7C8', diff --git a/web/org.openbravo.retail.posterminal/app/model/business-object/cashup/CashupUtils.js b/web/org.openbravo.retail.posterminal/app/model/business-object/cashup/CashupUtils.js index 2ccb4f95b..0ab7a7804 100644 --- a/web/org.openbravo.retail.posterminal/app/model/business-object/cashup/CashupUtils.js +++ b/web/org.openbravo.retail.posterminal/app/model/business-object/cashup/CashupUtils.js @@ -1,6 +1,6 @@ /* ************************************************************************************ - * Copyright (C) 2020-2021 Openbravo S.L.U. + * Copyright (C) 2020-2023 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. @@ -99,7 +99,7 @@ newCashup.cashTaxInfo = OB.App.State.Cashup.Utils.getTaxesFromBackendObject( currentCashupFromBackend.cashTaxInfo ); - newCashup.cashCloseInfo = currentCashupFromBackend.cashCloseInfo; + newCashup.cashCloseInfo = currentCashupFromBackend.cashCloseInfo || []; return newCashup; }, diff --git a/web/org.openbravo.retail.posterminal/app/model/business-object/cashup/PaymentMethodUtils.js b/web/org.openbravo.retail.posterminal/app/model/business-object/cashup/PaymentMethodUtils.js index 6fbfc14b4..aadeac62f 100644 --- a/web/org.openbravo.retail.posterminal/app/model/business-object/cashup/PaymentMethodUtils.js +++ b/web/org.openbravo.retail.posterminal/app/model/business-object/cashup/PaymentMethodUtils.js @@ -1,6 +1,6 @@ /* ************************************************************************************ - * Copyright (C) 2020-2021 Openbravo S.L.U. + * Copyright (C) 2020-2023 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. @@ -44,7 +44,7 @@ newCashup.totalStartings = OB.DEC.add( newCashup.totalStartings, - startingCash + OB.DEC.mul(startingCash, terminalPayment.rate) ); } } @@ -99,7 +99,16 @@ return paymentMethods; }, - getPaymentMethodFromBackendObject(paymentMethodCashUpModel) { + getCashManagementFromBackendObject(cashManagementInfos) { + return cashManagementInfos.map(cashMgmInfo => { + return { + ...cashMgmInfo, + timezoneOffset: new Date().getTimezoneOffset() + }; + }); + }, + + getPaymentMethodFromBackendObject(paymentMethodCashUpModel, cashMgmInfo) { const paymentMethodInfo = { id: paymentMethodCashUpModel.id, paymentMethodId: paymentMethodCashUpModel.paymentmethod_id, @@ -115,7 +124,17 @@ isocode: paymentMethodCashUpModel.isocode, lineNo: paymentMethodCashUpModel.lineNo, newPaymentMethod: false, - cashManagements: [] + usedInCurrentTrx: !!( + paymentMethodCashUpModel.totalSales || + paymentMethodCashUpModel.totalReturns || + paymentMethodCashUpModel.totalDeposits || + paymentMethodCashUpModel.totalDrops + ), + cashManagements: OB.App.State.Cashup.Utils.getCashManagementFromBackendObject( + cashMgmInfo.filter( + c => c.paymentMethodId === paymentMethodCashUpModel.paymentmethod_id + ) + ) }; if (paymentMethodCashUpModel.countPerAmount) { paymentMethodInfo.countPerAmount = @@ -125,7 +144,7 @@ }, addPaymentsFromBackendCashup(payload) { - const { currentCashupFromBackend, terminalPayments } = payload; + const { newCashup, currentCashupFromBackend, terminalPayments } = payload; const paymentMethods = []; currentCashupFromBackend.cashPaymentMethodInfo.forEach( @@ -151,13 +170,26 @@ paymentMethodCashUp.totalDrops !== 0) ) { const paymentFromBackend = OB.App.State.Cashup.Utils.getPaymentMethodFromBackendObject( - paymentMethodCashUp + paymentMethodCashUp, + currentCashupFromBackend.cashMgmInfo ); paymentMethods.push(paymentFromBackend); } } ); + // Update cashup properties based on payment methods + if (newCashup) { + newCashup.totalStartings = paymentMethods.reduce( + (total, p) => + OB.DEC.add( + total, + OB.DEC.mul(p.initialCounted || p.startingCash || 0, p.rate) + ), + 0 + ); + } + return paymentMethods; }, diff --git a/web/org.openbravo.retail.posterminal/app/model/business-object/cashup/actions/InitCashup.js b/web/org.openbravo.retail.posterminal/app/model/business-object/cashup/actions/InitCashup.js index ea5de32fc..dcb4954d6 100644 --- a/web/org.openbravo.retail.posterminal/app/model/business-object/cashup/actions/InitCashup.js +++ b/web/org.openbravo.retail.posterminal/app/model/business-object/cashup/actions/InitCashup.js @@ -1,6 +1,6 @@ /* ************************************************************************************ - * Copyright (C) 2020 Openbravo S.L.U. + * Copyright (C) 2020-2023 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. @@ -58,7 +58,7 @@ if (currentCashupFromBackend.cashPaymentMethodInfo.length !== 0) { newCashup.cashPaymentMethodInfo = OB.App.State.Cashup.Utils.addPaymentsFromBackendCashup( - { currentCashupFromBackend, terminalPayments } + { newCashup, currentCashupFromBackend, terminalPayments } ); } else { newCashup.cashPaymentMethodInfo = OB.App.State.Cashup.Utils.initializePaymentMethodCashup( diff --git a/web/org.openbravo.retail.posterminal/app/model/business-object/ticket/TicketUtils.js b/web/org.openbravo.retail.posterminal/app/model/business-object/ticket/TicketUtils.js index 30e61cafe..86d4883b5 100644 --- a/web/org.openbravo.retail.posterminal/app/model/business-object/ticket/TicketUtils.js +++ b/web/org.openbravo.retail.posterminal/app/model/business-object/ticket/TicketUtils.js @@ -1500,6 +1500,7 @@ if (currentCashupFromBackend.cashPaymentMethodInfo.length !== 0) { newCashup.cashPaymentMethodInfo = OB.App.State.Cashup.Utils.addPaymentsFromBackendCashup( { + newCashup, currentCashupFromBackend, terminalPayments: payload.payments } 53473_22Q2_posterminal.diff [^] (19,839 bytes) 2023-09-29 14:13 [Show Content] [Hide Content] diff --git a/src/org/openbravo/retail/posterminal/UpdateCashup.java b/src/org/openbravo/retail/posterminal/UpdateCashup.java index 4d9b84475..5f6ddb1e1 100644 --- a/src/org/openbravo/retail/posterminal/UpdateCashup.java +++ b/src/org/openbravo/retail/posterminal/UpdateCashup.java @@ -1,6 +1,6 @@ /* ************************************************************************************ - * Copyright (C) 2016-2021 Openbravo S.L.U. + * Copyright (C) 2016-2023 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. @@ -78,7 +78,7 @@ public class UpdateCashup { } else if (cashUpReportString.lastIndexOf("Z") != -1) { cashUpReportDate = (Date) JsonToDataConverter.convertJsonToPropertyValue( PropertyByType.DATETIME, - (cashUpReportString).subSequence(0, (cashUpReportString).lastIndexOf("Z")) + ":00"); + (cashUpReportString).subSequence(0, (cashUpReportString).lastIndexOf("Z"))); } else { cashUpReportDate = (Date) JsonToDataConverter .convertJsonToPropertyValue(PropertyByType.DATETIME, cashUpReportString); diff --git a/src/org/openbravo/retail/posterminal/master/Cashup.java b/src/org/openbravo/retail/posterminal/master/Cashup.java index 08990351f..afe700c51 100644 --- a/src/org/openbravo/retail/posterminal/master/Cashup.java +++ b/src/org/openbravo/retail/posterminal/master/Cashup.java @@ -1,6 +1,6 @@ /* ************************************************************************************ - * Copyright (C) 2014-2021 Openbravo S.L.U. + * Copyright (C) 2014-2023 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. @@ -49,6 +49,7 @@ import org.openbravo.service.json.JsonConstants; public class Cashup extends JSONProcessSimple { private static final Logger log = LogManager.getLogger(); + private static final DateFormat dateFormatUTC = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'"); @Inject @Any @@ -97,6 +98,9 @@ public class Cashup extends JSONProcessSimple { return result; } + final TimeZone tz = TimeZone.getTimeZone("UTC"); + dateFormatUTC.setTimeZone(tz); + String isprocessed; if (jsonsent.has("isprocessed")) { isprocessed = jsonsent.getString("isprocessed"); @@ -141,13 +145,9 @@ public class Cashup extends JSONProcessSimple { cashupJSON.put("netReturns", cashup[3]); cashupJSON.put("grossReturns", cashup[4]); cashupJSON.put("totalRetailTransactions", cashup[5]); - TimeZone tz = TimeZone.getTimeZone("UTC"); - DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm'Z'"); - df.setTimeZone(tz); - String nowAsISO = df.format(cashup[6]); - cashupJSON.put("creationDate", nowAsISO); + cashupJSON.put("creationDate", dateFormatUTC.format(cashup[6])); cashupJSON.put("userId", cashup[7]); - cashupJSON.put("isprocessed", ((Boolean) cashup[8]) ? "Y" : "N"); + cashupJSON.put("isprocessed", (Boolean) cashup[8]); cashupJSON.put("posterminal", cashup[9]); cashupJSON.put("organization", cashup[10]); @@ -334,20 +334,21 @@ public class Cashup extends JSONProcessSimple { // Set the cashManagement data result.put("id", cashMgmtJSON.get("id")); result.put("description", cashMgmtJSON.get("description")); - result.put("amount", totalamt.toString()); - result.put("origAmount", totalamt.toString()); + result.put("amount", totalamt); + result.put("origAmount", totalamt); result.put("type", cashMgmtJSON.get("paymentAmount").toString().equals("0") ? "deposit" : "drop"); result.put("reasonId", reasonId); result.put("paymentMethodId", paymentmethodId); - result.put("creationDate", cashMgmtJSON.get("creationDate").toString()); + result.put("creationDate", + dateFormatUTC.format(((FIN_FinaccTransaction) cashMgmt).getCreationDate())); result.put("timezoneOffset", "0"); + result.put("posTerminal", posId); result.put("userId", cashMgmtJSON.get("createdBy")); result.put("user", cashMgmtJSON.get("createdBy$_identifier")); result.put("isocode", cashMgmtJSON.get("currency$_identifier")); result.put("cashup_id", cashMgmtJSON.get("obposAppCashup")); result.put("glItem", cashMgmtJSON.get("gLItem")); - result.put("_idx", ""); respArray.put(result); } } diff --git a/src/org/openbravo/retail/posterminal/term/Payments.java b/src/org/openbravo/retail/posterminal/term/Payments.java index 73f20dfa3..336d94335 100644 --- a/src/org/openbravo/retail/posterminal/term/Payments.java +++ b/src/org/openbravo/retail/posterminal/term/Payments.java @@ -1,6 +1,6 @@ /* ************************************************************************************ - * Copyright (C) 2012-2021 Openbravo S.L.U. + * Copyright (C) 2012-2023 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. @@ -61,7 +61,8 @@ public class Payments extends JSONTerminalProperty { + " providerGroupImage.bindaryData as pgimage, providerGroupImage.mimetype as pgmimetype, " + " paymentType, " + " color.hexColor as color, " - + " pmg_color.hexColor as pmg_color " + + " pmg_color.hexColor as pmg_color, " + + " p.line as lineNo " + "from OBPOS_App_Payment as p " + " left join p.financialAccount as f " + " left join f.currency as c " @@ -166,6 +167,7 @@ public class Payments extends JSONTerminalProperty { } payment.put("color", objPayment[15]); payment.put("imageClass", ttPaymentMethod.getImageClass()); + payment.put("lineNo", objPayment[17]); // If the Payment Method is cash, load the rounding properties of the currency if (appPayment.getPaymentMethod().isCash()) { diff --git a/web-test/model/business-object/cashup/Cashup-initCashup-StateAction-fromBackend.test.js b/web-test/model/business-object/cashup/Cashup-initCashup-StateAction-fromBackend.test.js index cda2576d4..eda3f8746 100644 --- a/web-test/model/business-object/cashup/Cashup-initCashup-StateAction-fromBackend.test.js +++ b/web-test/model/business-object/cashup/Cashup-initCashup-StateAction-fromBackend.test.js @@ -1,6 +1,6 @@ /* ************************************************************************************ - * Copyright (C) 2020 Openbravo S.L.U. + * Copyright (C) 2020-2023 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. @@ -64,7 +64,7 @@ describe('Cashup - init cashup State Action - from backend', () => { }; deepfreeze(expectedState); const result = initCashup(initialState, payloadInitFromBackend); - expect(result).toEqual(expectedState); + expect(result).toEqual(expect.objectContaining(expectedState)); }); it('initialize cashup from backend - without cashPaymentMethodInfo', () => { @@ -92,6 +92,6 @@ describe('Cashup - init cashup State Action - from backend', () => { initialState, payloadWithoutCashPaymentMethodInfo ); - expect(result).toEqual(expectedState); + expect(result).toEqual(expect.objectContaining(expectedState)); }); }); diff --git a/web-test/model/business-object/cashup/test-data/cashupAfterComplete.js b/web-test/model/business-object/cashup/test-data/cashupAfterComplete.js index a54bd59be..9cbaeb25d 100644 --- a/web-test/model/business-object/cashup/test-data/cashupAfterComplete.js +++ b/web-test/model/business-object/cashup/test-data/cashupAfterComplete.js @@ -1,6 +1,6 @@ /* ************************************************************************************ - * Copyright (C) 2020 Openbravo S.L.U. + * Copyright (C) 2020-2023 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. @@ -16,7 +16,7 @@ module.exports = { netReturns: 0, grossReturns: 0, totalRetailTransactions: 0, - totalStartings: 250, + totalStartings: 238.04, creationDate: '2020-06-26T14:36:53.173Z', userId: '3073EDF96A3C42CC86C7069E379522D2', posterminal: '9104513C2D0741D4850AE8493998A7C8', diff --git a/web-test/model/business-object/cashup/test-data/cashupAfterLoadCashupFromBackend.js b/web-test/model/business-object/cashup/test-data/cashupAfterLoadCashupFromBackend.js index f92b164cc..b42dc0d38 100644 --- a/web-test/model/business-object/cashup/test-data/cashupAfterLoadCashupFromBackend.js +++ b/web-test/model/business-object/cashup/test-data/cashupAfterLoadCashupFromBackend.js @@ -1,6 +1,6 @@ /* ************************************************************************************ - * Copyright (C) 2020 Openbravo S.L.U. + * Copyright (C) 2020-2023 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. @@ -19,6 +19,7 @@ module.exports = { totalStartings: 0, creationDate: '2020-06-24T07:45Z', userId: '3073EDF96A3C42CC86C7069E379522D2', + cashCloseInfo: [], cashTaxInfo: [ { id: 'E44EB6A6CF2D362EA88FAC723638CDA6', @@ -41,6 +42,7 @@ module.exports = { rate: 1, isocode: 'EUR', newPaymentMethod: false, + usedInCurrentTrx: false, cashManagements: [] }, { @@ -56,6 +58,7 @@ module.exports = { rate: 1, isocode: 'EUR', newPaymentMethod: false, + usedInCurrentTrx: true, cashManagements: [] }, { @@ -71,6 +74,7 @@ module.exports = { rate: 0.76082, isocode: 'USD', newPaymentMethod: false, + usedInCurrentTrx: false, cashManagements: [] }, { @@ -86,6 +90,7 @@ module.exports = { rate: 1, isocode: 'EUR', newPaymentMethod: false, + usedInCurrentTrx: false, cashManagements: [] } ], diff --git a/web-test/model/business-object/cashup/test-data/cashupAfterLoadCashupFromBackendWithoutPayments.js b/web-test/model/business-object/cashup/test-data/cashupAfterLoadCashupFromBackendWithoutPayments.js index e22d0b742..f0996a079 100644 --- a/web-test/model/business-object/cashup/test-data/cashupAfterLoadCashupFromBackendWithoutPayments.js +++ b/web-test/model/business-object/cashup/test-data/cashupAfterLoadCashupFromBackendWithoutPayments.js @@ -1,6 +1,6 @@ /* ************************************************************************************ - * Copyright (C) 2020 Openbravo S.L.U. + * Copyright (C) 2020-2023 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. @@ -19,7 +19,7 @@ module.exports = { totalStartings: 0, creationDate: '2020-06-24T07:45Z', userId: '3073EDF96A3C42CC86C7069E379522D2', - cashCloseInfo: undefined, + cashCloseInfo: [], cashTaxInfo: [ { id: 'E44EB6A6CF2D362EA88FAC723638CDA6', diff --git a/web-test/model/business-object/cashup/test-data/messagesAfterCompleteCashupSharedPayments.js b/web-test/model/business-object/cashup/test-data/messagesAfterCompleteCashupSharedPayments.js index e587721fb..a504d6fe1 100644 --- a/web-test/model/business-object/cashup/test-data/messagesAfterCompleteCashupSharedPayments.js +++ b/web-test/model/business-object/cashup/test-data/messagesAfterCompleteCashupSharedPayments.js @@ -1,6 +1,6 @@ /* ************************************************************************************ - * Copyright (C) 2020-2021 Openbravo S.L.U. + * Copyright (C) 2020-2023 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. @@ -2016,7 +2016,7 @@ module.exports = [ netReturns: 0, grossReturns: 0, totalRetailTransactions: 0, - totalStartings: 250, + totalStartings: 238.04, creationDate: '2020-06-26T14:36:53.173Z', userId: '3073EDF96A3C42CC86C7069E379522D2', posterminal: '9104513C2D0741D4850AE8493998A7C8', diff --git a/web/org.openbravo.retail.posterminal/app/model/business-object/cashup/CashupUtils.js b/web/org.openbravo.retail.posterminal/app/model/business-object/cashup/CashupUtils.js index 3816e247c..4bdbb0cfb 100644 --- a/web/org.openbravo.retail.posterminal/app/model/business-object/cashup/CashupUtils.js +++ b/web/org.openbravo.retail.posterminal/app/model/business-object/cashup/CashupUtils.js @@ -99,7 +99,7 @@ newCashup.cashTaxInfo = OB.App.State.Cashup.Utils.getTaxesFromBackendObject( currentCashupFromBackend.cashTaxInfo ); - newCashup.cashCloseInfo = currentCashupFromBackend.cashCloseInfo; + newCashup.cashCloseInfo = currentCashupFromBackend.cashCloseInfo || []; return newCashup; }, diff --git a/web/org.openbravo.retail.posterminal/app/model/business-object/cashup/PaymentMethodUtils.js b/web/org.openbravo.retail.posterminal/app/model/business-object/cashup/PaymentMethodUtils.js index e8bc0b437..d418fe56b 100644 --- a/web/org.openbravo.retail.posterminal/app/model/business-object/cashup/PaymentMethodUtils.js +++ b/web/org.openbravo.retail.posterminal/app/model/business-object/cashup/PaymentMethodUtils.js @@ -1,6 +1,6 @@ /* ************************************************************************************ - * Copyright (C) 2020-2021 Openbravo S.L.U. + * Copyright (C) 2020-2023 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. @@ -44,7 +44,7 @@ newCashup.totalStartings = OB.DEC.add( newCashup.totalStartings, - startingCash + OB.DEC.mul(startingCash, terminalPayment.rate) ); } } @@ -100,7 +100,16 @@ return paymentMethods; }, - getPaymentMethodFromBackendObject(paymentMethodCashUpModel) { + getCashManagementFromBackendObject(cashManagementInfos) { + return cashManagementInfos.map(cashMgmInfo => { + return { + ...cashMgmInfo, + timezoneOffset: new Date().getTimezoneOffset() + }; + }); + }, + + getPaymentMethodFromBackendObject(paymentMethodCashUpModel, cashMgmInfo) { const paymentMethodInfo = { id: paymentMethodCashUpModel.id, paymentMethodId: paymentMethodCashUpModel.paymentmethod_id, @@ -117,7 +126,17 @@ isocode: paymentMethodCashUpModel.isocode, lineNo: paymentMethodCashUpModel.lineNo, newPaymentMethod: false, - cashManagements: [] + usedInCurrentTrx: !!( + paymentMethodCashUpModel.totalSales || + paymentMethodCashUpModel.totalReturns || + paymentMethodCashUpModel.totalDeposits || + paymentMethodCashUpModel.totalDrops + ), + cashManagements: OB.App.State.Cashup.Utils.getCashManagementFromBackendObject( + cashMgmInfo.filter( + c => c.paymentMethodId === paymentMethodCashUpModel.paymentmethod_id + ) + ) }; if (paymentMethodCashUpModel.countPerAmount) { paymentMethodInfo.countPerAmount = @@ -127,7 +146,7 @@ }, addPaymentsFromBackendCashup(payload) { - const { currentCashupFromBackend, terminalPayments } = payload; + const { newCashup, currentCashupFromBackend, terminalPayments } = payload; const paymentMethods = []; currentCashupFromBackend.cashPaymentMethodInfo.forEach( @@ -153,13 +172,23 @@ paymentMethodCashUp.totalDrops !== 0) ) { const paymentFromBackend = OB.App.State.Cashup.Utils.getPaymentMethodFromBackendObject( - paymentMethodCashUp + paymentMethodCashUp, + currentCashupFromBackend.cashMgmInfo ); paymentMethods.push(paymentFromBackend); } } ); + // Update cashup properties based on payment methods + if (newCashup) { + newCashup.totalStartings = paymentMethods.reduce( + (total, p) => + OB.DEC.add(total, OB.DEC.mul(p.initialCounted || 0, p.rate)), + 0 + ); + } + return paymentMethods; }, diff --git a/web/org.openbravo.retail.posterminal/app/model/business-object/cashup/actions/InitCashup.js b/web/org.openbravo.retail.posterminal/app/model/business-object/cashup/actions/InitCashup.js index d4b4acf7b..f9c14e9d7 100644 --- a/web/org.openbravo.retail.posterminal/app/model/business-object/cashup/actions/InitCashup.js +++ b/web/org.openbravo.retail.posterminal/app/model/business-object/cashup/actions/InitCashup.js @@ -1,6 +1,6 @@ /* ************************************************************************************ - * Copyright (C) 2020 Openbravo S.L.U. + * Copyright (C) 2020-2023 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. @@ -30,9 +30,9 @@ initCashup(state, payload) { const newState = { ...state }; const creationDate = payload.currentDate; - const cashup = { - ...newState.Cashup, - userId: payload.userId, + const cashup = { + ...newState.Cashup, + userId: payload.userId, creationDate: creationDate.toISOString() }; let newCashup; @@ -63,7 +63,7 @@ if (currentCashupFromBackend.cashPaymentMethodInfo.length !== 0) { newCashup.cashPaymentMethodInfo = OB.App.State.Cashup.Utils.addPaymentsFromBackendCashup( - { currentCashupFromBackend, terminalPayments } + { newCashup, currentCashupFromBackend, terminalPayments } ); } else { newCashup.cashPaymentMethodInfo = OB.App.State.Cashup.Utils.initializePaymentMethodCashup( diff --git a/web/org.openbravo.retail.posterminal/app/model/business-object/ticket/TicketUtils.js b/web/org.openbravo.retail.posterminal/app/model/business-object/ticket/TicketUtils.js index 586395eae..5b607d5a7 100644 --- a/web/org.openbravo.retail.posterminal/app/model/business-object/ticket/TicketUtils.js +++ b/web/org.openbravo.retail.posterminal/app/model/business-object/ticket/TicketUtils.js @@ -1649,6 +1649,7 @@ if (currentCashupFromBackend.cashPaymentMethodInfo.length !== 0) { newCashup.cashPaymentMethodInfo = OB.App.State.Cashup.Utils.addPaymentsFromBackendCashup( { + newCashup, currentCashupFromBackend, terminalPayments: payload.payments } 53473_22Q4_posterminal.diff [^] (22,405 bytes) 2023-09-29 14:13 [Show Content] [Hide Content] diff --git a/src/org/openbravo/retail/posterminal/UpdateCashup.java b/src/org/openbravo/retail/posterminal/UpdateCashup.java index 2bdbc0950..2afbcc77b 100644 --- a/src/org/openbravo/retail/posterminal/UpdateCashup.java +++ b/src/org/openbravo/retail/posterminal/UpdateCashup.java @@ -85,7 +85,7 @@ public class UpdateCashup { } else if (cashUpReportString.lastIndexOf("Z") != -1) { cashUpReportDate = (Date) JsonToDataConverter.convertJsonToPropertyValue( PropertyByType.DATETIME, - (cashUpReportString).subSequence(0, (cashUpReportString).lastIndexOf("Z")) + ":00"); + (cashUpReportString).subSequence(0, (cashUpReportString).lastIndexOf("Z"))); } else { cashUpReportDate = (Date) JsonToDataConverter .convertJsonToPropertyValue(PropertyByType.DATETIME, cashUpReportString); diff --git a/src/org/openbravo/retail/posterminal/master/Cashup.java b/src/org/openbravo/retail/posterminal/master/Cashup.java index 66e2dc408..fc8701a6a 100644 --- a/src/org/openbravo/retail/posterminal/master/Cashup.java +++ b/src/org/openbravo/retail/posterminal/master/Cashup.java @@ -8,6 +8,7 @@ */ package org.openbravo.retail.posterminal.master; +import java.math.BigDecimal; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.ArrayList; @@ -52,6 +53,7 @@ import org.openbravo.service.json.JsonConstants; public class Cashup extends JSONProcessSimple { private static final Logger log = LogManager.getLogger(); + private static final DateFormat dateFormatUTC = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'"); @Inject @Any @@ -120,6 +122,9 @@ public class Cashup extends JSONProcessSimple { return result; } + final TimeZone tz = TimeZone.getTimeZone("UTC"); + dateFormatUTC.setTimeZone(tz); + String isprocessed; if (jsonsent.has("isprocessed")) { isprocessed = jsonsent.getString("isprocessed"); @@ -167,13 +172,9 @@ public class Cashup extends JSONProcessSimple { cashupJSON.put("netReturns", cashup[3]); cashupJSON.put("grossReturns", cashup[4]); cashupJSON.put("totalRetailTransactions", cashup[5]); - TimeZone tz = TimeZone.getTimeZone("UTC"); - DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm'Z'"); - df.setTimeZone(tz); - String nowAsISO = df.format(cashup[6]); - cashupJSON.put("creationDate", nowAsISO); + cashupJSON.put("creationDate", dateFormatUTC.format(cashup[6])); cashupJSON.put("userId", cashup[7]); - cashupJSON.put("isprocessed", ((Boolean) cashup[8]) ? "Y" : "N"); + cashupJSON.put("isprocessed", (Boolean) cashup[8]); cashupJSON.put("posterminal", cashup[9]); cashupJSON.put("organization", cashup[10]); cashupJSON.put("totalDeleteTickets", cashup[11]); @@ -378,20 +379,21 @@ public class Cashup extends JSONProcessSimple { // Set the cashManagement data result.put("id", cashMgmtJSON.get("id")); result.put("description", cashMgmtJSON.get("description")); - result.put("amount", totalamt.toString()); - result.put("origAmount", totalamt.toString()); + result.put("amount", totalamt); + result.put("origAmount", totalamt); result.put("type", cashMgmtJSON.get("paymentAmount").toString().equals("0") ? "deposit" : "drop"); result.put("reasonId", reasonId); result.put("paymentMethodId", paymentmethodId); - result.put("creationDate", cashMgmtJSON.get("creationDate").toString()); + result.put("creationDate", + dateFormatUTC.format(((FIN_FinaccTransaction) cashMgmt).getCreationDate())); result.put("timezoneOffset", "0"); + result.put("posTerminal", posId); result.put("userId", cashMgmtJSON.get("createdBy")); result.put("user", cashMgmtJSON.get("createdBy$_identifier")); result.put("isocode", cashMgmtJSON.get("currency$_identifier")); result.put("cashup_id", cashMgmtJSON.get("obposAppCashup")); result.put("glItem", cashMgmtJSON.get("gLItem")); - result.put("_idx", ""); respArray.put(result); } } @@ -414,6 +416,7 @@ public class Cashup extends JSONProcessSimple { JSONObject productCategoryObject = new JSONObject(); productCategoryObject.put("prodCatId", productCategory.getProductCategory().getId()); + productCategoryObject.put("prodCatName", productCategory.getProductCategory().getName()); productCategoryObject.put("numberOfItems", productCategory.getNumberofitems()); productCategoryObject.put("totalAmount", productCategory.getTotalamount()); @@ -438,6 +441,7 @@ public class Cashup extends JSONProcessSimple { JSONObject userObject = new JSONObject(); userObject.put("id", user.getSupervisor().getId()); + userObject.put("name", user.getSupervisor().getName()); userObject.put("totalCompleteTickets", user.getTotalcompletetickets()); userObject.put("totalAmount", user.getTotalamount()); @@ -459,7 +463,9 @@ public class Cashup extends JSONProcessSimple { JSONArray paymentMethodArray = new JSONArray(); for (OBPOSPaymentMethodCashup paymentMethod : paymentMethodList) { - + if (BigDecimal.ZERO.compareTo(paymentMethod.getTotalreceipt()) == 0) { + continue; + } JSONObject paymentMethodObject = new JSONObject(); paymentMethodObject.put("name", paymentMethod.getSearchkey()); paymentMethodObject.put("quantityReceipt", paymentMethod.getTotalreceipt()); diff --git a/src/org/openbravo/retail/posterminal/term/Payments.java b/src/org/openbravo/retail/posterminal/term/Payments.java index d1ecab09a..ac286f30c 100644 --- a/src/org/openbravo/retail/posterminal/term/Payments.java +++ b/src/org/openbravo/retail/posterminal/term/Payments.java @@ -1,6 +1,6 @@ /* ************************************************************************************ - * Copyright (C) 2012-2022 Openbravo S.L.U. + * Copyright (C) 2012-2023 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. @@ -63,7 +63,8 @@ public class Payments extends JSONTerminalProperty { + " paymentType, " + " color.hexColor as color, " + " pmg_color.hexColor as pmg_color, " - + " p.paymentMethod.currency.pricePrecision as obposPricePrecision " + + " p.paymentMethod.currency.pricePrecision as obposPricePrecision, " + + " p.line as lineNo " + "from OBPOS_App_Payment as p " + " left join p.financialAccount as f " + " left join f.currency as c " @@ -171,6 +172,7 @@ public class Payments extends JSONTerminalProperty { if (objPayment[8] != null) { payment.put("obposPricePrecision", objPayment[17]); } + payment.put("lineNo", objPayment[18]); // If the Payment Method is cash, load the rounding properties of the currency if (appPayment.getPaymentMethod().isCash()) { diff --git a/web-test/model/business-object/cashup/Cashup-initCashup-StateAction-fromBackend.test.js b/web-test/model/business-object/cashup/Cashup-initCashup-StateAction-fromBackend.test.js index cda2576d4..eda3f8746 100644 --- a/web-test/model/business-object/cashup/Cashup-initCashup-StateAction-fromBackend.test.js +++ b/web-test/model/business-object/cashup/Cashup-initCashup-StateAction-fromBackend.test.js @@ -1,6 +1,6 @@ /* ************************************************************************************ - * Copyright (C) 2020 Openbravo S.L.U. + * Copyright (C) 2020-2023 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. @@ -64,7 +64,7 @@ describe('Cashup - init cashup State Action - from backend', () => { }; deepfreeze(expectedState); const result = initCashup(initialState, payloadInitFromBackend); - expect(result).toEqual(expectedState); + expect(result).toEqual(expect.objectContaining(expectedState)); }); it('initialize cashup from backend - without cashPaymentMethodInfo', () => { @@ -92,6 +92,6 @@ describe('Cashup - init cashup State Action - from backend', () => { initialState, payloadWithoutCashPaymentMethodInfo ); - expect(result).toEqual(expectedState); + expect(result).toEqual(expect.objectContaining(expectedState)); }); }); diff --git a/web-test/model/business-object/cashup/test-data/cashupAfterComplete.js b/web-test/model/business-object/cashup/test-data/cashupAfterComplete.js index 0bcaa4c6f..b2076e220 100644 --- a/web-test/model/business-object/cashup/test-data/cashupAfterComplete.js +++ b/web-test/model/business-object/cashup/test-data/cashupAfterComplete.js @@ -1,6 +1,6 @@ /* ************************************************************************************ - * Copyright (C) 2020 Openbravo S.L.U. + * Copyright (C) 2020-2023 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. @@ -17,7 +17,7 @@ module.exports = { netReturns: 0, grossReturns: 0, totalRetailTransactions: 0, - totalStartings: 250, + totalStartings: 238.04, creationDate: '2020-06-26T14:36:53.173Z', userId: '3073EDF96A3C42CC86C7069E379522D2', posterminal: '9104513C2D0741D4850AE8493998A7C8', diff --git a/web-test/model/business-object/cashup/test-data/cashupAfterLoadCashupFromBackend.js b/web-test/model/business-object/cashup/test-data/cashupAfterLoadCashupFromBackend.js index f92b164cc..b42dc0d38 100644 --- a/web-test/model/business-object/cashup/test-data/cashupAfterLoadCashupFromBackend.js +++ b/web-test/model/business-object/cashup/test-data/cashupAfterLoadCashupFromBackend.js @@ -1,6 +1,6 @@ /* ************************************************************************************ - * Copyright (C) 2020 Openbravo S.L.U. + * Copyright (C) 2020-2023 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. @@ -19,6 +19,7 @@ module.exports = { totalStartings: 0, creationDate: '2020-06-24T07:45Z', userId: '3073EDF96A3C42CC86C7069E379522D2', + cashCloseInfo: [], cashTaxInfo: [ { id: 'E44EB6A6CF2D362EA88FAC723638CDA6', @@ -41,6 +42,7 @@ module.exports = { rate: 1, isocode: 'EUR', newPaymentMethod: false, + usedInCurrentTrx: false, cashManagements: [] }, { @@ -56,6 +58,7 @@ module.exports = { rate: 1, isocode: 'EUR', newPaymentMethod: false, + usedInCurrentTrx: true, cashManagements: [] }, { @@ -71,6 +74,7 @@ module.exports = { rate: 0.76082, isocode: 'USD', newPaymentMethod: false, + usedInCurrentTrx: false, cashManagements: [] }, { @@ -86,6 +90,7 @@ module.exports = { rate: 1, isocode: 'EUR', newPaymentMethod: false, + usedInCurrentTrx: false, cashManagements: [] } ], diff --git a/web-test/model/business-object/cashup/test-data/cashupAfterLoadCashupFromBackendWithoutPayments.js b/web-test/model/business-object/cashup/test-data/cashupAfterLoadCashupFromBackendWithoutPayments.js index e22d0b742..f0996a079 100644 --- a/web-test/model/business-object/cashup/test-data/cashupAfterLoadCashupFromBackendWithoutPayments.js +++ b/web-test/model/business-object/cashup/test-data/cashupAfterLoadCashupFromBackendWithoutPayments.js @@ -1,6 +1,6 @@ /* ************************************************************************************ - * Copyright (C) 2020 Openbravo S.L.U. + * Copyright (C) 2020-2023 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. @@ -19,7 +19,7 @@ module.exports = { totalStartings: 0, creationDate: '2020-06-24T07:45Z', userId: '3073EDF96A3C42CC86C7069E379522D2', - cashCloseInfo: undefined, + cashCloseInfo: [], cashTaxInfo: [ { id: 'E44EB6A6CF2D362EA88FAC723638CDA6', diff --git a/web-test/model/business-object/cashup/test-data/messagesAfterCompleteCashupSharedPayments.js b/web-test/model/business-object/cashup/test-data/messagesAfterCompleteCashupSharedPayments.js index f0962fdd1..609e8b5bd 100644 --- a/web-test/model/business-object/cashup/test-data/messagesAfterCompleteCashupSharedPayments.js +++ b/web-test/model/business-object/cashup/test-data/messagesAfterCompleteCashupSharedPayments.js @@ -1,6 +1,6 @@ /* ************************************************************************************ - * Copyright (C) 2020-2021 Openbravo S.L.U. + * Copyright (C) 2020-2023 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. @@ -2025,7 +2025,7 @@ module.exports = [ netReturns: 0, grossReturns: 0, totalRetailTransactions: 0, - totalStartings: 250, + totalStartings: 238.04, creationDate: '2020-06-26T14:36:53.173Z', userId: '3073EDF96A3C42CC86C7069E379522D2', posterminal: '9104513C2D0741D4850AE8493998A7C8', diff --git a/web/org.openbravo.retail.posterminal/app/model/business-object/cashup/CashupUtils.js b/web/org.openbravo.retail.posterminal/app/model/business-object/cashup/CashupUtils.js index 1580b99d3..36cbaa115 100644 --- a/web/org.openbravo.retail.posterminal/app/model/business-object/cashup/CashupUtils.js +++ b/web/org.openbravo.retail.posterminal/app/model/business-object/cashup/CashupUtils.js @@ -1,6 +1,6 @@ /* ************************************************************************************ - * Copyright (C) 2020-2022 Openbravo S.L.U. + * Copyright (C) 2020-2023 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. @@ -85,6 +85,7 @@ newCashup.users = []; newCashup.productCategories = []; newCashup.paymentMethods = []; + newCashup.cashCloseInfo = []; return OB.App.State.DocumentSequence.Utils.generateCashupDocumentNumber( { ...newCashup }, @@ -94,7 +95,7 @@ }, createNewCashupFromBackend(payload) { - const { cashup, currentCashupFromBackend } = payload; + const { cashup, documentSequence, currentCashupFromBackend } = payload; const newCashup = { ...cashup }; newCashup.id = currentCashupFromBackend.id; @@ -114,7 +115,7 @@ newCashup.cashTaxInfo = OB.App.State.Cashup.Utils.getTaxesFromBackendObject( currentCashupFromBackend.cashTaxInfo ); - newCashup.cashCloseInfo = currentCashupFromBackend.cashCloseInfo; + newCashup.cashCloseInfo = currentCashupFromBackend.cashCloseInfo || []; newCashup.totalDeleteTickets = currentCashupFromBackend.totalDeleteTickets; @@ -129,6 +130,16 @@ newCashup.productCategories = currentCashupFromBackend.productCategories; newCashup.paymentMethods = currentCashupFromBackend.paymentMethods; + if (documentSequence) { + const sequenceName = OB.App.State.DocumentSequence.Utils.getCashupSequenceName(); + const { sequencePrefix, sequenceNumber } = documentSequence[ + sequenceName + ]; + newCashup.obposSequencename = sequenceName; + newCashup.obposSequenceprefix = sequencePrefix; + newCashup.obposSequencenumber = sequenceNumber; + } + return newCashup; }, diff --git a/web/org.openbravo.retail.posterminal/app/model/business-object/cashup/PaymentMethodUtils.js b/web/org.openbravo.retail.posterminal/app/model/business-object/cashup/PaymentMethodUtils.js index e8bc0b437..d418fe56b 100644 --- a/web/org.openbravo.retail.posterminal/app/model/business-object/cashup/PaymentMethodUtils.js +++ b/web/org.openbravo.retail.posterminal/app/model/business-object/cashup/PaymentMethodUtils.js @@ -1,6 +1,6 @@ /* ************************************************************************************ - * Copyright (C) 2020-2021 Openbravo S.L.U. + * Copyright (C) 2020-2023 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. @@ -44,7 +44,7 @@ newCashup.totalStartings = OB.DEC.add( newCashup.totalStartings, - startingCash + OB.DEC.mul(startingCash, terminalPayment.rate) ); } } @@ -100,7 +100,16 @@ return paymentMethods; }, - getPaymentMethodFromBackendObject(paymentMethodCashUpModel) { + getCashManagementFromBackendObject(cashManagementInfos) { + return cashManagementInfos.map(cashMgmInfo => { + return { + ...cashMgmInfo, + timezoneOffset: new Date().getTimezoneOffset() + }; + }); + }, + + getPaymentMethodFromBackendObject(paymentMethodCashUpModel, cashMgmInfo) { const paymentMethodInfo = { id: paymentMethodCashUpModel.id, paymentMethodId: paymentMethodCashUpModel.paymentmethod_id, @@ -117,7 +126,17 @@ isocode: paymentMethodCashUpModel.isocode, lineNo: paymentMethodCashUpModel.lineNo, newPaymentMethod: false, - cashManagements: [] + usedInCurrentTrx: !!( + paymentMethodCashUpModel.totalSales || + paymentMethodCashUpModel.totalReturns || + paymentMethodCashUpModel.totalDeposits || + paymentMethodCashUpModel.totalDrops + ), + cashManagements: OB.App.State.Cashup.Utils.getCashManagementFromBackendObject( + cashMgmInfo.filter( + c => c.paymentMethodId === paymentMethodCashUpModel.paymentmethod_id + ) + ) }; if (paymentMethodCashUpModel.countPerAmount) { paymentMethodInfo.countPerAmount = @@ -127,7 +146,7 @@ }, addPaymentsFromBackendCashup(payload) { - const { currentCashupFromBackend, terminalPayments } = payload; + const { newCashup, currentCashupFromBackend, terminalPayments } = payload; const paymentMethods = []; currentCashupFromBackend.cashPaymentMethodInfo.forEach( @@ -153,13 +172,23 @@ paymentMethodCashUp.totalDrops !== 0) ) { const paymentFromBackend = OB.App.State.Cashup.Utils.getPaymentMethodFromBackendObject( - paymentMethodCashUp + paymentMethodCashUp, + currentCashupFromBackend.cashMgmInfo ); paymentMethods.push(paymentFromBackend); } } ); + // Update cashup properties based on payment methods + if (newCashup) { + newCashup.totalStartings = paymentMethods.reduce( + (total, p) => + OB.DEC.add(total, OB.DEC.mul(p.initialCounted || 0, p.rate)), + 0 + ); + } + return paymentMethods; }, diff --git a/web/org.openbravo.retail.posterminal/app/model/business-object/cashup/actions/InitCashup.js b/web/org.openbravo.retail.posterminal/app/model/business-object/cashup/actions/InitCashup.js index 979af679e..76164c940 100644 --- a/web/org.openbravo.retail.posterminal/app/model/business-object/cashup/actions/InitCashup.js +++ b/web/org.openbravo.retail.posterminal/app/model/business-object/cashup/actions/InitCashup.js @@ -1,6 +1,6 @@ /* ************************************************************************************ - * Copyright (C) 2020-2022 Openbravo S.L.U. + * Copyright (C) 2020-2023 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. @@ -53,12 +53,13 @@ newCashup = OB.App.State.Cashup.Utils.createNewCashupFromBackend({ cashup, + documentSequence: state.DocumentSequence, currentCashupFromBackend }); if (currentCashupFromBackend.cashPaymentMethodInfo.length !== 0) { newCashup.cashPaymentMethodInfo = OB.App.State.Cashup.Utils.addPaymentsFromBackendCashup( - { currentCashupFromBackend, terminalPayments } + { newCashup, currentCashupFromBackend, terminalPayments } ); } else { newCashup.cashPaymentMethodInfo = OB.App.State.Cashup.Utils.initializePaymentMethodCashup( diff --git a/web/org.openbravo.retail.posterminal/app/model/business-object/ticket/TicketUtils.js b/web/org.openbravo.retail.posterminal/app/model/business-object/ticket/TicketUtils.js index 20ad7052f..5b7c9ed46 100644 --- a/web/org.openbravo.retail.posterminal/app/model/business-object/ticket/TicketUtils.js +++ b/web/org.openbravo.retail.posterminal/app/model/business-object/ticket/TicketUtils.js @@ -1717,11 +1717,13 @@ // Load Cashup from Backend const newCashup = OB.App.State.Cashup.Utils.createNewCashupFromBackend({ cashup: state.Cashup, + documentSequence: state.DocumentSequence, currentCashupFromBackend }); if (currentCashupFromBackend.cashPaymentMethodInfo.length !== 0) { newCashup.cashPaymentMethodInfo = OB.App.State.Cashup.Utils.addPaymentsFromBackendCashup( { + newCashup, currentCashupFromBackend, terminalPayments: payload.payments } | |||||||
Relationships [ Relation Graph ] [ Dependency Graph ] | |||||||||||||||||||||||||||||||||
|
Notes | |
(0155181) hgbot (developer) 2023-09-22 13:38 |
Merge Request created: https://gitlab.com/openbravo/product/pmods/org.openbravo.retail.posterminal/-/merge_requests/1357 [^] |
(0155182) hgbot (developer) 2023-09-22 13:38 |
Merge Request created: https://gitlab.com/openbravo/ci/mobile-test/-/merge_requests/328 [^] |
(0155232) hgbot (developer) 2023-09-26 09:46 |
Merge Request created: https://gitlab.com/openbravo/product/pmods/org.openbravo.retail.sessions/-/merge_requests/98 [^] |
(0155233) hgbot (developer) 2023-09-26 09:46 |
Merge Request created: https://gitlab.com/openbravo/product/pmods/org.openbravo.pos2/-/merge_requests/2115 [^] |
(0155245) hgbot (developer) 2023-09-26 14:32 |
Merge request merged: https://gitlab.com/openbravo/product/pmods/org.openbravo.retail.posterminal/-/merge_requests/1357 [^] |
(0155246) hgbot (developer) 2023-09-26 14:32 |
Directly closing issue as related merge request is already approved. Repository: https://gitlab.com/openbravo/product/pmods/org.openbravo.retail.posterminal [^] Changeset: 599e9a528761640db733f17f8828aa29d6e80ec4 Author: Ranjith S R <ranjith@qualiantech.com> Date: 26-09-2023 15:11:53 URL: https://gitlab.com/openbravo/product/pmods/org.openbravo.retail.posterminal/-/commit/599e9a528761640db733f17f8828aa29d6e80ec4 [^] Fixed ISSUE-53473: Added Cashup properties when creating cashup from backend * When cashup loaded from backoffice, following cashup properties should be updated * Cashup totalStartings * Cashup PaymentMethod's cashManagementsInfo * Cashup documentNo sequence info --- M src/org/openbravo/retail/posterminal/UpdateCashup.java M src/org/openbravo/retail/posterminal/master/Cashup.java M src/org/openbravo/retail/posterminal/term/Payments.java M web-test/model/business-object/cashup/Cashup-initCashup-StateAction-fromBackend.test.js M web-test/model/business-object/cashup/test-data/cashupAfterLoadCashupFromBackend.js M web-test/model/business-object/cashup/test-data/cashupAfterLoadCashupFromBackendWithoutPayments.js M web/org.openbravo.retail.posterminal/app/model/business-object/cashup/CashupUtils.js M web/org.openbravo.retail.posterminal/app/model/business-object/cashup/PaymentMethodUtils.js M web/org.openbravo.retail.posterminal/app/model/business-object/cashup/actions/InitCashup.js M web/org.openbravo.retail.posterminal/app/model/business-object/ticket/TicketUtils.js --- |
(0155247) hgbot (developer) 2023-09-26 14:32 |
Merge request merged: https://gitlab.com/openbravo/ci/mobile-test/-/merge_requests/328 [^] |
(0155248) hgbot (developer) 2023-09-26 14:32 |
Merge request merged: https://gitlab.com/openbravo/product/pmods/org.openbravo.retail.sessions/-/merge_requests/98 [^] |
(0155249) hgbot (developer) 2023-09-26 14:32 |
Repository: https://gitlab.com/openbravo/product/pmods/org.openbravo.retail.sessions [^] Changeset: fd562c50ed8fc78eec29b6027746aa199becb543 Author: Ranjith S R <ranjith@qualiantech.com> Date: 26-09-2023 13:04:41 URL: https://gitlab.com/openbravo/product/pmods/org.openbravo.retail.sessions/-/commit/fd562c50ed8fc78eec29b6027746aa199becb543 [^] Related to ISSUE-53473: TotalStartings should be updatd based on Currency Rate --- M web/org.openbravo.retail.sessions/js/hook/ProcessCashManagements.js --- |
(0155250) hgbot (developer) 2023-09-26 14:32 |
Repository: https://gitlab.com/openbravo/ci/mobile-test [^] Changeset: b257f9a54a4c1a8b60a60f80b9c957b1cda62131 Author: Ranjith S R <ranjith@qualiantech.com> Date: 26-09-2023 12:32:30 URL: https://gitlab.com/openbravo/ci/mobile-test/-/commit/b257f9a54a4c1a8b60a60f80b9c957b1cda62131 [^] Verifies ISSUE-53473: Updated tests for validating Cashup after cache clear --- M src-test/org/openbravo/test/mobile/retail/extmodules/selenium/tests/sessions/openstoretill/I40490_VerifyTillDifferenceNotDeletedWhenCacheIsCleared.java --- |
(0155251) hgbot (developer) 2023-09-26 14:32 |
Repository: https://gitlab.com/openbravo/product/pmods/org.openbravo.pos2 [^] Changeset: c4efe2598900f37e7bbb3febc36a50b1a737edd7 Author: Ranjith S R <ranjith@qualiantech.com> Date: 26-09-2023 12:32:43 URL: https://gitlab.com/openbravo/product/pmods/org.openbravo.pos2/-/commit/c4efe2598900f37e7bbb3febc36a50b1a737edd7 [^] Related to ISSUE-53473: TotalStartings should be updatd based on Currency Rate --- M web-jspack/org.openbravo.pos2/src/model/user-interface/actions/cashup/SetInitialCountCashup.js --- |
(0155252) hgbot (developer) 2023-09-26 14:32 |
Merge request merged: https://gitlab.com/openbravo/product/pmods/org.openbravo.pos2/-/merge_requests/2115 [^] |
(0155256) hgbot (developer) 2023-09-26 15:15 |
Repository: https://gitlab.com/openbravo/product/pmods/org.openbravo.retail.posterminal [^] Changeset: b89dcd4c985208c7909b9e33ffbf2ade0b9d082f Author: Ranjith S R <ranjith@qualiantech.com> Date: 26-09-2023 18:44:02 URL: https://gitlab.com/openbravo/product/pmods/org.openbravo.retail.posterminal/-/commit/b89dcd4c985208c7909b9e33ffbf2ade0b9d082f [^] Related to ISSUE-53473: Updated Cashup jest test for validating totalStartings * Cashup totalStartings should be updated based on payment method conversion rate --- M web-test/model/business-object/cashup/test-data/cashupAfterComplete.js M web-test/model/business-object/cashup/test-data/messagesAfterCompleteCashupSharedPayments.js --- |
Issue History | |||
Date Modified | Username | Field | Change |
2023-09-18 14:14 | ranjith_qualiantech_com | New Issue | |
2023-09-18 14:14 | ranjith_qualiantech_com | Assigned To | => ranjith_qualiantech_com |
2023-09-18 14:14 | ranjith_qualiantech_com | Triggers an Emergency Pack | => No |
2023-09-18 14:16 | ranjith_qualiantech_com | Relationship added | related to 0052864 |
2023-09-18 14:16 | ranjith_qualiantech_com | Relationship added | related to 0053425 |
2023-09-19 02:39 | ranjith_qualiantech_com | Status | new => scheduled |
2023-09-22 13:38 | hgbot | Note Added: 0155181 | |
2023-09-22 13:38 | hgbot | Note Added: 0155182 | |
2023-09-26 09:46 | hgbot | Note Added: 0155232 | |
2023-09-26 09:46 | hgbot | Note Added: 0155233 | |
2023-09-26 14:32 | hgbot | Note Added: 0155245 | |
2023-09-26 14:32 | hgbot | Resolution | open => fixed |
2023-09-26 14:32 | hgbot | Status | scheduled => closed |
2023-09-26 14:32 | hgbot | Fixed in Version | => RR23Q4 |
2023-09-26 14:32 | hgbot | Note Added: 0155246 | |
2023-09-26 14:32 | hgbot | Note Added: 0155247 | |
2023-09-26 14:32 | hgbot | Note Added: 0155248 | |
2023-09-26 14:32 | hgbot | Note Added: 0155249 | |
2023-09-26 14:32 | hgbot | Note Added: 0155250 | |
2023-09-26 14:32 | hgbot | Note Added: 0155251 | |
2023-09-26 14:32 | hgbot | Note Added: 0155252 | |
2023-09-26 15:15 | hgbot | Note Added: 0155256 | |
2023-09-29 14:12 | malsasua | File Added: 53473_21Q4_posterminal.diff | |
2023-09-29 14:13 | malsasua | File Added: 53473_22Q2_posterminal.diff | |
2023-09-29 14:13 | malsasua | File Added: 53473_22Q4_posterminal.diff |
Copyright © 2000 - 2009 MantisBT Group |