@amboras-dev/money 0.2.0 → 0.3.0
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/README.md +15 -8
- package/dist/ai.cjs +12 -13
- package/dist/ai.d.cts +5 -9
- package/dist/ai.d.ts +5 -9
- package/dist/ai.js +12 -13
- package/dist/{allocate-CZRg4TOP.cjs → allocate-AusholrC.cjs} +3 -4
- package/dist/{allocate-X7_jAtOj.js → allocate-BBRfdaSC.js} +3 -4
- package/dist/{amount-BV0O-aN8.cjs → amount-CwFzcxUl.cjs} +29 -12
- package/dist/{amount-BoYBMgK9.js → amount-DHFOK2Yd.js} +29 -12
- package/dist/{arithmetic-BhNwisjb.js → arithmetic-C97-YafD.js} +4 -5
- package/dist/{arithmetic-DjT4Kzgt.cjs → arithmetic-D8A6IeZ0.cjs} +4 -5
- package/dist/billing.cjs +5 -8
- package/dist/billing.d.cts +1 -9
- package/dist/billing.d.ts +1 -9
- package/dist/billing.js +5 -8
- package/dist/commerce.cjs +15 -23
- package/dist/commerce.d.cts +2 -16
- package/dist/commerce.d.ts +2 -16
- package/dist/commerce.js +15 -23
- package/dist/{format-DLhno7eX.cjs → format-92fzvTXY.cjs} +9 -9
- package/dist/{format-BdPnijvn.js → format-BJC513u4.js} +9 -9
- package/dist/fx.cjs +12 -18
- package/dist/fx.d.cts +5 -15
- package/dist/fx.d.ts +5 -15
- package/dist/fx.js +12 -18
- package/dist/index.cjs +10 -12
- package/dist/index.d.cts +17 -23
- package/dist/index.d.ts +17 -23
- package/dist/index.js +10 -12
- package/dist/input.cjs +7 -10
- package/dist/input.d.cts +9 -16
- package/dist/input.d.ts +9 -16
- package/dist/input.js +7 -10
- package/dist/{iso-minor-wSwJN57T.cjs → iso-minor-DyNjT9A1.cjs} +2 -3
- package/dist/{iso-minor-CqkWDxHS.js → iso-minor-odkY-e6I.js} +2 -3
- package/dist/{medusa-lRY9xlsf.cjs → medusa-CzVK0bth.cjs} +3 -4
- package/dist/{medusa-DBXJXXvF.d.ts → medusa-DofdvIgQ.d.cts} +1 -3
- package/dist/{medusa-4K8N1pUc.d.cts → medusa-DrbYmD2Y.d.ts} +1 -3
- package/dist/{medusa-DqJY1qpj.js → medusa-pKGlImn9.js} +3 -4
- package/dist/{money-B-3aFjNJ.d.cts → money-BkMeYDEW.d.cts} +0 -6
- package/dist/{money-B-3aFjNJ.d.ts → money-BkMeYDEW.d.ts} +0 -6
- package/dist/{money-WhnGiI00.js → money-BxbAw7BP.js} +7 -15
- package/dist/{money-B3wH_Z4S.cjs → money-DWBjuuEK.cjs} +7 -15
- package/dist/{number-text-DE-q4jO5.js → number-text-Bj-gZXiF.js} +3 -4
- package/dist/{number-text-BWu67jUq.cjs → number-text-CWuVwrlg.cjs} +3 -4
- package/dist/{own-oP9DXFWv.cjs → own-C5imDkyB.cjs} +1 -2
- package/dist/{own-D7544D3k.js → own-DHxqIYqL.js} +1 -2
- package/dist/{percent-D1VB9xXG.js → percent-CB3Ixjc_.js} +2 -3
- package/dist/{percent-C0InC2t2.cjs → percent-DABHiSBs.cjs} +2 -3
- package/dist/{rate-DBPiYgT1.d.ts → rate-BvvZUdSu.d.ts} +1 -3
- package/dist/{rate-tqK8ijG0.d.cts → rate-CEakW3ia.d.cts} +1 -3
- package/dist/{rate-CVeMii4a.cjs → rate-CEjWTATc.cjs} +3 -4
- package/dist/{rate-DicStBue.js → rate-D6S2_wgZ.js} +3 -4
- package/dist/{reporting-tpGJbqYp.d.ts → reporting-DFNyDBdi.d.cts} +2 -4
- package/dist/{reporting-CG-ai2sM.d.cts → reporting-jIBILvnr.d.ts} +2 -4
- package/dist/{retail-DRUTTQoJ.d.ts → retail-B04CjW3b.d.ts} +1 -3
- package/dist/{retail-Cml8YSKg.cjs → retail-CYGPU4ea.cjs} +4 -5
- package/dist/{retail-C_BPLvMj.d.cts → retail-CmEyJQOH.d.cts} +1 -3
- package/dist/{retail-1mu888J1.js → retail-DXgs11ov.js} +4 -5
- package/dist/{rounding-DHBtNCHG.cjs → rounding-4QKTRbMQ.cjs} +2 -3
- package/dist/{rounding-g9rvye0k.js → rounding-CA1PVP3b.js} +2 -3
- package/dist/sql.cjs +9 -15
- package/dist/sql.d.cts +2 -12
- package/dist/sql.d.ts +2 -12
- package/dist/sql.js +9 -15
- package/dist/testing.cjs +39198 -12
- package/dist/testing.d.cts +20 -13
- package/dist/testing.d.ts +20 -13
- package/dist/testing.js +39198 -13
- package/dist/{wire-sW0yzqth.js → wire-B4QU8O3W.js} +350 -93
- package/dist/{wire-CaUN9Vf_.d.ts → wire-CVNicirK.d.ts} +165 -46
- package/dist/{wire-xjYXv4go.d.cts → wire-CtNJmWVP.d.cts} +165 -46
- package/dist/{wire-Bhuut8cW.cjs → wire-u2tmHY0Y.cjs} +403 -92
- package/dist/wire.cjs +10 -1
- package/dist/wire.d.cts +2 -2
- package/dist/wire.d.ts +2 -2
- package/dist/wire.js +1 -2
- package/package.json +4 -3
package/dist/sql.cjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_money = require("./money-
|
|
3
|
-
const require_rate = require("./rate-
|
|
4
|
-
const require_retail = require("./retail-
|
|
5
|
-
|
|
2
|
+
const require_money = require("./money-DWBjuuEK.cjs");
|
|
3
|
+
const require_rate = require("./rate-CEjWTATc.cjs");
|
|
4
|
+
const require_retail = require("./retail-CYGPU4ea.cjs");
|
|
5
|
+
// src/sql/guard.ts
|
|
6
6
|
const STATEMENT_BREAKERS = /;|--|\/\*|\*\/|\0/;
|
|
7
7
|
const refuse = (name, value) => new require_money.MoneyError("parse", `${name} must be a SQL expression written in code, got ${require_money.describeValue(value)}`);
|
|
8
8
|
/** Code-written text, or `parse` when it is blank, could break out of the expression or holds a `?` placeholder. */
|
|
@@ -57,8 +57,7 @@ function dialectOf(value) {
|
|
|
57
57
|
if (value !== "pg" && value !== "clickhouse") throw new require_money.MoneyError("parse", `Unknown SQL dialect: ${require_money.describeValue(value)}`);
|
|
58
58
|
return value;
|
|
59
59
|
}
|
|
60
|
-
|
|
61
|
-
//#region src/sql/lists.ts
|
|
60
|
+
// src/sql/lists.ts
|
|
62
61
|
const quoted = (pick) => require_money.CURRENCIES.filter(pick).map((info) => `'${info.code}'`).join(",");
|
|
63
62
|
/** Storage scale 1000: `'BHD','IQD','JOD','KWD','LYD','OMR','TND'`. */
|
|
64
63
|
const SCALE_1000_CODES = quoted((info) => info.storageScale === 1e3);
|
|
@@ -70,8 +69,7 @@ const DISPLAY_3_CODES = quoted((info) => info.displayDigits === 3);
|
|
|
70
69
|
const MEDUSA_0_CODES = quoted((info) => info.medusaDigits === 0);
|
|
71
70
|
/** Medusa core `decimal_digits` 3 (payment-status epsilon 0.001). */
|
|
72
71
|
const MEDUSA_3_CODES = quoted((info) => info.medusaDigits === 3);
|
|
73
|
-
|
|
74
|
-
//#region src/sql/amounts.ts
|
|
72
|
+
// src/sql/amounts.ts
|
|
75
73
|
const CH_STORED_SCALE = 3;
|
|
76
74
|
const CH_ROUND_SCALE = 12;
|
|
77
75
|
/** The storage divisor of the currency in `codeExpr`, keyed by code (never `currency.decimal_digits`). */
|
|
@@ -145,8 +143,7 @@ function rawAmountJsonSql(expr) {
|
|
|
145
143
|
function normalizeCurrencySql(expr) {
|
|
146
144
|
return sql`lower(btrim(${expression(expr, "expr")}))`;
|
|
147
145
|
}
|
|
148
|
-
|
|
149
|
-
//#region src/sql/clickhouse.ts
|
|
146
|
+
// src/sql/clickhouse.ts
|
|
150
147
|
/**
|
|
151
148
|
* The SELECT list and GROUP BY of per-currency purchase revenue in stored units. The event name
|
|
152
149
|
* is a ClickHouse query parameter (`{revenue_event:String}`, pass `params` as `query_params`),
|
|
@@ -165,8 +162,7 @@ function chEventRevenueByCurrencySql(cols = {}) {
|
|
|
165
162
|
params: { revenue_event: event }
|
|
166
163
|
};
|
|
167
164
|
}
|
|
168
|
-
|
|
169
|
-
//#region src/sql/ddl.ts
|
|
165
|
+
// src/sql/ddl.ts
|
|
170
166
|
/** The column type of a stored amount. */
|
|
171
167
|
const STORAGE_AMOUNT_SQL_TYPE = "BIGINT";
|
|
172
168
|
/** A column for DDL, which Postgres never parameterises: a fragment with bindings is `parse`. */
|
|
@@ -208,8 +204,7 @@ function usdToCreditsSql(expr) {
|
|
|
208
204
|
function monthlyEquivalentSql(expr) {
|
|
209
205
|
return sql`ROUND((${expression(expr, "expr")})::numeric / 12)`;
|
|
210
206
|
}
|
|
211
|
-
|
|
212
|
-
//#region src/sql/fx.ts
|
|
207
|
+
// src/sql/fx.ts
|
|
213
208
|
function factorsJson(table) {
|
|
214
209
|
require_money.resolveCurrency(table?.base, { allowHistoric: true });
|
|
215
210
|
return JSON.stringify(table.factors);
|
|
@@ -268,7 +263,6 @@ function convertStoredByColumnsSql(amountExpr, cols) {
|
|
|
268
263
|
const whole = sql`(FLOOR(${x} / ${major}) * ${major})`;
|
|
269
264
|
return sql`(CASE WHEN ${retail} = 'none' THEN ${x} WHEN ${x} <= 0 THEN ${x} WHEN ${charm} IS NULL THEN CEIL(${x} / (100 * ${major})) * (100 * ${major}) WHEN ${x} <= ${whole} + ${charm} THEN ${whole} + ${charm} ELSE ${whole} + ${major} + ${charm} END)`;
|
|
270
265
|
}
|
|
271
|
-
//#endregion
|
|
272
266
|
exports.STORAGE_AMOUNT_SQL_TYPE = STORAGE_AMOUNT_SQL_TYPE;
|
|
273
267
|
exports.chEventRevenueByCurrencySql = chEventRevenueByCurrencySql;
|
|
274
268
|
exports.convertStoredByColumnsSql = convertStoredByColumnsSql;
|
package/dist/sql.d.cts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { r as Rate } from "./rate-
|
|
2
|
-
import { t as FactorTable } from "./reporting-
|
|
3
|
-
//#region src/sql/guard.d.ts
|
|
1
|
+
import { r as Rate } from "./rate-CEakW3ia.cjs";
|
|
2
|
+
import { t as FactorTable } from "./reporting-DFNyDBdi.cjs";
|
|
4
3
|
type SqlBinding = string | number;
|
|
5
4
|
/** Text with knex `?` placeholders and the values they bind, in order: `knex.raw(f.sql, f.bindings)`. */
|
|
6
5
|
interface SqlFragment {
|
|
@@ -10,8 +9,6 @@ interface SqlFragment {
|
|
|
10
9
|
/** An expression argument: SQL text written in code (a column reference), or a builder's SqlFragment. */
|
|
11
10
|
type SqlExpression = string | SqlFragment;
|
|
12
11
|
type SqlDialect = 'pg' | 'clickhouse';
|
|
13
|
-
//#endregion
|
|
14
|
-
//#region src/sql/amounts.d.ts
|
|
15
12
|
/** The storage divisor of the currency in `codeExpr`, keyed by code (never `currency.decimal_digits`). */
|
|
16
13
|
export declare function storageDivisorSql(codeExpr: SqlExpression, dialect?: SqlDialect): SqlFragment;
|
|
17
14
|
/**
|
|
@@ -51,8 +48,6 @@ export declare function summaryAmountSql(totalsExpr: SqlExpression, key: string,
|
|
|
51
48
|
export declare function rawAmountJsonSql(expr: SqlExpression): SqlFragment;
|
|
52
49
|
/** A currency code column normalised the way Medusa stores it. */
|
|
53
50
|
export declare function normalizeCurrencySql(expr: SqlExpression): SqlFragment;
|
|
54
|
-
//#endregion
|
|
55
|
-
//#region src/sql/clickhouse.d.ts
|
|
56
51
|
interface EventRevenueColumns {
|
|
57
52
|
/** Default `'value'` (stored units). */
|
|
58
53
|
readonly value?: string;
|
|
@@ -79,8 +74,6 @@ interface EventRevenueSql {
|
|
|
79
74
|
* (verified on 24.8).
|
|
80
75
|
*/
|
|
81
76
|
export declare function chEventRevenueByCurrencySql(cols?: EventRevenueColumns): EventRevenueSql;
|
|
82
|
-
//#endregion
|
|
83
|
-
//#region src/sql/ddl.d.ts
|
|
84
77
|
/** The column type of a stored amount. */
|
|
85
78
|
export declare const STORAGE_AMOUNT_SQL_TYPE = "BIGINT";
|
|
86
79
|
/** Lower-case three-letter currency codes only. */
|
|
@@ -108,8 +101,6 @@ export declare function storageAmountCheckSql(column: SqlExpression, options?: S
|
|
|
108
101
|
export declare function usdToCreditsSql(expr: SqlExpression): SqlFragment;
|
|
109
102
|
/** A yearly price as its monthly equivalent, half away from zero, the twin of `billing.monthlyEquivalent`. */
|
|
110
103
|
export declare function monthlyEquivalentSql(expr: SqlExpression): SqlFragment;
|
|
111
|
-
//#endregion
|
|
112
|
-
//#region src/sql/fx.d.ts
|
|
113
104
|
/**
|
|
114
105
|
* A stored amount in the currency of `codeExpr` converted with the bound factor table
|
|
115
106
|
* (`fx.storeFactors`): `output: 'stored'` rounds half away from zero to a storage unit of the
|
|
@@ -143,5 +134,4 @@ interface ConvertColumns {
|
|
|
143
134
|
}
|
|
144
135
|
/** `convertStoredSql` with the factor and rounding read from columns, so one statement converts many currencies. */
|
|
145
136
|
export declare function convertStoredByColumnsSql(amountExpr: SqlExpression, cols: ConvertColumns): SqlFragment;
|
|
146
|
-
//#endregion
|
|
147
137
|
export type { ConvertColumns, EventRevenueColumns, EventRevenueSql, SqlBinding, SqlDialect, SqlExpression, SqlFragment, StorageAmountCheckOptions };
|
package/dist/sql.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { r as Rate } from "./rate-
|
|
2
|
-
import { t as FactorTable } from "./reporting-
|
|
3
|
-
//#region src/sql/guard.d.ts
|
|
1
|
+
import { r as Rate } from "./rate-BvvZUdSu.js";
|
|
2
|
+
import { t as FactorTable } from "./reporting-jIBILvnr.js";
|
|
4
3
|
type SqlBinding = string | number;
|
|
5
4
|
/** Text with knex `?` placeholders and the values they bind, in order: `knex.raw(f.sql, f.bindings)`. */
|
|
6
5
|
interface SqlFragment {
|
|
@@ -10,8 +9,6 @@ interface SqlFragment {
|
|
|
10
9
|
/** An expression argument: SQL text written in code (a column reference), or a builder's SqlFragment. */
|
|
11
10
|
type SqlExpression = string | SqlFragment;
|
|
12
11
|
type SqlDialect = 'pg' | 'clickhouse';
|
|
13
|
-
//#endregion
|
|
14
|
-
//#region src/sql/amounts.d.ts
|
|
15
12
|
/** The storage divisor of the currency in `codeExpr`, keyed by code (never `currency.decimal_digits`). */
|
|
16
13
|
export declare function storageDivisorSql(codeExpr: SqlExpression, dialect?: SqlDialect): SqlFragment;
|
|
17
14
|
/**
|
|
@@ -51,8 +48,6 @@ export declare function summaryAmountSql(totalsExpr: SqlExpression, key: string,
|
|
|
51
48
|
export declare function rawAmountJsonSql(expr: SqlExpression): SqlFragment;
|
|
52
49
|
/** A currency code column normalised the way Medusa stores it. */
|
|
53
50
|
export declare function normalizeCurrencySql(expr: SqlExpression): SqlFragment;
|
|
54
|
-
//#endregion
|
|
55
|
-
//#region src/sql/clickhouse.d.ts
|
|
56
51
|
interface EventRevenueColumns {
|
|
57
52
|
/** Default `'value'` (stored units). */
|
|
58
53
|
readonly value?: string;
|
|
@@ -79,8 +74,6 @@ interface EventRevenueSql {
|
|
|
79
74
|
* (verified on 24.8).
|
|
80
75
|
*/
|
|
81
76
|
export declare function chEventRevenueByCurrencySql(cols?: EventRevenueColumns): EventRevenueSql;
|
|
82
|
-
//#endregion
|
|
83
|
-
//#region src/sql/ddl.d.ts
|
|
84
77
|
/** The column type of a stored amount. */
|
|
85
78
|
export declare const STORAGE_AMOUNT_SQL_TYPE = "BIGINT";
|
|
86
79
|
/** Lower-case three-letter currency codes only. */
|
|
@@ -108,8 +101,6 @@ export declare function storageAmountCheckSql(column: SqlExpression, options?: S
|
|
|
108
101
|
export declare function usdToCreditsSql(expr: SqlExpression): SqlFragment;
|
|
109
102
|
/** A yearly price as its monthly equivalent, half away from zero, the twin of `billing.monthlyEquivalent`. */
|
|
110
103
|
export declare function monthlyEquivalentSql(expr: SqlExpression): SqlFragment;
|
|
111
|
-
//#endregion
|
|
112
|
-
//#region src/sql/fx.d.ts
|
|
113
104
|
/**
|
|
114
105
|
* A stored amount in the currency of `codeExpr` converted with the bound factor table
|
|
115
106
|
* (`fx.storeFactors`): `output: 'stored'` rounds half away from zero to a storage unit of the
|
|
@@ -143,5 +134,4 @@ interface ConvertColumns {
|
|
|
143
134
|
}
|
|
144
135
|
/** `convertStoredSql` with the factor and rounding read from columns, so one statement converts many currencies. */
|
|
145
136
|
export declare function convertStoredByColumnsSql(amountExpr: SqlExpression, cols: ConvertColumns): SqlFragment;
|
|
146
|
-
//#endregion
|
|
147
137
|
export type { ConvertColumns, EventRevenueColumns, EventRevenueSql, SqlBinding, SqlDialect, SqlExpression, SqlFragment, StorageAmountCheckOptions };
|
package/dist/sql.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { $ as describeValue, A as storageScale, E as resolveCurrency, Q as MoneyError, u as CURRENCIES } from "./money-
|
|
2
|
-
import { r as checkRate } from "./rate-
|
|
3
|
-
import { t as priceRoundingParams } from "./retail-
|
|
4
|
-
|
|
1
|
+
import { $ as describeValue, A as storageScale, E as resolveCurrency, Q as MoneyError, u as CURRENCIES } from "./money-BxbAw7BP.js";
|
|
2
|
+
import { r as checkRate } from "./rate-D6S2_wgZ.js";
|
|
3
|
+
import { t as priceRoundingParams } from "./retail-DXgs11ov.js";
|
|
4
|
+
// src/sql/guard.ts
|
|
5
5
|
const STATEMENT_BREAKERS = /;|--|\/\*|\*\/|\0/;
|
|
6
6
|
const refuse = (name, value) => new MoneyError("parse", `${name} must be a SQL expression written in code, got ${describeValue(value)}`);
|
|
7
7
|
/** Code-written text, or `parse` when it is blank, could break out of the expression or holds a `?` placeholder. */
|
|
@@ -56,8 +56,7 @@ function dialectOf(value) {
|
|
|
56
56
|
if (value !== "pg" && value !== "clickhouse") throw new MoneyError("parse", `Unknown SQL dialect: ${describeValue(value)}`);
|
|
57
57
|
return value;
|
|
58
58
|
}
|
|
59
|
-
|
|
60
|
-
//#region src/sql/lists.ts
|
|
59
|
+
// src/sql/lists.ts
|
|
61
60
|
const quoted = (pick) => CURRENCIES.filter(pick).map((info) => `'${info.code}'`).join(",");
|
|
62
61
|
/** Storage scale 1000: `'BHD','IQD','JOD','KWD','LYD','OMR','TND'`. */
|
|
63
62
|
const SCALE_1000_CODES = quoted((info) => info.storageScale === 1e3);
|
|
@@ -69,8 +68,7 @@ const DISPLAY_3_CODES = quoted((info) => info.displayDigits === 3);
|
|
|
69
68
|
const MEDUSA_0_CODES = quoted((info) => info.medusaDigits === 0);
|
|
70
69
|
/** Medusa core `decimal_digits` 3 (payment-status epsilon 0.001). */
|
|
71
70
|
const MEDUSA_3_CODES = quoted((info) => info.medusaDigits === 3);
|
|
72
|
-
|
|
73
|
-
//#region src/sql/amounts.ts
|
|
71
|
+
// src/sql/amounts.ts
|
|
74
72
|
const CH_STORED_SCALE = 3;
|
|
75
73
|
const CH_ROUND_SCALE = 12;
|
|
76
74
|
/** The storage divisor of the currency in `codeExpr`, keyed by code (never `currency.decimal_digits`). */
|
|
@@ -144,8 +142,7 @@ function rawAmountJsonSql(expr) {
|
|
|
144
142
|
function normalizeCurrencySql(expr) {
|
|
145
143
|
return sql`lower(btrim(${expression(expr, "expr")}))`;
|
|
146
144
|
}
|
|
147
|
-
|
|
148
|
-
//#region src/sql/clickhouse.ts
|
|
145
|
+
// src/sql/clickhouse.ts
|
|
149
146
|
/**
|
|
150
147
|
* The SELECT list and GROUP BY of per-currency purchase revenue in stored units. The event name
|
|
151
148
|
* is a ClickHouse query parameter (`{revenue_event:String}`, pass `params` as `query_params`),
|
|
@@ -164,8 +161,7 @@ function chEventRevenueByCurrencySql(cols = {}) {
|
|
|
164
161
|
params: { revenue_event: event }
|
|
165
162
|
};
|
|
166
163
|
}
|
|
167
|
-
|
|
168
|
-
//#region src/sql/ddl.ts
|
|
164
|
+
// src/sql/ddl.ts
|
|
169
165
|
/** The column type of a stored amount. */
|
|
170
166
|
const STORAGE_AMOUNT_SQL_TYPE = "BIGINT";
|
|
171
167
|
/** A column for DDL, which Postgres never parameterises: a fragment with bindings is `parse`. */
|
|
@@ -207,8 +203,7 @@ function usdToCreditsSql(expr) {
|
|
|
207
203
|
function monthlyEquivalentSql(expr) {
|
|
208
204
|
return sql`ROUND((${expression(expr, "expr")})::numeric / 12)`;
|
|
209
205
|
}
|
|
210
|
-
|
|
211
|
-
//#region src/sql/fx.ts
|
|
206
|
+
// src/sql/fx.ts
|
|
212
207
|
function factorsJson(table) {
|
|
213
208
|
resolveCurrency(table?.base, { allowHistoric: true });
|
|
214
209
|
return JSON.stringify(table.factors);
|
|
@@ -267,5 +262,4 @@ function convertStoredByColumnsSql(amountExpr, cols) {
|
|
|
267
262
|
const whole = sql`(FLOOR(${x} / ${major}) * ${major})`;
|
|
268
263
|
return sql`(CASE WHEN ${retail} = 'none' THEN ${x} WHEN ${x} <= 0 THEN ${x} WHEN ${charm} IS NULL THEN CEIL(${x} / (100 * ${major})) * (100 * ${major}) WHEN ${x} <= ${whole} + ${charm} THEN ${whole} + ${charm} ELSE ${whole} + ${major} + ${charm} END)`;
|
|
269
264
|
}
|
|
270
|
-
//#endregion
|
|
271
265
|
export { STORAGE_AMOUNT_SQL_TYPE, chEventRevenueByCurrencySql, convertStoredByColumnsSql, convertStoredSql, currencyCodeCheckSql, medusaEpsilonSql, monthlyEquivalentSql, normalizeCurrencySql, parseDecimalSql, rawAmountJsonSql, reportingCompleteSql, roundMajorSql, storageAmountCheckSql, storageDivisorSql, storedToMajorSql, summaryAmountSql, toReportingSql, usdToCreditsSql, withinEpsilonSql };
|