Commit 694c9fee by Arnaud Fontaine

ZODB Components: Before migrating Interfaces from FS, there must be one…

ZODB Components: Before migrating Interfaces from FS, there must be one Interface class per source file matching its name.

Same as Document class: this avoids registering Interfaces at startup and just do it
when using the Interface. In assuming that portal_components/XXX has a class
name equals to XXX.getRference(), it is easier to:
 * List all existing Interfaces (for example in Portal Type Class view): getReference()
   on all validated 'Interface Component' in portal_components.
 * Lookup for an 'Interface Component': 'from erp5.component.interfaces.XXX import XXX'.
parent d9627917
# -*- coding: utf-8 -*-
##############################################################################
#
# Copyright (c) 2009 Nexedi SA and Contributors. All Rights Reserved.
# Jean-Paul Smets-Solanes <jp@nexedi.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 Products.ERP5.interfaces.asset_movement import IAssetMovement
class IAccountingMovement(IAssetMovement):
"""
Accounting Movement private interface specification
The notion of debit and credit is used in accounting instead of signed
quantity. The following calculation rules apply:
Credit/Debit
if quantity > 0
source_credit = quantity
source_debit = 0
destination_credit = 0
destination_debit = quantity
if quantity < 0
source_credit = 0
source_debit = - quantity
destination_credit = - quantity
destination_debit = 0
The cancellation amount concept from IAmount interface also applies for debit
and credit. For a cancellation amount, the calculation rule are different:
if quantity > 0
source_credit = 0
source_debit = - quantity
destination_credit = - quantity
destination_debit = 0
if quantity < 0
source_credit = quantity
source_debit = 0
destination_credit = 0
destination_debit = quantity
"""
# We must a find a way to use property sheets in or as interfaces
# property_sheets = (PropertySheet.Price, )
# Helper methods for single currency Accounting (debit / credit)
def getSourceDebit():
"""
Returns the source debit in the transaction currency
"""
def getSourceCredit():
"""
Returns the source credit in the transaction currency
"""
def getDestinationDebit():
"""
Returns the destination debit in the transaction currency
"""
def getDestinationCredit():
"""
Returns the destination credit in the transaction currency
"""
# Helper methods for multi currency Accounting (debit / credit)
def getSourceAssetDebit():
"""
Returns the source debit in the source section management currency
based on the source_total_asset price property
"""
def getSourceAssetCredit():
"""
Returns the source credit in the source section management currency
based on the source_total_asset price property
"""
def getDestinationAssetDebit():
"""
Returns the destination debit in the destination section management currency
based on the destination_total_asset price property
"""
def getDestinationAssetCredit():
"""
Returns the destination credit in the destination section management currency
based on the destination_total_asset price property
"""
# The following is really unclear -
# It uses getSourceInventoriatedTotalAssetPrice instead of
# of getSourceInventoriatedTotalAssetPrice instead of getSourceTotalAssetPrice
# I can only see one purpose: presentation of reports in predictive accounting
# ie. in transactions generated by simulation which do not yet have
# well defined source_total_asset/destination_total_asset
def getSourceInventoriatedTotalAssetDebit():
"""
Unclear - XXX
"""
def getSourceInventoriatedTotalAssetCredit():
"""
Unclear - XXX
"""
def getDestinationInventoriatedTotalAssetDebit():
"""
Unclear - XXX
"""
def getDestinationInventoriatedTotalAssetCredit():
"""
Unclear - XXX
"""
# -*- coding: utf-8 -*-
##############################################################################
#
......@@ -30,196 +31,10 @@
Products.ERP5.interfaces.amount
"""
from zope.interface import Interface
class IAmountCore(Interface):
"""Amount Core private interface specification
IAmountCore defines the minimal set of getters required
to implement an amount.
"""
def getQuantity():
"""
Returns the quantity of the resource
in the unit specified by the Amount
NOTE: declaration is redundant with IAmountGetter
"""
def getResource():
"""
Returns the resource category relative URL
of the Amount
NOTE: declaration is redundant with IAmountGetter
"""
def getQuantityUnit():
"""
Returns the quantity unit category relative URL
of the Amount
NOTE: declaration is redundant with IAmountGetter
"""
def isCancellationAmount():
"""
A cancellation amount must be interpreted
reversely wrt. to the sign of quantity.
For example, a negative credit for a cancellation
amount is a negative credit, not a positive
debit.
A negative production quantity for a cancellation
amount is a cancelled production, not
a consumption
NOTE: declaration is redundant with IAmountGetter
"""
def getEfficiency():
"""
Returns the ratio of loss for the given amount. This
is only used in Path such as Transformation. In other
words, efficiency of movements is always 100%.
NOTE: declaration is redundant with IAmountGetter
"""
def getBaseContributionList():
"""
The list of bases this amount contributes to.
XXX: explain better
"""
def getBaseApplicationList():
"""
The list of bases this amount has been applied on. Only set if the
amount comes from a transformation.
XXX: explain better
"""
class IAmountConversion(Interface):
"""Amount Conversion private interface specification
IAmountConversion defines methods which can be used
to convert an amount from one quantity unit and to another,
taking into account efficiency.
"""
def getNetQuantity():
"""
Take into account efficiency in quantity. This is
only useful in Path which define a loss ratio, such
as Transformation.
Formula:
net_quantity = quantity / efficiency
"""
def getConvertedQuantity(quantity_unit=None, measure=None):
"""
Returns the quantity of the resource converted in the
default management unit of the resource.
quantity_unit -- optional quantity unit to use
for conversion.
measure -- optional quantity unit to use
for conversion.
"""
def getNetConvertedQuantity(quantity_unit=None, measure=None):
"""
Returns the net quantity of the resource converted in the
default management unit of the resource.
quantity_unit -- optional quantity unit to use
for conversion.
measure -- optional quantity unit to use
for conversion.
"""
class IAmountPrice(Interface):
"""Amount Price private interface specification
IAmountPrice defines methods to compute total price
and unit price of a resource, taking into account
contributions and roundings.
"""
def getPrice():
"""
Returns the input unit price of the resource
NOTE: redundant with IPriceGetter
"""
def getUnitPrice(base_contribution=None, rounding=False):
"""
Returns the unit price of the resource, taking into
account rounding and contributions (ex. taxes).
base_contribution -- optional base_contribution.
If defined, a complex process is launched
to add or remove to the price various amounts
calculated from applicable trade models if
any.
rounding -- optional rounding parameter. If set to True,
find and applies appropriate rounding model.
"""
def getTotalPrice(base_contribution=None, rounding=False):
"""
Returns total price ie. the unit price of the resource
multiplied by the quantity, taking into
account rounding and contributions (ex. taxes).
base_contribution -- optional base_contribution.
If defined, a complex process is launched
to add or remove to the price various amounts
calculated from applicable trade models if
any.
rounding -- optional rounding parameter. If set to True,
find and applies appropriate rounding model.
"""
class IAmountArithmetic(Interface):
"""Amount Arithmetic private interface specification
IAmountArithmetic defines methods to add, substract,
multiply or device amounts of resources. No rounding
should happen. All amounts should be converted to
the default management unit using getNetConvertedQuantity.
"""
def __add__(value):
"""Add an amount to another amount
'value' is an IAmount document
"""
def __sub__(value):
"""Substract an amount from another amount
'value' is an IAmount document
"""
def __mul__(value):
"""Multiply an Amount by a float
'value' is a float
"""
def __div__(value):
"""Divide an Amount by a float
'value' is a float
"""
from Products.ERP5.interfaces.amount_core import IAmountCore
from Products.ERP5.interfaces.amount_conversion import IAmountConversion
from Products.ERP5.interfaces.amount_price import IAmountPrice
from Products.ERP5.interfaces.amount_arithmetic import IAmountArithmetic
class IAmount(IAmountCore, IAmountConversion, IAmountPrice, IAmountArithmetic):
"""Amount interface specification
......
# -*- coding: utf-8 -*-
##############################################################################
#
# Copyright (c) 2009 Nexedi SARL and Contributors. All Rights Reserved.
# Jean-Paul Smets-Solanes <jp@nexedi.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.
#
##############################################################################
"""
Products.ERP5.interfaces.amount_arithmetic
"""
from zope.interface import Interface
class IAmountArithmetic(Interface):
"""Amount Arithmetic private interface specification
IAmountArithmetic defines methods to add, substract,
multiply or device amounts of resources. No rounding
should happen. All amounts should be converted to
the default management unit using getNetConvertedQuantity.
"""
def __add__(value):
"""Add an amount to another amount
'value' is an IAmount document
"""
def __sub__(value):
"""Substract an amount from another amount
'value' is an IAmount document
"""
def __mul__(value):
"""Multiply an Amount by a float
'value' is a float
"""
def __div__(value):
"""Divide an Amount by a float
'value' is a float
"""
# -*- coding: utf-8 -*-
##############################################################################
#
# Copyright (c) 2009 Nexedi SARL and Contributors. All Rights Reserved.
# Jean-Paul Smets-Solanes <jp@nexedi.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.
#
##############################################################################
"""
Products.ERP5.interfaces.amount_conversion
"""
from zope.interface import Interface
class IAmountConversion(Interface):
"""Amount Conversion private interface specification
IAmountConversion defines methods which can be used
to convert an amount from one quantity unit and to another,
taking into account efficiency.
"""
def getNetQuantity():
"""
Take into account efficiency in quantity. This is
only useful in Path which define a loss ratio, such
as Transformation.
Formula:
net_quantity = quantity / efficiency
"""
def getConvertedQuantity(quantity_unit=None, measure=None):
"""
Returns the quantity of the resource converted in the
default management unit of the resource.
quantity_unit -- optional quantity unit to use
for conversion.
measure -- optional quantity unit to use
for conversion.
"""
def getNetConvertedQuantity(quantity_unit=None, measure=None):
"""
Returns the net quantity of the resource converted in the
default management unit of the resource.
quantity_unit -- optional quantity unit to use
for conversion.
measure -- optional quantity unit to use
for conversion.
"""
# -*- coding: utf-8 -*-
##############################################################################
#
# Copyright (c) 2009 Nexedi SARL and Contributors. All Rights Reserved.
# Jean-Paul Smets-Solanes <jp@nexedi.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.
#
##############################################################################
"""
Products.ERP5.interfaces.amount_core
"""
from zope.interface import Interface
class IAmountCore(Interface):
"""Amount Core private interface specification
IAmountCore defines the minimal set of getters required
to implement an amount.
"""
def getQuantity():
"""
Returns the quantity of the resource
in the unit specified by the Amount
NOTE: declaration is redundant with IAmountGetter
"""
def getResource():
"""
Returns the resource category relative URL
of the Amount
NOTE: declaration is redundant with IAmountGetter
"""
def getQuantityUnit():
"""
Returns the quantity unit category relative URL
of the Amount
NOTE: declaration is redundant with IAmountGetter
"""
def isCancellationAmount():
"""
A cancellation amount must be interpreted
reversely wrt. to the sign of quantity.
For example, a negative credit for a cancellation
amount is a negative credit, not a positive
debit.
A negative production quantity for a cancellation
amount is a cancelled production, not
a consumption
NOTE: declaration is redundant with IAmountGetter
"""
def getEfficiency():
"""
Returns the ratio of loss for the given amount. This
is only used in Path such as Transformation. In other
words, efficiency of movements is always 100%.
NOTE: declaration is redundant with IAmountGetter
"""
def getBaseContributionList():
"""
The list of bases this amount contributes to.
XXX: explain better
"""
def getBaseApplicationList():
"""
The list of bases this amount has been applied on. Only set if the
amount comes from a transformation.
XXX: explain better
"""
......@@ -83,32 +83,5 @@ class IAmountGenerator(Interface):
simplistic)
"""
class IAmountGeneratorLine(Interface):
"""Amount Generator Line interface specification
"""
def getCellAggregateKey():
"""Define a key in order to aggregate amounts at cell level
Transformed Resource (Transformation)
key must be None because:
- quantity and variation are defined in different cells so that the
user does not need to enter values depending on all axes
- amount_generator_cell.test should filter only 1 variant
current key = (acquired resource, acquired variation)
Assorted Resource (Transformation)
key = (assorted resource, assorted resource variation)
usually resource and quantity provided together
Payroll
key = (payroll resource, payroll resource variation)
Tax
key = (tax resource, tax resource variation)
"""
def getBaseAmountQuantity(delivery_amount, base_application, rounding):
"""Default method to compute quantity for the given base_application
"""
# For backward compatibility only
from Products.ERP5.interfaces.amount_generator_line import IAmountGeneratorLine
# -*- coding: utf-8 -*-
##############################################################################
#
# Copyright (c) 2009 Nexedi SA and Contributors. All Rights Reserved.
# Jean-Paul Smets-Solanes <jp@nexedi.com>
# Lukasz Nowak <luke@nexedi.com>
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsibility 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
# guarantees and support are strongly advised 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
##############################################################################
"""
Products.ERP5.interfaces.amount_generator_line
"""
from zope.interface import Interface
class IAmountGeneratorLine(Interface):
"""Amount Generator Line interface specification
"""
def getCellAggregateKey():
"""Define a key in order to aggregate amounts at cell level
Transformed Resource (Transformation)
key must be None because:
- quantity and variation are defined in different cells so that the
user does not need to enter values depending on all axes
- amount_generator_cell.test should filter only 1 variant
current key = (acquired resource, acquired variation)
Assorted Resource (Transformation)
key = (assorted resource, assorted resource variation)
usually resource and quantity provided together
Payroll
key = (payroll resource, payroll resource variation)
Tax
key = (tax resource, tax resource variation)
"""
def getBaseAmountQuantity(delivery_amount, base_application, rounding):
"""Default method to compute quantity for the given base_application
"""
# -*- coding: utf-8 -*-
##############################################################################
#
# Copyright (c) 2009 Nexedi SARL and Contributors. All Rights Reserved.
# Jean-Paul Smets-Solanes <jp@nexedi.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.
#
##############################################################################
"""
Products.ERP5.interfaces.amount_price
"""
from zope.interface import Interface
class IAmountPrice(Interface):
"""Amount Price private interface specification
IAmountPrice defines methods to compute total price
and unit price of a resource, taking into account
contributions and roundings.
"""
def getPrice():
"""
Returns the input unit price of the resource
NOTE: redundant with IPriceGetter
"""
def getUnitPrice(base_contribution=None, rounding=False):
"""
Returns the unit price of the resource, taking into
account rounding and contributions (ex. taxes).
base_contribution -- optional base_contribution.
If defined, a complex process is launched
to add or remove to the price various amounts
calculated from applicable trade models if
any.
rounding -- optional rounding parameter. If set to True,
find and applies appropriate rounding model.
"""
def getTotalPrice(base_contribution=None, rounding=False):
"""
Returns total price ie. the unit price of the resource
multiplied by the quantity, taking into