Skip to content

feat: add bieannial and triannial billing frequency#8

Merged
barredterra merged 5 commits into
version-16from
extend-billing-frequency
Jun 17, 2026
Merged

feat: add bieannial and triannial billing frequency#8
barredterra merged 5 commits into
version-16from
extend-billing-frequency

Conversation

@HenningWendtland

@HenningWendtland HenningWendtland commented Jun 15, 2026

Copy link
Copy Markdown
Member

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

@HenningWendtland HenningWendtland changed the title feat: ad bieannial and triannial billing frequency feat: add bieannial and triannial billing frequency Jun 15, 2026
@greptile-apps

greptile-apps Bot commented Jun 15, 2026

Copy link
Copy Markdown

Confidence Score: 5/5

Safe to merge. The biennial/triennial date arithmetic is correct, all four period_type × billing_time combinations are covered, and the new tests verify the boundary cases including the cross-year block alignment.

The block-anchor formula start_year + (Δyears // years_span) * years_span correctly handles forward and backward navigation through biennial and triennial calendar windows. The validate() hook reliably gates the multi-year + CalendarMonths combination at save time, and create_current_invoice catches the matching ValueError at run time. No new failure modes were introduced relative to the existing handling of Yearly/Halfyearly frequencies.

No files require special attention.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A([get_from_and_to_date]) --> B{period_type?}
    B -- StartDate --> C{billing_time?}
    B -- CalendarMonths --> D{billing_time?}

    C -- AtBeginning --> E[get_date_period\neval_date, freq, start_date]
    C -- AfterEnd --> F[get_date_period\ncurrent_start - 1d, freq, start_date]

    D -- AtBeginning --> G[get_calendar_period\neval_date, freq, start_year]
    D -- AfterEnd --> H[get_calendar_period\ncurrent_start - 1d, freq, start_year]

    G --> I{freq in\nMULTI_YEAR?}
    H --> I

    I -- Yes\nBiennial/Triennial --> J[block_start_year =\nstart_year + floor_div x years_span\nfrom_date = date block_start_year 1 1]
    I -- No\nMonthly/Quarterly/\nHalfyearly/Yearly --> K[from_date via\nINVOICE_MONTH_MAP]

    J --> L[to_date = from_date +\nrelativedelta months=freq.value - 1 day]
    K --> L
    E --> M([return from_date, to_date])
    F --> M
    L --> M
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([get_from_and_to_date]) --> B{period_type?}
    B -- StartDate --> C{billing_time?}
    B -- CalendarMonths --> D{billing_time?}

    C -- AtBeginning --> E[get_date_period\neval_date, freq, start_date]
    C -- AfterEnd --> F[get_date_period\ncurrent_start - 1d, freq, start_date]

    D -- AtBeginning --> G[get_calendar_period\neval_date, freq, start_year]
    D -- AfterEnd --> H[get_calendar_period\ncurrent_start - 1d, freq, start_year]

    G --> I{freq in\nMULTI_YEAR?}
    H --> I

    I -- Yes\nBiennial/Triennial --> J[block_start_year =\nstart_year + floor_div x years_span\nfrom_date = date block_start_year 1 1]
    I -- No\nMonthly/Quarterly/\nHalfyearly/Yearly --> K[from_date via\nINVOICE_MONTH_MAP]

    J --> L[to_date = from_date +\nrelativedelta months=freq.value - 1 day]
    K --> L
    E --> M([return from_date, to_date])
    F --> M
    L --> M
Loading

Reviews (4): Last reviewed commit: "fix: pass only start_year and replace fr..." | Re-trigger Greptile

@HenningWendtland

Copy link
Copy Markdown
Member Author

@greptileai

@HenningWendtland

Copy link
Copy Markdown
Member Author

@greptileai

@barredterra barredterra left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One last nitpick

@barredterra

Copy link
Copy Markdown
Member

@greptileai

@barredterra
barredterra merged commit 57f176b into version-16 Jun 17, 2026
5 checks passed
@barredterra
barredterra deleted the extend-billing-frequency branch June 17, 2026 16:57
@barredterra

barredterra commented Jun 17, 2026

Copy link
Copy Markdown
Member

@Mergifyio backport version-15

@barredterra barredterra removed their assignment Jun 17, 2026
@mergify

mergify Bot commented Jun 17, 2026

Copy link
Copy Markdown

backport version-15

✅ Backports have been created

Details

Cherry-pick of 57f176b has failed:

On branch mergify/bp/version-15/pr-8
Your branch is up to date with 'origin/version-15'.

You are currently cherry-picking commit 57f176b.
  (fix conflicts and run "git cherry-pick --continue")
  (use "git cherry-pick --skip" to skip this patch)
  (use "git cherry-pick --abort" to cancel the cherry-pick operation)

Changes to be committed:
	modified:   README.md
	modified:   simple_subscription/locale/de.po
	modified:   simple_subscription/locale/main.pot
	modified:   simple_subscription/simple_subscription/doctype/simple_subscription/simple_subscription.json

Unmerged paths:
  (use "git add <file>..." to mark resolution)
	both modified:   simple_subscription/simple_subscription/doctype/simple_subscription/simple_subscription.py
	both modified:   simple_subscription/simple_subscription/doctype/simple_subscription/test_simple_subscription.py

To fix up this pull request, you can check it out locally. See documentation: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/checking-out-pull-requests-locally

barredterra pushed a commit that referenced this pull request Jun 23, 2026
Co-authored-by: Henning Wendtland <156231187+HenningWendtland@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants