Skip to content
Extraits de code Groupes Projets
Valider dcd30901 rédigé par Rémi - Le Filament's avatar Rémi - Le Filament
Parcourir les fichiers

[FIX] do not split bank statements per day

parent 8cbc3772
Branches
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
from . import ebics_file
import base64
from odoo import models
class EbicsFile(models.Model):
_inherit = "ebics.file"
def _split_cfonb(self, res):
# Avoid splitting cfonb in one statement per day
datas = []
datas.append({"data": base64.b64encode(self.data)})
return datas
......@@ -56,13 +56,12 @@ class EbicsStatementRopImport(models.TransientModel):
if ebics_mvt_file:
# Process EBICS MVT (= create bank statement)
_logger.debug("Creating statements for retrieved enriched moves")
ebics_mvt_file.with_context(active_model='ebics.file').process()
ebics_mvt_file.with_context(active_model="ebics.file").process()
bank_statement_ids = ebics_mvt_file.bank_statement_ids
_logger.debug(f"Created statements : {bank_statement_ids.mapped('date')}")
self.log += f"""
<strong><u>Import des mouvements enrichis<u></strong><br/>
{ebics_mvt_file.note_process}
- Journal : {bank_statement_ids[0].journal_id.name}
- Du : {bank_statement_ids[0].date}
au : {bank_statement_ids[-1].date} <br/>
......@@ -119,18 +118,13 @@ class EbicsStatementRopImport(models.TransientModel):
# Ajout des lignes ROP
_logger.debug("Adding statement lines for ROP files")
rop_lines = self._get_rop_lines(ebics_rop_file.data)
statement_ids = bank_statement_ids.filtered("date")
statement_to_delete = bank_statement_ids - statement_ids
statement_to_delete.unlink()
for ropl in rop_lines:
_logger.debug(f"Adding {ropl['payment_ref']} - {ropl['date']}")
_logger.debug(f"List of statement_ids : {statement_ids.mapped('date')}")
_logger.debug(
f"List of statement_ids : {bank_statement_ids.mapped('date')}"
)
statement_id = statement_ids.filtered(
lambda st: fields.Date.from_string(ropl["date"]) <= st.date
)[0]
_logger.debug(f"in {statement_id} - {statement_id.name} - {statement_id.date}")
ropl.update({"statement_id": statement_id.id})
ropl.update({"statement_id": bank_statement_ids[0].id})
self.env["account.bank.statement.line"].create(ropl)
ebics_rop_file.set_to_done()
......@@ -140,7 +134,9 @@ class EbicsStatementRopImport(models.TransientModel):
<hr/>
"""
else:
_logger.debug(f"No ROP file to process or no bank_statements created by enriched moves")
_logger.debug(
"No ROP file to process or no bank_statements created by enriched moves"
)
self.log += """
<strong><u>Suppression de lignes CORPORATE &
Intégration du fichier ROP<u></strong><br/>
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter