openfun / joanie

👛 A headless ERP for education to manage course enrollment/subscription, payment and certificates delivery.
MIT License
20 stars 2 forks source link

✨(backend) allow to configure how the withdrawal data is computed #837

Closed jonathanreveille closed 2 weeks ago

jonathanreveille commented 3 weeks ago

This PR will solve the issue

Purpose

We have added two new settings to be able to choose the calendar country depending on where the application is used geographically. The setting variable is called : JOANIE_CONTRACT_COUNTRY_CALENDAR. To get the instance of calendar set in settings, it can be retrieved by using the method : get_country_calendar()

The other setting allows (JOANIE_CONTRACT_COUNTRY_CALENDAR) to set the period of days a consumer has the right to withdraw from a contract.

The calendar was set to France and the withdrawal period of days (16 days for French context) was hard coded into the method :

def _withdrawal_limit_date(signed_contract_date, course_start_date):
...

Proposal

Give more flexibility to set different values for the chosen calendar and the period of days for withdrawal when signing a contract (which may change depending the country's regulation).

    # settings.py

    # The full list of countries available for use:
    # https://github.com/workalendar/workalendar#available-calendars
    JOANIE_CONTRACT_COUNTRY_CALENDAR = values.Value(
        "workalendar.europe.France",
        environ_name="JOANIE_CONTRACT_COUNTRY_CALENDAR",
        environ_prefix=None,
    )
    # Number of days for the withdrawal period as required by your country's contract legislation
    JOANIE_CONTRACT_COUNTRY_CALENDAR = values.PositiveIntegerValue(
        16,
        environ_name="JOANIE_CONTRACT_WITHDRAWAL_PERIOD_DAYS",
        environ_prefix=None,
    )