Project:
View Issue Details[ Jump to Notes ] | [ Issue History ] [ Print ] | |||||||
ID | ||||||||
0039200 | ||||||||
Type | Category | Severity | Reproducibility | Date Submitted | Last Update | |||
feature request | [Retail Modules] Web POS | major | have not tried | 2018-08-30 10:01 | 2018-11-16 08:37 | |||
Reporter | ebecerra | View Status | public | |||||
Assigned To | ebecerra | |||||||
Priority | normal | Resolution | fixed | Fixed in Version | RR19Q1 | |||
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 | migueldejuana | |||||||
Regression level | ||||||||
Regression date | ||||||||
Regression introduced in release | ||||||||
Regression introduced by commit | ||||||||
Triggers an Emergency Pack | No | |||||||
Summary | 0039200: Allow reimburse Gift Card with different payment methods. | |||||||
Description | Extend current Gift Cards functionality to allow reimburse Gift Card with different payment methods. | |||||||
Steps To Reproduce | N/A | |||||||
Tags | No tags attached. | |||||||
Attached Files | mobile-core.diff [^] (2,195 bytes) 2018-11-12 12:00 [Show Content] [Hide Content]diff --git a/web/org.openbravo.mobile.core/source/component/ob-keyboard.js b/web/org.openbravo.mobile.core/source/component/ob-keyboard.js --- a/web/org.openbravo.mobile.core/source/component/ob-keyboard.js +++ b/web/org.openbravo.mobile.core/source/component/ob-keyboard.js @@ -1198,7 +1198,16 @@ name: 'OB.UI.ToolbarMore', style: 'display:table; width:100%;', handlers: { - onStatusChanged: 'statusChanged' + onStatusChanged: 'statusChanged', + onDisableButton: 'disableButton' + }, + disableButton: function (inSender, inEvent) { + this.$.btn.setDisabled(inEvent.disabled); + if (inEvent.disabled) { + this.$.btn.addClass('btnkeyboard-inactive'); + } else { + this.$.btn.removeClass('btnkeyboard-inactive'); + } }, components: [{ style: 'margin: 5px;', diff --git a/web/org.openbravo.mobile.core/source/model/ob-terminal-model.js b/web/org.openbravo.mobile.core/source/model/ob-terminal-model.js --- a/web/org.openbravo.mobile.core/source/model/ob-terminal-model.js +++ b/web/org.openbravo.mobile.core/source/model/ob-terminal-model.js @@ -395,12 +395,13 @@ * If you want to create a new point in the history then pReplace should be passed as false * http://backbonejs.org/#Router-navigate */ - navigate: function (route, pReplace) { + navigate: function (route, pReplace, parameters) { if (pReplace !== false) { pReplace = true; } OB.debug("Navigating to '" + route + "' Replace: " + pReplace); OB.MobileApp.view.keyReceivers.splice(0, OB.MobileApp.view.keyReceivers.length); + OB.MobileApp.view.currentWindowParameters = parameters; this.router.navigate(route, { trigger: true, replace: pReplace @@ -1885,6 +1886,12 @@ OB.MobileApp.view.$.containerWindow.render(); OB.UTIL.showLoading(false); OB.MobileApp.view.$.containerWindow.resized(); + + OB.UTIL.HookManager.executeHooks('OBPOS_AfterRenderContainerWindow', { + context: OB.MobileApp.view.$.containerWindow, + window: OB.MobileApp.view.currentWindow, + parameters: OB.MobileApp.view.currentWindowParameters + }, function () {}); }, updateSession: function (user, callback) { posterminal.diff [^] (36,620 bytes) 2018-11-12 12:18 [Show Content] [Hide Content] diff --git a/src-db/database/model/tables/OBPOS_APP_PAYMENT_TYPE.xml b/src-db/database/model/tables/OBPOS_APP_PAYMENT_TYPE.xml --- a/src-db/database/model/tables/OBPOS_APP_PAYMENT_TYPE.xml +++ b/src-db/database/model/tables/OBPOS_APP_PAYMENT_TYPE.xml @@ -201,6 +201,10 @@ <default/> <onCreateDefault/> </column> + <column name="CASHMNGPROVIDER" primaryKey="false" required="false" type="VARCHAR" size="60" autoIncrement="false"> + <default/> + <onCreateDefault/> + </column> <column name="CHANGELESSTHAN" primaryKey="false" required="false" type="DECIMAL" autoIncrement="false"> <default/> <onCreateDefault/> diff --git a/src-db/database/sourcedata/AD_COLUMN.xml b/src-db/database/sourcedata/AD_COLUMN.xml --- a/src-db/database/sourcedata/AD_COLUMN.xml +++ b/src-db/database/sourcedata/AD_COLUMN.xml @@ -14138,6 +14138,44 @@ <!--A52D9C3B5EEE4BE7B8B68CB040D4A965--> <ALLOWED_CROSS_ORG_LINK><![CDATA[N]]></ALLOWED_CROSS_ORG_LINK> <!--A52D9C3B5EEE4BE7B8B68CB040D4A965--></AD_COLUMN> +<!--A69D7C5EB67C4D97AD13EBFBCBC0FA9A--><AD_COLUMN> +<!--A69D7C5EB67C4D97AD13EBFBCBC0FA9A--> <AD_COLUMN_ID><![CDATA[A69D7C5EB67C4D97AD13EBFBCBC0FA9A]]></AD_COLUMN_ID> +<!--A69D7C5EB67C4D97AD13EBFBCBC0FA9A--> <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID> +<!--A69D7C5EB67C4D97AD13EBFBCBC0FA9A--> <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID> +<!--A69D7C5EB67C4D97AD13EBFBCBC0FA9A--> <ISACTIVE><![CDATA[Y]]></ISACTIVE> +<!--A69D7C5EB67C4D97AD13EBFBCBC0FA9A--> <NAME><![CDATA[Cash Management Provider]]></NAME> +<!--A69D7C5EB67C4D97AD13EBFBCBC0FA9A--> <HELP><![CDATA[External payment provider who processes this kind of cash management types.]]></HELP> +<!--A69D7C5EB67C4D97AD13EBFBCBC0FA9A--> <COLUMNNAME><![CDATA[Cashmngprovider]]></COLUMNNAME> +<!--A69D7C5EB67C4D97AD13EBFBCBC0FA9A--> <AD_TABLE_ID><![CDATA[B096FDF43917472D8FDE9693E9CCFFD4]]></AD_TABLE_ID> +<!--A69D7C5EB67C4D97AD13EBFBCBC0FA9A--> <AD_REFERENCE_ID><![CDATA[17]]></AD_REFERENCE_ID> +<!--A69D7C5EB67C4D97AD13EBFBCBC0FA9A--> <AD_REFERENCE_VALUE_ID><![CDATA[BDB5235D4E7A42BDA5D91987F11C8AB1]]></AD_REFERENCE_VALUE_ID> +<!--A69D7C5EB67C4D97AD13EBFBCBC0FA9A--> <FIELDLENGTH><![CDATA[60]]></FIELDLENGTH> +<!--A69D7C5EB67C4D97AD13EBFBCBC0FA9A--> <ISKEY><![CDATA[N]]></ISKEY> +<!--A69D7C5EB67C4D97AD13EBFBCBC0FA9A--> <ISPARENT><![CDATA[N]]></ISPARENT> +<!--A69D7C5EB67C4D97AD13EBFBCBC0FA9A--> <ISMANDATORY><![CDATA[N]]></ISMANDATORY> +<!--A69D7C5EB67C4D97AD13EBFBCBC0FA9A--> <ISUPDATEABLE><![CDATA[Y]]></ISUPDATEABLE> +<!--A69D7C5EB67C4D97AD13EBFBCBC0FA9A--> <ISIDENTIFIER><![CDATA[N]]></ISIDENTIFIER> +<!--A69D7C5EB67C4D97AD13EBFBCBC0FA9A--> <SEQNO><![CDATA[525]]></SEQNO> +<!--A69D7C5EB67C4D97AD13EBFBCBC0FA9A--> <ISTRANSLATED><![CDATA[N]]></ISTRANSLATED> +<!--A69D7C5EB67C4D97AD13EBFBCBC0FA9A--> <ISENCRYPTED><![CDATA[N]]></ISENCRYPTED> +<!--A69D7C5EB67C4D97AD13EBFBCBC0FA9A--> <ISSELECTIONCOLUMN><![CDATA[N]]></ISSELECTIONCOLUMN> +<!--A69D7C5EB67C4D97AD13EBFBCBC0FA9A--> <AD_ELEMENT_ID><![CDATA[829EE1F0546D425A922C63607A6CA027]]></AD_ELEMENT_ID> +<!--A69D7C5EB67C4D97AD13EBFBCBC0FA9A--> <ISSESSIONATTR><![CDATA[N]]></ISSESSIONATTR> +<!--A69D7C5EB67C4D97AD13EBFBCBC0FA9A--> <ISSECONDARYKEY><![CDATA[N]]></ISSECONDARYKEY> +<!--A69D7C5EB67C4D97AD13EBFBCBC0FA9A--> <ISDESENCRYPTABLE><![CDATA[N]]></ISDESENCRYPTABLE> +<!--A69D7C5EB67C4D97AD13EBFBCBC0FA9A--> <DEVELOPMENTSTATUS><![CDATA[RE]]></DEVELOPMENTSTATUS> +<!--A69D7C5EB67C4D97AD13EBFBCBC0FA9A--> <AD_MODULE_ID><![CDATA[FF808181326CC34901326D53DBCF0018]]></AD_MODULE_ID> +<!--A69D7C5EB67C4D97AD13EBFBCBC0FA9A--> <POSITION><![CDATA[50]]></POSITION> +<!--A69D7C5EB67C4D97AD13EBFBCBC0FA9A--> <ISTRANSIENT><![CDATA[N]]></ISTRANSIENT> +<!--A69D7C5EB67C4D97AD13EBFBCBC0FA9A--> <ISAUTOSAVE><![CDATA[Y]]></ISAUTOSAVE> +<!--A69D7C5EB67C4D97AD13EBFBCBC0FA9A--> <VALIDATEONNEW><![CDATA[Y]]></VALIDATEONNEW> +<!--A69D7C5EB67C4D97AD13EBFBCBC0FA9A--> <IMAGESIZEVALUESACTION><![CDATA[N]]></IMAGESIZEVALUESACTION> +<!--A69D7C5EB67C4D97AD13EBFBCBC0FA9A--> <ISUSEDSEQUENCE><![CDATA[N]]></ISUSEDSEQUENCE> +<!--A69D7C5EB67C4D97AD13EBFBCBC0FA9A--> <ALLOWSORTING><![CDATA[Y]]></ALLOWSORTING> +<!--A69D7C5EB67C4D97AD13EBFBCBC0FA9A--> <ALLOWFILTERING><![CDATA[Y]]></ALLOWFILTERING> +<!--A69D7C5EB67C4D97AD13EBFBCBC0FA9A--> <ALLOWED_CROSS_ORG_LINK><![CDATA[N]]></ALLOWED_CROSS_ORG_LINK> +<!--A69D7C5EB67C4D97AD13EBFBCBC0FA9A--></AD_COLUMN> + <!--A6CE2D53B758490A85300B4CB7C261E2--><AD_COLUMN> <!--A6CE2D53B758490A85300B4CB7C261E2--> <AD_COLUMN_ID><![CDATA[A6CE2D53B758490A85300B4CB7C261E2]]></AD_COLUMN_ID> <!--A6CE2D53B758490A85300B4CB7C261E2--> <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID> diff --git a/src-db/database/sourcedata/AD_ELEMENT.xml b/src-db/database/sourcedata/AD_ELEMENT.xml --- a/src-db/database/sourcedata/AD_ELEMENT.xml +++ b/src-db/database/sourcedata/AD_ELEMENT.xml @@ -1574,6 +1574,19 @@ <!--817096B54C6E42519F0713ED39F0599F--> <ISGLOSSARY><![CDATA[N]]></ISGLOSSARY> <!--817096B54C6E42519F0713ED39F0599F--></AD_ELEMENT> +<!--829EE1F0546D425A922C63607A6CA027--><AD_ELEMENT> +<!--829EE1F0546D425A922C63607A6CA027--> <AD_ELEMENT_ID><![CDATA[829EE1F0546D425A922C63607A6CA027]]></AD_ELEMENT_ID> +<!--829EE1F0546D425A922C63607A6CA027--> <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID> +<!--829EE1F0546D425A922C63607A6CA027--> <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID> +<!--829EE1F0546D425A922C63607A6CA027--> <ISACTIVE><![CDATA[Y]]></ISACTIVE> +<!--829EE1F0546D425A922C63607A6CA027--> <COLUMNNAME><![CDATA[Cashmngprovider]]></COLUMNNAME> +<!--829EE1F0546D425A922C63607A6CA027--> <NAME><![CDATA[Cash Management Provider]]></NAME> +<!--829EE1F0546D425A922C63607A6CA027--> <PRINTNAME><![CDATA[Cash Management Provider]]></PRINTNAME> +<!--829EE1F0546D425A922C63607A6CA027--> <HELP><![CDATA[External payment provider who processes this kind of cash management types.]]></HELP> +<!--829EE1F0546D425A922C63607A6CA027--> <AD_MODULE_ID><![CDATA[FF808181326CC34901326D53DBCF0018]]></AD_MODULE_ID> +<!--829EE1F0546D425A922C63607A6CA027--> <ISGLOSSARY><![CDATA[N]]></ISGLOSSARY> +<!--829EE1F0546D425A922C63607A6CA027--></AD_ELEMENT> + <!--834F6A01A9A24D22AF1E7E7CF89455AC--><AD_ELEMENT> <!--834F6A01A9A24D22AF1E7E7CF89455AC--> <AD_ELEMENT_ID><![CDATA[834F6A01A9A24D22AF1E7E7CF89455AC]]></AD_ELEMENT_ID> <!--834F6A01A9A24D22AF1E7E7CF89455AC--> <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID> diff --git a/src-db/database/sourcedata/AD_FIELD.xml b/src-db/database/sourcedata/AD_FIELD.xml --- a/src-db/database/sourcedata/AD_FIELD.xml +++ b/src-db/database/sourcedata/AD_FIELD.xml @@ -9861,6 +9861,33 @@ <!--C6684E7E0F254873989FD348311CE64B--> <EM_OBUIAPP_SHOWSUMMARY><![CDATA[N]]></EM_OBUIAPP_SHOWSUMMARY> <!--C6684E7E0F254873989FD348311CE64B--></AD_FIELD> +<!--C7C064DCB8C34DF6912AF5927D1ED450--><AD_FIELD> +<!--C7C064DCB8C34DF6912AF5927D1ED450--> <AD_FIELD_ID><![CDATA[C7C064DCB8C34DF6912AF5927D1ED450]]></AD_FIELD_ID> +<!--C7C064DCB8C34DF6912AF5927D1ED450--> <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID> +<!--C7C064DCB8C34DF6912AF5927D1ED450--> <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID> +<!--C7C064DCB8C34DF6912AF5927D1ED450--> <ISACTIVE><![CDATA[Y]]></ISACTIVE> +<!--C7C064DCB8C34DF6912AF5927D1ED450--> <NAME><![CDATA[Cash Management Provider]]></NAME> +<!--C7C064DCB8C34DF6912AF5927D1ED450--> <HELP><![CDATA[External payment provider who processes this kind of cash management types.]]></HELP> +<!--C7C064DCB8C34DF6912AF5927D1ED450--> <ISCENTRALLYMAINTAINED><![CDATA[Y]]></ISCENTRALLYMAINTAINED> +<!--C7C064DCB8C34DF6912AF5927D1ED450--> <AD_TAB_ID><![CDATA[4D9F5E9CC0014A96861CEFB64BBF013B]]></AD_TAB_ID> +<!--C7C064DCB8C34DF6912AF5927D1ED450--> <AD_COLUMN_ID><![CDATA[A69D7C5EB67C4D97AD13EBFBCBC0FA9A]]></AD_COLUMN_ID> +<!--C7C064DCB8C34DF6912AF5927D1ED450--> <IGNOREINWAD><![CDATA[N]]></IGNOREINWAD> +<!--C7C064DCB8C34DF6912AF5927D1ED450--> <ISDISPLAYED><![CDATA[Y]]></ISDISPLAYED> +<!--C7C064DCB8C34DF6912AF5927D1ED450--> <DISPLAYLENGTH><![CDATA[60]]></DISPLAYLENGTH> +<!--C7C064DCB8C34DF6912AF5927D1ED450--> <ISREADONLY><![CDATA[N]]></ISREADONLY> +<!--C7C064DCB8C34DF6912AF5927D1ED450--> <SEQNO><![CDATA[86]]></SEQNO> +<!--C7C064DCB8C34DF6912AF5927D1ED450--> <ISSAMELINE><![CDATA[N]]></ISSAMELINE> +<!--C7C064DCB8C34DF6912AF5927D1ED450--> <ISFIELDONLY><![CDATA[N]]></ISFIELDONLY> +<!--C7C064DCB8C34DF6912AF5927D1ED450--> <ISENCRYPTED><![CDATA[N]]></ISENCRYPTED> +<!--C7C064DCB8C34DF6912AF5927D1ED450--> <SHOWINRELATION><![CDATA[N]]></SHOWINRELATION> +<!--C7C064DCB8C34DF6912AF5927D1ED450--> <ISFIRSTFOCUSEDFIELD><![CDATA[N]]></ISFIRSTFOCUSEDFIELD> +<!--C7C064DCB8C34DF6912AF5927D1ED450--> <AD_MODULE_ID><![CDATA[FF808181326CC34901326D53DBCF0018]]></AD_MODULE_ID> +<!--C7C064DCB8C34DF6912AF5927D1ED450--> <STARTINODDCOLUMN><![CDATA[N]]></STARTINODDCOLUMN> +<!--C7C064DCB8C34DF6912AF5927D1ED450--> <STARTNEWLINE><![CDATA[N]]></STARTNEWLINE> +<!--C7C064DCB8C34DF6912AF5927D1ED450--> <ISSHOWNINSTATUSBAR><![CDATA[N]]></ISSHOWNINSTATUSBAR> +<!--C7C064DCB8C34DF6912AF5927D1ED450--> <EM_OBUIAPP_SHOWSUMMARY><![CDATA[N]]></EM_OBUIAPP_SHOWSUMMARY> +<!--C7C064DCB8C34DF6912AF5927D1ED450--></AD_FIELD> + <!--C7D1E9F6A0C543A0A57125F32183781F--><AD_FIELD> <!--C7D1E9F6A0C543A0A57125F32183781F--> <AD_FIELD_ID><![CDATA[C7D1E9F6A0C543A0A57125F32183781F]]></AD_FIELD_ID> <!--C7D1E9F6A0C543A0A57125F32183781F--> <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID> diff --git a/src-db/database/sourcedata/AD_MESSAGE.xml b/src-db/database/sourcedata/AD_MESSAGE.xml --- a/src-db/database/sourcedata/AD_MESSAGE.xml +++ b/src-db/database/sourcedata/AD_MESSAGE.xml @@ -7337,6 +7337,18 @@ <!--AB752B5561AC4C07B234AEF5CD77CF3F--> <ISINCLUDEINI18N><![CDATA[N]]></ISINCLUDEINI18N> <!--AB752B5561AC4C07B234AEF5CD77CF3F--></AD_MESSAGE> +<!--AB9714CA6770447C9A970888851AFF51--><AD_MESSAGE> +<!--AB9714CA6770447C9A970888851AFF51--> <AD_MESSAGE_ID><![CDATA[AB9714CA6770447C9A970888851AFF51]]></AD_MESSAGE_ID> +<!--AB9714CA6770447C9A970888851AFF51--> <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID> +<!--AB9714CA6770447C9A970888851AFF51--> <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID> +<!--AB9714CA6770447C9A970888851AFF51--> <ISACTIVE><![CDATA[Y]]></ISACTIVE> +<!--AB9714CA6770447C9A970888851AFF51--> <VALUE><![CDATA[OBPOS_MsgCloseOrDoneCashManagement]]></VALUE> +<!--AB9714CA6770447C9A970888851AFF51--> <MSGTEXT><![CDATA[You have an operation pending. Please complete or cancel Cash Management.]]></MSGTEXT> +<!--AB9714CA6770447C9A970888851AFF51--> <MSGTYPE><![CDATA[I]]></MSGTYPE> +<!--AB9714CA6770447C9A970888851AFF51--> <AD_MODULE_ID><![CDATA[FF808181326CC34901326D53DBCF0018]]></AD_MODULE_ID> +<!--AB9714CA6770447C9A970888851AFF51--> <ISINCLUDEINI18N><![CDATA[N]]></ISINCLUDEINI18N> +<!--AB9714CA6770447C9A970888851AFF51--></AD_MESSAGE> + <!--ABA1CA6533F949829471ABEFAD4FAB9F--><AD_MESSAGE> <!--ABA1CA6533F949829471ABEFAD4FAB9F--> <AD_MESSAGE_ID><![CDATA[ABA1CA6533F949829471ABEFAD4FAB9F]]></AD_MESSAGE_ID> <!--ABA1CA6533F949829471ABEFAD4FAB9F--> <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID> diff --git a/src-db/database/sourcedata/AD_REFERENCE.xml b/src-db/database/sourcedata/AD_REFERENCE.xml --- a/src-db/database/sourcedata/AD_REFERENCE.xml +++ b/src-db/database/sourcedata/AD_REFERENCE.xml @@ -291,6 +291,20 @@ <!--BDA324CB4B8847C3A1D2318E978BA08A--> <ISVALUEDISPLAYED><![CDATA[N]]></ISVALUEDISPLAYED> <!--BDA324CB4B8847C3A1D2318E978BA08A--></AD_REFERENCE> +<!--BDB5235D4E7A42BDA5D91987F11C8AB1--><AD_REFERENCE> +<!--BDB5235D4E7A42BDA5D91987F11C8AB1--> <AD_REFERENCE_ID><![CDATA[BDB5235D4E7A42BDA5D91987F11C8AB1]]></AD_REFERENCE_ID> +<!--BDB5235D4E7A42BDA5D91987F11C8AB1--> <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID> +<!--BDB5235D4E7A42BDA5D91987F11C8AB1--> <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID> +<!--BDB5235D4E7A42BDA5D91987F11C8AB1--> <ISACTIVE><![CDATA[Y]]></ISACTIVE> +<!--BDB5235D4E7A42BDA5D91987F11C8AB1--> <NAME><![CDATA[Cash Management Provider]]></NAME> +<!--BDB5235D4E7A42BDA5D91987F11C8AB1--> <DESCRIPTION><![CDATA[External payment provider who processes this kind of cash management types.]]></DESCRIPTION> +<!--BDB5235D4E7A42BDA5D91987F11C8AB1--> <HELP><![CDATA[External payment provider who processes this kind of cash management types.]]></HELP> +<!--BDB5235D4E7A42BDA5D91987F11C8AB1--> <AD_MODULE_ID><![CDATA[FF808181326CC34901326D53DBCF0018]]></AD_MODULE_ID> +<!--BDB5235D4E7A42BDA5D91987F11C8AB1--> <ISBASEREFERENCE><![CDATA[N]]></ISBASEREFERENCE> +<!--BDB5235D4E7A42BDA5D91987F11C8AB1--> <PARENTREFERENCE_ID><![CDATA[17]]></PARENTREFERENCE_ID> +<!--BDB5235D4E7A42BDA5D91987F11C8AB1--> <ISVALUEDISPLAYED><![CDATA[N]]></ISVALUEDISPLAYED> +<!--BDB5235D4E7A42BDA5D91987F11C8AB1--></AD_REFERENCE> + <!--C4832B2197944359BFEDD98C0FBDC906--><AD_REFERENCE> <!--C4832B2197944359BFEDD98C0FBDC906--> <AD_REFERENCE_ID><![CDATA[C4832B2197944359BFEDD98C0FBDC906]]></AD_REFERENCE_ID> <!--C4832B2197944359BFEDD98C0FBDC906--> <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 --- a/src-db/database/sourcedata/AD_REF_LIST.xml +++ b/src-db/database/sourcedata/AD_REF_LIST.xml @@ -1494,6 +1494,17 @@ <!--8E594CEE611248C69312FAB49DE88FF2--> <AD_MODULE_ID><![CDATA[FF808181326CC34901326D53DBCF0018]]></AD_MODULE_ID> <!--8E594CEE611248C69312FAB49DE88FF2--></AD_REF_LIST> +<!--8EC7AA4924CE41E1BB7AC2A30A3EE058--><AD_REF_LIST> +<!--8EC7AA4924CE41E1BB7AC2A30A3EE058--> <AD_REF_LIST_ID><![CDATA[8EC7AA4924CE41E1BB7AC2A30A3EE058]]></AD_REF_LIST_ID> +<!--8EC7AA4924CE41E1BB7AC2A30A3EE058--> <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID> +<!--8EC7AA4924CE41E1BB7AC2A30A3EE058--> <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID> +<!--8EC7AA4924CE41E1BB7AC2A30A3EE058--> <ISACTIVE><![CDATA[Y]]></ISACTIVE> +<!--8EC7AA4924CE41E1BB7AC2A30A3EE058--> <VALUE><![CDATA[OB.UI.MockPayment]]></VALUE> +<!--8EC7AA4924CE41E1BB7AC2A30A3EE058--> <NAME><![CDATA[Confirm return dialog]]></NAME> +<!--8EC7AA4924CE41E1BB7AC2A30A3EE058--> <AD_REFERENCE_ID><![CDATA[BDB5235D4E7A42BDA5D91987F11C8AB1]]></AD_REFERENCE_ID> +<!--8EC7AA4924CE41E1BB7AC2A30A3EE058--> <AD_MODULE_ID><![CDATA[FF808181326CC34901326D53DBCF0018]]></AD_MODULE_ID> +<!--8EC7AA4924CE41E1BB7AC2A30A3EE058--></AD_REF_LIST> + <!--9622025366CB4D3B9227A3F2D3465088--><AD_REF_LIST> <!--9622025366CB4D3B9227A3F2D3465088--> <AD_REF_LIST_ID><![CDATA[9622025366CB4D3B9227A3F2D3465088]]></AD_REF_LIST_ID> <!--9622025366CB4D3B9227A3F2D3465088--> <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID> diff --git a/src-db/database/sourcedata/OBMOBC_PROCESS_DEFINITION.xml b/src-db/database/sourcedata/OBMOBC_PROCESS_DEFINITION.xml --- a/src-db/database/sourcedata/OBMOBC_PROCESS_DEFINITION.xml +++ b/src-db/database/sourcedata/OBMOBC_PROCESS_DEFINITION.xml @@ -88,6 +88,17 @@ <!--C8DDB7E5DF124999A0A64B70EE9C1684--> <DESCRIPTION><![CDATA[Show the payment panel in the rigth side]]></DESCRIPTION> <!--C8DDB7E5DF124999A0A64B70EE9C1684--></OBMOBC_PROCESS_DEFINITION> +<!--D429C6FF77DD4F059069C48D10534E3F--><OBMOBC_PROCESS_DEFINITION> +<!--D429C6FF77DD4F059069C48D10534E3F--> <OBMOBC_PROCESS_DEFINITION_ID><![CDATA[D429C6FF77DD4F059069C48D10534E3F]]></OBMOBC_PROCESS_DEFINITION_ID> +<!--D429C6FF77DD4F059069C48D10534E3F--> <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID> +<!--D429C6FF77DD4F059069C48D10534E3F--> <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID> +<!--D429C6FF77DD4F059069C48D10534E3F--> <AD_MODULE_ID><![CDATA[FF808181326CC34901326D53DBCF0018]]></AD_MODULE_ID> +<!--D429C6FF77DD4F059069C48D10534E3F--> <ISACTIVE><![CDATA[Y]]></ISACTIVE> +<!--D429C6FF77DD4F059069C48D10534E3F--> <SEARCHKEY><![CDATA[cashMngPaymentDone]]></SEARCHKEY> +<!--D429C6FF77DD4F059069C48D10534E3F--> <NAME><![CDATA[Cash Management Payment Done]]></NAME> +<!--D429C6FF77DD4F059069C48D10534E3F--> <DESCRIPTION><![CDATA[Payment complete in Cash Management window]]></DESCRIPTION> +<!--D429C6FF77DD4F059069C48D10534E3F--></OBMOBC_PROCESS_DEFINITION> + <!--E602ED1A21C64564BB565B5E9BB16E39--><OBMOBC_PROCESS_DEFINITION> <!--E602ED1A21C64564BB565B5E9BB16E39--> <OBMOBC_PROCESS_DEFINITION_ID><![CDATA[E602ED1A21C64564BB565B5E9BB16E39]]></OBMOBC_PROCESS_DEFINITION_ID> <!--E602ED1A21C64564BB565B5E9BB16E39--> <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID> diff --git a/web/org.openbravo.retail.posterminal/js/cashmgmt/model/cashmgmt-model.js b/web/org.openbravo.retail.posterminal/js/cashmgmt/model/cashmgmt-model.js --- a/web/org.openbravo.retail.posterminal/js/cashmgmt/model/cashmgmt-model.js +++ b/web/org.openbravo.retail.posterminal/js/cashmgmt/model/cashmgmt-model.js @@ -22,26 +22,36 @@ this.initModels(function () {}); this.loadModels(function () {}); }, + pendingToSaveHaveCashManagementProvider: function () { + var hasPayment = false; + _.each(this.depsdropstosave.models, function (drop) { + var payment = _.find(OB.POS.modelterminal.get('payments'), function (p) { + return p.payment.id === drop.get('paymentMethodId') && p.paymentMethod.cashManagementProvider; + }); + if (!OB.UTIL.isNullOrUndefined(payment) || drop.get('allowOnlyOne')) { + hasPayment = true; + } + }); + return hasPayment; + }, initModels: function (initModelsCallback) { var me = this; this.depsdropstosave = new Backbone.Collection(); this.depsdropstosave.on('paymentDone', function (model, p, callback, errorCallback) { + var execution = OB.UTIL.ProcessController.start('cashMngPaymentDone'); // argument checks OB.UTIL.Debug.execute(function () { if (!me.payments) { OB.error("The 'payments' variable has not been initialized (value: " + me.payments + "'"); } }); - var isError = false; - me.payments.each(function (pay) { - if (p.id === pay.get('paymentmethod_id')) { - isError = (p.type === 'drop' && OB.DEC.sub(pay.get('total'), OB.DEC.mul(p.amount, p.rate)) < 0); - } - }); - + var isError = !OB.UTIL.isNullOrUndefined(_.find(me.payments.models, function (pay) { + return p.iscash && p.id === pay.get('paymentmethod_id') && p.type === 'drop' && OB.DEC.sub(pay.get('total'), OB.DEC.mul(p.amount, p.rate)) < 0; + })); if (isError) { + OB.UTIL.ProcessController.finish('cashMngPaymentDone', execution); OB.UTIL.showError(OB.I18N.getLabel('OBPOS_MsgMoreThanAvailable')); if (errorCallback) { errorCallback(OB.I18N.getLabel('OBPOS_MsgMoreThanAvailable')); @@ -50,6 +60,7 @@ } if (OB.DEC.mul(p.amount, p.rate) <= 0) { + OB.UTIL.ProcessController.finish('cashMngPaymentDone', execution); OB.UTIL.showError(OB.I18N.getLabel('OBPOS_amtGreaterThanZero')); return; } @@ -99,10 +110,17 @@ }); asyncToSyncWrapper.then(function () { + // Check pending drop to save have cash management provider + execution.set('hasPendigOp', me.pendingToSaveHaveCashManagementProvider()); + if (execution.get('hasPendigOp')) { + OB.UTIL.showWarning(OB.I18N.getLabel('OBPOS_MsgCloseOrDoneCashManagement')); + } + OB.UTIL.ProcessController.finish('cashMngPaymentDone', execution); if (callback) { callback(); } }, function () { + OB.UTIL.ProcessController.finish('cashMngPaymentDone', execution); var errorMsg = 'Could not save payment information'; if (errorCallback) { errorCallback(errorMsg); @@ -400,7 +418,22 @@ resolve(); }, reject, pay); } else { - resolve(); + OB.UTIL.HookManager.executeHooks('OBPOS_AddPaymentToCashManagement', { + context: me, + pay: pay, + paymentMethod: paymentMth + }, function (args) { + if (args.includePay) { + OB.Dal.find(OB.Model.CashManagement, criteria, function (cashmgmt, pay) { + if (cashmgmt.length > 0) { + pay.set('listdepositsdrops', cashmgmt.models); + } + resolve(); + }, reject, pay); + } else { + resolve(); + } + }); } }); } diff --git a/web/org.openbravo.retail.posterminal/js/cashmgmt/view/cashmgmt.js b/web/org.openbravo.retail.posterminal/js/cashmgmt/view/cashmgmt.js --- a/web/org.openbravo.retail.posterminal/js/cashmgmt/view/cashmgmt.js +++ b/web/org.openbravo.retail.posterminal/js/cashmgmt/view/cashmgmt.js @@ -44,7 +44,37 @@ }, tap: function () { OB.POS.hwserver.checkDrawer(function () { - this.model.depsdropstosave.trigger('makeDeposits'); + var hasProvider = false, + payment = null, + currentDrop = null; + this.model.depsdropstosave.each(function (drop) { + payment = _.find(OB.POS.modelterminal.get('payments'), function (p) { + return p.payment.id === drop.get('paymentMethodId'); + }); + if (payment && payment.paymentMethod.cashManagementProvider) { + hasProvider = true; + currentDrop = drop; + } + }); + if (hasProvider) { + this.bubble('onShowPopup', { + popup: 'modalpayment', + args: { + 'receipt': null, + 'cashManagement': this.model, + 'provider': payment.paymentMethod.cashManagementProvider, + 'key': payment.paymentMethod.searchKey, + 'name': payment.paymentMethod._identifier, + 'paymentMethod': payment.paymentMethod, + 'amount': currentDrop.get('amount'), + 'rate': payment.rate, + 'mulrate': payment.mulrate, + 'isocode': payment.isocode + } + }); + } else { + this.model.depsdropstosave.trigger('makeDeposits'); + } }, this); } }] @@ -74,8 +104,11 @@ onShowPopup: '' }, handlers: { + onPaymentChanged: 'paymentChanged', + onPaymentChangedCancelled: 'paymentChangedCancelled', onAdvancedFilterSelector: 'advancedFilterSelector', - onChangeFilterSelector: 'changeFilterSelector' + onChangeFilterSelector: 'changeFilterSelector', + onCashManagementOpenWindow: 'cashManagementOpenWindow' }, components: [{ kind: 'OB.UI.MultiColumn', @@ -146,6 +179,16 @@ }] }], + paymentChanged: function (inSender, inEvent) { + // sending the event to the components bellow this one + this.waterfall('onButtonPaymentChanged', inEvent); + }, + + paymentChangedCancelled: function (inSender, inEvent) { + // sending the event to the components bellow this one + this.waterfall('onButtonPaymentChangedCancelled', inEvent); + }, + advancedFilterSelector: function (inSender, inEvent) { this.waterfall('onGetAdvancedFilterSelector', inEvent); }, @@ -154,6 +197,11 @@ this.waterfall('onUpdateFilterSelector', inEvent); }, + cashManagementOpenWindow: function (inSender, inEvent) { + inEvent.keyboard = this; + this.waterfall('onCashManagementOpen', inEvent); + }, + init: function () { this.inherited(arguments); @@ -269,4 +317,9 @@ return payment.paymentMethod.iscash === true; }).length > 0; } +}); + +OB.UI.WindowView.registerPopup('OB.OBPOSCashMgmt.UI.CashManagement', { + kind: 'OB.UI.ModalPayment', + name: 'modalpayment' }); \ No newline at end of file diff --git a/web/org.openbravo.retail.posterminal/js/cashmgmt/view/cashmgmtkeyboard.js b/web/org.openbravo.retail.posterminal/js/cashmgmt/view/cashmgmtkeyboard.js --- a/web/org.openbravo.retail.posterminal/js/cashmgmt/view/cashmgmtkeyboard.js +++ b/web/org.openbravo.retail.posterminal/js/cashmgmt/view/cashmgmtkeyboard.js @@ -16,6 +16,20 @@ events: { onShowPopup: '' }, + processesToListen: ['cashMngPaymentDone'], + processFinished: function (process, execution, processesInExec) { + if (processesInExec.models.length === 0) { + if (execution.get('hasPendigOp')) { + var commands = _.map(this.buttons, function (b) { + return b.command; + }); + this.waterfall('onDisableButton', { + disabled: true, + commands: commands + }); + } + } + }, getPayment: function (id, key, iscash, allowopendrawer, name, identifier, type, rate, isocode, glItem, paymentMethod) { var me = this; var i; @@ -78,9 +92,9 @@ }, init: function () { - var buttons = []; + this.buttons = []; this.inherited(arguments); - buttons.push({ + this.buttons.push({ command: 'opendrawer', i18nLabel: 'OBPOS_OpenDrawer', stateless: true, @@ -101,7 +115,7 @@ if (paymentMethod.paymentMethod.allowdeposits) { for (i = 0; i < OB.MobileApp.model.get('cashMgmtDepositEvents').length; i++) { if (OB.MobileApp.model.get('cashMgmtDepositEvents')[i].isocode === paymentMethod.isocode && paymentMethod.paymentMethod.paymentMethod === OB.MobileApp.model.get('cashMgmtDepositEvents')[i].paymentmethod) { - buttons.push({ + this.buttons.push({ idSufix: 'Deposit.' + paymentMethod.isocode, command: payment.searchKey + '_' + OB.I18N.getLabel('OBPOS_LblDeposit'), definition: this.getPayment(payment.id, payment.searchKey, paymentMethod.paymentMethod.iscash, paymentMethod.paymentMethod.allowopendrawer, payment._identifier, payment._identifier, 'deposit', paymentMethod.rate, paymentMethod.isocode, paymentMethod.paymentMethod.gLItemForDeposits, paymentMethod.paymentMethod.paymentMethod), @@ -115,7 +129,7 @@ if (paymentMethod.paymentMethod.allowdrops) { for (i = 0; i < OB.MobileApp.model.get('cashMgmtDropEvents').length; i++) { if (OB.MobileApp.model.get('cashMgmtDropEvents')[i].isocode === paymentMethod.isocode && paymentMethod.paymentMethod.paymentMethod === OB.MobileApp.model.get('cashMgmtDropEvents')[i].paymentmethod) { - buttons.push({ + this.buttons.push({ idSufix: 'Withdrawal.' + paymentMethod.isocode, command: payment.searchKey + '_' + OB.I18N.getLabel('OBPOS_LblWithdrawal'), definition: this.getPayment(payment.id, payment.searchKey, paymentMethod.paymentMethod.iscash, paymentMethod.paymentMethod.allowopendrawer, payment._identifier, payment._identifier, 'drop', paymentMethod.rate, paymentMethod.isocode, paymentMethod.paymentMethod.gLItemForDrops, paymentMethod.paymentMethod.paymentMethod), @@ -132,11 +146,11 @@ buttons: [] }, function (args) { _.each(args.buttons, function (btn) { - buttons.push(btn); + args.context.buttons.push(btn); }); args.context.addToolbar({ name: 'cashMgmtToolbar', - buttons: buttons + buttons: args.context.buttons }); args.context.showToolbar('cashMgmtToolbar'); }); @@ -144,5 +158,10 @@ initComponents: function () { this.inherited(arguments); this.keyMatcher = new RegExp('^([0-9]|\\' + OB.Format.defaultDecimalSymbol + ')$', 'g'); + OB.UTIL.ProcessController.subscribe(this.processesToListen, this); + }, + destroyComponents: function () { + this.inherited(arguments); + OB.UTIL.ProcessController.unSubscribe(this.processesToListen, this); } }); \ No newline at end of file diff --git a/web/org.openbravo.retail.posterminal/js/components/mockpayments.js b/web/org.openbravo.retail.posterminal/js/components/mockpayments.js --- a/web/org.openbravo.retail.posterminal/js/components/mockpayments.js +++ b/web/org.openbravo.retail.posterminal/js/components/mockpayments.js @@ -73,19 +73,22 @@ i18nContent: 'OBMOBC_LblOk', isDefaultAction: true, tap: function () { - this.owner.receipt.addPayment(new OB.Model.PaymentLine({ - 'kind': (this.owner.isReversePayment) ? this.owner.reversedPayment.get('kind') : this.owner.key, - 'name': this.owner.paymentType, - 'amount': this.owner.paymentAmount, - 'allowOpenDrawer': this.owner.allowOpenDrawer, - 'isCash': this.owner.isCash, - 'openDrawer': this.owner.openDrawer, - 'printtwice': this.owner.printtwice, - 'isReversePayment': this.owner.isReversePayment, - 'reversedPaymentId': this.owner.reversedPaymentId, - 'reversedPayment': this.owner.reversedPayment - })); - + if (this.owner.receipt) { + this.owner.receipt.addPayment(new OB.Model.PaymentLine({ + 'kind': (this.owner.isReversePayment) ? this.owner.reversedPayment.get('kind') : this.owner.key, + 'name': this.owner.paymentType, + 'amount': this.owner.paymentAmount, + 'allowOpenDrawer': this.owner.allowOpenDrawer, + 'isCash': this.owner.isCash, + 'openDrawer': this.owner.openDrawer, + 'printtwice': this.owner.printtwice, + 'isReversePayment': this.owner.isReversePayment, + 'reversedPaymentId': this.owner.reversedPaymentId, + 'reversedPayment': this.owner.reversedPayment + })); + } else if (this.owner.cashManagement) { + this.owner.cashManagement.depsdropstosave.trigger('makeDeposits'); + } this.doHideThisPopup(); } }); \ No newline at end of file diff --git a/web/org.openbravo.retail.posterminal/js/components/modalpayment.js b/web/org.openbravo.retail.posterminal/js/components/modalpayment.js --- a/web/org.openbravo.retail.posterminal/js/components/modalpayment.js +++ b/web/org.openbravo.retail.posterminal/js/components/modalpayment.js @@ -1,6 +1,6 @@ /* ************************************************************************************ - * Copyright (C) 2012-2017 Openbravo S.L.U. + * Copyright (C) 2012-2018 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 @@ bodyContent: {}, executeOnShow: function () { - this.$.header.setContent(this.args.receipt.getTotal() > 0 ? OB.I18N.getLabel('OBPOS_LblModalPayment', [OB.I18N.formatCurrency(this.args.amount)]) : OB.I18N.getLabel('OBPOS_LblModalReturn', [OB.I18N.formatCurrency(this.args.amount)])); + this.$.header.setContent(this.args.receipt && this.args.receipt.getTotal() > 0 ? OB.I18N.getLabel('OBPOS_LblModalPayment', [OB.I18N.formatCurrency(this.args.amount)]) : OB.I18N.getLabel('OBPOS_LblModalReturn', [OB.I18N.formatCurrency(this.args.amount)])); this.$.bodyContent.destroyComponents(); //default values to reset changes done by a payment method @@ -35,6 +35,7 @@ isocode: this.args.isocode, key: this.args.key, receipt: this.args.receipt, + cashManagement: this.args.cashManagement, allowOpenDrawer: this.args.paymentMethod.allowopendrawer, isCash: this.args.paymentMethod.iscash, openDrawer: this.args.paymentMethod.openDrawer, diff --git a/web/org.openbravo.retail.posterminal/js/pointofsale/view/modals/modalpayments.js b/web/org.openbravo.retail.posterminal/js/pointofsale/view/modals/modalpayments.js --- a/web/org.openbravo.retail.posterminal/js/pointofsale/view/modals/modalpayments.js +++ b/web/org.openbravo.retail.posterminal/js/pointofsale/view/modals/modalpayments.js @@ -1,13 +1,13 @@ /* ************************************************************************************ - * Copyright (C) 2015-2017 Openbravo S.L.U. + * Copyright (C) 2015-2018 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. ************************************************************************************ */ -/*global enyo, Backbone, */ +/*global enyo, Backbone, _ */ enyo.kind({ kind: 'OB.UI.Modal', @@ -84,17 +84,20 @@ if (!item.disabled) { var dialog = this.owner.owner.owner; dialog.doHideThisPopup(); - dialog.bubble('onStatusChanged', { - payment: this.payment, - status: this.payment.payment.searchKey, - amount: dialog.args.amount, - options: dialog.args.options - }); + dialog.selectItem = true; dialog.bubble('onPaymentChanged', { payment: this.payment, status: this.payment.payment.searchKey, amount: dialog.args.amount }); + if (!dialog.args.cashManagement) { + dialog.bubble('onStatusChanged', { + payment: this.payment, + status: this.payment.payment.searchKey, + amount: dialog.args.amount, + options: dialog.args.options + }); + } } }, initComponents: function () { @@ -120,19 +123,35 @@ var items = [], payments = OB.POS.modelterminal.get('payments'), filterBy = this.$.body.$.paymentname.getValue().toUpperCase(); - enyo.forEach(payments, function (payment) { - if (payment.paymentMethod.paymentMethodCategory && payment.paymentMethod.paymentMethodCategory === this.args.idCategory && OB.MobileApp.model.hasPermission(payment.payment.searchKey)) { - if (filterBy === '' || payment.paymentMethod._identifier.toUpperCase().indexOf(filterBy) >= 0) { - var isDisabled = (OB.MobileApp.model.receipt.getTotal() < 0 ? !payment.paymentMethod.refundable : false); + if (this.args.availables) { + enyo.forEach(this.args.availables, function (sk) { + var payment = _.find(payments, function (pay) { + return pay.paymentMethod.searchKey === sk; + }); + if (payment) { items.push({ name: payment.paymentMethod._identifier, image: payment.image, payment: payment, - disabled: isDisabled + disabled: false }); } - } - }, this); + }, this); + } else { + enyo.forEach(payments, function (payment) { + if (payment.paymentMethod.paymentMethodCategory && payment.paymentMethod.paymentMethodCategory === this.args.idCategory && OB.MobileApp.model.hasPermission(payment.payment.searchKey)) { + if (filterBy === '' || payment.paymentMethod._identifier.toUpperCase().indexOf(filterBy) >= 0) { + var isDisabled = (OB.MobileApp.model.receipt.getTotal() < 0 ? !payment.paymentMethod.refundable : false); + items.push({ + name: payment.paymentMethod._identifier, + image: payment.image, + payment: payment, + disabled: isDisabled + }); + } + } + }, this); + } this.$.body.$.paymentMethods.setItems(items); var me = this; setTimeout(function () { @@ -144,5 +163,13 @@ this.searchAction(); this.bubble('onClearPaymentSelect'); this.bubble('onPaymentChanged'); + this.selectItem = false; + }, + executeOnHide: function () { + if (!this.selectItem) { + this.bubble('onPaymentChangedCancelled', { + cashManagement: this.args.cashManagement + }); + } } }); \ No newline at end of file diff --git a/web/org.openbravo.retail.posterminal/js/pointofsale/view/pointofsale.js b/web/org.openbravo.retail.posterminal/js/pointofsale/view/pointofsale.js --- a/web/org.openbravo.retail.posterminal/js/pointofsale/view/pointofsale.js +++ b/web/org.openbravo.retail.posterminal/js/pointofsale/view/pointofsale.js @@ -68,6 +68,7 @@ onLineChecked: 'checkedLine', onStatusChanged: 'statusChanged', onPaymentChanged: 'paymentChanged', + onPaymentChangedCancelled: 'paymentChangedCancelled', onPaymentActionPay: 'paymentActionPay', onClearPaymentSelect: 'clearPaymentSelect', onLayaways: 'layaways', @@ -1234,6 +1235,10 @@ // sending the event to the components bellow this one this.waterfall('onButtonPaymentChanged', inEvent); }, + paymentChangedCancelled: function (inSender, inEvent) { + // sending the event to the components bellow this one + this.waterfall('onButtonPaymentChangedCancelled', inEvent); + }, paymentActionPay: function (inSender, inEvent) { // sending the event to the components bellow this one this.waterfall('onActionPay', inEvent); pi-mobile.diff [^] (21,395 bytes) 2018-11-12 13:24 [Show Content] [Hide Content] diff --git a/src-test/org/openbravo/test/mobile/retail/extmodules/selenium/TestIdExtModules.java b/src-test/org/openbravo/test/mobile/retail/extmodules/selenium/TestIdExtModules.java --- a/src-test/org/openbravo/test/mobile/retail/extmodules/selenium/TestIdExtModules.java +++ b/src-test/org/openbravo/test/mobile/retail/extmodules/selenium/TestIdExtModules.java @@ -110,6 +110,8 @@ "bodyContent_expirationDate"); // public static TestIdConstructor BUTTON_GIFTCARDPAYMENT_CANCEL = new TestIdConstructor( "bodyButtons_cancelDialogButton", EnyoKind.BUTTON); // + public static TestIdConstructor BUTTON_GIFTCARDPAYMENT_RETURN = new TestIdConstructor( + "bodyButtons_returnbutton", EnyoKind.BUTTON); // public static TestIdConstructor DATEPICKER_POPUP_GIFT_CERTIFICATE = new TestIdConstructor( "newAttribute_giftcardExpirationDate"); // public static TestIdConstructor GIFTCARD_CATEGORY_COMBO = new TestIdConstructor( @@ -342,6 +344,18 @@ public static TestIdConstructor BUTTON_FIRSTROW_CREDITNOTE = new TestIdConstructor( "stGCAssignToReceipt_row1_listGCsSelectorLine", EnyoKind.BUTTON); // + // Reimburse gift card in different payment method + public static TestIdConstructor FIELD_CASHMGMT_REIMBURSE_AMOUNT = new TestIdConstructor( + "bodyButtons_btnModalReimburseAmountSearchInput"); // + public static TestIdConstructor BUTTON_CASHMGMT_REIMBURSE_APPLY = new TestIdConstructor( + "bodyButtons_btnApplyReimburse", EnyoKind.BUTTON); // + public static TestIdConstructor BUTTON_CASHMGMT_PAYMENT_CARD = new TestIdConstructor( + "paymentMethods_row2_reimbursePaymentMethodsLine", EnyoKind.BUTTON); // + public static TestIdConstructor BUTTON_CASHMGMT_PAYMENT_CASH = new TestIdConstructor( + "paymentMethods_row3_reimbursePaymentMethodsLine", EnyoKind.BUTTON); // + public static TestIdConstructor BUTTON_MOCKPAYMENT_OK = new TestIdConstructor( + "mockPayment_OkButton", EnyoKind.BUTTON); // + // Best Deal Case public static TestIdConstructor BUTTON_SEARCHPRODUCT_WHISTLE_SHOWPRODSK = new TestIdConstructor( "WVG/B0007 - Whistle", EnyoKind.SEARCHPRODUCT); // diff --git a/src-test/org/openbravo/test/mobile/retail/extmodules/selenium/tests/creditnote/CreditNoteReimburse.java b/src-test/org/openbravo/test/mobile/retail/extmodules/selenium/tests/creditnote/CreditNoteReimburse.java --- a/src-test/org/openbravo/test/mobile/retail/extmodules/selenium/tests/creditnote/CreditNoteReimburse.java +++ b/src-test/org/openbravo/test/mobile/retail/extmodules/selenium/tests/creditnote/CreditNoteReimburse.java @@ -159,7 +159,9 @@ verify(TestIdExtModules.LABEL_INITIAL_BALANCE, "150.50"); verify(TestIdExtModules.LABEL_CURRENT_BALANCEE, "136.00"); tap(TestIdExtModules.BUTTON_CREDITNOTE_MODAL_APPLY); - + verify(TestIdExtModules.FIELD_CASHMGMT_REIMBURSE_AMOUNT, "136.00"); + tap(TestIdExtModules.BUTTON_CASHMGMT_REIMBURSE_APPLY); + tap(TestIdExtModules.BUTTON_CASHMGMT_PAYMENT_CASH); verify(TestIdExtModules.BUTTON_CASHMGMT_REIMBURSED_BODY, "Reimbursed: 136.00€"); tap(TestIdExtModules.BUTTON_CASHMGMT_REIMBURSED_OKBUTTON); tap(TestIdExtModules.BUTTON_CASHMANAGEMENT_DONE); diff --git a/src-test/org/openbravo/test/mobile/retail/extmodules/selenium/tests/giftcards/I38405_VerifyCashUpWhenGiftCardIsRefunded.java b/src-test/org/openbravo/test/mobile/retail/extmodules/selenium/tests/giftcards/I38405_VerifyCashUpWhenGiftCardIsRefunded.java --- a/src-test/org/openbravo/test/mobile/retail/extmodules/selenium/tests/giftcards/I38405_VerifyCashUpWhenGiftCardIsRefunded.java +++ b/src-test/org/openbravo/test/mobile/retail/extmodules/selenium/tests/giftcards/I38405_VerifyCashUpWhenGiftCardIsRefunded.java @@ -22,16 +22,22 @@ package org.openbravo.test.mobile.retail.extmodules.selenium.tests.giftcards; +import java.sql.ResultSet; +import java.sql.SQLException; + import org.junit.Test; import org.openbravo.test.mobile.core.utils.OBUtils; import org.openbravo.test.mobile.retail.extmodules.selenium.TestIdExtModules; import org.openbravo.test.mobile.retail.extmodules.selenium.terminals.WebPOSExtModulesTerminalHelper; +import org.openbravo.test.mobile.retail.mobilecore.database.DatabaseHelperSelect; import org.openbravo.test.mobile.retail.mobilecore.javascript.SynchronizationMonitor; import org.openbravo.test.mobile.retail.mobilecore.selenium.TestIdCore; import org.openbravo.test.mobile.retail.mobilecore.utils.ApplicationWindow; import org.openbravo.test.mobile.retail.pack.selenium.TestIdPack; public class I38405_VerifyCashUpWhenGiftCardIsRefunded extends WebPOSExtModulesTerminalHelper { + private String numberGiftCard = ""; + @Test public void test() { cleanCashup(); @@ -47,11 +53,15 @@ tap(TestIdCore.BUTTON_MENU); tap(TestIdPack.BUTTON_MENU_CASHMANAGEMENT); tap(TestIdExtModules.BUTTON_CASHMANAGEMENT_GIFTCARD); + write(TestIdExtModules.FIELD_GIFTCARDPAYMENT_CARDID, numberGiftCard); tap(TestIdExtModules.BUTTON_GIFTCARDPAYMENT_SEARCH); tap(TestIdExtModules.GIFTCARD_CASHMNG_ROW1); // verify that the selected giftcard is the correct one verify(TestIdExtModules.LABEL_GIFTCARDS_AMOUNT, "33.00"); tap(TestIdExtModules.BUTTON_GIFTCARDPAYMENT_DETAILSAPPLY); + verify(TestIdExtModules.FIELD_CASHMGMT_REIMBURSE_AMOUNT, "33.00"); + tap(TestIdExtModules.BUTTON_CASHMGMT_REIMBURSE_APPLY); + tap(TestIdExtModules.BUTTON_CASHMGMT_PAYMENT_CASH); tap(TestIdExtModules.BUTTON_GIFTCARD_ACEPTMESSAGE); tap(TestIdPack.BUTTON_CASHMANAGEMENT_DONE); tap(TestIdPack.BUTTON_POPUP_OK); @@ -77,6 +87,7 @@ } private void createGiftCardReimbursed(int amount) { + searchSequense(); tap(TestIdExtModules.BUTTON_MENU); tap(TestIdExtModules.BUTTON_MENU_GIFT_CERTICATE); TestIdExtModules.GIFTCARD_CATEGORY_COMBO.enyoNode().executeExtension(".setSelected(3)"); @@ -85,7 +96,17 @@ write(TestIdExtModules.INPUT_GIFTCARD_AMOUNT, String.valueOf(amount)); tap(TestIdExtModules.BUTTON_SPLITLINE_APPLY); OBUtils.pause(2000); - ; + } + + private void searchSequense() { + final String sql = "SELECT em_gcnv_gcseq_lastnum AS lastnumber FROM obpos_applications WHERE obpos_applications_id = '4BDE301A4275465AB7BCB15395699821'"; + new DatabaseHelperSelect() { + @Override + protected void yieldResultSet(final ResultSet rs) throws SQLException { + long nextNum = rs.getLong("lastnumber") + 1l; + numberGiftCard = "YS-11" + String.format("%07d", nextNum); + } + }.execute(sql, 1); } private void cleanCashup() { diff --git a/src-test/org/openbravo/test/mobile/retail/extmodules/selenium/tests/giftcards/I39200_ReimburseInDifferentPaymentMethods.java b/src-test/org/openbravo/test/mobile/retail/extmodules/selenium/tests/giftcards/I39200_ReimburseInDifferentPaymentMethods.java new file mode 100644 --- /dev/null +++ b/src-test/org/openbravo/test/mobile/retail/extmodules/selenium/tests/giftcards/I39200_ReimburseInDifferentPaymentMethods.java @@ -0,0 +1,242 @@ +/* + ************************************************************************* + * The contents of this file are subject to the Openbravo Public License + * Version 1.0 (the "License"), being the Mozilla Public License + * Version 1.1 with a permitted attribution clause; you may not use this + * file except in compliance with the License. You may obtain a copy of + * the License at http://www.openbravo.com/legal/license.html + * Software distributed under the License is distributed on an "AS IS" + * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the + * License for the specific language governing rights and limitations + * under the License. + * The Original Code is Openbravo ERP. + * The Initial Developer of the Original Code is Openbravo S.L.U. + * All portions are Copyright (C) 2018 Openbravo S.L.U. + * All Rights Reserved. + * Contributor(s): + ************************************************************************ + * + * @author EBE + * + */ +package org.openbravo.test.mobile.retail.extmodules.selenium.tests.giftcards; + +import static org.junit.Assert.assertEquals; + +import java.sql.ResultSet; +import java.sql.SQLException; + +import org.junit.Test; +import org.openbravo.test.mobile.core.utils.OBUtils; +import org.openbravo.test.mobile.retail.extmodules.selenium.TestIdExtModules; +import org.openbravo.test.mobile.retail.extmodules.selenium.terminals.WebPOSExtModulesTerminalHelper; +import org.openbravo.test.mobile.retail.mobilecore.database.DatabaseHelperSelect; +import org.openbravo.test.mobile.retail.pack.API.WebPOSAPI; + +public class I39200_ReimburseInDifferentPaymentMethods extends WebPOSExtModulesTerminalHelper { + + private String numberGiftCard = ""; + private static final double DELTA = 1e-15; + + @Test + public void testReimburseFromCashManagement() { + WebPOSAPI.cleanCashup(this); + logIn(); + createGiftCardReimbursable(); + + // Pay a ticket with Cash + tap(TestIdExtModules.BUTTON_SEARCH); + write(TestIdExtModules.FIELD_SEARCH_TEXT, "Avalanche"); + tap(TestIdExtModules.BUTTON_SEARCH_EXECUTE); + tap(TestIdExtModules.BUTTON_SEARCHPRODUCT_AVALANCHETRANSCEIVERWVG); + tap(TestIdExtModules.BUTTON_PAY); + tap(TestIdExtModules.BUTTON_PAY_EXACT); + tap(TestIdExtModules.BUTTON_PAY_DONE); + verify(TestIdExtModules.LABEL_TOTALTOPAY, "0.00"); + + // Cash Management + makeReimburse("50.00", "50.00", false); + + // Verify ERP + verifyGiftCardInstance("C", 50.0, 0.0, 50.0, true); + verifyGiftCardHistory("Cash", "Cash - Gift Card - Reimburse", 150.5, 50.0, 50.0); + } + + @Test + public void testReimburseFromDetailWindow() { + WebPOSAPI.cleanCashup(this); + logIn(); + createGiftCardReimbursable(); + + tap(TestIdExtModules.BUTTON_MENU); + tap(TestIdExtModules.BUTTON_MENU_GIFT_CARDSVOUCHERS); + + write(TestIdExtModules.FIELD_SEARCH_GIFTCARD, numberGiftCard); + tap(TestIdExtModules.BUTTON_SEARCH_GIFTCARD); + OBUtils.pause(2000); + tap(TestIdExtModules.GIFTCARD_LIST_ROW1); + + verify(TestIdExtModules.LABEL_GIFTCARDS_SEARCHKEY, numberGiftCard); + verify(TestIdExtModules.LABEL_GIFTCARDS_STATUS, "New"); + verify(TestIdExtModules.LABEL_GIFTCARDS_CATEGORY, "Refund the difference"); + verify(TestIdExtModules.LABEL_GIFTCARDS_BP, "Arturo Montoro"); + verify(TestIdExtModules.LABEL_GIFTCARDS_AMOUNT, "50.00"); + verify(TestIdExtModules.LABEL_GIFTCARDS_CURRENTAMOUNT, "50.00"); + verify(TestIdExtModules.LABEL_GIFTCARDS_EXPIRIATIONDATE, "09-12-2116"); + + tap(TestIdExtModules.BUTTON_GIFTCARDPAYMENT_RETURN); + OBUtils.pause(2000); + verify(TestIdExtModules.LABEL_GIFTCARDS_SEARCHKEY, numberGiftCard); + tap(TestIdExtModules.BUTTON_GIFTCARDPAYMENT_APPLY); + verify(TestIdExtModules.FIELD_CASHMGMT_REIMBURSE_AMOUNT, "50.00"); + tap(TestIdExtModules.BUTTON_CASHMGMT_REIMBURSE_APPLY); + tap(TestIdExtModules.BUTTON_CASHMGMT_PAYMENT_CARD); + verify(TestIdExtModules.LABEL_GIFTCARD_BODY_MESSAGE, "Reimbursed: 50.00€"); + tap(TestIdExtModules.BUTTON_GIFTCARD_ACEPTMESSAGE); + tap(TestIdExtModules.BUTTON_CASHMANAGEMENT_DONE); + tap(TestIdExtModules.BUTTON_MOCKPAYMENT_OK); + tap(TestIdExtModules.BUTTON_POPUP_OK); + + // Verify ERP + verifyGiftCardInstance("C", 50.0, 0.0, 50.0, true); + verifyGiftCardHistory("Card", "Card - Gift Cards - Reimbursed (Wire Transfer)", 0.0, 50.0, 50.0); + } + + @Test + public void testReimbursePartialAmount() { + WebPOSAPI.cleanCashup(this); + logIn(); + createGiftCardReimbursable(); + + // Make a partial reimburse (20.00) + makeReimburse("50.00", "20.00", true); + verifyGiftCardInstance("P", 50.0, 30.0, 20.0, false); + verifyGiftCardHistory("Card", "Card - Gift Cards - Reimbursed (Wire Transfer)", 0.0, 20.0, 20.0); + + // Make complete partial reimburse (30.00) + makeReimburse("30.00", "30.00", true); + verifyGiftCardInstance("C", 50.0, 0.0, 30.0, true); + verifyGiftCardHistory("Card", "Card - Gift Cards - Reimbursed (Wire Transfer)", 0.0, 50.0, 30.0); + } + + private void makeReimburse(String checkAmount, String reimburseAmount, boolean cardPayment) { + tap(TestIdExtModules.BUTTON_MENU); + tap(TestIdExtModules.BUTTON_MENU_CASHMANAGEMENT); + tap(TestIdExtModules.BUTTON_CASHMANAGEMENT_GIFTCARD); + write(TestIdExtModules.FIELD_GIFTCARDPAYMENT_CARDID, numberGiftCard); + tap(TestIdExtModules.BUTTON_GIFTCARDPAYMENT_SEARCH); + tap(TestIdExtModules.BUTTON_GIFTCARDPAYMENT_APPLY); + verify(TestIdExtModules.FIELD_CASHMGMT_REIMBURSE_AMOUNT, checkAmount); + write(TestIdExtModules.FIELD_CASHMGMT_REIMBURSE_AMOUNT, reimburseAmount); + tap(TestIdExtModules.BUTTON_CASHMGMT_REIMBURSE_APPLY); + tap(cardPayment ? TestIdExtModules.BUTTON_CASHMGMT_PAYMENT_CARD + : TestIdExtModules.BUTTON_CASHMGMT_PAYMENT_CASH); + verify(TestIdExtModules.LABEL_GIFTCARD_BODY_MESSAGE, "Reimbursed: " + reimburseAmount + "€"); + tap(TestIdExtModules.BUTTON_GIFTCARD_ACEPTMESSAGE); + tap(TestIdExtModules.BUTTON_CASHMANAGEMENT_DONE); + if (cardPayment) { + tap(TestIdExtModules.BUTTON_MOCKPAYMENT_OK); + } + tap(TestIdExtModules.BUTTON_POPUP_OK); + } + + private void verifyGiftCardInstance(final String status, final double initialAmount, + final double currentamount, final double amount, final boolean iscancelled) { + String sql = "SELECT gcnv_giftcard_inst_id, status, amount, currentamount FROM gcnv_giftcard_inst WHERE value = '" + + numberGiftCard + "'"; + + new DatabaseHelperSelect() { + + @Override + protected void yieldResultSet(ResultSet rs) throws SQLException { + assertEquals(status, rs.getString("status")); + assertEquals(initialAmount, rs.getDouble("amount"), DELTA); + assertEquals(currentamount, rs.getDouble("currentamount"), DELTA); + + String giftcardInstId = rs.getString("gcnv_giftcard_inst_id"); + String transSQL = "SELECT amount FROM gcnv_giftcard_trans WHERE iscancelled = " + + (iscancelled ? "'Y'" : "'N'") + " and gcnv_giftcard_inst_id = '" + giftcardInstId + + "'"; + + new DatabaseHelperSelect() { + + @Override + protected void yieldResultSet(ResultSet rsTransation) throws SQLException { + assertEquals(amount, rsTransation.getDouble("amount"), DELTA); + } + }.execute(transSQL, 1, false); + } + }.execute(sql, 1); + } + + private void verifyGiftCardHistory(final String paymentMethod, final String paymentName, + final double totalSales, final double totalDrops, final double amount) { + String sql = "SELECT pm.obpos_paymentmethodcashup_id, pm.totalsales, pm.totaldrops " + + "FROM obpos_applications t JOIN obpos_app_cashup c ON t.obpos_applications_id = c.obpos_applications_id " + + "JOIN obpos_paymentmethodcashup pm ON pm.obpos_app_cashup_id = c.obpos_app_cashup_id " + + "JOIN obpos_app_payment p ON pm.obpos_app_payment_id = p.obpos_app_payment_id " + + "WHERE t.value = 'YS-11' AND c.isprocessed = 'N' AND p.name = '" + paymentMethod + + "' ORDER BY cashupdate DESC"; + + new DatabaseHelperSelect() { + + @Override + protected void yieldResultSet(ResultSet rs) throws SQLException { + assertEquals(totalSales, rs.getDouble("totalsales"), DELTA); + assertEquals(totalDrops, rs.getDouble("totaldrops"), DELTA); + + String paymentmethodcashupId = rs.getString("obpos_paymentmethodcashup_id"); + String eventsSQL = "SELECT name, type FROM OBPOS_Paymentcashup_Events WHERE obpos_paymentmethodcashup_id = '" + + paymentmethodcashupId + "' and amount = " + amount; + + new DatabaseHelperSelect() { + + @Override + protected void yieldResultSet(ResultSet rsEvent) throws SQLException { + assertEquals(paymentName, rsEvent.getString("name")); + assertEquals("drop", rsEvent.getString("type")); + } + }.execute(eventsSQL, 1, false); + } + }.execute(sql, 1); + } + + private void searchSequense() { + final String sql = "SELECT em_gcnv_gcseq_lastnum AS num FROM obpos_applications WHERE obpos_applications_id = '4BDE301A4275465AB7BCB15395699821'"; + new DatabaseHelperSelect() { + @Override + protected void yieldResultSet(final ResultSet rs) throws SQLException { + long nextNum = rs.getLong("num") + 1l; + numberGiftCard = "YS-11" + String.format("%07d", nextNum); + } + }.execute(sql, 1); + } + + private void verifyGiftCardInstance(String value) { + String sqlBackoffice = "select amount, currentamount, type, status, gcnv_giftcard_reason_id" + + " from gcnv_giftcard_inst " + " where value = '" + value + "'"; + new DatabaseHelperSelect() { + + @Override + protected void yieldResultSet(ResultSet rs) throws SQLException { + assertEquals("BasedOnGLItem", rs.getString("type")); + assertEquals("N", rs.getString("status")); + assertEquals(50, rs.getInt("amount")); + assertEquals(50, rs.getInt("currentamount")); + } + }.execute(sqlBackoffice, 1); + } + + private void createGiftCardReimbursable() { + searchSequense(); + tap(TestIdExtModules.BUTTON_MENU); + tap(TestIdExtModules.BUTTON_MENU_GIFT_CERTICATE); + TestIdExtModules.GIFTCARD_CATEGORY_COMBO.enyoNode().executeExtension(".setSelected(3)"); + TestIdExtModules.DATEPICKER_POPUP_GIFT_CERTIFICATE.enyoNode().executeExtension( + ".setValue(new Date('12/09/2116')) "); + write(TestIdExtModules.INPUT_GIFTCARD_AMOUNT, "50"); + tap(TestIdExtModules.BUTTON_SPLITLINE_APPLY); + verifyGiftCardInstance(numberGiftCard); + } + +} \ No newline at end of file diff --git a/src-test/org/openbravo/test/mobile/retail/extmodules/selenium/tests/giftcards/ReimburseCard.java b/src-test/org/openbravo/test/mobile/retail/extmodules/selenium/tests/giftcards/ReimburseCard.java --- a/src-test/org/openbravo/test/mobile/retail/extmodules/selenium/tests/giftcards/ReimburseCard.java +++ b/src-test/org/openbravo/test/mobile/retail/extmodules/selenium/tests/giftcards/ReimburseCard.java @@ -81,8 +81,6 @@ tap(TestIdExtModules.BUTTON_SEARCH_EXECUTE); tap(TestIdExtModules.BUTTON_SEARCHPRODUCT_HEADLAMPULTRALIGHTWVG); tap(TestIdExtModules.BUTTON_PAY); - // tap(TestIdExtModules.BUTTON_MORE_PAYMENTS_DIV); - // TestIdExtModules.BUTTON_PAYMENT_GIFTCARD.enyoNode().waitUntilIsReady(100); tap(TestIdExtModules.BUTTON_PAYMENT_GIFTCERTIFICATE); tap(TestIdExtModules.BUTTON_PAY_EXACT); write(TestIdExtModules.FIELD_GIFTCARDPAYMENT_CARDID, numberGiftCard); @@ -116,6 +114,9 @@ write(TestIdExtModules.FIELD_GIFTCARDPAYMENT_CARDID, numberGiftCard); tap(TestIdExtModules.BUTTON_GIFTCARDPAYMENT_SEARCH); tap(TestIdExtModules.BUTTON_GIFTCARDPAYMENT_APPLY); + verify(TestIdExtModules.FIELD_CASHMGMT_REIMBURSE_AMOUNT, "31.10"); + tap(TestIdExtModules.BUTTON_CASHMGMT_REIMBURSE_APPLY); + tap(TestIdExtModules.BUTTON_CASHMGMT_PAYMENT_CASH); verify(TestIdExtModules.LABEL_GIFTCARD_BODY_MESSAGE, "Reimbursed: 31.10€"); tap(TestIdExtModules.BUTTON_GIFTCARD_ACEPTMESSAGE); tap(TestIdExtModules.BUTTON_CASHMANAGEMENT_DONE); @@ -169,6 +170,7 @@ } private void verifyCashUpHistory() { + // Gift Certificate String sql = "SELECT pm.totalsales, pm.totaldeposits, pm.totaldrops FROM obpos_applications t JOIN obpos_app_cashup c ON t.obpos_applications_id = c.obpos_applications_id JOIN obpos_paymentmethodcashup pm ON pm.obpos_app_cashup_id = c.obpos_app_cashup_id JOIN obpos_app_payment p ON pm.obpos_app_payment_id = p.obpos_app_payment_id WHERE t.value = 'YS-11' AND c.isprocessed = 'N' AND p.name = 'Gift Certificate' ORDER BY cashupdate DESC"; new DatabaseHelperSelect() { @@ -181,6 +183,7 @@ } }.execute(sql, 1); + // Cash sql = "SELECT pm.totalsales, pm.totaldeposits, pm.totaldrops FROM obpos_applications t JOIN obpos_app_cashup c ON t.obpos_applications_id = c.obpos_applications_id JOIN obpos_paymentmethodcashup pm ON pm.obpos_app_cashup_id = c.obpos_app_cashup_id JOIN obpos_app_payment p ON pm.obpos_app_payment_id = p.obpos_app_payment_id WHERE t.value = 'YS-11' AND c.isprocessed = 'N' AND p.name = 'Cash' ORDER BY cashupdate DESC"; new DatabaseHelperSelect() { diff --git a/src-test/org/openbravo/test/mobile/retail/extmodules/selenium/tests/giftcards/TryReimburseCardNotReimbursable.java b/src-test/org/openbravo/test/mobile/retail/extmodules/selenium/tests/giftcards/TryReimburseCardNotReimbursable.java --- a/src-test/org/openbravo/test/mobile/retail/extmodules/selenium/tests/giftcards/TryReimburseCardNotReimbursable.java +++ b/src-test/org/openbravo/test/mobile/retail/extmodules/selenium/tests/giftcards/TryReimburseCardNotReimbursable.java @@ -63,7 +63,7 @@ tap(TestIdExtModules.BUTTON_GIFTCARDPAYMENT_SEARCH); tap(TestIdExtModules.BUTTON_GIFTCARDPAYMENT_APPLY); verify(TestIdExtModules.LABEL_GIFTCARD_BODY_MESSAGE, "Gift card with ID " + numberGiftCard - + " is not reimbursable"); + + " is not reimbursable. The gift card category must be: Refund the difference"); tap(TestIdExtModules.BUTTON_GIFTCARD_ACEPTMESSAGE); tap(TestIdExtModules.BUTTON_GIFTCARDPAYMENT_CANCEL); tap(TestIdExtModules.BUTTON_GIFTCARD_MODAL_CLOSESELECTOR); giftcards.diff [^] (91,538 bytes) 2018-11-12 14:07 [Show Content] [Hide Content] diff --git a/src-db/database/sourcedata/AD_COLUMN.xml b/src-db/database/sourcedata/AD_COLUMN.xml --- a/src-db/database/sourcedata/AD_COLUMN.xml +++ b/src-db/database/sourcedata/AD_COLUMN.xml @@ -2937,7 +2937,7 @@ <!--C794D2141935481B9D95A513A4D5421B--> <ISDESENCRYPTABLE><![CDATA[N]]></ISDESENCRYPTABLE> <!--C794D2141935481B9D95A513A4D5421B--> <DEVELOPMENTSTATUS><![CDATA[RE]]></DEVELOPMENTSTATUS> <!--C794D2141935481B9D95A513A4D5421B--> <AD_MODULE_ID><![CDATA[17B5337C4B1948DF857B12FD3ABE5094]]></AD_MODULE_ID> -<!--C794D2141935481B9D95A513A4D5421B--> <POSITION><![CDATA[52]]></POSITION> +<!--C794D2141935481B9D95A513A4D5421B--> <POSITION><![CDATA[49]]></POSITION> <!--C794D2141935481B9D95A513A4D5421B--> <ISTRANSIENT><![CDATA[N]]></ISTRANSIENT> <!--C794D2141935481B9D95A513A4D5421B--> <ISAUTOSAVE><![CDATA[Y]]></ISAUTOSAVE> <!--C794D2141935481B9D95A513A4D5421B--> <VALIDATEONNEW><![CDATA[Y]]></VALIDATEONNEW> diff --git a/src-db/database/sourcedata/AD_MESSAGE.xml b/src-db/database/sourcedata/AD_MESSAGE.xml --- a/src-db/database/sourcedata/AD_MESSAGE.xml +++ b/src-db/database/sourcedata/AD_MESSAGE.xml @@ -156,6 +156,18 @@ <!--1986D965D1DC4C8386DD0C2AB6259609--> <ISINCLUDEINI18N><![CDATA[N]]></ISINCLUDEINI18N> <!--1986D965D1DC4C8386DD0C2AB6259609--></AD_MESSAGE> +<!--20D896FF304B4B4CB17E4D44F4D40337--><AD_MESSAGE> +<!--20D896FF304B4B4CB17E4D44F4D40337--> <AD_MESSAGE_ID><![CDATA[20D896FF304B4B4CB17E4D44F4D40337]]></AD_MESSAGE_ID> +<!--20D896FF304B4B4CB17E4D44F4D40337--> <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID> +<!--20D896FF304B4B4CB17E4D44F4D40337--> <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID> +<!--20D896FF304B4B4CB17E4D44F4D40337--> <ISACTIVE><![CDATA[Y]]></ISACTIVE> +<!--20D896FF304B4B4CB17E4D44F4D40337--> <VALUE><![CDATA[GCNV_ErrorGiftCardNotAllowdrops]]></VALUE> +<!--20D896FF304B4B4CB17E4D44F4D40337--> <MSGTEXT><![CDATA[The selected payment method doesn't allow drops.]]></MSGTEXT> +<!--20D896FF304B4B4CB17E4D44F4D40337--> <MSGTYPE><![CDATA[I]]></MSGTYPE> +<!--20D896FF304B4B4CB17E4D44F4D40337--> <AD_MODULE_ID><![CDATA[17B5337C4B1948DF857B12FD3ABE5094]]></AD_MODULE_ID> +<!--20D896FF304B4B4CB17E4D44F4D40337--> <ISINCLUDEINI18N><![CDATA[N]]></ISINCLUDEINI18N> +<!--20D896FF304B4B4CB17E4D44F4D40337--></AD_MESSAGE> + <!--2375C32E5E1A4BC7B4F64B9C419E42EA--><AD_MESSAGE> <!--2375C32E5E1A4BC7B4F64B9C419E42EA--> <AD_MESSAGE_ID><![CDATA[2375C32E5E1A4BC7B4F64B9C419E42EA]]></AD_MESSAGE_ID> <!--2375C32E5E1A4BC7B4F64B9C419E42EA--> <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID> @@ -324,6 +336,30 @@ <!--3461C87BE74E4545B4CA6F3E12AF4D20--> <ISINCLUDEINI18N><![CDATA[N]]></ISINCLUDEINI18N> <!--3461C87BE74E4545B4CA6F3E12AF4D20--></AD_MESSAGE> +<!--35D5116415C347ACA99CF48076F79FB9--><AD_MESSAGE> +<!--35D5116415C347ACA99CF48076F79FB9--> <AD_MESSAGE_ID><![CDATA[35D5116415C347ACA99CF48076F79FB9]]></AD_MESSAGE_ID> +<!--35D5116415C347ACA99CF48076F79FB9--> <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID> +<!--35D5116415C347ACA99CF48076F79FB9--> <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID> +<!--35D5116415C347ACA99CF48076F79FB9--> <ISACTIVE><![CDATA[Y]]></ISACTIVE> +<!--35D5116415C347ACA99CF48076F79FB9--> <VALUE><![CDATA[GCNV_amountGreaterThanAvailable]]></VALUE> +<!--35D5116415C347ACA99CF48076F79FB9--> <MSGTEXT><![CDATA[The amount is greater than current balance: %0]]></MSGTEXT> +<!--35D5116415C347ACA99CF48076F79FB9--> <MSGTYPE><![CDATA[E]]></MSGTYPE> +<!--35D5116415C347ACA99CF48076F79FB9--> <AD_MODULE_ID><![CDATA[17B5337C4B1948DF857B12FD3ABE5094]]></AD_MODULE_ID> +<!--35D5116415C347ACA99CF48076F79FB9--> <ISINCLUDEINI18N><![CDATA[N]]></ISINCLUDEINI18N> +<!--35D5116415C347ACA99CF48076F79FB9--></AD_MESSAGE> + +<!--385BE4F9BA314FDEABBC714678B40668--><AD_MESSAGE> +<!--385BE4F9BA314FDEABBC714678B40668--> <AD_MESSAGE_ID><![CDATA[385BE4F9BA314FDEABBC714678B40668]]></AD_MESSAGE_ID> +<!--385BE4F9BA314FDEABBC714678B40668--> <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID> +<!--385BE4F9BA314FDEABBC714678B40668--> <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID> +<!--385BE4F9BA314FDEABBC714678B40668--> <ISACTIVE><![CDATA[Y]]></ISACTIVE> +<!--385BE4F9BA314FDEABBC714678B40668--> <VALUE><![CDATA[GCNV_ErrorGiftCardNotFoundReimbursePaymentMethod]]></VALUE> +<!--385BE4F9BA314FDEABBC714678B40668--> <MSGTEXT><![CDATA[Not found a payment method to reimburse Gift Card. Please configure Cash Management Events for this store (Event Type = Reimbursed).]]></MSGTEXT> +<!--385BE4F9BA314FDEABBC714678B40668--> <MSGTYPE><![CDATA[I]]></MSGTYPE> +<!--385BE4F9BA314FDEABBC714678B40668--> <AD_MODULE_ID><![CDATA[17B5337C4B1948DF857B12FD3ABE5094]]></AD_MODULE_ID> +<!--385BE4F9BA314FDEABBC714678B40668--> <ISINCLUDEINI18N><![CDATA[N]]></ISINCLUDEINI18N> +<!--385BE4F9BA314FDEABBC714678B40668--></AD_MESSAGE> + <!--3A8C8E19F3C1437284056CBF480AAFAC--><AD_MESSAGE> <!--3A8C8E19F3C1437284056CBF480AAFAC--> <AD_MESSAGE_ID><![CDATA[3A8C8E19F3C1437284056CBF480AAFAC]]></AD_MESSAGE_ID> <!--3A8C8E19F3C1437284056CBF480AAFAC--> <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID> @@ -336,6 +372,18 @@ <!--3A8C8E19F3C1437284056CBF480AAFAC--> <ISINCLUDEINI18N><![CDATA[N]]></ISINCLUDEINI18N> <!--3A8C8E19F3C1437284056CBF480AAFAC--></AD_MESSAGE> +<!--3EB95928E3F143FEBF6095017C3699AD--><AD_MESSAGE> +<!--3EB95928E3F143FEBF6095017C3699AD--> <AD_MESSAGE_ID><![CDATA[3EB95928E3F143FEBF6095017C3699AD]]></AD_MESSAGE_ID> +<!--3EB95928E3F143FEBF6095017C3699AD--> <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID> +<!--3EB95928E3F143FEBF6095017C3699AD--> <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID> +<!--3EB95928E3F143FEBF6095017C3699AD--> <ISACTIVE><![CDATA[Y]]></ISACTIVE> +<!--3EB95928E3F143FEBF6095017C3699AD--> <VALUE><![CDATA[GCNV_LblSelectReimburseAmount]]></VALUE> +<!--3EB95928E3F143FEBF6095017C3699AD--> <MSGTEXT><![CDATA[Enter amount to be reimbursed:]]></MSGTEXT> +<!--3EB95928E3F143FEBF6095017C3699AD--> <MSGTYPE><![CDATA[I]]></MSGTYPE> +<!--3EB95928E3F143FEBF6095017C3699AD--> <AD_MODULE_ID><![CDATA[17B5337C4B1948DF857B12FD3ABE5094]]></AD_MODULE_ID> +<!--3EB95928E3F143FEBF6095017C3699AD--> <ISINCLUDEINI18N><![CDATA[N]]></ISINCLUDEINI18N> +<!--3EB95928E3F143FEBF6095017C3699AD--></AD_MESSAGE> + <!--3F6BBC712E334662B8ADFE241CE7D582--><AD_MESSAGE> <!--3F6BBC712E334662B8ADFE241CE7D582--> <AD_MESSAGE_ID><![CDATA[3F6BBC712E334662B8ADFE241CE7D582]]></AD_MESSAGE_ID> <!--3F6BBC712E334662B8ADFE241CE7D582--> <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID> @@ -450,7 +498,7 @@ <!--4D4F420CE4E046CA8952F171EA4A9F4E--> <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID> <!--4D4F420CE4E046CA8952F171EA4A9F4E--> <ISACTIVE><![CDATA[Y]]></ISACTIVE> <!--4D4F420CE4E046CA8952F171EA4A9F4E--> <VALUE><![CDATA[GCNV_ErrorGiftCardNotReimbursed]]></VALUE> -<!--4D4F420CE4E046CA8952F171EA4A9F4E--> <MSGTEXT><![CDATA[Gift card with ID %0 is not reimbursable]]></MSGTEXT> +<!--4D4F420CE4E046CA8952F171EA4A9F4E--> <MSGTEXT><![CDATA[Gift card with ID %0 is not reimbursable. The gift card category must be: Refund the difference]]></MSGTEXT> <!--4D4F420CE4E046CA8952F171EA4A9F4E--> <MSGTYPE><![CDATA[E]]></MSGTYPE> <!--4D4F420CE4E046CA8952F171EA4A9F4E--> <AD_MODULE_ID><![CDATA[17B5337C4B1948DF857B12FD3ABE5094]]></AD_MODULE_ID> <!--4D4F420CE4E046CA8952F171EA4A9F4E--> <ISINCLUDEINI18N><![CDATA[N]]></ISINCLUDEINI18N> @@ -684,6 +732,18 @@ <!--69CE6D68043C4D3EBDFFA8AB2C9C7A2D--> <ISINCLUDEINI18N><![CDATA[N]]></ISINCLUDEINI18N> <!--69CE6D68043C4D3EBDFFA8AB2C9C7A2D--></AD_MESSAGE> +<!--6ADF5B698C984928B3350126997FDDC6--><AD_MESSAGE> +<!--6ADF5B698C984928B3350126997FDDC6--> <AD_MESSAGE_ID><![CDATA[6ADF5B698C984928B3350126997FDDC6]]></AD_MESSAGE_ID> +<!--6ADF5B698C984928B3350126997FDDC6--> <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID> +<!--6ADF5B698C984928B3350126997FDDC6--> <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID> +<!--6ADF5B698C984928B3350126997FDDC6--> <ISACTIVE><![CDATA[Y]]></ISACTIVE> +<!--6ADF5B698C984928B3350126997FDDC6--> <VALUE><![CDATA[GCNV_amountGreaterThanZero]]></VALUE> +<!--6ADF5B698C984928B3350126997FDDC6--> <MSGTEXT><![CDATA[The amount must be greater than zero]]></MSGTEXT> +<!--6ADF5B698C984928B3350126997FDDC6--> <MSGTYPE><![CDATA[E]]></MSGTYPE> +<!--6ADF5B698C984928B3350126997FDDC6--> <AD_MODULE_ID><![CDATA[17B5337C4B1948DF857B12FD3ABE5094]]></AD_MODULE_ID> +<!--6ADF5B698C984928B3350126997FDDC6--> <ISINCLUDEINI18N><![CDATA[N]]></ISINCLUDEINI18N> +<!--6ADF5B698C984928B3350126997FDDC6--></AD_MESSAGE> + <!--6B6C06DF1E554A3EAB2C043856DB237C--><AD_MESSAGE> <!--6B6C06DF1E554A3EAB2C043856DB237C--> <AD_MESSAGE_ID><![CDATA[6B6C06DF1E554A3EAB2C043856DB237C]]></AD_MESSAGE_ID> <!--6B6C06DF1E554A3EAB2C043856DB237C--> <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID> @@ -936,6 +996,18 @@ <!--A17B62E41C0D48C398CCA0CDF2853576--> <ISINCLUDEINI18N><![CDATA[N]]></ISINCLUDEINI18N> <!--A17B62E41C0D48C398CCA0CDF2853576--></AD_MESSAGE> +<!--A2E99B069FA540AFBB7BB765E0B3D5C2--><AD_MESSAGE> +<!--A2E99B069FA540AFBB7BB765E0B3D5C2--> <AD_MESSAGE_ID><![CDATA[A2E99B069FA540AFBB7BB765E0B3D5C2]]></AD_MESSAGE_ID> +<!--A2E99B069FA540AFBB7BB765E0B3D5C2--> <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID> +<!--A2E99B069FA540AFBB7BB765E0B3D5C2--> <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID> +<!--A2E99B069FA540AFBB7BB765E0B3D5C2--> <ISACTIVE><![CDATA[Y]]></ISACTIVE> +<!--A2E99B069FA540AFBB7BB765E0B3D5C2--> <VALUE><![CDATA[GCNV_LblReimbursePaymentSelector]]></VALUE> +<!--A2E99B069FA540AFBB7BB765E0B3D5C2--> <MSGTEXT><![CDATA[Select a payment method to reimburse]]></MSGTEXT> +<!--A2E99B069FA540AFBB7BB765E0B3D5C2--> <MSGTYPE><![CDATA[I]]></MSGTYPE> +<!--A2E99B069FA540AFBB7BB765E0B3D5C2--> <AD_MODULE_ID><![CDATA[17B5337C4B1948DF857B12FD3ABE5094]]></AD_MODULE_ID> +<!--A2E99B069FA540AFBB7BB765E0B3D5C2--> <ISINCLUDEINI18N><![CDATA[N]]></ISINCLUDEINI18N> +<!--A2E99B069FA540AFBB7BB765E0B3D5C2--></AD_MESSAGE> + <!--A33EF80737A44BAC85E6369C6FFE6C19--><AD_MESSAGE> <!--A33EF80737A44BAC85E6369C6FFE6C19--> <AD_MESSAGE_ID><![CDATA[A33EF80737A44BAC85E6369C6FFE6C19]]></AD_MESSAGE_ID> <!--A33EF80737A44BAC85E6369C6FFE6C19--> <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID> diff --git a/src/org/openbravo/retail/giftcards/FindGiftCard.java b/src/org/openbravo/retail/giftcards/FindGiftCard.java --- a/src/org/openbravo/retail/giftcards/FindGiftCard.java +++ b/src/org/openbravo/retail/giftcards/FindGiftCard.java @@ -1,6 +1,6 @@ /* ************************************************************************************ - * Copyright (C) 2012-2017 Openbravo S.L.U. + * Copyright (C) 2012-2018 Openbravo S.L.U. * Licensed under the Openbravo Commercial License version 1.0 * You may obtain a copy of the License at http://www.openbravo.com/legal/obcl.html * or in the legal folder of this module distribution. @@ -8,10 +8,16 @@ */ package org.openbravo.retail.giftcards; +import java.util.List; + +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.base.provider.OBProvider; import org.openbravo.dal.core.OBContext; +import org.openbravo.dal.service.OBDal; import org.openbravo.model.common.enterprise.Organization; import org.openbravo.retail.giftcards.org.openbravo.retail.giftcards.GiftCardInst; import org.openbravo.service.json.DataResolvingMode; @@ -28,18 +34,47 @@ final GiftCardInst giftcard = model.findGiftCard(json.getString("giftcard"), json.optString("giftcardtype", null)); - if (giftcard != null && "BasedOnGLItem".equals(giftcard.getType()) - && giftcard.getCategory().isOnlyOrg()) { - Organization org = OBContext.getOBContext().getCurrentOrganization(); - if (!giftcard.getOrganization().getId().equals(org.getId())) { - throw new Exception("GCNV_ErrorGiftCardNotExists:" + giftcard.getSearchKey()); - } - } final DataToJsonConverterExt toJsonConverter = OBProvider.getInstance().get( DataToJsonConverterExt.class); - final JSONObject jsongiftcard = toJsonConverter.toJsonObject(giftcard, - DataResolvingMode.FULL); + JSONObject jsongiftcard = toJsonConverter.toJsonObject(giftcard, DataResolvingMode.FULL); + + if (giftcard != null) { + if ("BasedOnGLItem".equals(giftcard.getType())) { + Organization org = OBContext.getOBContext().getCurrentOrganization(); + if (giftcard.getCategory().isOnlyOrg()) { + if (!giftcard.getOrganization().getId().equals(org.getId())) { + throw new Exception("GCNV_ErrorGiftCardNotExists:" + giftcard.getSearchKey()); + } + } + } + if ("BasedOnGLItem".equals(giftcard.getType()) + || "BasedOnCreditNote".equals(giftcard.getType())) { + Boolean loadReimbursedMethods = json.has("loadReimbursedMethods") ? json + .getBoolean("loadReimbursedMethods") : false; + if (loadReimbursedMethods) { + final String sqlString = "SELECT pmtype.paymentMethod.searchKey, pmtype.paymentMethod.name " + + "FROM OBPOS_Applications term JOIN term.oBPOSAppPaymentList pmtype " + + "WHERE term.id = :termId AND pmtype.active = true AND pmtype.paymentMethod.paymentMethod.id IN " + + "(SELECT cme.paymentMethod.id FROM OBRETCO_CashManagementEvents cme " + + "WHERE cme.organization.id = term.organization.id AND cme.paymentMethod.id = pmtype.paymentMethod.paymentMethod.id" + + " AND cme.active = true AND cme.eventtype = 'GCNV_reimbursed') order by pmtype.line, pmtype.commercialName"; + final Session session = OBDal.getInstance().getSession(); + @SuppressWarnings("unchecked") + final Query<Object[]> query = session.createQuery(sqlString); + query.setParameter("termId", json.getString("pos")); + JSONArray reimbursedMethods = new JSONArray(); + final List<Object[]> paymentMethods = query.list(); + for (Object[] item : paymentMethods) { + JSONObject method = new JSONObject(); + method.put("searchKey", (String) item[0]); + method.put("name", (String) item[1]); + reimbursedMethods.put(method); + } + jsongiftcard.put("reimbursedMethods", reimbursedMethods); + } + } + } if (giftcard.getPayment() != null) { jsongiftcard.put("currency", giftcard.getPayment().getAccount().getCurrency().getId()); diff --git a/src/org/openbravo/retail/giftcards/GCNVComponentProvider.java b/src/org/openbravo/retail/giftcards/GCNVComponentProvider.java --- a/src/org/openbravo/retail/giftcards/GCNVComponentProvider.java +++ b/src/org/openbravo/retail/giftcards/GCNVComponentProvider.java @@ -1,6 +1,6 @@ /* ************************************************************************************ - * Copyright (C) 2012-2017 Openbravo S.L.U. + * Copyright (C) 2012-2018 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. @@ -55,6 +55,8 @@ grhelper.add("components/GiftCardDetails.js"); grhelper.add("components/GiftCardPaymentAmount.js"); grhelper.add("components/GiftCardPaymentVoucher.js"); + grhelper.add("components/GiftCardReimburseAmount.js"); + grhelper.add("components/GiftCardReimbursePaymentSelector.js"); grhelper.add("components/GiftCardCancel.js"); grhelper.add("components/GiftCardMessage.js"); grhelper.add("components/GiftCardSearchDialog.js"); @@ -66,6 +68,8 @@ grhelper.add("hooks/preremovepaymenthook.js"); grhelper.add("hooks/postaddpaymenthook.js"); grhelper.add("hooks/AddButtonToCashManagementHook.js"); + grhelper.add("hooks/AddPaymentToCashManagementHook.js"); + grhelper.add("hooks/AfterRenderContainerWindowHook.js"); grhelper.add("hooks/printGiftCardPrePrintHook.js"); grhelper.add("hooks/PreReversePaymentHook.js"); grhelper.add("hooks/precustomersavehook.js"); diff --git a/src/org/openbravo/retail/giftcards/ListGiftCard.java b/src/org/openbravo/retail/giftcards/ListGiftCard.java --- a/src/org/openbravo/retail/giftcards/ListGiftCard.java +++ b/src/org/openbravo/retail/giftcards/ListGiftCard.java @@ -1,6 +1,6 @@ /* ************************************************************************************ - * Copyright (C) 2012-2017 Openbravo S.L.U. + * Copyright (C) 2012-2018 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,14 +30,16 @@ + "gc.organization.id in (" + Utility.getInStrSet(new HashSet<String>(new OrganizationStructureProvider() .getParentList(OBContext.getOBContext().getCurrentOrganization().getId(), true))) - + ") and (upper(gc.businessPartner.name) like upper(:filter) or upper(gc.searchKey) like upper(:filter))"; + + ") and (upper(gc.businessPartner.name) like upper(:filter) or upper(gc.searchKey) like upper(:filter)) "; String query = "select gc.searchKey as _identifier, gc.businessPartner.name as businessPartner$_identifier, " + "gc.id as id, p.name as product$_identifier, c.name as category$_identifier, " + "gc.searchKey as searchKey, gc.type as type " // + "from GCNV_GiftCardInst gc left join gc.product as p left join gc.category as c "; - return Arrays.asList(new String[] { query + where }); + String orderby = "order by gc.searchKey desc"; + + return Arrays.asList(new String[] { query + where + orderby }); } @Override diff --git a/src/org/openbravo/retail/giftcards/hooks/ProcessCashMgmtHookGiftCard.java b/src/org/openbravo/retail/giftcards/hooks/ProcessCashMgmtHookGiftCard.java --- a/src/org/openbravo/retail/giftcards/hooks/ProcessCashMgmtHookGiftCard.java +++ b/src/org/openbravo/retail/giftcards/hooks/ProcessCashMgmtHookGiftCard.java @@ -1,6 +1,6 @@ /* ************************************************************************************ - * Copyright (C) 2015-2017 Openbravo S.L.U. + * Copyright (C) 2015-2018 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. @@ -26,6 +26,7 @@ import org.openbravo.model.financialmgmt.gl.GLItem; import org.openbravo.model.financialmgmt.payment.FIN_FinaccTransaction; import org.openbravo.model.financialmgmt.payment.FIN_FinancialAccount; +import org.openbravo.model.financialmgmt.payment.FIN_Payment; import org.openbravo.retail.giftcards.org.openbravo.retail.giftcards.GiftCardInst; import org.openbravo.retail.giftcards.org.openbravo.retail.giftcards.GiftCardTrans; import org.openbravo.retail.giftcards.process.GiftCardGLItemUtils; @@ -68,8 +69,9 @@ throw new OBException(OBMessageUtils.getI18NMessage("GCNV_NoGLItemForReimburse", new String[] { OBMessageUtils.messageBD("GCNV_LblCreditNote"), terminal.getObposTerminaltype().getName() })); - } else + } else { glitem = appPayObj.getPaymentMethod().getGcnvReimburseGlitem(); + } } } else { glitem = giftCardInst.getCategory().getGLItem(); @@ -100,10 +102,15 @@ paymentcashupEvent.setFINFinaccTransaction(cashOutTransaction); OBDal.getInstance().save(paymentcashupEvent); - // Close GiftCard + // Consume Gift Card if (jsonsent.has("transactionId")) { GiftCardTrans trans = OBDal.getInstance().get(GiftCardTrans.class, jsonsent.getString("transactionId")); + if (trans.getPayment() == null) { + // Make a payment + FIN_Payment payment = GiftCardGLItemUtils.makePayment(giftCardInst, cashup, amount); + trans.setPayment(payment); + } FIN_FinaccTransaction transaction = trans.getPayment().getFINFinaccTransactionList() .get(0); transaction.setObposAppCashup(cashup); @@ -111,7 +118,14 @@ paymentcashupEvent.setRelatedTransaction(transaction); OBDal.getInstance().save(paymentcashupEvent); } else { - GiftCardGLItemUtils.close(giftCardInst, cashup, paymentcashupEvent, "R"); + if (giftCardInst.getCurrentamount().compareTo(amount) > 0) { + OBPOSApplications posterminal = cashup == null ? null : cashup.getPOSTerminal(); + GiftCardGLItemUtils.makeGiftCardTrans(giftCardInst, cashup, posterminal, + paymentcashupEvent, "PU", amount, false); + } else { + // Close GiftCard + GiftCardGLItemUtils.close(giftCardInst, cashup, paymentcashupEvent, "R"); + } } } } diff --git a/src/org/openbravo/retail/giftcards/master/CashMgmtEvents.java b/src/org/openbravo/retail/giftcards/master/CashMgmtEvents.java --- a/src/org/openbravo/retail/giftcards/master/CashMgmtEvents.java +++ b/src/org/openbravo/retail/giftcards/master/CashMgmtEvents.java @@ -1,6 +1,6 @@ /* ************************************************************************************ - * Copyright (C) 2017 Openbravo S.L.U. + * Copyright (C) 2017-2018 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. @@ -20,8 +20,9 @@ @Override protected List<String> getQuery(JSONObject jsonsent) throws JSONException { return Arrays - .asList(new String[] { "select c.id as id, c.name as name, c.eventtype as eventType from OBRETCO_CashManagementEvents c " - + "where c.$orgCriteria and c.eventtype like 'GCNV_%' order by c.name, c.id " }); + .asList(new String[] { "select c.id as id, c.name as name, c.eventtype as eventType, c.paymentMethod.id as paymentMethodId, c.paymentMethod.name as paymentMethodName " + + "from OBRETCO_CashManagementEvents c " + + "where c.$naturalOrgCriteria and c.eventtype like 'GCNV_%' order by c.name" }); } @Override diff --git a/src/org/openbravo/retail/giftcards/process/CreditNoteException.java b/src/org/openbravo/retail/giftcards/process/CreditNoteException.java new file mode 100644 --- /dev/null +++ b/src/org/openbravo/retail/giftcards/process/CreditNoteException.java @@ -0,0 +1,22 @@ +/* + ************************************************************************************ + * Copyright (C) 2018 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.giftcards.process; + +import org.openbravo.base.exception.OBException; + +public class CreditNoteException extends OBException { + + private static final long serialVersionUID = 1L; + + public CreditNoteException(String message) { + super(message); + } + +} diff --git a/src/org/openbravo/retail/giftcards/process/GiftCardGLItemUtils.java b/src/org/openbravo/retail/giftcards/process/GiftCardGLItemUtils.java --- a/src/org/openbravo/retail/giftcards/process/GiftCardGLItemUtils.java +++ b/src/org/openbravo/retail/giftcards/process/GiftCardGLItemUtils.java @@ -27,7 +27,6 @@ import org.openbravo.erpCommon.ad_forms.AcctServer; import org.openbravo.erpCommon.utility.OBError; import org.openbravo.erpCommon.utility.OBMessageUtils; -import org.openbravo.mobile.core.utils.OBMOBCUtils; import org.openbravo.model.common.enterprise.Organization; import org.openbravo.model.financialmgmt.gl.GLItem; import org.openbravo.model.financialmgmt.payment.FIN_FinaccTransaction; @@ -46,6 +45,7 @@ public class GiftCardGLItemUtils { private static final Logger log4j = Logger.getLogger(GiftCardGLItemUtils.class); public static final String STATUS_CLOSED = "C"; + public static final String STATUS_PARTIAL = "P"; public static GiftCardTrans close(OBPOSApplications posterminal, String gftCardId, String certificateStatus) { @@ -78,113 +78,144 @@ return getLastCancelTransaction(giftCardInst); } - GiftCardTrans trans = OBProvider.getInstance().get(GiftCardTrans.class); - + GiftCardTrans trans = null; try { - long init = System.currentTimeMillis(); log4j.info("Closing Gift Card Instance: " + giftCardInst.getIdentifier()); - FIN_FinancialAccount account = giftCardInst.getPayment().getAccount(); - Organization organization = giftCardInst.getPayment().getOrganization(); - if (cashup != null) { - organization = cashup.getOrganization(); - account = getAccount(cashup.getPOSTerminal(), giftCardInst.getPayment().getPaymentMethod()); - } else if (posterminal != null) { - organization = posterminal.getOrganization(); - account = getAccount(posterminal, giftCardInst.getPayment().getPaymentMethod()); - } - Date date = OBMOBCUtils.stripTime(new Date()); BigDecimal amount = giftCardInst.getCurrentamount(); - // Make a payment - FIN_Payment payment = new AdvPaymentMngtDao().getNewPayment(true, organization, FIN_Utility - .getDocumentType(organization, AcctServer.DOCTYPE_ARReceipt), null, giftCardInst - .getPayment().getBusinessPartner(), giftCardInst.getPayment().getPaymentMethod(), - account, amount.toString(), date, null, account.getCurrency(), null, null); - if (cashup != null && payment != null) { - payment.setObposAppCashup(cashup); - payment.setOBPOSPOSTerminal(cashup.getPOSTerminal()); - OBDal.getInstance().save(payment); + trans = makeGiftCardTrans(giftCardInst, cashup, posterminal, paymentcashupEvent, + certificateStatus, amount, true); + } catch (Exception e) { + if (e instanceof CreditNoteException) { + throw new OBException(e.getMessage()); } - log4j.info("Time to save payment header: " + (System.currentTimeMillis() - init)); - GLItem glitem = null; - if ("BasedOnCreditNote".equals(giftCardInst.getType())) { - String posTerminalId = giftCardInst.getSalesOrder().getObposApplications().getId(); - OBCriteria<OBPOSAppPayment> appPaymentCri = OBDal.getInstance().createCriteria( - OBPOSAppPayment.class); - appPaymentCri.add(Restrictions.eq(OBPOSAppPayment.PROPERTY_OBPOSAPPLICATIONS + ".id", - posTerminalId)); - appPaymentCri.add(Restrictions.eq(OBPOSAppPayment.PROPERTY_SEARCHKEY, - "GCNV_payment.creditnote")); - appPaymentCri.setMaxResults(1); - List<OBPOSAppPayment> appPaymentList = appPaymentCri.list(); - if (appPaymentList.size() > 0) { - OBPOSAppPayment appPayObj = appPaymentList.get(0); - if (appPayObj.getPaymentMethod().getGcnvReimburseGlitem() == null) { - OBPOSApplications terminal = OBDal.getInstance().get(OBPOSApplications.class, - posTerminalId); - throw new OBException(OBMessageUtils.getI18NMessage("GCNV_NoGLItemForReimburse", - new String[] { OBMessageUtils.messageBD("GCNV_LblCreditNote"), - terminal.getObposTerminaltype().getName() })); - } else - glitem = appPayObj.getPaymentMethod().getGcnvReimburseGlitem(); - } - } else { - glitem = giftCardInst.getCategory().getGLItem(); - } - - // Flush to prevent security errors on the following code. - OBDal.getInstance().flush(); - - if (payment != null) { - long init2 = System.currentTimeMillis(); - if ("BasedOnCreditNote".equals(giftCardInst.getType())) { - FIN_AddPayment.saveGLItem(payment, amount, glitem, giftCardInst.getPayment() - .getBusinessPartner(), null, null, null, null, null, null, null, null); - } else { - FIN_AddPayment.saveGLItem(payment, amount, glitem, giftCardInst.getPayment() - .getBusinessPartner(), null, null, null, null, null, null, null, null); - } - log4j.info("Time to save payment GL Item: " + (System.currentTimeMillis() - init2)); - long init3 = System.currentTimeMillis(); - OBError error = FIN_AddPayment.processPayment(RequestContext.get().getVariablesSecureApp(), - new DalConnectionProvider(true), "D", payment); - if (!"Success".equals(error.getType())) { - throw new OBException(error.getMessage()); - } - log4j.info("Time to process payment: " + (System.currentTimeMillis() - init3)); - } - long init4 = System.currentTimeMillis(); - if (cashup != null) { - FIN_FinaccTransaction transaction = payment.getFINFinaccTransactionList().get(0); - transaction.setObposAppCashup(cashup); - OBDal.getInstance().save(transaction); - if (paymentcashupEvent != null) { - paymentcashupEvent.setRelatedTransaction(transaction); - OBDal.getInstance().save(paymentcashupEvent); - } - } - // Create a cancel transaction with amount - trans.setOrganization(organization); - trans.setActive(true); - trans.setOrderDate(date); - trans.setPayment(payment); - trans.setAmount(amount); - trans.setCancelled(true); - trans.setGcnvGiftcardInst(giftCardInst); - OBDal.getInstance().save(trans); - giftCardInst.setCurrentamount(BigDecimal.ZERO); - giftCardInst.setAlertStatus(STATUS_CLOSED); - giftCardInst.setGiftCardCertificateStatus(certificateStatus); - OBDal.getInstance().save(giftCardInst); - log4j.info("Time to save gift card transaction: " + (System.currentTimeMillis() - init4)); - log4j.info("Total Time to close a gift card: " + (System.currentTimeMillis() - init)); - } catch (Exception e) { if (giftCardInst != null) { throw new OBException(OBMessageUtils.getI18NMessage("GCNV_ExceptionCloseGiftcard", new String[] { giftCardInst.getSearchKey() }), e); } } return trans; + } + public static GiftCardTrans makeGiftCardTrans(GiftCardInst giftCardInst, OBPOSAppCashup cashup, + OBPOSApplications posterminal, OBPOSPaymentcashupEvents paymentcashupEvent, + String certificateStatus, BigDecimal amount, boolean cancelled) throws Exception { + long init = System.currentTimeMillis(); + GiftCardTrans trans = OBProvider.getInstance().get(GiftCardTrans.class); + FIN_FinancialAccount account = giftCardInst.getPayment().getAccount(); + Organization organization = giftCardInst.getPayment().getOrganization(); + if (cashup != null) { + organization = cashup.getOrganization(); + account = getAccount(cashup.getPOSTerminal(), giftCardInst.getPayment().getPaymentMethod()); + } else if (posterminal != null) { + organization = posterminal.getOrganization(); + account = getAccount(posterminal, giftCardInst.getPayment().getPaymentMethod()); + } + + // Make a payment + FIN_Payment payment = makePayment(giftCardInst, cashup, organization, account, amount); + long init4 = System.currentTimeMillis(); + if (cashup != null) { + FIN_FinaccTransaction transaction = payment.getFINFinaccTransactionList().get(0); + transaction.setObposAppCashup(cashup); + OBDal.getInstance().save(transaction); + if (paymentcashupEvent != null) { + paymentcashupEvent.setRelatedTransaction(transaction); + OBDal.getInstance().save(paymentcashupEvent); + } + } + + // Create a transaction with amount + trans.setOrganization(organization); + trans.setActive(true); + trans.setOrderDate(new Date()); + trans.setPayment(payment); + trans.setAmount(amount); + trans.setCancelled(cancelled); + trans.setGcnvGiftcardInst(giftCardInst); + OBDal.getInstance().save(trans); + giftCardInst.setCurrentamount(cancelled ? BigDecimal.ZERO : giftCardInst.getCurrentamount() + .subtract(amount)); + giftCardInst + .setAlertStatus(giftCardInst.getCurrentamount().compareTo(BigDecimal.ZERO) > 0 ? STATUS_PARTIAL + : STATUS_CLOSED); + giftCardInst.setGiftCardCertificateStatus(certificateStatus); + OBDal.getInstance().save(giftCardInst); + log4j.info("Time to save gift card transaction: " + (System.currentTimeMillis() - init4)); + log4j.info("Total Time to close a gift card: " + (System.currentTimeMillis() - init)); + return trans; + } + + public static FIN_Payment makePayment(GiftCardInst giftCardInst, OBPOSAppCashup cashup, + Organization organization, FIN_FinancialAccount account, BigDecimal amount) throws Exception { + long init = System.currentTimeMillis(); + FIN_Payment payment = new AdvPaymentMngtDao().getNewPayment(true, organization, FIN_Utility + .getDocumentType(organization, AcctServer.DOCTYPE_ARReceipt), null, giftCardInst + .getPayment().getBusinessPartner(), giftCardInst.getPayment().getPaymentMethod(), account, + amount.toString(), new Date(), null, account.getCurrency(), null, null); + if (cashup != null && payment != null) { + payment.setObposAppCashup(cashup); + payment.setOBPOSPOSTerminal(cashup.getPOSTerminal()); + OBDal.getInstance().save(payment); + } + log4j.info("Time to save payment header: " + (System.currentTimeMillis() - init)); + GLItem glitem = null; + if ("BasedOnCreditNote".equals(giftCardInst.getType())) { + String posTerminalId = giftCardInst.getSalesOrder().getObposApplications().getId(); + OBCriteria<OBPOSAppPayment> appPaymentCri = OBDal.getInstance().createCriteria( + OBPOSAppPayment.class); + appPaymentCri.add(Restrictions.eq(OBPOSAppPayment.PROPERTY_OBPOSAPPLICATIONS + ".id", + posTerminalId)); + appPaymentCri.add(Restrictions.eq(OBPOSAppPayment.PROPERTY_SEARCHKEY, + "GCNV_payment.creditnote")); + appPaymentCri.setMaxResults(1); + List<OBPOSAppPayment> appPaymentList = appPaymentCri.list(); + if (appPaymentList.size() > 0) { + OBPOSAppPayment appPayObj = appPaymentList.get(0); + if (appPayObj.getPaymentMethod().getGcnvReimburseGlitem() == null) { + OBPOSApplications terminal = OBDal.getInstance().get(OBPOSApplications.class, + posTerminalId); + throw new CreditNoteException(OBMessageUtils.getI18NMessage("GCNV_NoGLItemForReimburse", + new String[] { OBMessageUtils.messageBD("GCNV_LblCreditNote"), + terminal.getObposTerminaltype().getName() })); + } else + glitem = appPayObj.getPaymentMethod().getGcnvReimburseGlitem(); + } + } else { + glitem = giftCardInst.getCategory().getGLItem(); + } + + // Flush to prevent security errors on the following code. + OBDal.getInstance().flush(); + + if (payment != null) { + long init2 = System.currentTimeMillis(); + payment.setDescription(OBMessageUtils.getI18NMessage("GCNV_CloseGiftCard_PaymentDescription", + null)); + OBDal.getInstance().save(payment); + if ("BasedOnCreditNote".equals(giftCardInst.getType())) { + FIN_AddPayment.saveGLItem(payment, amount, glitem, giftCardInst.getPayment() + .getBusinessPartner(), null, null, null, null, null, null, null, null); + } else { + FIN_AddPayment.saveGLItem(payment, amount, glitem, giftCardInst.getPayment() + .getBusinessPartner(), null, null, null, null, null, null, null, null); + } + log4j.info("Time to save payment GL Item: " + (System.currentTimeMillis() - init2)); + long init3 = System.currentTimeMillis(); + OBError error = FIN_AddPayment.processPayment(RequestContext.get().getVariablesSecureApp(), + new DalConnectionProvider(true), "D", payment); + if (!"Success".equals(error.getType())) { + throw new OBException(error.getMessage()); + } + log4j.info("Time to process payment: " + (System.currentTimeMillis() - init3)); + } + + return payment; + } + + public static FIN_Payment makePayment(GiftCardInst giftCardInst, OBPOSAppCashup cashup, + BigDecimal amount) throws Exception { + return makePayment(giftCardInst, cashup, giftCardInst.getPayment().getOrganization(), + giftCardInst.getPayment().getAccount(), amount); } private static FIN_FinancialAccount getAccount(OBPOSApplications posterminal, diff --git a/web/org.openbravo.retail.giftcards/css/gcnv.css b/web/org.openbravo.retail.giftcards/css/gcnv.css --- a/web/org.openbravo.retail.giftcards/css/gcnv.css +++ b/web/org.openbravo.retail.giftcards/css/gcnv.css @@ -1,6 +1,6 @@ /* ************************************************************************************ - * Copyright (C) 2017 Openbravo S.L.U. + * Copyright (C) 2017-2018 Openbravo S.L.U. * Licensed under the Openbravo Commercial License version 1.0 * You may obtain a copy of the License at http://www.openbravo.com/legal/obcl.html * or in the legal folder of this module distribution. @@ -8,5 +8,11 @@ */ .gcnv-edit-error { - border: 1px solid red; + border: 1px solid red; +} + +.gcnv-reimburse-payment-line { + height: 60px; + background-color: #dddddd !important; + border: 1px solid #ffffff !important; } \ No newline at end of file diff --git a/web/org.openbravo.retail.giftcards/js/components/GiftCardDetails.js b/web/org.openbravo.retail.giftcards/js/components/GiftCardDetails.js --- a/web/org.openbravo.retail.giftcards/js/components/GiftCardDetails.js +++ b/web/org.openbravo.retail.giftcards/js/components/GiftCardDetails.js @@ -177,7 +177,8 @@ handlers: { onAcceptButton: 'acceptButton', onReturnButton: 'returnButton', - onPrintButton: 'printButton' + onPrintButton: 'printButton', + onCashManagementOpen: 'cashManagementOpen' }, style: 'min-height: 455px; overflow: hidden', bodyContent: { @@ -356,11 +357,15 @@ }] }, + cashManagementOpen: function (inSender, inEvent) { + OB.OBGCNE.Utils.openGiftCardSelector(inEvent.keyboard, inEvent.parameters.searchKey); + }, + returnButton: function (inSender, inEvent) { var me = this; - if (this.args.receipt.get('orderType') === 0) { + if (this.args.giftcard.type !== 'BasedOnGLItem' && this.args.giftcard.type !== 'BasedOnCreditNote' && this.args.receipt.get('orderType') === 0) { // must be a return order this.args.view.doShowPopup({ popup: 'GCNV_UI_Message', @@ -404,8 +409,13 @@ me.$.bodyButtons.$.returnbutton.setAttribute('disabled', 'disabled'); me.$.bodyButtons.$.returnbutton.setContent(OB.I18N.getLabel('GCNV_LblLoading')); - // - OB.UI.GiftCardUtils.cancelGiftCard(this.args.view, this.args.receipt, giftcard.searchKey, consumeOK, consumeFail); + this.pushCancelButton = false; + if (giftcard.type === 'BasedOnGLItem' || giftcard.type === 'BasedOnCreditNote') { + me.doHideThisPopup(); + OB.MobileApp.model.navigate('retail.cashmanagement', true, giftcard); + } else { + OB.UI.GiftCardUtils.cancelGiftCard(this.args.view, this.args.receipt, giftcard.searchKey, consumeOK, consumeFail); + } }, printButton: function (inSender, inEvent) { @@ -529,7 +539,9 @@ } }; + this.pushCancelButton = false; this.statusLoading(); + this.propertiesCancelled = false; if (this.args.action) { this.args.action(this, consumeOK, consumeFail); @@ -562,7 +574,8 @@ applyButton = false; } this.$.bodyButtons.$.okbutton.putDisabled(!applyButton); - this.$.bodyButtons.$.returnbutton.putHide(isCNOrGLItem || (!isCNOrGLItem && !OB.MobileApp.model.hasPermission('GCNV_AllowRefundGiftCardsAndVouchers', true)) || this.args.giftcard.type === 'CN' || this.args.view.kind === 'OB.OBPOSPointOfSale.UI.KeyboardOrder' || !receipt.get('isEditable') || (receipt.get('orderType') !== 1 && receipt.get('orderType') !== 0)); + this.$.bodyButtons.$.returnbutton.setAttribute('disabled', null); + this.$.bodyButtons.$.returnbutton.putHide((!isCNOrGLItem && !OB.MobileApp.model.hasPermission('GCNV_AllowRefundGiftCardsAndVouchers', true)) || this.args.giftcard.type === 'CN' || this.args.view.kind === 'OB.OBPOSPointOfSale.UI.KeyboardOrder' || !receipt.get('isEditable') || (receipt.get('orderType') !== 1 && receipt.get('orderType') !== 0)); } else { this.$.bodyButtons.$.okbutton.putDisabled(false); this.$.bodyButtons.$.returnbutton.putHide(true); @@ -621,69 +634,78 @@ }, executeOnHide: function () { - if (this.args.parentDialog && this.args.cancelAction && this.propertiesCancelled) { + if (this.pushCancelButton && this.args.parentDialog && this.args.cancelAction && this.propertiesCancelled) { this.args.cancelAction(); + } else { + this.savedArgs = this.args; } }, executeOnShow: function () { - var giftcard = this.args.giftcard; + this.pushCancelButton = true; + if (this.args.giftcard) { + var giftcard = this.args.giftcard; - this.propertiesCancelled = true; - this.statusReady(); + this.propertiesCancelled = true; + this.statusReady(); - this.$.bodyContent.$.searchkey.setContent(giftcard.searchKey); - this.$.bodyContent.$.status.setContent(OB.I18N.getLabel('GCNV_LblStatus-' + giftcard.alertStatus)); - if (giftcard.type === 'BasedOnGLItem') { - this.$.bodyContent.$.productcontainer.setShowing(false); - this.$.bodyContent.$.categorycontainer.setShowing(true); - this.$.bodyContent.$.category.setContent(giftcard.category$_identifier); - } else if (giftcard.type === 'BasedOnCreditNote') { - this.$.bodyContent.$.productcontainer.setShowing(false); - this.$.bodyContent.$.categorycontainer.setShowing(false); - this.$.bodyContent.$.expirationDatecontainer.setShowing(false); - } else { - this.$.bodyContent.$.categorycontainer.setShowing(false); - this.$.bodyContent.$.productcontainer.setShowing(true); - this.$.bodyContent.$.product.setContent(giftcard.product$_identifier); - } - this.$.bodyContent.$.businesspartner.setContent(giftcard.businessPartner$_identifier); - this.$.bodyContent.$.gcowner.setContent(giftcard.obgcneGCOwner$_identifier); - this.$.bodyContent.$.expirationDate.setContent(!OB.UTIL.isNullOrUndefined(giftcard.obgcneExpirationdate) ? OB.I18N.formatDate(new Date(OB.I18N.parseServerDate(giftcard.obgcneExpirationdate))) : ''); + this.$.bodyContent.$.searchkey.setContent(giftcard.searchKey); + this.$.bodyContent.$.status.setContent(OB.I18N.getLabel('GCNV_LblStatus-' + giftcard.alertStatus)); + if (giftcard.type === 'BasedOnGLItem') { + this.$.bodyContent.$.productcontainer.setShowing(false); + this.$.bodyContent.$.categorycontainer.setShowing(true); + this.$.bodyContent.$.category.setContent(giftcard.category$_identifier); + } else if (giftcard.type === 'BasedOnCreditNote') { + this.$.bodyContent.$.productcontainer.setShowing(false); + this.$.bodyContent.$.categorycontainer.setShowing(false); + this.$.bodyContent.$.expirationDatecontainer.setShowing(false); + } else { + this.$.bodyContent.$.categorycontainer.setShowing(false); + this.$.bodyContent.$.productcontainer.setShowing(true); + this.$.bodyContent.$.product.setContent(giftcard.product$_identifier); + } + this.$.bodyContent.$.businesspartner.setContent(giftcard.businessPartner$_identifier); + this.$.bodyContent.$.gcowner.setContent(giftcard.obgcneGCOwner$_identifier); + this.$.bodyContent.$.expirationDate.setContent(!OB.UTIL.isNullOrUndefined(giftcard.obgcneExpirationdate) ? OB.I18N.formatDate(new Date(OB.I18N.parseServerDate(giftcard.obgcneExpirationdate))) : ''); + + if (giftcard.obgcneExpirationdate && OB.OBGCNE.Utils.isInThePast(giftcard.obgcneExpirationdate)) { + this.$.bodyButtons.$.okbutton.setAttribute('disabled', 'disabled'); + this.$.bodyButtons.$.returnbutton.setAttribute('disabled', 'disabled'); + this.$.bodyContent.$.status.setContent(OB.I18N.getLabel('OBGCNE_Expired')); + } - if (giftcard.obgcneExpirationdate && OB.OBGCNE.Utils.isInThePast(giftcard.obgcneExpirationdate)) { - this.$.bodyButtons.$.okbutton.setAttribute('disabled', 'disabled'); - this.$.bodyButtons.$.returnbutton.setAttribute('disabled', 'disabled'); - this.$.bodyContent.$.status.setContent(OB.I18N.getLabel('OBGCNE_Expired')); - } - - if (giftcard.amount !== null) { - // It's a gift card - if (giftcard.type === 'BasedOnCreditNote') { - this.$.header.setContent(OB.I18N.getLabel('GCNV_LblCreditNote')); - } else if (giftcard.type === 'BasedOnGLItem') { - this.$.header.setContent(OB.I18N.getLabel('GCNV_LblGiftCardsCertificate')); + if (giftcard.amount !== null) { + // It's a gift card + if (giftcard.type === 'BasedOnCreditNote') { + this.$.header.setContent(OB.I18N.getLabel('GCNV_LblCreditNote')); + } else if (giftcard.type === 'BasedOnGLItem') { + this.$.header.setContent(OB.I18N.getLabel('GCNV_LblGiftCardsCertificate')); + } else { + this.$.header.setContent(OB.I18N.getLabel('GCNV_LblDialogGiftCard')); + } + this.$.bodyContent.$.summary.setShowing(false); + this.$.bodyContent.$.amountcontainer.setShowing(true); + this.$.bodyContent.$.currentamountcontainer.setShowing(true); + this.$.bodyContent.$.amount.setContent(OB.I18N.formatCurrency(giftcard.amount)); + this.$.bodyContent.$.currentamount.setContent(OB.I18N.formatCurrency(giftcard.currentamount)); } else { - this.$.header.setContent(OB.I18N.getLabel('GCNV_LblDialogGiftCard')); + // It's a gift voucher + this.$.header.setContent(OB.I18N.getLabel('GCNV_LblDialogGiftVoucher')); + this.$.bodyContent.$.summary.setShowing(true); + this.$.bodyContent.$.amountcontainer.setShowing(false); + this.$.bodyContent.$.currentamountcontainer.setShowing(false); + // summary ordered by product identifier. + var summarylist = new Backbone.Collection(); + summarylist.comparator = function (model) { + return model.get('product$_identifier'); + }; + summarylist.add(giftcard.gCNVGiftCardSummaryList); + this.$.bodyContent.$.summary.setCollection(summarylist); } - this.$.bodyContent.$.summary.setShowing(false); - this.$.bodyContent.$.amountcontainer.setShowing(true); - this.$.bodyContent.$.currentamountcontainer.setShowing(true); - this.$.bodyContent.$.amount.setContent(OB.I18N.formatCurrency(giftcard.amount)); - this.$.bodyContent.$.currentamount.setContent(OB.I18N.formatCurrency(giftcard.currentamount)); } else { - // It's a gift voucher - this.$.header.setContent(OB.I18N.getLabel('GCNV_LblDialogGiftVoucher')); - this.$.bodyContent.$.summary.setShowing(true); - this.$.bodyContent.$.amountcontainer.setShowing(false); - this.$.bodyContent.$.currentamountcontainer.setShowing(false); - // summary ordered by product identifier. - var summarylist = new Backbone.Collection(); - summarylist.comparator = function (model) { - return model.get('product$_identifier'); - }; - summarylist.add(giftcard.gCNVGiftCardSummaryList); - this.$.bodyContent.$.summary.setCollection(summarylist); + this.args = this.savedArgs; + this.propertiesCancelled = true; + this.statusReady(); } }, initComponents: function () { diff --git a/web/org.openbravo.retail.giftcards/js/components/GiftCardDialog.js b/web/org.openbravo.retail.giftcards/js/components/GiftCardDialog.js --- a/web/org.openbravo.retail.giftcards/js/components/GiftCardDialog.js +++ b/web/org.openbravo.retail.giftcards/js/components/GiftCardDialog.js @@ -1,6 +1,6 @@ /* ************************************************************************************ - * Copyright (C) 2012-2017 Openbravo S.L.U. + * Copyright (C) 2012-2018 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. @@ -45,10 +45,16 @@ column.preset.name = ''; } this.initSelector(); - this.getFilterSelectorTableHeader().clearFilter(); this.$.header.setContent(this.args.header); - this.$.body.$.giftcards.gcsList.reset(); - this.$.body.$.giftcards.$.stGCAssignToReceipt.$.tempty.show(); + if (this.args.giftcardId) { + var filterSelector = this.getFilterSelectorTableHeader(); + filterSelector.$.entityFilterText.setValue(this.args.giftcardId); + filterSelector.searchAction(); + } else { + this.getFilterSelectorTableHeader().clearFilter(); + this.$.body.$.giftcards.gcsList.reset(); + this.$.body.$.giftcards.$.stGCAssignToReceipt.$.tempty.show(); + } } else { this.args = this.initializedArgs; } diff --git a/web/org.openbravo.retail.giftcards/js/components/GiftCardMessage.js b/web/org.openbravo.retail.giftcards/js/components/GiftCardMessage.js --- a/web/org.openbravo.retail.giftcards/js/components/GiftCardMessage.js +++ b/web/org.openbravo.retail.giftcards/js/components/GiftCardMessage.js @@ -1,6 +1,6 @@ /* ************************************************************************************ - * Copyright (C) 2012-2017 Openbravo S.L.U. + * Copyright (C) 2012-2018 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. @@ -24,8 +24,15 @@ onAcceptButton: 'acceptButton' }, bodyContent: { - name: 'bodymessage', - content: 'label' + components: [{ + name: 'bodymessage', + content: 'label' + }, { + name: 'secondaryMessage', + content: '', + style: 'margin-top: 1em; color: red;', + showing: false + }] }, bodyButtons: { components: [{ @@ -38,6 +45,10 @@ executeOnShow: function () { this.$.header.setContent(this.args.header || OB.I18N.getLabel('GCNV_LblGiftCardHeader')); this.$.bodyContent.$.bodymessage.setContent(this.args.message); + this.$.bodyContent.$.secondaryMessage.setShowing(!OB.UTIL.isNullOrUndefined(this.args.secondaryMessage)); + if (this.args.secondaryMessage) { + this.$.bodyContent.$.secondaryMessage.setContent(this.args.secondaryMessage); + } this.$.bodyButtons.$.cancelButton.setShowing(this.args.cancelButton); }, acceptButton: function (inSender, inEvent) { diff --git a/web/org.openbravo.retail.giftcards/js/components/GiftCardReimburseAmount.js b/web/org.openbravo.retail.giftcards/js/components/GiftCardReimburseAmount.js new file mode 100644 --- /dev/null +++ b/web/org.openbravo.retail.giftcards/js/components/GiftCardReimburseAmount.js @@ -0,0 +1,75 @@ +/* + ************************************************************************************ + * Copyright (C) 2018 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. + ************************************************************************************ + */ + +/*global enyo, $, _ */ + +enyo.kind({ + kind: 'OB.UI.ModalAction', + name: 'GCNV.UI.ModalReimburseAmount', + autoDismiss: false, + executeOnShow: function () { + var me = this; + this.applyChange = false; + this.$.header.setContent(OB.I18N.getLabel('GCNV_LblCurrentAmount') + ': ' + OB.I18N.formatCurrency(this.args.amount)); + this.$.bodyButtons.$.btnModalReimburseAmountSearchInput.setValue(OB.I18N.formatCurrency(this.args.amount)); + window.setTimeout(function () { + me.$.bodyButtons.$.btnModalReimburseAmountSearchInput.focus(); + }, 100); + }, + executeOnHide: function () { + this.args.callback(this.applyChange, this.amount); + }, + bodyContent: { + i18nContent: 'GCNV_LblSelectReimburseAmount' + }, + bodyButtons: { + components: [{ + name: 'btnModalReimburseAmountSearchInput', + kind: 'OB.UI.SearchInput', + selectOnFocus: true + }, { + kind: 'GCNV.UI.btnApplyReimburse' + }] + } +}); + +enyo.kind({ + kind: 'OB.UI.ModalDialogButton', + name: 'GCNV.UI.btnApplyReimburse', + isDefaultAction: true, + i18nContent: 'OBPOS_LblApplyButton', + tap: function () { + var tmpAmount = this.owner.$.btnModalReimburseAmountSearchInput.getValue(); + if (OB.I18N.isValidNumber(tmpAmount)) { + while (tmpAmount.indexOf(OB.Format.defaultGroupingSymbol) >= 0) { + tmpAmount = tmpAmount.replace(OB.Format.defaultGroupingSymbol, ""); + } + var balance = this.owner.owner.args.amount, + amount = OB.I18N.parseNumber(tmpAmount); + this.owner.owner.amount = amount; + if (amount > balance) { + OB.UTIL.showConfirmation.display(OB.I18N.getLabel('OBPOS_notValidInput_header'), OB.I18N.getLabel('GCNV_amountGreaterThanAvailable', [OB.I18N.formatCurrency(balance)])); + return; + } + if (amount <= 0) { + OB.UTIL.showConfirmation.display(OB.I18N.getLabel('OBPOS_notValidInput_header'), OB.I18N.getLabel('GCNV_amountGreaterThanZero', [OB.I18N.formatCurrency(balance)])); + return; + } + this.owner.owner.applyChange = true; + this.doHideThisPopup(); + } else { + OB.UTIL.showConfirmation.display(OB.I18N.getLabel('OBPOS_notValidInput_header'), OB.I18N.getLabel('OBPOS_notValidQty')); + } + } +}); + +OB.UI.WindowView.registerPopup('OB.OBPOSCashMgmt.UI.CashManagement', { + kind: 'GCNV.UI.ModalReimburseAmount', + name: 'GCNV_modalReimburseAmount' +}); \ No newline at end of file diff --git a/web/org.openbravo.retail.giftcards/js/components/GiftCardReimbursePaymentSelector.js b/web/org.openbravo.retail.giftcards/js/components/GiftCardReimbursePaymentSelector.js new file mode 100644 --- /dev/null +++ b/web/org.openbravo.retail.giftcards/js/components/GiftCardReimbursePaymentSelector.js @@ -0,0 +1,280 @@ +/* + ************************************************************************************ + * Copyright (C) 2018 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. + ************************************************************************************ + */ + +/*global OB, Backbone, enyo, _, console*/ + +// Renders a modal popup with the available payment methods for reimburse gift card +enyo.kind({ + name: 'GCNV.UI.ModalReimbursePaymentSelector', + kind: 'OB.UI.Modal', + topPosition: '125px', + events: { + onShowPopup: '' + }, + handlers: { + onButtonPaymentChanged: 'buttonPaymentChanged', + onButtonPaymentChangedCancelled: 'buttonPaymentChangedCancelled' + }, + body: { + kind: 'GCNV.UI.ReimbursePaymentMethods' + }, + buttonPaymentChanged: function (inSender, inEvent) { + + if (inEvent && inEvent.status) { + var cashupMng = this.owner, + keyboard = inEvent.keyboard ? inEvent.keyboard : this.args.keyboard, + consumeOK = inEvent.consumeOK ? inEvent.consumeOK : this.args.consumeOK, + consumeFail = inEvent.consumeFail ? inEvent.consumeFail : this.args.consumeFail; + + var successCallback = function (successMessage) { + consumeOK(null, successMessage); + }; + + var errorCallback = function (errorMessage) { + consumeFail(null, errorMessage); + }; + + var convertAmount = function convertAmount(amount, fromCurrency, toCurrency) { + var converter = OB.UTIL.currency.findConverter(fromCurrency, toCurrency); + if (fromCurrency === toCurrency) { + return amount; + } else if (converter) { + return OB.DEC.mul(amount, converter.rate); + } else { + converter = OB.UTIL.currency.findConverter(fromCurrency, OB.UTIL.currency.webPOSDefaultCurrencyId()); + if (converter) { + return OB.UTIL.currency.toForeignCurrency(toCurrency, converter.getFinancialAmountOf(amount)); + } else { + return; + } + } + }; + + var getCurrentCashOf = function getCurrentCashOf(payment) { + var cashmgmtPayment = cashupMng.model.get('payments').find(function (pm) { + return payment.payment.id === pm.get('paymentmethod_id'); + }); + if (cashmgmtPayment) { + return cashmgmtPayment.get('total'); + } else { + return payment.currentCash; + } + }; + + var payment = inEvent.payment, + giftcard = inEvent.giftcard ? inEvent.giftcard : this.args.giftcard, + giftcardAmount = convertAmount(giftcard.reimbursedAmount, giftcard.currency, payment.paymentMethod.currency); + + // Check if payment method is cash and has enough cash + if (payment.paymentMethod.iscash) { + if (!payment.paymentMethod.allowdrops) { + errorCallback({ + message: 'GCNV_ErrorGiftCardNotAllowdrops', + params: [giftcard.searchKey], + keyboard: keyboard + }); + return; + } + var availableCash = OB.UTIL.currency.toForeignCurrency(payment.paymentMethod.currency, getCurrentCashOf(payment)); + if (availableCash < giftcardAmount) { + errorCallback({ + message: 'GCNV_ErrorGiftCardNotCash', + params: [giftcard.searchKey], + keyboard: keyboard + }); + return; + } + } + + // Check if card are already reimbursed + var isError = !OB.UTIL.isNullOrUndefined(_.find(cashupMng.model.depsdropstosave, function (pay) { + return pay.get('gcnvGiftCardId') === giftcard.id; + })); + if (isError) { + errorCallback({ + message: 'GCNV_ErrorCashMngAlreadyReimbursed', + params: [giftcard.searchKey], + keyboard: keyboard + }); + return; + } + + var criteria = { + bpartner: giftcard.businessPartner + }; + if (OB.MobileApp.model.hasPermission('OBPOS_remote.customer', true)) { + var bPartnerId = { + columns: ['bpartner'], + operator: 'equals', + value: giftcard.businessPartner, + isId: true + }; + var remoteCriteria = [bPartnerId]; + criteria.remoteFilters = remoteCriteria; + } + + OB.Dal.find(OB.Model.BPLocation, criteria, function (dataBps) { + if (dataBps.models[0]) { + giftcard.address = dataBps.models[0]; + } + // Request approval + OB.UTIL.Approval.requestApproval(cashupMng.model, 'GCNV_PaymentGiftCardReimbursed', function (approved) { + if (approved) { + // Add to Cash Management + cashupMng.currentPayment = { + allowopendrawer: payment.paymentMethod.allowopendrawer, + amount: giftcardAmount, + destinationKey: payment.payment.searchKey, + glItem: payment.paymentMethod.gLItemForDrops, + id: payment.payment.id, + identifier: payment.payment._identifier, + iscash: payment.paymentMethod.iscash, + isocode: payment.isocode, + rate: payment.rate, + type: "drop", + defaultProcess: 'N', + extendedType: 'GCNV_reimbursed', + extendedProp: { + gcnvGiftCardId: giftcard.id, + giftcard: giftcard, + allowOnlyOne: true + } + }; + + var reimburseEvent = _.find(OB.MobileApp.model.get('cashMgmtGiftCardsEvents'), function (event) { + return event.eventType === 'GCNV_reimbursed' && event.paymentMethodId === payment.paymentMethod.paymentMethod; + }); + + cashupMng.model.depsdropstosave.trigger('paymentDone', new Backbone.Model({ + id: reimburseEvent.id, + name: reimburseEvent.name + }), cashupMng.currentPayment, function () { + console.info("GCNV.UI.ModalReimbursePaymentSelector: " + cashupMng.windowName); + console.info("GCNV.UI.ModalReimbursePaymentSelector: pendingToSaveHaveCashManagementProvider = " + (cashupMng.model.pendingToSaveHaveCashManagementProvider ? 'defined' : 'undefined')); + if (cashupMng.model.pendingToSaveHaveCashManagementProvider()) { + keyboard.doShowPopup({ + popup: 'GCNV_UI_Message', + args: { + message: OB.I18N.getLabel('GCNV_ReimbursedSuccess', [OB.I18N.formatCurrencyWithSymbol(giftcardAmount, payment.symbol, payment.currencySymbolAtTheRight)]), + secondaryMessage: OB.I18N.getLabel('OBPOS_MsgCloseOrDoneCashManagement') + } + }); + } else { + successCallback({ + message: 'GCNV_ReimbursedSuccess', + params: [OB.I18N.formatCurrencyWithSymbol(giftcardAmount, payment.symbol, payment.currencySymbolAtTheRight)], + keyboard: keyboard + }); + } + }); + } + }); + }, function (tx, error) { + OB.UTIL.showError("OBDAL error: " + error); + }); + } + }, + buttonPaymentChangedCancelled: function (inSender, inEvent) { + if (inEvent.cashManagement) { + this.show(); + } + }, + executeOnShow: function () { + if (this.args.paymentMethods) { + var collection = new OB.Collection.GiftCardList(); + this.$.body.$.reimbursePaymentMethods.$.paymentMethods.setCollection(collection); + collection.reset(this.args.paymentMethods); + } + this.selectItem = false; + }, + executeOnHide: function () { + if (!this.selectItem) { + this.doShowPopup({ + popup: 'GCNV_UI_Details' + }); + } + }, + initComponents: function () { + this.header = OB.I18N.getLabel('GCNV_LblReimbursePaymentSelector'); + this.inherited(arguments); + } +}); + +enyo.kind({ + name: 'GCNV.UI.ReimbursePaymentMethods', + classes: 'row-fluid', + components: [{ + classes: 'span12', + components: [{ + name: 'paymentMethods', + kind: 'OB.UI.Table', + style: 'overflow: auto; max-height: 600px', + renderLine: 'GCNV.UI.ReimbursePaymentMethodsLine', + renderEmpty: 'OB.UI.RenderEmpty' + }] + }] +}); + +enyo.kind({ + name: 'GCNV.UI.ReimbursePaymentMethodsLine', + kind: 'OB.UI.SelectButton', + classes: 'gcnv-reimburse-payment-line', + events: { + onShowPopup: '', + onHideThisPopup: '' + }, + components: [{ + name: 'line', + style: 'padding: 1px 0px 1px 5px;' + }], + tap: function () { + this.inherited(arguments); + var dialog = this.owner.owner.owner.owner.owner.owner, + amount = dialog.args.giftcard.reimbursedAmount; + dialog.selectItem = true; + this.doHideThisPopup(); + if (this.model.get('paymentMethodCategory')) { + this.doShowPopup({ + popup: 'modalPaymentsSelect', + args: { + idCategory: this.model.get('paymentMethodCategory'), + availables: this.model.get('availables'), + cashManagement: true, + amount: amount + } + }); + } else { + var searchKey = this.model.get('searchKey'), + payment = _.find(OB.POS.modelterminal.get('payments'), function (pay) { + return pay.paymentMethod.searchKey === searchKey; + }); + if (payment) { + this.bubble('onPaymentChanged', { + payment: payment, + status: searchKey, + amount: amount + }); + } + } + }, + create: function () { + this.inherited(arguments); + this.$.line.setContent(this.model.get('name')); + } +}); + +OB.UI.WindowView.registerPopup('OB.OBPOSCashMgmt.UI.CashManagement', { + kind: 'GCNV.UI.ModalReimbursePaymentSelector', + name: 'GCNV_UI_ModalReimbursePaymentSelector' +}); + +OB.UI.WindowView.registerPopup('OB.OBPOSCashMgmt.UI.CashManagement', { + kind: 'OB.OBPOSPointOfSale.UI.Modals.ModalPaymentsSelect', + name: 'modalPaymentsSelect' +}); \ No newline at end of file diff --git a/web/org.openbravo.retail.giftcards/js/hooks/AddButtonToCashManagementHook.js b/web/org.openbravo.retail.giftcards/js/hooks/AddButtonToCashManagementHook.js --- a/web/org.openbravo.retail.giftcards/js/hooks/AddButtonToCashManagementHook.js +++ b/web/org.openbravo.retail.giftcards/js/hooks/AddButtonToCashManagementHook.js @@ -1,6 +1,6 @@ /* ************************************************************************************ - * Copyright (C) 2017 Openbravo S.L.U. + * Copyright (C) 2017-2018 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. @@ -28,217 +28,8 @@ stateless: true, permission: 'OBPOS_PaymentGiftCard', action: function (keyboard, txt) { - args.context.doShowPopup({ - popup: 'GCNV_UI_ModalGiftCards', - args: { - keyboard: args.context, - header: OB.I18N.getLabel('GCNV_HeaderGiftCardCashMng'), - notDefaultAction: true, - giftcardtype: ['BasedOnCreditNote', 'BasedOnGLItem'], - action: function (dialog, consumeOK, consumeFail) { - OB.UI.GiftCardUtils.service('org.openbravo.retail.giftcards.FindGiftCard', { - giftcard: dialog.args.giftcard.searchKey - }, function (result) { - var giftcard = result.data, - criteria = {}, - cashPayment; - - var successCallback = function (successMessage) { - consumeOK(null, successMessage); - }; - - var errorCallback = function (errorMessage) { - consumeFail(null, errorMessage); - }; - - // Verify is closed - if (giftcard.alertStatus === "C") { - errorCallback({ - message: 'GCNV_ErrorGiftCardClosed', - params: [giftcard.searchKey], - keyboard: args.context - }); - return; - } - - if (giftcard.type !== 'BasedOnCreditNote') { - // Verify is BasedOnGLItem - if (giftcard.type !== 'BasedOnGLItem') { - errorCallback({ - message: 'GCNV_ErrorGiftCardNotCertificate', - params: [giftcard.searchKey], - keyboard: args.context - }); - return; - } - - // Verify it can be reimbursed - var reasonType = _.find(OB.MobileApp.model.get('gcnvGiftcardReason'), function (reason) { - return reason.id === giftcard.category; - }); - if (!reasonType) { - errorCallback({ - message: 'GCNV_ErrorGiftCardNotFoundCategory', - params: [giftcard.searchKey], - keyboard: args.context - }); - return; - } - if (!reasonType.reimbursed) { - errorCallback({ - message: 'GCNV_ErrorGiftCardNotReimbursed', - params: [giftcard.searchKey], - keyboard: args.context - }); - return; - } - } - - // Find Cash payment method for GiftCard payment method - var cashPayments = _.filter(OB.MobileApp.model.get('payments'), function (p) { - return p.paymentMethod.iscash && p.paymentMethod.allowdrops; - }), - cashupMng = args.context.owner.owner.owner; - - function convertAmount(amount, fromCurrency, toCurrency) { - var converter = OB.UTIL.currency.findConverter(fromCurrency, toCurrency); - if (fromCurrency === toCurrency) { - return amount; - } else if (converter) { - return OB.DEC.mul(amount, converter.rate); - } else { - converter = OB.UTIL.currency.findConverter(fromCurrency, OB.UTIL.currency.webPOSDefaultCurrencyId()); - if (converter) { - return OB.UTIL.currency.toForeignCurrency(toCurrency, converter.getFinancialAmountOf(amount)); - } else { - return; - } - } - } - - function getCurrentCashOf(payment) { - var cashmgmtPayment = cashupMng.model.get('payments').find(function (pm) { - return payment.payment.id === pm.get('paymentmethod_id'); - }); - if (cashmgmtPayment) { - return cashmgmtPayment.get('total'); - } else { - return payment.currentCash; - } - } - - var amount = giftcard.currentamount ? giftcard.currentamount : giftcard.amount; - var availablePaymentMethods = _.map(cashPayments, function (cp) { - return { - currency: cp.paymentMethod.currency, - availableCash: OB.UTIL.currency.toForeignCurrency(cp.paymentMethod.currency, getCurrentCashOf(cp)), - giftcardAmount: convertAmount(amount, giftcard.currency, cp.paymentMethod.currency), - payment: cp, - isDefaultPayment: giftcard.currency === cp.paymentMethod.currency - }; - }); - - //Keep only Payment Methods with enough cash - availablePaymentMethods = availablePaymentMethods.filter(function (cur) { - return cur.availableCash >= cur.giftcardAmount; - }); - - if (availablePaymentMethods.length === 0) { - errorCallback({ - message: 'GCNV_ErrorGiftCardNotCash', - params: [giftcard.searchKey], - keyboard: args.context - }); - return; - } - - var apm = availablePaymentMethods.find(function (pay) { - return pay.isDefaultPayment; - }); - apm = apm || availablePaymentMethods[0]; - cashPayment = apm.payment; - - // Check if card are already reimbursed - var isError = false; - cashupMng.model.depsdropstosave.each(function (pay) { - if (pay.get('gcnvGiftCardId') === giftcard.id) { - isError = true; - } - }); - if (isError) { - errorCallback({ - message: 'GCNV_ErrorCashMngAlreadyReimbursed', - params: [giftcard.searchKey], - keyboard: args.context - }); - return; - } - - criteria.bpartner = giftcard.businessPartner; - if (OB.MobileApp.model.hasPermission('OBPOS_remote.customer', true)) { - var bPartnerId = { - columns: ['bpartner'], - operator: 'equals', - value: giftcard.businessPartner, - isId: true - }; - var remoteCriteria = [bPartnerId]; - criteria.remoteFilters = remoteCriteria; - } - OB.Dal.find(OB.Model.BPLocation, criteria, function (dataBps) { - if (dataBps.models[0]) { - giftcard.address = dataBps.models[0]; - } - // Request approval - OB.UTIL.Approval.requestApproval(cashupMng.model, 'GCNV_PaymentGiftCardReimbursed', function (approved) { - if (approved) { - // Add to Cash Management - cashupMng.currentPayment = { - allowopendrawer: cashPayment.paymentMethod.allowopendrawer, - amount: apm.giftcardAmount, - destinationKey: cashPayment.payment.searchKey, - glItem: cashPayment.paymentMethod.gLItemForDrops, - id: cashPayment.payment.id, - identifier: cashPayment.payment._identifier, - iscash: true, - isocode: cashPayment.isocode, - rate: cashPayment.rate, - type: "drop", - defaultProcess: 'N', - extendedType: 'GCNV_reimbursed', - extendedProp: { - gcnvGiftCardId: giftcard.id, - giftcard: giftcard - } - }; - - cashupMng.model.depsdropstosave.trigger('paymentDone', new Backbone.Model({ - id: reimburseEvent.id, - name: reimburseEvent.name - }), cashupMng.currentPayment); - - successCallback({ - message: 'GCNV_ReimbursedSuccess', - params: [OB.I18N.formatCurrencyWithSymbol(apm.giftcardAmount, cashPayment.symbol, cashPayment.currencySymbolAtTheRight)], - keyboard: args.context - }); - } - }); - }, function (tx, error) { - OB.UTIL.showError(error); - }); - }, function (error) { - var msgsplit = (error.exception.message || 'GCNV_ErrorGenericMessage').split(':'); - args.context.doShowPopup({ - popup: 'GCNV_UI_Message', - args: { - message: OB.I18N.getLabel(msgsplit[0], msgsplit.slice(1)) - } - }); - }); - } - } - }); + keyboard.$.OB_UI_MoreButtons.hide(); + OB.OBGCNE.Utils.openGiftCardSelector(args.context); } } }); diff --git a/web/org.openbravo.retail.giftcards/js/hooks/AddPaymentToCashManagementHook.js b/web/org.openbravo.retail.giftcards/js/hooks/AddPaymentToCashManagementHook.js new file mode 100644 --- /dev/null +++ b/web/org.openbravo.retail.giftcards/js/hooks/AddPaymentToCashManagementHook.js @@ -0,0 +1,29 @@ +/* + ************************************************************************************ + * Copyright (C) 2018 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. + ************************************************************************************ + */ + +/*global OB, enyo, Backbone, _ */ + +(function () { + + OB.UTIL.HookManager.registerHook('OBPOS_AddPaymentToCashManagement', function (args, callbacks) { + + var payment = _.find(OB.POS.modelterminal.get('payments'), function (p) { + return p.paymentMethod.searchKey === args.paymentMethod.searchKey; + }); + var reimburseEvent = _.find(OB.MobileApp.model.get('cashMgmtGiftCardsEvents'), function (event) { + return event.paymentMethodId === payment.paymentMethod.paymentMethod; + }); + if (!OB.UTIL.isNullOrUndefined(reimburseEvent)) { + args.context.get('payments').add(args.pay); + } + args.includePay = !OB.UTIL.isNullOrUndefined(reimburseEvent); + OB.UTIL.HookManager.callbackExecutor(args, callbacks); + }); + +}()); \ No newline at end of file diff --git a/web/org.openbravo.retail.giftcards/js/hooks/AfterRenderContainerWindowHook.js b/web/org.openbravo.retail.giftcards/js/hooks/AfterRenderContainerWindowHook.js new file mode 100644 --- /dev/null +++ b/web/org.openbravo.retail.giftcards/js/hooks/AfterRenderContainerWindowHook.js @@ -0,0 +1,25 @@ +/* + ************************************************************************************ + * Copyright (C) 2018 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. + ************************************************************************************ + */ + +/*global OB, enyo, Backbone, _ */ + +(function () { + + OB.UTIL.HookManager.registerHook('OBPOS_AfterRenderContainerWindow', function (args, callbacks) { + + if (args.window === 'retail.cashmanagement' && args.parameters && args.parameters._entityName === 'GCNV_GiftCardInst' && (args.parameters.type === 'BasedOnGLItem' || args.parameters.type === 'BasedOnCreditNote')) { + OB.MobileApp.view.waterfall('onCashManagementOpenWindow', { + parameters: args.parameters + }); + } + + OB.UTIL.HookManager.callbackExecutor(args, callbacks); + }); + +}()); \ No newline at end of file diff --git a/web/org.openbravo.retail.giftcards/js/hooks/preSaveCashManagementsHook.js b/web/org.openbravo.retail.giftcards/js/hooks/preSaveCashManagementsHook.js --- a/web/org.openbravo.retail.giftcards/js/hooks/preSaveCashManagementsHook.js +++ b/web/org.openbravo.retail.giftcards/js/hooks/preSaveCashManagementsHook.js @@ -12,41 +12,66 @@ (function () { OB.UTIL.HookManager.registerHook('OBPOS_PreSaveCashManagements', function (args, callback) { - var callbackLogic; + var callbackLogic, processDropsDeposits, completeTransaction; - function processDropsDeposits(dropsdeps, index) { + completeTransaction = function (result, dropsdeps, index) { + var dropdep = dropsdeps.at(index), + giftcard = dropdep.get('giftcard'); + dropdep.set('transactionId', result.transaction.id); + OB.UI.GiftCardUtils.getPaymentMethodCashUp(giftcard.type, function (payMthd) { + var deps = payMthd.get('totalDeposits') + OB.DEC.div(dropdep.get('origAmount'), payMthd.get('rate')); + payMthd.set('totalDeposits', deps); + OB.UI.GiftCardUtils.updatePaymentMethodCashUp(payMthd, giftcard.searchKey, "GiftCardCertificate.reimbursed", function () { + processDropsDeposits(dropsdeps, index + 1); + }); + }); + }; + + processDropsDeposits = function (dropsdeps, index) { if (index === dropsdeps.length) { OB.UTIL.HookManager.callbackExecutor(args, callback); } else { if (dropsdeps.at(index).get('extendedType') === 'GCNV_reimbursed' && _.find(OB.MobileApp.model.get('payments'), function (payment) { return payment.id === dropsdeps.at(index).get('paymentMethodId') && payment.paymentMethod.countpaymentincashup; })) { - OB.UI.GiftCardUtils.service('org.openbravo.retail.giftcards.CloseGiftCard', { - _executeInOneServer: true, - _tryCentralFromStore: true, - giftcard: dropsdeps.at(index).get('giftcard').id - }, function (result) { - dropsdeps.at(index).set('transactionId', result.transaction.id); - callbackLogic(dropsdeps, index); - }, function () { - callbackLogic(dropsdeps, index); - }); + var dropdep = dropsdeps.at(index), + giftcard = dropdep.get('giftcard'); + if (dropdep.get('amount') < giftcard.currentamount) { + OB.UI.GiftCardUtils.service('org.openbravo.retail.giftcards.ConsumeGiftCardAmount', { + giftcard: giftcard.searchKey, + _executeInOneServer: true, + _tryCentralFromStore: true, + amount: dropdep.get('amount'), + isReturn: false, + transaction: null, + hasPaymentMethod: true + }, function (result) { + completeTransaction(result, dropsdeps, index); + }, function (error) { + if (error && error.exception) { + OB.UTIL.showConfirmation.display(OB.I18N.getLabel('OBPOS_CashMgmtError'), error.exception.message); + } + }); + } else { + OB.UI.GiftCardUtils.service('org.openbravo.retail.giftcards.CloseGiftCard', { + _executeInOneServer: true, + _tryCentralFromStore: true, + giftcard: giftcard.id + }, function (result) { + completeTransaction(result, dropsdeps, index); + }, function (error) { + if (error && error.exception) { + OB.UTIL.showConfirmation.display(OB.I18N.getLabel('OBPOS_CashMgmtError'), error.exception.message); + } + }); + } } else { processDropsDeposits(dropsdeps, index + 1); } } - } - processDropsDeposits(args.dropsdeps, 0); + }; - callbackLogic = function (dropsdeps, index) { - OB.UI.GiftCardUtils.getPaymentMethodCashUp(dropsdeps.at(index).get('giftcard').type, function (payMthd) { - var deps = payMthd.get('totalDeposits') + OB.DEC.div(dropsdeps.at(index).get('origAmount'), payMthd.get('rate')); - payMthd.set('totalDeposits', deps); - OB.UI.GiftCardUtils.updatePaymentMethodCashUp(payMthd, dropsdeps.at(index).get('giftcard').searchKey, "GiftCardCertificate.reimbursed", function () { - processDropsDeposits(dropsdeps, index + 1); - }); - }); - }; + processDropsDeposits(args.dropsdeps, 0); }); }()); \ No newline at end of file diff --git a/web/org.openbravo.retail.giftcards/js/model/GiftCardUtils.js b/web/org.openbravo.retail.giftcards/js/model/GiftCardUtils.js --- a/web/org.openbravo.retail.giftcards/js/model/GiftCardUtils.js +++ b/web/org.openbravo.retail.giftcards/js/model/GiftCardUtils.js @@ -623,4 +623,168 @@ return date.getTime() < now.getTime(); }; + OB.OBGCNE.Utils.openGiftCardSelector = function (context, giftcardId) { + context.doShowPopup({ + popup: 'GCNV_UI_ModalGiftCards', + args: { + keyboard: context, + header: OB.I18N.getLabel('GCNV_HeaderGiftCardCashMng'), + notDefaultAction: true, + giftcardtype: ['BasedOnCreditNote', 'BasedOnGLItem'], + giftcardId: giftcardId, + action: function (dialog, consumeOK, consumeFail) { + OB.UI.GiftCardUtils.service('org.openbravo.retail.giftcards.FindGiftCard', { + giftcard: dialog.args.giftcard.searchKey, + loadReimbursedMethods: true + }, function (result) { + var giftcard = result.data, + errorCallback = function (errorMessage) { + consumeFail(null, errorMessage); + }; + + // Verify is closed + if (giftcard.alertStatus === "C") { + errorCallback({ + message: 'GCNV_ErrorGiftCardClosed', + params: [giftcard.searchKey], + keyboard: context + }); + return; + } + + if (giftcard.type !== 'BasedOnCreditNote') { + // Verify is BasedOnGLItem + if (giftcard.type !== 'BasedOnGLItem') { + errorCallback({ + message: 'GCNV_ErrorGiftCardNotCertificate', + params: [giftcard.searchKey], + keyboard: context + }); + return; + } + + // Verify it can be reimbursed + var reasonType = _.find(OB.MobileApp.model.get('gcnvGiftcardReason'), function (reason) { + return reason.id === giftcard.category; + }); + if (!reasonType) { + errorCallback({ + message: 'GCNV_ErrorGiftCardNotFoundCategory', + params: [giftcard.searchKey], + keyboard: context + }); + return; + } + if (!reasonType.reimbursed) { + errorCallback({ + message: 'GCNV_ErrorGiftCardNotReimbursed', + params: [giftcard.searchKey], + keyboard: context + }); + return; + } + } + + // Ask reimbursed amount + OB.MobileApp.view.waterfall('onHidePopup', { + popup: 'GCNV_UI_Details', + testingHide: true + }); + OB.MobileApp.view.waterfall('onShowPopup', { + popup: 'GCNV_modalReimburseAmount', + args: { + amount: giftcard.currentamount, + callback: function (applyChange, reimbursedAmount) { + if (applyChange) { + giftcard.reimbursedAmount = reimbursedAmount; + // Select Cash payment method for GiftCard payment method + var paymentMethods = []; + _.each(giftcard.reimbursedMethods, function (method) { + var item = _.find(OB.MobileApp.model.get('payments'), function (p) { + return p.paymentMethod.searchKey === method.searchKey; + }); + if (item) { + if (item.paymentMethod.paymentMethodCategory) { + var category = _.find(paymentMethods, function (pm) { + return pm.paymentMethodCategory === item.paymentMethod.paymentMethodCategory; + }); + if (!category) { + method.paymentMethodCategory = item.paymentMethod.paymentMethodCategory; + method.name = item.paymentMethod.paymentMethodCategory$_identifier; + method.availables = [method.searchKey]; + method.searchKey = ''; + paymentMethods.push(method); + } else { + category.availables.push(method.searchKey); + } + } else { + paymentMethods.push(method); + } + } else { + OB.UTIL.showError('Not found payment method: ' + method.name); + } + }); + + if (paymentMethods.length > 1 || (paymentMethods.length === 1 && paymentMethods[0].paymentMethodCategory)) { + OB.MobileApp.view.waterfall('onHidePopup', { + popup: 'GCNV_UI_Details', + testingHide: true + }); + OB.MobileApp.view.waterfall('onShowPopup', { + popup: 'GCNV_UI_ModalReimbursePaymentSelector', + args: { + paymentMethods: paymentMethods, + giftcard: giftcard, + consumeOK: consumeOK, + consumeFail: consumeFail, + keyboard: context + } + }); + } else if (paymentMethods.length === 1) { + var searchKey = paymentMethods[0].searchKey, + payment = _.find(OB.POS.modelterminal.get('payments'), function (pay) { + return pay.paymentMethod.searchKey === searchKey; + }); + if (payment) { + OB.MobileApp.view.waterfall('onPaymentChanged', { + payment: payment, + status: searchKey, + giftcard: giftcard, + consumeOK: consumeOK, + consumeFail: consumeFail, + keyboard: context + }); + } else { + errorCallback({ + message: 'GCNV_ErrorGiftCardNotFoundReimbursePaymentMethod', + params: [giftcard.searchKey], + keyboard: context + }); + } + } else { + errorCallback({ + message: 'GCNV_ErrorGiftCardNotFoundReimbursePaymentMethod', + params: [giftcard.searchKey], + keyboard: context + }); + } + } + } + } + }); + }, function (error) { + var msgsplit = (error.exception.message || 'GCNV_ErrorGenericMessage').split(':'); + context.doShowPopup({ + popup: 'GCNV_UI_Message', + args: { + message: OB.I18N.getLabel(msgsplit[0], msgsplit.slice(1)) + } + }); + }); + } + } + }); + + }; + }()); \ No newline at end of file test-mobile-sampledata.diff [^] (3,294 bytes) 2018-11-12 14:08 [Show Content] [Hide Content] diff --git a/referencedata/sampledata/The_White_Valley_Group/OBPOS_APP_PAYMENT_TYPE.xml b/referencedata/sampledata/The_White_Valley_Group/OBPOS_APP_PAYMENT_TYPE.xml --- a/referencedata/sampledata/The_White_Valley_Group/OBPOS_APP_PAYMENT_TYPE.xml +++ b/referencedata/sampledata/The_White_Valley_Group/OBPOS_APP_PAYMENT_TYPE.xml @@ -800,7 +800,7 @@ <ISACTIVE><![CDATA[Y]]></ISACTIVE> <CREATED><![CDATA[2014-11-19 10:25:53.766]]></CREATED> <CREATEDBY><![CDATA[100]]></CREATEDBY> - <UPDATED><![CDATA[2014-11-19 10:25:55.372]]></UPDATED> + <UPDATED><![CDATA[2018-09-12 09:19:12.226]]></UPDATED> <UPDATEDBY><![CDATA[100]]></UPDATEDBY> <VALUE><![CDATA[OBPOS_creditcard]]></VALUE> <NAME><![CDATA[Credit card]]></NAME> @@ -831,6 +831,7 @@ <REFUNDABLE><![CDATA[Y]]></REFUNDABLE> <ISREVERSABLE><![CDATA[Y]]></ISREVERSABLE> <COUNTPAYMENTINCASHUP><![CDATA[Y]]></COUNTPAYMENTINCASHUP> + <CASHMNGPROVIDER><![CDATA[OB.UI.MockPayment]]></CASHMNGPROVIDER> <EM_OBDICO_ISDIGITALCOUPON><![CDATA[N]]></EM_OBDICO_ISDIGITALCOUPON> <EM_OBSCO_PRINTRECEIPT><![CDATA[never]]></EM_OBSCO_PRINTRECEIPT> <EM_POSS_INITIALCOUNTCASH><![CDATA[N]]></EM_POSS_INITIALCOUNTCASH> diff --git a/referencedata/sampledata/The_White_Valley_Group/OBRETCO_CMEVENTS.xml b/referencedata/sampledata/The_White_Valley_Group/OBRETCO_CMEVENTS.xml --- a/referencedata/sampledata/The_White_Valley_Group/OBRETCO_CMEVENTS.xml +++ b/referencedata/sampledata/The_White_Valley_Group/OBRETCO_CMEVENTS.xml @@ -213,9 +213,9 @@ <ISACTIVE><![CDATA[Y]]></ISACTIVE> <CREATED><![CDATA[2016-01-25 12:35:46.155]]></CREATED> <CREATEDBY><![CDATA[100]]></CREATEDBY> - <UPDATED><![CDATA[2016-01-25 12:35:46.155]]></UPDATED> + <UPDATED><![CDATA[2018-09-12 09:17:54.106]]></UPDATED> <UPDATEDBY><![CDATA[100]]></UPDATEDBY> - <NAME><![CDATA[Gift Cards - Reimbursed]]></NAME> + <NAME><![CDATA[Gift Cards - Reimbursed (Cash)]]></NAME> <C_CURRENCY_ID><![CDATA[102]]></C_CURRENCY_ID> <FIN_PAYMENTMETHOD_ID><![CDATA[45A202BF44884F05B8A1BF741E2063B6]]></FIN_PAYMENTMETHOD_ID> <EVENTTYPE><![CDATA[GCNV_reimbursed]]></EVENTTYPE> @@ -287,6 +287,22 @@ </OBRETCO_CMEVENTS> <OBRETCO_CMEVENTS> + <OBRETCO_CMEVENTS_ID><![CDATA[5031B825F46F4E1D87484674B55BA753]]></OBRETCO_CMEVENTS_ID> + <AD_CLIENT_ID><![CDATA[39363B0921BB4293B48383844325E84C]]></AD_CLIENT_ID> + <AD_ORG_ID><![CDATA[E41B10B390B0430289A00FD6E5CC0CDA]]></AD_ORG_ID> + <ISACTIVE><![CDATA[Y]]></ISACTIVE> + <CREATED><![CDATA[2018-09-12 09:18:35.351]]></CREATED> + <CREATEDBY><![CDATA[100]]></CREATEDBY> + <UPDATED><![CDATA[2018-09-12 09:18:35.351]]></UPDATED> + <UPDATEDBY><![CDATA[100]]></UPDATEDBY> + <NAME><![CDATA[Gift Cards - Reimbursed (Wire Transfer)]]></NAME> + <C_CURRENCY_ID><![CDATA[102]]></C_CURRENCY_ID> + <FIN_PAYMENTMETHOD_ID><![CDATA[5A741F883A31408CA3AC097D76AA6D32]]></FIN_PAYMENTMETHOD_ID> + <EVENTTYPE><![CDATA[GCNV_reimbursed]]></EVENTTYPE> + <FIN_FINANCIAL_ACCOUNT_ID><![CDATA[0CD3DD983CFE46B4B2A6B73C74D35280]]></FIN_FINANCIAL_ACCOUNT_ID> +</OBRETCO_CMEVENTS> + +<OBRETCO_CMEVENTS> <OBRETCO_CMEVENTS_ID><![CDATA[515141A289B04CC6AE5470E8745B9FB8]]></OBRETCO_CMEVENTS_ID> <AD_CLIENT_ID><![CDATA[39363B0921BB4293B48383844325E84C]]></AD_CLIENT_ID> <AD_ORG_ID><![CDATA[3B187EC130A549A7A9388F8060EF156D]]></AD_ORG_ID> | |||||||
Relationships [ Relation Graph ] [ Dependency Graph ] | |
Notes | |
(0107381) ebecerra (developer) 2018-10-18 08:47 edited on: 2018-10-22 10:30 |
Change description: ------------------------------------------------------------ - org.openbravo.mobile.core ------------------------------------------------------------ * source/model/ob-terminal-model.js - Add hook: OBPOS_AfterRenderContainerWindow - Add a parameter to: OB.MobileApp.model.navigate and add a hook: OBPOS_AfterRenderContainerWindow to be passed a new parameter ------------------------------------------------------------ - org.openbravo.retail.posterminal ------------------------------------------------------------ * js/cashmgmt/model/cashmgmt-model.js - When Done a payment, only validate Cash - Check pending drop to save have cash management provider * js/cashmgmt/view/cashmgmt.js - Button Done: Show Cash Management Provider dialog - Add following event handlers: + onPaymentChanged + onPaymentChangedCancelled + onCashManagementDisableKeyboardButtons - Register window: OB.OBPOSCashMgmt.UI.CashManagement * js/cashmgmt/view/cashmgmtkeyboard.js - Add the event handlers: onDisableKeyboardButtons * js/components/mockpayments.js - Check if mock dialog is used from receipt Payment or Cash Management * js/components/modalpayment.js - Add related window: Cash Management * js/pointofsale/view/modals/modalpayments.js - Add business logic when Credit Card Selector is open from CashManagement * js/pointofsale/view/pointofsale.js - Add event: onPaymentChangedCancelled ------------------------------------------------------------ - org.openbravo.retail.giftcards ------------------------------------------------------------ [src/org/openbravo/retail/giftcards] * hooks/ProcessCashMgmtHookGiftCard.java - Add a new payment when Gift Card transaction do not have one * master/CashMgmtEvents.java - Add following field to CashMgmtEvents: + Payment Method identifier + Payment Method Name * process/CreditNoteException.java - A new class Exception * process/GiftCardGLItemUtils.java - Refactor code to add a new method: makePayment * FindGiftCard.java - Allow to load reimburse methods when find a Gitt Card * GCNVComponentProvider.java - Add new JS files [web/org.openbravo.retail.giftcards] * js/components/GiftCardDetails.js - Allow return for gift card types: BasedOnGLItem and BasedOnCreditNote - Navigate to Cash Management window when gift card types are BasedOnGLItem or BasedOnCreditNote - Refactor "executeOnShow" when is opened from Cash Management Window * js/components/GiftCardDialog.js - Refactor "executeOnShow" to allow prefilter by GiftCard Identifier * js/components/GiftCardReimburseAmount.js - A new dialog to enter amount to reimburse * js/components/GiftCardReimbursePaymentSelector.js - A new dialog to select a payment method used to reimburse * js/hooks/AddButtonToCashManagementHook.js - Use refactor code (OB.OBGCNE.Utils.openGiftCardSelector) * js/hooks/AddPaymentToCashManagementHook.js - Register hook: OBPOS_AddPaymentToCashManagement * js/hooks/AfterRenderContainerWindowHook.js - Register hook: OBPOS_AfterRenderContainerWindow, to open Gift Card selector, when Cash Management is opened from GiftCardDetail dialog (button Return) * js/hooks/preSaveCashManagementsHook.js - Refactor code * js/model/GiftCardUtils.js - Add a new utility method: openGiftCardSelector |
(0107844) hgbot (developer) 2018-11-12 11:58 |
Repository: erp/pmods/org.openbravo.mobile.core Changeset: bcdf375d222c18e70f50d2df0121ed131dd288fb Author: Eduardo Becerra <ebec70 <at> yahoo.com> Date: Mon Nov 12 11:58:09 2018 +0100 URL: http://code.openbravo.com/erp/pmods/org.openbravo.mobile.core/rev/bcdf375d222c18e70f50d2df0121ed131dd288fb [^] Related issue 39200: Allow reimburse Gift Card with different payment methods - Add event handler "onDisableButton" to component "OB.UI.ToolbarMore" - Add a "parameters" argument to OB.Model.Terminal.navigate function - Add a new hook: OBPOS_AfterRenderContainerWindow --- M web/org.openbravo.mobile.core/source/component/ob-keyboard.js M web/org.openbravo.mobile.core/source/model/ob-terminal-model.js --- |
(0107852) hgbot (developer) 2018-11-12 14:05 |
Repository: tools/automation/pi-mobile Changeset: 12b5fca97516022ad379dae1b74244890933484d Author: Eduardo Becerra <ebec70 <at> yahoo.com> Date: Mon Nov 12 13:18:31 2018 +0100 URL: http://code.openbravo.com/tools/automation/pi-mobile/rev/12b5fca97516022ad379dae1b74244890933484d [^] Related issue 39200: Allow reimburse Gift Card with different payment methods --- M src-test/org/openbravo/test/mobile/retail/extmodules/selenium/TestIdExtModules.java M src-test/org/openbravo/test/mobile/retail/extmodules/selenium/tests/creditnote/CreditNoteReimburse.java M src-test/org/openbravo/test/mobile/retail/extmodules/selenium/tests/giftcards/I38405_VerifyCashUpWhenGiftCardIsRefunded.java M src-test/org/openbravo/test/mobile/retail/extmodules/selenium/tests/giftcards/ReimburseCard.java M src-test/org/openbravo/test/mobile/retail/extmodules/selenium/tests/giftcards/TryReimburseCardNotReimbursable.java A src-test/org/openbravo/test/mobile/retail/extmodules/selenium/tests/giftcards/I39200_ReimburseInDifferentPaymentMethods.java --- |
(0107853) hgbot (developer) 2018-11-12 14:06 |
Repository: erp/pmods/org.openbravo.retail.posterminal Changeset: 3bca8320511c82600fc16c06453b81984a387a2d Author: Eduardo Becerra <ebec70 <at> yahoo.com> Date: Mon Nov 12 14:05:45 2018 +0100 URL: http://code.openbravo.com/erp/pmods/org.openbravo.retail.posterminal/rev/3bca8320511c82600fc16c06453b81984a387a2d [^] Related issue 39200: Allow reimburse Gift Card with different payment methods - New column/field: "Cash Management Provider" was added to table OBPOS_App_Payment_Type to define an external payment provider who processes this kind of refund types - Add a new process definition: cashMngPaymentDone, to define the start and finish of payment done on Cash Management window - Add a new "Cash Management Provider". By default use "OB.UI.MockPayment" - Add a new event: onPaymentChangedCancelled is trigger when no select any payment method - Modify ModalPayment to include "OB.OBPOSCashMgmt.Model.CashManagement" as parameter - Modify MockPayment to complete payment process on Cash Management window - Modify OB.OBPOSCashMgmt.Model.CashManagement to use process definition: cashMngPaymentDone - Add a new hook: OBPOS_AddPaymentToCashManagement to be executed when "Cash Up Management" window load the payment methods - Modify "cashmgmtkeyboard.js" to enable/disable button when process "cashMngPaymentDone" is executed --- M src-db/database/model/tables/OBPOS_APP_PAYMENT_TYPE.xml M src-db/database/sourcedata/AD_COLUMN.xml M src-db/database/sourcedata/AD_ELEMENT.xml M src-db/database/sourcedata/AD_FIELD.xml M src-db/database/sourcedata/AD_MESSAGE.xml M src-db/database/sourcedata/AD_REFERENCE.xml M src-db/database/sourcedata/AD_REF_LIST.xml M src-db/database/sourcedata/OBMOBC_PROCESS_DEFINITION.xml M web/org.openbravo.retail.posterminal/js/cashmgmt/model/cashmgmt-model.js M web/org.openbravo.retail.posterminal/js/cashmgmt/view/cashmgmt.js M web/org.openbravo.retail.posterminal/js/cashmgmt/view/cashmgmtkeyboard.js M web/org.openbravo.retail.posterminal/js/components/mockpayments.js M web/org.openbravo.retail.posterminal/js/components/modalpayment.js M web/org.openbravo.retail.posterminal/js/pointofsale/view/modals/modalpayments.js M web/org.openbravo.retail.posterminal/js/pointofsale/view/pointofsale.js --- |
(0107854) hgbot (developer) 2018-11-12 14:07 |
Repository: erp/pmods/org.openbravo.retail.giftcards Changeset: 3560830d8fab70c56751576772f204de9e3f1991 Author: Eduardo Becerra <ebec70 <at> yahoo.com> Date: Mon Nov 12 14:06:59 2018 +0100 URL: http://code.openbravo.com/erp/pmods/org.openbravo.retail.giftcards/rev/3560830d8fab70c56751576772f204de9e3f1991 [^] Related issue 39200: Allow reimburse Gift Card with different payment methods - Add message for labels, messages, errors and buttons - Change: ProcessCashMgmtHookGiftCard.java to make payment and transactions when reimburse a gift card or credit note - Change: CashMgmtEvents.java to return payment method information for events (id and name) - Change: FindGiftCard.java to allow return payment methods to reimburse to "Credit Note" and "Gift Card Certificate" - Change: ListGiftCard.java to sort gift card by "searckKey" - Refactor code of GiftCardUtils.js and AddButtonToCashManagementHook.js to reuse "openGiftCardSelector" functionality - Change: preSaveCashManagementsHook.js to consume GiftCard when reimburse - Add a new hook implementation: OBPOS_AfterRenderContainerWindow, to open Gift Card Detail dialog if navigate to Cash Management from gift card selector - Add a new hook implementation: OBPOS_AddPaymentToCashManagement, to add payments to different payment method in left panel - Change: GiftCardDetails.js to allow open reimburse in Cash Management window when push "Return" button - Change: GiftCardDialog.js to filter by a gift card identifier - Change: GiftCardMessage.js to allow more complex notification messages - Add a new dialog "GCNV.UI.ModalReimburseAmount" to select reimburse amount - Add a new dialog "GCNV.UI.ModalReimbursePaymentSelector" to select the payment method to reimburse --- M src-db/database/sourcedata/AD_COLUMN.xml M src-db/database/sourcedata/AD_MESSAGE.xml M src/org/openbravo/retail/giftcards/FindGiftCard.java M src/org/openbravo/retail/giftcards/GCNVComponentProvider.java M src/org/openbravo/retail/giftcards/ListGiftCard.java M src/org/openbravo/retail/giftcards/hooks/ProcessCashMgmtHookGiftCard.java M src/org/openbravo/retail/giftcards/master/CashMgmtEvents.java M src/org/openbravo/retail/giftcards/process/GiftCardGLItemUtils.java M web/org.openbravo.retail.giftcards/css/gcnv.css M web/org.openbravo.retail.giftcards/js/components/GiftCardDetails.js M web/org.openbravo.retail.giftcards/js/components/GiftCardDialog.js M web/org.openbravo.retail.giftcards/js/components/GiftCardMessage.js M web/org.openbravo.retail.giftcards/js/hooks/AddButtonToCashManagementHook.js M web/org.openbravo.retail.giftcards/js/hooks/preSaveCashManagementsHook.js M web/org.openbravo.retail.giftcards/js/model/GiftCardUtils.js A src/org/openbravo/retail/giftcards/process/CreditNoteException.java A web/org.openbravo.retail.giftcards/js/components/GiftCardReimburseAmount.js A web/org.openbravo.retail.giftcards/js/components/GiftCardReimbursePaymentSelector.js A web/org.openbravo.retail.giftcards/js/hooks/AddPaymentToCashManagementHook.js A web/org.openbravo.retail.giftcards/js/hooks/AfterRenderContainerWindowHook.js --- |
Issue History | |||
Date Modified | Username | Field | Change |
2018-08-30 10:01 | ebecerra | New Issue | |
2018-08-30 10:01 | ebecerra | Assigned To | => Retail |
2018-08-30 10:01 | ebecerra | Triggers an Emergency Pack | => No |
2018-09-10 13:25 | ebecerra | File Added: posterminal.diff | |
2018-09-10 13:43 | ebecerra | File Added: mobile-core.diff | |
2018-09-12 09:24 | ebecerra | File Added: test-mobile-sampledata.diff | |
2018-09-17 10:55 | ebecerra | File Added: giftcards.diff | |
2018-09-19 08:50 | ebecerra | File Deleted: giftcards.diff | |
2018-09-19 08:50 | ebecerra | File Added: giftcards.diff | |
2018-09-19 09:27 | ebecerra | File Added: test-pi-mobile.diff | |
2018-09-20 13:02 | ebecerra | File Deleted: test-pi-mobile.diff | |
2018-09-20 13:02 | ebecerra | File Added: test-pi-mobile.diff | |
2018-09-20 13:21 | ebecerra | File Deleted: posterminal.diff | |
2018-09-20 13:21 | ebecerra | File Added: posterminal.diff | |
2018-09-26 10:14 | ebecerra | File Added: posterminal-db.diff | |
2018-10-18 08:47 | ebecerra | Note Added: 0107381 | |
2018-10-18 09:00 | ebecerra | Note Edited: 0107381 | View Revisions |
2018-10-18 09:18 | ebecerra | Note Edited: 0107381 | View Revisions |
2018-10-18 09:21 | ebecerra | Note Edited: 0107381 | View Revisions |
2018-10-18 09:40 | ebecerra | Note Edited: 0107381 | View Revisions |
2018-10-22 10:30 | ebecerra | Note Edited: 0107381 | View Revisions |
2018-10-25 12:58 | ebecerra | File Added: test-pi-mobile-partial-reimburse.diff | |
2018-11-12 11:58 | hgbot | Checkin | |
2018-11-12 11:58 | hgbot | Note Added: 0107844 | |
2018-11-12 12:00 | ebecerra | File Deleted: mobile-core.diff | |
2018-11-12 12:00 | ebecerra | File Added: mobile-core.diff | |
2018-11-12 12:18 | ebecerra | File Deleted: posterminal.diff | |
2018-11-12 12:18 | ebecerra | File Deleted: posterminal-db.diff | |
2018-11-12 12:18 | ebecerra | File Added: posterminal.diff | |
2018-11-12 13:23 | ebecerra | File Deleted: test-pi-mobile.diff | |
2018-11-12 13:23 | ebecerra | File Deleted: test-pi-mobile-partial-reimburse.diff | |
2018-11-12 13:24 | ebecerra | File Added: pi-mobile.diff | |
2018-11-12 14:05 | hgbot | Checkin | |
2018-11-12 14:05 | hgbot | Note Added: 0107852 | |
2018-11-12 14:06 | hgbot | Checkin | |
2018-11-12 14:06 | hgbot | Note Added: 0107853 | |
2018-11-12 14:07 | hgbot | Checkin | |
2018-11-12 14:07 | hgbot | Note Added: 0107854 | |
2018-11-12 14:07 | ebecerra | File Deleted: giftcards.diff | |
2018-11-12 14:07 | ebecerra | File Added: giftcards.diff | |
2018-11-12 14:07 | ebecerra | File Deleted: test-mobile-sampledata.diff | |
2018-11-12 14:08 | ebecerra | File Added: test-mobile-sampledata.diff | |
2018-11-16 08:36 | marvintm | Status | new => scheduled |
2018-11-16 08:36 | marvintm | Assigned To | Retail => ebecerra |
2018-11-16 08:36 | marvintm | Status | scheduled => resolved |
2018-11-16 08:36 | marvintm | Fixed in Version | => RR19Q1 |
2018-11-16 08:36 | marvintm | Resolution | open => fixed |
2018-11-16 08:37 | marvintm | Review Assigned To | => migueldejuana |
2018-11-16 08:37 | marvintm | Status | resolved => closed |
Copyright © 2000 - 2009 MantisBT Group |