Skip to content

Commit

Permalink
[FIX] pos_financial_risk: Payment Screen design is updated.
Browse files Browse the repository at this point in the history
  • Loading branch information
geomer198 committed Sep 30, 2023
1 parent 3a4d001 commit 0a3217c
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 4 deletions.
2 changes: 2 additions & 0 deletions pos_financial_risk/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
"assets": {
"point_of_sale.assets": [
"pos_financial_risk/static/src/js/*.js",
"pos_financial_risk/static/src/scss/*.scss",
"pos_financial_risk/static/src/xml/*.xml",
],
},
"license": "AGPL-3",
Expand Down
17 changes: 13 additions & 4 deletions pos_financial_risk/static/src/js/PaymentScreen.esm.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ export const PaymentScreenRisk = (PaymentScreen) =>
setup() {
super.setup();
this.paymentMethodsFromConfigBase = this.payment_methods_from_config;
this.paymentMethodsUnlock = [];
this.paymentMethodsLock = [];
this.remainderLimit = 0.0;
this.riskLimit = 0.0;
this.updatePaymentMethod();
}

Expand Down Expand Up @@ -39,25 +43,30 @@ export const PaymentScreenRisk = (PaymentScreen) =>
const riskRemainingValue = partnerFields[0].risk_remaining_value;
const riskException = partnerFields[0].risk_exception;
const creditLimit = partnerFields[0].credit_limit;

if (
riskException ||
(creditLimit > 0 && orderTotal > riskRemainingValue)
) {
if (paymentCreditLimit.length > 0) {
this.payment_methods_from_config =
this.paymentMethodsUnlock =
this.paymentMethodsFromConfigBase.filter(
(method) => !paymentCreditLimit.includes(method.id)
);
} else {
this.payment_methods_from_config =
this.paymentMethodsUnlock =
this.paymentMethodsFromConfigBase.filter(
(method) => !method.credit_limit_restricted
);
}
} else {
this.payment_methods_from_config =
this.paymentMethodsFromConfigBase;
this.paymentMethodsUnlock = this.paymentMethodsFromConfigBase;
}
this.riskLimit = riskRemainingValue;
this.remainderLimit = (riskRemainingValue - orderTotal).toFixed(2);
this.paymentMethodsLock = this.paymentMethodsFromConfigBase.filter(
(method) => !this.paymentMethodsUnlock.includes(method)
);
this.render(true);
});
}
Expand Down
5 changes: 5 additions & 0 deletions pos_financial_risk/static/src/scss/pos.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.pos .button.error_risk {
background: $warning !important;
border-color: $warning !important;
color: black !important;
}
45 changes: 45 additions & 0 deletions pos_financial_risk/static/src/xml/PaymentScreen.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?xml version="1.0" encoding="UTF-8" ?>
<templates id="template" xml:space="preserve">
<t t-inherit="point_of_sale.PaymentScreen" t-inherit-mode="extension" owl="1">
<xpath
expr="//t[@t-foreach='payment_methods_from_config']"
position="attributes"
>
<attribute name="t-foreach">paymentMethodsUnlock</attribute>
</xpath>
<xpath expr="//div[hasclass('paymentmethods')]" position="after">
<div class="paymentmethods" t-if="paymentMethodsLock.length > 0">
<p class="title-category">Blocked due to credit limit reached</p>
<t
t-foreach="paymentMethodsLock"
t-as="paymentMethod"
t-key="paymentMethod.id"
>
<div class="button paymentmethod">
<div
class="payment-name"
style="background: rgba(255, 0, 0, 0.6); cursor: not-allowed;"
>
<s t-esc="paymentMethod.name" />
</div>
</div>
</t>
</div>
</xpath>
<xpath
expr="//div[hasclass('payment-buttons')]/div[hasclass('partner-button')]/div[hasclass('button')]"
position="attributes"
>
<attribute name="t-att-class">{
highlight: currentOrder.get_partner(),
error_risk: currentOrder.get_partner() &amp;&amp; riskLimit > 0 &amp;&amp; remainderLimit &lt;= 0 }
</attribute>
</xpath>
<xpath
expr="//div[hasclass('payment-buttons')]/div[hasclass('partner-button')]//t[@t-esc='partner.name']"
position="after"
>
<span t-if="riskLimit > 0"> (remainder <t t-esc="remainderLimit" />$)</span>
</xpath>
</t>
</templates>

0 comments on commit 0a3217c

Please sign in to comment.