Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[16.0][ADD] pos_financial_risk #1018

Merged
merged 1 commit into from
Dec 27, 2023

Conversation

geomer198
Copy link
Contributor

Extends Partner Financial Risk to manage POS orders.
If POS order exceeds partner limit POS order forbidden to be confirmed.

@geomer198 geomer198 marked this pull request as draft June 27, 2023 21:50
@geomer198 geomer198 force-pushed the 16.0-t2660-pos_financial_risk-add branch from 2d052dd to 12a6e03 Compare June 27, 2023 22:30
const total = order.get_total_with_tax() + order.get_rounding_applied();
if (total > partner.risk_total) {
return this.showPopup("ErrorPopup", {
title: _t("Confirmation order is not allowed!"),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cannot confirm order

if (total > partner.risk_total) {
return this.showPopup("ErrorPopup", {
title: _t("Confirmation order is not allowed!"),
body: _t("Order total more than Customer risk total!"),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Order total exceeds customer credit limit

@@ -0,0 +1,31 @@
odoo.define("pos_financial_risk.ProductScreen", function (require) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please use the new method to define the js files, this will be more flexible for porting to a new version of odoo in the future

/** @odoo-module **/


import ProductScreen from "point_of_sale.ProductScreen";
import Registries from "point_of_sale.Registries";
import { _t } from "web.core";

export const ProductScreenRisk = (ProductScreen) =>

and etc

Comment on lines 11 to 25
async _onClickPay() {
const order = this.env.pos.get_order();
const partner = order.partner;
if (!partner) {
return super._onClickPay();
}
const total = order.get_total_with_tax() + order.get_rounding_applied();
if (total > partner.risk_total) {
return this.showPopup("ErrorPopup", {
title: _t("Confirmation order is not allowed!"),
body: _t("Order total more than Customer risk total!"),
});
}
return super._onClickPay();
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
async _onClickPay() {
const order = this.env.pos.get_order();
const partner = order.partner;
if (!partner) {
return super._onClickPay();
}
const total = order.get_total_with_tax() + order.get_rounding_applied();
if (total > partner.risk_total) {
return this.showPopup("ErrorPopup", {
title: _t("Confirmation order is not allowed!"),
body: _t("Order total more than Customer risk total!"),
});
}
return super._onClickPay();
}
async _onClickPay() {
const order = this.env.pos.get_order();
const partner = order.partner;
if (partner && order.get_total_with_tax() + order.get_rounding_applied() > partner.risk_total) {
return await this.showPopup("ErrorPopup", {
title: _t("Cannot confirm order"),
body: _t("Order total exceeds customer credit limit"),
});
}
return await super._onClickPay();
}

Copy link
Member

@chienandalu chienandalu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably a silly question 😅 : PoS orders are paid in the moment, shouldn't that keep the customer credit always balanced?

@ivs-cetmix
Copy link
Member

ivs-cetmix commented Jun 30, 2023

Probably a silly question 😅 : PoS orders are paid in the moment, shouldn't that keep the customer credit always balanced?

Well that's a good question. Actually they should. However at some moment you would like to block a customer from purchasing anything before he pays his debt. Otherwise he can keep paying through POS without taking care of his pending balance 😅

@geomer198 geomer198 closed this Jul 2, 2023
@luke-stdev001
Copy link

@geomer198 ,

I think this PR is useful and should be re-opened. We have a use-case for it internally and may want to flesh out the concept a little more. How can I contact you to discuss funding this development?

@ivs-cetmix
Copy link
Member

@geomer198 ,

I think this PR is useful and should be re-opened. We have a use-case for it internally and may want to flesh out the concept a little more. How can I contact you to discuss funding this development?

Hi @luke-stdev001
We will reopen the PR. Pls ping us on [email protected]

@geomer198 geomer198 reopened this Jul 3, 2023
@geomer198 geomer198 force-pushed the 16.0-t2660-pos_financial_risk-add branch from 6e833ea to 8ad21c2 Compare September 24, 2023 20:20
@legalsylvain legalsylvain added this to the 16.0 milestone Sep 26, 2023
@geomer198 geomer198 force-pushed the 16.0-t2660-pos_financial_risk-add branch from 0a3217c to 609cc41 Compare September 30, 2023 20:40
@luke-stdev001
Copy link

luke-stdev001 commented Oct 10, 2023

@geomer198 ,

Functional testing has been done and it works as expected, thanks for the changes. From my end we are ok to merge pending a code review, however we'd prefer to just pull in the OCA/POS repo rather than maintain our own version until this PR is merged here.

Would a code review from our team on this PR here help with the OCA process, or are we waiting on PSC and tests to pass for approval to merge into 16.0 for the OCA?

@ivs-cetmix
Copy link
Member

@geomer198 ,

Functional testing has been done and it works as expected, thanks for the changes. From my end we are ok to merge pending a code review, however we'd prefer to just pull in the OCA/POS repo rather than maintain our own version until this PR is merged here.

Would a code review from our team on this PR here help with the OCA process, or are we waiting on PSC and tests to pass for approval to merge into 16.0 for the OCA?

@luke-stdev001 you can make a code review meanwhile. We will also do our own too

Copy link
Member

@GabbasovDinar GabbasovDinar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@geomer198 geomer198 force-pushed the 16.0-t2660-pos_financial_risk-add branch from 609cc41 to 6414b7d Compare October 16, 2023 18:24
@geomer198 geomer198 marked this pull request as ready for review October 16, 2023 18:24
Copy link
Member

@ivs-cetmix ivs-cetmix left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Functional OK

@@ -0,0 +1 @@
odoo-addon-account_financial_risk @ git+https://github.com/OCA/credit-control.git@refs/pull/272/head#subdirectory=setup/account_financial_risk
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could please you rebase and update this dependency? 🙏🏻 it seems it was replaced by another PR

<div class="button paymentmethod">
<div
class="payment-name"
style="background: rgba(255, 0, 0, 0.6); cursor: not-allowed;"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not really a good practice to add inline styles.
The convention is to add styles through css or scss files instead

@geomer198 geomer198 force-pushed the 16.0-t2660-pos_financial_risk-add branch from 6414b7d to 1698896 Compare December 20, 2023 12:58
@geomer198 geomer198 force-pushed the 16.0-t2660-pos_financial_risk-add branch from d9a698d to 1632a68 Compare December 20, 2023 13:09
@ivantodorovich
Copy link
Contributor

thanks!

/ocabot merge nobump

@OCA-git-bot
Copy link
Contributor

This PR looks fantastic, let's merge it!
Prepared branch 16.0-ocabot-merge-pr-1018-by-ivantodorovich-bump-nobump, awaiting test results.

@OCA-git-bot OCA-git-bot merged commit 5a94f69 into OCA:16.0 Dec 27, 2023
6 of 7 checks passed
@OCA-git-bot
Copy link
Contributor

Congratulations, your PR was merged at 810d455. Thanks a lot for contributing to OCA. ❤️

@ivs-cetmix ivs-cetmix deleted the 16.0-t2660-pos_financial_risk-add branch December 27, 2023 12:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants