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][MIG] l10n_be_iso20022_pain #204

Open
wants to merge 25 commits into
base: 16.0
Choose a base branch
from

Conversation

sbejaoui
Copy link
Contributor

@sbejaoui sbejaoui commented Sep 21, 2023

@@ -25,7 +25,8 @@ class AccountMove(models.Model):
_inherit = "account.move"

reference_type = fields.Selection(
selection_add=[("bba", "BBA Structured Communication")]
selection_add=[("bba", "BBA Structured Communication")],
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, in the previous versions, _get_invoice_reference_be_partner was located in l10n_be_invoice_bba, but now it has been merged into l10n_be. This method provides a default BBA-formatted reference.

l10n_be_iso20022_pain add a new reference type bba to ensure that the reference (whether generated or edited by the user) complies with the valid BBA format.

Copy link
Member

Choose a reason for hiding this comment

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

I don't think we should add a reference_type. If reference_type is structured and journal_id.invoice_reference_model is be it means we have a bba structured communication.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Correct,

I believe we should keep only the check for the ref in this module.

cc @ThomasBinsfeld

_inherit = "account.move"

reference_type = fields.Selection(
selection_add=[("bba", "BBA Structured Communication")],
Copy link
Contributor

Choose a reason for hiding this comment

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

"bba" in payment order should be "BBA" (uppercase)

Copy link
Member

Choose a reason for hiding this comment

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

@ThomasBinsfeld can you elaborate why you downvoted the comment above?
@luc-demeyer if you have a link to the spec of what must go in a SEPA Credit Transfer file for BBA structured communications, that would be helpful?

Copy link
Contributor

Choose a reason for hiding this comment

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

I didn't see the need to change that and imply some refactoring. But this part has been removed since.

@ThomasBinsfeld
Copy link
Contributor

LGTM

Copy link

There hasn't been any activity on this pull request in the past 4 months, so it has been marked as stale and it will be closed automatically if no further activity occurs in the next 30 days.
If you want this PR to never become stale, please ask a PSC member to apply the "no stale" label.

@github-actions github-actions bot added the stale PR/Issue without recent activity, it'll be soon closed automatically. label May 12, 2024
@github-actions github-actions bot removed the stale PR/Issue without recent activity, it'll be soon closed automatically. label Jun 16, 2024
@sbejaoui sbejaoui force-pushed the 16.0-l10n_be_iso20022_pain-sbj branch from a370091 to 535bd80 Compare July 9, 2024 19:38
@sbejaoui sbejaoui force-pushed the 16.0-l10n_be_iso20022_pain-sbj branch from 535bd80 to f65c848 Compare July 9, 2024 20:09
@sbidoul
Copy link
Member

sbidoul commented Jul 10, 2024

@sbejaoui @ThomasBinsfeld Is it not necessary to check and/or enforce invoice_reference_model = 'be', for instance in the migration script or in _check_communication ?

@ThomasBinsfeld
Copy link
Contributor

@sbejaoui @ThomasBinsfeld Is it not necessary to check and/or enforce invoice_reference_model = 'be', for instance in the migration script or in _check_communication ?

The migration script looks to me. But the constraint on account.payment.line should check the reference model of the journal indeed.

Comment on lines 13 to 19
@api.constrains("communication", "communication_type")
def _check_communication(self):
for rec in self:
if rec.communication_type == "structured" and not check_bbacomm(
rec.communication
):
raise ValidationError(_("Invalid BBA Structured Communication !"))
Copy link
Contributor

@ThomasBinsfeld ThomasBinsfeld Jul 15, 2024

Choose a reason for hiding this comment

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

Suggested change
@api.constrains("communication", "communication_type")
def _check_communication(self):
for rec in self:
if rec.communication_type == "structured" and not check_bbacomm(
rec.communication
):
raise ValidationError(_("Invalid BBA Structured Communication !"))
@api.constrains("order_id", "communication", "communication_type")
def _check_communication(self):
for rec in self:
if (
rec.order_id.journal_id.invoice_reference_model == "be"
and rec.communication_type == "structured"
and not check_bbacomm(rec.communication
):
raise ValidationError(_("Invalid BBA Structured Communication !"))

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ThomasBinsfeld , I made the field invoice_reference_model visible for the bank journal so we can perform this check. See the last commit.

@sbejaoui sbejaoui force-pushed the 16.0-l10n_be_iso20022_pain-sbj branch 2 times, most recently from 853f332 to f6a8c8f Compare July 15, 2024 15:01
@OCA-git-bot
Copy link
Contributor

This PR has the approved label and has been created more than 5 days ago. It should therefore be ready to merge by a maintainer (or a PSC member if the concerned addon has no declared maintainer). 🤖

…yment line

check BBA structured communication on payment line only if  the journal invoice reference model is "be"

Co-authored-by: Thomas Binsfeld (ACSONE) <[email protected]>
@sbejaoui sbejaoui force-pushed the 16.0-l10n_be_iso20022_pain-sbj branch from f6a8c8f to ec5fae3 Compare July 17, 2024 12:16
>
<attribute
name="attrs"
>{'invisible': [('type', 'not in', ('sale', 'bank'))]}</attribute>
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure it makes sense to make invoice_reference_model and invoice_reference_type visible for other journals than customer invoice journals. Because when we pay invoice bills with a journal, we don't control the type of reference we need to use for the suppliers. So I think invoice_reference_model and invoice_reference_type should only be used when generating payment reference on documents that we generate, not documents that we receive from suppliers.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In this case, we remove the check on the payment reference in payment orders. We assume that the reference was checked for our invoices, and we don't concern ourselves with whether it's correct for vendor bills.

and rec.journal_id.invoice_reference_type == "invoice"
and rec.reference_type == "structured"
):
return check_bbacomm(rec.ref)
Copy link
Member

@sbidoul sbidoul Aug 14, 2024

Choose a reason for hiding this comment

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

Should we not use rec.payment_reference here?

Copy link
Member

Choose a reason for hiding this comment

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

At least for vendor bills, where ref is the supplier invoice number?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should we not use rec.payment_reference here?

yes

Copy link
Contributor Author

@sbejaoui sbejaoui Aug 14, 2024

Choose a reason for hiding this comment

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

At least for vendor bills, where ref is the supplier invoice number?

only for out_invoice, and don't check for VB

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.