Repository navigation
Fix #507: enforce ledger close-time for invoice settlement classification - #527
Draft
s6pa1rta3n-lab wants to merge 1 commit into
Draft
s6pa1rta3n-lab wants to merge 1 commit into
s6pa1rta3n-lab wants to merge 1 commit into
Conversation
…ent classification
Collaborator
7 tasks done
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.
Summary
Resolves #507.
Enforces ledger
close_timefor invoice settlement classification across memory and Postgres storage backends, API endpoints, payment monitor polling, and frontend timeline/receipt surfaces.Changes
Shared Settlement Contract:
shared/settlement.ts, definingsettlementFieldsForInvoice()andSettlementTimeUnavailableError.close_timeagainst invoiceexpires_atandcancelled_atto classify settlement asON_TIME,AFTER_EXPIRY, orAFTER_CANCEL.PAYMENT_RECEIVED_AFTER_EXPIRYandPAYMENT_RECEIVED_AFTER_CANCEL.Backend Services & Endpoints:
InvoiceService.markAsPaidto acceptsettled_at, conditionally settlingEXPIREDorPENDINGinvoices and settingsettlement_context,prior_status, andlate_payment_warning_code.MemoryStorage.markAsPaidto mirror Postgres behavior, rejecting missing settlement times on expired/cancelled invoices.verifyPaymentininvoice.handlers.tsto pass Horizoncreated_at(close_time) assettledAtand fail closed with HTTP 503TRANSACTION_CLOSE_TIME_UNAVAILABLEwhenclose_timeis unavailable.PaymentMonitorServiceto pass transactioncreated_atto verification and mark invoices paid with proper expiry settlement context.Frontend Timeline & Receipts:
InvoiceTimelineandbuildInvoiceTimelineEventsto displayexpiredmilestone beforepaidwhen settledAFTER_EXPIRY.PaymentReceiptand PDF exports to render warning banners whenlatePaymentWarningCodeis present.Testing:
backend/tests/invoice-expiry-settlement.test.tsverifying on-time vs after-expiry classification, clock skew resilience, and fail-closed 503 behavior on missingclose_time.frontend/tests/invoice-workspace.test.jsvalidating timeline sequence for after-expiry payments.Acceptance Criteria Checklist
close_timebeforeexpiresAtsettles asON_TIMEeven if verified after expiry.close_timeafterexpiresAtsettles asAFTER_EXPIRYwithPAYMENT_RECEIVED_AFTER_EXPIRYwarning.TRANSACTION_CLOSE_TIME_UNAVAILABLEwhen Horizonclose_timeis unavailable.close_timeduring automated sync cycles.created -> expired -> paidevents chronologically for late payments.Payout Routing
0xF46C9F6d70C50BF81ef3588AB523a90a594a2F89GCL6OXAMLD75BMTINA6EMRUDWK5THQUSHMYNLSNBCJAPZJHNYJTUNIBC