Commit 205a6c54 authored by Arnaud Fontaine's avatar Arnaud Fontaine

ZODB Components: erp5_core: Migrate ImmobilisationDelivery from filesystem.

This also moves ImmobilisationItem and its interface from erp5_immobilisation
to erp5_core as ImmobilisationDelivery import them.
parent 7889858e
##############################################################################
#
# Copyright (c) 2002 Nexedi SARL and Contributors. All Rights Reserved.
# Guillaume Michon <guillaume.michon@e-asc.com>
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
import zope.interface
from AccessControl import ClassSecurityInfo
from DateTime import DateTime
from string import capitalize
from Products.ERP5Type import Permissions, PropertySheet
from erp5.component.interface.IImmobilisationItem import IImmobilisationItem
from Products.ERP5Type.DateUtils import addToDate, getClosestDate, roundDate
from Products.ERP5Type.DateUtils import getRoundedMonthBetween, millis
from Products.ERP5Type.DateUtils import getAccountableYearFraction
from Products.ERP5.Document.Amount import Amount
from erp5.component.document.Item import Item
from Products.CMFCore.utils import getToolByName
from Products.ERP5.Document.ImmobilisationMovement import (
UNIMMOBILISING_METHOD, NO_CHANGE_METHOD, AMORTISATION_METHOD_PREFIX )
from Products.ERP5.Document.ImmobilisationMovement import (
IMMOBILISATION_NEEDED_PROPERTY_LIST,
IMMOBILISATION_UNCONTINUOUS_NEEDED_PROPERTY_LIST,
IMMOBILISATION_FACULTATIVE_PROPERTY_LIST )
from zLOG import LOG
NEGLIGEABLE_PRICE = 10e-8
from Products.ERP5Type.Errors import ImmobilisationValidityError
from Products.ERP5Type.Errors import ImmobilisationCalculationError
class ImmobilisableItem(Item, Amount):
"""
An Immobilisable Item is an Item which can be immobilised
and amortised in accounting
"""
meta_type = 'ERP5 ImmobilisableItem'
portal_type = 'Immobilisable Item'
add_permission = Permissions.AddPortalContent
# Declarative security
security = ClassSecurityInfo()
security.declareObjectProtected(Permissions.AccessContentsInformation)
# Declarative properties
property_sheets = ( PropertySheet.Base
, PropertySheet.XMLObject
, PropertySheet.CategoryCore
, PropertySheet.DublinCore
, PropertySheet.Price
, PropertySheet.Item
, PropertySheet.Amount
, PropertySheet.Reference
, PropertySheet.Amortisation
)
zope.interface.implements(IImmobilisationItem)
# IExpandableItem interface implementation
def getSimulationMovementSimulationState(self, simulation_movement):
"""Returns the simulation state for this simulation movement.
"""
portal = self.getPortalObject()
draft_state_list = portal.getPortalDraftOrderStateList()
# if we have an order which is not draft, we'll consider the generated
# simulation movement are planned.
# This is probably oversimplified implementation, as we may want to look
# deliveries / invoices.
for movement in self.getAggregateRelatedValueList(
portal_type=portal.getPortalOrderMovementTypeList(),):
if movement.getSimulationState() not in draft_state_list:
return 'planned'
return 'draft'
security.declareProtected(Permissions.AccessContentsInformation,
'getImmobilisationRelatedMovementList')
def getImmobilisationRelatedMovementList(self,
from_date = None,
to_date = None,
include_to_date = 0,
filter_valid = 1,
immobilisation_movement_list = None,
owner_movement_list = None,
**kw):
"""
Returns a dictionary of lists containing movements related to amortisation
system from_date is included, to_date is excluded filter_valid eliminates
all invalid immobilisation movements in immobilisation movement list.
Also, only movements in current_inventory state are returned
if filter_valid is set.
If filter_valid is set and some movements are in state 'calculating',
a ImmobilisationValidityError is launch.
Immobilisation_movement and owner_change specify which lists to return
immobilisation_movement_list is the list of movements to use instead of
looking in SQL. Warning : in the case of movement_list is provided,
no filter is applied on it (unless looking at each movement validity) and
movement_list is supposed to be well sorted.
The search is based on catalog so you can use related keys
"""
wf_tool = self.portal_workflow
sim_tool = self.portal_simulation
catalog = self.portal_catalog
immo_list = []
owner_change_list = []
immo_and_owner_list = []
if immobilisation_movement_list is None:
# First build the SQL query
sql_dict = self._getCleanSqlDict(**kw)
sql_dict['aggregate_uid'] = self.getUid()
if filter_valid:
sql_dict['immobilisation_state'] = ['calculating','valid']
sql_dict['simulation_state'] = self.getPortalCurrentInventoryStateList()
portal_type = sql_dict.get('portal_type',None)
if portal_type is None:
portal_type = self.getPortalDeliveryMovementTypeList() + \
('Immobilisation Line', 'Immobilisation Cell')
sql_dict['portal_type'] = portal_type
sql_dict['sort_on'] = [('movement.stop_date','ascending')]
# Handle dates
date_key = 'movement.stop_date'
date_range = ''
date_query = []
if from_date is not None:
date_query.append(DateTime(from_date))
date_range += 'min'
if to_date is not None:
date_query.append(DateTime(to_date))
if include_to_date:
date_range += 'ngt'
else:
date_range += 'max'
if len(date_query) != 0:
sql_dict[date_key] = { 'range':date_range, 'query':date_query}
# Then execute the query
immobilisation_movement_list = catalog(**sql_dict)
if kw.get('src__', 0) == 1:
return immobilisation_movement_list
# Then build immobilisation list
for movement in immobilisation_movement_list:
movement = movement.getObject()
if movement.getStopDate() is not None:
# Test immobilisation movement
if filter_valid and movement.getImmobilisationState() in ('invalid',
'calculating',):
raise ImmobilisationValidityError, \
'%s : some preceding movements are still in calculating state' % self.getRelativeUrl()
immo_list.append(movement)
return immo_list
def _ownerChange(self, first_section, second_section):
"""
Tests if section 1 and section 2 are the same owner or not
It is done by looking at the mapped organisations
If a mapped organisation exists, and the social capital currency is not None,
it is considered as an independant organisation
"""
if first_section == second_section:
return 0
first_section = self._getFirstIndependantOrganisation(first_section)
second_section = self._getFirstIndependantOrganisation(second_section)
if first_section is None:
if second_section is None:
return 0
else:
return 1
elif second_section is None:
return 1
else:
if first_section == second_section:
return 0
return 1
def _getFirstIndependantOrganisation(self, section):
"""
Returns the first found independant organisation, looking at
the group tree upward. An independant organisation is found when the
category has a mapping related value, and this value has a social capital currency
"""
if section in (None, ""):
return None
if section.getPortalType() not in ("Category","Base Category"):
if hasattr(section, 'getMappingValue'):
category = section.getMappingValue()
organisation = section
else:
category = None
organisation = section
else:
category = section
try:
organisation = category.getMappingRelatedValueList(strict_membership = 1)[0]
except IndexError:
organisation = section
if organisation is None or \
(not hasattr(organisation, 'getPriceCurrencyValue')) or \
(not hasattr(organisation, 'getFinancialYearStopDate')) or \
organisation.getPriceCurrencyValue() is None or \
organisation.getFinancialYearStopDate() is None:
if category is None: return None
if category.getPortalType() != "Base Category":
return self._getFirstIndependantOrganisation(category.getParentValue())
else:
return None
return organisation
security.declareProtected(Permissions.AccessContentsInformation,
'getImmobilisationMovementValueList')
def getImmobilisationMovementValueList(self,
from_date=None,
to_date=None,
filter_valid=1,
**kw):
"""
Returns a list of immobilisation movements applied to current item from
date to date
Argument filter_valid allows to select only the valid immobilisation movements
"""
return self.getImmobilisationRelatedMovementList(from_date=from_date,
to_date=to_date,
filter_valid=filter_valid,
**kw)
security.declareProtected(Permissions.AccessContentsInformation,
'getUnfilteredImmobilisationMovementValueList')
def getUnfilteredImmobilisationMovementValueList(self, from_date=None, to_date=None, **kw):
"""
Returns a list of immobilisation applied to the current item from date to date
All of the movements are returned, not even those which are valid
"""
return self.getImmobilisationMovementValueList(from_date=from_date,
to_date=to_date,
filter_valid=0, **kw)
security.declareProtected(Permissions.AccessContentsInformation,
'getPastImmobilisationMovementValueList')
def getPastImmobilisationMovementValueList(self, from_date=None, at_date=None, **kw):
"""
Returns a list of immobilisation movements applied to current item
before the given date, or now
"""
if at_date is None: at_date = DateTime()
result = self.getImmobilisationMovementValueList(from_date=from_date,
to_date=at_date, **kw )
return result
security.declareProtected(Permissions.AccessContentsInformation,
'getFutureImmobilisationMovementValueList')
def getFutureImmobilisationMovementValueList(self, to_date=None, at_date=None, from_movement=None, **kw):
"""
Returns a list of immobilisation movements applied to current item
after the given date (excluded), or now.
If from_movement is set and the given movement is found, remove it from the list.
"""
if at_date is None: at_date = DateTime()
at_date = at_date + millis
result = self.getImmobilisationMovementValueList(from_date=at_date,
to_date=to_date, **kw)
if from_movement is not None and from_movement in result:
result.remove(from_movement)
return result
security.declareProtected(Permissions.AccessContentsInformation,
'getLastImmobilisationMovementValue')
def getLastImmobilisationMovementValue(self, at_date=None, **kw):
"""
Returns the last immobilisation movement before the given date, or now
"""
past_list = self.getPastImmobilisationMovementValueList(at_date=at_date, **kw)
if len(past_list) > 0:
return past_list[-1]
return None
security.declareProtected(Permissions.AccessContentsInformation,
'getNextImmobilisationMovementValue')
def getNextImmobilisationMovementValue(self, at_date=None, from_movement=None, **kw):
"""
Returns the first immobilisation movement after the given date, or now
If from_movement is set and the given movement is the next one, returns
the second next movement
"""
future_list = self.getFutureImmobilisationMovementValueList(
at_date=at_date,
from_movement=from_movement,
**kw)
if len(future_list) > 0:
return future_list[0]
return None
security.declareProtected(Permissions.AccessContentsInformation,
'getImmobilisationPeriodList')
def getImmobilisationPeriodList(self, from_date=None, to_date=None, **kw):
"""
Returns a list of dictionaries representing immobilisation periods for the object
from_date is included, to_date is excluded
"""
kw_key_list = kw.keys()
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':{},
'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])) :
return immo_cache_dict['period'][ (self.getRelativeUrl(), from_date, to_date) +
tuple( [(key,kw[key]) for key in kw_key_list]) ]
def setPreviousPeriodParameters(period_list,
current_period,
prefix = 'initial',
keys=[]):
if len(period_list) > 0:
previous_period = period_list[-1]
if previous_period['stop_date'] == current_period['start_date']:
if len(keys) == 0:
for key in previous_period.keys():
if key.split('_')[0] == prefix:
current_period[key] = previous_period[key]
else:
for key in keys:
current_period[key] = previous_period[key]
"""
We need to separate immobilisation treatment from section_change
movements treatment.
An immobilisation is a movement which contains immobilisation data
and MAY change the section.
A section change movement DOES NOT contain immobilisation data
"""
immobilisation_list = self.getImmobilisationMovementValueList(from_date=from_date,
to_date=to_date,
**kw)
section_change_list = self.getSectionChangeList(from_date=from_date,
at_date=to_date,
**kw)
# Sanity check
section_movement_list = []
date_list = [movement.getStopDate() for movement in immobilisation_list]
for section_movement in [o['movement'] for o in section_change_list]:
if section_movement.getStopDate() in date_list and \
section_movement not in section_movement_list and \
section_movement not in immobilisation_list:
raise ImmobilisationCalculationError, \
"Some movements related to item %s have the same date" % self.getRelativeUrl()
elif section_movement.getStopDate() not in date_list and \
section_movement not in section_movement_list:
#The section movement is different from immobilisation movements
date_list.append(section_movement.getStopDate())
section_movement_list.append(section_movement)
else:
#It means the current section_movement is a movement in immobilisation_list
if section_movement.getAmortisationMethod() in ("", None, NO_CHANGE_METHOD):
section_movement_list.append(section_movement)
immobilisation_list.remove(section_movement)
"""
At this stade, section_movement_list contains the movements which only
change the owner.
Immobilisation_list contains movements with immobilisation data and which
may change the owner, but it may contain some movements which does not
change the owner but with a NO_CHANGE_METHOD.
Such movements must not be took into account, because they do not define
a new immobilisation period. So remove them.
"""
for immobilisation in immobilisation_list[:]:
if immobilisation.getAmortisationMethod() in ("", None, NO_CHANGE_METHOD):
immobilisation_list.remove(immobilisation)
immo_period_list = []
current_immo_period = {}
immo_cursor = 0
section_cursor = 0
while immo_cursor <= len(immobilisation_list) and\
section_cursor <= len(section_movement_list) and \
not (immo_cursor == len(immobilisation_list) and \
section_cursor == len(section_movement_list)):
immobilisation = None
section_movement = None
is_immo_movement = 0
is_section_movement = 0
if immo_cursor < len(immobilisation_list):
immobilisation = immobilisation_list[immo_cursor]
if section_cursor < len(section_movement_list):
section_movement = section_movement_list[section_cursor]
if (immobilisation is not None) and (section_movement is None or \
section_movement.getStopDate() > immobilisation.getStopDate()):
# immobilisation treatment
immo_cursor += 1
is_immo_movement = 1
movement = immobilisation
method = immobilisation.getAmortisationMethod()
open_new_period = 1
else:
# section_change treatment
section_cursor += 1
is_section_movement = 1
movement = section_movement
method = NO_CHANGE_METHOD
if len(immo_period_list)>0:
previous_period = immo_period_list[-1]
else:
previous_period = None
if current_immo_period not in ({},None) or (
previous_period is not None and
previous_period.get('stop_date', None) is not None and
previous_period['stop_date'] == section_movement.getStopDate()
):
open_new_period = 1
else:
open_new_period = 0
# First close the previous immobilisation period
if current_immo_period not in (None, {}):
current_immo_period['stop_durability'] = self.getRemainingDurability(
at_date=movement.getStopDate(),
immo_period_list=immo_period_list+[current_immo_period],
immo_cache_dict=immo_cache_dict)
current_immo_period['stop_duration'] = self.getRemainingAmortisationDuration(
at_date=movement.getStopDate(),
immo_period_list=immo_period_list+[current_immo_period],
immo_cache_dict=immo_cache_dict)
current_immo_period['stop_movement'] = movement
current_immo_period['stop_date'] = movement.getStopDate()
immo_period_list.append(current_immo_period)
current_immo_period = {}
current_immo_period = {}
# Then open the new one
if open_new_period and method != UNIMMOBILISING_METHOD:
# First check if there is a valid owner in this period
section = self.getSectionValue(at_date=movement.getStopDate(),
include_to_date=1)
if (section is not None) and \
(section.getPriceCurrencyValue() is not None) and \
(section.getFinancialYearStopDate() is not None):
# Fill data about this period
if is_immo_movement:
previous_period_method = None
current_immo_period['continuous_movement'] = movement.getAmortisationMethodParameterForItem(self,"continuous")['continuous']
"""
The current movement is an immobilisation movement.
We fill each 'start' and 'initial' property by looking at the movement
properties
"""
property_list = IMMOBILISATION_NEEDED_PROPERTY_LIST + \
IMMOBILISATION_UNCONTINUOUS_NEEDED_PROPERTY_LIST + \
IMMOBILISATION_FACULTATIVE_PROPERTY_LIST
property_list.extend(movement.getNeededSpecificParameterListForItem(self))
property_list.extend(movement.getUncontinuousNeededSpecificParameterListForItem(self))
property_list.extend(movement.getFacultativeSpecificParameterListForItem(self))
for key,value,tag in property_list:
value = 'get' + ''.join(map(capitalize, value.split('_')))
value = getattr(movement, value, None)
if value is not None:
value = value()
current_immo_period['start_' + key] = value
current_immo_period['initial_' + key] = value
else:
"""
The current movement is a section change movement.
We get 'start' properties from previous period, and set some other
'start' properties by calculation
"""
current_immo_period['start_date'] = movement.getStopDate()
setPreviousPeriodParameters(immo_period_list,
current_immo_period,
prefix='start')
current_immo_period['start_date'] = movement.getStopDate()
setPreviousPeriodParameters(immo_period_list,
current_immo_period,
keys=['continuous_movement'])
current_immo_period['start_vat'] = 0
current_immo_period['start_extra_cost_price'] = 0
current_immo_period['start_main_price'] = self.getAmortisationPrice(
at_date=movement.getStopDate(),
immo_cache_dict=immo_cache_dict)
current_immo_period['start_duration'] = self.getRemainingAmortisationDuration(
at_date=movement.getStopDate(),
immo_cache_dict=immo_cache_dict)
current_immo_period['start_durability'] = self.getRemainingDurability(
at_date=movement.getStopDate(),
immo_cache_dict=immo_cache_dict)
method = current_immo_period.get('start_method', "")
# For both types of movement, set some properties
extra_cost_price = current_immo_period.get('start_extra_cost_price')
main_price = current_immo_period.get('start_main_price')
current_immo_period['start_extra_cost_price'] = extra_cost_price or 0.
current_immo_period['start_movement'] = movement
current_immo_period['initial_movement'] = movement
current_immo_period['start_price'] = (main_price or 0.) + (extra_cost_price or 0.)
current_immo_period['initial_price'] = current_immo_period['start_price']
current_immo_period['owner'] = section
"""
Determine if this period continues a previous one.
There are two concepts of 'continuing' :
- "continuous" means the current period is continuing the previous
immobilisation
- "adjacent" means the current period will use previous period
data but starts a new immobilisation
"""
continuous = 0
adjacent = 0
if len(immo_period_list)>0:
previous_period_method = immo_period_list[-1]["initial_method"]
adjacent = \
current_immo_period['continuous_movement'] and \
(previous_period_method is not None) and (\
previous_period_method==method or \
method in ("", NO_CHANGE_METHOD) \
) and \
immo_period_list[-1]['stop_date'] == movement.getStopDate()
"""
We must check if the current owner is in the same group as
the previous one, in order to know if this period is completely
new or not
"""
previous_section = self.getSectionValue(at_date = movement.getStopDate())
continuous = adjacent and not (
previous_section is None or \
previous_section.getGroup() is None or \
section.getGroup() is None or \
previous_section.getGroup() != section.getGroup()
)
current_immo_period['continuous'] = continuous
current_immo_period['adjacent'] = adjacent
if continuous:
# A continuous period gets 'initial' data from previous period.
setPreviousPeriodParameters(immo_period_list, current_immo_period)
elif adjacent:
"""
An adjacent period calculates some start values then copies them to
initial values.
These values overload 'initial' values acquired from previous period
"""
setPreviousPeriodParameters(immo_period_list, current_immo_period)
if is_immo_movement:
#Calculation of start values is already done above for section change movements
current_immo_period['start_vat'] = 0
current_immo_period['start_extra_cost_price'] = 0
current_immo_period['start_main_price'] = self.getAmortisationPrice(
at_date=movement.getStopDate(),
immo_cache_dict=immo_cache_dict)
current_immo_period['start_duration'] = self.getRemainingAmortisationDuration(
at_date=movement.getStopDate(),
immo_cache_dict=immo_cache_dict)
current_immo_period['start_durability'] = self.getRemainingDurability(
at_date=movement.getStopDate(),
immo_cache_dict=immo_cache_dict)
extra_cost_price = current_immo_period.get('start_extra_cost_price')
main_price = current_immo_period.get('start_main_price')
current_immo_period['start_price'] = (main_price or 0.) + (extra_cost_price or 0.)
key_list = current_immo_period.keys()
for key in key_list:
value = current_immo_period[key]
if key.find('_') != -1:
if key.split('_')[0] == 'start' and value not in (None, '', NO_CHANGE_METHOD):
current_immo_period['initial_%s' % '_'.join(key.split('_')[1:])] = value
else:
# A period wich is alone only copies start values to initial ones
# So it may be invalid later
key_list = current_immo_period.keys()
for key in key_list:
value = current_immo_period[key]
if key.find('_') != -1:
if key.split('_')[0] == 'start' and value is not None:
current_immo_period['initial_%s' % '_'.join(key.split('_')[1:])] = value
# Finally check if this period is valid. If the method is still NO_CHANGE_METHOD,
# it means there is an inconsistency, because there is no previous immobilisation period
needed_property_list = IMMOBILISATION_NEEDED_PROPERTY_LIST + \
IMMOBILISATION_UNCONTINUOUS_NEEDED_PROPERTY_LIST + \
movement.getNeededSpecificParameterListForItem(self) + \
movement.getUncontinuousNeededSpecificParameterListForItem(self)
for key, value, tag in needed_property_list:
if current_immo_period.get('initial_%s' % key) in (None, '', NO_CHANGE_METHOD):
current_immo_period = {}
if current_immo_period not in (None, {}):
immo_period_list.append(current_immo_period)
# Round dates since immobilisation calculation is made on days
for immo_period in immo_period_list:
for property in ('start_date', 'stop_date', 'initial_date',):
if immo_period.has_key(property):
immo_period[property] = roundDate(immo_period[property])
immo_cache_dict['period'][ (self.getRelativeUrl(), from_date, to_date) +
tuple([(key,kw[key]) for key in kw_key_list]) ] = immo_period_list
return immo_period_list
security.declareProtected(Permissions.AccessContentsInformation,
'getLastImmobilisationPeriod')
def getLastImmobilisationPeriod(self, to_date=None, **kw):
"""
Returns the current immobilisation period, or the last one if the
item is not currently immobilised, at the given at_date (excluded)
"""
period_list = self.getImmobilisationPeriodList(from_date=None,
to_date=to_date, **kw)
if len(period_list) == 0:
return None
return period_list[-1]
security.declareProtected(Permissions.AccessContentsInformation,
'isCurrentlyImmobilised')
def isCurrentlyImmobilised(self, **kw):
""" Returns true if the item is immobilised at this time """
return self.isImmobilised(at_date = DateTime(), **kw)
security.declareProtected(Permissions.AccessContentsInformation,
'isNotCurrentlyImmobilised')
def isNotCurrentlyImmobilised(self, **kw):
""" Returns true if the item is not immobilised at this time """
return not self.isCurrentlyImmobilised(**kw)
security.declareProtected(Permissions.AccessContentsInformation,
'isImmobilised')
def isImmobilised(self, at_date=None, **kw):
"""
Returns true if the item is immobilised at the given date.
If at_date = None, returns true if the item has ever been immobilised.
"""
immo_period_list = self.getImmobilisationPeriodList(to_date=at_date, **kw)
if len(immo_period_list) == 0:
return 0
elif len(immo_period_list) > 0 and at_date is None:
return 1
immo_period = immo_period_list[-1]
if immo_period.has_key('stop_date'):
# It means the latest period is terminated before the current date
return 0
return 1
security.declareProtected(Permissions.AccessContentsInformation,
'getCurrentRemainingAmortisationDuration')
def getCurrentRemainingAmortisationDuration(self, **kw):
""" Returns the calculated remaining amortisation duration for this item
at the current time.
"""
return self.getRemainingAmortisationDuration(at_date=DateTime(), **kw)
security.declareProtected(Permissions.AccessContentsInformation,
'getRemainingAmortisationDuration')
def getRemainingAmortisationDuration(self, at_date=None, immo_period_list=None, **kw):
"""
Returns the calculated remaining amortisation duration for the item.
It is based on the latest immobilisation period at given date, or now.
"""
if at_date is None:
at_date = DateTime()
new_kw = dict(kw)
if new_kw.has_key('to_date'):
del new_kw['to_date']
if new_kw.has_key('at_date'):
del new_kw['at_date']
if immo_period_list is None:
immo_period_list = self.getImmobilisationPeriodList(to_date=at_date, **new_kw)
if len(immo_period_list) > 0:
immo_period = immo_period_list[-1]
initial_date = immo_period['initial_date']
initial_duration = immo_period.get('initial_duration',0)
stop_date = immo_period.get('stop_date', at_date)
calculate = 1
consumpted_duration = getRoundedMonthBetween(initial_date, stop_date, True)
remaining_duration = initial_duration - consumpted_duration
if remaining_duration < 0:
returned_value = 0
return int(remaining_duration)
return None
security.declareProtected(Permissions.AccessContentsInformation,
'getRemainingDurability')
def getRemainingDurability(self, at_date=None, immo_period_list=None, **kw):
"""
Returns the durability of the item at the given date, or now.
The durability is quantity of something which corresponds to the 'life' of the item
(ex : km for a car, or time for anything)
Each Immobilisation Movement stores the durability at a given time,
so it is possible to approximate the durability between two Immobilisation
Movements by using a simple
linear calculation.
Note that durability has no sense for items which are immobilisated but not
amortised (like grounds, etc...). Calculation is based on duration, so an item
immobilised without amortisation duration will not decrease its durability.
"""
if at_date is None:
at_date = DateTime()
new_kw = dict(kw)
if new_kw.has_key('to_date'):
del new_kw['to_date']
if new_kw.has_key('at_date'):
del new_kw['at_date']
if immo_period_list is None:
immo_period_list = self.getImmobilisationPeriodList(to_date=at_date, **new_kw)
# First case : no data about immobilisation
if len(immo_period_list) == 0:
return None
immo_period = immo_period_list[-1]
# Second case : the item is not currently immobilised
if immo_period.has_key('stop_date'):
return immo_period['stop_durability']
# Third case : the item is currently immobilised
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':{},
'currency': {}})
start_durability = self.getRemainingDurability(at_date=start_date,
immo_cache_dict=immo_cache_dict)
if start_durability is None:
return None
stop_date = None
stop_durability = None
next_movement = self.getNextImmobilisationMovementValue(at_date=at_date, **kw)
while stop_durability is None and next_movement is not None:
stop_date = next_movement.getStopDate()
stop_durability = next_movement.getDurability()
next_movement = self.getNextImmobilisationMovementValue(
at_date=stop_date,
from_movement=next_movement,
**kw)
if stop_durability is None:
# In this case, we take the end of life of the item and use
# it like an immobilisation movement with values set to 0
initial_date = immo_period['initial_date']
initial_duration = immo_period['initial_duration']
stop_date = addToDate(initial_date, month=initial_duration)
stop_durability = 0
consumpted_durability = start_durability - stop_durability
consumpted_time = getRoundedMonthBetween(start_date, stop_date, True)
current_consumpted_time = getRoundedMonthBetween(start_date, at_date, True)
if consumpted_time <= 0 or current_consumpted_time <= 0:
return start_durability
else:
return start_durability - consumpted_durability * current_consumpted_time / consumpted_time
security.declareProtected(Permissions.AccessContentsInformation,
'getCurrentRemainingDurability')
def getCurrentRemainingDurability(self, **kw):
"""
Returns the remaining durability at the current date
"""
return self.getRemainingDurability(at_date=DateTime(), **kw)
security.declareProtected(Permissions.AccessContentsInformation,
'getAmortisationPrice')
def getAmortisationPrice(self, at_date=None, with_currency=0, **kw):
"""
Returns the deprecated value of item at given date, or now.
If with_currency is set, returns a string containing the value and the
corresponding currency.
"""
if at_date is None:
at_date = DateTime()
kw_key_list = kw.keys()
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':{},
'currency': {}})
kw['immo_cache_dict'] = immo_cache_dict
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
immo_period_list = self.getImmobilisationPeriodList(to_date=at_date, **kw)
if len(immo_period_list) == 0:
# Item has never been immobilised. We cannot get its price
if with_currency:
return "N/A"
return None
# Get data from the last immo period
immo_period = immo_period_list[-1]
initial_movement = immo_period['initial_movement']
start_date = immo_period['start_date']
disposal_price = immo_period['initial_disposal_price']
period_start_date = immo_period['initial_date']
period_start_price = immo_period['initial_price']
period_start_duration = immo_period['initial_duration']
start_price = immo_period['start_price']
start_duration = immo_period['start_duration']
start_durability = immo_period['start_durability']
owner = immo_period['owner']
# Calculate data if not found
if start_price is None:
start_price = self.getAmortisationPrice(at_date=start_date,
immo_cache_dict=immo_cache_dict)
if start_duration is None:
start_duration = self.getRemainingAmortisationDuration(at_date=start_date,
immo_cache_dict=immo_cache_dict)
if start_durability is None:
start_durability = self.getRemainingDurability(at_date=start_date,
immo_cache_dict=immo_cache_dict)
# Get the current period stop date, duration and durability
if immo_period.has_key('stop_date'):
stop_date = immo_period['stop_date']
period_stop_date = stop_date
else:
stop_date = at_date
next_movement = self.getNextImmobilisationMovementValue(at_date=at_date, **kw)
if next_movement is not None:
period_stop_date = next_movement.getStopDate()
else:
period_stop_date = addToDate(period_start_date, month=period_start_duration)
if at_date > period_stop_date:
return self.getAmortisationPrice(at_date=period_stop_date, **kw)
stop_duration = self.getRemainingAmortisationDuration(
at_date=period_stop_date,
immo_period_list=immo_period_list,
immo_cache_dict=immo_cache_dict)
stop_durability = self.getRemainingDurability(at_date=period_stop_date,
immo_period_list=immo_period_list,
immo_cache_dict=immo_cache_dict)
section = owner
currency = owner.getPriceCurrency()
depreciable_price = period_start_price - disposal_price
financial_date = section.getFinancialYearStopDate()
amortisation_method = AMORTISATION_METHOD_PREFIX + immo_period['initial_method']
# Get the amortisation method parameters
amortisation_parameters = initial_movement.getAmortisationMethodParameterForItem(
item=self, parameter_list = [
"cut_annuities", "price_calculation_basis",
"round_duration", "date_precision", "with_amortisation"])
cut_annuities = amortisation_parameters["cut_annuities"]
price_calculation_basis = amortisation_parameters["price_calculation_basis"]
round_duration = amortisation_parameters["round_duration"]
date_precision = amortisation_parameters["date_precision"]
with_amortisation = amortisation_parameters["with_amortisation"]
# Return the price if no amortisation is needed
if not with_amortisation:
return period_start_price
### Adjust some values according to the parameters
# Adapt period bound dates according to date_precision
period_start_date = getClosestDate(date=financial_date,
target_date=period_start_date,
precision=date_precision, before=1, strict=0)
period_stop_date = getClosestDate(date=financial_date,
target_date=period_stop_date,
precision=date_precision, before=0, strict=0)
# Calculate remaining annuities at bound dates
local_stop_date = addToDate(period_start_date, month = period_start_duration)
initial_remaining_annuities = getAccountableYearFraction(
from_date=period_start_date,
to_date=local_stop_date)
start_remaining_annuities = getAccountableYearFraction(from_date=start_date,
to_date=local_stop_date)
local_stop_date = addToDate(period_stop_date, month=stop_duration)
stop_remaining_annuities = getAccountableYearFraction(from_date=period_stop_date,
to_date=local_stop_date)
# Round annuities if needed
if round_duration == "greater annuity":
if start_remaining_annuities != int(start_remaining_annuities):
start_remaining_annuities = int(start_remaining_annuities) + 1
else:
start_remaining_annuities = int(start_remaining_annuities)
elif round_duration == "lower annuity":
start_remaining_annuities = int(start_remaining_annuities)
if cut_annuities:
current_date = getClosestDate(date=financial_date,
target_date=period_start_date,
precision='year',
before=0)
else:
current_date = period_start_date
annuity_number = -1
if period_start_date - current_date < 0:
annuity_number += 1
while current_date - at_date < 0:
annuity_number += 1
current_date = addToDate(current_date, year=1)
if annuity_number < 0:
return depreciable_price + disposal_price
annuity_start_date = addToDate(current_date, year=-1)
annuity_stop_date = current_date
truncated_annuity_stop_date = annuity_stop_date
truncated_annuity_start_date = annuity_start_date
# Adjust dates if it is a bound annuity
if period_stop_date < annuity_stop_date:
truncated_annuity_stop_date = period_stop_date
if truncated_annuity_stop_date > at_date:
truncated_annuity_stop_date = at_date
if period_start_date > annuity_start_date:
truncated_annuity_start_date = period_start_date
# Get the current ratio
checked_remaining_annuities = initial_remaining_annuities
if int(checked_remaining_annuities) != checked_remaining_annuities:
checked_remaining_annuities += 1
if annuity_number+1 > checked_remaining_annuities:
current_ratio = 0
else:
ratio_params = dict(immo_period)
ratio_params.update(
{'initial_remaining_annuities': initial_remaining_annuities,
'start_remaining_annuities': start_remaining_annuities,
'stop_remaining_annuities': stop_remaining_annuities,
'current_annuity': annuity_number,
'start_remaining_durability': start_durability,
'stop_remaining_durability': stop_durability,
#'annuity_start_date': annuity_start_date,
})
try:
ratio_script = self.unrestrictedTraverse(amortisation_method).ratioCalculation
except KeyError:
LOG('ERP5 Warning :', 0,
'Unable to find the ratio calculation script %s for item %s at date %s' % (
'%s/ratioCalculation' % amortisation_method, self.getRelativeUrl(), repr(at_date)))
raise ImmobilisationCalculationError, \
'Unable to find the ratio calculation script %s for item %s at date %s' % (
'%s/ratioCalculation' % amortisation_method, self.getRelativeUrl(), repr(at_date))
current_ratio = ratio_script(**ratio_params)
if current_ratio is None:
LOG("ERP5 Warning :",0,
"Unable to calculate the ratio during the amortisation calculation on item %s at date %s : script %s returned None" % (
self.getRelativeUrl(), repr(at_date), '%s/ratioCalculation' % amortisation_method))
raise ImmobilisationCalculationError, \
"Unable to calculate the ratio during the amortisation calculation on item %s at date %s" % (
repr(self), repr(at_date))
# Calculate the value at the beginning of the annuity
annuity_start_price = depreciable_price
local_period_start_price = annuity_start_price
if annuity_number:
if price_calculation_basis == "period recalculated start price":
local_period_start_date = start_date
local_period_start_price = self.getAmortisationPrice(
at_date=local_period_start_date,
immo_cache_dict=immo_cache_dict)
if local_period_start_price is None:
# It means no immobilisation period exists before ; we use real start date
local_period_start_price = start_price
if local_period_start_date > annuity_start_date:
annuity_start_price = local_period_start_price
else:
annuity_start_price = self.getAmortisationPrice(
at_date=annuity_start_date,
immo_cache_dict=immo_cache_dict) - disposal_price
else:
annuity_start_price = self.getAmortisationPrice(
at_date=annuity_start_date,
immo_cache_dict=immo_cache_dict) - disposal_price
# Calculate the raw annuity value
if price_calculation_basis == "start price":
raw_annuity_price = depreciable_price * current_ratio
elif price_calculation_basis == "annuity start price":
raw_annuity_price = annuity_start_price * current_ratio
elif price_calculation_basis == "period recalculated start price":
raw_annuity_price = local_period_start_price * current_ratio
# Apply the prorata temporis on the raw annuity value
if annuity_number and \
price_calculation_basis == 'period recalculated start price' and \
truncated_annuity_start_date < local_period_start_date:
truncated_annuity_start_date = local_period_start_date
if truncated_annuity_start_date <= annuity_start_date and \
truncated_annuity_stop_date >= annuity_stop_date:
annuity_value = raw_annuity_price
else:
local_stop_date = truncated_annuity_stop_date
if local_stop_date > at_date:
local_stop_date = at_date
annuity_value = raw_annuity_price * getAccountableYearFraction(
from_date=truncated_annuity_start_date,
to_date=local_stop_date)
if annuity_value < NEGLIGEABLE_PRICE:
annuity_value = 0
# Deduct the price at the given date
returned_price = annuity_start_price - annuity_value
if returned_price < NEGLIGEABLE_PRICE:
returned_price = 0
if returned_price is None:
return None
returned_price += disposal_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
security.declareProtected(Permissions.AccessContentsInformation,
'getCurrentAmortisationPrice')
def getCurrentAmortisationPrice(self, with_currency=0, **kw):
""" Returns the deprecated value of item at current time """
return self.getAmortisationPrice(at_date=DateTime(),
with_currency=with_currency, **kw)
def _createAmortisationRule(self):
"""
Build or update the amortisation rule related to this item, then expand the rule
SHOULD BE RUN AS MANAGER
"""
applied_rule_list = self.getCausalityRelatedValueList(portal_type='Applied Rule')
my_applied_rule_list = []
for applied_rule in applied_rule_list:
specialise_value = applied_rule.getSpecialiseValue()
if specialise_value is not None and\
specialise_value.getPortalType() == "Amortisation Rule":
my_applied_rule_list.append(applied_rule)
if len(my_applied_rule_list) == 0:
# Create a new applied order rule (portal_rules.order_rule)
portal_rules = getToolByName(self, 'portal_rules')
portal_simulation = getToolByName(self, 'portal_simulation')
my_applied_rule = portal_rules.default_amortisation_rule.constructNewAppliedRule(portal_simulation)
# Set causality
my_applied_rule.setCausalityValue(self)
my_applied_rule.reindexObject(activate_kw={'tag':'expand_amortisation'})
elif len(my_applied_rule_list) == 1:
# Re expand the rule if possible
my_applied_rule = my_applied_rule_list[0]
else:
# Delete first rules and re expand if possible
for my_applied_rule in my_applied_rule_list[:-1]:
my_applied_rule.getParentValue()._delObject(my_applied_rule.getId())
my_applied_rule = my_applied_rule_list[-1]
# We are now certain we have a single applied rule
# It is time to expand it
my_applied_rule.expand('immediate') # XXX: can it be done by activity ?
security.declareProtected(Permissions.AccessContentsInformation,
'expandAmortisation')
def expandAmortisation(self,**kw):
"""
Calculate the amortisation annuities for the item
in an activity
SHOULD BE RUN AS MANAGER
"""
# An item can be expanded for amortisation only when related deliveries
# are no more in 'calculating' immobilisation_state
related_packing_list_list = self.getAggregateRelatedValueList()
for related_packing_list in related_packing_list_list:
# XXX: Tagged reindexation added to replace after_path_and_method_id. May be unnecessary.
related_packing_list.recursiveReindexObject(
# Recycle a tag we must wait on anyway.
# XXX: it would be better to have per-item tags...
activate_kw={'tag': 'expand_amortisation'},
)
self.activate(
after_path_and_method_id=(
[x.getPath() for x in related_packing_list_list],
('updateImmobilisationState', ),
),
after_tag='expand_amortisation'
).immediateExpandAmortisation()
security.declareProtected(Permissions.AccessContentsInformation,
'immediateExpandAmortisation')
def immediateExpandAmortisation(self):
"""
Calculate the amortisation annuities for the item
SHOULD BE RUN AS MANAGER
"""
activate_kw = {'tag' : 'expand_amortisation'}
try:
self._createAmortisationRule()
except ImmobilisationValidityError:
delivery_list = self.getAggregateRelatedValueList()
for delivery in delivery_list:
if getattr(delivery, 'updateImmobilisationState', None) is not None:
delivery.updateImmobilisationState()
self.activate().expandAmortisation(activate_kw=activate_kw)
security.declareProtected(Permissions.AccessContentsInformation, 'getSectionMovementValueList')
def getSectionMovementValueList(self, include_to_date=0, **kw):
"""
Return the list of successive movements affecting
owners of the item. If at_date is None, return the result all the time
Only the movements in current_inventory_state are taken into account
"""
# Get tracking list
sql_kw = self._getCleanSqlDict(**kw)
sql_kw['item'] = self.getRelativeUrl()
sql_kw['sort_on'] = [('item.date','ascending')]
change_list = self.portal_simulation.getCurrentTrackingHistoryList(**sql_kw)
to_date = kw.get('to_date')
# Collect data
movement_list = []
for change in change_list:
date = change['date']
movement_uid = change['delivery_uid']
if (date is not None) and \
movement_uid is not None:
movement = self.portal_catalog.getObject(movement_uid)
movement_list.append(movement)
if include_to_date:
sql_kw['to_date'] = None
sql_kw['at_date'] = to_date
last_movement = self.portal_simulation.getCurrentTrackingList(**sql_kw)
if len(last_movement) > 0:
movement_uid = last_movement[-1]['delivery_uid']
if movement_uid is not None:
movement = self.portal_catalog.getObject(movement_uid)
if len(movement_list) == 0 or movement_list[-1] != movement:
movement_list.append(movement)
return movement_list
security.declareProtected(Permissions.AccessContentsInformation, 'getSectionChangeList')
def getSectionChangeList(self, at_date=None, **kw):
"""
Return the list of successive owners of the item with
the corresponding ownership change dates
If at_date is None, return the result all the time
"""
new_kw = self._getCleanSqlDict(**kw)
new_kw['to_date'] = at_date
movement_list = self.getSectionMovementValueList(**new_kw)
# Find ownership changes
from_date = new_kw.get('from_date')
if from_date is None:
previous_section = None
else:
previous_section = self.getSectionValue(at_date=from_date)
owner_change_list = []
for movement in movement_list:
new_section = movement.getDestinationSectionValue()
if self._ownerChange(previous_section, new_section):
# This movement is a ownership change movement
owner_change_list.append(movement)
previous_section = new_section
owner_list = []
for movement in owner_change_list:
owner = movement.getDestinationSectionValue()
owner = self._getFirstIndependantOrganisation(owner)
owner_list.append( {'owner' : owner,
'date' : movement.getStopDate(),
'movement' : movement } )
return owner_list
security.declareProtected(Permissions.AccessContentsInformation, 'getSectionValue')
def getSectionValue(self, at_date=None, **kw):
"""
Return the owner of the item at the given date
If at_date is None, return the last owner without time limit
"""
owner_list = self.getSectionChangeList(at_date=at_date, **kw)
if len(owner_list) > 0:
return owner_list[-1]['owner']
return None
security.declareProtected(Permissions.AccessContentsInformation, 'getCurrentSectionValue')
def getCurrentSectionValue(self, **kw):
"""
Return the current owner of the item
"""
return self.getSectionValue(at_date=DateTime(), **kw)
def _getCleanSqlDict(self, **kw):
no_key_list = ('immo_cache_dict',)
for key in no_key_list:
if key in kw:
del kw[key]
return kw
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Document Component" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>default_reference</string> </key>
<value> <string>ImmobilisableItem</string> </value>
</item>
<item>
<key> <string>default_source_reference</string> </key>
<value> <string>Products.ERP5.Document.ImmobilisableItem</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>document.erp5.ImmobilisableItem</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Document Component</string> </value>
</item>
<item>
<key> <string>sid</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>text_content_error_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>text_content_warning_message</string> </key>
<value>
<tuple>
<string>W: 56, 0: Bad indentation. Found 4 spaces, expected 2 (bad-indentation)</string>
<string>W: 61, 0: Bad indentation. Found 4 spaces, expected 2 (bad-indentation)</string>
<string>W: 62, 0: Bad indentation. Found 4 spaces, expected 2 (bad-indentation)</string>
<string>W: 63, 0: Bad indentation. Found 4 spaces, expected 2 (bad-indentation)</string>
<string>W: 66, 0: Bad indentation. Found 4 spaces, expected 2 (bad-indentation)</string>
<string>W: 67, 0: Bad indentation. Found 4 spaces, expected 2 (bad-indentation)</string>
<string>W: 70, 0: Bad indentation. Found 4 spaces, expected 2 (bad-indentation)</string>
<string>W: 81, 0: Bad indentation. Found 4 spaces, expected 2 (bad-indentation)</string>
<string>W: 84, 0: Bad indentation. Found 4 spaces, expected 2 (bad-indentation)</string>
<string>W: 85, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W: 87, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W: 88, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W: 93, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W: 95, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W: 96, 0: Bad indentation. Found 10 spaces, expected 8 (bad-indentation)</string>
<string>W: 97, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W: 99, 0: Bad indentation. Found 4 spaces, expected 2 (bad-indentation)</string>
<string>W:101, 0: Bad indentation. Found 4 spaces, expected 2 (bad-indentation)</string>
<string>W:109, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:125, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:126, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:127, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:128, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:129, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:130, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:131, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:133, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:134, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:135, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:136, 0: Bad indentation. Found 10 spaces, expected 8 (bad-indentation)</string>
<string>W:137, 0: Bad indentation. Found 10 spaces, expected 8 (bad-indentation)</string>
<string>W:138, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:139, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:140, 0: Bad indentation. Found 10 spaces, expected 8 (bad-indentation)</string>
<string>W:142, 0: Bad indentation. Found 10 spaces, expected 8 (bad-indentation)</string>
<string>W:143, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:147, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:148, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:149, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:150, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:151, 0: Bad indentation. Found 10 spaces, expected 8 (bad-indentation)</string>
<string>W:152, 0: Bad indentation. Found 10 spaces, expected 8 (bad-indentation)</string>
<string>W:153, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:154, 0: Bad indentation. Found 10 spaces, expected 8 (bad-indentation)</string>
<string>W:155, 0: Bad indentation. Found 10 spaces, expected 8 (bad-indentation)</string>
<string>W:156, 0: Bad indentation. Found 12 spaces, expected 10 (bad-indentation)</string>
<string>W:157, 0: Bad indentation. Found 10 spaces, expected 8 (bad-indentation)</string>
<string>W:158, 0: Bad indentation. Found 12 spaces, expected 10 (bad-indentation)</string>
<string>W:159, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:160, 0: Bad indentation. Found 10 spaces, expected 8 (bad-indentation)</string>
<string>W:162, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:163, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:164, 0: Bad indentation. Found 10 spaces, expected 8 (bad-indentation)</string>
<string>W:166, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:167, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:168, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:170, 0: Bad indentation. Found 10 spaces, expected 8 (bad-indentation)</string>
<string>W:172, 0: Bad indentation. Found 12 spaces, expected 10 (bad-indentation)</string>
<string>W:174, 0: Bad indentation. Found 10 spaces, expected 8 (bad-indentation)</string>
<string>W:175, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:177, 0: Bad indentation. Found 4 spaces, expected 2 (bad-indentation)</string>
<string>W:178, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:184, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:185, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:187, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:188, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:189, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:190, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:191, 0: Bad indentation. Found 10 spaces, expected 8 (bad-indentation)</string>
<string>W:192, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:193, 0: Bad indentation. Found 10 spaces, expected 8 (bad-indentation)</string>
<string>W:194, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:195, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:196, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:197, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:198, 0: Bad indentation. Found 10 spaces, expected 8 (bad-indentation)</string>
<string>W:199, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:201, 0: Bad indentation. Found 4 spaces, expected 2 (bad-indentation)</string>
<string>W:202, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:207, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:208, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:209, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:210, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:211, 0: Bad indentation. Found 10 spaces, expected 8 (bad-indentation)</string>
<string>W:212, 0: Bad indentation. Found 10 spaces, expected 8 (bad-indentation)</string>
<string>W:213, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:214, 0: Bad indentation. Found 10 spaces, expected 8 (bad-indentation)</string>
<string>W:215, 0: Bad indentation. Found 10 spaces, expected 8 (bad-indentation)</string>
<string>W:216, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:217, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:218, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:219, 0: Bad indentation. Found 10 spaces, expected 8 (bad-indentation)</string>
<string>W:220, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:221, 0: Bad indentation. Found 10 spaces, expected 8 (bad-indentation)</string>
<string>W:222, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:227, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:228, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:229, 0: Bad indentation. Found 10 spaces, expected 8 (bad-indentation)</string>
<string>W:230, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:231, 0: Bad indentation. Found 10 spaces, expected 8 (bad-indentation)</string>
<string>W:232, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:234, 0: Bad indentation. Found 4 spaces, expected 2 (bad-indentation)</string>
<string>W:236, 0: Bad indentation. Found 4 spaces, expected 2 (bad-indentation)</string>
<string>W:241, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:246, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:251, 0: Bad indentation. Found 4 spaces, expected 2 (bad-indentation)</string>
<string>W:253, 0: Bad indentation. Found 4 spaces, expected 2 (bad-indentation)</string>
<string>W:254, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:258, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:262, 0: Bad indentation. Found 4 spaces, expected 2 (bad-indentation)</string>
<string>W:264, 0: Bad indentation. Found 4 spaces, expected 2 (bad-indentation)</string>
<string>W:265, 0: Bad indentation. Found 7 spaces, expected 4 (bad-indentation)</string>
<string>W:269, 0: Bad indentation. Found 7 spaces, expected 4 (bad-indentation)</string>
<string>W:270, 0: Bad indentation. Found 7 spaces, expected 4 (bad-indentation)</string>
<string>W:272, 0: Bad indentation. Found 7 spaces, expected 4 (bad-indentation)</string>
<string>W:274, 0: Bad indentation. Found 4 spaces, expected 2 (bad-indentation)</string>
<string>W:276, 0: Bad indentation. Found 4 spaces, expected 2 (bad-indentation)</string>
<string>W:277, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:282, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:283, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:284, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:286, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:287, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:288, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:291, 0: Bad indentation. Found 4 spaces, expected 2 (bad-indentation)</string>
<string>W:293, 0: Bad indentation. Found 4 spaces, expected 2 (bad-indentation)</string>
<string>W:294, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:297, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:298, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:299, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:300, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:302, 0: Bad indentation. Found 4 spaces, expected 2 (bad-indentation)</string>
<string>W:304, 0: Bad indentation. Found 4 spaces, expected 2 (bad-indentation)</string>
<string>W:305, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:310, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:314, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:315, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:316, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:318, 0: Bad indentation. Found 4 spaces, expected 2 (bad-indentation)</string>
<string>W:320, 0: Bad indentation. Found 4 spaces, expected 2 (bad-indentation)</string>
<string>W:321, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:325, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:326, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:327, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:328, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:329, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:332, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:333, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:335, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:337, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:341, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:342, 0: Bad indentation. Found 10 spaces, expected 8 (bad-indentation)</string>
<string>W:343, 0: Bad indentation. Found 10 spaces, expected 8 (bad-indentation)</string>
<string>W:344, 0: Bad indentation. Found 12 spaces, expected 10 (bad-indentation)</string>
<string>W:345, 0: Bad indentation. Found 14 spaces, expected 12 (bad-indentation)</string>
<string>W:346, 0: Bad indentation. Found 16 spaces, expected 14 (bad-indentation)</string>
<string>W:347, 0: Bad indentation. Found 18 spaces, expected 16 (bad-indentation)</string>
<string>W:348, 0: Bad indentation. Found 12 spaces, expected 10 (bad-indentation)</string>
<string>W:349, 0: Bad indentation. Found 14 spaces, expected 12 (bad-indentation)</string>
<string>W:350, 0: Bad indentation. Found 16 spaces, expected 14 (bad-indentation)</string>
<string>W:351, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:358, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:361, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:365, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:366, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:367, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:368, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:371, 0: Bad indentation. Found 10 spaces, expected 8 (bad-indentation)</string>
<string>W:373, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:376, 0: Bad indentation. Found 10 spaces, expected 8 (bad-indentation)</string>
<string>W:377, 0: Bad indentation. Found 10 spaces, expected 8 (bad-indentation)</string>
<string>W:378, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:380, 0: Bad indentation. Found 10 spaces, expected 8 (bad-indentation)</string>
<string>W:381, 0: Bad indentation. Found 12 spaces, expected 10 (bad-indentation)</string>
<string>W:382, 0: Bad indentation. Found 12 spaces, expected 10 (bad-indentation)</string>
<string>W:383, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:392, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:393, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:394, 0: Bad indentation. Found 10 spaces, expected 8 (bad-indentation)</string>
<string>W:395, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:396, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:397, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:398, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:399, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:403, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:404, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:405, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:406, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:407, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:408, 0: Bad indentation. Found 10 spaces, expected 8 (bad-indentation)</string>
<string>W:409, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:410, 0: Bad indentation. Found 10 spaces, expected 8 (bad-indentation)</string>
<string>W:412, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:415, 0: Bad indentation. Found 10 spaces, expected 8 (bad-indentation)</string>
<string>W:416, 0: Bad indentation. Found 10 spaces, expected 8 (bad-indentation)</string>
<string>W:417, 0: Bad indentation. Found 10 spaces, expected 8 (bad-indentation)</string>
<string>W:418, 0: Bad indentation. Found 10 spaces, expected 8 (bad-indentation)</string>
<string>W:419, 0: Bad indentation. Found 10 spaces, expected 8 (bad-indentation)</string>
<string>W:420, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:422, 0: Bad indentation. Found 10 spaces, expected 8 (bad-indentation)</string>
<string>W:423, 0: Bad indentation. Found 10 spaces, expected 8 (bad-indentation)</string>
<string>W:424, 0: Bad indentation. Found 10 spaces, expected 8 (bad-indentation)</string>
<string>W:425, 0: Bad indentation. Found 10 spaces, expected 8 (bad-indentation)</string>
<string>W:426, 0: Bad indentation. Found 10 spaces, expected 8 (bad-indentation)</string>
<string>W:427, 0: Bad indentation. Found 12 spaces, expected 10 (bad-indentation)</string>
<string>W:428, 0: Bad indentation. Found 10 spaces, expected 8 (bad-indentation)</string>
<string>W:429, 0: Bad indentation. Found 12 spaces, expected 10 (bad-indentation)</string>
<string>W:430, 0: Bad indentation. Found 10 spaces, expected 8 (bad-indentation)</string>
<string>W:435, 0: Bad indentation. Found 12 spaces, expected 10 (bad-indentation)</string>
<string>W:436, 0: Bad indentation. Found 10 spaces, expected 8 (bad-indentation)</string>
<string>W:437, 0: Bad indentation. Found 12 spaces, expected 10 (bad-indentation)</string>
<string>W:439, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:440, 0: Bad indentation. Found 10 spaces, expected 8 (bad-indentation)</string>
<string>W:444, 0: Bad indentation. Found 10 spaces, expected 8 (bad-indentation)</string>
<string>W:448, 0: Bad indentation. Found 10 spaces, expected 8 (bad-indentation)</string>
<string>W:449, 0: Bad indentation. Found 10 spaces, expected 8 (bad-indentation)</string>
<string>W:450, 0: Bad indentation. Found 10 spaces, expected 8 (bad-indentation)</string>
<string>W:451, 0: Bad indentation. Found 10 spaces, expected 8 (bad-indentation)</string>
<string>W:452, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:455, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:457, 0: Bad indentation. Found 10 spaces, expected 8 (bad-indentation)</string>
<string>W:459, 0: Bad indentation. Found 10 spaces, expected 8 (bad-indentation)</string>
<string>W:463, 0: Bad indentation. Found 12 spaces, expected 10 (bad-indentation)</string>
<string>W:464, 0: Bad indentation. Found 14 spaces, expected 12 (bad-indentation)</string>
<string>W:465, 0: Bad indentation. Found 14 spaces, expected 12 (bad-indentation)</string>
<string>W:466, 0: Bad indentation. Found 14 spaces, expected 12 (bad-indentation)</string>
<string>W:471, 0: Bad indentation. Found 14 spaces, expected 12 (bad-indentation)</string>
<string>W:474, 0: Bad indentation. Found 14 spaces, expected 12 (bad-indentation)</string>
<string>W:475, 0: Bad indentation. Found 14 spaces, expected 12 (bad-indentation)</string>
<string>W:476, 0: Bad indentation. Found 14 spaces, expected 12 (bad-indentation)</string>
<string>W:477, 0: Bad indentation. Found 14 spaces, expected 12 (bad-indentation)</string>
<string>W:478, 0: Bad indentation. Found 16 spaces, expected 14 (bad-indentation)</string>
<string>W:479, 0: Bad indentation. Found 16 spaces, expected 14 (bad-indentation)</string>
<string>W:480, 0: Bad indentation. Found 16 spaces, expected 14 (bad-indentation)</string>
<string>W:481, 0: Bad indentation. Found 18 spaces, expected 16 (bad-indentation)</string>
<string>W:482, 0: Bad indentation. Found 16 spaces, expected 14 (bad-indentation)</string>
<string>W:483, 0: Bad indentation. Found 16 spaces, expected 14 (bad-indentation)</string>
<string>W:484, 0: Bad indentation. Found 12 spaces, expected 10 (bad-indentation)</string>
<string>W:485, 0: Bad indentation. Found 14 spaces, expected 12 (bad-indentation)</string>
<string>W:490, 0: Bad indentation. Found 14 spaces, expected 12 (bad-indentation)</string>
<string>W:491, 0: Bad indentation. Found 14 spaces, expected 12 (bad-indentation)</string>
<string>W:494, 0: Bad indentation. Found 14 spaces, expected 12 (bad-indentation)</string>
<string>W:495, 0: Bad indentation. Found 14 spaces, expected 12 (bad-indentation)</string>
<string>W:498, 0: Bad indentation. Found 14 spaces, expected 12 (bad-indentation)</string>
<string>W:499, 0: Bad indentation. Found 14 spaces, expected 12 (bad-indentation)</string>
<string>W:500, 0: Bad indentation. Found 14 spaces, expected 12 (bad-indentation)</string>
<string>W:503, 0: Bad indentation. Found 14 spaces, expected 12 (bad-indentation)</string>
<string>W:506, 0: Bad indentation. Found 14 spaces, expected 12 (bad-indentation)</string>
<string>W:509, 0: Bad indentation. Found 14 spaces, expected 12 (bad-indentation)</string>
<string>W:511, 0: Bad indentation. Found 12 spaces, expected 10 (bad-indentation)</string>
<string>W:512, 0: Bad indentation. Found 12 spaces, expected 10 (bad-indentation)</string>
<string>W:513, 0: Bad indentation. Found 12 spaces, expected 10 (bad-indentation)</string>
<string>W:514, 0: Bad indentation. Found 12 spaces, expected 10 (bad-indentation)</string>
<string>W:515, 0: Bad indentation. Found 12 spaces, expected 10 (bad-indentation)</string>
<string>W:516, 0: Bad indentation. Found 12 spaces, expected 10 (bad-indentation)</string>
<string>W:517, 0: Bad indentation. Found 12 spaces, expected 10 (bad-indentation)</string>
<string>W:518, 0: Bad indentation. Found 12 spaces, expected 10 (bad-indentation)</string>
<string>W:519, 0: Bad indentation. Found 12 spaces, expected 10 (bad-indentation)</string>
<string>W:527, 0: Bad indentation. Found 12 spaces, expected 10 (bad-indentation)</string>
<string>W:528, 0: Bad indentation. Found 12 spaces, expected 10 (bad-indentation)</string>
<string>W:529, 0: Bad indentation. Found 12 spaces, expected 10 (bad-indentation)</string>
<string>W:530, 0: Bad indentation. Found 14 spaces, expected 12 (bad-indentation)</string>
<string>W:531, 0: Bad indentation. Found 14 spaces, expected 12 (bad-indentation)</string>
<string>W:538, 0: Bad indentation. Found 14 spaces, expected 12 (bad-indentation)</string>
<string>W:543, 0: Bad indentation. Found 14 spaces, expected 12 (bad-indentation)</string>
<string>W:544, 0: Bad indentation. Found 14 spaces, expected 12 (bad-indentation)</string>
<string>W:550, 0: Bad indentation. Found 12 spaces, expected 10 (bad-indentation)</string>
<string>W:551, 0: Bad indentation. Found 12 spaces, expected 10 (bad-indentation)</string>
<string>W:553, 0: Bad indentation. Found 12 spaces, expected 10 (bad-indentation)</string>
<string>W:555, 0: Bad indentation. Found 14 spaces, expected 12 (bad-indentation)</string>
<string>W:556, 0: Bad indentation. Found 12 spaces, expected 10 (bad-indentation)</string>
<string>W:557, 0: Bad indentation. Found 14 spaces, expected 12 (bad-indentation)</string>
<string>W:562, 0: Bad indentation. Found 14 spaces, expected 12 (bad-indentation)</string>
<string>W:563, 0: Bad indentation. Found 14 spaces, expected 12 (bad-indentation)</string>
<string>W:565, 0: Bad indentation. Found 16 spaces, expected 14 (bad-indentation)</string>
<string>W:566, 0: Bad indentation. Found 16 spaces, expected 14 (bad-indentation)</string>
<string>W:567, 0: Bad indentation. Found 16 spaces, expected 14 (bad-indentation)</string>
<string>W:570, 0: Bad indentation. Found 16 spaces, expected 14 (bad-indentation)</string>
<string>W:573, 0: Bad indentation. Found 16 spaces, expected 14 (bad-indentation)</string>
<string>W:576, 0: Bad indentation. Found 16 spaces, expected 14 (bad-indentation)</string>
<string>W:577, 0: Bad indentation. Found 16 spaces, expected 14 (bad-indentation)</string>
<string>W:578, 0: Bad indentation. Found 16 spaces, expected 14 (bad-indentation)</string>
<string>W:579, 0: Bad indentation. Found 14 spaces, expected 12 (bad-indentation)</string>
<string>W:580, 0: Bad indentation. Found 14 spaces, expected 12 (bad-indentation)</string>
<string>W:581, 0: Bad indentation. Found 16 spaces, expected 14 (bad-indentation)</string>
<string>W:582, 0: Bad indentation. Found 16 spaces, expected 14 (bad-indentation)</string>
<string>W:583, 0: Bad indentation. Found 18 spaces, expected 16 (bad-indentation)</string>
<string>W:584, 0: Bad indentation. Found 20 spaces, expected 18 (bad-indentation)</string>
<string>W:585, 0: Bad indentation. Found 12 spaces, expected 10 (bad-indentation)</string>
<string>W:588, 0: Bad indentation. Found 14 spaces, expected 12 (bad-indentation)</string>
<string>W:589, 0: Bad indentation. Found 14 spaces, expected 12 (bad-indentation)</string>
<string>W:590, 0: Bad indentation. Found 16 spaces, expected 14 (bad-indentation)</string>
<string>W:591, 0: Bad indentation. Found 16 spaces, expected 14 (bad-indentation)</string>
<string>W:592, 0: Bad indentation. Found 18 spaces, expected 16 (bad-indentation)</string>
<string>W:593, 0: Bad indentation. Found 20 spaces, expected 18 (bad-indentation)</string>
<string>W:597, 0: Bad indentation. Found 12 spaces, expected 10 (bad-indentation)</string>
<string>W:601, 0: Bad indentation. Found 12 spaces, expected 10 (bad-indentation)</string>
<string>W:602, 0: Bad indentation. Found 14 spaces, expected 12 (bad-indentation)</string>
<string>W:603, 0: Bad indentation. Found 16 spaces, expected 14 (bad-indentation)</string>
<string>W:605, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:606, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:608, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:609, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:610, 0: Bad indentation. Found 10 spaces, expected 8 (bad-indentation)</string>
<string>W:611, 0: Bad indentation. Found 12 spaces, expected 10 (bad-indentation)</string>
<string>W:612, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:614, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:616, 0: Bad indentation. Found 4 spaces, expected 2 (bad-indentation)</string>
<string>W:618, 0: Bad indentation. Found 4 spaces, expected 2 (bad-indentation)</string>
<string>W:619, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:623, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:625, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:626, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:627, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:629, 0: Bad indentation. Found 4 spaces, expected 2 (bad-indentation)</string>
<string>W:631, 0: Bad indentation. Found 4 spaces, expected 2 (bad-indentation)</string>
<string>W:632, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:633, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:635, 0: Bad indentation. Found 4 spaces, expected 2 (bad-indentation)</string>
<string>W:637, 0: Bad indentation. Found 4 spaces, expected 2 (bad-indentation)</string>
<string>W:638, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:639, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:642, 0: Bad indentation. Found 4 spaces, expected 2 (bad-indentation)</string>
<string>W:644, 0: Bad indentation. Found 4 spaces, expected 2 (bad-indentation)</string>
<string>W:645, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:649, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:650, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:651, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:652, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:653, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:654, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:655, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:657, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:658, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:660, 0: Bad indentation. Found 4 spaces, expected 2 (bad-indentation)</string>
<string>W:662, 0: Bad indentation. Found 4 spaces, expected 2 (bad-indentation)</string>
<string>W:663, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:666, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:668, 0: Bad indentation. Found 4 spaces, expected 2 (bad-indentation)</string>
<string>W:670, 0: Bad indentation. Found 4 spaces, expected 2 (bad-indentation)</string>
<string>W:671, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:675, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:676, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:677, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:678, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:679, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:680, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:681, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:682, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:683, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:684, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:685, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:686, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:687, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:688, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:689, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:690, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:691, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:692, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:693, 0: Bad indentation. Found 10 spaces, expected 8 (bad-indentation)</string>
<string>W:694, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:695, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:697, 0: Bad indentation. Found 4 spaces, expected 2 (bad-indentation)</string>
<string>W:699, 0: Bad indentation. Found 4 spaces, expected 2 (bad-indentation)</string>
<string>W:700, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:714, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:715, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:717, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:718, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:719, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:720, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:721, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:722, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:723, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:725, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:726, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:728, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:730, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:731, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:734, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:735, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:736, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:737, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:740, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:742, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:743, 0: Bad indentation. Found 10 spaces, expected 8 (bad-indentation)</string>
<string>W:744, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:745, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:746, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:747, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:748, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:749, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:750, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:754, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:757, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:758, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:759, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:760, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:762, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:763, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:764, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:765, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:766, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:767, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:768, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:771, 0: Bad indentation. Found 4 spaces, expected 2 (bad-indentation)</string>
<string>W:773, 0: Bad indentation. Found 4 spaces, expected 2 (bad-indentation)</string>
<string>W:774, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:777, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:780, 0: Bad indentation. Found 4 spaces, expected 2 (bad-indentation)</string>
<string>W:782, 0: Bad indentation. Found 4 spaces, expected 2 (bad-indentation)</string>
<string>W:783, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:788, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:789, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:790, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:791, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:793, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:794, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:795, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:798, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:800, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:802, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:803, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:804, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:805, 0: Bad indentation. Found 10 spaces, expected 8 (bad-indentation)</string>
<string>W:806, 0: Bad indentation. Found 10 spaces, expected 8 (bad-indentation)</string>
<string>W:807, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:809, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:810, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:812, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:813, 0: Bad indentation. Found 10 spaces, expected 8 (bad-indentation)</string>
<string>W:814, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:817, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:818, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:819, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:820, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:821, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:822, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:823, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:824, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:825, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:826, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:827, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:829, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:830, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:832, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:833, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:835, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:836, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:839, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:840, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:841, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:842, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:843, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:844, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:845, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:846, 0: Bad indentation. Found 10 spaces, expected 8 (bad-indentation)</string>
<string>W:847, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:848, 0: Bad indentation. Found 10 spaces, expected 8 (bad-indentation)</string>
<string>W:849, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:850, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:851, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:855, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:859, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:860, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:861, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:862, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:863, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:866, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:870, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:871, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:872, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:873, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:874, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:877, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:878, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:882, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:885, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:889, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:890, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:894, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:897, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:898, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:901, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:902, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:903, 0: Bad indentation. Found 10 spaces, expected 8 (bad-indentation)</string>
<string>W:904, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:905, 0: Bad indentation. Found 10 spaces, expected 8 (bad-indentation)</string>
<string>W:906, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:907, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:909, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:910, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:914, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:915, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:916, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:917, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:918, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:919, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:920, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:921, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:922, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:923, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:924, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:925, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:926, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:927, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:929, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:930, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:931, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:932, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:933, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:934, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:937, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:938, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:939, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:940, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:941, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:942, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:943, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:944, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:953, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:954, 0: Bad indentation. Found 10 spaces, expected 8 (bad-indentation)</string>
<string>W:955, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:956, 0: Bad indentation. Found 10 spaces, expected 8 (bad-indentation)</string>
<string>W:959, 0: Bad indentation. Found 10 spaces, expected 8 (bad-indentation)</string>
<string>W:963, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:964, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:965, 0: Bad indentation. Found 10 spaces, expected 8 (bad-indentation)</string>
<string>W:968, 0: Bad indentation. Found 10 spaces, expected 8 (bad-indentation)</string>
<string>W:973, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:974, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:975, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:976, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:977, 0: Bad indentation. Found 10 spaces, expected 8 (bad-indentation)</string>
<string>W:978, 0: Bad indentation. Found 10 spaces, expected 8 (bad-indentation)</string>
<string>W:981, 0: Bad indentation. Found 10 spaces, expected 8 (bad-indentation)</string>
<string>W:983, 0: Bad indentation. Found 12 spaces, expected 10 (bad-indentation)</string>
<string>W:984, 0: Bad indentation. Found 10 spaces, expected 8 (bad-indentation)</string>
<string>W:985, 0: Bad indentation. Found 12 spaces, expected 10 (bad-indentation)</string>
<string>W:986, 0: Bad indentation. Found 10 spaces, expected 8 (bad-indentation)</string>
<string>W:987, 0: Bad indentation. Found 12 spaces, expected 10 (bad-indentation)</string>
<string>W:990, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:991, 0: Bad indentation. Found 10 spaces, expected 8 (bad-indentation)</string>
<string>W:996, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:997, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:998, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:999, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:1000, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:1001, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:1004, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:1007, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:1008, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:1010, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:1011, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:1012, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:1013, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:1014, 0: Bad indentation. Found 10 spaces, expected 8 (bad-indentation)</string>
<string>W:1015, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:1018, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:1019, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:1021, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:1022, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:1023, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:1024, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:1025, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:1026, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:1027, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:1028, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:1029, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:1030, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:1031, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:1033, 0: Bad indentation. Found 4 spaces, expected 2 (bad-indentation)</string>
<string>W:1035, 0: Bad indentation. Found 4 spaces, expected 2 (bad-indentation)</string>
<string>W:1036, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:1037, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:1040, 0: Bad indentation. Found 4 spaces, expected 2 (bad-indentation)</string>
<string>W:1041, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:1045, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:1046, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:1047, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:1048, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:1049, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:1051, 0: Bad indentation. Found 10 spaces, expected 8 (bad-indentation)</string>
<string>W:1053, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:1055, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:1056, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:1057, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:1059, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:1060, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:1062, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:1064, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:1065, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:1067, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:1068, 0: Bad indentation. Found 10 spaces, expected 8 (bad-indentation)</string>
<string>W:1069, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:1072, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:1074, 0: Bad indentation. Found 4 spaces, expected 2 (bad-indentation)</string>
<string>W:1076, 0: Bad indentation. Found 4 spaces, expected 2 (bad-indentation)</string>
<string>W:1077, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:1084, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:1085, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:1087, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:1092, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:1100, 0: Bad indentation. Found 4 spaces, expected 2 (bad-indentation)</string>
<string>W:1102, 0: Bad indentation. Found 4 spaces, expected 2 (bad-indentation)</string>
<string>W:1103, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:1107, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:1108, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:1109, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:1110, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:1111, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:1112, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:1113, 0: Bad indentation. Found 10 spaces, expected 8 (bad-indentation)</string>
<string>W:1114, 0: Bad indentation. Found 12 spaces, expected 10 (bad-indentation)</string>
<string>W:1115, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:1117, 0: Bad indentation. Found 4 spaces, expected 2 (bad-indentation)</string>
<string>W:1118, 0: Bad indentation. Found 4 spaces, expected 2 (bad-indentation)</string>
<string>W:1119, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:1125, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:1126, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:1127, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:1128, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:1129, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:1131, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:1132, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:1133, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:1134, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:1135, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:1137, 0: Bad indentation. Found 10 spaces, expected 8 (bad-indentation)</string>
<string>W:1138, 0: Bad indentation. Found 10 spaces, expected 8 (bad-indentation)</string>
<string>W:1139, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:1140, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:1141, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:1142, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:1143, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:1144, 0: Bad indentation. Found 10 spaces, expected 8 (bad-indentation)</string>
<string>W:1145, 0: Bad indentation. Found 10 spaces, expected 8 (bad-indentation)</string>
<string>W:1146, 0: Bad indentation. Found 12 spaces, expected 10 (bad-indentation)</string>
<string>W:1147, 0: Bad indentation. Found 12 spaces, expected 10 (bad-indentation)</string>
<string>W:1148, 0: Bad indentation. Found 14 spaces, expected 12 (bad-indentation)</string>
<string>W:1149, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:1151, 0: Bad indentation. Found 4 spaces, expected 2 (bad-indentation)</string>
<string>W:1152, 0: Bad indentation. Found 4 spaces, expected 2 (bad-indentation)</string>
<string>W:1153, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:1158, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:1159, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:1160, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:1162, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:1163, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:1164, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:1165, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:1166, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:1167, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:1168, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:1169, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:1170, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:1172, 0: Bad indentation. Found 10 spaces, expected 8 (bad-indentation)</string>
<string>W:1173, 0: Bad indentation. Found 10 spaces, expected 8 (bad-indentation)</string>
<string>W:1174, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:1175, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:1176, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:1177, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:1178, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:1181, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:1183, 0: Bad indentation. Found 4 spaces, expected 2 (bad-indentation)</string>
<string>W:1184, 0: Bad indentation. Found 4 spaces, expected 2 (bad-indentation)</string>
<string>W:1185, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:1189, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:1190, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:1191, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:1192, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:1194, 0: Bad indentation. Found 4 spaces, expected 2 (bad-indentation)</string>
<string>W:1195, 0: Bad indentation. Found 4 spaces, expected 2 (bad-indentation)</string>
<string>W:1196, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:1199, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:1201, 0: Bad indentation. Found 4 spaces, expected 2 (bad-indentation)</string>
<string>W:1202, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:1203, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:1204, 0: Bad indentation. Found 8 spaces, expected 6 (bad-indentation)</string>
<string>W:1205, 0: Bad indentation. Found 10 spaces, expected 8 (bad-indentation)</string>
<string>W:1206, 0: Bad indentation. Found 6 spaces, expected 4 (bad-indentation)</string>
<string>W:126, 6: Unused variable \'sim_tool\' (unused-variable)</string>
<string>W:130, 6: Unused variable \'immo_and_owner_list\' (unused-variable)</string>
<string>W:129, 6: Unused variable \'owner_change_list\' (unused-variable)</string>
<string>W:125, 6: Unused variable \'wf_tool\' (unused-variable)</string>
<string>W:609, 12: Redefining built-in \'property\' (redefined-builtin)</string>
<string>W:337, 6: Dangerous default value [] as argument (dangerous-default-value)</string>
<string>W:477, 28: Unused variable \'tag\' (unused-variable)</string>
<string>W:406, 8: Unused variable \'is_section_movement\' (unused-variable)</string>
<string>W:689, 8: Unused variable \'calculate\' (unused-variable)</string>
<string>W:693, 10: Unused variable \'returned_value\' (unused-variable)</string>
</tuple>
</value>
</item>
<item>
<key> <string>version</string> </key>
<value> <string>erp5</string> </value>
</item>
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary>
<item>
<key> <string>component_validation_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>validate</string> </value>
</item>
<item>
<key> <string>validation_state</string> </key>
<value> <string>validated</string> </value>
</item>
</dictionary>
</list>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
document.erp5.AmortisationRule
document.erp5.ImmobilisableItem
document.erp5.Immobilisation
document.erp5.ImmobilisationLine
\ No newline at end of file
interface.erp5.IImmobilisationItem
\ No newline at end of file
portal_components/document.erp5.ImmobilisationItem
portal_components/interface.erp5.IImmobilisationItem
\ No newline at end of file
##############################################################################
#
# Copyright (c) 2002 Nexedi SARL and Contributors. All Rights Reserved.
# Guillaume Michon <guillaume.michon@e-asc.com>
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
from AccessControl import ClassSecurityInfo
from Products.ERP5Type import Permissions, PropertySheet
from Products.ERP5Type.XMLObject import XMLObject
class ImmobilisationDelivery(XMLObject):
"""
An Immobilisation Delivery is an object whose role is to
contain delivery movements which can immobilise items.
"""
meta_type = 'ERP5 Immobilisation Delivery'
portal_type = 'Immobilisation Delivery'
add_permission = Permissions.AddPortalContent
# Declarative security
security = ClassSecurityInfo()
security.declareObjectProtected(Permissions.AccessContentsInformation)
# Declarative properties
property_sheets = ( PropertySheet.Base
, PropertySheet.XMLObject
, PropertySheet.CategoryCore
, PropertySheet.DublinCore
, PropertySheet.Task
, PropertySheet.Arrow
, PropertySheet.Movement
, PropertySheet.Delivery
, PropertySheet.Reference
)
security.declareProtected(Permissions.AccessContentsInformation, 'updateImmobilisationState')
def updateImmobilisationState(self, **kw):
"""
This is often called as an activity, it will check if the
delivery is valid as an immobilisation movement, and if so
it will put the delivery in a valid state, if not valid in
an invalid state
"""
if self.getImmobilisationState() == 'calculating':
from erp5.component.document.ImmobilisableItem import ImmobilisationValidityError
try:
if self.isValidImmobilisationMovement(**kw):
self.validateImmobilisation()
else:
self.invalidateImmobilisation()
except ImmobilisationValidityError:
self.calculateImmobilisationValidity()
security.declareProtected(Permissions.AccessContentsInformation, 'getImmobilisationMovementList')
def getImmobilisationMovementList(self, **kw):
"""
Return regular movements + immobilisation movements like
Immobilisation Line and Immobilisation Cell
"""
return self.getMovementList(self.getPortalMovementTypeList() +
('Immobilisation Line', 'Immobilisation Cell'), **kw)
security.declareProtected(Permissions.AccessContentsInformation, 'checkImmobilisationConsistency')
def checkImmobilisationConsistency(self, *args, **kw):
"""
Check the consistency about immobilisation values
"""
return_list = []
for movement in self.getImmobilisationMovementList():
return_list.extend(movement.checkImmobilisationConsistency())
return return_list
security.declareProtected(Permissions.AccessContentsInformation, 'isValidImmobilisationMovement')
def isValidImmobilisationMovement(self, *args, **kw):
"""
Return true if all submovements are valid in terms of immobilisation
"""
error_list = self.checkImmobilisationConsistency(*args, **kw)
return len(error_list) == 0
security.declareProtected(Permissions.AccessContentsInformation, 'isInvalidImmobilisationMovement')
def isInvalidImmobilisationMovement(self, *args, **kw):
"""
Return false if all submovements are valid in terms of immobilisation
"""
return not self.isValidImmobilisationMovement(*args, **kw)
security.declareProtected(Permissions.AccessContentsInformation,
'getAggregatedItemsNextImmobilisationMovementValueList')
def getAggregatedItemsNextImmobilisationMovementValueList(self, **kw):
"""
Return the list of each next immobilisation movement for each aggregated item
"""
from erp5.component.interface.IImmobilisationItem import IImmobilisationItem
returned_list = []
sub_movement_list = self.contentValues()
for movement in self.getImmobilisationMovementList(**kw):
for item in movement.getAggregateValueList():
if IImmobilisationItem.providedBy(item):
future_movement_list = item.getFutureImmobilisationMovementValueList(
at_date = self.getStopDate(),
from_movement = self,
filter_valid = 0)
if future_movement_list is not None:
for next_movement in future_movement_list:
if next_movement is not None and \
next_movement not in sub_movement_list and \
next_movement not in returned_list and \
next_movement.getStopDate() != self.getStopDate():
returned_list.append(next_movement)
return returned_list
......@@ -38,8 +38,8 @@ from AccessControl.PermissionRole import PermissionRole
from Products.ERP5Type import Permissions, PropertySheet, interfaces
from Products.ERP5Type.Accessor.Constant import PropertyGetter as ConstantGetter
from Products.ERP5Type.XMLObject import XMLObject
from Products.ERP5.Document.ImmobilisationDelivery import ImmobilisationDelivery
from Products.ERP5.mixin.amount_generator import AmountGeneratorMixin
from erp5.component.document.ImmobilisationDelivery import ImmobilisationDelivery
from Products.ERP5.mixin.composition import CompositionMixin
from erp5.component.mixin.SimulableMixin import SimulableMixin
from Products.ERP5Type.UnrestrictedMethod import UnrestrictedMethod, \
......
##############################################################################
#
# Copyright (c) 2002 Nexedi SARL and Contributors. All Rights Reserved.
# Guillaume Michon <guillaume.michon@e-asc.com>
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
import zope.interface
from AccessControl import ClassSecurityInfo
from DateTime import DateTime
from string import capitalize
from Products.ERP5Type import Permissions, PropertySheet
from erp5.component.interface.IImmobilisationItem import IImmobilisationItem
from Products.ERP5Type.DateUtils import addToDate, getClosestDate, roundDate
from Products.ERP5Type.DateUtils import getRoundedMonthBetween, millis
from Products.ERP5Type.DateUtils import getAccountableYearFraction
from Products.ERP5.Document.Amount import Amount
from erp5.component.document.Item import Item
from Products.CMFCore.utils import getToolByName
from Products.ERP5.Document.ImmobilisationMovement import (
UNIMMOBILISING_METHOD, NO_CHANGE_METHOD, AMORTISATION_METHOD_PREFIX )
from Products.ERP5.Document.ImmobilisationMovement import (
IMMOBILISATION_NEEDED_PROPERTY_LIST,
IMMOBILISATION_UNCONTINUOUS_NEEDED_PROPERTY_LIST,
IMMOBILISATION_FACULTATIVE_PROPERTY_LIST )
from zLOG import LOG
NEGLIGEABLE_PRICE = 10e-8
from Products.ERP5Type.Errors import ImmobilisationValidityError
from Products.ERP5Type.Errors import ImmobilisationCalculationError
class ImmobilisableItem(Item, Amount):
"""
An Immobilisable Item is an Item which can be immobilised
and amortised in accounting
"""
meta_type = 'ERP5 ImmobilisableItem'
portal_type = 'Immobilisable Item'
add_permission = Permissions.AddPortalContent
# Declarative security
security = ClassSecurityInfo()
security.declareObjectProtected(Permissions.AccessContentsInformation)
# Declarative properties
property_sheets = ( PropertySheet.Base
, PropertySheet.XMLObject
, PropertySheet.CategoryCore
, PropertySheet.DublinCore
, PropertySheet.Price
, PropertySheet.Item
, PropertySheet.Amount
, PropertySheet.Reference
, PropertySheet.Amortisation
)
zope.interface.implements(IImmobilisationItem)
# IExpandableItem interface implementation
def getSimulationMovementSimulationState(self, simulation_movement):
"""Returns the simulation state for this simulation movement.
"""
portal = self.getPortalObject()
draft_state_list = portal.getPortalDraftOrderStateList()
# if we have an order which is not draft, we'll consider the generated
# simulation movement are planned.
# This is probably oversimplified implementation, as we may want to look
# deliveries / invoices.
for movement in self.getAggregateRelatedValueList(
portal_type=portal.getPortalOrderMovementTypeList(),):
if movement.getSimulationState() not in draft_state_list:
return 'planned'
return 'draft'
security.declareProtected(Permissions.AccessContentsInformation,
'getImmobilisationRelatedMovementList')
def getImmobilisationRelatedMovementList(self,
from_date = None,
to_date = None,
include_to_date = 0,
filter_valid = 1,
immobilisation_movement_list = None,
owner_movement_list = None,
**kw):
"""
Returns a dictionary of lists containing movements related to amortisation
system from_date is included, to_date is excluded filter_valid eliminates
all invalid immobilisation movements in immobilisation movement list.
Also, only movements in current_inventory state are returned
if filter_valid is set.
If filter_valid is set and some movements are in state 'calculating',
a ImmobilisationValidityError is launch.
Immobilisation_movement and owner_change specify which lists to return
immobilisation_movement_list is the list of movements to use instead of
looking in SQL. Warning : in the case of movement_list is provided,
no filter is applied on it (unless looking at each movement validity) and
movement_list is supposed to be well sorted.
The search is based on catalog so you can use related keys
"""
catalog = self.portal_catalog
immo_list = []
if immobilisation_movement_list is None:
# First build the SQL query
sql_dict = self._getCleanSqlDict(**kw)
sql_dict['aggregate_uid'] = self.getUid()
if filter_valid:
sql_dict['immobilisation_state'] = ['calculating','valid']
sql_dict['simulation_state'] = self.getPortalCurrentInventoryStateList()
portal_type = sql_dict.get('portal_type',None)
if portal_type is None:
portal_type = self.getPortalDeliveryMovementTypeList() + \
('Immobilisation Line', 'Immobilisation Cell')
sql_dict['portal_type'] = portal_type
sql_dict['sort_on'] = [('movement.stop_date','ascending')]
# Handle dates
date_key = 'movement.stop_date'
date_range = ''
date_query = []
if from_date is not None:
date_query.append(DateTime(from_date))
date_range += 'min'
if to_date is not None:
date_query.append(DateTime(to_date))
if include_to_date:
date_range += 'ngt'
else:
date_range += 'max'
if len(date_query) != 0:
sql_dict[date_key] = { 'range':date_range, 'query':date_query}
# Then execute the query
immobilisation_movement_list = catalog(**sql_dict)
if kw.get('src__', 0) == 1:
return immobilisation_movement_list
# Then build immobilisation list
for movement in immobilisation_movement_list:
movement = movement.getObject()
if movement.getStopDate() is not None:
# Test immobilisation movement
if filter_valid and movement.getImmobilisationState() in ('invalid',
'calculating',):
raise ImmobilisationValidityError, \
'%s : some preceding movements are still in calculating state' % self.getRelativeUrl()
immo_list.append(movement)
return immo_list
def _ownerChange(self, first_section, second_section):
"""
Tests if section 1 and section 2 are the same owner or not
It is done by looking at the mapped organisations
If a mapped organisation exists, and the social capital currency is not None,
it is considered as an independant organisation
"""
if first_section == second_section:
return 0
first_section = self._getFirstIndependantOrganisation(first_section)
second_section = self._getFirstIndependantOrganisation(second_section)
if first_section is None:
if second_section is None:
return 0
else:
return 1
elif second_section is None:
return 1
else:
if first_section == second_section:
return 0
return 1
def _getFirstIndependantOrganisation(self, section):
"""
Returns the first found independant organisation, looking at
the group tree upward. An independant organisation is found when the
category has a mapping related value, and this value has a social capital currency
"""
if section in (None, ""):
return None
if section.getPortalType() not in ("Category","Base Category"):
if hasattr(section, 'getMappingValue'):
category = section.getMappingValue()
organisation = section
else:
category = None
organisation = section
else:
category = section
try:
organisation = category.getMappingRelatedValueList(strict_membership = 1)[0]
except IndexError:
organisation = section
if organisation is None or \
(not hasattr(organisation, 'getPriceCurrencyValue')) or \
(not hasattr(organisation, 'getFinancialYearStopDate')) or \
organisation.getPriceCurrencyValue() is None or \
organisation.getFinancialYearStopDate() is None:
if category is None: return None
if category.getPortalType() != "Base Category":
return self._getFirstIndependantOrganisation(category.getParentValue())
else:
return None
return organisation
security.declareProtected(Permissions.AccessContentsInformation,
'getImmobilisationMovementValueList')
def getImmobilisationMovementValueList(self,
from_date=None,
to_date=None,
filter_valid=1,
**kw):
"""
Returns a list of immobilisation movements applied to current item from
date to date
Argument filter_valid allows to select only the valid immobilisation movements
"""
return self.getImmobilisationRelatedMovementList(from_date=from_date,
to_date=to_date,
filter_valid=filter_valid,
**kw)
security.declareProtected(Permissions.AccessContentsInformation,
'getUnfilteredImmobilisationMovementValueList')
def getUnfilteredImmobilisationMovementValueList(self, from_date=None, to_date=None, **kw):
"""
Returns a list of immobilisation applied to the current item from date to date
All of the movements are returned, not even those which are valid
"""
return self.getImmobilisationMovementValueList(from_date=from_date,
to_date=to_date,
filter_valid=0, **kw)
security.declareProtected(Permissions.AccessContentsInformation,
'getPastImmobilisationMovementValueList')
def getPastImmobilisationMovementValueList(self, from_date=None, at_date=None, **kw):
"""
Returns a list of immobilisation movements applied to current item
before the given date, or now
"""
if at_date is None: at_date = DateTime()
result = self.getImmobilisationMovementValueList(from_date=from_date,
to_date=at_date, **kw )
return result
security.declareProtected(Permissions.AccessContentsInformation,
'getFutureImmobilisationMovementValueList')
def getFutureImmobilisationMovementValueList(self, to_date=None, at_date=None, from_movement=None, **kw):
"""
Returns a list of immobilisation movements applied to current item
after the given date (excluded), or now.
If from_movement is set and the given movement is found, remove it from the list.
"""
if at_date is None: at_date = DateTime()
at_date = at_date + millis
result = self.getImmobilisationMovementValueList(from_date=at_date,
to_date=to_date, **kw)
if from_movement is not None and from_movement in result:
result.remove(from_movement)
return result
security.declareProtected(Permissions.AccessContentsInformation,
'getLastImmobilisationMovementValue')
def getLastImmobilisationMovementValue(self, at_date=None, **kw):
"""
Returns the last immobilisation movement before the given date, or now
"""
past_list = self.getPastImmobilisationMovementValueList(at_date=at_date, **kw)
if len(past_list) > 0:
return past_list[-1]
return None
security.declareProtected(Permissions.AccessContentsInformation,
'getNextImmobilisationMovementValue')
def getNextImmobilisationMovementValue(self, at_date=None, from_movement=None, **kw):
"""
Returns the first immobilisation movement after the given date, or now
If from_movement is set and the given movement is the next one, returns
the second next movement
"""
future_list = self.getFutureImmobilisationMovementValueList(
at_date=at_date,
from_movement=from_movement,
**kw)
if len(future_list) > 0:
return future_list[0]
return None
security.declareProtected(Permissions.AccessContentsInformation,
'getImmobilisationPeriodList')
def getImmobilisationPeriodList(self, from_date=None, to_date=None, **kw):
"""
Returns a list of dictionaries representing immobilisation periods for the object
from_date is included, to_date is excluded
"""
kw_key_list = kw.keys()
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':{},
'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])) :
return immo_cache_dict['period'][ (self.getRelativeUrl(), from_date, to_date) +
tuple( [(key,kw[key]) for key in kw_key_list]) ]
def setPreviousPeriodParameters(period_list,
current_period,
prefix = 'initial',
keys=()):
if len(period_list) > 0:
previous_period = period_list[-1]
if previous_period['stop_date'] == current_period['start_date']:
if len(keys) == 0:
for key in previous_period.keys():
if key.split('_')[0] == prefix:
current_period[key] = previous_period[key]
else:
for key in keys:
current_period[key] = previous_period[key]
"""
We need to separate immobilisation treatment from section_change
movements treatment.
An immobilisation is a movement which contains immobilisation data
and MAY change the section.
A section change movement DOES NOT contain immobilisation data
"""
immobilisation_list = self.getImmobilisationMovementValueList(from_date=from_date,
to_date=to_date,
**kw)
section_change_list = self.getSectionChangeList(from_date=from_date,
at_date=to_date,
**kw)
# Sanity check
section_movement_list = []
date_list = [movement.getStopDate() for movement in immobilisation_list]
for section_movement in [o['movement'] for o in section_change_list]:
if section_movement.getStopDate() in date_list and \
section_movement not in section_movement_list and \
section_movement not in immobilisation_list:
raise ImmobilisationCalculationError, \
"Some movements related to item %s have the same date" % self.getRelativeUrl()
elif section_movement.getStopDate() not in date_list and \
section_movement not in section_movement_list:
#The section movement is different from immobilisation movements
date_list.append(section_movement.getStopDate())
section_movement_list.append(section_movement)
else:
#It means the current section_movement is a movement in immobilisation_list
if section_movement.getAmortisationMethod() in ("", None, NO_CHANGE_METHOD):
section_movement_list.append(section_movement)
immobilisation_list.remove(section_movement)
"""
At this stade, section_movement_list contains the movements which only
change the owner.
Immobilisation_list contains movements with immobilisation data and which
may change the owner, but it may contain some movements which does not
change the owner but with a NO_CHANGE_METHOD.
Such movements must not be took into account, because they do not define
a new immobilisation period. So remove them.
"""
for immobilisation in immobilisation_list[:]:
if immobilisation.getAmortisationMethod() in ("", None, NO_CHANGE_METHOD):
immobilisation_list.remove(immobilisation)
immo_period_list = []
current_immo_period = {}
immo_cursor = 0
section_cursor = 0
while immo_cursor <= len(immobilisation_list) and\
section_cursor <= len(section_movement_list) and \
not (immo_cursor == len(immobilisation_list) and \
section_cursor == len(section_movement_list)):
immobilisation = None
section_movement = None
is_immo_movement = 0
if immo_cursor < len(immobilisation_list):
immobilisation = immobilisation_list[immo_cursor]
if section_cursor < len(section_movement_list):
section_movement = section_movement_list[section_cursor]
if (immobilisation is not None) and (section_movement is None or \
section_movement.getStopDate() > immobilisation.getStopDate()):
# immobilisation treatment
immo_cursor += 1
is_immo_movement = 1
movement = immobilisation
method = immobilisation.getAmortisationMethod()
open_new_period = 1
else:
# section_change treatment
section_cursor += 1
movement = section_movement
method = NO_CHANGE_METHOD
if len(immo_period_list)>0:
previous_period = immo_period_list[-1]
else:
previous_period = None
if current_immo_period not in ({},None) or (
previous_period is not None and
previous_period.get('stop_date', None) is not None and
previous_period['stop_date'] == section_movement.getStopDate()
):
open_new_period = 1
else:
open_new_period = 0
# First close the previous immobilisation period
if current_immo_period not in (None, {}):
current_immo_period['stop_durability'] = self.getRemainingDurability(
at_date=movement.getStopDate(),
immo_period_list=immo_period_list+[current_immo_period],
immo_cache_dict=immo_cache_dict)
current_immo_period['stop_duration'] = self.getRemainingAmortisationDuration(
at_date=movement.getStopDate(),
immo_period_list=immo_period_list+[current_immo_period],
immo_cache_dict=immo_cache_dict)
current_immo_period['stop_movement'] = movement
current_immo_period['stop_date'] = movement.getStopDate()
immo_period_list.append(current_immo_period)
current_immo_period = {}
current_immo_period = {}
# Then open the new one
if open_new_period and method != UNIMMOBILISING_METHOD:
# First check if there is a valid owner in this period
section = self.getSectionValue(at_date=movement.getStopDate(),
include_to_date=1)
if (section is not None) and \
(section.getPriceCurrencyValue() is not None) and \
(section.getFinancialYearStopDate() is not None):
# Fill data about this period
if is_immo_movement:
previous_period_method = None
current_immo_period['continuous_movement'] = movement.getAmortisationMethodParameterForItem(self,"continuous")['continuous']
"""
The current movement is an immobilisation movement.
We fill each 'start' and 'initial' property by looking at the movement
properties
"""
property_list = IMMOBILISATION_NEEDED_PROPERTY_LIST + \
IMMOBILISATION_UNCONTINUOUS_NEEDED_PROPERTY_LIST + \
IMMOBILISATION_FACULTATIVE_PROPERTY_LIST
property_list.extend(movement.getNeededSpecificParameterListForItem(self))
property_list.extend(movement.getUncontinuousNeededSpecificParameterListForItem(self))
property_list.extend(movement.getFacultativeSpecificParameterListForItem(self))
for key,value,_ in property_list:
value = 'get' + ''.join(map(capitalize, value.split('_')))
value = getattr(movement, value, None)
if value is not None:
value = value()
current_immo_period['start_' + key] = value
current_immo_period['initial_' + key] = value
else:
"""
The current movement is a section change movement.
We get 'start' properties from previous period, and set some other
'start' properties by calculation
"""
current_immo_period['start_date'] = movement.getStopDate()
setPreviousPeriodParameters(immo_period_list,
current_immo_period,
prefix='start')
current_immo_period['start_date'] = movement.getStopDate()
setPreviousPeriodParameters(immo_period_list,
current_immo_period,
keys=['continuous_movement'])
current_immo_period['start_vat'] = 0
current_immo_period['start_extra_cost_price'] = 0
current_immo_period['start_main_price'] = self.getAmortisationPrice(
at_date=movement.getStopDate(),
immo_cache_dict=immo_cache_dict)
current_immo_period['start_duration'] = self.getRemainingAmortisationDuration(
at_date=movement.getStopDate(),
immo_cache_dict=immo_cache_dict)
current_immo_period['start_durability'] = self.getRemainingDurability(
at_date=movement.getStopDate(),
immo_cache_dict=immo_cache_dict)
method = current_immo_period.get('start_method', "")
# For both types of movement, set some properties
extra_cost_price = current_immo_period.get('start_extra_cost_price')
main_price = current_immo_period.get('start_main_price')
current_immo_period['start_extra_cost_price'] = extra_cost_price or 0.
current_immo_period['start_movement'] = movement
current_immo_period['initial_movement'] = movement
current_immo_period['start_price'] = (main_price or 0.) + (extra_cost_price or 0.)
current_immo_period['initial_price'] = current_immo_period['start_price']
current_immo_period['owner'] = section
"""
Determine if this period continues a previous one.
There are two concepts of 'continuing' :
- "continuous" means the current period is continuing the previous
immobilisation
- "adjacent" means the current period will use previous period
data but starts a new immobilisation
"""
continuous = 0
adjacent = 0
if len(immo_period_list)>0:
previous_period_method = immo_period_list[-1]["initial_method"]
adjacent = \
current_immo_period['continuous_movement'] and \
(previous_period_method is not None) and (\
previous_period_method==method or \
method in ("", NO_CHANGE_METHOD) \
) and \
immo_period_list[-1]['stop_date'] == movement.getStopDate()
"""
We must check if the current owner is in the same group as
the previous one, in order to know if this period is completely
new or not
"""
previous_section = self.getSectionValue(at_date = movement.getStopDate())
continuous = adjacent and not (
previous_section is None or \
previous_section.getGroup() is None or \
section.getGroup() is None or \
previous_section.getGroup() != section.getGroup()
)
current_immo_period['continuous'] = continuous
current_immo_period['adjacent'] = adjacent
if continuous:
# A continuous period gets 'initial' data from previous period.
setPreviousPeriodParameters(immo_period_list, current_immo_period)
elif adjacent:
"""
An adjacent period calculates some start values then copies them to
initial values.
These values overload 'initial' values acquired from previous period
"""
setPreviousPeriodParameters(immo_period_list, current_immo_period)
if is_immo_movement:
#Calculation of start values is already done above for section change movements
current_immo_period['start_vat'] = 0
current_immo_period['start_extra_cost_price'] = 0
current_immo_period['start_main_price'] = self.getAmortisationPrice(
at_date=movement.getStopDate(),
immo_cache_dict=immo_cache_dict)
current_immo_period['start_duration'] = self.getRemainingAmortisationDuration(
at_date=movement.getStopDate(),
immo_cache_dict=immo_cache_dict)
current_immo_period['start_durability'] = self.getRemainingDurability(
at_date=movement.getStopDate(),
immo_cache_dict=immo_cache_dict)
extra_cost_price = current_immo_period.get('start_extra_cost_price')
main_price = current_immo_period.get('start_main_price')
current_immo_period['start_price'] = (main_price or 0.) + (extra_cost_price or 0.)
key_list = current_immo_period.keys()
for key in key_list:
value = current_immo_period[key]
if key.find('_') != -1:
if key.split('_')[0] == 'start' and value not in (None, '', NO_CHANGE_METHOD):
current_immo_period['initial_%s' % '_'.join(key.split('_')[1:])] = value
else:
# A period wich is alone only copies start values to initial ones
# So it may be invalid later
key_list = current_immo_period.keys()
for key in key_list:
value = current_immo_period[key]
if key.find('_') != -1:
if key.split('_')[0] == 'start' and value is not None:
current_immo_period['initial_%s' % '_'.join(key.split('_')[1:])] = value
# Finally check if this period is valid. If the method is still NO_CHANGE_METHOD,
# it means there is an inconsistency, because there is no previous immobilisation period
needed_property_list = IMMOBILISATION_NEEDED_PROPERTY_LIST + \
IMMOBILISATION_UNCONTINUOUS_NEEDED_PROPERTY_LIST + \
movement.getNeededSpecificParameterListForItem(self) + \
movement.getUncontinuousNeededSpecificParameterListForItem(self)
for key, value, _ in needed_property_list:
if current_immo_period.get('initial_%s' % key) in (None, '', NO_CHANGE_METHOD):
current_immo_period = {}
if current_immo_period not in (None, {}):
immo_period_list.append(current_immo_period)
# Round dates since immobilisation calculation is made on days
for immo_period in immo_period_list:
for property_ in ('start_date', 'stop_date', 'initial_date',):
if immo_period.has_key(property_):
immo_period[property_] = roundDate(immo_period[property_])
immo_cache_dict['period'][ (self.getRelativeUrl(), from_date, to_date) +
tuple([(key,kw[key]) for key in kw_key_list]) ] = immo_period_list
return immo_period_list
security.declareProtected(Permissions.AccessContentsInformation,
'getLastImmobilisationPeriod')
def getLastImmobilisationPeriod(self, to_date=None, **kw):
"""
Returns the current immobilisation period, or the last one if the
item is not currently immobilised, at the given at_date (excluded)
"""
period_list = self.getImmobilisationPeriodList(from_date=None,
to_date=to_date, **kw)
if len(period_list) == 0:
return None
return period_list[-1]
security.declareProtected(Permissions.AccessContentsInformation,
'isCurrentlyImmobilised')
def isCurrentlyImmobilised(self, **kw):
""" Returns true if the item is immobilised at this time """
return self.isImmobilised(at_date = DateTime(), **kw)
security.declareProtected(Permissions.AccessContentsInformation,
'isNotCurrentlyImmobilised')
def isNotCurrentlyImmobilised(self, **kw):
""" Returns true if the item is not immobilised at this time """
return not self.isCurrentlyImmobilised(**kw)
security.declareProtected(Permissions.AccessContentsInformation,
'isImmobilised')
def isImmobilised(self, at_date=None, **kw):
"""
Returns true if the item is immobilised at the given date.
If at_date = None, returns true if the item has ever been immobilised.
"""
immo_period_list = self.getImmobilisationPeriodList(to_date=at_date, **kw)
if len(immo_period_list) == 0:
return 0
elif len(immo_period_list) > 0 and at_date is None:
return 1
immo_period = immo_period_list[-1]
if immo_period.has_key('stop_date'):
# It means the latest period is terminated before the current date
return 0
return 1
security.declareProtected(Permissions.AccessContentsInformation,
'getCurrentRemainingAmortisationDuration')
def getCurrentRemainingAmortisationDuration(self, **kw):
""" Returns the calculated remaining amortisation duration for this item
at the current time.
"""
return self.getRemainingAmortisationDuration(at_date=DateTime(), **kw)
security.declareProtected(Permissions.AccessContentsInformation,
'getRemainingAmortisationDuration')
def getRemainingAmortisationDuration(self, at_date=None, immo_period_list=None, **kw):
"""
Returns the calculated remaining amortisation duration for the item.
It is based on the latest immobilisation period at given date, or now.
"""
if at_date is None:
at_date = DateTime()
new_kw = dict(kw)
if new_kw.has_key('to_date'):
del new_kw['to_date']
if new_kw.has_key('at_date'):
del new_kw['at_date']
if immo_period_list is None:
immo_period_list = self.getImmobilisationPeriodList(to_date=at_date, **new_kw)
if len(immo_period_list) > 0:
immo_period = immo_period_list[-1]
initial_date = immo_period['initial_date']
initial_duration = immo_period.get('initial_duration',0)
stop_date = immo_period.get('stop_date', at_date)
consumpted_duration = getRoundedMonthBetween(initial_date, stop_date, True)
remaining_duration = initial_duration - consumpted_duration
if remaining_duration < 0:
remaining_duration = 0
return int(remaining_duration)
return None
security.declareProtected(Permissions.AccessContentsInformation,
'getRemainingDurability')
def getRemainingDurability(self, at_date=None, immo_period_list=None, **kw):
"""
Returns the durability of the item at the given date, or now.
The durability is quantity of something which corresponds to the 'life' of the item
(ex : km for a car, or time for anything)
Each Immobilisation Movement stores the durability at a given time,
so it is possible to approximate the durability between two Immobilisation
Movements by using a simple
linear calculation.
Note that durability has no sense for items which are immobilisated but not
amortised (like grounds, etc...). Calculation is based on duration, so an item
immobilised without amortisation duration will not decrease its durability.
"""
if at_date is None:
at_date = DateTime()
new_kw = dict(kw)
if new_kw.has_key('to_date'):
del new_kw['to_date']
if new_kw.has_key('at_date'):
del new_kw['at_date']
if immo_period_list is None:
immo_period_list = self.getImmobilisationPeriodList(to_date=at_date, **new_kw)
# First case : no data about immobilisation
if len(immo_period_list) == 0:
return None
immo_period = immo_period_list[-1]
# Second case : the item is not currently immobilised
if immo_period.has_key('stop_date'):
return immo_period['stop_durability']
# Third case : the item is currently immobilised
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':{},
'currency': {}})
start_durability = self.getRemainingDurability(at_date=start_date,
immo_cache_dict=immo_cache_dict)
if start_durability is None:
return None
stop_date = None
stop_durability = None
next_movement = self.getNextImmobilisationMovementValue(at_date=at_date, **kw)
while stop_durability is None and next_movement is not None:
stop_date = next_movement.getStopDate()
stop_durability = next_movement.getDurability()
next_movement = self.getNextImmobilisationMovementValue(
at_date=stop_date,
from_movement=next_movement,
**kw)
if stop_durability is None:
# In this case, we take the end of life of the item and use
# it like an immobilisation movement with values set to 0
initial_date = immo_period['initial_date']
initial_duration = immo_period['initial_duration']
stop_date = addToDate(initial_date, month=initial_duration)
stop_durability = 0
consumpted_durability = start_durability - stop_durability
consumpted_time = getRoundedMonthBetween(start_date, stop_date, True)
current_consumpted_time = getRoundedMonthBetween(start_date, at_date, True)
if consumpted_time <= 0 or current_consumpted_time <= 0:
return start_durability
else:
return start_durability - consumpted_durability * current_consumpted_time / consumpted_time
security.declareProtected(Permissions.AccessContentsInformation,
'getCurrentRemainingDurability')
def getCurrentRemainingDurability(self, **kw):
"""
Returns the remaining durability at the current date
"""
return self.getRemainingDurability(at_date=DateTime(), **kw)
security.declareProtected(Permissions.AccessContentsInformation,
'getAmortisationPrice')
def getAmortisationPrice(self, at_date=None, with_currency=0, **kw):
"""
Returns the deprecated value of item at given date, or now.
If with_currency is set, returns a string containing the value and the
corresponding currency.
"""
if at_date is None:
at_date = DateTime()
kw_key_list = kw.keys()
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':{},
'currency': {}})
kw['immo_cache_dict'] = immo_cache_dict
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
immo_period_list = self.getImmobilisationPeriodList(to_date=at_date, **kw)
if len(immo_period_list) == 0:
# Item has never been immobilised. We cannot get its price
if with_currency:
return "N/A"
return None
# Get data from the last immo period
immo_period = immo_period_list[-1]
initial_movement = immo_period['initial_movement']
start_date = immo_period['start_date']
disposal_price = immo_period['initial_disposal_price']
period_start_date = immo_period['initial_date']
period_start_price = immo_period['initial_price']
period_start_duration = immo_period['initial_duration']
start_price = immo_period['start_price']
start_duration = immo_period['start_duration']
start_durability = immo_period['start_durability']
owner = immo_period['owner']
# Calculate data if not found
if start_price is None:
start_price = self.getAmortisationPrice(at_date=start_date,
immo_cache_dict=immo_cache_dict)
if start_duration is None:
start_duration = self.getRemainingAmortisationDuration(at_date=start_date,
immo_cache_dict=immo_cache_dict)
if start_durability is None:
start_durability = self.getRemainingDurability(at_date=start_date,
immo_cache_dict=immo_cache_dict)
# Get the current period stop date, duration and durability
if immo_period.has_key('stop_date'):
stop_date = immo_period['stop_date']
period_stop_date = stop_date
else:
stop_date = at_date
next_movement = self.getNextImmobilisationMovementValue(at_date=at_date, **kw)
if next_movement is not None:
period_stop_date = next_movement.getStopDate()
else:
period_stop_date = addToDate(period_start_date, month=period_start_duration)
if at_date > period_stop_date:
return self.getAmortisationPrice(at_date=period_stop_date, **kw)
stop_duration = self.getRemainingAmortisationDuration(
at_date=period_stop_date,
immo_period_list=immo_period_list,
immo_cache_dict=immo_cache_dict)
stop_durability = self.getRemainingDurability(at_date=period_stop_date,
immo_period_list=immo_period_list,
immo_cache_dict=immo_cache_dict)
section = owner
currency = owner.getPriceCurrency()
depreciable_price = period_start_price - disposal_price
financial_date = section.getFinancialYearStopDate()
amortisation_method = AMORTISATION_METHOD_PREFIX + immo_period['initial_method']
# Get the amortisation method parameters
amortisation_parameters = initial_movement.getAmortisationMethodParameterForItem(
item=self, parameter_list = [
"cut_annuities", "price_calculation_basis",
"round_duration", "date_precision", "with_amortisation"])
cut_annuities = amortisation_parameters["cut_annuities"]
price_calculation_basis = amortisation_parameters["price_calculation_basis"]
round_duration = amortisation_parameters["round_duration"]
date_precision = amortisation_parameters["date_precision"]
with_amortisation = amortisation_parameters["with_amortisation"]
# Return the price if no amortisation is needed
if not with_amortisation:
return period_start_price
### Adjust some values according to the parameters
# Adapt period bound dates according to date_precision
period_start_date = getClosestDate(date=financial_date,
target_date=period_start_date,
precision=date_precision, before=1, strict=0)
period_stop_date = getClosestDate(date=financial_date,
target_date=period_stop_date,
precision=date_precision, before=0, strict=0)
# Calculate remaining annuities at bound dates
local_stop_date = addToDate(period_start_date, month = period_start_duration)
initial_remaining_annuities = getAccountableYearFraction(
from_date=period_start_date,
to_date=local_stop_date)
start_remaining_annuities = getAccountableYearFraction(from_date=start_date,
to_date=local_stop_date)
local_stop_date = addToDate(period_stop_date, month=stop_duration)
stop_remaining_annuities = getAccountableYearFraction(from_date=period_stop_date,
to_date=local_stop_date)
# Round annuities if needed
if round_duration == "greater annuity":
if start_remaining_annuities != int(start_remaining_annuities):
start_remaining_annuities = int(start_remaining_annuities) + 1
else:
start_remaining_annuities = int(start_remaining_annuities)
elif round_duration == "lower annuity":
start_remaining_annuities = int(start_remaining_annuities)
if cut_annuities:
current_date = getClosestDate(date=financial_date,
target_date=period_start_date,
precision='year',
before=0)
else:
current_date = period_start_date
annuity_number = -1
if period_start_date - current_date < 0:
annuity_number += 1
while current_date - at_date < 0:
annuity_number += 1
current_date = addToDate(current_date, year=1)
if annuity_number < 0:
return depreciable_price + disposal_price
annuity_start_date = addToDate(current_date, year=-1)
annuity_stop_date = current_date
truncated_annuity_stop_date = annuity_stop_date
truncated_annuity_start_date = annuity_start_date
# Adjust dates if it is a bound annuity
if period_stop_date < annuity_stop_date:
truncated_annuity_stop_date = period_stop_date
if truncated_annuity_stop_date > at_date:
truncated_annuity_stop_date = at_date
if period_start_date > annuity_start_date:
truncated_annuity_start_date = period_start_date
# Get the current ratio
checked_remaining_annuities = initial_remaining_annuities
if int(checked_remaining_annuities) != checked_remaining_annuities:
checked_remaining_annuities += 1
if annuity_number+1 > checked_remaining_annuities:
current_ratio = 0
else:
ratio_params = dict(immo_period)
ratio_params.update(
{'initial_remaining_annuities': initial_remaining_annuities,
'start_remaining_annuities': start_remaining_annuities,
'stop_remaining_annuities': stop_remaining_annuities,
'current_annuity': annuity_number,
'start_remaining_durability': start_durability,
'stop_remaining_durability': stop_durability,
#'annuity_start_date': annuity_start_date,
})
try:
ratio_script = self.unrestrictedTraverse(amortisation_method).ratioCalculation
except KeyError:
LOG('ERP5 Warning :', 0,
'Unable to find the ratio calculation script %s for item %s at date %s' % (
'%s/ratioCalculation' % amortisation_method, self.getRelativeUrl(), repr(at_date)))
raise ImmobilisationCalculationError, \
'Unable to find the ratio calculation script %s for item %s at date %s' % (
'%s/ratioCalculation' % amortisation_method, self.getRelativeUrl(), repr(at_date))
current_ratio = ratio_script(**ratio_params)
if current_ratio is None:
LOG("ERP5 Warning :",0,
"Unable to calculate the ratio during the amortisation calculation on item %s at date %s : script %s returned None" % (
self.getRelativeUrl(), repr(at_date), '%s/ratioCalculation' % amortisation_method))
raise ImmobilisationCalculationError, \
"Unable to calculate the ratio during the amortisation calculation on item %s at date %s" % (
repr(self), repr(at_date))
# Calculate the value at the beginning of the annuity
annuity_start_price = depreciable_price
local_period_start_price = annuity_start_price
if annuity_number:
if price_calculation_basis == "period recalculated start price":
local_period_start_date = start_date
local_period_start_price = self.getAmortisationPrice(
at_date=local_period_start_date,
immo_cache_dict=immo_cache_dict)
if local_period_start_price is None:
# It means no immobilisation period exists before ; we use real start date
local_period_start_price = start_price
if local_period_start_date > annuity_start_date:
annuity_start_price = local_period_start_price
else:
annuity_start_price = self.getAmortisationPrice(
at_date=annuity_start_date,
immo_cache_dict=immo_cache_dict) - disposal_price
else:
annuity_start_price = self.getAmortisationPrice(
at_date=annuity_start_date,
immo_cache_dict=immo_cache_dict) - disposal_price
# Calculate the raw annuity value
if price_calculation_basis == "start price":
raw_annuity_price = depreciable_price * current_ratio
elif price_calculation_basis == "annuity start price":
raw_annuity_price = annuity_start_price * current_ratio
elif price_calculation_basis == "period recalculated start price":
raw_annuity_price = local_period_start_price * current_ratio
# Apply the prorata temporis on the raw annuity value
if annuity_number and \
price_calculation_basis == 'period recalculated start price' and \
truncated_annuity_start_date < local_period_start_date:
truncated_annuity_start_date = local_period_start_date
if truncated_annuity_start_date <= annuity_start_date and \
truncated_annuity_stop_date >= annuity_stop_date:
annuity_value = raw_annuity_price
else:
local_stop_date = truncated_annuity_stop_date
if local_stop_date > at_date:
local_stop_date = at_date
annuity_value = raw_annuity_price * getAccountableYearFraction(
from_date=truncated_annuity_start_date,
to_date=local_stop_date)
if annuity_value < NEGLIGEABLE_PRICE:
annuity_value = 0
# Deduct the price at the given date
returned_price = annuity_start_price - annuity_value
if returned_price < NEGLIGEABLE_PRICE:
returned_price = 0
if returned_price is None:
return None
returned_price += disposal_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
security.declareProtected(Permissions.AccessContentsInformation,
'getCurrentAmortisationPrice')
def getCurrentAmortisationPrice(self, with_currency=0, **kw):
""" Returns the deprecated value of item at current time """
return self.getAmortisationPrice(at_date=DateTime(),
with_currency=with_currency, **kw)
def _createAmortisationRule(self):
"""
Build or update the amortisation rule related to this item, then expand the rule
SHOULD BE RUN AS MANAGER
"""
applied_rule_list = self.getCausalityRelatedValueList(portal_type='Applied Rule')
my_applied_rule_list = []
for applied_rule in applied_rule_list:
specialise_value = applied_rule.getSpecialiseValue()
if specialise_value is not None and\
specialise_value.getPortalType() == "Amortisation Rule":
my_applied_rule_list.append(applied_rule)
if len(my_applied_rule_list) == 0:
# Create a new applied order rule (portal_rules.order_rule)
portal_rules = getToolByName(self, 'portal_rules')
portal_simulation = getToolByName(self, 'portal_simulation')
my_applied_rule = portal_rules.default_amortisation_rule.constructNewAppliedRule(portal_simulation)
# Set causality
my_applied_rule.setCausalityValue(self)
my_applied_rule.reindexObject(activate_kw={'tag':'expand_amortisation'})
elif len(my_applied_rule_list) == 1:
# Re expand the rule if possible
my_applied_rule = my_applied_rule_list[0]
else:
# Delete first rules and re expand if possible
for my_applied_rule in my_applied_rule_list[:-1]:
my_applied_rule.getParentValue()._delObject(my_applied_rule.getId())
my_applied_rule = my_applied_rule_list[-1]
# We are now certain we have a single applied rule
# It is time to expand it
my_applied_rule.expand('immediate') # XXX: can it be done by activity ?
security.declareProtected(Permissions.AccessContentsInformation,
'expandAmortisation')
def expandAmortisation(self,**kw):
"""
Calculate the amortisation annuities for the item
in an activity
SHOULD BE RUN AS MANAGER
"""
# An item can be expanded for amortisation only when related deliveries
# are no more in 'calculating' immobilisation_state
related_packing_list_list = self.getAggregateRelatedValueList()
for related_packing_list in related_packing_list_list:
# XXX: Tagged reindexation added to replace after_path_and_method_id. May be unnecessary.
related_packing_list.recursiveReindexObject(
# Recycle a tag we must wait on anyway.
# XXX: it would be better to have per-item tags...
activate_kw={'tag': 'expand_amortisation'},
)
self.activate(
after_path_and_method_id=(
[x.getPath() for x in related_packing_list_list],
('updateImmobilisationState', ),
),
after_tag='expand_amortisation'
).immediateExpandAmortisation()
security.declareProtected(Permissions.AccessContentsInformation,
'immediateExpandAmortisation')
def immediateExpandAmortisation(self):
"""
Calculate the amortisation annuities for the item
SHOULD BE RUN AS MANAGER
"""
activate_kw = {'tag' : 'expand_amortisation'}
try:
self._createAmortisationRule()
except ImmobilisationValidityError:
delivery_list = self.getAggregateRelatedValueList()
for delivery in delivery_list:
if getattr(delivery, 'updateImmobilisationState', None) is not None:
delivery.updateImmobilisationState()
self.activate().expandAmortisation(activate_kw=activate_kw)
security.declareProtected(Permissions.AccessContentsInformation, 'getSectionMovementValueList')
def getSectionMovementValueList(self, include_to_date=0, **kw):
"""
Return the list of successive movements affecting
owners of the item. If at_date is None, return the result all the time
Only the movements in current_inventory_state are taken into account
"""
# Get tracking list
sql_kw = self._getCleanSqlDict(**kw)
sql_kw['item'] = self.getRelativeUrl()
sql_kw['sort_on'] = [('item.date','ascending')]
change_list = self.portal_simulation.getCurrentTrackingHistoryList(**sql_kw)
to_date = kw.get('to_date')
# Collect data
movement_list = []
for change in change_list:
date = change['date']
movement_uid = change['delivery_uid']
if (date is not None) and \
movement_uid is not None:
movement = self.portal_catalog.getObject(movement_uid)
movement_list.append(movement)
if include_to_date:
sql_kw['to_date'] = None
sql_kw['at_date'] = to_date
last_movement = self.portal_simulation.getCurrentTrackingList(**sql_kw)
if len(last_movement) > 0:
movement_uid = last_movement[-1]['delivery_uid']
if movement_uid is not None:
movement = self.portal_catalog.getObject(movement_uid)
if len(movement_list) == 0 or movement_list[-1] != movement:
movement_list.append(movement)
return movement_list
security.declareProtected(Permissions.AccessContentsInformation, 'getSectionChangeList')
def getSectionChangeList(self, at_date=None, **kw):
"""
Return the list of successive owners of the item with
the corresponding ownership change dates
If at_date is None, return the result all the time
"""
new_kw = self._getCleanSqlDict(**kw)
new_kw['to_date'] = at_date
movement_list = self.getSectionMovementValueList(**new_kw)
# Find ownership changes
from_date = new_kw.get('from_date')
if from_date is None:
previous_section = None
else:
previous_section = self.getSectionValue(at_date=from_date)
owner_change_list = []
for movement in movement_list:
new_section = movement.getDestinationSectionValue()
if self._ownerChange(previous_section, new_section):
# This movement is a ownership change movement
owner_change_list.append(movement)
previous_section = new_section
owner_list = []
for movement in owner_change_list:
owner = movement.getDestinationSectionValue()
owner = self._getFirstIndependantOrganisation(owner)
owner_list.append( {'owner' : owner,
'date' : movement.getStopDate(),
'movement' : movement } )
return owner_list
security.declareProtected(Permissions.AccessContentsInformation, 'getSectionValue')
def getSectionValue(self, at_date=None, **kw):
"""
Return the owner of the item at the given date
If at_date is None, return the last owner without time limit
"""
owner_list = self.getSectionChangeList(at_date=at_date, **kw)
if len(owner_list) > 0:
return owner_list[-1]['owner']
return None
security.declareProtected(Permissions.AccessContentsInformation, 'getCurrentSectionValue')
def getCurrentSectionValue(self, **kw):
"""
Return the current owner of the item
"""
return self.getSectionValue(at_date=DateTime(), **kw)
def _getCleanSqlDict(self, **kw):
no_key_list = ('immo_cache_dict',)
for key in no_key_list:
if key in kw:
del kw[key]
return kw
\ No newline at end of file
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Document Component" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_recorded_property_dict</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>default_reference</string> </key>
<value> <string>ImmobilisableItem</string> </value>
</item>
<item>
<key> <string>default_source_reference</string> </key>
<value> <string>Products.ERP5.Document.ImmobilisableItem</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>document.erp5.ImmobilisableItem</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Document Component</string> </value>
</item>
<item>
<key> <string>sid</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>text_content_error_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>text_content_warning_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>version</string> </key>
<value> <string>erp5</string> </value>
</item>
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary>
<item>
<key> <string>component_validation_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>validate</string> </value>
</item>
<item>
<key> <string>validation_state</string> </key>
<value> <string>validated</string> </value>
</item>
</dictionary>
</list>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
##############################################################################
#
# Copyright (c) 2002 Nexedi SARL and Contributors. All Rights Reserved.
# Guillaume Michon <guillaume.michon@e-asc.com>
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
from AccessControl import ClassSecurityInfo
from Products.ERP5Type import Permissions, PropertySheet
from Products.ERP5Type.XMLObject import XMLObject
class ImmobilisationDelivery(XMLObject):
"""
An Immobilisation Delivery is an object whose role is to
contain delivery movements which can immobilise items.
"""
meta_type = 'ERP5 Immobilisation Delivery'
portal_type = 'Immobilisation Delivery'
add_permission = Permissions.AddPortalContent
# Declarative security
security = ClassSecurityInfo()
security.declareObjectProtected(Permissions.AccessContentsInformation)
# Declarative properties
property_sheets = ( PropertySheet.Base
, PropertySheet.XMLObject
, PropertySheet.CategoryCore
, PropertySheet.DublinCore
, PropertySheet.Task
, PropertySheet.Arrow
, PropertySheet.Movement
, PropertySheet.Delivery
, PropertySheet.Reference
)
security.declareProtected(Permissions.AccessContentsInformation, 'updateImmobilisationState')
def updateImmobilisationState(self, **kw):
"""
This is often called as an activity, it will check if the
delivery is valid as an immobilisation movement, and if so
it will put the delivery in a valid state, if not valid in
an invalid state
"""
if self.getImmobilisationState() == 'calculating':
from erp5.component.document.ImmobilisableItem import ImmobilisationValidityError
try:
if self.isValidImmobilisationMovement(**kw):
self.validateImmobilisation()
else:
self.invalidateImmobilisation()
except ImmobilisationValidityError:
self.calculateImmobilisationValidity()
security.declareProtected(Permissions.AccessContentsInformation, 'getImmobilisationMovementList')
def getImmobilisationMovementList(self, **kw):
"""
Return regular movements + immobilisation movements like
Immobilisation Line and Immobilisation Cell
"""
return self.getMovementList(self.getPortalMovementTypeList() +
('Immobilisation Line', 'Immobilisation Cell'), **kw)
security.declareProtected(Permissions.AccessContentsInformation, 'checkImmobilisationConsistency')
def checkImmobilisationConsistency(self, *args, **kw):
"""
Check the consistency about immobilisation values
"""
return_list = []
for movement in self.getImmobilisationMovementList():
return_list.extend(movement.checkImmobilisationConsistency())
return return_list
security.declareProtected(Permissions.AccessContentsInformation, 'isValidImmobilisationMovement')
def isValidImmobilisationMovement(self, *args, **kw):
"""
Return true if all submovements are valid in terms of immobilisation
"""
error_list = self.checkImmobilisationConsistency(*args, **kw)
return len(error_list) == 0
security.declareProtected(Permissions.AccessContentsInformation, 'isInvalidImmobilisationMovement')
def isInvalidImmobilisationMovement(self, *args, **kw):
"""
Return false if all submovements are valid in terms of immobilisation
"""
return not self.isValidImmobilisationMovement(*args, **kw)
security.declareProtected(Permissions.AccessContentsInformation,
'getAggregatedItemsNextImmobilisationMovementValueList')
def getAggregatedItemsNextImmobilisationMovementValueList(self, **kw):
"""
Return the list of each next immobilisation movement for each aggregated item
"""
from erp5.component.interface.IImmobilisationItem import IImmobilisationItem
returned_list = []
sub_movement_list = self.contentValues()
for movement in self.getImmobilisationMovementList(**kw):
for item in movement.getAggregateValueList():
if IImmobilisationItem.providedBy(item):
future_movement_list = item.getFutureImmobilisationMovementValueList(
at_date = self.getStopDate(),
from_movement = self,
filter_valid = 0)
if future_movement_list is not None:
for next_movement in future_movement_list:
if next_movement is not None and \
next_movement not in sub_movement_list and \
next_movement not in returned_list and \
next_movement.getStopDate() != self.getStopDate():
returned_list.append(next_movement)
return returned_list
\ No newline at end of file
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Document Component" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>default_reference</string> </key>
<value> <string>ImmobilisationDelivery</string> </value>
</item>
<item>
<key> <string>default_source_reference</string> </key>
<value> <string>Products.ERP5.Document.ImmobilisationDelivery</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>document.erp5.ImmobilisationDelivery</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Document Component</string> </value>
</item>
<item>
<key> <string>sid</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>text_content_error_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>text_content_warning_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>version</string> </key>
<value> <string>erp5</string> </value>
</item>
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary>
<item>
<key> <string>component_validation_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>validate</string> </value>
</item>
<item>
<key> <string>validation_state</string> </key>
<value> <string>validated</string> </value>
</item>
</dictionary>
</list>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -2,6 +2,8 @@ document.erp5.AppliedRule
document.erp5.Delivery
document.erp5.DeliveryCell
document.erp5.DeliveryLine
document.erp5.ImmobilisationDelivery
document.erp5.ImmobilisableItem
document.erp5.Inventory
document.erp5.InventoryCell
document.erp5.InventoryLine
......
interface.erp5.IDivergenceController
interface.erp5.IExpandable
interface.erp5.IImmobilisationItem
interface.erp5.IMovementCollection
interface.erp5.IMovementCollectionDiff
interface.erp5.IMovementCollectionUpdater
......
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