-
Notifications
You must be signed in to change notification settings - Fork 41
since migrating to 14 rejected payment order are not treated #272
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -102,7 +102,7 @@ def _on_error_parse_xml_and_cancel(self, err_message): | |
| [("name", "=", po_name)] | ||
| ) | ||
| _logger.info("PAIN002 payment_order: %s", payment_order) | ||
| if payment_order.state == "generated": | ||
| if payment_order.state in ("generated","uploaded"): | ||
| if po_state == "RJCT": | ||
| _logger.info( | ||
| "RJCT payment order %s with the folowing err: %s", | ||
|
|
@@ -121,13 +121,11 @@ def _on_error_parse_xml_and_cancel(self, err_message): | |
| for t in tx: | ||
| if t.find("./ns:TxSts", namespaces={"ns": ns}).text == "RJCT": | ||
| # search for payment line | ||
| payment_line_ids = payment_order.bank_line_ids.filtered( | ||
| lambda r, transaction=t: r.name | ||
| == transaction.find( | ||
| "./ns:OrgnlEndToEndId", namespaces={"ns": ns} | ||
| ).text | ||
| )[0].payment_line_ids | ||
| _logger.info("PAIN002 payment_line_ids: %s", payment_line_ids) | ||
| endtoend_id=t.find("./ns:OrgnlEndToEndId", namespaces={"ns": ns}).text | ||
| payment_id = payment_order.payment_ids.filtered( | ||
| lambda l: l.move_id.id == int(endtoend_id)) | ||
| payment_line_ids = payment_order.payment_line_ids.filtered(lambda l: l.payment_ids.id ==payment_id.id) | ||
| _logger.info(f"PAIN002 payment_line_ids: {payment_id.name} with endtoend_id: {endtoend_id}", ) | ||
|
Comment on lines
+124
to
+128
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The logic for finding
endtoend_id = t.find("./ns:OrgnlEndToEndId", namespaces={"ns": ns}).text
try:
move_id = int(endtoend_id)
except (ValueError, TypeError):
_logger.warning(f"PAIN002: Invalid OrgnlEndToEndId '{endtoend_id}'.")
continue
payment = payment_order.payment_ids.filtered(
lambda p: p.move_id.id == move_id
)
if not payment:
_logger.warning(f"PAIN002: No payment found for move_id {move_id}.")
continue
payment.ensure_one()
payment_line_ids = payment_order.payment_line_ids.filtered(
lambda l: payment in l.payment_ids
)
_logger.info(
f"PAIN002 found payment lines {payment_line_ids.ids} for payment {payment.name} with endtoend_id: {endtoend_id}"
) |
||
|
|
||
| # free line with message | ||
| rsn = t.findall( | ||
|
|
@@ -136,9 +134,18 @@ def _on_error_parse_xml_and_cancel(self, err_message): | |
| rsn_text = [] | ||
| for r in rsn: | ||
| rsn_text.append(r.text) | ||
| payment_line_ids.free_line(" ".join(rsn_text)) | ||
| rsn_txt = " ".join(rsn_text) | ||
| _logger.info(f"PAIN002 line free: {rsn_txt} for lines {payment_line_ids}", ) | ||
| for b in payment_line_ids: | ||
| try: | ||
| b.free_line(rsn_txt) | ||
| _logger.info(f"PAIN002 line free: {rsn_txt}" ,) | ||
| except Exception as e: | ||
| _logger.info(f"error line free: {e}" ,) | ||
|
Comment on lines
+139
to
+144
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The
for b in payment_line_ids:
try:
b.free_line(rsn_txt)
_logger.info(f"PAIN002 line free: {rsn_txt}")
except UserError as e:
_logger.error(f"Error freeing line {b.id}: {e}") |
||
|
|
||
| payment_order.generated2uploaded() | ||
|
|
||
| if payment_order.state == "generated": | ||
| payment_order.generated2uploaded() | ||
| self.write({"state": "done", "note_process": err_message}) | ||
|
|
||
| def _unlink_pain002(self): | ||
|
|
||
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For better readability and adherence to PEP 8 style guidelines, it's recommended to add a space after the comma within the tuple.
References