Project:
View Issue Details[ Jump to Notes ] | [ Issue History ] [ Print ] | |||||||
ID | ||||||||
0048442 | ||||||||
Type | Category | Severity | Reproducibility | Date Submitted | Last Update | |||
defect | [Retail Modules] Web POS | major | N/A | 2022-01-19 20:40 | 2022-01-31 07:39 | |||
Reporter | ffourcade | View Status | public | |||||
Assigned To | ranjith_qualiantech_com | |||||||
Priority | normal | Resolution | no change required | 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 | pi | SCM revision | ||||||
Merge Request Status | ||||||||
Review Assigned To | marvintm | |||||||
OBNetwork customer | Gold | |||||||
Support ticket | ||||||||
Regression level | ||||||||
Regression date | ||||||||
Regression introduced in release | ||||||||
Regression introduced by commit | ||||||||
Triggers an Emergency Pack | No | |||||||
Summary | 0048442: Request for doing a validation in the web pos to avoid a recurring Error While importing | |||||||
Description | When an order is loaded to the WEB Pos, if it is modified by someone else in other till, or in the backoffice before we send it to the back office, an error while importing can appears with the error OutDatedDataChangeException. | |||||||
Steps To Reproduce | . | |||||||
Proposed Solution | Implement a validation when clicking "Done" to check if the sales order has been modified since we opened it in the web pos. It is done with layaways, but not with regular orders. | |||||||
Tags | No tags attached. | |||||||
Attached Files | ![]() diff --git a/src-db/database/sourcedata/AD_MESSAGE.xml b/src-db/database/sourcedata/AD_MESSAGE.xml index 21f6e2426..ffcd9b15b 100644 --- a/src-db/database/sourcedata/AD_MESSAGE.xml +++ b/src-db/database/sourcedata/AD_MESSAGE.xml @@ -853,6 +853,18 @@ <!--12BF57825EA1456E8567E73E1E947402--> <ISINCLUDEINI18N><![CDATA[N]]></ISINCLUDEINI18N> <!--12BF57825EA1456E8567E73E1E947402--></AD_MESSAGE> +<!--12DA431A4FCA47F89C8519B42F46E295--><AD_MESSAGE> +<!--12DA431A4FCA47F89C8519B42F46E295--> <AD_MESSAGE_ID><![CDATA[12DA431A4FCA47F89C8519B42F46E295]]></AD_MESSAGE_ID> +<!--12DA431A4FCA47F89C8519B42F46E295--> <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID> +<!--12DA431A4FCA47F89C8519B42F46E295--> <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID> +<!--12DA431A4FCA47F89C8519B42F46E295--> <ISACTIVE><![CDATA[Y]]></ISACTIVE> +<!--12DA431A4FCA47F89C8519B42F46E295--> <VALUE><![CDATA[OBPOS_SyncPending]]></VALUE> +<!--12DA431A4FCA47F89C8519B42F46E295--> <MSGTEXT><![CDATA[The receipt %0 is still synchronizing. It's not possible to synchronize it again until the previous one finishes. Try again later.]]></MSGTEXT> +<!--12DA431A4FCA47F89C8519B42F46E295--> <MSGTYPE><![CDATA[E]]></MSGTYPE> +<!--12DA431A4FCA47F89C8519B42F46E295--> <AD_MODULE_ID><![CDATA[FF808181326CC34901326D53DBCF0018]]></AD_MODULE_ID> +<!--12DA431A4FCA47F89C8519B42F46E295--> <ISINCLUDEINI18N><![CDATA[N]]></ISINCLUDEINI18N> +<!--12DA431A4FCA47F89C8519B42F46E295--></AD_MESSAGE> + <!--1315FACB3884414BA9E7B8CAB3A9E81F--><AD_MESSAGE> <!--1315FACB3884414BA9E7B8CAB3A9E81F--> <AD_MESSAGE_ID><![CDATA[1315FACB3884414BA9E7B8CAB3A9E81F]]></AD_MESSAGE_ID> <!--1315FACB3884414BA9E7B8CAB3A9E81F--> <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID> @@ -1417,6 +1429,18 @@ <!--2526D690429D4D0B8CC879B799D9A611--> <ISINCLUDEINI18N><![CDATA[N]]></ISINCLUDEINI18N> <!--2526D690429D4D0B8CC879B799D9A611--></AD_MESSAGE> +<!--25415E46FCB54A64A24C27E38FF9237D--><AD_MESSAGE> +<!--25415E46FCB54A64A24C27E38FF9237D--> <AD_MESSAGE_ID><![CDATA[25415E46FCB54A64A24C27E38FF9237D]]></AD_MESSAGE_ID> +<!--25415E46FCB54A64A24C27E38FF9237D--> <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID> +<!--25415E46FCB54A64A24C27E38FF9237D--> <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID> +<!--25415E46FCB54A64A24C27E38FF9237D--> <ISACTIVE><![CDATA[Y]]></ISACTIVE> +<!--25415E46FCB54A64A24C27E38FF9237D--> <VALUE><![CDATA[OBPOS_ErrorCheckingReceipt]]></VALUE> +<!--25415E46FCB54A64A24C27E38FF9237D--> <MSGTEXT><![CDATA[There was an error while checking the receipt]]></MSGTEXT> +<!--25415E46FCB54A64A24C27E38FF9237D--> <MSGTYPE><![CDATA[E]]></MSGTYPE> +<!--25415E46FCB54A64A24C27E38FF9237D--> <AD_MODULE_ID><![CDATA[FF808181326CC34901326D53DBCF0018]]></AD_MODULE_ID> +<!--25415E46FCB54A64A24C27E38FF9237D--> <ISINCLUDEINI18N><![CDATA[N]]></ISINCLUDEINI18N> +<!--25415E46FCB54A64A24C27E38FF9237D--></AD_MESSAGE> + <!--25866352B24A483F936D4F557C4A940A--><AD_MESSAGE> <!--25866352B24A483F936D4F557C4A940A--> <AD_MESSAGE_ID><![CDATA[25866352B24A483F936D4F557C4A940A]]></AD_MESSAGE_ID> <!--25866352B24A483F936D4F557C4A940A--> <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID> @@ -2642,6 +2666,18 @@ <!--3A9DC2120A7D4F9FB0C3BF24E6A0B901--> <ISINCLUDEINI18N><![CDATA[N]]></ISINCLUDEINI18N> <!--3A9DC2120A7D4F9FB0C3BF24E6A0B901--></AD_MESSAGE> +<!--3AD5E3D255834AC99842DE893DAA395E--><AD_MESSAGE> +<!--3AD5E3D255834AC99842DE893DAA395E--> <AD_MESSAGE_ID><![CDATA[3AD5E3D255834AC99842DE893DAA395E]]></AD_MESSAGE_ID> +<!--3AD5E3D255834AC99842DE893DAA395E--> <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID> +<!--3AD5E3D255834AC99842DE893DAA395E--> <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID> +<!--3AD5E3D255834AC99842DE893DAA395E--> <ISACTIVE><![CDATA[Y]]></ISACTIVE> +<!--3AD5E3D255834AC99842DE893DAA395E--> <VALUE><![CDATA[OBPOS_UpdatedReceipt]]></VALUE> +<!--3AD5E3D255834AC99842DE893DAA395E--> <MSGTEXT><![CDATA[The receipt has already been updated]]></MSGTEXT> +<!--3AD5E3D255834AC99842DE893DAA395E--> <MSGTYPE><![CDATA[E]]></MSGTYPE> +<!--3AD5E3D255834AC99842DE893DAA395E--> <AD_MODULE_ID><![CDATA[FF808181326CC34901326D53DBCF0018]]></AD_MODULE_ID> +<!--3AD5E3D255834AC99842DE893DAA395E--> <ISINCLUDEINI18N><![CDATA[N]]></ISINCLUDEINI18N> +<!--3AD5E3D255834AC99842DE893DAA395E--></AD_MESSAGE> + <!--3AE2C03C27BD457D92FB657A83719419--><AD_MESSAGE> <!--3AE2C03C27BD457D92FB657A83719419--> <AD_MESSAGE_ID><![CDATA[3AE2C03C27BD457D92FB657A83719419]]></AD_MESSAGE_ID> <!--3AE2C03C27BD457D92FB657A83719419--> <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID> @@ -7553,6 +7589,18 @@ Please contact your system administrator.]]></MSGTEXT> <!--A7CBAF28EE6C42A791DF740B61D77D4C--> <ISINCLUDEINI18N><![CDATA[N]]></ISINCLUDEINI18N> <!--A7CBAF28EE6C42A791DF740B61D77D4C--></AD_MESSAGE> +<!--A82BF80461074071BBFEE185294D72DD--><AD_MESSAGE> +<!--A82BF80461074071BBFEE185294D72DD--> <AD_MESSAGE_ID><![CDATA[A82BF80461074071BBFEE185294D72DD]]></AD_MESSAGE_ID> +<!--A82BF80461074071BBFEE185294D72DD--> <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID> +<!--A82BF80461074071BBFEE185294D72DD--> <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID> +<!--A82BF80461074071BBFEE185294D72DD--> <ISACTIVE><![CDATA[Y]]></ISACTIVE> +<!--A82BF80461074071BBFEE185294D72DD--> <VALUE><![CDATA[OBPOS_SyncWithErrors]]></VALUE> +<!--A82BF80461074071BBFEE185294D72DD--> <MSGTEXT><![CDATA[The receipt %0 has been synchronized with errors. It's not possible to synchronize it again until those errors are fixed.]]></MSGTEXT> +<!--A82BF80461074071BBFEE185294D72DD--> <MSGTYPE><![CDATA[E]]></MSGTYPE> +<!--A82BF80461074071BBFEE185294D72DD--> <AD_MODULE_ID><![CDATA[FF808181326CC34901326D53DBCF0018]]></AD_MODULE_ID> +<!--A82BF80461074071BBFEE185294D72DD--> <ISINCLUDEINI18N><![CDATA[N]]></ISINCLUDEINI18N> +<!--A82BF80461074071BBFEE185294D72DD--></AD_MESSAGE> + <!--A847E3FCBDCD4ED98A1FB6671E5A4420--><AD_MESSAGE> <!--A847E3FCBDCD4ED98A1FB6671E5A4420--> <AD_MESSAGE_ID><![CDATA[A847E3FCBDCD4ED98A1FB6671E5A4420]]></AD_MESSAGE_ID> <!--A847E3FCBDCD4ED98A1FB6671E5A4420--> <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID> @@ -9449,6 +9497,18 @@ Please contact your system administrator.]]></MSGTEXT> <!--D2C6A0EFE64C44008B144E99CBA8BD21--> <ISINCLUDEINI18N><![CDATA[N]]></ISINCLUDEINI18N> <!--D2C6A0EFE64C44008B144E99CBA8BD21--></AD_MESSAGE> +<!--D3292AA1625A4FA8A641638024CADDE3--><AD_MESSAGE> +<!--D3292AA1625A4FA8A641638024CADDE3--> <AD_MESSAGE_ID><![CDATA[D3292AA1625A4FA8A641638024CADDE3]]></AD_MESSAGE_ID> +<!--D3292AA1625A4FA8A641638024CADDE3--> <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID> +<!--D3292AA1625A4FA8A641638024CADDE3--> <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID> +<!--D3292AA1625A4FA8A641638024CADDE3--> <ISACTIVE><![CDATA[Y]]></ISACTIVE> +<!--D3292AA1625A4FA8A641638024CADDE3--> <VALUE><![CDATA[OBPOS_NotPossibleToConfirmReceipt]]></VALUE> +<!--D3292AA1625A4FA8A641638024CADDE3--> <MSGTEXT><![CDATA[It has not been possible to confirm the status of the receipt %0. Please, go online before closing it.]]></MSGTEXT> +<!--D3292AA1625A4FA8A641638024CADDE3--> <MSGTYPE><![CDATA[E]]></MSGTYPE> +<!--D3292AA1625A4FA8A641638024CADDE3--> <AD_MODULE_ID><![CDATA[FF808181326CC34901326D53DBCF0018]]></AD_MODULE_ID> +<!--D3292AA1625A4FA8A641638024CADDE3--> <ISINCLUDEINI18N><![CDATA[N]]></ISINCLUDEINI18N> +<!--D3292AA1625A4FA8A641638024CADDE3--></AD_MESSAGE> + <!--D387B80B40A945B89B84255FFAD2076A--><AD_MESSAGE> <!--D387B80B40A945B89B84255FFAD2076A--> <AD_MESSAGE_ID><![CDATA[D387B80B40A945B89B84255FFAD2076A]]></AD_MESSAGE_ID> <!--D387B80B40A945B89B84255FFAD2076A--> <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID> @@ -10158,6 +10218,18 @@ Please contact your system administrator.]]></MSGTEXT> <!--DF0B0C41CE7D490AAE15F6408CE0AF72--> <ISINCLUDEINI18N><![CDATA[N]]></ISINCLUDEINI18N> <!--DF0B0C41CE7D490AAE15F6408CE0AF72--></AD_MESSAGE> +<!--DF0B7FF461C74C2EA78F6B099A51B1F1--><AD_MESSAGE> +<!--DF0B7FF461C74C2EA78F6B099A51B1F1--> <AD_MESSAGE_ID><![CDATA[DF0B7FF461C74C2EA78F6B099A51B1F1]]></AD_MESSAGE_ID> +<!--DF0B7FF461C74C2EA78F6B099A51B1F1--> <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID> +<!--DF0B7FF461C74C2EA78F6B099A51B1F1--> <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID> +<!--DF0B7FF461C74C2EA78F6B099A51B1F1--> <ISACTIVE><![CDATA[Y]]></ISACTIVE> +<!--DF0B7FF461C74C2EA78F6B099A51B1F1--> <VALUE><![CDATA[OBPOS_NotPossibleToConfirmReceiptWarn]]></VALUE> +<!--DF0B7FF461C74C2EA78F6B099A51B1F1--> <MSGTEXT><![CDATA[It has not been possible to confirm the status of the receipt %0. Do you want to continue?]]></MSGTEXT> +<!--DF0B7FF461C74C2EA78F6B099A51B1F1--> <MSGTYPE><![CDATA[W]]></MSGTYPE> +<!--DF0B7FF461C74C2EA78F6B099A51B1F1--> <AD_MODULE_ID><![CDATA[FF808181326CC34901326D53DBCF0018]]></AD_MODULE_ID> +<!--DF0B7FF461C74C2EA78F6B099A51B1F1--> <ISINCLUDEINI18N><![CDATA[N]]></ISINCLUDEINI18N> +<!--DF0B7FF461C74C2EA78F6B099A51B1F1--></AD_MESSAGE> + <!--DFE86ADABCC443AD990A32603747EBBD--><AD_MESSAGE> <!--DFE86ADABCC443AD990A32603747EBBD--> <AD_MESSAGE_ID><![CDATA[DFE86ADABCC443AD990A32603747EBBD]]></AD_MESSAGE_ID> <!--DFE86ADABCC443AD990A32603747EBBD--> <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID> @@ -10614,6 +10686,18 @@ Please contact your system administrator.]]></MSGTEXT> <!--E8A4371A89F448188D846B927D8D839D--> <ISINCLUDEINI18N><![CDATA[N]]></ISINCLUDEINI18N> <!--E8A4371A89F448188D846B927D8D839D--></AD_MESSAGE> +<!--E8AF932893AC449FBF0BEF357E5973B1--><AD_MESSAGE> +<!--E8AF932893AC449FBF0BEF357E5973B1--> <AD_MESSAGE_ID><![CDATA[E8AF932893AC449FBF0BEF357E5973B1]]></AD_MESSAGE_ID> +<!--E8AF932893AC449FBF0BEF357E5973B1--> <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID> +<!--E8AF932893AC449FBF0BEF357E5973B1--> <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID> +<!--E8AF932893AC449FBF0BEF357E5973B1--> <ISACTIVE><![CDATA[Y]]></ISACTIVE> +<!--E8AF932893AC449FBF0BEF357E5973B1--> <VALUE><![CDATA[OBPOS_RemoveAndLoad]]></VALUE> +<!--E8AF932893AC449FBF0BEF357E5973B1--> <MSGTEXT><![CDATA[There is a newer version of the receipt %0 in the server. Please, remove the receipt and load it again if needed.]]></MSGTEXT> +<!--E8AF932893AC449FBF0BEF357E5973B1--> <MSGTYPE><![CDATA[E]]></MSGTYPE> +<!--E8AF932893AC449FBF0BEF357E5973B1--> <AD_MODULE_ID><![CDATA[FF808181326CC34901326D53DBCF0018]]></AD_MODULE_ID> +<!--E8AF932893AC449FBF0BEF357E5973B1--> <ISINCLUDEINI18N><![CDATA[N]]></ISINCLUDEINI18N> +<!--E8AF932893AC449FBF0BEF357E5973B1--></AD_MESSAGE> + <!--E8D0E5B09BB04AD09D73299B63D70C87--><AD_MESSAGE> <!--E8D0E5B09BB04AD09D73299B63D70C87--> <AD_MESSAGE_ID><![CDATA[E8D0E5B09BB04AD09D73299B63D70C87]]></AD_MESSAGE_ID> <!--E8D0E5B09BB04AD09D73299B63D70C87--> <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID> diff --git a/src-db/database/sourcedata/AD_PREFERENCE.xml b/src-db/database/sourcedata/AD_PREFERENCE.xml index d9d5dbd03..d9d3523d0 100644 --- a/src-db/database/sourcedata/AD_PREFERENCE.xml +++ b/src-db/database/sourcedata/AD_PREFERENCE.xml @@ -385,6 +385,17 @@ <!--334C41966CAE4DEDB430C96C466377AB--> <AD_MODULE_ID><![CDATA[FF808181326CC34901326D53DBCF0018]]></AD_MODULE_ID> <!--334C41966CAE4DEDB430C96C466377AB--></AD_PREFERENCE> +<!--33F51ABEE99D46E499A1B4E33BC40FB2--><AD_PREFERENCE> +<!--33F51ABEE99D46E499A1B4E33BC40FB2--> <AD_PREFERENCE_ID><![CDATA[33F51ABEE99D46E499A1B4E33BC40FB2]]></AD_PREFERENCE_ID> +<!--33F51ABEE99D46E499A1B4E33BC40FB2--> <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID> +<!--33F51ABEE99D46E499A1B4E33BC40FB2--> <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID> +<!--33F51ABEE99D46E499A1B4E33BC40FB2--> <ISACTIVE><![CDATA[Y]]></ISACTIVE> +<!--33F51ABEE99D46E499A1B4E33BC40FB2--> <VALUE><![CDATA[N]]></VALUE> +<!--33F51ABEE99D46E499A1B4E33BC40FB2--> <PROPERTY><![CDATA[OBPOS_AllowToSynchronizeLoadedReceiptsOffline]]></PROPERTY> +<!--33F51ABEE99D46E499A1B4E33BC40FB2--> <ISPROPERTYLIST><![CDATA[Y]]></ISPROPERTYLIST> +<!--33F51ABEE99D46E499A1B4E33BC40FB2--> <AD_MODULE_ID><![CDATA[FF808181326CC34901326D53DBCF0018]]></AD_MODULE_ID> +<!--33F51ABEE99D46E499A1B4E33BC40FB2--></AD_PREFERENCE> + <!--349C292127AE47888F6185D1ACEE7991--><AD_PREFERENCE> <!--349C292127AE47888F6185D1ACEE7991--> <AD_PREFERENCE_ID><![CDATA[349C292127AE47888F6185D1ACEE7991]]></AD_PREFERENCE_ID> <!--349C292127AE47888F6185D1ACEE7991--> <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID> diff --git a/src-db/database/sourcedata/AD_REF_LIST.xml b/src-db/database/sourcedata/AD_REF_LIST.xml index 78ca35ba0..8a9485acb 100644 --- a/src-db/database/sourcedata/AD_REF_LIST.xml +++ b/src-db/database/sourcedata/AD_REF_LIST.xml @@ -2575,6 +2575,18 @@ <!--E53EE08A990E4ED99FEB794FF1F4E94C--> <AD_MODULE_ID><![CDATA[FF808181326CC34901326D53DBCF0018]]></AD_MODULE_ID> <!--E53EE08A990E4ED99FEB794FF1F4E94C--></AD_REF_LIST> +<!--E60919FF262B4A5091228A65FF0FD931--><AD_REF_LIST> +<!--E60919FF262B4A5091228A65FF0FD931--> <AD_REF_LIST_ID><![CDATA[E60919FF262B4A5091228A65FF0FD931]]></AD_REF_LIST_ID> +<!--E60919FF262B4A5091228A65FF0FD931--> <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID> +<!--E60919FF262B4A5091228A65FF0FD931--> <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID> +<!--E60919FF262B4A5091228A65FF0FD931--> <ISACTIVE><![CDATA[Y]]></ISACTIVE> +<!--E60919FF262B4A5091228A65FF0FD931--> <VALUE><![CDATA[OBPOS_AllowToSynchronizeLoadedReceiptsOffline]]></VALUE> +<!--E60919FF262B4A5091228A65FF0FD931--> <NAME><![CDATA[Web POS Allow to Synchronize Loaded Receipts Offline]]></NAME> +<!--E60919FF262B4A5091228A65FF0FD931--> <DESCRIPTION><![CDATA[Preference to allow to synchronize receipts in offline without checking if the receipt is updated.]]></DESCRIPTION> +<!--E60919FF262B4A5091228A65FF0FD931--> <AD_REFERENCE_ID><![CDATA[A26BA480E2014707B47257024C3CBFF7]]></AD_REFERENCE_ID> +<!--E60919FF262B4A5091228A65FF0FD931--> <AD_MODULE_ID><![CDATA[FF808181326CC34901326D53DBCF0018]]></AD_MODULE_ID> +<!--E60919FF262B4A5091228A65FF0FD931--></AD_REF_LIST> + <!--E74F58F60D6743A48C52B2B232DD80BE--><AD_REF_LIST> <!--E74F58F60D6743A48C52B2B232DD80BE--> <AD_REF_LIST_ID><![CDATA[E74F58F60D6743A48C52B2B232DD80BE]]></AD_REF_LIST_ID> <!--E74F58F60D6743A48C52B2B232DD80BE--> <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID> diff --git a/src-db/database/sourcedata/OBMOBC_SERVICES.xml b/src-db/database/sourcedata/OBMOBC_SERVICES.xml index 3daa607af..195adda73 100644 --- a/src-db/database/sourcedata/OBMOBC_SERVICES.xml +++ b/src-db/database/sourcedata/OBMOBC_SERVICES.xml @@ -413,6 +413,19 @@ <!--670E3C221CB14D1BBEFCE47270B7F266--> <SERVER_RUNTIME><![CDATA[OBSTSYN_ON_CENTRAL]]></SERVER_RUNTIME> <!--670E3C221CB14D1BBEFCE47270B7F266--></OBMOBC_SERVICES> +<!--697D67A91CAB45E3AE055985607CD952--><OBMOBC_SERVICES> +<!--697D67A91CAB45E3AE055985607CD952--> <OBMOBC_SERVICES_ID><![CDATA[697D67A91CAB45E3AE055985607CD952]]></OBMOBC_SERVICES_ID> +<!--697D67A91CAB45E3AE055985607CD952--> <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID> +<!--697D67A91CAB45E3AE055985607CD952--> <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID> +<!--697D67A91CAB45E3AE055985607CD952--> <AD_MODULE_ID><![CDATA[FF808181326CC34901326D53DBCF0018]]></AD_MODULE_ID> +<!--697D67A91CAB45E3AE055985607CD952--> <ISACTIVE><![CDATA[Y]]></ISACTIVE> +<!--697D67A91CAB45E3AE055985607CD952--> <SERVICE><![CDATA[org.openbravo.retail.posterminal.process.CheckUpdated]]></SERVICE> +<!--697D67A91CAB45E3AE055985607CD952--> <DESCRIPTION><![CDATA[Process to check if a synchronizing order has been modified in the server since the moment the terminal loaded the ticket in the Web POS.]]></DESCRIPTION> +<!--697D67A91CAB45E3AE055985607CD952--> <ROUTINGTYPE><![CDATA[Failover]]></ROUTINGTYPE> +<!--697D67A91CAB45E3AE055985607CD952--> <DEFAULTTIMEOUT><![CDATA[5]]></DEFAULTTIMEOUT> +<!--697D67A91CAB45E3AE055985607CD952--> <SERVER_RUNTIME><![CDATA[OBSTSYN_ON_CENTRAL]]></SERVER_RUNTIME> +<!--697D67A91CAB45E3AE055985607CD952--></OBMOBC_SERVICES> + <!--6AB9803C78B645B8BF647C8D6744125D--><OBMOBC_SERVICES> <!--6AB9803C78B645B8BF647C8D6744125D--> <OBMOBC_SERVICES_ID><![CDATA[6AB9803C78B645B8BF647C8D6744125D]]></OBMOBC_SERVICES_ID> <!--6AB9803C78B645B8BF647C8D6744125D--> <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID> diff --git a/src/org/openbravo/retail/posterminal/PaidReceiptLinesProperties.java b/src/org/openbravo/retail/posterminal/PaidReceiptLinesProperties.java index 042a35de2..64f422e52 100644 --- a/src/org/openbravo/retail/posterminal/PaidReceiptLinesProperties.java +++ b/src/org/openbravo/retail/posterminal/PaidReceiptLinesProperties.java @@ -75,6 +75,7 @@ public class PaidReceiptLinesProperties extends ModelExtension { + "')) ELSE null end FROM OrderLine line where line.id = ordLine.id)", "attributeValue")); add(new HQLProperty("ordLine.salesOrder.id", "orderId")); + add(new HQLProperty("ordLine.updated", "loaded")); } }; diff --git a/src/org/openbravo/retail/posterminal/process/CheckUpdated.java b/src/org/openbravo/retail/posterminal/process/CheckUpdated.java new file mode 100644 index 000000000..d6261b3cd --- /dev/null +++ b/src/org/openbravo/retail/posterminal/process/CheckUpdated.java @@ -0,0 +1,117 @@ +/* + ************************************************************************************ + * Copyright (C) 2022 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. + ************************************************************************************ + */ + +package org.openbravo.retail.posterminal.process; + +import org.codehaus.jettison.json.JSONArray; +import org.codehaus.jettison.json.JSONException; +import org.codehaus.jettison.json.JSONObject; +import org.hibernate.Session; +import org.hibernate.query.Query; +import org.openbravo.dal.core.OBContext; +import org.openbravo.dal.service.OBDal; +import org.openbravo.mobile.core.process.JSONProcessSimple; +import org.openbravo.mobile.core.utils.OBMOBCUtils; +import org.openbravo.model.common.order.Order; +import org.openbravo.model.common.order.OrderLine; +import org.openbravo.service.json.JsonConstants; + +public class CheckUpdated extends JSONProcessSimple { + + private final String PENDING = "P"; + private final String ERROR = "E"; + private final String OUTDATED = "O"; + + @Override + public JSONObject exec(JSONObject jsonData) { + final JSONObject result = new JSONObject(); + + OBContext.setAdminMode(true); + try { + final JSONObject data = new JSONObject(); + final JSONObject jsonOrder = jsonData.getJSONObject("order"); + final Session session = OBDal.getInstance().getSession(); + + if (hasImportEntries(session, jsonOrder.optString("id"))) { + data.put("error", true); + data.put("type", PENDING); + } else if (hasErrosrWhileImporting(session, jsonOrder.optString("id"))) { + data.put("error", true); + data.put("type", ERROR); + } else if (isOrderOutdated(jsonOrder)) { + data.put("error", true); + data.put("type", OUTDATED); + } + + result.put(JsonConstants.RESPONSE_DATA, data); + result.put(JsonConstants.RESPONSE_STATUS, JsonConstants.RPCREQUEST_STATUS_SUCCESS); + + } catch (JSONException e) { + } finally { + OBContext.restorePreviousMode(); + } + return result; + } + + private boolean hasImportEntries(final Session session, final String orderId) { + final String whereClause = "%\"id\":\"" + orderId + "\"%"; + final String importEntryHQL = "" // + + "SELECT id " // + + "FROM C_IMPORT_ENTRY " // + + "WHERE importStatus = 'Initial' " // + + "AND (typeofdata = 'Order' OR typeofdata = 'OBPOS_CancelLayaway' OR typeofdata = 'OBPOS_VoidLayaway') " // + + "AND jsonInfo LIKE :orderId"; + final Query<String> importEntryQuery = session.createQuery(importEntryHQL, String.class); + importEntryQuery.setParameter("orderId", whereClause); + importEntryQuery.setMaxResults(1); + return importEntryQuery.uniqueResult() != null; + } + + private boolean hasErrosrWhileImporting(final Session session, final String orderId) { + final String whereClause = "%\"id\":\"" + orderId + "\"%"; + final String errorWhileImportingHQL = "" // + + "SELECT id " // + + "FROM OBPOS_Errors " // + + "WHERE orderstatus = 'N' " // + + "AND (typeofdata = 'Order' OR typeofdata = 'OBPOS_CancelLayaway' OR typeofdata = 'OBPOS_VoidLayaway') " // + + "AND jsonInfo LIKE :orderId"; + final Query<String> errorWhileImportingQuery = session.createQuery(errorWhileImportingHQL, + String.class); + errorWhileImportingQuery.setParameter("orderId", whereClause); + errorWhileImportingQuery.setMaxResults(1); + return errorWhileImportingQuery.uniqueResult() != null; + } + + private boolean isOrderOutdated(final JSONObject jsonOrder) throws JSONException { + final Order order = OBDal.getInstance().get(Order.class, jsonOrder.optString("id")); + String loaded = jsonOrder.optString("loaded", null), + updated = OBMOBCUtils.convertToUTCDateComingFromServer(order.getUpdated()); + if (loaded == null || loaded.compareTo(updated) != 0) { + return true; + } else { + final JSONArray jsonOrderlines = jsonOrder.optJSONArray("lines"); + if (jsonOrderlines != null) { + for (int i = 0; i < jsonOrderlines.length(); i++) { + final JSONObject jsonOrderLine = jsonOrderlines.getJSONObject(i); + final OrderLine orderLine = OBDal.getInstance() + .get(OrderLine.class, jsonOrderLine.optString("id")); + if (orderLine != null) { + loaded = jsonOrderLine.optString("loaded"); + updated = OBMOBCUtils.convertToUTCDateComingFromServer(orderLine.getUpdated()); + if (loaded == null || loaded.compareTo(updated) != 0) { + return true; + } + } + } + } + } + return false; + } + +} diff --git a/web/org.openbravo.retail.posterminal/js/data/dataordersave.js b/web/org.openbravo.retail.posterminal/js/data/dataordersave.js index 5fdd29297..52535232b 100644 --- a/web/org.openbravo.retail.posterminal/js/data/dataordersave.js +++ b/web/org.openbravo.retail.posterminal/js/data/dataordersave.js @@ -151,236 +151,244 @@ receipt: model.get('order') }, function (args) { var receipt = args.context.receipt; + var handleError = function () { + args.context.receipt.set('isbeingprocessed', 'N'); + args.context.receipt.set('hasbeenpaid', 'N'); + args.context.receipt.trigger('paymentCancel'); + if (eventParams && eventParams.callback) { + eventParams.callback({ + frozenReceipt: receipt, + isCancelled: true, + skipCallback: args.skipCallback + }); + } + args.context.receipt.setIsCalculateReceiptLockState(false); + args.context.receipt.setIsCalculateGrossLockState(false); + return true; + }; + if (args && args.cancellation && args.cancellation === true) { - args.context.receipt.set('isbeingprocessed', 'N'); - args.context.receipt.set('hasbeenpaid', 'N'); - args.context.receipt.trigger('paymentCancel'); - if (eventParams && eventParams.callback) { - eventParams.callback({ - frozenReceipt: receipt, - isCancelled: true, - skipCallback: args.skipCallback - }); - } - args.context.receipt.setIsCalculateReceiptLockState(false); - args.context.receipt.setIsCalculateGrossLockState(false); + handleError(); return true; } - OB.UTIL.clone(receipt, frozenReceipt); - - OB.UTIL.TicketCloseUtils.processChangePayments(frozenReceipt, function () { - receipt.trigger('checkOpenDrawer'); - - if (OB.UTIL.RfidController.isRfidConfigured()) { - OB.UTIL.RfidController.processRemainingCodes(frozenReceipt); - OB.UTIL.RfidController.updateEpcBuffers(); - } - OB.trace('Execution of pre order save hook OK.'); - delete frozenReceipt.attributes.json; - frozenReceipt.set('creationDate', normalizedCreationDate); - frozenReceipt.set('timezoneOffset', creationDate.getTimezoneOffset()); - frozenReceipt.set('created', creationDate.getTime()); - frozenReceipt.set('obposCreatedabsolute', OB.I18N.formatDateISO(creationDate)); - frozenReceipt.set('orderDate', orderDate); - frozenReceipt.set('movementDate', OB.I18N.normalizeDate(new Date())); - frozenReceipt.set('accountingDate', OB.I18N.normalizeDate(new Date())); - frozenReceipt.set('undo', null); - frozenReceipt.set('multipleUndo', null); - - // Set the quantities to deliver - frozenReceipt.setQuantitiesToDeliver(); - - frozenReceipt.set('paymentMethodKind', null); - if (frozenReceipt.get('payments').length === 1 && frozenReceipt.get('completeTicket') && frozenReceipt.isFullyPaid()) { - var payment = frozenReceipt.get('payments').models[0]; - frozenReceipt.set('paymentMethodKind', payment.get('kind')); - } + OB.UTIL.TicketCloseUtils.checkOrdersUpdated(receipt.get('doCancelAndReplace') ? receipt.get('canceledorder') : receipt, function () { + OB.UTIL.clone(receipt, frozenReceipt); - // multiterminal support - // be sure that the active terminal is the one set as the order proprietary - frozenReceipt.set('posTerminal', OB.MobileApp.model.get('terminal').id); - frozenReceipt.set('posTerminal' + OB.Constants.FIELDSEPARATOR + OB.Constants.IDENTIFIER, OB.MobileApp.model.get('terminal')._identifier); + OB.UTIL.TicketCloseUtils.processChangePayments(frozenReceipt, function () { + receipt.trigger('checkOpenDrawer'); - frozenReceipt.get('approvals').forEach(function (approval) { - if (typeof (approval.approvalType) === 'object') { - approval.approvalMessage = OB.I18N.getLabel(approval.approvalType.message, approval.approvalType.params); - approval.approvalType = approval.approvalType.approval; + if (OB.UTIL.RfidController.isRfidConfigured()) { + OB.UTIL.RfidController.processRemainingCodes(frozenReceipt); + OB.UTIL.RfidController.updateEpcBuffers(); } - }); - frozenReceipt.set('obposAppCashup', OB.MobileApp.model.get('terminal').cashUpId); - // convert returns - if (receipt.isNegative()) { - _.forEach(frozenReceipt.get('payments').models, function (item) { - if (!item.get('isPrePayment') && !item.get('reversedPaymentId') && !frozenReceipt.get('isPaid')) { - item.set('amount', -item.get('amount')); - if (item.get('amountRounded')) { - item.set('amountRounded', -item.get('amountRounded')); - } - item.set('origAmount', -item.get('origAmount')); - if (item.get('origAmountRounded')) { - item.set('origAmountRounded', -item.get('origAmountRounded')); - } - item.set('paid', -item.get('paid')); - } else { - item.set('paid', item.get('amount')); - } - }); - } - - var successCallback = function () { + OB.trace('Execution of pre order save hook OK.'); + delete frozenReceipt.attributes.json; + frozenReceipt.set('creationDate', normalizedCreationDate); + frozenReceipt.set('timezoneOffset', creationDate.getTimezoneOffset()); + frozenReceipt.set('created', creationDate.getTime()); + frozenReceipt.set('obposCreatedabsolute', OB.I18N.formatDateISO(creationDate)); + frozenReceipt.set('orderDate', orderDate); + frozenReceipt.set('movementDate', OB.I18N.normalizeDate(new Date())); + frozenReceipt.set('accountingDate', OB.I18N.normalizeDate(new Date())); + frozenReceipt.set('undo', null); + frozenReceipt.set('multipleUndo', null); + + // Set the quantities to deliver + frozenReceipt.setQuantitiesToDeliver(); + + frozenReceipt.set('paymentMethodKind', null); + if (frozenReceipt.get('payments').length === 1 && frozenReceipt.get('completeTicket') && frozenReceipt.isFullyPaid()) { + var payment = frozenReceipt.get('payments').models[0]; + frozenReceipt.set('paymentMethodKind', payment.get('kind')); + } - var syncSuccessCallback, syncErrorCallback, closeParamCallback, restoreReceiptCallback, serverMessageForQuotation, receiptForPostSyncReceipt; - // success transaction... - OB.info("[receipt.closed] Transaction success. ReceiptId: " + frozenReceipt.get('id')); - OB.info('Ticket closed: ', frozenReceipt.get('json').replace(/logclientErrors/g, "logErrors"), "caller: " + OB.UTIL.getStackTrace('Backbone.Events.trigger', true)); + // multiterminal support + // be sure that the active terminal is the one set as the order proprietary + frozenReceipt.set('posTerminal', OB.MobileApp.model.get('terminal').id); + frozenReceipt.set('posTerminal' + OB.Constants.FIELDSEPARATOR + OB.Constants.IDENTIFIER, OB.MobileApp.model.get('terminal')._identifier); - // create a clone of the receipt to be used when executing the final callback - receipt.clearWith(frozenReceipt); - OB.UTIL.clone(receipt, diffReceipt); - if (OB.UTIL.HookManager.get('OBPOS_PostSyncReceipt')) { - receiptForPostSyncReceipt = new OB.Model.Order(); - OB.UTIL.clone(frozenReceipt, receiptForPostSyncReceipt); + frozenReceipt.get('approvals').forEach(function (approval) { + if (typeof (approval.approvalType) === 'object') { + approval.approvalMessage = OB.I18N.getLabel(approval.approvalType.message, approval.approvalType.params); + approval.approvalType = approval.approvalType.approval; } + }); - serverMessageForQuotation = function (frozenReceipt) { - var isLayaway = (frozenReceipt.get('orderType') === 2 || frozenReceipt.get('isLayaway')); - var currentDocNo = frozenReceipt.get('documentNo'); - if (frozenReceipt && frozenReceipt.get('isQuotation')) { - OB.UTIL.showSuccess(OB.I18N.getLabel('OBPOS_QuotationSaved', [currentDocNo])); - } else { - if (isLayaway) { - OB.UTIL.showSuccess(OB.I18N.getLabel('OBPOS_MsgLayawaySaved', [currentDocNo])); - } else { - OB.UTIL.showSuccess(OB.I18N.getLabel('OBPOS_MsgReceiptSaved', [currentDocNo])); + frozenReceipt.set('obposAppCashup', OB.MobileApp.model.get('terminal').cashUpId); + // convert returns + if (receipt.isNegative()) { + _.forEach(frozenReceipt.get('payments').models, function (item) { + if (!item.get('isPrePayment') && !item.get('reversedPaymentId') && !frozenReceipt.get('isPaid')) { + item.set('amount', -item.get('amount')); + if (item.get('amountRounded')) { + item.set('amountRounded', -item.get('amountRounded')); } - } - OB.trace('Order successfully removed.'); - }; - - closeParamCallback = function () { - if (eventParams && eventParams.callback) { - eventParams.callback({ - frozenReceipt: frozenReceipt, - diffReceipt: diffReceipt, - isCancelled: false - }); - } - }; - - syncSuccessCallback = function (callback, eventParams) { - if (OB.UTIL.HookManager.get('OBPOS_PostSyncReceipt') && (!eventParams || (eventParams && !eventParams.ignoreSyncProcess))) { - OB.UTIL.HookManager.executeHooks('OBPOS_PostSyncReceipt', { - receipt: receiptForPostSyncReceipt, - syncSuccess: true - }, function () { - callback(); - }); + item.set('origAmount', -item.get('origAmount')); + if (item.get('origAmountRounded')) { + item.set('origAmountRounded', -item.get('origAmountRounded')); + } + item.set('paid', -item.get('paid')); } else { - callback(); + item.set('paid', item.get('amount')); } - }; + }); + } + + var successCallback = function () { - restoreReceiptCallback = function () { - restoreReceiptOnError(eventParams, receipt); - }; + var syncSuccessCallback, syncErrorCallback, closeParamCallback, restoreReceiptCallback, serverMessageForQuotation, receiptForPostSyncReceipt; + // success transaction... + OB.info("[receipt.closed] Transaction success. ReceiptId: " + frozenReceipt.get('id')); + OB.info('Ticket closed: ', frozenReceipt.get('json').replace(/logclientErrors/g, "logErrors"), "caller: " + OB.UTIL.getStackTrace('Backbone.Events.trigger', true)); - syncErrorCallback = function () { + // create a clone of the receipt to be used when executing the final callback + receipt.clearWith(frozenReceipt); + OB.UTIL.clone(receipt, diffReceipt); if (OB.UTIL.HookManager.get('OBPOS_PostSyncReceipt')) { - OB.UTIL.HookManager.executeHooks('OBPOS_PostSyncReceipt', { - receipt: receiptForPostSyncReceipt, - syncSuccess: false - }, restoreReceiptCallback); - } else { - restoreReceiptCallback(); + receiptForPostSyncReceipt = new OB.Model.Order(); + OB.UTIL.clone(frozenReceipt, receiptForPostSyncReceipt); } - }; - if (!OB.MobileApp.model.hasPermission('OBMOBC_SynchronizedMode', true)) { - // the trigger is fired on the receipt object, as there is only 1 that is being updated - receipt.trigger('integrityOk', frozenReceipt); // Is important for module print last receipt. This module listen trigger. - closeParamCallback(); - } + serverMessageForQuotation = function (frozenReceipt) { + var isLayaway = (frozenReceipt.get('orderType') === 2 || frozenReceipt.get('isLayaway')); + var currentDocNo = frozenReceipt.get('documentNo'); + if (frozenReceipt && frozenReceipt.get('isQuotation')) { + OB.UTIL.showSuccess(OB.I18N.getLabel('OBPOS_QuotationSaved', [currentDocNo])); + } else { + if (isLayaway) { + OB.UTIL.showSuccess(OB.I18N.getLabel('OBPOS_MsgLayawaySaved', [currentDocNo])); + } else { + OB.UTIL.showSuccess(OB.I18N.getLabel('OBPOS_MsgReceiptSaved', [currentDocNo])); + } + } + OB.trace('Order successfully removed.'); + }; + + closeParamCallback = function () { + if (eventParams && eventParams.callback) { + eventParams.callback({ + frozenReceipt: frozenReceipt, + diffReceipt: diffReceipt, + isCancelled: false + }); + } + }; + + syncSuccessCallback = function (callback, eventParams) { + if (OB.UTIL.HookManager.get('OBPOS_PostSyncReceipt') && (!eventParams || (eventParams && !eventParams.ignoreSyncProcess))) { + OB.UTIL.HookManager.executeHooks('OBPOS_PostSyncReceipt', { + receipt: receiptForPostSyncReceipt, + syncSuccess: true + }, function () { + callback(); + }); + } else { + callback(); + } + }; + + restoreReceiptCallback = function () { + restoreReceiptOnError(eventParams, receipt); + }; + + syncErrorCallback = function () { + if (OB.UTIL.HookManager.get('OBPOS_PostSyncReceipt')) { + OB.UTIL.HookManager.executeHooks('OBPOS_PostSyncReceipt', { + receipt: receiptForPostSyncReceipt, + syncSuccess: false + }, restoreReceiptCallback); + } else { + restoreReceiptCallback(); + } + }; - OB.trace('Execution Sync process.'); - OB.MobileApp.model.runSyncProcess(function () { - // in synchronized mode do the doc sequence update in the success - if (OB.MobileApp.model.hasPermission('OBMOBC_SynchronizedMode', true)) { - OB.Dal.transaction(function (tx) { - OB.UTIL.calculateCurrentCash(null, tx); - OB.MobileApp.model.updateDocumentSequenceWhenOrderSaved(frozenReceipt.get('documentnoSuffix'), frozenReceipt.get('quotationnoSuffix'), frozenReceipt.get('returnnoSuffix'), function () { - // the trigger is fired on the receipt object, as there is only 1 that is being updated - receipt.trigger('integrityOk', frozenReceipt); // Is important for module print last receipt. This module listen trigger. - syncSuccessCallback(function () { - serverMessageForQuotation(frozenReceipt); - closeParamCallback(); - }, eventParams); - }, tx); - }); - } else { - syncSuccessCallback(function () { - serverMessageForQuotation(frozenReceipt); - }, eventParams); + if (!OB.MobileApp.model.hasPermission('OBMOBC_SynchronizedMode', true)) { + // the trigger is fired on the receipt object, as there is only 1 that is being updated + receipt.trigger('integrityOk', frozenReceipt); // Is important for module print last receipt. This module listen trigger. + closeParamCallback(); } - OB.debug("Ticket closed: runSyncProcess executed"); - }, function () { - syncErrorCallback(); - }); - }; - - var executePreSyncReceipt = function (tx) { - OB.UTIL.HookManager.executeHooks('OBPOS_PreSyncReceipt', { - receipt: frozenReceipt, - model: model, - tx: tx - }, function (args) { - frozenReceipt.set('json', JSON.stringify(frozenReceipt.serializeToJSON())); - frozenReceipt.set('hasbeenpaid', 'Y'); - // Important: at this point, the frozenReceipt is considered final. Nothing must alter it - // when all the properties of the frozenReceipt have been set, keep a copy - OB.UTIL.clone(receipt, diffReceipt); - OB.Dal.saveInTransaction(tx, frozenReceipt, function () { - successCallback(); - }); - }); - }; - //Create the invoice - frozenReceipt.generateInvoice(function (invoice) { - if (invoice) { - frozenReceipt.set('calculatedInvoice', invoice); - } - OB.info("[receipt.closed] Starting transaction. ReceiptId: " + frozenReceipt.get('id')); - OB.Dal.transaction(function (tx) { - OB.trace('Calculationg cashup information.'); - OB.UTIL.cashUpReport(frozenReceipt, function (cashUp) { - frozenReceipt.set('cashUpReportInformation', JSON.parse(cashUp.models[0].get('objToSend'))); - frozenReceipt.set('json', JSON.stringify(frozenReceipt.serializeToJSON())); - OB.UTIL.setScanningFocus(true); - if (OB.MobileApp.model.hasPermission('OBMOBC_SynchronizedMode', true)) { + OB.trace('Execution Sync process.'); + OB.MobileApp.model.runSyncProcess(function () { + // in synchronized mode do the doc sequence update in the success + if (OB.MobileApp.model.hasPermission('OBMOBC_SynchronizedMode', true)) { + OB.Dal.transaction(function (tx) { + OB.UTIL.calculateCurrentCash(null, tx); + OB.MobileApp.model.updateDocumentSequenceWhenOrderSaved(frozenReceipt.get('documentnoSuffix'), frozenReceipt.get('quotationnoSuffix'), frozenReceipt.get('returnnoSuffix'), function () { + // the trigger is fired on the receipt object, as there is only 1 that is being updated + receipt.trigger('integrityOk', frozenReceipt); // Is important for module print last receipt. This module listen trigger. + syncSuccessCallback(function () { + serverMessageForQuotation(frozenReceipt); + closeParamCallback(); + }, eventParams); + }, tx); + }); + } else { + syncSuccessCallback(function () { + serverMessageForQuotation(frozenReceipt); + }, eventParams); + } + OB.debug("Ticket closed: runSyncProcess executed"); + }, function () { + syncErrorCallback(); + }); + }; + + var executePreSyncReceipt = function (tx) { + OB.UTIL.HookManager.executeHooks('OBPOS_PreSyncReceipt', { + receipt: frozenReceipt, + model: model, + tx: tx + }, function (args) { + frozenReceipt.set('json', JSON.stringify(frozenReceipt.serializeToJSON())); + frozenReceipt.set('hasbeenpaid', 'Y'); + // Important: at this point, the frozenReceipt is considered final. Nothing must alter it + // when all the properties of the frozenReceipt have been set, keep a copy + OB.UTIL.clone(receipt, diffReceipt); OB.Dal.saveInTransaction(tx, frozenReceipt, function () { - executePreSyncReceipt(tx); + successCallback(); }); - } else { - OB.UTIL.calculateCurrentCash(null, tx); - OB.MobileApp.model.updateDocumentSequenceWhenOrderSaved(frozenReceipt.get('documentnoSuffix'), frozenReceipt.get('quotationnoSuffix'), frozenReceipt.get('returnnoSuffix'), function () { - OB.trace('Saving receipt.'); + }); + }; + + //Create the invoice + frozenReceipt.generateInvoice(function (invoice) { + if (invoice) { + frozenReceipt.set('calculatedInvoice', invoice); + } + OB.info("[receipt.closed] Starting transaction. ReceiptId: " + frozenReceipt.get('id')); + OB.Dal.transaction(function (tx) { + OB.trace('Calculationg cashup information.'); + OB.UTIL.cashUpReport(frozenReceipt, function (cashUp) { + frozenReceipt.set('cashUpReportInformation', JSON.parse(cashUp.models[0].get('objToSend'))); + frozenReceipt.set('json', JSON.stringify(frozenReceipt.serializeToJSON())); + OB.UTIL.setScanningFocus(true); + if (OB.MobileApp.model.hasPermission('OBMOBC_SynchronizedMode', true)) { OB.Dal.saveInTransaction(tx, frozenReceipt, function () { executePreSyncReceipt(tx); }); - }, tx); - } - }, tx); - }, function () { - // the transaction failed - OB.UTIL.showError("[receipt.closed] The transaction failed to be commited. ReceiptId: " + receipt.get('id')); - // rollback other changes - receipt.set('hasbeenpaid', 'N'); - frozenReceipt.set('hasbeenpaid', 'N'); - }, null); + } else { + OB.UTIL.calculateCurrentCash(null, tx); + OB.MobileApp.model.updateDocumentSequenceWhenOrderSaved(frozenReceipt.get('documentnoSuffix'), frozenReceipt.get('quotationnoSuffix'), frozenReceipt.get('returnnoSuffix'), function () { + OB.trace('Saving receipt.'); + OB.Dal.saveInTransaction(tx, frozenReceipt, function () { + executePreSyncReceipt(tx); + }); + }, tx); + } + }, tx); + }, function () { + // the transaction failed + OB.UTIL.showError("[receipt.closed] The transaction failed to be commited. ReceiptId: " + receipt.get('id')); + // rollback other changes + receipt.set('hasbeenpaid', 'N'); + frozenReceipt.set('hasbeenpaid', 'N'); + }, null); + }); }); - }); + }, handleError); }); }; @@ -582,77 +590,84 @@ receipt: receipt }, function (args) { OB.trace('Execution of pre order save hook OK.'); + var handleError = function () { + restoreMultiOrderOnError(function () { + if (closedCallback instanceof Function) { + closedCallback(false); + } + }); + }; + if (args && args.cancellation && args.cancellation === true) { - restoreMultiOrderOnError(function () { - if (closedCallback instanceof Function) { - closedCallback(false); - } - }); + handleError(); return true; } - OB.UTIL.TicketCloseUtils.processChangePayments(args.receipt, function () { - var currentReceipt = args.receipt; - currentReceipt.prepareToSend(function () { - if (currentReceipt.get('orderType') !== 2 && currentReceipt.get('orderType') !== 3) { - var negativeLines = _.filter(currentReceipt.get('lines').models, function (line) { - return line.get('qty') < 0; - }).length; - if (negativeLines === currentReceipt.get('lines').models.length || (negativeLines > 0 && OB.MobileApp.model.get('permissions').OBPOS_SalesWithOneLineNegativeAsReturns)) { - currentReceipt.setOrderType('OBPOS_receipt.return', OB.DEC.One, { - applyPromotions: false, - saveOrder: false - }); - } else { - currentReceipt.setOrderType('', OB.DEC.Zero, { - applyPromotions: false, - saveOrder: false - }); - } - } - currentReceipt.set('orderDate', new Date()); - var creationDate, normalizedCreationDate = OB.I18N.normalizeDate(currentReceipt.get('creationDate')); - if (normalizedCreationDate === null) { - creationDate = new Date(); - normalizedCreationDate = OB.I18N.normalizeDate(creationDate); - } else { - creationDate = new Date(normalizedCreationDate); - } - currentReceipt.set('creationDate', normalizedCreationDate); - currentReceipt.set('movementDate', OB.I18N.normalizeDate(new Date())); - currentReceipt.set('accountingDate', OB.I18N.normalizeDate(new Date())); - - delete currentReceipt.attributes.json; - currentReceipt.set('timezoneOffset', creationDate.getTimezoneOffset()); - currentReceipt.set('created', creationDate.getTime()); - currentReceipt.set('obposCreatedabsolute', OB.I18N.formatDateISO(creationDate)); // Absolute date in ISO format - currentReceipt.set('obposAppCashup', OB.MobileApp.model.get('terminal').cashUpId); - if (OB.UTIL.isNullOrUndefined(currentReceipt.get('amountToLayaway'))) { - currentReceipt.set('completeTicket', true); - } - // multiterminal support - // be sure that the active terminal is the one set as the order proprietary - currentReceipt.set('posTerminal', OB.MobileApp.model.get('terminal').id); - currentReceipt.set('posTerminal' + OB.Constants.FIELDSEPARATOR + OB.Constants.IDENTIFIER, OB.MobileApp.model.get('terminal')._identifier); - - // Set the quantities to deliver - currentReceipt.setQuantitiesToDeliver(); - - currentReceipt.get('approvals').forEach(function (approval) { - if (typeof (approval.approvalType) === 'object') { - approval.approvalMessage = OB.I18N.getLabel(approval.approvalType.message, approval.approvalType.params); - approval.approvalType = approval.approvalType.approval; + OB.UTIL.TicketCloseUtils.checkOrdersUpdated(args.receipt, function () { + OB.UTIL.TicketCloseUtils.processChangePayments(args.receipt, function () { + var currentReceipt = args.receipt; + currentReceipt.prepareToSend(function () { + if (currentReceipt.get('orderType') !== 2 && currentReceipt.get('orderType') !== 3) { + var negativeLines = _.filter(currentReceipt.get('lines').models, function (line) { + return line.get('qty') < 0; + }).length; + if (negativeLines === currentReceipt.get('lines').models.length || (negativeLines > 0 && OB.MobileApp.model.get('permissions').OBPOS_SalesWithOneLineNegativeAsReturns)) { + currentReceipt.setOrderType('OBPOS_receipt.return', OB.DEC.One, { + applyPromotions: false, + saveOrder: false + }); + } else { + currentReceipt.setOrderType('', OB.DEC.Zero, { + applyPromotions: false, + saveOrder: false + }); + } } - }); + currentReceipt.set('orderDate', new Date()); - currentReceipt.generateInvoice(function (invoice) { - if (invoice) { - currentReceipt.set('calculatedInvoice', invoice); + var creationDate, normalizedCreationDate = OB.I18N.normalizeDate(currentReceipt.get('creationDate')); + if (normalizedCreationDate === null) { + creationDate = new Date(); + normalizedCreationDate = OB.I18N.normalizeDate(creationDate); + } else { + creationDate = new Date(normalizedCreationDate); } - completeMultiOrder(); + currentReceipt.set('creationDate', normalizedCreationDate); + currentReceipt.set('movementDate', OB.I18N.normalizeDate(new Date())); + currentReceipt.set('accountingDate', OB.I18N.normalizeDate(new Date())); + + delete currentReceipt.attributes.json; + currentReceipt.set('timezoneOffset', creationDate.getTimezoneOffset()); + currentReceipt.set('created', creationDate.getTime()); + currentReceipt.set('obposCreatedabsolute', OB.I18N.formatDateISO(creationDate)); // Absolute date in ISO format + currentReceipt.set('obposAppCashup', OB.MobileApp.model.get('terminal').cashUpId); + if (OB.UTIL.isNullOrUndefined(currentReceipt.get('amountToLayaway'))) { + currentReceipt.set('completeTicket', true); + } + // multiterminal support + // be sure that the active terminal is the one set as the order proprietary + currentReceipt.set('posTerminal', OB.MobileApp.model.get('terminal').id); + currentReceipt.set('posTerminal' + OB.Constants.FIELDSEPARATOR + OB.Constants.IDENTIFIER, OB.MobileApp.model.get('terminal')._identifier); + + // Set the quantities to deliver + currentReceipt.setQuantitiesToDeliver(); + + currentReceipt.get('approvals').forEach(function (approval) { + if (typeof (approval.approvalType) === 'object') { + approval.approvalMessage = OB.I18N.getLabel(approval.approvalType.message, approval.approvalType.params); + approval.approvalType = approval.approvalType.approval; + } + }); + + currentReceipt.generateInvoice(function (invoice) { + if (invoice) { + currentReceipt.set('calculatedInvoice', invoice); + } + completeMultiOrder(); + }); }); }); - }); + }, handleError); }); }); }; 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 index c16334327..d96436b04 100644 --- a/web/org.openbravo.retail.posterminal/js/pointofsale/model/pointofsale-model.js +++ b/web/org.openbravo.retail.posterminal/js/pointofsale/model/pointofsale-model.js @@ -722,58 +722,60 @@ OB.OBPOSPointOfSale.Model.PointOfSale = OB.Model.TerminalWindowModel.extend({ } function updateCashup() { - auxReceipt.set('timezoneOffset', new Date().getTimezoneOffset()); - auxReceipt.set('gross', OB.DEC.Zero); - auxReceipt.set('isVoided', true); - auxReceipt.set('orderType', 3); - auxReceipt.prepareToSend(function () { - OB.Dal.transaction(function (tx) { - OB.UTIL.cashUpReport(auxReceipt, function (cashUp) { - auxReceipt.set('cashUpReportInformation', JSON.parse(cashUp.models[0].get('objToSend'))); - OB.UTIL.HookManager.executeHooks('OBPOS_PreSyncReceipt', { - receipt: receipt, - model: me, - tx: tx - }, function (args) { - auxReceipt.set('json', JSON.stringify(receipt.serializeToJSON())); - process.exec({ - messageId: OB.UTIL.get_UUID(), - data: [{ - id: auxReceipt.get('id'), - order: auxReceipt - }] - }, function (data) { - if (data && data.exception) { + OB.UTIL.TicketCloseUtils.checkOrdersUpdated(auxReceipt, function () { + auxReceipt.set('timezoneOffset', new Date().getTimezoneOffset()); + auxReceipt.set('gross', OB.DEC.Zero); + auxReceipt.set('isVoided', true); + auxReceipt.set('orderType', 3); + auxReceipt.prepareToSend(function () { + OB.Dal.transaction(function (tx) { + OB.UTIL.cashUpReport(auxReceipt, function (cashUp) { + auxReceipt.set('cashUpReportInformation', JSON.parse(cashUp.models[0].get('objToSend'))); + OB.UTIL.HookManager.executeHooks('OBPOS_PreSyncReceipt', { + receipt: receipt, + model: me, + tx: tx + }, function (args) { + auxReceipt.set('json', JSON.stringify(receipt.serializeToJSON())); + process.exec({ + messageId: OB.UTIL.get_UUID(), + data: [{ + id: auxReceipt.get('id'), + order: auxReceipt + }] + }, function (data) { + if (data && data.exception) { + revertCashupReport(function () { + if (data.exception.message) { + OB.UTIL.showConfirmation.display(OB.I18N.getLabel('OBMOBC_Error'), data.exception.message); + } else { + OB.UTIL.showError(OB.I18N.getLabel('OBPOS_MsgErrorVoidLayaway')); + } + finishVoidLayaway(); + }); + } else { + auxReceipt.trigger(OB.MobileApp.model.get('terminal').defaultwebpostab); + OB.Dal.remove(receipt, null, function (tx, err) { + OB.UTIL.showError(err); + }); + OB.UTIL.clone(auxReceipt, receiptForPrinting); + auxReceipt.trigger('print', receiptForPrinting); + orderList.deleteCurrent(); + receipt.trigger('change:gross', receipt); + OB.UTIL.showSuccess(OB.I18N.getLabel('OBPOS_MsgSuccessVoidLayaway')); + finishVoidLayaway(); + } + }, function () { revertCashupReport(function () { - if (data.exception.message) { - OB.UTIL.showConfirmation.display(OB.I18N.getLabel('OBMOBC_Error'), data.exception.message); - } else { - OB.UTIL.showError(OB.I18N.getLabel('OBPOS_MsgErrorVoidLayaway')); - } + OB.UTIL.showError(OB.I18N.getLabel('OBPOS_OfflineWindowRequiresOnline')); finishVoidLayaway(); }); - } else { - auxReceipt.trigger(OB.MobileApp.model.get('terminal').defaultwebpostab); - OB.Dal.remove(receipt, null, function (tx, err) { - OB.UTIL.showError(err); - }); - OB.UTIL.clone(auxReceipt, receiptForPrinting); - auxReceipt.trigger('print', receiptForPrinting); - orderList.deleteCurrent(); - receipt.trigger('change:gross', receipt); - OB.UTIL.showSuccess(OB.I18N.getLabel('OBPOS_MsgSuccessVoidLayaway')); - finishVoidLayaway(); - } - }, function () { - revertCashupReport(function () { - OB.UTIL.showError(OB.I18N.getLabel('OBPOS_OfflineWindowRequiresOnline')); - finishVoidLayaway(); }); - }); + }, tx); }, tx); - }, tx); + }); }); - }); + }, finishVoidLayaway); } enyo.$.scrim.show(); @@ -799,174 +801,178 @@ OB.OBPOSPointOfSale.Model.PointOfSale = OB.Model.TerminalWindowModel.extend({ var cloneOrderForNew = new OB.Model.Order(); var cloneOrderForPrinting = new OB.Model.Order(); - receipt.prepareToSend(function () { - OB.UTIL.HookManager.executeHooks('OBPOS_FinishCancelLayaway', { - context: me, - model: me, - receipt: receipt - }, function (args) { - OB.UTIL.HookManager.executeHooks('OBPOS_PreSyncReceipt', { - receipt: receipt, - model: me + OB.UTIL.TicketCloseUtils.checkOrdersUpdated(receipt.get('canceledorder'), function () { + receipt.prepareToSend(function () { + OB.UTIL.HookManager.executeHooks('OBPOS_FinishCancelLayaway', { + context: me, + model: me, + receipt: receipt }, function (args) { - OB.Dal.transaction(function (tx) { - if (receipt.isNegative()) { - receipt.get('payments').forEach(function (payment) { - payment.set('amount', OB.DEC.mul(payment.get('amount'), -1)); - payment.set('origAmount', OB.DEC.mul(payment.get('origAmount'), -1)); - payment.set('paid', OB.DEC.mul(payment.get('paid'), -1)); - }); - } - OB.UTIL.cashUpReport(receipt, function (cashUp) { - var cancelLayawayModel = new OB.Model.CancelLayaway(), - cancelLayawayObj; + OB.UTIL.HookManager.executeHooks('OBPOS_PreSyncReceipt', { + receipt: receipt, + model: me + }, function (args) { + OB.Dal.transaction(function (tx) { + if (receipt.isNegative()) { + receipt.get('payments').forEach(function (payment) { + payment.set('amount', OB.DEC.mul(payment.get('amount'), -1)); + payment.set('origAmount', OB.DEC.mul(payment.get('origAmount'), -1)); + payment.set('paid', OB.DEC.mul(payment.get('paid'), -1)); + }); + } + OB.UTIL.cashUpReport(receipt, function (cashUp) { + var cancelLayawayModel = new OB.Model.CancelLayaway(), + cancelLayawayObj; - receipt.set('cashUpReportInformation', JSON.parse(cashUp.models[0].get('objToSend'))); - receipt.set('created', (new Date()).getTime()); - receipt.set('json', JSON.stringify(receipt.serializeToJSON())); + receipt.set('cashUpReportInformation', JSON.parse(cashUp.models[0].get('objToSend'))); + receipt.set('created', (new Date()).getTime()); + receipt.set('json', JSON.stringify(receipt.serializeToJSON())); - OB.UTIL.clone(receipt, cloneOrderForNew); - OB.UTIL.clone(receipt, cloneOrderForPrinting); + OB.UTIL.clone(receipt, cloneOrderForNew); + OB.UTIL.clone(receipt, cloneOrderForPrinting); - cancelLayawayObj = receipt.serializeToJSON(); - cancelLayawayModel.set('json', JSON.stringify(cancelLayawayObj)); - OB.Dal.getInTransaction(tx, OB.Model.Order, receipt.id, function (model) { - OB.Dal.removeInTransaction(tx, model); - }); - OB.Dal.saveInTransaction(tx, cancelLayawayModel); - }, tx); - }, function () { - //transaction error callback - OB.error("[cancellayaway] The transaction failed to be commited. LayawayId: " + receipt.get('id')); - OB.UTIL.ProcessController.finish('cancelLayaway', execution); - }, function () { - //transaction success callback - OB.info("[cancellayaway] Transaction success. LayawayId: " + receipt.get('id')); - - function cancelAndNew() { - if (OB.MobileApp.model.hasPermission('OBPOS_cancelLayawayAndNew', true)) { - OB.UTIL.showConfirmation.display(OB.I18N.getLabel('OBPOS_cancelLayawayAndNewHeader'), OB.I18N.getLabel('OBPOS_cancelLayawayAndNewBody'), [{ - label: OB.I18N.getLabel('OBPOS_LblOk'), - action: function () { - orderList.addNewOrder(); - var linesMap = {}, - order = orderList.modelorder, - addRelatedLines, addLineToTicket; - - var finalCallback = function () { - order.unset('preventServicesUpdate'); - order.get('lines').trigger('updateRelations'); - }; - - addRelatedLines = function (index) { - if (index === order.get('lines').length) { - finalCallback(); - return; - } - var line = order.get('lines').at(index), - oldLine = linesMap[line.id]; - if (oldLine.get('relatedLines')) { - line.set('relatedLines', []); - _.each(oldLine.get('relatedLines'), function (relatedLine) { - var newRelatedLine = _.clone(relatedLine); - // If the service is not a deferred service, the related line, documentNo - // and orderId must be updated. If it is, is must be marked as deferred - if (!newRelatedLine.otherTicket) { - var i, keys = _.keys(linesMap); - newRelatedLine.orderDocumentNo = order.get('documentNo'); - newRelatedLine.orderId = order.id; - for (i = 0; i < keys.length; i++) { - var key = keys[i]; - if (newRelatedLine.orderlineId === linesMap[key].id) { - newRelatedLine.orderlineId = key; - break; + cancelLayawayObj = receipt.serializeToJSON(); + cancelLayawayModel.set('json', JSON.stringify(cancelLayawayObj)); + OB.Dal.getInTransaction(tx, OB.Model.Order, receipt.id, function (model) { + OB.Dal.removeInTransaction(tx, model); + }); + OB.Dal.saveInTransaction(tx, cancelLayawayModel); + }, tx); + }, function () { + //transaction error callback + OB.error("[cancellayaway] The transaction failed to be commited. LayawayId: " + receipt.get('id')); + OB.UTIL.ProcessController.finish('cancelLayaway', execution); + }, function () { + //transaction success callback + OB.info("[cancellayaway] Transaction success. LayawayId: " + receipt.get('id')); + + function cancelAndNew() { + if (OB.MobileApp.model.hasPermission('OBPOS_cancelLayawayAndNew', true)) { + OB.UTIL.showConfirmation.display(OB.I18N.getLabel('OBPOS_cancelLayawayAndNewHeader'), OB.I18N.getLabel('OBPOS_cancelLayawayAndNewBody'), [{ + label: OB.I18N.getLabel('OBPOS_LblOk'), + action: function () { + orderList.addNewOrder(); + var linesMap = {}, + order = orderList.modelorder, + addRelatedLines, addLineToTicket; + + var finalCallback = function () { + order.unset('preventServicesUpdate'); + order.get('lines').trigger('updateRelations'); + }; + + addRelatedLines = function (index) { + if (index === order.get('lines').length) { + finalCallback(); + return; + } + var line = order.get('lines').at(index), + oldLine = linesMap[line.id]; + if (oldLine.get('relatedLines')) { + line.set('relatedLines', []); + _.each(oldLine.get('relatedLines'), function (relatedLine) { + var newRelatedLine = _.clone(relatedLine); + // If the service is not a deferred service, the related line, documentNo + // and orderId must be updated. If it is, is must be marked as deferred + if (!newRelatedLine.otherTicket) { + var i, keys = _.keys(linesMap); + newRelatedLine.orderDocumentNo = order.get('documentNo'); + newRelatedLine.orderId = order.id; + for (i = 0; i < keys.length; i++) { + var key = keys[i]; + if (newRelatedLine.orderlineId === linesMap[key].id) { + newRelatedLine.orderlineId = key; + break; + } } } - } - line.get('relatedLines').push(newRelatedLine); + line.get('relatedLines').push(newRelatedLine); + }); + } + // Hook to allow any needed relation from an external module + OB.UTIL.HookManager.executeHooks('OBPOS_CancelAndNewAddLineRelation', { + order: order, + cloneOrderForNew: cloneOrderForNew, + line: line, + oldLine: oldLine, + linesMap: linesMap + }, function (args) { + addRelatedLines(index + 1); }); - } - // Hook to allow any needed relation from an external module - OB.UTIL.HookManager.executeHooks('OBPOS_CancelAndNewAddLineRelation', { - order: order, - cloneOrderForNew: cloneOrderForNew, - line: line, - oldLine: oldLine, - linesMap: linesMap - }, function (args) { - addRelatedLines(index + 1); - }); - }; - - addLineToTicket = function (idx) { - if (idx === cloneOrderForNew.get('lines').length) { - addRelatedLines(0); - } else { - var line = cloneOrderForNew.get('lines').at(idx); - order.addProduct(line.get('product'), -line.get('qty'), { - isSilentAddProduct: true - }, undefined, function (success, orderline) { - if (success) { - linesMap[order.get('lines').at(order.get('lines').length - 1).id] = line; - } - addLineToTicket(idx + 1); + }; + + addLineToTicket = function (idx) { + if (idx === cloneOrderForNew.get('lines').length) { + addRelatedLines(0); + } else { + var line = cloneOrderForNew.get('lines').at(idx); + order.addProduct(line.get('product'), -line.get('qty'), { + isSilentAddProduct: true + }, undefined, function (success, orderline) { + if (success) { + linesMap[order.get('lines').at(order.get('lines').length - 1).id] = line; + } + addLineToTicket(idx + 1); + }); + } + }; + + if (cloneOrderForNew.get('isLayaway')) { + OB.MobileApp.view.$.containerWindow.getRoot().showDivText(null, { + permission: null, + orderType: 2 }); } - }; - - if (cloneOrderForNew.get('isLayaway')) { - OB.MobileApp.view.$.containerWindow.getRoot().showDivText(null, { - permission: null, - orderType: 2 - }); + order.set('bp', cloneOrderForNew.get('bp')); + addLineToTicket(0); } - order.set('bp', cloneOrderForNew.get('bp')); - addLineToTicket(0); - } - }, { - label: OB.I18N.getLabel('OBPOS_Cancel') - }]); + }, { + label: OB.I18N.getLabel('OBPOS_Cancel') + }]); + } } - } - - function syncProcessCallback() { - OB.UTIL.showSuccess(OB.I18N.getLabel('OBPOS_MsgSuccessCancelLayaway', [receipt.get('canceledorder').get('documentNo')])); - orderList.deleteCurrent(); - enyo.$.scrim.hide(); - OB.UTIL.calculateCurrentCash(); - OB.UTIL.ProcessController.finish('cancelLayaway', execution); - receipt.trigger('print', cloneOrderForPrinting, { - callback: cancelAndNew, - forceCallback: true - }); - } - OB.MobileApp.model.runSyncProcess(function () { - OB.UTIL.ProcessController.finish('cancelLayaway', execution); - syncProcessCallback(); - }, function () { - if (OB.MobileApp.model.hasPermission('OBMOBC_SynchronizedMode', true)) { - OB.Dal.get(OB.Model.Order, receipt.get('id'), function (loadedReceipt) { - receipt.clearWith(loadedReceipt); - //We need to restore the payment tab, as that's what the user should see if synchronization fails - OB.MobileApp.view.waterfall('onTabChange', { - tabPanel: 'payment', - keyboard: 'toolbarpayment', - edit: false - }); - receipt.set('hasbeenpaid', 'N'); - receipt.trigger('updatePending'); - OB.Dal.save(receipt, function () { - OB.UTIL.calculateCurrentCash(); - }, null, false); + function syncProcessCallback() { + OB.UTIL.showSuccess(OB.I18N.getLabel('OBPOS_MsgSuccessCancelLayaway', [receipt.get('canceledorder').get('documentNo')])); + orderList.deleteCurrent(); + enyo.$.scrim.hide(); + OB.UTIL.calculateCurrentCash(); + OB.UTIL.ProcessController.finish('cancelLayaway', execution); + receipt.trigger('print', cloneOrderForPrinting, { + callback: cancelAndNew, + forceCallback: true }); - } else { - syncProcessCallback(); } + + OB.MobileApp.model.runSyncProcess(function () { + OB.UTIL.ProcessController.finish('cancelLayaway', execution); + syncProcessCallback(); + }, function () { + if (OB.MobileApp.model.hasPermission('OBMOBC_SynchronizedMode', true)) { + OB.Dal.get(OB.Model.Order, receipt.get('id'), function (loadedReceipt) { + receipt.clearWith(loadedReceipt); + //We need to restore the payment tab, as that's what the user should see if synchronization fails + OB.MobileApp.view.waterfall('onTabChange', { + tabPanel: 'payment', + keyboard: 'toolbarpayment', + edit: false + }); + receipt.set('hasbeenpaid', 'N'); + receipt.trigger('updatePending'); + OB.Dal.save(receipt, function () { + OB.UTIL.calculateCurrentCash(); + }, null, false); + }); + } else { + syncProcessCallback(); + } + }); }); }); }); }); + }, function () { + OB.UTIL.ProcessController.finish('cancelLayaway', execution); }); }; diff --git a/web/org.openbravo.retail.posterminal/js/utils/ticketCloseUtils.js b/web/org.openbravo.retail.posterminal/js/utils/ticketCloseUtils.js index 9bbe2e2d0..342803c0d 100644 --- a/web/org.openbravo.retail.posterminal/js/utils/ticketCloseUtils.js +++ b/web/org.openbravo.retail.posterminal/js/utils/ticketCloseUtils.js @@ -312,4 +312,115 @@ return payment.get('paymentData').label; }).join(' + '); }; + + OB.UTIL.TicketCloseUtils.checkOrdersUpdated = function ( + order, successCallback, errorCallback) { + var errorPopup = function (offline, errorType) { + var title = '', + message = '', + buttons = []; + if ( + offline && !OB.MobileApp.model.hasPermission('OBPOS_AllowToSynchronizeLoadedReceiptsOffline', true)) { + title = OB.I18N.getLabel('OBPOS_ErrorCheckingReceipt'); + message = OB.I18N.getLabel('OBPOS_NotPossibleToConfirmReceipt', [ + order.get('documentNo')]); + buttons.push({ + label: OB.I18N.getLabel('OBMOBC_LblOk'), + isConfirmButton: true, + action: function () { + errorCallback(); + } + }); + } else if ( + offline && OB.MobileApp.model.hasPermission('OBPOS_AllowToSynchronizeLoadedReceiptsOffline', true)) { + title = OB.I18N.getLabel('OBPOS_UpdatedReceipt'); + message = OB.I18N.getLabel('OBPOS_NotPossibleToConfirmReceiptWarn', [ + order.get('documentNo')]); + buttons.push({ + label: OB.I18N.getLabel('OBMOBC_LblOk'), + isConfirmButton: true, + action: function () { + successCallback(); + } + }); + buttons.push({ + label: OB.I18N.getLabel('OBMOBC_LblCancel'), + action: function () { + errorCallback(); + } + }); + } else { + title = OB.I18N.getLabel('OBPOS_ErrorCheckingReceipt'); + if (errorType === 'P') { + message = OB.I18N.getLabel('OBPOS_SyncPending', [ + order.get('documentNo')]); + } else if (errorType === 'E') { + message = OB.I18N.getLabel('OBPOS_SyncWithErrors', [ + order.get('documentNo')]); + } else { + message = OB.I18N.getLabel('OBPOS_RemoveAndLoad', [ + order.get('documentNo')]); + } + + buttons.push({ + label: OB.I18N.getLabel('OBMOBC_LblOk'), + isConfirmButton: true, + action: function () { + errorCallback(); + } + }); + } + OB.UTIL.showConfirmation.display(title, message, buttons, { + onHideFunction: function () { + errorCallback(); + } + }); + }; + + if (OB.MobileApp.model.hasPermission('OBMOBC_SynchronizedMode', true)) { + successCallback(); + return; + } + + if (!order.get('isLayaway') && !order.get('isPaid')) { + successCallback(); + return; + } + + if (!OB.MobileApp.model.get('connectedToERP') || !navigator.onLine) { + errorPopup(true); + return; + } + + var checkUpdated = new OB.DS.Process('org.openbravo.retail.posterminal.process.CheckUpdated'), + _order = { + id: order.id, + loaded: order.get('loaded'), + lines: [] + }; + _.each(order.get('lines').models, function (line) { + var _line = { + id: line.id, + loaded: line.get('loaded') + }; + _order.lines.push(_line); + }); + checkUpdated.exec({ + order: _order + }, function (data) { + if (data) { + if (data.exception) { + errorPopup(false); + } else if (data.error) { + errorPopup(false, data.type); + } else { + successCallback(); + } + } else { + errorCallback(); + } + }, function (data) { + errorPopup(true); + }); + }; }()); \ No newline at end of file | |||||||
![]() |
||||||||
|
![]() |
|
(0134661) ranjith_qualiantech_com (viewer) 2022-01-28 14:05 |
Issue is not reproducible in pi. But happens in 19Q1. Attached patch for 19Q1 |
(0134673) marvintm (viewer) 2022-01-31 07:39 |
In master this currently works correctly. Attached a patch for 19Q1 release. |
![]() |
|||
Date Modified | Username | Field | Change |
2022-01-19 20:40 | ffourcade | New Issue | |
2022-01-19 20:40 | ffourcade | Assigned To | => gorka_gil |
2022-01-19 20:40 | ffourcade | OBNetwork customer | => Gold |
2022-01-19 20:40 | ffourcade | Triggers an Emergency Pack | => No |
2022-01-20 11:17 | marvintm | Assigned To | gorka_gil => Retail |
2022-01-20 11:17 | marvintm | Type | feature request => defect |
2022-01-27 12:17 | ranjith_qualiantech_com | Assigned To | Retail => ranjith_qualiantech_com |
2022-01-28 10:16 | ranjith_qualiantech_com | Relationship added | related to 0041762 |
2022-01-28 14:05 | ranjith_qualiantech_com | File Added: 48442_19Q1_posterminal.diff | |
2022-01-28 14:05 | ranjith_qualiantech_com | Status | new => scheduled |
2022-01-28 14:05 | ranjith_qualiantech_com | Note Added: 0134661 | |
2022-01-28 14:05 | ranjith_qualiantech_com | Status | scheduled => resolved |
2022-01-28 14:05 | ranjith_qualiantech_com | Resolution | open => fixed |
2022-01-31 07:38 | marvintm | Status | resolved => new |
2022-01-31 07:38 | marvintm | Resolution | fixed => open |
2022-01-31 07:39 | marvintm | Review Assigned To | => marvintm |
2022-01-31 07:39 | marvintm | Note Added: 0134673 | |
2022-01-31 07:39 | marvintm | Status | new => closed |
2022-01-31 07:39 | marvintm | Resolution | open => no change required |
Copyright © 2000 - 2009 MantisBT Group |