vsmsconnect — API — amicus

← all endpoints

POST/api/v1/businesses/:businessId/accounting/amicus/sync auth: apikey

On-premise AMICUS agent push. Scope-bound to `amicus`. Per-row register→till routing (null till → sign-but-don't-print), `PosSaleId` persisted on `Invoices`, refund referent resolution via `originalPosSaleId`. Supports split-tender (one payment with `tenders[]`). Unrouted invoices return `outcomes[].outcome='register_unmapped'` and fire `AMICUS_RECEIPT_UNROUTED` audit.

handlers: AccountingAgentSyncController.syncAmicus

Inputs

namerequireddefaultdescription
businessId path
uuid
yes—Target business UUID.
Authorization header
string
yes—`ApiKey <key>`.
invoices body
PushInvoice[]
yes—Array of pushed invoices. Each may carry `posSaleId`, `posRegisterId`, `originalPosSaleId`, `cashierId`, and split-tender `payments[].tenders[]`.

Outputs

200
APIResponseDataObject<PushInvoicesResponse>
Push result summary including per-invoice `outcomes` for unrouted receipts.
401
APIError
Missing or invalid API key.
403
APIError
API key scope does not match `amicus`.
GET/api/v1/accounting/amicus/tax-mappings auth: jwt (administrator)

List AMICUS tax-mappings for the business (`Provider='amicus'`).

handlers: AccountingAgentTaxMappingsController.listFor('amicus')

Inputs

No parameters.

Outputs

200
APIResponseDataList<TaxRateMappingDTO>
AMICUS mappings.
PUT/api/v1/accounting/amicus/tax-mappings auth: jwt (administrator)

Upsert one AMICUS tax-mapping.

handlers: AccountingAgentTaxMappingsController.upsertFor('amicus')

Inputs

namerequireddefaultdescription
providerTaxType body
string
yes—AMICUS tax-code (typically `VAT` or `EXEMPT`).
providerTaxName body
string | null
no—Human-readable tax name.
providerRate body
number | null
no—Provider tax rate.
vsdcTaxLabel body
string
yes—V-SDC label.
vsdcRate body
number | null
no—V-SDC rate percent.

Outputs

200
APIResponseDataObject<TaxRateMappingDTO>
Upserted mapping.
422
APIError
Invalid V-SDC label.
DELETE/api/v1/accounting/amicus/tax-mappings/:providerTaxType auth: jwt (administrator)

Soft-delete an AMICUS tax-mapping (`IsActive=0`). Idempotent.

handlers: AccountingAgentTaxMappingsController.removeFor('amicus')

Inputs

namerequireddefaultdescription
providerTaxType path
string
yes—AMICUS tax-code to deactivate.

Outputs

204
empty
No content.
PATCH/api/v1/accounting/amicus/tax-mappings/:providerTaxType/restore auth: jwt (administrator)

Re-activate a deactivated AMICUS mapping (`IsActive=1`). Idempotent.

handlers: AccountingAgentTaxMappingsController.restoreFor('amicus')

Inputs

namerequireddefaultdescription
providerTaxType path
string
yes—AMICUS tax-code to re-activate.

Outputs

204
empty
No content.
POST/api/v1/businesses/:businessId/accounting/amicus/register-manifest auth: apikey

AMICUS register discovery. The sales agent posts its `dbo.Sites` + `dbo.Tills` snapshot (incrementally: only rows changed since its watermark). The cloud upserts one `Locations` row per site, left `proposed` for admin review, and one `Tills` row per till keyed on `PosRegisterId`, with `MachineId` hostname-normalised. A till's site is resolved from the payload first, then by a DB lookup of the existing location. Existing rows are never overwritten except for source-wins renames and till site moves. Fires `AMICUS_MANIFEST_RECEIVED` plus per-row rename/move audits.

handlers: AccountingAgentSyncController.registerAmicusManifest

Inputs

namerequireddefaultdescription
businessId path
uuid
yes—Target business UUID. Must match the API key's `BusinessId`; a mismatch is rejected with 403.
Authorization header
string
yes—`ApiKey <key>` — validated by `requireApiKey` against the stored key hash.
capturedAt body
number
yes—Epoch-ms time the agent captured the snapshot.
sites body
{ amicusSiteNumber: number; name: string; address1: string|null; address2: string|null; suburb: string|null; postcode: string|null }[]
yes—AMICUS sites.
tills body
{ amicusTillNumber: number; name: string; computerName: string; amicusSiteNumber: number }[]
yes—AMICUS tills. A till whose site cannot be resolved is skipped.

Outputs

200
APIResponseDataObject<AmicusRegisterManifestResponse>
Counts of what the manifest created / already had / renamed / moved.
401
APIError
AUTH_UNAUTHORIZED — missing or invalid (unknown or revoked) API key.
403
APIError
USER_FORBIDDEN — the API key does not belong to the business in the path.
403
APIError
USER_FORBIDDEN — API key scope does not match `amicus`. Unscoped keys pass.
422
APIError
VALIDATION_ERROR — body or path failed schema validation.
POST/api/v1/accounting/amicus/tax-mappings/seed-from-agent auth: apikey

AMICUS agent tax-rate seed. The sales agent posts its `dbo.SalesTax` snapshot on startup and whenever a push response carries `requestTaxRateSeed`. Every not-yet-confirmed code is written as a PROPOSAL (`UnmappedTaxTypes`) with its name and rate; nothing is auto-confirmed into `TaxRateMappings`. Already-confirmed codes are skipped unless the source rate or name has drifted, in which case the mapping is deactivated for admin review. The backend also appends the synthetic `VAT-EXCL` exempt sentinel to the proposals (never un-confirming an existing mapping). The business comes from the API key (no path businessId); only `requireApiKey` runs, with no scope check.

handlers: AmicusTaxMappingsController.seedFromAgent

Inputs

namerequireddefaultdescription
Authorization header
string
yes—`ApiKey <key>` — validated by `requireApiKey` against the stored key hash.
taxRates body
{ code: string; name?: string|null; rate?: number|null }[]
yes—Rows from AMICUS `dbo.SalesTax` (`code` and `name` are the Name value, `rate` a percentage).

Outputs

200
APIResponseDataObject<{ proposed: { code: string; name: string|null; rate: number|null }[]; alreadyMapped: number; driftDetected: number }>
Codes proposed this call, count of already-confirmed codes and count of drift deactivations.
401
APIError
AUTH_UNAUTHORIZED — missing or invalid (unknown or revoked) API key.
422
APIError
VALIDATION_ERROR — body or path failed schema validation.
POST/api/v1/accounting/amicus/tax-mappings/request-seed auth: jwt (administrator)

Admin request for a AMICUS tax-rate re-seed. Sets an in-memory per-business flag; the next AMICUS agent push response carries `requestTaxRateSeed: true`, prompting the agent to call seed-from-agent again. Business is taken from the JWT. Fires `AMICUS_TAX_MAPPING_SEED_REQUESTED`.

handlers: AmicusTaxMappingsController.requestSeed

Inputs

No parameters.

Outputs

202
APIResponseDataObject<{ requested: true }>
Re-seed flagged for the next agent push.
401
APIError
AUTH_UNAUTHORIZED — missing or invalid access token.
403
APIError
USER_FORBIDDEN — caller is not an administrator.
409
APIError
BUSINESS_CONTEXT_REQUIRED — no active business on the JWT.
GET/api/v1/businesses/:businessId/accounting/amicus/branch-mappings auth: jwt (administrator); requireBusinessAccess enforces :businessId = caller's business (administrator bypasses)

List every AMICUS branch the admin should see: the union of currently discovered branches and stored mappings, so a mapping whose branch vanished from the source is still visible. Each row carries branchId, branchName, locationId (null when unmapped), status ('active' | 'inactive'), discoveredLocationId and proposalStatus.

handlers: AmicusBranchMappingController.list

Inputs

namerequireddefaultdescription
businessId path
uuid
yes—Target business UUID.

Outputs

200
APIResponseDataObject<{ branches: AMICUSBranchMappingView[] }>
Wrapped list of branch mappings under `branches`.
403
APIError
USER_FORBIDDEN — not an administrator, or :businessId does not match the caller's business.
POST/api/v1/businesses/:businessId/accounting/amicus/branch-mappings/resync-blocked auth: jwt (administrator); requireBusinessAccess enforces :businessId = caller's business (administrator bypasses)

Re-evaluate every invoice blocked by branch-certificate routing and dispatch the ones that can now be signed. A parallel action to POST /invoices/reprocess-unmapped, which is scoped to unmapped tax codes and cannot see these block reasons. Quotes (PROFORMA) that become eligible are counted but not dispatched. Runs in the background: replies `202 { runId }` at once and stores the outcome on the run. The finished run's `result` is an `APIResponseDataObject` of the re-sync counts (`reprocessed`, `nowEligible`, `nowEligibleInvoices`, `nowEligibleQuotes`, `stillBlocked`, `autoFiscalisationJobIds`).

handlers: AmicusBranchMappingController.resyncBlocked

Inputs

namerequireddefaultdescription
businessId path
uuid
yes—Target business UUID.

Outputs

202
APIResponseDataObject<BackgroundRunAcceptedDTO>
Started in the background: `{ runId }`. Poll `GET /api/v1/businesses/:businessId/background-runs/:runId`; once `status` is `done`, `result` holds the response body this endpoint used to return.
409
APIError
BACKGROUND_RUN_IN_PROGRESS — a blocked-invoice re-sync for this business (every re-sync entry point shares one lock) is already running. `data` is `BackgroundRunInProgressDTO` (`runId`, `kind`, `params`, `startedAt`) of the running run.
403
APIError
USER_FORBIDDEN — not an administrator, or :businessId does not match the caller's business.
501
APIError
NOT_IMPLEMENTED — the branch-routed re-sync action is not wired on this deployment.
POST/api/v1/businesses/:businessId/accounting/amicus/branch-mappings/request-manifest auth: jwt (administrator); requireBusinessAccess enforces :businessId = caller's business (administrator bypasses)

Ask the AMICUS sales agent to re-send its sites and tills, so a branch or till added on the AMICUS side appears without restarting the agent. Sets a request that the agent receives as `requestManifest: true` on its next push; the agent then re-sends asynchronously, so the new rows appear shortly after this call returns.

handlers: AmicusBranchMappingController.requestManifest

Inputs

namerequireddefaultdescription
businessId path
uuid
yes—Target business UUID.

Outputs

202
empty
Request recorded; no body. The agent re-sends its sites and tills on its next push.
403
APIError
USER_FORBIDDEN — not an administrator, or :businessId does not match the caller's business.
501
APIError
NOT_IMPLEMENTED — the manifest re-send request is not wired on this deployment.
POST/api/v1/businesses/:businessId/accounting/amicus/branch-mappings/backfill auth: jwt (administrator); requireBusinessAccess enforces :businessId = caller's business (administrator bypasses)

Seed branch mappings from what already-fiscalised invoices attest to, and report which target locations hold no usable certificate. Idempotent and never overwrites an admin's own mapping; a branch whose history names several signing locations is skipped ('conflicting_history') rather than guessed.

handlers: AmicusBranchMappingController.backfill

Inputs

namerequireddefaultdescription
businessId path
uuid
yes—Target business UUID.

Outputs

200
APIResponseDataObject<object>
written[] ({ branchId, locationId }), skipped[] ({ branchId, reason: 'conflicting_history' | 'already_mapped' }), locationsWithoutCertificate[] ({ locationId, name }).
403
APIError
USER_FORBIDDEN — not an administrator, or :businessId does not match the caller's business.
501
APIError
NOT_IMPLEMENTED — the backfill action is not wired on this deployment.
PUT/api/v1/businesses/:businessId/accounting/amicus/branch-mappings/:branchId auth: jwt (administrator); requireBusinessAccess enforces :businessId = caller's business (administrator bypasses)

Assign this AMICUS branch to a business Location. The mapping decides which certificate signs the branch's invoices, so a write changes fiscalisation behaviour for its future sales. locationId is required and non-null; clearing is the separate DELETE.

handlers: AmicusBranchMappingController.setMapping

Inputs

namerequireddefaultdescription
businessId path
uuid
yes—Target business UUID.
branchId path
string
yes—AMICUS Sites.number — the source system's own identifier (1-100 chars, not a uuid).
locationId body
uuid
yes—Business Location whose certificate signs this branch's invoices.
branchName body
string
no—Branch display name at assignment time (max 255 chars), cached so the row stays labelled if the branch later disappears from the source.

Outputs

204
empty
Mapping stored.
403
APIError
USER_FORBIDDEN — not an administrator, or :businessId does not match the caller's business.
404
APIError
LOCATION_NOT_FOUND — the Location does not belong to this business.
422
APIError
VALIDATION_ERROR — schema violation.
DELETE/api/v1/businesses/:businessId/accounting/amicus/branch-mappings/:branchId auth: jwt (administrator); requireBusinessAccess enforces :businessId = caller's business (administrator bypasses)

Clear the mapping for this AMICUS branch. Idempotent: clearing an absent mapping is still 204. The branch's future invoices then block rather than falling back to the business default certificate.

handlers: AmicusBranchMappingController.clearMapping

Inputs

namerequireddefaultdescription
businessId path
uuid
yes—Target business UUID.
branchId path
string
yes—AMICUS Sites.number — the source system's own identifier (1-100 chars, not a uuid).

Outputs

204
empty
Mapping cleared (or already absent).
403
APIError
USER_FORBIDDEN — not an administrator, or :businessId does not match the caller's business.
422
APIError
VALIDATION_ERROR — schema violation.