@nimee/shared-types 1.0.333 → 1.0.336
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/crm/diningCommit.d.ts +44 -0
- package/package.json +1 -1
- package/src/crm/diningCommit.ts +45 -0
|
@@ -38,6 +38,13 @@ export interface IDiningCommitItem {
|
|
|
38
38
|
addedAt?: Date | string;
|
|
39
39
|
[key: string]: unknown;
|
|
40
40
|
}
|
|
41
|
+
export interface IDiningCommitAdjustment {
|
|
42
|
+
amount: number;
|
|
43
|
+
reason: string;
|
|
44
|
+
createdBy?: string | mongoose.Types.ObjectId;
|
|
45
|
+
createdByName?: string;
|
|
46
|
+
createdAt?: Date;
|
|
47
|
+
}
|
|
41
48
|
export interface IDiningCommitModel {
|
|
42
49
|
_id?: string | mongoose.Types.ObjectId;
|
|
43
50
|
endUser: string | mongoose.Types.ObjectId;
|
|
@@ -68,6 +75,43 @@ export interface IDiningCommitModel {
|
|
|
68
75
|
customer?: Record<string, unknown>;
|
|
69
76
|
settled: boolean;
|
|
70
77
|
chargeId?: string | mongoose.Types.ObjectId | null;
|
|
78
|
+
/** Who triggered settlement, and when. `null`/`undefined` reserved for a future automated sweep. */
|
|
79
|
+
settledBy?: string | mongoose.Types.ObjectId | null;
|
|
80
|
+
settledByName?: string | null;
|
|
81
|
+
settledAt?: Date | null;
|
|
82
|
+
/**
|
|
83
|
+
* Whether the charge that collected this meal was later refunded. Stamped at refund time, not
|
|
84
|
+
* derived on read — the guest's page must stay one query.
|
|
85
|
+
*
|
|
86
|
+
* `full` means the whole charge came back, so this meal's money did too. `partial` is charge-level
|
|
87
|
+
* and carries no per-meal figure: a charge covers several meals and a partial refund does not say
|
|
88
|
+
* which of them it was for.
|
|
89
|
+
*/
|
|
90
|
+
refundState?: "partial" | "full";
|
|
91
|
+
refundedAt?: Date;
|
|
92
|
+
/**
|
|
93
|
+
* This meal's share of the money returned, in SHEKELS. Stamped alongside `refundState`.
|
|
94
|
+
*
|
|
95
|
+
* On a `full` refund it is exactly this meal's own effectiveAmount. On a `partial` it is the
|
|
96
|
+
* meal's PRO-RATA share of the charge's refunded total, weighted by effective amount — an
|
|
97
|
+
* apportionment, not a fact about this meal, since a partial refund never says which of the
|
|
98
|
+
* charge's meals it was for. The apportionment is exact in aggregate: the shares always sum back
|
|
99
|
+
* to the amount actually returned, which is what makes it safe to total in reporting.
|
|
100
|
+
*
|
|
101
|
+
* That is also why the guest-facing page shows this figure only for a `full` refund: reporting can
|
|
102
|
+
* honestly sum an apportionment, but telling one diner "we gave you back 41.30 for this dish"
|
|
103
|
+
* would state something we do not know.
|
|
104
|
+
*/
|
|
105
|
+
refundedAmount?: number;
|
|
106
|
+
/** Pre-charge-only price reductions. `amount` above is never mutated — see `effectiveAmount`. */
|
|
107
|
+
adjustments?: IDiningCommitAdjustment[];
|
|
108
|
+
/**
|
|
109
|
+
* `amount + sum(adjustments[].amount)`. NEVER stored — always computed at read time (aggregation
|
|
110
|
+
* `$addFields` in the DB manager, or in-memory when a single already-fetched doc is reshaped). This
|
|
111
|
+
* field exists on the interface only so callers that receive an already-computed value (API
|
|
112
|
+
* responses, aggregation output) have a name for it.
|
|
113
|
+
*/
|
|
114
|
+
effectiveAmount?: number;
|
|
71
115
|
createdAt?: Date;
|
|
72
116
|
updatedAt?: Date;
|
|
73
117
|
}
|
package/package.json
CHANGED
package/src/crm/diningCommit.ts
CHANGED
|
@@ -15,6 +15,14 @@ export interface IDiningCommitItem {
|
|
|
15
15
|
[key: string]: unknown;
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
+
export interface IDiningCommitAdjustment {
|
|
19
|
+
amount: number; // always < 0 — a compensation only ever reduces the price
|
|
20
|
+
reason: string;
|
|
21
|
+
createdBy?: string | mongoose.Types.ObjectId;
|
|
22
|
+
createdByName?: string;
|
|
23
|
+
createdAt?: Date;
|
|
24
|
+
}
|
|
25
|
+
|
|
18
26
|
export interface IDiningCommitModel {
|
|
19
27
|
_id?: string | mongoose.Types.ObjectId;
|
|
20
28
|
endUser: string | mongoose.Types.ObjectId;
|
|
@@ -45,6 +53,43 @@ export interface IDiningCommitModel {
|
|
|
45
53
|
customer?: Record<string, unknown>;
|
|
46
54
|
settled: boolean;
|
|
47
55
|
chargeId?: string | mongoose.Types.ObjectId | null;
|
|
56
|
+
/** Who triggered settlement, and when. `null`/`undefined` reserved for a future automated sweep. */
|
|
57
|
+
settledBy?: string | mongoose.Types.ObjectId | null;
|
|
58
|
+
settledByName?: string | null;
|
|
59
|
+
settledAt?: Date | null;
|
|
60
|
+
/**
|
|
61
|
+
* Whether the charge that collected this meal was later refunded. Stamped at refund time, not
|
|
62
|
+
* derived on read — the guest's page must stay one query.
|
|
63
|
+
*
|
|
64
|
+
* `full` means the whole charge came back, so this meal's money did too. `partial` is charge-level
|
|
65
|
+
* and carries no per-meal figure: a charge covers several meals and a partial refund does not say
|
|
66
|
+
* which of them it was for.
|
|
67
|
+
*/
|
|
68
|
+
refundState?: "partial" | "full";
|
|
69
|
+
refundedAt?: Date;
|
|
70
|
+
/**
|
|
71
|
+
* This meal's share of the money returned, in SHEKELS. Stamped alongside `refundState`.
|
|
72
|
+
*
|
|
73
|
+
* On a `full` refund it is exactly this meal's own effectiveAmount. On a `partial` it is the
|
|
74
|
+
* meal's PRO-RATA share of the charge's refunded total, weighted by effective amount — an
|
|
75
|
+
* apportionment, not a fact about this meal, since a partial refund never says which of the
|
|
76
|
+
* charge's meals it was for. The apportionment is exact in aggregate: the shares always sum back
|
|
77
|
+
* to the amount actually returned, which is what makes it safe to total in reporting.
|
|
78
|
+
*
|
|
79
|
+
* That is also why the guest-facing page shows this figure only for a `full` refund: reporting can
|
|
80
|
+
* honestly sum an apportionment, but telling one diner "we gave you back 41.30 for this dish"
|
|
81
|
+
* would state something we do not know.
|
|
82
|
+
*/
|
|
83
|
+
refundedAmount?: number;
|
|
84
|
+
/** Pre-charge-only price reductions. `amount` above is never mutated — see `effectiveAmount`. */
|
|
85
|
+
adjustments?: IDiningCommitAdjustment[];
|
|
86
|
+
/**
|
|
87
|
+
* `amount + sum(adjustments[].amount)`. NEVER stored — always computed at read time (aggregation
|
|
88
|
+
* `$addFields` in the DB manager, or in-memory when a single already-fetched doc is reshaped). This
|
|
89
|
+
* field exists on the interface only so callers that receive an already-computed value (API
|
|
90
|
+
* responses, aggregation output) have a name for it.
|
|
91
|
+
*/
|
|
92
|
+
effectiveAmount?: number;
|
|
48
93
|
createdAt?: Date;
|
|
49
94
|
updatedAt?: Date;
|
|
50
95
|
}
|