Commit 8fa60530 authored by Luca Cristaldi's avatar Luca Cristaldi
Browse files

add possibility to specify a maturity date

for the membership fees
parent 39f69895
Loading
Loading
Loading
Loading
+12 −2
Original line number Diff line number Diff line
# This file is part of Tryton. The COPYRIGHT file at the top level of
# this repository contains the full copyright notices and license terms.
from decimal import Decimal
from datetime import timedelta
from trytond.config import config
from trytond.i18n import gettext
from trytond.model import Workflow, ModelView, ModelSQL, fields, Unique
@@ -286,6 +287,9 @@ class MembershipType(ModelSQL, ModelView):
        required=True,
        ondelete='RESTRICT',
        help="The revenue account that is used for the fee.")
    maturity_delay = fields.TimeDelta("Maturity Delay",
        required=True,
        help="The period of time after the membership fees must be paid")
    company = fields.Many2One('company.company', 'Company', required=True,
        select=True,
        domain=[
@@ -298,6 +302,10 @@ class MembershipType(ModelSQL, ModelView):
    def default_company(cls):
        return Transaction().context.get('company')

    @classmethod
    def default_maturity_delay(cls):
        return timedelta(0)


class Membership(ModelSQL, ModelView):
    """Membership"""
@@ -617,13 +625,15 @@ class Fee(ModelSQL, ModelView):
        party = None
        if account.party_required:
            party = self.member.party
        else:
            party = None

        maturity_date= self.period.start_date + \
            self.period.membership_type.maturity_delay

        return MoveLine(
            debit=abs(amount) if amount > 0 else 0,
            credit=abs(amount) if amount < 0 else 0,
            account=account,
            maturity_date=maturity_date,
            party=party,
        )

+2 −0
Original line number Diff line number Diff line
@@ -14,6 +14,8 @@ this repository contains the full copyright notices and license terms. -->
            <field name="account_revenue" />
            <label name="journal" />
            <field name="journal" />
            <label name="maturity_delay" />
            <field name="maturity_delay" />
        </page>
    </notebook>
</form>
 No newline at end of file