@riocrypto/common-server 1.0.777 → 1.0.778
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.
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Country, Fiat, Processor, User } from "@riocrypto/common";
|
|
2
2
|
import { Mongoose } from "mongoose";
|
|
3
3
|
export declare const getPlatformAndPartnerFees: (mongoose: Mongoose, amountFiat: number, fiat: Fiat, processor: Processor, country: Country, discount: number, partnerId?: string, brokerId?: string, user?: User) => Promise<{
|
|
4
|
-
platformFeeFiat: number;
|
|
4
|
+
platformFeeFiat: number | undefined;
|
|
5
5
|
platformFeeFiatTax: number;
|
|
6
6
|
partnerFeeFiat: number;
|
|
7
7
|
feesComped: boolean;
|
|
@@ -61,6 +61,32 @@ const getPlatformAndPartnerFees = (mongoose, amountFiat, fiat, processor, countr
|
|
|
61
61
|
platformFeeFiat = amountFiat * netPlatformFee;
|
|
62
62
|
partnerFeeFiat = amountFiat * partner.partnerFee;
|
|
63
63
|
}
|
|
64
|
+
else if (brokerId) {
|
|
65
|
+
const User = (0, user_1.buildUser)(mongoose);
|
|
66
|
+
const brokerCustomer = yield User.findById(brokerId);
|
|
67
|
+
if (!brokerCustomer) {
|
|
68
|
+
throw new Error("Broker customer not found");
|
|
69
|
+
}
|
|
70
|
+
if (brokerCustomer === null || brokerCustomer === void 0 ? void 0 : brokerCustomer.platformFeeRanges) {
|
|
71
|
+
for (const range of brokerCustomer.platformFeeRanges) {
|
|
72
|
+
if (range.min <= Number(amountUSD) && range.max >= Number(amountUSD)) {
|
|
73
|
+
if (discount) {
|
|
74
|
+
if (discount > range.fee) {
|
|
75
|
+
throw new Error("Discount cannot be greater than platform fee");
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
const netFee = range.fee - discount;
|
|
79
|
+
platformFeeFiat = amountFiat * netFee;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
platformFeeFiat = amountFiat * range.fee;
|
|
84
|
+
}
|
|
85
|
+
break;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
64
90
|
else if (user === null || user === void 0 ? void 0 : user.platformFeeRanges) {
|
|
65
91
|
let volume;
|
|
66
92
|
if ((_a = user === null || user === void 0 ? void 0 : user.attributes) === null || _a === void 0 ? void 0 : _a.includes(common_1.UserAttribute.summedVolumeFees)) {
|
|
@@ -105,32 +131,6 @@ const getPlatformAndPartnerFees = (mongoose, amountFiat, fiat, processor, countr
|
|
|
105
131
|
platformFeeFiat = amountFiat * netPlatformFee;
|
|
106
132
|
partnerFeeFiat = 0;
|
|
107
133
|
}
|
|
108
|
-
if (brokerId && !platformFeeFiat) {
|
|
109
|
-
const User = (0, user_1.buildUser)(mongoose);
|
|
110
|
-
const brokerCustomer = yield User.findById(brokerId);
|
|
111
|
-
if (!brokerCustomer) {
|
|
112
|
-
throw new Error("Broker customer not found");
|
|
113
|
-
}
|
|
114
|
-
if (brokerCustomer === null || brokerCustomer === void 0 ? void 0 : brokerCustomer.platformFeeRanges) {
|
|
115
|
-
for (const range of brokerCustomer.platformFeeRanges) {
|
|
116
|
-
if (range.min <= Number(amountUSD) && range.max >= Number(amountUSD)) {
|
|
117
|
-
if (discount) {
|
|
118
|
-
if (discount > range.fee) {
|
|
119
|
-
throw new Error("Discount cannot be greater than platform fee");
|
|
120
|
-
}
|
|
121
|
-
else {
|
|
122
|
-
const netFee = range.fee - discount;
|
|
123
|
-
platformFeeFiat = amountFiat * netFee;
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
else {
|
|
127
|
-
platformFeeFiat = amountFiat * range.fee;
|
|
128
|
-
}
|
|
129
|
-
break;
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
134
|
if ((fiat === common_1.Fiat.MXN && processor === common_1.Processor.SPEI) ||
|
|
135
135
|
(fiat === common_1.Fiat.USD && processor === common_1.Processor.SPID)) {
|
|
136
136
|
if (country === common_1.Country.Mexico) {
|