Skip to content

feat: add bieannial and triannial billing frequency (backport #8)#9

Merged
barredterra merged 2 commits into
version-15from
mergify/bp/version-15/pr-8
Jun 23, 2026
Merged

feat: add bieannial and triannial billing frequency (backport #8)#9
barredterra merged 2 commits into
version-15from
mergify/bp/version-15/pr-8

Conversation

@mergify

@mergify mergify Bot commented Jun 17, 2026

Copy link
Copy Markdown

Addition of biennial and triennial billing (every 2 and 3 years).
This was easily possible for the period_type == "start date" but not for "calendar months" type, so just implemented for the first type.
To improve the UI the correct types are displayed dynamically

Reference: AIT-46


This is an automatic backport of pull request #8 done by Mergify.

(cherry picked from commit 57f176b)

# Conflicts:
#	simple_subscription/simple_subscription/doctype/simple_subscription/simple_subscription.py
#	simple_subscription/simple_subscription/doctype/simple_subscription/test_simple_subscription.py
@mergify

This comment was marked as resolved.

@greptile-apps

greptile-apps Bot commented Jun 17, 2026

Copy link
Copy Markdown

Confidence Score: 5/5

The change is safe to merge — the core date-calculation logic is well-tested, validation guards are in place, and the error-handling path is correctly wired up.

The new Biennial/Triennial logic uses frequency.value directly, which is simple and consistent across all period types. The MULTI_YEAR_FREQUENCIES sentinel and the start_year anchoring formula are both tested with multiple boundary dates. The validate() hook prevents the one known invalid configuration (CalendarMonths + multi-year + no start_date) from being saved. The only remaining items are minor annotation style inconsistencies and an idiomatic None-check that do not affect runtime behaviour.

No files require special attention beyond the minor style notes on simple_subscription.py.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[create_current_invoice / daily scheduler] --> B[get_from_and_to_date]
    B --> C{period_type?}
    C -->|StartDate| D{billing_time?}
    C -->|CalendarMonths| E{billing_time?}
    D -->|AtBeginning| F[get_date_period]
    D -->|AfterEnd| G[get_date_period prev]
    E -->|AtBeginning| H[get_calendar_period]
    E -->|AfterEnd| I[get_calendar_period prev]
    H --> J{freq in MULTI_YEAR?}
    I --> J
    J -->|Yes Biennial/Triennial| K[block_start_year anchor from start_year]
    J -->|No| L[INVOICE_MONTH_MAP lookup]
    K --> M[from=Jan 1 of block_start_year]
    L --> N[from=month start]
    B -->|ValueError| O{silent?}
    O -->|No| P[frappe.throw]
    O -->|Yes| Q[return silently]
    M --> R{start_date > from_date?}
    N --> R
    R -->|Yes| S[skip / throw]
    R -->|No| T[create_invoice]
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
flowchart TD
    A[create_current_invoice / daily scheduler] --> B[get_from_and_to_date]
    B --> C{period_type?}
    C -->|StartDate| D{billing_time?}
    C -->|CalendarMonths| E{billing_time?}
    D -->|AtBeginning| F[get_date_period]
    D -->|AfterEnd| G[get_date_period prev]
    E -->|AtBeginning| H[get_calendar_period]
    E -->|AfterEnd| I[get_calendar_period prev]
    H --> J{freq in MULTI_YEAR?}
    I --> J
    J -->|Yes Biennial/Triennial| K[block_start_year anchor from start_year]
    J -->|No| L[INVOICE_MONTH_MAP lookup]
    K --> M[from=Jan 1 of block_start_year]
    L --> N[from=month start]
    B -->|ValueError| O{silent?}
    O -->|No| P[frappe.throw]
    O -->|Yes| Q[return silently]
    M --> R{start_date > from_date?}
    N --> R
    R -->|Yes| S[skip / throw]
    R -->|No| T[create_invoice]
Loading

Reviews (2): Last reviewed commit: "fix: resolve backport merge confilcts fo..." | Re-trigger Greptile

@barredterra
barredterra merged commit f2156bf into version-15 Jun 23, 2026
6 checks passed
@barredterra
barredterra deleted the mergify/bp/version-15/pr-8 branch June 23, 2026 14:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants