aboutsummaryrefslogtreecommitdiff
path: root/packages/taler-wallet-core/src/operations/tip.ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/taler-wallet-core/src/operations/tip.ts')
-rw-r--r--packages/taler-wallet-core/src/operations/tip.ts27
1 files changed, 27 insertions, 0 deletions
diff --git a/packages/taler-wallet-core/src/operations/tip.ts b/packages/taler-wallet-core/src/operations/tip.ts
index b37288079..5bcf609b5 100644
--- a/packages/taler-wallet-core/src/operations/tip.ts
+++ b/packages/taler-wallet-core/src/operations/tip.ts
@@ -35,6 +35,9 @@ import {
TalerErrorCode,
TalerProtocolTimestamp,
TipPlanchetDetail,
+ TransactionMajorState,
+ TransactionMinorState,
+ TransactionState,
TransactionType,
URL,
} from "@gnu-taler/taler-util";
@@ -67,6 +70,30 @@ import { selectWithdrawalDenominations } from "../util/coinSelection.js";
const logger = new Logger("operations/tip.ts");
+/**
+ * Get the (DD37-style) transaction status based on the
+ * database record of a tip.
+ */
+export function computeTipTransactionStatus(
+ tipRecord: TipRecord,
+): TransactionState {
+ if (tipRecord.pickedUpTimestamp) {
+ return {
+ major: TransactionMajorState.Done,
+ };
+ }
+ if (tipRecord.acceptedTimestamp) {
+ return {
+ major: TransactionMajorState.Pending,
+ minor: TransactionMinorState.Pickup,
+ };
+ }
+ return {
+ major: TransactionMajorState.Pending,
+ minor: TransactionMinorState.User,
+ };
+}
+
export async function prepareTip(
ws: InternalWalletState,
talerTipUri: string,