-
-
Notifications
You must be signed in to change notification settings - Fork 621
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MIG] pos_cashback: Migration to 16.0 (from 12.0)
- rename from pos_casback_warning, to allow to add new feature, such as charging a commission. - Adapt to V16 PoS Framework
- Loading branch information
1 parent
531edd9
commit 9c12599
Showing
21 changed files
with
94 additions
and
110 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
...ack_warning/i18n/pos_cashback_warning.pot → pos_cashback/i18n/pos_cashback.pot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/** *************************************************************************** | ||
Copyright (C) 2022 - Today: GRAP (http://www.grap.coop) | ||
@author: Sylvain LE GAL (https://twitter.com/legalsylvain) | ||
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
******************************************************************************/ | ||
|
||
odoo.define("pos_cashback.Order", function (require) { | ||
var {Order} = require("point_of_sale.models"); | ||
const Registries = require("point_of_sale.Registries"); | ||
var utils = require("web.utils"); | ||
|
||
var round_pr = utils.round_precision; | ||
|
||
const OverloadOrder = (OriginalOrder) => | ||
class extends OriginalOrder { | ||
get_extradue_cashback() { | ||
var total_cash_received = 0.0; | ||
var extradue = 0.0; | ||
var due = this.get_due(); | ||
var lines = this.get_paymentlines(); | ||
|
||
if (due && lines.length) { | ||
extradue = due; | ||
} | ||
|
||
_.each(lines, function (line) { | ||
if (line.payment_method.type === "cash") { | ||
total_cash_received += line.amount; | ||
} | ||
}); | ||
|
||
if (extradue < 0.0 && total_cash_received + extradue < 0.0) { | ||
return round_pr( | ||
-(total_cash_received + extradue), | ||
this.pos.currency.rounding | ||
); | ||
} | ||
return round_pr(0.0, this.pos.currency.rounding); | ||
} | ||
}; | ||
Registries.Model.extend(Order, OverloadOrder); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.cashback-message-container { | ||
font-size: 25px; | ||
} |
22 changes: 22 additions & 0 deletions
22
pos_cashback/static/src/xml/PaymentScreen/PaymentScreenStatus.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<!-- | ||
Copyright 2022 - Today Sylvain LE GAL | ||
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
--> | ||
<templates id="template" xml:space="preserve"> | ||
|
||
<t t-inherit="point_of_sale.PaymentScreenStatus" t-inherit-mode="extension"> | ||
<xpath expr="//div[hasclass('payment-status-container')]" position="after"> | ||
<div | ||
class="cashback-message-container" | ||
t-if="props.order.get_extradue_cashback() > 0" | ||
> | ||
<i class='fa fa-warning' /> | ||
This will generate a cashback of <t | ||
t-esc='env.pos.format_currency(props.order.get_extradue_cashback())' | ||
/> | ||
</div> | ||
</xpath> | ||
</t> | ||
|
||
</templates> |
Binary file not shown.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../../../pos_cashback |
File renamed without changes.
This file was deleted.
Oops, something went wrong.