@ancha-labs/cli 0.4.13 → 0.4.14
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/lib/ancha.mjs +67 -19
- package/lib/assets/harbor/companion.mjs +17 -7
- package/lib/assets/harbor/suiteql-worker.mjs +12 -2
- package/lib/mcp-entry.mjs +4 -1
- package/lib/suiteql-worker.mjs +12 -2
- package/lib/worker.mjs +39 -12
- package/lib/world-server.mjs +17 -7
- package/package.json +1 -1
package/lib/ancha.mjs
CHANGED
|
@@ -33885,6 +33885,15 @@ var init_carrier_portal = __esm({
|
|
|
33885
33885
|
}
|
|
33886
33886
|
});
|
|
33887
33887
|
|
|
33888
|
+
// packages/core/src/tools/netsuite-money.ts
|
|
33889
|
+
var netsuiteRound;
|
|
33890
|
+
var init_netsuite_money = __esm({
|
|
33891
|
+
"packages/core/src/tools/netsuite-money.ts"() {
|
|
33892
|
+
"use strict";
|
|
33893
|
+
netsuiteRound = (value5) => Math.sign(value5) * Math.round(Number(`${Math.abs(value5).toFixed(10)}e2`)) / 100 || 0;
|
|
33894
|
+
}
|
|
33895
|
+
});
|
|
33896
|
+
|
|
33888
33897
|
// packages/core/src/tools/netsuite.ts
|
|
33889
33898
|
function recordNamer(seed43) {
|
|
33890
33899
|
const symbols = new Map(seed43.currencies.map((c) => [c.id, c.symbol ?? c.name]));
|
|
@@ -33948,7 +33957,7 @@ function checkSeed(seed43, report9) {
|
|
|
33948
33957
|
}
|
|
33949
33958
|
function books(seed43, issue6, money18) {
|
|
33950
33959
|
if (seed43.integration.customerCreditLimitHandlingOverride && !seed43.policy.allowCustomerCreditLimitHandlingOverride) issue6(["integration", "customerCreditLimitHandlingOverride"], "credit handling override requires policy permission");
|
|
33951
|
-
const round24 =
|
|
33960
|
+
const round24 = netsuiteRound;
|
|
33952
33961
|
const accountById = new Map(seed43.accounts.map((a) => [a.id, a])), itemById = new Map(seed43.items.map((i) => [i.id, i]));
|
|
33953
33962
|
const itemTotal = (lines3) => round24(lines3.reduce((sum6, line2) => sum6 + round24(line2.quantity * (line2.rate ?? itemById.get(line2.item)?.rate ?? 0)), 0));
|
|
33954
33963
|
const buyTotal = (lines3) => round24(lines3.reduce((sum6, line2) => sum6 + round24(line2.quantity * (line2.rate ?? itemById.get(line2.item)?.cost ?? itemById.get(line2.item)?.rate ?? 0)), 0));
|
|
@@ -34494,6 +34503,7 @@ var init_netsuite = __esm({
|
|
|
34494
34503
|
"packages/core/src/tools/netsuite.ts"() {
|
|
34495
34504
|
"use strict";
|
|
34496
34505
|
init_zod();
|
|
34506
|
+
init_netsuite_money();
|
|
34497
34507
|
NETSUITE_ACCOUNT_TYPES = [
|
|
34498
34508
|
"Bank",
|
|
34499
34509
|
"AcctRec",
|
|
@@ -45122,6 +45132,7 @@ var init_evals = __esm({
|
|
|
45122
45132
|
"packages/core/src/datasets/netsuite-pe/evals.ts"() {
|
|
45123
45133
|
"use strict";
|
|
45124
45134
|
init_netsuite();
|
|
45135
|
+
init_netsuite_money();
|
|
45125
45136
|
DAY = 864e5;
|
|
45126
45137
|
MONTHS2 = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
|
|
45127
45138
|
cents3 = (value5) => Math.round(value5 * 100);
|
|
@@ -45139,7 +45150,7 @@ var init_evals = __esm({
|
|
|
45139
45150
|
money8 = (code5, value5) => `${code5} ${grouped(Math.round(value5))}`;
|
|
45140
45151
|
byText = (x, y) => x < y ? -1 : x > y ? 1 : 0;
|
|
45141
45152
|
count2 = (n2, one7, many = `${one7}s`) => `${n2} ${n2 === 1 ? one7 : many}`;
|
|
45142
|
-
inBase = (value5, rate) => rate === 1 ? value5 : Math.round(
|
|
45153
|
+
inBase = (value5, rate) => rate === 1 ? value5 : Math.round(netsuiteRound(value5 / 100 * rate) * 100);
|
|
45143
45154
|
companyKey = (name5) => name5.toUpperCase().replace(/&/g, "AND").replace(/[^A-Z0-9]/g, "").replace(/(INC|LLC|CO|CORP|COMPANY|GROUP|PARTNERS|LTD)$/, "");
|
|
45144
45155
|
KEY_SQL = (column) => `REGEXP_REPLACE(REGEXP_REPLACE(UPPER(REPLACE(${column}, '&', 'AND')), '[^A-Z0-9]', ''), '(INC|LLC|CO|CORP|COMPANY|GROUP|PARTNERS|LTD)$', '')`;
|
|
45145
45156
|
}
|
|
@@ -47020,7 +47031,7 @@ var init_netsuite_pe = __esm({
|
|
|
47020
47031
|
init_generate();
|
|
47021
47032
|
init_names();
|
|
47022
47033
|
init_evals();
|
|
47023
|
-
NETSUITE_PE_VERSION = "1.0.
|
|
47034
|
+
NETSUITE_PE_VERSION = "1.0.1";
|
|
47024
47035
|
NETSUITE_PE_START_TIME = "2026-11-02T14:00:00Z";
|
|
47025
47036
|
NETSUITE_PE_DATASET = {
|
|
47026
47037
|
kind: "generated",
|
|
@@ -166905,14 +166916,14 @@ CREATE VIEW ns_q_transaction AS SELECT t.id, t.tranid, t.trandate, t.type, t.rec
|
|
|
166905
166916
|
CREATE VIEW ns_q_transactionline AS
|
|
166906
166917
|
-- Reserve four digits for the line; transaction IDs up to 2000000000 stay below 2^53.
|
|
166907
166918
|
SELECT 0 AS id, t.id * 10000 AS uniquekey, t.id AS "transaction", 0 AS linesequencenumber, 'T' AS mainline, 'F' AS taxline, NULL AS item, NULL AS itemtype, NULL AS quantity,
|
|
166908
|
-
NULL AS rate,
|
|
166919
|
+
NULL AS rate, ns_round(${signed("t.total", 0)} * t.exchangerate) AS netamount, ${signed("t.total", 0)} AS foreignamount, t.memo, NULL AS expenseaccount, t.account, t.entity, t.subsidiary,
|
|
166909
166920
|
t.department, t.location, t.class, t.createdfrom, 'F' AS isclosed,
|
|
166910
166921
|
NULL AS debit, NULL AS credit, NULL AS quantitybilled, NULL AS quantityshiprecv, NULL AS quantitycommitted, NULL AS category, NULL AS costestimate, t.extra, 'F' AS iscogs
|
|
166911
166922
|
FROM ns_transactions t WHERE t.type <> 'Journal'
|
|
166912
166923
|
UNION ALL
|
|
166913
166924
|
SELECT l.line AS id, l."transaction" * 10000 + l.line AS uniquekey, l."transaction", l.line, 'F', 'F', l.item, i.itemtype,
|
|
166914
166925
|
${signed("l.quantity", 2)}, l.rate,
|
|
166915
|
-
|
|
166926
|
+
ns_round(CASE WHEN t.type = 'Journal' THEN COALESCE(l.debit, 0) - COALESCE(l.credit, 0) WHEN t.type IN ('ItemShip', 'ItemRcpt') THEN NULL ELSE ${signed("l.amount", 1)} END * t.exchangerate),
|
|
166916
166927
|
CASE WHEN t.type = 'Journal' THEN COALESCE(l.debit, 0) - COALESCE(l.credit, 0) WHEN t.type IN ('ItemShip', 'ItemRcpt') THEN NULL ELSE ${signed("l.amount", 1)} END,
|
|
166917
166928
|
COALESCE(l.memo, l.description), l.account, l.account, COALESCE(l.entity, t.entity), t.subsidiary, COALESCE(l.department, t.department),
|
|
166918
166929
|
COALESCE(l.location, t.location), COALESCE(l.class, t.class), l.createdfrom, ${bool8("l.isclosed")}, l.debit, l.credit,
|
|
@@ -167389,6 +167400,19 @@ CREATE VIEW ns_q_mediaitemfolder AS SELECT id, name, parent, description, datecr
|
|
|
167389
167400
|
}
|
|
167390
167401
|
});
|
|
167391
167402
|
|
|
167403
|
+
// packages/server/src/twins/netsuite/money.ts
|
|
167404
|
+
function registerRound(db3) {
|
|
167405
|
+
db3.function("ns_round", { deterministic: true }, (value5) => value5 === null || value5 === void 0 ? null : round(Number(value5)));
|
|
167406
|
+
}
|
|
167407
|
+
var round;
|
|
167408
|
+
var init_money = __esm({
|
|
167409
|
+
"packages/server/src/twins/netsuite/money.ts"() {
|
|
167410
|
+
"use strict";
|
|
167411
|
+
init_netsuite_money();
|
|
167412
|
+
round = netsuiteRound;
|
|
167413
|
+
}
|
|
167414
|
+
});
|
|
167415
|
+
|
|
167392
167416
|
// packages/server/src/twins/netsuite/banking-schema.ts
|
|
167393
167417
|
var isBanking, read5, list16, BANK_FIELDS, BANK_LINES;
|
|
167394
167418
|
var init_banking_schema = __esm({
|
|
@@ -169972,6 +169996,7 @@ function sql2(ctx) {
|
|
|
169972
169996
|
upgradeSchema(db3);
|
|
169973
169997
|
const registered = { clock: ctx.clock };
|
|
169974
169998
|
db3.function("ns_today", { deterministic: false }, () => registered.clock.now().toISOString().slice(0, 10));
|
|
169999
|
+
registerRound(db3);
|
|
169975
170000
|
clocks.set(db3, holder = registered);
|
|
169976
170001
|
}
|
|
169977
170002
|
holder.clock = ctx.clock;
|
|
@@ -170730,13 +170755,14 @@ function dumpState41(ctx) {
|
|
|
170730
170755
|
records: db3.prepare("SELECT type, id, externalid, fields FROM ns_records ORDER BY type, id").all().map((r2) => clean({ type: r2.type, id: r2.id, externalId: r2.externalid, fields: json31(r2.fields) }))
|
|
170731
170756
|
};
|
|
170732
170757
|
}
|
|
170733
|
-
var RECORD_ROOT, LIST_KINDS, isTx, isItem, isEntity, isList, customerOf, vendorOf, AR, AP, FUNDS, BANK2, TX, TX_CODE, TX_LABEL, ORDERS, sublistsOf, r, w, ref21, HOLD, statusOptions, MONEY, SEGMENTS2, DATED, ENTITY, ITEM_COMMON, LIST_FIELDS, TX_BASE, party2, ADDRESSES, SALE, order4, FIELDS3, LINE_SEGMENTS, ITEM_LINE, LINE_FIELDS, clocks, today, stamp5,
|
|
170758
|
+
var RECORD_ROOT, LIST_KINDS, isTx, isItem, isEntity, isList, customerOf, vendorOf, AR, AP, FUNDS, BANK2, TX, TX_CODE, TX_LABEL, ORDERS, sublistsOf, r, w, ref21, HOLD, statusOptions, MONEY, SEGMENTS2, DATED, ENTITY, ITEM_COMMON, LIST_FIELDS, TX_BASE, party2, ADDRESSES, SALE, order4, FIELDS3, LINE_SEGMENTS, ITEM_LINE, LINE_FIELDS, clocks, today, stamp5, qty, addDays2, json31, config10, customFields2, entityRow, itemRow, txRow, listRow, periodRow, lineRows, allLines, unpaid, unapplied, applications, listName, termDays2, firstList, accountOfType, accountType, movesStock, nextTranId, statusText, href, selfLink, entityName, accountName, option3, PASSTHROUGH, docOpen, payable, addressBookLines, extraOwner;
|
|
170734
170759
|
var init_store5 = __esm({
|
|
170735
170760
|
"packages/server/src/twins/netsuite/store.ts"() {
|
|
170736
170761
|
"use strict";
|
|
170737
170762
|
init_open_items();
|
|
170738
170763
|
init_netsuite();
|
|
170739
170764
|
init_schema7();
|
|
170765
|
+
init_money();
|
|
170740
170766
|
init_banking_schema();
|
|
170741
170767
|
init_banking();
|
|
170742
170768
|
init_errors6();
|
|
@@ -171057,7 +171083,6 @@ var init_store5 = __esm({
|
|
|
171057
171083
|
clocks = /* @__PURE__ */ new WeakMap();
|
|
171058
171084
|
today = (ctx) => ctx.clock.now().toISOString().slice(0, 10);
|
|
171059
171085
|
stamp5 = (ctx) => ctx.clock.now().toISOString().replace(/\.\d{3}Z$/, "Z");
|
|
171060
|
-
round = (value5) => Math.sign(value5) * Math.round(Number(`${Math.abs(value5).toFixed(10)}e2`)) / 100 || 0;
|
|
171061
171086
|
qty = (value5) => Math.round(value5 * 1e8) / 1e8;
|
|
171062
171087
|
addDays2 = (date11, days) => new Date(Date.parse(`${date11}T00:00:00Z`) + days * 864e5).toISOString().slice(0, 10);
|
|
171063
171088
|
json31 = (text29) => {
|
|
@@ -171620,6 +171645,7 @@ function* matches7(re, source, position) {
|
|
|
171620
171645
|
}
|
|
171621
171646
|
}
|
|
171622
171647
|
function installFunctions(db3, hierarchy) {
|
|
171648
|
+
registerRound(db3);
|
|
171623
171649
|
const register4 = (name5, fn) => {
|
|
171624
171650
|
db3.function(`ns_suiteql_${name5}`, { deterministic: true, varargs: true }, fn);
|
|
171625
171651
|
};
|
|
@@ -171898,6 +171924,7 @@ var init_suiteql = __esm({
|
|
|
171898
171924
|
"packages/server/src/twins/netsuite/suiteql.ts"() {
|
|
171899
171925
|
"use strict";
|
|
171900
171926
|
init_schema7();
|
|
171927
|
+
init_money();
|
|
171901
171928
|
SuiteqlError = class extends Error {
|
|
171902
171929
|
gap;
|
|
171903
171930
|
constructor(message7, gap6 = false) {
|
|
@@ -173984,10 +174011,10 @@ function balanceSheet(ctx, p2) {
|
|
|
173984
174011
|
}
|
|
173985
174012
|
function openItems2(ctx, side, to, subsidiary) {
|
|
173986
174013
|
return sql2(ctx).prepare(`SELECT t.id,t.type,t.tranid,t.trandate,t.duedate,i.entity,t.otherrefnum,
|
|
173987
|
-
|
|
174014
|
+
ns_round(SUM((i.original - COALESCE((SELECT SUM(a.amount) FROM ns_applications a JOIN ns_transactions owner ON owner.id=a.payment
|
|
173988
174015
|
WHERE owner.trandate<=@to AND ((i.role='debt' AND a.doc=i.doc AND a.docline=i.line) OR (i.role='credit' AND a.source=i.doc AND a.sourceline=i.line))),0)
|
|
173989
174016
|
- CASE WHEN i.role='credit' THEN COALESCE((SELECT SUM(a.amount) FROM ns_applications a JOIN ns_transactions owner ON owner.id=a.payment WHERE owner.trandate<=@to AND a.doc=i.doc AND a.docline=i.line),0) ELSE 0 END)
|
|
173990
|
-
* CASE i.role WHEN 'debt' THEN 1 ELSE -1 END * t.exchangerate)
|
|
174017
|
+
* CASE i.role WHEN 'debt' THEN 1 ELSE -1 END * t.exchangerate)) AS open
|
|
173991
174018
|
FROM ns_item_original i JOIN ns_transactions t ON t.id=i.doc WHERE i.side=@side AND t.trandate<=@to AND (@subsidiary IS NULL OR i.subsidiary=@subsidiary)
|
|
173992
174019
|
GROUP BY i.doc,i.entity,i.account ORDER BY t.trandate,t.id,i.account`).all({ to, side: side === "ar" ? "receivable" : "payable", subsidiary: subsidiary ?? null }).filter((row2) => row2.open !== 0);
|
|
173993
174020
|
}
|
|
@@ -174896,7 +174923,7 @@ var init_searches = __esm({
|
|
|
174896
174923
|
iso20 = (d) => d.toISOString().slice(0, 10);
|
|
174897
174924
|
at2 = (y, m, d) => new Date(Date.UTC(y, m, d));
|
|
174898
174925
|
SUMMARIES = ["group", "count", "sum", "avg", "min", "max"];
|
|
174899
|
-
money15 = (value5) => value5 === void 0 ? "" : Number(value5).toFixed(2);
|
|
174926
|
+
money15 = (value5) => value5 === void 0 ? "" : round(Number(value5)).toFixed(2);
|
|
174900
174927
|
}
|
|
174901
174928
|
});
|
|
174902
174929
|
|
|
@@ -216010,7 +216037,7 @@ async function executeRun(opts) {
|
|
|
216010
216037
|
// A world's seed once (run-inputs.ts). Names only, never values: what a later `ancha runs upload` redacts (hosting spec §3.1).
|
|
216011
216038
|
agentEnvironment: { passEnv: agent.passEnv ?? [], inheritEnv: agent.inheritEnv === true },
|
|
216012
216039
|
isolation: { execution: executionDescription(agent), toolWorld: "fresh-per-attempt", agentProcess: agent.mode === "endpoint" && agent.start === void 0 ? "external-setup-adapter" : "fresh-per-attempt", agentState: agent.execution?.mode === "container" ? "fresh-container-scratch" : "provided-namespace-only", limits: agent.execution?.mode === "container" ? "Local Linux container, read-only source, bounded scratch, scoped tool gateway and explicit model hosts; not a multi-tenant cloud security certification." : "Agent files and external memory are shared unless the agent uses ANCHA_STATE_DIR or ANCHA_ATTEMPT_ID. This is not host or network isolation." }
|
|
216013
|
-
}
|
|
216040
|
+
})}
|
|
216014
216041
|
`, { flag: "wx", mode: 384 });
|
|
216015
216042
|
const kept = /* @__PURE__ */ new Map();
|
|
216016
216043
|
for (const [index, item2] of cases.entries()) {
|
|
@@ -216200,9 +216227,15 @@ function logTail2(data5, cap) {
|
|
|
216200
216227
|
if (newline !== -1 && newline < data5.length - 1) start = newline + 1;
|
|
216201
216228
|
return Buffer.concat([note2(start), data5.subarray(start)]);
|
|
216202
216229
|
}
|
|
216203
|
-
function capFor(path7) {
|
|
216230
|
+
function capFor(path7, inputsBytes = BUNDLE_LIMITS2.largeFileBytes) {
|
|
216204
216231
|
const name5 = path7.slice(path7.lastIndexOf("/") + 1);
|
|
216205
|
-
return name5 === "trace.jsonl" || name5 === "state.json" ? BUNDLE_LIMITS2.largeFileBytes : name5 === "agent.log" ? BUNDLE_LIMITS2.agentLogBytes : BUNDLE_LIMITS2.fileBytes;
|
|
216232
|
+
return name5 === "trace.jsonl" || name5 === "state.json" ? BUNDLE_LIMITS2.largeFileBytes : name5 === "agent.log" ? BUNDLE_LIMITS2.agentLogBytes : path7 === "inputs.json" ? inputsBytes : BUNDLE_LIMITS2.fileBytes;
|
|
216233
|
+
}
|
|
216234
|
+
function readsLargeInputs(version6) {
|
|
216235
|
+
const match3 = /^(\d+)\.(\d+)\.(\d+)/.exec(version6 ?? "");
|
|
216236
|
+
if (!match3) return false;
|
|
216237
|
+
const [major, minor, patch] = match3.slice(1).map(Number);
|
|
216238
|
+
return major !== 0 ? major > 0 : minor !== 4 ? minor > 4 : patch >= 14;
|
|
216206
216239
|
}
|
|
216207
216240
|
async function runFiles(runDir, source) {
|
|
216208
216241
|
const root3 = await readdir3(runDir, { withFileTypes: true });
|
|
@@ -216223,7 +216256,7 @@ async function packRun(options4) {
|
|
|
216223
216256
|
const entries4 = [], omitted = [];
|
|
216224
216257
|
for (const path7 of paths2) {
|
|
216225
216258
|
let data5 = redact(await readFile8(join20(options4.runDir, path7)), options4.secrets);
|
|
216226
|
-
const cap = capFor(path7);
|
|
216259
|
+
const cap = capFor(path7, options4.inputsBytes);
|
|
216227
216260
|
if (data5.length > cap) {
|
|
216228
216261
|
if (path7.endsWith("/agent.log")) data5 = logTail2(data5, cap);
|
|
216229
216262
|
else if (options4.source === "cloud" && MANDATORY_CLOUD_PATH.test(path7)) throw tooBig2(`run ${options4.runId}: ${path7} is ${data5.length} bytes; a run keeps at most ${cap}`);
|
|
@@ -221596,8 +221629,9 @@ function finalizeInput(value5) {
|
|
|
221596
221629
|
if (missing8 !== void 0) wrong(`has no ${what}.${missing8}`);
|
|
221597
221630
|
return v;
|
|
221598
221631
|
};
|
|
221599
|
-
const input4 = fields11(value5, "input", ["version", "jobId", "bundleHash", "workspace", "startedAt", "finishedAt", "terminalIntent", "options", "attempts", "execution", "provenance", "requestedConcurrency", "effectiveConcurrency", "observedPeakConcurrency", "caps"]);
|
|
221632
|
+
const input4 = fields11(value5, "input", ["version", "jobId", "bundleHash", "workspace", "startedAt", "finishedAt", "terminalIntent", "options", "attempts", "execution", "provenance", "requestedConcurrency", "effectiveConcurrency", "observedPeakConcurrency", "caps"], ["cliVersion"]);
|
|
221600
221633
|
if (input4.version !== 1) wrong(`has version ${JSON.stringify(input4.version)}`);
|
|
221634
|
+
if (input4.cliVersion !== void 0 && typeof input4.cliVersion !== "string") wrong("names a CLI version that is not one");
|
|
221601
221635
|
if (typeof input4.jobId !== "string" || !CLOUD_RUN_ID.test(input4.jobId)) wrong("names no cloud run");
|
|
221602
221636
|
if (typeof input4.bundleHash !== "string" || !SHA256.test(input4.bundleHash)) wrong("has no bundle hash");
|
|
221603
221637
|
if (typeof input4.workspace !== "string" || !/^[a-z0-9][a-z0-9-]{0,99}$/.test(input4.workspace)) wrong("names no workspace");
|
|
@@ -221835,7 +221869,7 @@ async function assembleCloudRun(options4) {
|
|
|
221835
221869
|
const value5 = { id: item2.caseId, scenarioId: item2.scene.id, seed: item2.seed, compiledFingerprint: sceneFingerprint(item2.scene), identity: {} };
|
|
221836
221870
|
return { ...value5, fingerprint: sceneFingerprint(value5), scene: item2.scene };
|
|
221837
221871
|
});
|
|
221838
|
-
await writeFile18(join42(runDir, "inputs.json"), `${JSON.stringify({ schemaVersion: 1, cases: sharedSeeds(frozen), isolation: { execution: "cloud", toolWorld: "fresh-per-attempt", agentProcess: "fresh-machine-per-attempt", agentState: "fresh-machine-per-attempt" } }
|
|
221872
|
+
await writeFile18(join42(runDir, "inputs.json"), `${JSON.stringify({ schemaVersion: 1, cases: sharedSeeds(frozen), isolation: { execution: "cloud", toolWorld: "fresh-per-attempt", agentProcess: "fresh-machine-per-attempt", agentState: "fresh-machine-per-attempt" } })}
|
|
221839
221873
|
`, { flag: "wx", mode: 384 });
|
|
221840
221874
|
const results = new Map(cases.map((item2) => [item2.caseId, { scene: item2.scene, trials: [], requestedTrials: resolved.attempts, ...item2.records !== void 0 && { records: item2.records } }]));
|
|
221841
221875
|
for (const item2 of cases) {
|
|
@@ -221882,7 +221916,16 @@ async function assembleCloudRun(options4) {
|
|
|
221882
221916
|
await writeFile18(join42(runDir, "reproduction.json"), json35(summary.reproduction), { flag: "wx", mode: 384 });
|
|
221883
221917
|
await writeFile18(join42(runDir, "cloud.json"), json35({ version: 1, jobId: runId2, bundleHash: input4.bundleHash, startedAt: input4.startedAt, finishedAt: input4.finishedAt, terminalIntent: input4.terminalIntent, attempts: input4.attempts }), { flag: "wx", mode: 384 });
|
|
221884
221918
|
await writeFile18(join42(runDir, "summary.json"), json35(summary), { flag: "wx", mode: 384 });
|
|
221885
|
-
const { archive } = await packRun({
|
|
221919
|
+
const { archive } = await packRun({
|
|
221920
|
+
runDir,
|
|
221921
|
+
runId: runId2,
|
|
221922
|
+
createdAt: input4.startedAt,
|
|
221923
|
+
source: "cloud",
|
|
221924
|
+
cli: options4.cli ?? "",
|
|
221925
|
+
project: { name: manifest2.agentName, git: null },
|
|
221926
|
+
secrets: [],
|
|
221927
|
+
inputsBytes: readsLargeInputs(input4.cliVersion) ? BUNDLE_LIMITS2.largeFileBytes : BUNDLE_LIMITS2.fileBytes
|
|
221928
|
+
});
|
|
221886
221929
|
const archivePath = join42(options4.outDir, `${runId2}.tar.gz`);
|
|
221887
221930
|
await writeFile18(archivePath, archive, { flag: "wx", mode: 384 });
|
|
221888
221931
|
return { archivePath, sha256: sha2565(archive), runId: runId2, exitCode: summary.exitCode, verdict: summary.verdict };
|
|
@@ -234139,8 +234182,11 @@ async function loadReplayAttempt(cwd, ref22, out) {
|
|
|
234139
234182
|
try {
|
|
234140
234183
|
inputs2 = JSON.parse(await readFile32(join46(runDir, "inputs.json"), "utf8"));
|
|
234141
234184
|
} catch (error65) {
|
|
234142
|
-
if (missing7(error65)) throw
|
|
234143
|
-
|
|
234185
|
+
if (!missing7(error65)) throw error65;
|
|
234186
|
+
const left = await readFile32(join46(runDir, "bundle.json"), "utf8").then((text29) => JSON.parse(text29).omitted?.find((item2) => item2.path === "inputs.json")).catch(() => void 0);
|
|
234187
|
+
const mb = (bytes3) => `${(bytes3 / (1024 * 1024)).toFixed(1)} MB`;
|
|
234188
|
+
if (left) throw new AnchaError("USAGE", `run ${runId2} came without its inputs.json (${mb(left.bytes)}, past the ${mb(left.cap)} its archive kept), so replay can't rebuild its worlds`, { hint: "a run started with ancha 0.4.14 or later keeps an inputs.json up to 12 MB: run the tests again, then replay the new run", cause: error65 });
|
|
234189
|
+
throw new AnchaError("USAGE", `unknown run ${JSON.stringify(runId2)}`, { hint: `see ${out ?? DEFAULT_RUNS_DIR}/`, cause: error65 });
|
|
234144
234190
|
}
|
|
234145
234191
|
const trials = (await readdir7(runDir).catch(() => [])).filter((name5) => TRIAL_DIR.test(name5)).sort();
|
|
234146
234192
|
if (!TRIAL_DIR.test(trialDir) || !trials.includes(trialDir)) {
|
|
@@ -234244,6 +234290,8 @@ function registerReplay(program2, ctx) {
|
|
|
234244
234290
|
if (opts.people !== void 0 && opts.people !== "live" && opts.people !== "strict") {
|
|
234245
234291
|
throw new AnchaError("USAGE", `--people takes live or strict, not ${opts.people}`, { hint: "ancha replay latest/trial-<test>-1 --people strict" });
|
|
234246
234292
|
}
|
|
234293
|
+
const runId2 = ref22.split("/")[0];
|
|
234294
|
+
if (/^run_cloud_/.test(runId2)) await cachedCloudRun(ctx, runId2, resolve36(cwd, opts.out ?? DEFAULT_RUNS_DIR));
|
|
234247
234295
|
const attempt = await loadReplayAttempt(cwd, ref22, opts.out);
|
|
234248
234296
|
const config11 = await ctx.loadConfig();
|
|
234249
234297
|
const resolved = resolveRunAgent(config11, cwd, { ...opts.agent !== void 0 && { agent: opts.agent } });
|
|
@@ -85210,6 +85210,9 @@ function carrierPortalSeedRecords(seed43) {
|
|
|
85210
85210
|
];
|
|
85211
85211
|
}
|
|
85212
85212
|
|
|
85213
|
+
// packages/core/src/tools/netsuite-money.ts
|
|
85214
|
+
var netsuiteRound = (value4) => Math.sign(value4) * Math.round(Number(`${Math.abs(value4).toFixed(10)}e2`)) / 100 || 0;
|
|
85215
|
+
|
|
85213
85216
|
// packages/core/src/tools/netsuite.ts
|
|
85214
85217
|
var NETSUITE_ACCOUNT_TYPES = [
|
|
85215
85218
|
"Bank",
|
|
@@ -85715,7 +85718,7 @@ function checkSeed(seed43, report3) {
|
|
|
85715
85718
|
}
|
|
85716
85719
|
function books(seed43, issue6, money13) {
|
|
85717
85720
|
if (seed43.integration.customerCreditLimitHandlingOverride && !seed43.policy.allowCustomerCreditLimitHandlingOverride) issue6(["integration", "customerCreditLimitHandlingOverride"], "credit handling override requires policy permission");
|
|
85718
|
-
const round2 =
|
|
85721
|
+
const round2 = netsuiteRound;
|
|
85719
85722
|
const accountById = new Map(seed43.accounts.map((a) => [a.id, a])), itemById = new Map(seed43.items.map((i) => [i.id, i]));
|
|
85720
85723
|
const itemTotal = (lines2) => round2(lines2.reduce((sum5, line2) => sum5 + round2(line2.quantity * (line2.rate ?? itemById.get(line2.item)?.rate ?? 0)), 0));
|
|
85721
85724
|
const buyTotal = (lines2) => round2(lines2.reduce((sum5, line2) => sum5 + round2(line2.quantity * (line2.rate ?? itemById.get(line2.item)?.cost ?? itemById.get(line2.item)?.rate ?? 0)), 0));
|
|
@@ -141667,14 +141670,14 @@ CREATE VIEW ns_q_transaction AS SELECT t.id, t.tranid, t.trandate, t.type, t.rec
|
|
|
141667
141670
|
CREATE VIEW ns_q_transactionline AS
|
|
141668
141671
|
-- Reserve four digits for the line; transaction IDs up to 2000000000 stay below 2^53.
|
|
141669
141672
|
SELECT 0 AS id, t.id * 10000 AS uniquekey, t.id AS "transaction", 0 AS linesequencenumber, 'T' AS mainline, 'F' AS taxline, NULL AS item, NULL AS itemtype, NULL AS quantity,
|
|
141670
|
-
NULL AS rate,
|
|
141673
|
+
NULL AS rate, ns_round(${signed("t.total", 0)} * t.exchangerate) AS netamount, ${signed("t.total", 0)} AS foreignamount, t.memo, NULL AS expenseaccount, t.account, t.entity, t.subsidiary,
|
|
141671
141674
|
t.department, t.location, t.class, t.createdfrom, 'F' AS isclosed,
|
|
141672
141675
|
NULL AS debit, NULL AS credit, NULL AS quantitybilled, NULL AS quantityshiprecv, NULL AS quantitycommitted, NULL AS category, NULL AS costestimate, t.extra, 'F' AS iscogs
|
|
141673
141676
|
FROM ns_transactions t WHERE t.type <> 'Journal'
|
|
141674
141677
|
UNION ALL
|
|
141675
141678
|
SELECT l.line AS id, l."transaction" * 10000 + l.line AS uniquekey, l."transaction", l.line, 'F', 'F', l.item, i.itemtype,
|
|
141676
141679
|
${signed("l.quantity", 2)}, l.rate,
|
|
141677
|
-
|
|
141680
|
+
ns_round(CASE WHEN t.type = 'Journal' THEN COALESCE(l.debit, 0) - COALESCE(l.credit, 0) WHEN t.type IN ('ItemShip', 'ItemRcpt') THEN NULL ELSE ${signed("l.amount", 1)} END * t.exchangerate),
|
|
141678
141681
|
CASE WHEN t.type = 'Journal' THEN COALESCE(l.debit, 0) - COALESCE(l.credit, 0) WHEN t.type IN ('ItemShip', 'ItemRcpt') THEN NULL ELSE ${signed("l.amount", 1)} END,
|
|
141679
141682
|
COALESCE(l.memo, l.description), l.account, l.account, COALESCE(l.entity, t.entity), t.subsidiary, COALESCE(l.department, t.department),
|
|
141680
141683
|
COALESCE(l.location, t.location), COALESCE(l.class, t.class), l.createdfrom, ${bool8("l.isclosed")}, l.debit, l.credit,
|
|
@@ -142297,6 +142300,12 @@ function upgradeSchema(db3) {
|
|
|
142297
142300
|
})();
|
|
142298
142301
|
}
|
|
142299
142302
|
|
|
142303
|
+
// packages/server/src/twins/netsuite/money.ts
|
|
142304
|
+
var round = netsuiteRound;
|
|
142305
|
+
function registerRound(db3) {
|
|
142306
|
+
db3.function("ns_round", { deterministic: true }, (value4) => value4 === null || value4 === void 0 ? null : round(Number(value4)));
|
|
142307
|
+
}
|
|
142308
|
+
|
|
142300
142309
|
// packages/server/src/twins/netsuite/banking-schema.ts
|
|
142301
142310
|
var isBanking = (type) => ["bankingTransaction", "bankRecSuggestion", "transactionMatch"].includes(type);
|
|
142302
142311
|
var read2 = (kind, target4) => ({ kind, ...target4 && { target: target4 } });
|
|
@@ -145124,6 +145133,7 @@ function sql(ctx) {
|
|
|
145124
145133
|
upgradeSchema(db3);
|
|
145125
145134
|
const registered = { clock: ctx.clock };
|
|
145126
145135
|
db3.function("ns_today", { deterministic: false }, () => registered.clock.now().toISOString().slice(0, 10));
|
|
145136
|
+
registerRound(db3);
|
|
145127
145137
|
clocks.set(db3, holder = registered);
|
|
145128
145138
|
}
|
|
145129
145139
|
holder.clock = ctx.clock;
|
|
@@ -145131,7 +145141,6 @@ function sql(ctx) {
|
|
|
145131
145141
|
}
|
|
145132
145142
|
var today = (ctx) => ctx.clock.now().toISOString().slice(0, 10);
|
|
145133
145143
|
var stamp5 = (ctx) => ctx.clock.now().toISOString().replace(/\.\d{3}Z$/, "Z");
|
|
145134
|
-
var round = (value4) => Math.sign(value4) * Math.round(Number(`${Math.abs(value4).toFixed(10)}e2`)) / 100 || 0;
|
|
145135
145144
|
var qty = (value4) => Math.round(value4 * 1e8) / 1e8;
|
|
145136
145145
|
var addDays = (date10, days) => new Date(Date.parse(`${date10}T00:00:00Z`) + days * 864e5).toISOString().slice(0, 10);
|
|
145137
145146
|
var json31 = (text23) => {
|
|
@@ -147507,6 +147516,7 @@ var nth = (re, source, position, occurrence) => {
|
|
|
147507
147516
|
return void 0;
|
|
147508
147517
|
};
|
|
147509
147518
|
function installFunctions(db3, hierarchy) {
|
|
147519
|
+
registerRound(db3);
|
|
147510
147520
|
const register3 = (name5, fn) => {
|
|
147511
147521
|
db3.function(`ns_suiteql_${name5}`, { deterministic: true, varargs: true }, fn);
|
|
147512
147522
|
};
|
|
@@ -148754,10 +148764,10 @@ function balanceSheet(ctx, p2) {
|
|
|
148754
148764
|
}
|
|
148755
148765
|
function openItems2(ctx, side, to, subsidiary) {
|
|
148756
148766
|
return sql(ctx).prepare(`SELECT t.id,t.type,t.tranid,t.trandate,t.duedate,i.entity,t.otherrefnum,
|
|
148757
|
-
|
|
148767
|
+
ns_round(SUM((i.original - COALESCE((SELECT SUM(a.amount) FROM ns_applications a JOIN ns_transactions owner ON owner.id=a.payment
|
|
148758
148768
|
WHERE owner.trandate<=@to AND ((i.role='debt' AND a.doc=i.doc AND a.docline=i.line) OR (i.role='credit' AND a.source=i.doc AND a.sourceline=i.line))),0)
|
|
148759
148769
|
- CASE WHEN i.role='credit' THEN COALESCE((SELECT SUM(a.amount) FROM ns_applications a JOIN ns_transactions owner ON owner.id=a.payment WHERE owner.trandate<=@to AND a.doc=i.doc AND a.docline=i.line),0) ELSE 0 END)
|
|
148760
|
-
* CASE i.role WHEN 'debt' THEN 1 ELSE -1 END * t.exchangerate)
|
|
148770
|
+
* CASE i.role WHEN 'debt' THEN 1 ELSE -1 END * t.exchangerate)) AS open
|
|
148761
148771
|
FROM ns_item_original i JOIN ns_transactions t ON t.id=i.doc WHERE i.side=@side AND t.trandate<=@to AND (@subsidiary IS NULL OR i.subsidiary=@subsidiary)
|
|
148762
148772
|
GROUP BY i.doc,i.entity,i.account ORDER BY t.trandate,t.id,i.account`).all({ to, side: side === "ar" ? "receivable" : "payable", subsidiary: subsidiary ?? null }).filter((row2) => row2.open !== 0);
|
|
148763
148773
|
}
|
|
@@ -149546,7 +149556,7 @@ function expression2(ctx, type, filters, params10, plan4) {
|
|
|
149546
149556
|
return out.join(" ");
|
|
149547
149557
|
}
|
|
149548
149558
|
var SUMMARIES = ["group", "count", "sum", "avg", "min", "max"];
|
|
149549
|
-
var money12 = (value4) => value4 === void 0 ? "" : Number(value4).toFixed(2);
|
|
149559
|
+
var money12 = (value4) => value4 === void 0 ? "" : round(Number(value4)).toFixed(2);
|
|
149550
149560
|
function listSearches(ctx, args) {
|
|
149551
149561
|
const needle = args.query?.trim().toLowerCase();
|
|
149552
149562
|
return { success: true, savedSearches: (config10(ctx).savedSearches ?? []).filter((s2) => !needle || s2.title.toLowerCase().includes(needle) || s2.id.includes(needle)).map((s2) => ({ id: s2.id, internalId: s2.internalId, title: s2.title, recordType: s2.type, isPublic: s2.isPublic })) };
|
|
@@ -204,14 +204,14 @@ CREATE VIEW ns_q_transaction AS SELECT t.id, t.tranid, t.trandate, t.type, t.rec
|
|
|
204
204
|
CREATE VIEW ns_q_transactionline AS
|
|
205
205
|
-- Reserve four digits for the line; transaction IDs up to 2000000000 stay below 2^53.
|
|
206
206
|
SELECT 0 AS id, t.id * 10000 AS uniquekey, t.id AS "transaction", 0 AS linesequencenumber, 'T' AS mainline, 'F' AS taxline, NULL AS item, NULL AS itemtype, NULL AS quantity,
|
|
207
|
-
NULL AS rate,
|
|
207
|
+
NULL AS rate, ns_round(${signed("t.total", 0)} * t.exchangerate) AS netamount, ${signed("t.total", 0)} AS foreignamount, t.memo, NULL AS expenseaccount, t.account, t.entity, t.subsidiary,
|
|
208
208
|
t.department, t.location, t.class, t.createdfrom, 'F' AS isclosed,
|
|
209
209
|
NULL AS debit, NULL AS credit, NULL AS quantitybilled, NULL AS quantityshiprecv, NULL AS quantitycommitted, NULL AS category, NULL AS costestimate, t.extra, 'F' AS iscogs
|
|
210
210
|
FROM ns_transactions t WHERE t.type <> 'Journal'
|
|
211
211
|
UNION ALL
|
|
212
212
|
SELECT l.line AS id, l."transaction" * 10000 + l.line AS uniquekey, l."transaction", l.line, 'F', 'F', l.item, i.itemtype,
|
|
213
213
|
${signed("l.quantity", 2)}, l.rate,
|
|
214
|
-
|
|
214
|
+
ns_round(CASE WHEN t.type = 'Journal' THEN COALESCE(l.debit, 0) - COALESCE(l.credit, 0) WHEN t.type IN ('ItemShip', 'ItemRcpt') THEN NULL ELSE ${signed("l.amount", 1)} END * t.exchangerate),
|
|
215
215
|
CASE WHEN t.type = 'Journal' THEN COALESCE(l.debit, 0) - COALESCE(l.credit, 0) WHEN t.type IN ('ItemShip', 'ItemRcpt') THEN NULL ELSE ${signed("l.amount", 1)} END,
|
|
216
216
|
COALESCE(l.memo, l.description), l.account, l.account, COALESCE(l.entity, t.entity), t.subsidiary, COALESCE(l.department, t.department),
|
|
217
217
|
COALESCE(l.location, t.location), COALESCE(l.class, t.class), l.createdfrom, ${bool("l.isclosed")}, l.debit, l.credit,
|
|
@@ -787,6 +787,15 @@ var DISPLAY = {
|
|
|
787
787
|
shipstatus: { A: "Picked", B: "Packed", C: "Shipped" }
|
|
788
788
|
};
|
|
789
789
|
|
|
790
|
+
// packages/core/src/tools/netsuite-money.ts
|
|
791
|
+
var netsuiteRound = (value) => Math.sign(value) * Math.round(Number(`${Math.abs(value).toFixed(10)}e2`)) / 100 || 0;
|
|
792
|
+
|
|
793
|
+
// packages/server/src/twins/netsuite/money.ts
|
|
794
|
+
var round = netsuiteRound;
|
|
795
|
+
function registerRound(db) {
|
|
796
|
+
db.function("ns_round", { deterministic: true }, (value) => value === null || value === void 0 ? null : round(Number(value)));
|
|
797
|
+
}
|
|
798
|
+
|
|
790
799
|
// packages/server/src/twins/netsuite/suiteql.ts
|
|
791
800
|
var SuiteqlError = class extends Error {
|
|
792
801
|
gap;
|
|
@@ -2329,6 +2338,7 @@ var nth = (re, source, position, occurrence) => {
|
|
|
2329
2338
|
return void 0;
|
|
2330
2339
|
};
|
|
2331
2340
|
function installFunctions(db, hierarchy) {
|
|
2341
|
+
registerRound(db);
|
|
2332
2342
|
const register = (name, fn) => {
|
|
2333
2343
|
db.function(`ns_suiteql_${name}`, { deterministic: true, varargs: true }, fn);
|
|
2334
2344
|
};
|
package/lib/mcp-entry.mjs
CHANGED
|
@@ -65632,6 +65632,9 @@ var carrierPortalStarterSeed = {
|
|
|
65632
65632
|
messages: [{ id: "welcome", policy: "LM-10042", request: "LMR-PRIOR-01", subject: "Mailing address confirmed", body: "The requested mailing address has been approved." }]
|
|
65633
65633
|
};
|
|
65634
65634
|
|
|
65635
|
+
// packages/core/src/tools/netsuite-money.ts
|
|
65636
|
+
var netsuiteRound = (value2) => Math.sign(value2) * Math.round(Number(`${Math.abs(value2).toFixed(10)}e2`)) / 100 || 0;
|
|
65637
|
+
|
|
65635
65638
|
// packages/core/src/tools/netsuite.ts
|
|
65636
65639
|
var NETSUITE_ACCOUNT_TYPES = [
|
|
65637
65640
|
"Bank",
|
|
@@ -66136,7 +66139,7 @@ function checkSeed(seed2, report) {
|
|
|
66136
66139
|
}
|
|
66137
66140
|
function books(seed2, issue2, money8) {
|
|
66138
66141
|
if (seed2.integration.customerCreditLimitHandlingOverride && !seed2.policy.allowCustomerCreditLimitHandlingOverride) issue2(["integration", "customerCreditLimitHandlingOverride"], "credit handling override requires policy permission");
|
|
66139
|
-
const round2 =
|
|
66142
|
+
const round2 = netsuiteRound;
|
|
66140
66143
|
const accountById = new Map(seed2.accounts.map((a) => [a.id, a])), itemById = new Map(seed2.items.map((i) => [i.id, i]));
|
|
66141
66144
|
const itemTotal = (lines2) => round2(lines2.reduce((sum, line2) => sum + round2(line2.quantity * (line2.rate ?? itemById.get(line2.item)?.rate ?? 0)), 0));
|
|
66142
66145
|
const buyTotal = (lines2) => round2(lines2.reduce((sum, line2) => sum + round2(line2.quantity * (line2.rate ?? itemById.get(line2.item)?.cost ?? itemById.get(line2.item)?.rate ?? 0)), 0));
|
package/lib/suiteql-worker.mjs
CHANGED
|
@@ -204,14 +204,14 @@ CREATE VIEW ns_q_transaction AS SELECT t.id, t.tranid, t.trandate, t.type, t.rec
|
|
|
204
204
|
CREATE VIEW ns_q_transactionline AS
|
|
205
205
|
-- Reserve four digits for the line; transaction IDs up to 2000000000 stay below 2^53.
|
|
206
206
|
SELECT 0 AS id, t.id * 10000 AS uniquekey, t.id AS "transaction", 0 AS linesequencenumber, 'T' AS mainline, 'F' AS taxline, NULL AS item, NULL AS itemtype, NULL AS quantity,
|
|
207
|
-
NULL AS rate,
|
|
207
|
+
NULL AS rate, ns_round(${signed("t.total", 0)} * t.exchangerate) AS netamount, ${signed("t.total", 0)} AS foreignamount, t.memo, NULL AS expenseaccount, t.account, t.entity, t.subsidiary,
|
|
208
208
|
t.department, t.location, t.class, t.createdfrom, 'F' AS isclosed,
|
|
209
209
|
NULL AS debit, NULL AS credit, NULL AS quantitybilled, NULL AS quantityshiprecv, NULL AS quantitycommitted, NULL AS category, NULL AS costestimate, t.extra, 'F' AS iscogs
|
|
210
210
|
FROM ns_transactions t WHERE t.type <> 'Journal'
|
|
211
211
|
UNION ALL
|
|
212
212
|
SELECT l.line AS id, l."transaction" * 10000 + l.line AS uniquekey, l."transaction", l.line, 'F', 'F', l.item, i.itemtype,
|
|
213
213
|
${signed("l.quantity", 2)}, l.rate,
|
|
214
|
-
|
|
214
|
+
ns_round(CASE WHEN t.type = 'Journal' THEN COALESCE(l.debit, 0) - COALESCE(l.credit, 0) WHEN t.type IN ('ItemShip', 'ItemRcpt') THEN NULL ELSE ${signed("l.amount", 1)} END * t.exchangerate),
|
|
215
215
|
CASE WHEN t.type = 'Journal' THEN COALESCE(l.debit, 0) - COALESCE(l.credit, 0) WHEN t.type IN ('ItemShip', 'ItemRcpt') THEN NULL ELSE ${signed("l.amount", 1)} END,
|
|
216
216
|
COALESCE(l.memo, l.description), l.account, l.account, COALESCE(l.entity, t.entity), t.subsidiary, COALESCE(l.department, t.department),
|
|
217
217
|
COALESCE(l.location, t.location), COALESCE(l.class, t.class), l.createdfrom, ${bool("l.isclosed")}, l.debit, l.credit,
|
|
@@ -787,6 +787,15 @@ var DISPLAY = {
|
|
|
787
787
|
shipstatus: { A: "Picked", B: "Packed", C: "Shipped" }
|
|
788
788
|
};
|
|
789
789
|
|
|
790
|
+
// packages/core/src/tools/netsuite-money.ts
|
|
791
|
+
var netsuiteRound = (value) => Math.sign(value) * Math.round(Number(`${Math.abs(value).toFixed(10)}e2`)) / 100 || 0;
|
|
792
|
+
|
|
793
|
+
// packages/server/src/twins/netsuite/money.ts
|
|
794
|
+
var round = netsuiteRound;
|
|
795
|
+
function registerRound(db) {
|
|
796
|
+
db.function("ns_round", { deterministic: true }, (value) => value === null || value === void 0 ? null : round(Number(value)));
|
|
797
|
+
}
|
|
798
|
+
|
|
790
799
|
// packages/server/src/twins/netsuite/suiteql.ts
|
|
791
800
|
var SuiteqlError = class extends Error {
|
|
792
801
|
gap;
|
|
@@ -2329,6 +2338,7 @@ var nth = (re, source, position, occurrence) => {
|
|
|
2329
2338
|
return void 0;
|
|
2330
2339
|
};
|
|
2331
2340
|
function installFunctions(db, hierarchy) {
|
|
2341
|
+
registerRound(db);
|
|
2332
2342
|
const register = (name, fn) => {
|
|
2333
2343
|
db.function(`ns_suiteql_${name}`, { deterministic: true, varargs: true }, fn);
|
|
2334
2344
|
};
|
package/lib/worker.mjs
CHANGED
|
@@ -30022,6 +30022,15 @@ var init_carrier_portal = __esm({
|
|
|
30022
30022
|
}
|
|
30023
30023
|
});
|
|
30024
30024
|
|
|
30025
|
+
// packages/core/src/tools/netsuite-money.ts
|
|
30026
|
+
var netsuiteRound;
|
|
30027
|
+
var init_netsuite_money = __esm({
|
|
30028
|
+
"packages/core/src/tools/netsuite-money.ts"() {
|
|
30029
|
+
"use strict";
|
|
30030
|
+
netsuiteRound = (value4) => Math.sign(value4) * Math.round(Number(`${Math.abs(value4).toFixed(10)}e2`)) / 100 || 0;
|
|
30031
|
+
}
|
|
30032
|
+
});
|
|
30033
|
+
|
|
30025
30034
|
// packages/core/src/tools/netsuite.ts
|
|
30026
30035
|
function recordNamer(seed43) {
|
|
30027
30036
|
const symbols = new Map(seed43.currencies.map((c) => [c.id, c.symbol ?? c.name]));
|
|
@@ -30085,7 +30094,7 @@ function checkSeed(seed43, report3) {
|
|
|
30085
30094
|
}
|
|
30086
30095
|
function books(seed43, issue6, money13) {
|
|
30087
30096
|
if (seed43.integration.customerCreditLimitHandlingOverride && !seed43.policy.allowCustomerCreditLimitHandlingOverride) issue6(["integration", "customerCreditLimitHandlingOverride"], "credit handling override requires policy permission");
|
|
30088
|
-
const round2 =
|
|
30097
|
+
const round2 = netsuiteRound;
|
|
30089
30098
|
const accountById = new Map(seed43.accounts.map((a) => [a.id, a])), itemById = new Map(seed43.items.map((i) => [i.id, i]));
|
|
30090
30099
|
const itemTotal = (lines2) => round2(lines2.reduce((sum5, line2) => sum5 + round2(line2.quantity * (line2.rate ?? itemById.get(line2.item)?.rate ?? 0)), 0));
|
|
30091
30100
|
const buyTotal = (lines2) => round2(lines2.reduce((sum5, line2) => sum5 + round2(line2.quantity * (line2.rate ?? itemById.get(line2.item)?.cost ?? itemById.get(line2.item)?.rate ?? 0)), 0));
|
|
@@ -30603,6 +30612,7 @@ var init_netsuite = __esm({
|
|
|
30603
30612
|
"packages/core/src/tools/netsuite.ts"() {
|
|
30604
30613
|
"use strict";
|
|
30605
30614
|
init_zod();
|
|
30615
|
+
init_netsuite_money();
|
|
30606
30616
|
NETSUITE_ACCOUNT_TYPES = [
|
|
30607
30617
|
"Bank",
|
|
30608
30618
|
"AcctRec",
|
|
@@ -40635,6 +40645,7 @@ var init_evals = __esm({
|
|
|
40635
40645
|
"packages/core/src/datasets/netsuite-pe/evals.ts"() {
|
|
40636
40646
|
"use strict";
|
|
40637
40647
|
init_netsuite();
|
|
40648
|
+
init_netsuite_money();
|
|
40638
40649
|
}
|
|
40639
40650
|
});
|
|
40640
40651
|
|
|
@@ -159595,14 +159606,14 @@ CREATE VIEW ns_q_transaction AS SELECT t.id, t.tranid, t.trandate, t.type, t.rec
|
|
|
159595
159606
|
CREATE VIEW ns_q_transactionline AS
|
|
159596
159607
|
-- Reserve four digits for the line; transaction IDs up to 2000000000 stay below 2^53.
|
|
159597
159608
|
SELECT 0 AS id, t.id * 10000 AS uniquekey, t.id AS "transaction", 0 AS linesequencenumber, 'T' AS mainline, 'F' AS taxline, NULL AS item, NULL AS itemtype, NULL AS quantity,
|
|
159598
|
-
NULL AS rate,
|
|
159609
|
+
NULL AS rate, ns_round(${signed("t.total", 0)} * t.exchangerate) AS netamount, ${signed("t.total", 0)} AS foreignamount, t.memo, NULL AS expenseaccount, t.account, t.entity, t.subsidiary,
|
|
159599
159610
|
t.department, t.location, t.class, t.createdfrom, 'F' AS isclosed,
|
|
159600
159611
|
NULL AS debit, NULL AS credit, NULL AS quantitybilled, NULL AS quantityshiprecv, NULL AS quantitycommitted, NULL AS category, NULL AS costestimate, t.extra, 'F' AS iscogs
|
|
159601
159612
|
FROM ns_transactions t WHERE t.type <> 'Journal'
|
|
159602
159613
|
UNION ALL
|
|
159603
159614
|
SELECT l.line AS id, l."transaction" * 10000 + l.line AS uniquekey, l."transaction", l.line, 'F', 'F', l.item, i.itemtype,
|
|
159604
159615
|
${signed("l.quantity", 2)}, l.rate,
|
|
159605
|
-
|
|
159616
|
+
ns_round(CASE WHEN t.type = 'Journal' THEN COALESCE(l.debit, 0) - COALESCE(l.credit, 0) WHEN t.type IN ('ItemShip', 'ItemRcpt') THEN NULL ELSE ${signed("l.amount", 1)} END * t.exchangerate),
|
|
159606
159617
|
CASE WHEN t.type = 'Journal' THEN COALESCE(l.debit, 0) - COALESCE(l.credit, 0) WHEN t.type IN ('ItemShip', 'ItemRcpt') THEN NULL ELSE ${signed("l.amount", 1)} END,
|
|
159607
159618
|
COALESCE(l.memo, l.description), l.account, l.account, COALESCE(l.entity, t.entity), t.subsidiary, COALESCE(l.department, t.department),
|
|
159608
159619
|
COALESCE(l.location, t.location), COALESCE(l.class, t.class), l.createdfrom, ${bool8("l.isclosed")}, l.debit, l.credit,
|
|
@@ -160079,6 +160090,19 @@ CREATE VIEW ns_q_mediaitemfolder AS SELECT id, name, parent, description, datecr
|
|
|
160079
160090
|
}
|
|
160080
160091
|
});
|
|
160081
160092
|
|
|
160093
|
+
// packages/server/src/twins/netsuite/money.ts
|
|
160094
|
+
function registerRound(db3) {
|
|
160095
|
+
db3.function("ns_round", { deterministic: true }, (value4) => value4 === null || value4 === void 0 ? null : round(Number(value4)));
|
|
160096
|
+
}
|
|
160097
|
+
var round;
|
|
160098
|
+
var init_money = __esm({
|
|
160099
|
+
"packages/server/src/twins/netsuite/money.ts"() {
|
|
160100
|
+
"use strict";
|
|
160101
|
+
init_netsuite_money();
|
|
160102
|
+
round = netsuiteRound;
|
|
160103
|
+
}
|
|
160104
|
+
});
|
|
160105
|
+
|
|
160082
160106
|
// packages/server/src/twins/netsuite/banking-schema.ts
|
|
160083
160107
|
var isBanking, read5, list15, BANK_FIELDS, BANK_LINES;
|
|
160084
160108
|
var init_banking_schema = __esm({
|
|
@@ -162662,6 +162686,7 @@ function sql(ctx) {
|
|
|
162662
162686
|
upgradeSchema(db3);
|
|
162663
162687
|
const registered = { clock: ctx.clock };
|
|
162664
162688
|
db3.function("ns_today", { deterministic: false }, () => registered.clock.now().toISOString().slice(0, 10));
|
|
162689
|
+
registerRound(db3);
|
|
162665
162690
|
clocks.set(db3, holder = registered);
|
|
162666
162691
|
}
|
|
162667
162692
|
holder.clock = ctx.clock;
|
|
@@ -163420,13 +163445,14 @@ function dumpState41(ctx) {
|
|
|
163420
163445
|
records: db3.prepare("SELECT type, id, externalid, fields FROM ns_records ORDER BY type, id").all().map((r2) => clean({ type: r2.type, id: r2.id, externalId: r2.externalid, fields: json31(r2.fields) }))
|
|
163421
163446
|
};
|
|
163422
163447
|
}
|
|
163423
|
-
var RECORD_ROOT, LIST_KINDS, isTx, isItem, isEntity, isList, customerOf, vendorOf, AR, AP, FUNDS, BANK2, TX, TX_CODE, TX_LABEL, ORDERS, sublistsOf, r, w, ref21, HOLD, statusOptions, MONEY, SEGMENTS2, DATED, ENTITY, ITEM_COMMON, LIST_FIELDS, TX_BASE, party2, ADDRESSES, SALE, order4, FIELDS3, LINE_SEGMENTS, ITEM_LINE, LINE_FIELDS, clocks, today, stamp5,
|
|
163448
|
+
var RECORD_ROOT, LIST_KINDS, isTx, isItem, isEntity, isList, customerOf, vendorOf, AR, AP, FUNDS, BANK2, TX, TX_CODE, TX_LABEL, ORDERS, sublistsOf, r, w, ref21, HOLD, statusOptions, MONEY, SEGMENTS2, DATED, ENTITY, ITEM_COMMON, LIST_FIELDS, TX_BASE, party2, ADDRESSES, SALE, order4, FIELDS3, LINE_SEGMENTS, ITEM_LINE, LINE_FIELDS, clocks, today, stamp5, qty, addDays, json31, config10, customFields2, entityRow, itemRow, txRow, listRow, periodRow, lineRows, allLines, unpaid, unapplied, applications, listName, termDays, firstList, accountOfType, accountType, movesStock, nextTranId, statusText, href, selfLink, entityName, accountName, option3, PASSTHROUGH, docOpen, payable, addressBookLines, extraOwner;
|
|
163424
163449
|
var init_store5 = __esm({
|
|
163425
163450
|
"packages/server/src/twins/netsuite/store.ts"() {
|
|
163426
163451
|
"use strict";
|
|
163427
163452
|
init_open_items();
|
|
163428
163453
|
init_netsuite();
|
|
163429
163454
|
init_schema7();
|
|
163455
|
+
init_money();
|
|
163430
163456
|
init_banking_schema();
|
|
163431
163457
|
init_banking();
|
|
163432
163458
|
init_errors6();
|
|
@@ -163747,7 +163773,6 @@ var init_store5 = __esm({
|
|
|
163747
163773
|
clocks = /* @__PURE__ */ new WeakMap();
|
|
163748
163774
|
today = (ctx) => ctx.clock.now().toISOString().slice(0, 10);
|
|
163749
163775
|
stamp5 = (ctx) => ctx.clock.now().toISOString().replace(/\.\d{3}Z$/, "Z");
|
|
163750
|
-
round = (value4) => Math.sign(value4) * Math.round(Number(`${Math.abs(value4).toFixed(10)}e2`)) / 100 || 0;
|
|
163751
163776
|
qty = (value4) => Math.round(value4 * 1e8) / 1e8;
|
|
163752
163777
|
addDays = (date10, days) => new Date(Date.parse(`${date10}T00:00:00Z`) + days * 864e5).toISOString().slice(0, 10);
|
|
163753
163778
|
json31 = (text24) => {
|
|
@@ -164310,6 +164335,7 @@ function* matches7(re, source, position) {
|
|
|
164310
164335
|
}
|
|
164311
164336
|
}
|
|
164312
164337
|
function installFunctions(db3, hierarchy) {
|
|
164338
|
+
registerRound(db3);
|
|
164313
164339
|
const register3 = (name5, fn) => {
|
|
164314
164340
|
db3.function(`ns_suiteql_${name5}`, { deterministic: true, varargs: true }, fn);
|
|
164315
164341
|
};
|
|
@@ -164588,6 +164614,7 @@ var init_suiteql = __esm({
|
|
|
164588
164614
|
"packages/server/src/twins/netsuite/suiteql.ts"() {
|
|
164589
164615
|
"use strict";
|
|
164590
164616
|
init_schema7();
|
|
164617
|
+
init_money();
|
|
164591
164618
|
SuiteqlError = class extends Error {
|
|
164592
164619
|
gap;
|
|
164593
164620
|
constructor(message7, gap6 = false) {
|
|
@@ -166674,10 +166701,10 @@ function balanceSheet(ctx, p2) {
|
|
|
166674
166701
|
}
|
|
166675
166702
|
function openItems2(ctx, side, to, subsidiary) {
|
|
166676
166703
|
return sql(ctx).prepare(`SELECT t.id,t.type,t.tranid,t.trandate,t.duedate,i.entity,t.otherrefnum,
|
|
166677
|
-
|
|
166704
|
+
ns_round(SUM((i.original - COALESCE((SELECT SUM(a.amount) FROM ns_applications a JOIN ns_transactions owner ON owner.id=a.payment
|
|
166678
166705
|
WHERE owner.trandate<=@to AND ((i.role='debt' AND a.doc=i.doc AND a.docline=i.line) OR (i.role='credit' AND a.source=i.doc AND a.sourceline=i.line))),0)
|
|
166679
166706
|
- CASE WHEN i.role='credit' THEN COALESCE((SELECT SUM(a.amount) FROM ns_applications a JOIN ns_transactions owner ON owner.id=a.payment WHERE owner.trandate<=@to AND a.doc=i.doc AND a.docline=i.line),0) ELSE 0 END)
|
|
166680
|
-
* CASE i.role WHEN 'debt' THEN 1 ELSE -1 END * t.exchangerate)
|
|
166707
|
+
* CASE i.role WHEN 'debt' THEN 1 ELSE -1 END * t.exchangerate)) AS open
|
|
166681
166708
|
FROM ns_item_original i JOIN ns_transactions t ON t.id=i.doc WHERE i.side=@side AND t.trandate<=@to AND (@subsidiary IS NULL OR i.subsidiary=@subsidiary)
|
|
166682
166709
|
GROUP BY i.doc,i.entity,i.account ORDER BY t.trandate,t.id,i.account`).all({ to, side: side === "ar" ? "receivable" : "payable", subsidiary: subsidiary ?? null }).filter((row2) => row2.open !== 0);
|
|
166683
166710
|
}
|
|
@@ -167586,7 +167613,7 @@ var init_searches = __esm({
|
|
|
167586
167613
|
iso20 = (d) => d.toISOString().slice(0, 10);
|
|
167587
167614
|
at2 = (y, m, d) => new Date(Date.UTC(y, m, d));
|
|
167588
167615
|
SUMMARIES = ["group", "count", "sum", "avg", "min", "max"];
|
|
167589
|
-
money12 = (value4) => value4 === void 0 ? "" : Number(value4).toFixed(2);
|
|
167616
|
+
money12 = (value4) => value4 === void 0 ? "" : round(Number(value4)).toFixed(2);
|
|
167590
167617
|
}
|
|
167591
167618
|
});
|
|
167592
167619
|
|
|
@@ -177592,9 +177619,9 @@ function logTail(data5, cap) {
|
|
|
177592
177619
|
if (newline !== -1 && newline < data5.length - 1) start = newline + 1;
|
|
177593
177620
|
return Buffer.concat([note2(start), data5.subarray(start)]);
|
|
177594
177621
|
}
|
|
177595
|
-
function capFor(path6) {
|
|
177622
|
+
function capFor(path6, inputsBytes = BUNDLE_LIMITS2.largeFileBytes) {
|
|
177596
177623
|
const name5 = path6.slice(path6.lastIndexOf("/") + 1);
|
|
177597
|
-
return name5 === "trace.jsonl" || name5 === "state.json" ? BUNDLE_LIMITS2.largeFileBytes : name5 === "agent.log" ? BUNDLE_LIMITS2.agentLogBytes : BUNDLE_LIMITS2.fileBytes;
|
|
177624
|
+
return name5 === "trace.jsonl" || name5 === "state.json" ? BUNDLE_LIMITS2.largeFileBytes : name5 === "agent.log" ? BUNDLE_LIMITS2.agentLogBytes : path6 === "inputs.json" ? inputsBytes : BUNDLE_LIMITS2.fileBytes;
|
|
177598
177625
|
}
|
|
177599
177626
|
async function runFiles(runDir, source) {
|
|
177600
177627
|
const root3 = await readdir(runDir, { withFileTypes: true });
|
|
@@ -177615,7 +177642,7 @@ async function packRun(options4) {
|
|
|
177615
177642
|
const entries3 = [], omitted = [];
|
|
177616
177643
|
for (const path6 of paths2) {
|
|
177617
177644
|
let data5 = redact(await readFile3(join4(options4.runDir, path6)), options4.secrets);
|
|
177618
|
-
const cap = capFor(path6);
|
|
177645
|
+
const cap = capFor(path6, options4.inputsBytes);
|
|
177619
177646
|
if (data5.length > cap) {
|
|
177620
177647
|
if (path6.endsWith("/agent.log")) data5 = logTail(data5, cap);
|
|
177621
177648
|
else if (options4.source === "cloud" && MANDATORY_CLOUD_PATH.test(path6)) throw tooBig(`run ${options4.runId}: ${path6} is ${data5.length} bytes; a run keeps at most ${cap}`);
|
|
@@ -206566,7 +206593,7 @@ async function executeRun(opts) {
|
|
|
206566
206593
|
// A world's seed once (run-inputs.ts). Names only, never values: what a later `ancha runs upload` redacts (hosting spec §3.1).
|
|
206567
206594
|
agentEnvironment: { passEnv: agent.passEnv ?? [], inheritEnv: agent.inheritEnv === true },
|
|
206568
206595
|
isolation: { execution: executionDescription(agent), toolWorld: "fresh-per-attempt", agentProcess: agent.mode === "endpoint" && agent.start === void 0 ? "external-setup-adapter" : "fresh-per-attempt", agentState: agent.execution?.mode === "container" ? "fresh-container-scratch" : "provided-namespace-only", limits: agent.execution?.mode === "container" ? "Local Linux container, read-only source, bounded scratch, scoped tool gateway and explicit model hosts; not a multi-tenant cloud security certification." : "Agent files and external memory are shared unless the agent uses ANCHA_STATE_DIR or ANCHA_ATTEMPT_ID. This is not host or network isolation." }
|
|
206569
|
-
}
|
|
206596
|
+
})}
|
|
206570
206597
|
`, { flag: "wx", mode: 384 });
|
|
206571
206598
|
const kept = /* @__PURE__ */ new Map();
|
|
206572
206599
|
for (const [index, item2] of cases.entries()) {
|
package/lib/world-server.mjs
CHANGED
|
@@ -100895,6 +100895,9 @@ function carrierPortalSeedRecords(seed43) {
|
|
|
100895
100895
|
];
|
|
100896
100896
|
}
|
|
100897
100897
|
|
|
100898
|
+
// packages/core/src/tools/netsuite-money.ts
|
|
100899
|
+
var netsuiteRound = (value4) => Math.sign(value4) * Math.round(Number(`${Math.abs(value4).toFixed(10)}e2`)) / 100 || 0;
|
|
100900
|
+
|
|
100898
100901
|
// packages/core/src/tools/netsuite.ts
|
|
100899
100902
|
var NETSUITE_ACCOUNT_TYPES = [
|
|
100900
100903
|
"Bank",
|
|
@@ -101400,7 +101403,7 @@ function checkSeed(seed43, report3) {
|
|
|
101400
101403
|
}
|
|
101401
101404
|
function books(seed43, issue6, money13) {
|
|
101402
101405
|
if (seed43.integration.customerCreditLimitHandlingOverride && !seed43.policy.allowCustomerCreditLimitHandlingOverride) issue6(["integration", "customerCreditLimitHandlingOverride"], "credit handling override requires policy permission");
|
|
101403
|
-
const round2 =
|
|
101406
|
+
const round2 = netsuiteRound;
|
|
101404
101407
|
const accountById = new Map(seed43.accounts.map((a) => [a.id, a])), itemById = new Map(seed43.items.map((i) => [i.id, i]));
|
|
101405
101408
|
const itemTotal = (lines2) => round2(lines2.reduce((sum5, line2) => sum5 + round2(line2.quantity * (line2.rate ?? itemById.get(line2.item)?.rate ?? 0)), 0));
|
|
101406
101409
|
const buyTotal = (lines2) => round2(lines2.reduce((sum5, line2) => sum5 + round2(line2.quantity * (line2.rate ?? itemById.get(line2.item)?.cost ?? itemById.get(line2.item)?.rate ?? 0)), 0));
|
|
@@ -157924,14 +157927,14 @@ CREATE VIEW ns_q_transaction AS SELECT t.id, t.tranid, t.trandate, t.type, t.rec
|
|
|
157924
157927
|
CREATE VIEW ns_q_transactionline AS
|
|
157925
157928
|
-- Reserve four digits for the line; transaction IDs up to 2000000000 stay below 2^53.
|
|
157926
157929
|
SELECT 0 AS id, t.id * 10000 AS uniquekey, t.id AS "transaction", 0 AS linesequencenumber, 'T' AS mainline, 'F' AS taxline, NULL AS item, NULL AS itemtype, NULL AS quantity,
|
|
157927
|
-
NULL AS rate,
|
|
157930
|
+
NULL AS rate, ns_round(${signed("t.total", 0)} * t.exchangerate) AS netamount, ${signed("t.total", 0)} AS foreignamount, t.memo, NULL AS expenseaccount, t.account, t.entity, t.subsidiary,
|
|
157928
157931
|
t.department, t.location, t.class, t.createdfrom, 'F' AS isclosed,
|
|
157929
157932
|
NULL AS debit, NULL AS credit, NULL AS quantitybilled, NULL AS quantityshiprecv, NULL AS quantitycommitted, NULL AS category, NULL AS costestimate, t.extra, 'F' AS iscogs
|
|
157930
157933
|
FROM ns_transactions t WHERE t.type <> 'Journal'
|
|
157931
157934
|
UNION ALL
|
|
157932
157935
|
SELECT l.line AS id, l."transaction" * 10000 + l.line AS uniquekey, l."transaction", l.line, 'F', 'F', l.item, i.itemtype,
|
|
157933
157936
|
${signed("l.quantity", 2)}, l.rate,
|
|
157934
|
-
|
|
157937
|
+
ns_round(CASE WHEN t.type = 'Journal' THEN COALESCE(l.debit, 0) - COALESCE(l.credit, 0) WHEN t.type IN ('ItemShip', 'ItemRcpt') THEN NULL ELSE ${signed("l.amount", 1)} END * t.exchangerate),
|
|
157935
157938
|
CASE WHEN t.type = 'Journal' THEN COALESCE(l.debit, 0) - COALESCE(l.credit, 0) WHEN t.type IN ('ItemShip', 'ItemRcpt') THEN NULL ELSE ${signed("l.amount", 1)} END,
|
|
157936
157939
|
COALESCE(l.memo, l.description), l.account, l.account, COALESCE(l.entity, t.entity), t.subsidiary, COALESCE(l.department, t.department),
|
|
157937
157940
|
COALESCE(l.location, t.location), COALESCE(l.class, t.class), l.createdfrom, ${bool8("l.isclosed")}, l.debit, l.credit,
|
|
@@ -158554,6 +158557,12 @@ function upgradeSchema(db3) {
|
|
|
158554
158557
|
})();
|
|
158555
158558
|
}
|
|
158556
158559
|
|
|
158560
|
+
// packages/server/src/twins/netsuite/money.ts
|
|
158561
|
+
var round = netsuiteRound;
|
|
158562
|
+
function registerRound(db3) {
|
|
158563
|
+
db3.function("ns_round", { deterministic: true }, (value4) => value4 === null || value4 === void 0 ? null : round(Number(value4)));
|
|
158564
|
+
}
|
|
158565
|
+
|
|
158557
158566
|
// packages/server/src/twins/netsuite/banking-schema.ts
|
|
158558
158567
|
var isBanking = (type) => ["bankingTransaction", "bankRecSuggestion", "transactionMatch"].includes(type);
|
|
158559
158568
|
var read5 = (kind, target4) => ({ kind, ...target4 && { target: target4 } });
|
|
@@ -161381,6 +161390,7 @@ function sql(ctx) {
|
|
|
161381
161390
|
upgradeSchema(db3);
|
|
161382
161391
|
const registered = { clock: ctx.clock };
|
|
161383
161392
|
db3.function("ns_today", { deterministic: false }, () => registered.clock.now().toISOString().slice(0, 10));
|
|
161393
|
+
registerRound(db3);
|
|
161384
161394
|
clocks.set(db3, holder = registered);
|
|
161385
161395
|
}
|
|
161386
161396
|
holder.clock = ctx.clock;
|
|
@@ -161388,7 +161398,6 @@ function sql(ctx) {
|
|
|
161388
161398
|
}
|
|
161389
161399
|
var today = (ctx) => ctx.clock.now().toISOString().slice(0, 10);
|
|
161390
161400
|
var stamp5 = (ctx) => ctx.clock.now().toISOString().replace(/\.\d{3}Z$/, "Z");
|
|
161391
|
-
var round = (value4) => Math.sign(value4) * Math.round(Number(`${Math.abs(value4).toFixed(10)}e2`)) / 100 || 0;
|
|
161392
161401
|
var qty = (value4) => Math.round(value4 * 1e8) / 1e8;
|
|
161393
161402
|
var addDays = (date10, days) => new Date(Date.parse(`${date10}T00:00:00Z`) + days * 864e5).toISOString().slice(0, 10);
|
|
161394
161403
|
var json31 = (text23) => {
|
|
@@ -163764,6 +163773,7 @@ var nth = (re, source, position, occurrence) => {
|
|
|
163764
163773
|
return void 0;
|
|
163765
163774
|
};
|
|
163766
163775
|
function installFunctions(db3, hierarchy) {
|
|
163776
|
+
registerRound(db3);
|
|
163767
163777
|
const register3 = (name5, fn) => {
|
|
163768
163778
|
db3.function(`ns_suiteql_${name5}`, { deterministic: true, varargs: true }, fn);
|
|
163769
163779
|
};
|
|
@@ -165011,10 +165021,10 @@ function balanceSheet(ctx, p2) {
|
|
|
165011
165021
|
}
|
|
165012
165022
|
function openItems2(ctx, side, to, subsidiary) {
|
|
165013
165023
|
return sql(ctx).prepare(`SELECT t.id,t.type,t.tranid,t.trandate,t.duedate,i.entity,t.otherrefnum,
|
|
165014
|
-
|
|
165024
|
+
ns_round(SUM((i.original - COALESCE((SELECT SUM(a.amount) FROM ns_applications a JOIN ns_transactions owner ON owner.id=a.payment
|
|
165015
165025
|
WHERE owner.trandate<=@to AND ((i.role='debt' AND a.doc=i.doc AND a.docline=i.line) OR (i.role='credit' AND a.source=i.doc AND a.sourceline=i.line))),0)
|
|
165016
165026
|
- CASE WHEN i.role='credit' THEN COALESCE((SELECT SUM(a.amount) FROM ns_applications a JOIN ns_transactions owner ON owner.id=a.payment WHERE owner.trandate<=@to AND a.doc=i.doc AND a.docline=i.line),0) ELSE 0 END)
|
|
165017
|
-
* CASE i.role WHEN 'debt' THEN 1 ELSE -1 END * t.exchangerate)
|
|
165027
|
+
* CASE i.role WHEN 'debt' THEN 1 ELSE -1 END * t.exchangerate)) AS open
|
|
165018
165028
|
FROM ns_item_original i JOIN ns_transactions t ON t.id=i.doc WHERE i.side=@side AND t.trandate<=@to AND (@subsidiary IS NULL OR i.subsidiary=@subsidiary)
|
|
165019
165029
|
GROUP BY i.doc,i.entity,i.account ORDER BY t.trandate,t.id,i.account`).all({ to, side: side === "ar" ? "receivable" : "payable", subsidiary: subsidiary ?? null }).filter((row2) => row2.open !== 0);
|
|
165020
165030
|
}
|
|
@@ -165803,7 +165813,7 @@ function expression2(ctx, type, filters, params10, plan4) {
|
|
|
165803
165813
|
return out.join(" ");
|
|
165804
165814
|
}
|
|
165805
165815
|
var SUMMARIES = ["group", "count", "sum", "avg", "min", "max"];
|
|
165806
|
-
var money12 = (value4) => value4 === void 0 ? "" : Number(value4).toFixed(2);
|
|
165816
|
+
var money12 = (value4) => value4 === void 0 ? "" : round(Number(value4)).toFixed(2);
|
|
165807
165817
|
function listSearches(ctx, args) {
|
|
165808
165818
|
const needle = args.query?.trim().toLowerCase();
|
|
165809
165819
|
return { success: true, savedSearches: (config10(ctx).savedSearches ?? []).filter((s2) => !needle || s2.title.toLowerCase().includes(needle) || s2.id.includes(needle)).map((s2) => ({ id: s2.id, internalId: s2.internalId, title: s2.title, recordType: s2.type, isPublic: s2.isPublic })) };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ancha-labs/cli",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.14",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Simulation playgrounds for agents: run your agent against stateful replicas of Slack, GitHub, Datadog and more, each attempt on a fresh cloud machine in your app.ancha.io workspace, or on your computer.",
|
|
6
6
|
"bugs": {
|