Repository navigation
Remind customers of payments falling due and overdue - #1068
Merged
Merged
Conversation
added 4 commits
November 19, 2026 05:36
Comment on lines
+40
to
+44
| catch (Exception ex) | ||
| { | ||
| logService.LogError(ex, "UpgradeProcess - PaymentDueReminders {Step} (2.5)", name); | ||
| success = false; | ||
| } |
added 3 commits
November 19, 2026 08:01
The reminders, the company credit, the overdue order list and IsPaymentOverdue each repeated the same predicate; they now use PaymentExtensions.UnpaidOnCredit.
The rule that a new due date sends the reminders again moves out of the controller. Only the purchase order number, the due date and the reminder markers are written, so a marker set by the reminder task meanwhile is not overwritten, and the due date is compared in UTC: LiteDB reads it back in local time.
Up to 365 days in the settings and in the task, so one store's value cannot stop the run for every store. A reminder that failed is not marked and is sent on the next run; a failed write no longer leaves the loop. Orders are loaded one by one from their ids, and the marker write publishes EntityUpdated.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Type: feature
Issue
Orders bought on credit (trade credit,
Payments.OnAccount) have a payment due date, an overdue rule (PaymentExtensions.IsPaymentOverdue), an "Overdue payments only" order filter andBlockWhenOverdue, but nobody tells the customer. The reminder e-mails were left out of #1001.Solution
IPaymentReminderService.SendPaymentReminders(utcNow)(Grand.Business.Checkout), run daily by the new scheduled task Payment due reminders. For each store it finds the unpaid orders bought on credit (PaymentExtensions.UnpaidOnCredit: not deleted, not cancelled, payment Pending / Authorized / Partially paid):OrderSettings.PaymentReminderDaysBeforedays (today included) → e-mailOrderPaymentDue.CustomerNotification;OrderPaymentOverdue.CustomerNotification. An order already overdue (e.g. the task was off) gets only this one.Order.PaymentReminderSentOnUtc/Order.PaymentOverdueNoticeSentOnUtc, written with a field update (a full save could overwrite a payment saved in the meantime), followed byEntityUpdated<Order>. No repeat and no escalation.IOrderService.UpdatePaymentTerms(used by the "Payment terms" popup instead of a fullUpdateOrder) writes only the purchase order number, the due date and, when the date changed, clears both markers, so the new date gets its own reminder and notice. The dates are compared in UTC, because LiteDB reads a stored date back in local time; saving the same date keeps the markers.OrderSettings.MaxPaymentReminderDaysBefore). The service clamps a stored value to the same range, so one store's value cannot stop the run for the others.PaymentExtensions.UnpaidOnCreditreplaces the same predicate repeated inCompanyCreditService,GetOrderQueryHandler(overdue filter) andIsPaymentOverdue.Ordertokens.{{Order.PaymentDueDate}}is the long date in the server's culture when sent by the task; a template can fix the format with thedatefilter, e.g.{{Order.PaymentDueDate | date: 'dd.MM.yyyy'}}.PaymentDueDateUtcon orders.MigrationPaymentDueReminders(2.5) adds the same to existing installations, with the task disabled: an existing shop may have orders that have been overdue for months, so the operator decides when those customers are told. Resources inDefaultLanguage.xmlandUpgrade/en_250.xml.Out of scope: copying the company owner, repeated overdue notices, a payment link in the e-mail (bank transfer and on-account orders have none), showing the markers in the panel (the order notes and the message queue show what was sent). Tax display and social links in e-mails sent by a scheduled task follow the task's store, not the order's; fixed separately for every e-mail in #1069.
Breaking changes
IOrderMessageProviderServicegainsSendPaymentDueReminderCustomerMessageandSendPaymentOverdueCustomerMessage, andIOrderServicegainsUpdatePaymentTerms. An implementation outside this repository has to add them.UpdatePaymentTermsinstead ofUpdateOrder.Testing
dotnet test:Grand.Business.Checkout.Tests938,Grand.Business.Messages.Tests153,Grand.Modules.Tests402,Grand.Web.Admin.Tests2065,Grand.Web.Store.Tests241,Grand.Mapping.Tests238 passed. Not checked in a browser (this worktree has no installed database).