@pax2pay/model-banking 0.1.218 → 0.1.219
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/Operation/Creatable.ts
CHANGED
|
@@ -37,7 +37,11 @@ export namespace Creatable {
|
|
|
37
37
|
export const is = type.is
|
|
38
38
|
export const flaw = type.flaw
|
|
39
39
|
export function fromRefund(account: string, entry: Settlement.Entry.Refund.Creatable, stack: Card.Stack): Creatable {
|
|
40
|
-
|
|
40
|
+
// The Entry.Refund.Creatable has negative amount and fee
|
|
41
|
+
// The operation amounts should always be positive
|
|
42
|
+
const [currency, entryAmount] = entry.amount
|
|
43
|
+
const operationAmount = Math.abs(entryAmount)
|
|
44
|
+
const operationFee = Math.abs(entry.fee.other[currency] ?? 0)
|
|
41
45
|
return {
|
|
42
46
|
account: account,
|
|
43
47
|
currency,
|
|
@@ -45,22 +49,22 @@ export namespace Creatable {
|
|
|
45
49
|
changes: {
|
|
46
50
|
actual: {
|
|
47
51
|
type: "add",
|
|
48
|
-
amount: isoly.Currency.add(currency,
|
|
52
|
+
amount: isoly.Currency.add(currency, operationAmount, operationFee),
|
|
49
53
|
status: "pending",
|
|
50
54
|
},
|
|
51
55
|
incomingReserved: {
|
|
52
56
|
type: "add",
|
|
53
|
-
amount: isoly.Currency.add(currency,
|
|
57
|
+
amount: isoly.Currency.add(currency, operationAmount, operationFee),
|
|
54
58
|
status: "pending",
|
|
55
59
|
},
|
|
56
60
|
[`fee_${stack}_${entry.batch}`]: {
|
|
57
61
|
type: "subtract" as const,
|
|
58
|
-
amount:
|
|
62
|
+
amount: operationFee,
|
|
59
63
|
status: "pending" as const,
|
|
60
64
|
},
|
|
61
65
|
[`settle_${stack}_${entry.batch}`]: {
|
|
62
66
|
type: "subtract" as const,
|
|
63
|
-
amount:
|
|
67
|
+
amount: operationAmount,
|
|
64
68
|
status: "pending" as const,
|
|
65
69
|
},
|
|
66
70
|
},
|
package/Transaction/Incoming.ts
CHANGED
|
@@ -23,7 +23,7 @@ export namespace Incoming {
|
|
|
23
23
|
return {
|
|
24
24
|
account: card,
|
|
25
25
|
currency,
|
|
26
|
-
amount: isoly.Currency.add(currency, amount, entry.fee.other[currency] ?? 0),
|
|
26
|
+
amount: isoly.Currency.add(currency, -amount, -(entry.fee.other[currency] ?? 0)),
|
|
27
27
|
posted: isoly.DateTime.now(),
|
|
28
28
|
counterpart: { type: "card", merchant: entry.merchant, acquirer: entry.acquirer },
|
|
29
29
|
description: "Refund transaction.",
|
|
@@ -27,7 +27,9 @@ export var Creatable;
|
|
|
27
27
|
Creatable.is = Creatable.type.is;
|
|
28
28
|
Creatable.flaw = Creatable.type.flaw;
|
|
29
29
|
function fromRefund(account, entry, stack) {
|
|
30
|
-
const [currency,
|
|
30
|
+
const [currency, entryAmount] = entry.amount;
|
|
31
|
+
const operationAmount = Math.abs(entryAmount);
|
|
32
|
+
const operationFee = Math.abs(entry.fee.other[currency] ?? 0);
|
|
31
33
|
return {
|
|
32
34
|
account: account,
|
|
33
35
|
currency,
|
|
@@ -35,22 +37,22 @@ export var Creatable;
|
|
|
35
37
|
changes: {
|
|
36
38
|
actual: {
|
|
37
39
|
type: "add",
|
|
38
|
-
amount: isoly.Currency.add(currency,
|
|
40
|
+
amount: isoly.Currency.add(currency, operationAmount, operationFee),
|
|
39
41
|
status: "pending",
|
|
40
42
|
},
|
|
41
43
|
incomingReserved: {
|
|
42
44
|
type: "add",
|
|
43
|
-
amount: isoly.Currency.add(currency,
|
|
45
|
+
amount: isoly.Currency.add(currency, operationAmount, operationFee),
|
|
44
46
|
status: "pending",
|
|
45
47
|
},
|
|
46
48
|
[`fee_${stack}_${entry.batch}`]: {
|
|
47
49
|
type: "subtract",
|
|
48
|
-
amount:
|
|
50
|
+
amount: operationFee,
|
|
49
51
|
status: "pending",
|
|
50
52
|
},
|
|
51
53
|
[`settle_${stack}_${entry.batch}`]: {
|
|
52
54
|
type: "subtract",
|
|
53
|
-
amount:
|
|
55
|
+
amount: operationAmount,
|
|
54
56
|
status: "pending",
|
|
55
57
|
},
|
|
56
58
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Creatable.js","sourceRoot":"../","sources":["Operation/Creatable.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,SAAS,CAAA;AAClC,OAAO,EAAE,KAAK,EAAE,MAAM,OAAO,CAAA;AAC7B,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAG3B,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AASnC,MAAM,KAAW,SAAS,
|
|
1
|
+
{"version":3,"file":"Creatable.js","sourceRoot":"../","sources":["Operation/Creatable.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,SAAS,CAAA;AAClC,OAAO,EAAE,KAAK,EAAE,MAAM,OAAO,CAAA;AAC7B,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAG3B,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AASnC,MAAM,KAAW,SAAS,CA0DzB;AA1DD,WAAiB,SAAS;IACZ,eAAK,GAAG;QACpB,UAAU;QACV,kBAAkB;QAClB,UAAU;QACV,kBAAkB;QAClB,eAAe;QACf,SAAS;QACT,QAAQ;QACR,QAAQ;QACR,QAAQ;QACR,QAAQ;QACR,SAAS;QACT,SAAS;KACA,CAAA;IAEG,cAAI,GAAG,IAAI,CAAC,MAAM,CAAY;QAC1C,OAAO,EAAE,IAAI,CAAC,MAAM,CAAC,oBAAoB,EAAE,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC;QACjE,QAAQ,EAAE,IAAI,CAAC,MAAM,CAAC,gBAAgB,EAAE,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC1D,OAAO,EAAE,OAAO,CAAC,IAAI;QACrB,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,UAAA,KAAK,CAAC;KACxB,CAAC,CAAA;IACW,YAAE,GAAG,UAAA,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
|
|
@@ -17,7 +17,7 @@ export var Incoming;
|
|
|
17
17
|
return {
|
|
18
18
|
account: card,
|
|
19
19
|
currency,
|
|
20
|
-
amount: isoly.Currency.add(currency, amount, entry.fee.other[currency] ?? 0),
|
|
20
|
+
amount: isoly.Currency.add(currency, -amount, -(entry.fee.other[currency] ?? 0)),
|
|
21
21
|
posted: isoly.DateTime.now(),
|
|
22
22
|
counterpart: { type: "card", merchant: entry.merchant, acquirer: entry.acquirer },
|
|
23
23
|
description: "Refund transaction.",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Incoming.js","sourceRoot":"../","sources":["Transaction/Incoming.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,OAAO,CAAA;AAC7B,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAC3B,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAA;AAE9B,OAAO,EAAE,SAAS,IAAI,oBAAoB,EAAE,MAAM,aAAa,CAAA;AAC/D,OAAO,EAAE,SAAS,IAAI,oBAAoB,EAAE,MAAM,aAAa,CAAA;AAO/D,MAAM,KAAW,QAAQ,CAmBxB;AAnBD,WAAiB,QAAQ;IACX,aAAI,GAAG,oBAAoB,CAAC,IAAI,CAAC,MAAM,CAAW;QAC9D,OAAO,EAAE,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,EAAE,CAAC;QACrC,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE;QACrB,SAAS,EAAE,oBAAoB,CAAC,IAAI,CAAC,QAAQ,EAAE;KAC/C,CAAC,CAAA;IACW,WAAE,GAAG,SAAA,IAAI,CAAC,EAAE,CAAA;IACZ,aAAI,GAAG,SAAA,IAAI,CAAC,IAAI,CAAA;IAC7B,SAAgB,UAAU,CAAC,KAAwC,EAAE,IAAe;QACnF,MAAM,CAAC,QAAQ,EAAE,MAAM,CAAC,GAAG,KAAK,CAAC,MAAM,CAAA;QACvC,OAAO;Y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