Commit 7a4db2aa authored by Arnaud Fontaine's avatar Arnaud Fontaine

ImmobilisableItem: Fix pylint error: E: 799, 47: Using variable 'currency' before assignment.

parent 1840bc00
Pipeline #7459 failed with stage
in 0 seconds
......@@ -271,10 +271,11 @@ class AmortisationRule(RuleMixin):
### First, plan the theorical accounting movements
accounting_movement_list = []
immo_cache_dict = {'period':{}, 'price':{}}
immo_cache_dict = {'period':{}, 'price':{}, 'currency': {}}
immo_period_list = my_item.getImmobilisationPeriodList(immo_cache_dict=immo_cache_dict)
for period_number in range(len(immo_period_list)):
immo_cache_dict['price'] = {}
immo_cache_dict['currency'] = {}
previous_period = None
next_period = None
immo_period = immo_period_list[period_number]
......
......@@ -326,7 +326,9 @@ class ImmobilisableItem(Item, Amount):
kw_key_list.sort()
if kw_key_list.count('immo_cache_dict'):
kw_key_list.remove('immo_cache_dict')
immo_cache_dict = kw.get('immo_cache_dict', {'period':{}, 'price':{}})
immo_cache_dict = kw.get('immo_cache_dict', {'period':{},
'price':{},
'currency': {}})
kw['immo_cache_dict'] = immo_cache_dict
if immo_cache_dict['period'].has_key((self.getRelativeUrl(), from_date, to_date) +
tuple([(key,kw[key]) for key in kw_key_list])) :
......@@ -732,7 +734,9 @@ class ImmobilisableItem(Item, Amount):
start_date = immo_period['start_date']
start_durability = immo_period['start_durability']
if start_durability is None:
immo_cache_dict = kw.get('immo_cache_dict', {'period':{}, 'price':{}})
immo_cache_dict = kw.get('immo_cache_dict', {'period':{},
'price':{},
'currency': {}})
start_durability = self.getRemainingDurability(at_date=start_date,
immo_cache_dict=immo_cache_dict)
if start_durability is None:
......@@ -788,14 +792,17 @@ class ImmobilisableItem(Item, Amount):
if kw_key_list.count('immo_cache_dict'):
kw_key_list.remove('immo_cache_dict')
immo_cache_dict = kw.get('immo_cache_dict', {'period':{}, 'price':{}})
immo_cache_dict = kw.get('immo_cache_dict', {'period':{},
'price':{},
'currency': {}})
kw['immo_cache_dict'] = immo_cache_dict
if immo_cache_dict['price'].has_key( (self.getRelativeUrl(), at_date) +
tuple([(key,kw[key]) for key in kw_key_list]) ) :
returned_price = immo_cache_dict['price'][ (self.getRelativeUrl(), at_date) +
tuple( [(key,kw[key]) for key in kw_key_list]) ]
immo_cache_dict_price_key = ((self.getRelativeUrl(), at_date) +
tuple([(key,kw[key]) for key in kw_key_list]))
if immo_cache_dict['price'].has_key(immo_cache_dict_price_key) :
returned_price = immo_cache_dict['price'][immo_cache_dict_price_key]
if with_currency:
currency = immo_cache_dict['currency'][immo_cache_dict_price_key]
return '%0.2f %s' % (returned_price, currency)
return returned_price
......@@ -1017,8 +1024,8 @@ class ImmobilisableItem(Item, Amount):
if returned_price is None:
return None
returned_price += disposal_price
immo_cache_dict['price'][ (self.getRelativeUrl(), at_date) +
tuple([(key,kw[key]) for key in kw_key_list]) ] = returned_price
immo_cache_dict['price'][immo_cache_dict_price_key] = returned_price
immo_cache_dict['currency'][immo_cache_dict_price_key] = currency
if with_currency:
return '%0.2f %s' % (returned_price, currency)
return returned_price
......
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