Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(dunning): reset customer dunning campaign last attempt data on threshold changes #2861

Merged
merged 11 commits into from
Nov 26, 2024

Conversation

ancorcruz
Copy link
Contributor

Roadmap

👉 https://getlago.canny.io/feature-requests/p/set-up-payment-retry-logic

👉 https://getlago.canny.io/feature-requests/p/send-reminders-for-overdue-invoices

Context

We want to automate dunning process so that our users don't have to look at each customer to maximize their chances of being paid retrying payments of overdue balances and sending email reminders.

We are extending dunning campaigns management to edit and delete campaigns.

Description

When a dunning campaign threshold changes, it resets customers last_dunning_campaign_attempt fields with the updated campaign applicable (through direct association or falling back to it through the organization default) when the thresholds does not match anymore (currency and/or amount_cents changed or deletion of the threshold).

improve code organization and readability
these will test side effects on campaign thresholds updates, reset last
dunning campaign attempt is required when the threshold does not match
anymore.
when the amount threshold does not match anymore
when matching threshold changes currency and it is not applicable
anymore
also refactor the code to trigger the customer reset if there is a
change in thresholds (discarded or changed) and there isn't at least one
of the persisted thresholds of the campaigh matching a customer overdue
blance with its currency
prior to this change in accepts to create new records with the same
currency as an existing one with the new record deleted_at not null.
however if the existing record was discarded (deleted_at not nil) and
the new record is not discarded and matches the currency with the
existing one, validation does not allow the record to be saved (not
valid)
to cover the scneairo when a threshold is deleted an a new one is added
in the same request that still matches the customer overdue balances and
the customer should not be reseted
when there is still a matching currency threshold it does not reset the
customer...
@ancorcruz ancorcruz merged commit 5a97420 into main Nov 26, 2024
6 checks passed
@ancorcruz ancorcruz deleted the feat/dunning-edit-thresholds branch November 26, 2024 08:06
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