@riocrypto/common-server 1.0.635 → 1.0.637
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,5 +1,6 @@
|
|
|
1
1
|
import { BusinessUser, Country, Fiat, Processor, User } from "@riocrypto/common";
|
|
2
|
-
|
|
2
|
+
import { Mongoose } from "mongoose";
|
|
3
|
+
export declare const getPlatformAndPartnerFees: (mongoose: Mongoose, amountFiat: number, fiat: Fiat, processor: Processor, country: Country, partnerId?: string, brokerCustomerId?: string, user?: BusinessUser | User) => Promise<{
|
|
3
4
|
platformFeeFiat: number;
|
|
4
5
|
platformFeeFiatTax: number;
|
|
5
6
|
partnerFeeFiat: number;
|
|
@@ -8,25 +8,21 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
12
|
exports.getPlatformAndPartnerFees = void 0;
|
|
16
13
|
const rio_settings_1 = require("../models/rio-settings");
|
|
17
|
-
const mongoose_1 = __importDefault(require("mongoose"));
|
|
18
14
|
const common_1 = require("@riocrypto/common");
|
|
19
15
|
const kapstar_client_1 = require("../clients/kapstar-client");
|
|
20
16
|
const currency_api_client_1 = require("../clients/currency-api-client");
|
|
21
17
|
const partner_1 = require("../models/partner");
|
|
22
18
|
const business_user_1 = require("../models/business-user");
|
|
23
|
-
const getPlatformAndPartnerFees = (amountFiat, fiat, processor, country, partnerId, brokerCustomerId, user) => __awaiter(void 0, void 0, void 0, function* () {
|
|
19
|
+
const getPlatformAndPartnerFees = (mongoose, amountFiat, fiat, processor, country, partnerId, brokerCustomerId, user) => __awaiter(void 0, void 0, void 0, function* () {
|
|
24
20
|
let platformFeeFiat = 0;
|
|
25
21
|
let platformFeeFiatTax = 0;
|
|
26
22
|
let partnerFeeFiat = 0;
|
|
27
23
|
let amountUSD;
|
|
28
24
|
let conversionRateToUSD = 0;
|
|
29
|
-
const RioSettings = (0, rio_settings_1.buildRioSettings)(
|
|
25
|
+
const RioSettings = (0, rio_settings_1.buildRioSettings)(mongoose);
|
|
30
26
|
const rioSettings = yield RioSettings.findOne();
|
|
31
27
|
if (!rioSettings) {
|
|
32
28
|
throw new common_1.RioSettingsNotFoundError();
|
|
@@ -47,7 +43,7 @@ const getPlatformAndPartnerFees = (amountFiat, fiat, processor, country, partner
|
|
|
47
43
|
throw new Error("Could not convert amount to USD");
|
|
48
44
|
}
|
|
49
45
|
if (partnerId) {
|
|
50
|
-
const Partner = (0, partner_1.buildPartner)(
|
|
46
|
+
const Partner = (0, partner_1.buildPartner)(mongoose);
|
|
51
47
|
const partner = yield Partner.findById(partnerId);
|
|
52
48
|
if (!partner) {
|
|
53
49
|
throw new common_1.PartnerNotFoundError();
|
|
@@ -73,7 +69,7 @@ const getPlatformAndPartnerFees = (amountFiat, fiat, processor, country, partner
|
|
|
73
69
|
partnerFeeFiat = 0;
|
|
74
70
|
}
|
|
75
71
|
if (brokerCustomerId) {
|
|
76
|
-
const BusinessUser = (0, business_user_1.buildBusinessUser)(
|
|
72
|
+
const BusinessUser = (0, business_user_1.buildBusinessUser)(mongoose);
|
|
77
73
|
const brokerCustomer = yield BusinessUser.findById(brokerCustomerId);
|
|
78
74
|
if (!brokerCustomer) {
|
|
79
75
|
throw new Error("Business user not found");
|