-
Notifications
You must be signed in to change notification settings - Fork 143
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(core): introduce 'ProcessPendingInvoiceResult' type
This is to introduce the new type and use it to decide when to mark invoices as 'proceesing completed' and 'paid'. The existing logic is kept in place an no iteration has been done on that as yet here. That will be addressed in follow-up commits.
- Loading branch information
Showing
4 changed files
with
252 additions
and
126 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
34 changes: 34 additions & 0 deletions
34
core/api/src/app/wallets/process-pending-invoice-result.ts
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
export const ProcessedReason = { | ||
InvoiceNotFound: "InvoiceNotFound", | ||
InvoiceCanceled: "InvoiceCanceled", | ||
} as const | ||
|
||
export const ProcessPendingInvoiceResult = { | ||
ok: (): ProcessPendingInvoiceResult => ({ | ||
isProcessed: true, | ||
isPaid: true, | ||
}), | ||
paidOnly: (): ProcessPendingInvoiceResult => ({ | ||
isProcessed: false, | ||
isPaid: true, | ||
}), | ||
paidWithError: (error: ApplicationError): ProcessPendingInvoiceResult => ({ | ||
isProcessed: false, | ||
isPaid: true, | ||
error, | ||
}), | ||
processedOnly: (reason: ProcessedReason): ProcessPendingInvoiceResult => ({ | ||
isProcessed: true, | ||
isPaid: false, | ||
reason, | ||
}), | ||
notPaid: (): ProcessPendingInvoiceResult => ({ | ||
isProcessed: false, | ||
isPaid: false, | ||
}), | ||
err: (error: ApplicationError): ProcessPendingInvoiceResult => ({ | ||
isProcessed: false, | ||
isPaid: false, | ||
error, | ||
}), | ||
} |
Oops, something went wrong.