@riocrypto/common-server 1.0.744 → 1.0.746

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,6 +1,6 @@
1
1
  import { 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, brokerId?: string, user?: User) => Promise<{
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
4
  platformFeeFiat: number;
5
5
  platformFeeFiatTax: number;
6
6
  partnerFeeFiat: number;
@@ -17,7 +17,7 @@ const currency_api_client_1 = require("../clients/currency-api-client");
17
17
  const partner_1 = require("../models/partner");
18
18
  const user_1 = require("../models/user");
19
19
  const calculate_aggregate_volume_1 = require("./calculate-aggregate-volume");
20
- const getPlatformAndPartnerFees = (mongoose, amountFiat, fiat, processor, country, partnerId, brokerId, user) => __awaiter(void 0, void 0, void 0, function* () {
20
+ const getPlatformAndPartnerFees = (mongoose, amountFiat, fiat, processor, country, discount, partnerId, brokerId, user) => __awaiter(void 0, void 0, void 0, function* () {
21
21
  var _a;
22
22
  let platformFeeFiat;
23
23
  let platformFeeFiatTax = 0;
@@ -68,7 +68,18 @@ const getPlatformAndPartnerFees = (mongoose, amountFiat, fiat, processor, countr
68
68
  }
69
69
  for (const range of user.platformFeeRanges) {
70
70
  if (range.min <= Number(volume) && range.max >= Number(volume)) {
71
- platformFeeFiat = amountFiat * range.fee;
71
+ if (discount) {
72
+ if (discount > range.fee) {
73
+ throw new Error("Discount cannot be greater than platform fee");
74
+ }
75
+ else {
76
+ const netFee = range.fee - discount;
77
+ platformFeeFiat = amountFiat * netFee;
78
+ }
79
+ }
80
+ else {
81
+ platformFeeFiat = amountFiat * range.fee;
82
+ }
72
83
  break;
73
84
  }
74
85
  }
@@ -25,7 +25,7 @@ interface OrderAttrs {
25
25
  brokerId?: string;
26
26
  conversionRateToUSD?: number;
27
27
  notes?: string;
28
- discountBPS?: number;
28
+ discount?: number;
29
29
  }
30
30
  interface OrderDoc extends Document {
31
31
  userId: string;
@@ -52,7 +52,7 @@ interface OrderDoc extends Document {
52
52
  brokerId?: string;
53
53
  conversionRateToUSD?: number;
54
54
  notes?: string;
55
- discountBPS?: number;
55
+ discount?: number;
56
56
  }
57
57
  interface OrderModel extends Model<OrderDoc> {
58
58
  build(attrs: OrderAttrs): OrderDoc;
@@ -102,7 +102,7 @@ const buildOrder = (mongoose) => {
102
102
  notes: {
103
103
  type: String,
104
104
  },
105
- discountBPS: {
105
+ discount: {
106
106
  type: Number,
107
107
  },
108
108
  }, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@riocrypto/common-server",
3
- "version": "1.0.744",
3
+ "version": "1.0.746",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",
@@ -24,7 +24,7 @@
24
24
  "@aws-sdk/client-s3": "^3.297.0",
25
25
  "@everapi/currencyapi-js": "^1.0.6",
26
26
  "@google-cloud/storage": "^6.9.5",
27
- "@riocrypto/common": "^1.0.661",
27
+ "@riocrypto/common": "^1.0.663",
28
28
  "@types/express": "^4.17.13",
29
29
  "axios": "^0.27.2",
30
30
  "ccxt": "^3.0.30",