Commit b6debe61 authored by Sebastien Robin's avatar Sebastien Robin

update made by Guillaume


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@1798 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent eb118709
This diff is collapsed.
...@@ -119,17 +119,17 @@ an accounting immobilisation (in order to amortise an object) ...@@ -119,17 +119,17 @@ an accounting immobilisation (in order to amortise an object)
} }
security.declareProtected(Permissions.View, 'getAmortisationOrDefaultAmortisationValue') security.declareProtected(Permissions.View, 'getAmortisationOrDefaultAmortisationPrice')
def getAmortisationOrDefaultAmortisationValue(self, with_currency=0, **kw): def getAmortisationOrDefaultAmortisationPrice(self, with_currency=0, **kw):
""" """
Returns the amortisation value. Returns the amortisation value.
If it is None, returns the default amortisation value. If it is None, returns the default amortisation value.
""" """
amortisation_value = self.getAmortisationValue() amortisation_price = self.getAmortisationBeginningPrice()
if amortisation_value is not None: if amortisation_price is not None:
return amortisation_value return amortisation_price
else: else:
return self.getDefaultAmortisationValue(with_currency=with_currency, **kw) return self.getDefaultAmortisationPrice(with_currency=with_currency, **kw)
security.declareProtected(Permissions.View, 'getAmortisationOrDefaultAmortisationDuration') security.declareProtected(Permissions.View, 'getAmortisationOrDefaultAmortisationDuration')
...@@ -159,15 +159,14 @@ an accounting immobilisation (in order to amortise an object) ...@@ -159,15 +159,14 @@ an accounting immobilisation (in order to amortise an object)
return item.getRemainingAmortisationDuration(current_date, from_immobilisation=1, **kw) return item.getRemainingAmortisationDuration(current_date, from_immobilisation=1, **kw)
security.declareProtected(Permissions.ModifyPortalContent, 'getDefaultAmortisationValue') security.declareProtected(Permissions.ModifyPortalContent, 'getDefaultAmortisationPrice')
def getDefaultAmortisationValue(self, with_currency=0, **kw): def getDefaultAmortisationPrice(self, with_currency=0, **kw):
""" """
Returns a calculated value of amortisation value Returns a calculated value of amortisation value
at the immobilisation movement date at the immobilisation movement date
""" """
item = self.getParent() item = self.getParent()
current_date = self.getStopDate() current_date = self.getStopDate()
LOG('Immobilisation :',0, 'current_date=%s, item=%s' % (repr(current_date), repr(item)))
if current_date is None or item is None: if current_date is None or item is None:
return None return None
...@@ -175,47 +174,40 @@ an accounting immobilisation (in order to amortise an object) ...@@ -175,47 +174,40 @@ an accounting immobilisation (in order to amortise an object)
return returned_value return returned_value
security.declarePrivate('_checkConsistency')
def _checkConsistency(self, fixit=0, mapped_value_property_list=()):
errors = []
relative_url = self.getRelativeUrl()
security.declareProtected(Permissions.View, 'isNotValid')
def isNotValid(self):
"""
Checks if necessary data is present on the immobilisation movement.
Returns an error message, or None if the immobilisation is valid
XXX please use checkConsistency API instead and try to use constraint
checkers for implementation
"""
item = self.getParent() item = self.getParent()
if item is None: if item is None:
return "The immobilisation movement does not apply on an item" errors += [(relative_url, "Property value inconsistency", 100, "The immobilisation movement does not apply on an item")]
immo_date = self.getStopDate() immo_date = self.getStopDate()
if immo_date is None: if immo_date is None:
return 'Date field is not filled' errors += [(relative_url, "Property value inconsistency", 100, 'Date property is empty')]
if self.getImmobilisation(): if self.getImmobilisation():
immo_duration = self.getAmortisationDuration() immo_duration = self.getAmortisationDuration()
if immo_duration is None: if immo_duration is None:
return 'Duration field is not filled' errors += [(relative_url, "Property value inconsistency", 100, 'Amortisation duration property is empty')]
immo_value = self.getAmortisationValue() immo_value = self.getAmortisationBeginningPrice()
if immo_value is None: if immo_value is None:
return 'Value field is not filled' errors += [(relative_url, "Property value inconsistency", 100, 'Amortisation price property is empty')]
immo_type = self.getAmortisationType() immo_type = self.getAmortisationType()
if immo_type is None or immo_type is "": if immo_type is None or immo_type is "":
return "Amortisation field is not filled" errors += [(relative_url, "Property value inconsistency", 100, 'Amortisation type property is empty')]
if immo_type == "degressive": if immo_type == "degressive":
fiscal_coef = self.getFiscalCoefficient() fiscal_coef = self.getFiscalCoefficient()
if fiscal_coef is None: if fiscal_coef is None:
return "Fiscal coefficient field is not filled" errors += [(relative_url, "Property value inconsistency", 100, 'Fiscal coefficient property is empty')]
vat = self.getVat() vat = self.getVat()
if vat is None: if vat is None:
return "VAT Amount field is not filled" errors += [(relative_url, "Property value inconsistency", 100, 'VAT Amount property is empty')]
for (account, text) in ( (self.getInputAccount() , "Input Account"), for (account, text) in ( (self.getInputAccount() , "Input Account"),
(self.getOutputAccount() , "Output Account"), (self.getOutputAccount() , "Output Account"),
...@@ -224,72 +216,58 @@ an accounting immobilisation (in order to amortise an object) ...@@ -224,72 +216,58 @@ an accounting immobilisation (in order to amortise an object)
(self.getDepreciationAccount() , "Deprecisation Account"), (self.getDepreciationAccount() , "Deprecisation Account"),
(self.getVatAccount() , "VAT Account") ): (self.getVatAccount() , "VAT Account") ):
if account is None or account is "": if account is None or account is "":
return text + " list has no selected choice" errors += [(relative_url, "Property value inconsistency", 100, text + ' property is empty')]
organisation = self.getOrganisation()
if organisation is None:
return "Item %s does not belong to an organisation at this date" % item.getTitle()
financial_date = organisation.getFinancialYearEndDate() section = self.getSectionValue()
if section is None:
errors += [(relative_url, "Property value inconsistency", 100, "The corresponding item does not belong to an organisation at this date")]
else:
financial_date = section.getFinancialYearStopDate()
if financial_date is None: if financial_date is None:
return "The organisation which owns the item at this date has no financial year end date" errors += [(relative_url, "Property value inconsistency", 100, "The organisation which owns the item at this date has no financial year end date")]
currency = self.getCurrency() currency = self.getPriceCurrency()
if currency is None: if currency is None:
return "The organisation which owns the item at this date has no amortisation currency" errors += [(relative_url, "Property value inconsistency", 100, "The organisation which owns the item at this date has no amortisation currency")]
return None return errors
security.declareProtected(Permissions.View, 'getOrganisation') security.declareProtected(Permissions.View, 'getSectionValue')
def getOrganisation(self): def getSectionValue(self):
""" """
Returns the organisation which owns the item on which the Returns the organisation which owns the item on which the
immobilisation movement applies, at the time of the immobilisation immobilisation movement applies, at the time of the immobilisation
movement movement
XXX Naming problem -> it is an owner
Please rename to getSectionValue on both item and immobilisation
""" """
# if self.isContext() and hasattr(self, 'organisation'):
# return self.organisation
item = self.getParent() item = self.getParent()
date = self.getStopDate() date = self.getStopDate()
if item is None or date is None: if item is None or date is None:
return None return None
LOG('Immobilisation :', 0, 'item = %s for immobilisation %s' % (repr(item), repr(self))) return item.getSectionValue(at_date = date)
return item.getOwner(at_date = date)
security.declareProtected(Permissions.View, 'getOrganisationTitle') security.declareProtected(Permissions.View, 'getSectionTitle')
def getOrganisationTitle(self): def getSectionTitle(self):
""" """
Returns the name of the organisation which owns the Returns the name of the organisation which owns the
item on which the immobilisation movement applies, at the item on which the immobilisation movement applies, at the
time of the immobilisation movement time of the immobilisation movement
XXX id. same naming problem getSectionTitle
""" """
organisation = self.getOrganisation() section = self.getSectionValue()
if organisation is None: if section is None:
return None return None
return organisation.getTitle() return section.getTitle()
security.declareProtected(Permissions.View, 'getCurrency') security.declareProtected(Permissions.View, 'getPriceCurrency')
def getCurrency(self): def getPriceCurrency(self):
""" """
Returns the used currency id for this particular immobilisation movement Returns the used currency id for this particular immobilisation movement
XXX Rename to getPriceCurrency (this is the name we use at this point, it will be renamed
some day to getTradeCurrency - make sure getPriceCurrencyValue is object and getPriceCurrency is not)
""" """
organisation = self.getOrganisation() section = self.getSectionValue()
if organisation is not None: if section is not None:
LOG('Immobilisation :', 0, 'organisation = %s, currency = %s' % (repr(organisation), repr(organisation.getSocialCapitalCurrency()))) return section.getSocialCapitalCurrency()
return organisation.getSocialCapitalCurrency()
LOG('Immobilisation :', 0, 'organisation = %s, currency = %s' % (repr(organisation), repr(None)))
return None return None
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