@accounter/server
Version:
Accounter GraphQL server
25 lines (24 loc) • 1.69 kB
TypeScript
import { Injector } from 'graphql-modules';
import type { BatchUpdateBusinessInput } from '../../../__generated__/types.js';
import type { IGetBusinessesByIdsResult } from '../types.js';
/**
* Apply one set of field values to many businesses.
*
* Every touched table gets a single statement for the whole selection, so the cost is a small fixed
* number of queries regardless of how many businesses were selected:
* - `businesses` (locality, flags, suggestion description) — one `batchUpdateBusinesses`
* - `financial_entities` (sort code, IRS code, active) — one `batchUpdateFinancialEntities`
* - `business_tax_category_match` (tax category) — one upsert
* plus one read to return the refreshed rows.
*
* Only the fields present in `fields` are written; the statements `COALESCE` every column against
* itself, so an absent field leaves each business's own value alone.
*/
export declare function applyBatchBusinessUpdate(injector: Injector, businessIds: readonly string[], ownerId: string, fields: BatchUpdateBusinessInput): Promise<IGetBusinessesByIdsResult[]>;
/**
* Add and/or remove suggestion tags across many businesses, leaving each business's other tags
* untouched. Mirrors the charges-side `applyChargeTagChanges`, but business suggestion tags live
* inside the `suggestion_data` JSON blob rather than a join table, so the whole selection is handled
* by one statement (the set arithmetic runs in SQL). An id passed in both lists ends up added.
*/
export declare function applyBatchBusinessTagChanges(injector: Injector, businessIds: readonly string[], addTagIds: readonly string[], removeTagIds: readonly string[]): Promise<IGetBusinessesByIdsResult[]>;