Files
cfw-autumn/server/tests/utils/testInitUtils/setOrgCurrency.ts

24 lines
629 B
TypeScript

import { initDrizzle } from "@/db/initDrizzle.js";
const { db } = initDrizzle();
import { OrgService } from "@/internal/orgs/OrgService.js";
import { clearOrgCache } from "@/internal/orgs/orgUtils/clearOrgCache.js";
/**
* Sets an org's default_currency and clears its cached secret-key verification.
* Use a dedicated sub-org: currency is org-wide state and test files run in parallel.
*/
export const setOrgCurrency = async ({
orgId,
currency,
}: {
orgId: string;
currency: string;
}) => {
await OrgService.update({
db,
orgId,
updates: { default_currency: currency },
});
await clearOrgCache({ db, orgId });
};