Commit 262e0f63 authored by Guillaume Risbourg's avatar Guillaume Risbourg Committed by hydrargyrum
Browse files

[creditmutuel] Add deferred date xpath

Some children of creditmutuel do not use the same xpath where we search
for the deferred date.
parent 1252fba6
......@@ -499,7 +499,7 @@ def get_history(self, account):
for tr in self.list_operations(coming_link, account):
transactions.append(tr)
differed_date = None
deferred_date = None
cards = ([page.select_card(account._card_number) for page in account._card_pages]
if hasattr(account, '_card_pages')
else account._card_links if hasattr(account, '_card_links') else [])
......@@ -509,8 +509,8 @@ def get_history(self, account):
if tr._to_delete:
# Delete main transaction when subtransactions exist
continue
if hasattr(tr, '_differed_date') and (not differed_date or tr._differed_date < differed_date):
differed_date = tr._differed_date
if hasattr(tr, '_deferred_date') and (not deferred_date or tr._deferred_date < deferred_date):
deferred_date = tr._deferred_date
if tr.date >= datetime.now():
tr._is_coming = True
elif hasattr(account, '_card_pages'):
......@@ -519,11 +519,11 @@ def get_history(self, account):
if card_trs:
transactions.extend(self.get_monthly_transactions(card_trs))
if differed_date is not None:
if deferred_date is not None:
# set deleted for card_summary
for tr in transactions:
tr.deleted = (tr.type == FrenchTransaction.TYPE_CARD_SUMMARY
and differed_date.month <= tr.date.month
and deferred_date.month <= tr.date.month
and not hasattr(tr, '_is_manualsum'))
for tr in sorted_transactions(transactions):
......
......@@ -381,7 +381,7 @@ def parse(self, el):
self.env['_is_webid'] = False
if "cartes" in CleanText('./td[1]')(el):
# handle cb differed card
# handle cb deferred card
if "cartes" in CleanText('./preceding-sibling::tr[1]/td[1]', replace=[(' ', '')])(el):
# In case it's the second month of card history present, we need to ignore the first
# one to get the attach accoount
......@@ -963,7 +963,10 @@ def condition(self):
return not CleanText('//td[contains(., "Aucun mouvement")]', default=False)(self)
def parse(self, el):
label = CleanText('//span[contains(text(), "Achats")]/following-sibling::span[2]')(el)
label = (
CleanText('//span[contains(text(), "Achats")]/following-sibling::span[2]')(el)
or CleanText('//*[contains(text(), "Achats")]')(el)
)
if not label:
return
try:
......@@ -983,7 +986,7 @@ class item(Transaction.TransactionElement):
obj_amount = Env('amount')
obj_original_amount = Env('original_amount')
obj_original_currency = Env('original_currency')
obj__differed_date = Env('differed_date')
obj__deferred_date = Env('deferred_date')
def obj_bdate(self):
if Field('type')(self) == Transaction.TYPE_DEFERRED_CARD:
......@@ -1007,10 +1010,11 @@ def parse(self, el):
else:
self.env['type'] = Transaction.TYPE_CARD
self.env['differed_date'] = Date(
CleanText('//span[contains(text(), "Achats")]/following-sibling::span[2]'),
parse_func=parse_french_date,
)(self)
text_date = (
CleanText('//span[contains(text(), "Achats")]/following-sibling::span[2]')(self)
or Regexp(CleanText('//*[contains(text(), "Achats")]'), r'(\d+ [^ ]+ \d+)$')(self)
)
self.env['deferred_date'] = parse_french_date(text_date).date()
amount = TableCell('credit')(self)[0]
if self.page.browser.is_new_website:
......@@ -2116,7 +2120,7 @@ class item(ItemElement):
klass = Account
def condition(self):
# Numerous cards are not differed card, we keep the card only if there is a coming
# Numerous cards are not deferred card, we keep the card only if there is a coming
return 'Dépenses' in CleanText('.//tr[1]/td/a[contains(@id,"C:more-card")]')(self) and (CleanText('.//div[1]/p')(self) == 'Active' or Field('coming')(self) != 0)
obj_balance = 0
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment