Attached Files | 45293_19Q3_mobilecore.diff [^] (2,806 bytes) 2020-11-04 09:08 [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
index 2c9f9a30..a6b89786 100644
--- a/web/org.openbravo.mobile.core/source/component/ob-keyboard.js
+++ b/web/org.openbravo.mobile.core/source/component/ob-keyboard.js
@@ -1051,8 +1051,24 @@ enyo.kind({
this.virtualKeypressHandler(inEvent.action);
},
+ handleKeyPress: function(button) {
+ var me = this;
+
+ if (button.$.button.disabled) {
+ return true;
+ }
+ if (button && button.definition && button.definition.includedInPopUp) {
+ me.virtualKeypressHandler(button.command, {
+ fromPopup: button.definition.includedInPopUp
+ });
+ } else {
+ me.virtualKeypressHandler(button.command);
+ }
+ },
+
registerButton: function(inSender, inEvent) {
var me = this,
+ payment,
button = inEvent.originator;
if (button.command) {
if (button.definition) {
@@ -1080,35 +1096,32 @@ enyo.kind({
}
if (button.command) {
- button.$.button.tap = function() {
- OB.UTIL.HookManager.executeHooks(
- 'OBMOBC_PrePaymentSelected',
- {
- paymentSelected: button,
- model: me.model,
- receipt: me.receipt
- },
- function(args) {
- if (args && args.cancellation && args.cancellation === true) {
- return;
- }
- if (button.$.button.disabled) {
- return true;
- }
- if (
- button &&
- button.definition &&
- button.definition.includedInPopUp
- ) {
- me.virtualKeypressHandler(button.command, {
- fromPopup: button.definition.includedInPopUp
- });
- } else {
- me.virtualKeypressHandler(button.command);
+ payment = OB.MobileApp.model.paymentnames[button.command];
+
+ if (payment) {
+ button.$.button.tap = function() {
+ OB.UTIL.HookManager.executeHooks(
+ 'OBMOBC_PrePaymentSelected',
+ {
+ paymentSelected: button,
+ paymentInfo: button.command,
+ model: me.model,
+ receipt: me.receipt
+ },
+ function(args) {
+ if (args && args.cancellation && args.cancellation === true) {
+ return;
+ }
+
+ me.handleKeyPress(button);
}
- }
- );
- };
+ );
+ };
+ } else {
+ button.$.button.tap = function() {
+ me.handleKeyPress(button);
+ };
+ }
this.addButton(button.command, button.$.button);
button.$.button.removeClass('btnkeyboard-inactive');
45293_19Q3_posterminal.diff [^] (6,350 bytes) 2020-11-04 09:08 [Show Content] [Hide Content]diff --git a/web/org.openbravo.retail.posterminal/js/pointofsale/view/keyboard-toolbars.js b/web/org.openbravo.retail.posterminal/js/pointofsale/view/keyboard-toolbars.js
index be03423e7..ccabbfac0 100644
--- a/web/org.openbravo.retail.posterminal/js/pointofsale/view/keyboard-toolbars.js
+++ b/web/org.openbravo.retail.posterminal/js/pointofsale/view/keyboard-toolbars.js
@@ -858,12 +858,57 @@ enyo.kind({
}
}
},
+ prepaymentSelection: function(
+ paymentToolBarComponents,
+ dafaultPaymentCommand
+ ) {
+ var keyboard = this.owner.owner,
+ defaultPaymentComp,
+ defaultPaymentButton;
+
+ //Fetch default payment button if available in toolbar(sometimes default payment will be in more option)
+ defaultPaymentComp = _.find(paymentToolBarComponents, function(
+ toolBarPayment
+ ) {
+ return (
+ toolBarPayment.btn &&
+ toolBarPayment.btn.command === dafaultPaymentCommand
+ );
+ });
+
+ if (defaultPaymentComp) {
+ defaultPaymentButton = defaultPaymentComp.$[dafaultPaymentCommand];
+ }
+
+ OB.UTIL.HookManager.executeHooks(
+ 'OBMOBC_PrePaymentSelected',
+ {
+ paymentSelected: defaultPaymentButton,
+ paymentInfo: dafaultPaymentCommand,
+ model: keyboard.model,
+ receipt: keyboard.receipt
+ },
+ function(args) {
+ if (args && args.cancellation && args.cancellation === true) {
+ keyboard.hasActivePayment = false;
+ keyboard.lastStatus = '';
+ keyboard.defaultcommand = '';
+ keyboard.setStatus('');
+ return;
+ }
+ keyboard.defaultcommand = dafaultPaymentCommand;
+ keyboard.setStatus(dafaultPaymentCommand);
+ }
+ );
+ },
shown: function() {
var me = this,
refundablePayment,
keypad,
sideButton,
+ paymentCommand,
keyboard = this.owner.owner,
+ paymentMethodCategory = {},
isReturnReceipt =
me.receipt && me.receipt.getPaymentStatus().isNegative ? true : false;
@@ -884,30 +929,73 @@ enyo.kind({
keypad.active = true;
});
_.each(OB.MobileApp.model.paymentnames, function(payment) {
+ paymentCommand =
+ payment.providerGroup && payment.providerGroup.id !== '0'
+ ? payment.providerGroup.id
+ : payment.payment.searchKey;
+
keyboard.disableCommandKey(me, {
disabled: isReturnReceipt ? !payment.paymentMethod.refundable : false,
- commands: [payment.payment.searchKey]
+ commands: [paymentCommand]
});
if (isReturnReceipt) {
sideButton = _.find(
OB.OBPOSPointOfSale.UI.PaymentMethods.prototype.sideButtons,
function(sideBtn) {
- return sideBtn.btn.command === payment.payment.searchKey;
+ return sideBtn.btn.command === paymentCommand;
}
);
if (sideButton) {
sideButton.active = payment.paymentMethod.refundable;
}
keypad = _.find(keyboard.activekeypads, function(keypad) {
- return keypad.payment === payment.payment.searchKey;
+ return keypad.payment === paymentCommand;
});
if (keypad) {
keypad.active = payment.paymentMethod.refundable;
}
}
+
+ if (payment.paymentMethod.paymentMethodCategory) {
+ paymentMethodCategory[payment.paymentMethod.paymentMethodCategory] =
+ paymentMethodCategory[
+ payment.paymentMethod.paymentMethodCategory
+ ] || [];
+ paymentMethodCategory[
+ payment.paymentMethod.paymentMethodCategory
+ ].push(payment);
+ }
});
+ for (let key in paymentMethodCategory) {
+ let payments = paymentMethodCategory[key],
+ paymentButtonId = 'paymentMethodCategory.showitems.' + key,
+ refundablePayment = _.find(payments, function(payment) {
+ return payment.paymentMethod.refundable;
+ });
+ if (isReturnReceipt && !refundablePayment) {
+ keyboard.disableCommandKey(me, {
+ disabled: true,
+ commands: [paymentButtonId]
+ });
+ sideButton = _.find(
+ OB.OBPOSPointOfSale.UI.PaymentMethods.prototype.sideButtons,
+ function(sideBtn) {
+ return sideBtn.btn.command === paymentButtonId;
+ }
+ );
+ if (sideButton) {
+ sideButton.active = false;
+ }
+ } else {
+ keyboard.disableCommandKey(me, {
+ disabled: false,
+ commands: [paymentButtonId]
+ });
+ }
+ }
+
keyboard.showKeypad('Coins-' + OB.MobileApp.model.get('currency').id); // shows the Coins/Notes panel for the terminal currency
keyboard.showSidepad('sidedisabled');
keyboard.hasActivePayment = true;
@@ -916,8 +1004,12 @@ enyo.kind({
!isReturnReceipt ||
(isReturnReceipt && me.defaultPayment.paymentMethod.refundable)
) {
- keyboard.defaultcommand = me.defaultPayment.payment.searchKey;
- keyboard.setStatus(me.defaultPayment.payment.searchKey);
+ paymentCommand =
+ me.defaultPayment.providerGroup &&
+ me.defaultPayment.providerGroup.id !== '0'
+ ? me.defaultPayment.providerGroup.id
+ : me.defaultPayment.payment.searchKey;
+ me.prepaymentSelection(this.getComponents(), paymentCommand);
} else {
refundablePayment = _.find(OB.MobileApp.model.get('payments'), function(
payment
@@ -925,8 +1017,12 @@ enyo.kind({
return payment.paymentMethod.refundable;
});
if (refundablePayment) {
- keyboard.defaultcommand = refundablePayment.payment.searchKey;
- keyboard.setStatus(refundablePayment.payment.searchKey);
+ paymentCommand =
+ refundablePayment.providerGroup &&
+ refundablePayment.providerGroup.id !== '0'
+ ? refundablePayment.providerGroup.id
+ : refundablePayment.payment.searchKey;
+ me.prepaymentSelection(this.getComponents(), paymentCommand);
} else {
keyboard.hasActivePayment = false;
keyboard.lastStatus = '';
|