diff --git a/.changeset/33911-extension-sibling-currency-field.md b/.changeset/33911-extension-sibling-currency-field.md new file mode 100644 index 00000000000..62bb3b99bdf --- /dev/null +++ b/.changeset/33911-extension-sibling-currency-field.md @@ -0,0 +1,21 @@ +--- +'@objectstack/objectql': minor +--- + +fix(objectql): an `object_extension` whose record-mode amount names a sibling `currencyField` the served object does not hold is refused at the save, not at every write + +Clause-②: no (narrowing) +Metadata-protocol: narrowed +Skills-docs: none — `skills/objectstack-data/rules/field-types.md` already says a record-mode amount's code lives in the `text` field `currencyField` names, declaring `valueDomain: 'iso_4217_currency'`, with no carve-out for an extension; the refusal now makes that true for an extension's amount, and its text carries the prescription + + + +**BREAKING** accept-set narrowing, shipped as `minor`. An object body whose record-mode amount names a one-segment `currencyField` it does not declare, or a field holding no ISO 4217 code, is refused `422 INVALID_METADATA` at parse. An extension's amount cannot be judged there, because its pointer may name a field only the owner declares, and the record-currency follow door judged an extension only on the two-segment `MASTER_DETAIL.CODE` path. So `PUT /api/v1/meta/object_extension/showcase_invoice` adding `fee: { type: 'currency', currencyConfig: { currencyMode: 'record', currencyField: 'zz_missing' } }` answered 200 and was served, and every later write of `fee` was refused `ERR_CURRENCY_CODE_REQUIRED`, prescribing a write into `zz_missing`, which does not exist. + +- **The verdict.** The follow door (`SchemaRegistry.objectRegistrationRefusal` with `againstRegistry`, and the end of an install, upgrade or reload on a running server) now judges a one-segment pointer against the object AS SERVED: its base, every enabled extension, and the incoming body. A pointer naming no other field, or a field that is not a `text` field declaring `valueDomain: 'iso_4217_currency'`, is refused `422 INVALID_METADATA` (`RecordCurrencyFollowRefusedError`), naming the amount, the pointer and the object's code-field candidates; nothing is stored. +- **Admitted as before.** A pointer naming a code field the owner declares, the same extension adds, or another enabled extension adds. +- **The owner's end.** An owner re-registering without the code field an extension's amount names is refused, naming the package that adds the amount. +- **Runs and single saves.** An install, upgrade or reload that leaves such a pointer as it found it is not refused over it. A published single save and the batch writers judge with the slot left empty: re-publishing an unchanged extension whose pointer a cold boot admitted is refused, and so is a published save of the owner while an extension's amount names no code field. Correct that extension's pointer (or uninstall it), then save the owner again unchanged. +- **Not asked.** The cold boot: packages installed before this release keep loading. + +One-line fix: point the amount's `currencyField` at the extended object's ISO 4217 code field (the refusal lists the candidates), or add one in the same extension and name it. diff --git a/packages/objectql/src/manifest-service-artifact-refusal-restores.test.ts b/packages/objectql/src/manifest-service-artifact-refusal-restores.test.ts index d7eba44427b..5bf3cedcada 100644 --- a/packages/objectql/src/manifest-service-artifact-refusal-restores.test.ts +++ b/packages/objectql/src/manifest-service-artifact-refusal-restores.test.ts @@ -997,3 +997,66 @@ describe('[#33593] an extension\'s record-mode amount is judged against its obje expect(fieldOf(ql, 'suite_line', 'inv2')?.reference).toBe('suite_invoice'); }); }); + +// ── [ADR-0144 D2] An extension's ONE-SEGMENT pointer, judged as its object is served, at the end of the run ── +// +// Pair (b) of the follow door: a record-mode amount an extension adds whose +// `currencyField` is a sibling name is judged against the served object. A run +// that adds a dangling one is refused; a run that leaves one as it found it +// (one a cold boot admitted unasked) is not (R7); a run that breaks one is +// refused naming the extension's package (R6). +describe('an extension\'s sibling record-currency pointer is judged against its object as served, at the end of the run', () => { + /** The child, holding an ISO 4217 code of its own under `currency_code` (none when `withCode` is false). */ + const coded = (withCode = true) => object('suite_line', { + fields: { + title: { type: 'text', label: 'Title' }, + invoice: { type: 'master_detail', label: 'Invoice', reference: 'suite_invoice' }, + ...(withCode ? { currency_code: CODE } : {}), + }, + }); + + it('an extension-only install naming no field of the served object is refused 422, naming the candidates, and leaves nothing', async () => { + const { ql, manifest } = await boot(); + await manifest.register(ledger('currency_code')); + await manifest.register(billing([coded()])); + + const err = await refusal(() => manifest.register(extender({ ext_amount: follows('zz_missing') }), { source: 'marketplace' })); + + expect(err).toMatchObject({ ...FOLLOW_REFUSED, objectName: 'suite_line', fieldName: 'ext_amount' }); + expect(String(err?.message)).toContain("'zz_missing'"); + expect(String(err?.message)).toContain("candidates: 'currency_code'"); + expect(extraOf(ql)).toBeUndefined(); + expect(ql.registry.getPackage(EXTENDER)).toBeUndefined(); + }); + + it('CONTROL: the extension naming the code field the owner declares installs', async () => { + const { ql, manifest } = await boot(); + await manifest.register(ledger('currency_code')); + await manifest.register(billing([coded()])); + + await manifest.register(extender({ ext_amount: follows('currency_code') }), { source: 'marketplace' }); + + expect(extraOf(ql)?.currencyConfig?.currencyField).toBe('currency_code'); + }); + + it('R7: a no-change upgrade of the owner, and of the extension, installs over a dangling pointer a cold boot admitted', async () => { + const { ql, manifest } = await bootWith([ledger('currency_code'), billing([coded()]), extender({ ext_amount: follows('zz_missing') })]); + expect(extraOf(ql)?.currencyConfig?.currencyField).toBe('zz_missing'); + + await manifest.register(billing([coded()], '1.0.1')); + await manifest.register(extender({ ext_amount: follows('zz_missing') }, '1.0.1')); + + expect(ql.registry.getPackage(BILLING)?.manifest?.version).toBe('1.0.1'); + expect(ql.registry.getPackage(EXTENDER)?.manifest?.version).toBe('1.0.1'); + }); + + it('R6: an owner upgrade that removes the code field an extension\'s amount names is refused, naming the extension\'s package', async () => { + const { ql, manifest } = await bootWith([ledger('currency_code'), billing([coded()]), extender({ ext_amount: follows('currency_code') })]); + + const err = await refusal(() => manifest.register(billing([coded(false)], '1.0.1'))); + + expect(err).toMatchObject({ ...FOLLOW_REFUSED, objectName: 'suite_line', fieldName: 'ext_amount' }); + expect(String(err?.message)).toContain(`'${EXTENDER}'`); + expect(ql.registry.getPackage(BILLING)?.manifest?.version).toBe('1.0.0'); + }); +}); diff --git a/packages/objectql/src/protocol-batch-object-registration.test.ts b/packages/objectql/src/protocol-batch-object-registration.test.ts index 944fa1376b8..d03adf90a6d 100644 --- a/packages/objectql/src/protocol-batch-object-registration.test.ts +++ b/packages/objectql/src/protocol-batch-object-registration.test.ts @@ -715,3 +715,113 @@ describe('[#33713] a metadata-API save of a `dynamic` roll-up over a child field expect(activeRow(h, 'object_extension', 'homeroll_project', P)).toBeUndefined(); }); }); + +// ── [ADR-0144 D2, amended] An extension's ONE-SEGMENT record-currency pointer, judged as its object is served ── +// +// `ObjectSchema` refuses a record-mode amount whose sibling `currencyField` +// names no code field of the object; `ObjectExtensionSchema` cannot (an +// extension's pointer may name a field only the owner declares). The follow +// door judges the pointer against the object AS SERVED — the owner, every +// enabled extension, and this body in its slot — so a pointer into nothing is +// refused at the save, never at every later write of the amount. +describe('an object_extension\'s record-mode amount naming a sibling code field is judged against its object as served', () => { + const P = 'com.qa.sib'; + const X = 'com.qa.siblingext'; + const fee = (pointer: string) => ({ name: 'fee', type: 'currency', label: 'Fee', currencyConfig: { currencyMode: 'record', currencyField: pointer } }); + const caught = async (run: () => Promise): Promise => { + try { + await run(); + } catch (e) { + return e; + } + return undefined; + }; + async function bootWithInvoice(owner: Record = invoice('sib')): Promise { + const h = await boot(); + vi.spyOn(console, 'warn').mockImplementation(() => {}); + await h.protocol.installPackage({ manifest: { id: P, name: 'Sibling', type: 'app' } }); + await h.protocol.saveMetaItem({ type: 'object', name: String(owner.name), packageId: P, item: owner, writeFace: 'external-import' }); + return h; + } + const saveExtension = (h: Harness, fields: Record) => h.protocol.saveMetaItem({ + type: 'object_extension', name: 'sib_invoice', packageId: P, mode: 'publish', writeFace: 'meta-envelope', + item: { extend: 'sib_invoice', fields }, + }); + + it('refuses 422 INVALID_METADATA a pointer naming no field of the served object, naming the field and the code-field candidates, and stores nothing', async () => { + const h = await bootWithInvoice(); + const err = await caught(() => saveExtension(h, { fee: fee('zz_missing') })); + expect(err).toMatchObject({ status: 422, code: 'INVALID_METADATA', name: 'RecordCurrencyFollowRefusedError', objectName: 'sib_invoice', fieldName: 'fee' }); + expect(err.message).toContain("'zz_missing'"); + expect(err.message).toContain("candidates: 'currency_code'"); + expect(registered(h, 'sib_invoice')?.fields?.fee).toBeUndefined(); + expect(activeRow(h, 'object_extension', 'sib_invoice', P)).toBeUndefined(); + }); + + it('refuses a pointer naming a served field that holds no ISO 4217 code', async () => { + const h = await bootWithInvoice(); + const err = await caught(() => saveExtension(h, { fee: fee('title') })); + expect(err).toMatchObject({ status: 422, code: 'INVALID_METADATA', objectName: 'sib_invoice', fieldName: 'fee' }); + expect(err.message).toContain("a 'text' field that does not hold an ISO 4217 code"); + expect(err.message).toContain("candidates: 'currency_code'"); + expect(activeRow(h, 'object_extension', 'sib_invoice', P)).toBeUndefined(); + }); + + it('says the object has no code field when the served object holds none', async () => { + const { currency_code: _code, ...withoutCode } = invoice('sib').fields; + const h = await bootWithInvoice({ ...invoice('sib'), fields: withoutCode }); + const err = await caught(() => saveExtension(h, { fee: fee('currency_code') })); + expect(err).toMatchObject({ status: 422, code: 'INVALID_METADATA', fieldName: 'fee' }); + expect(err.message).toContain("it has none; declare one"); + }); + + it('CONTROL: a pointer naming the code field the owner declares is saved and served', async () => { + const h = await bootWithInvoice(); + await saveExtension(h, { fee: fee('currency_code') }); + expect(registered(h, 'sib_invoice')?.fields?.fee?.currencyConfig?.currencyField).toBe('currency_code'); + expect(activeRow(h, 'object_extension', 'sib_invoice', P)).toBeDefined(); + }); + + it('CONTROL: a pointer naming a code field the same body, or another registered extension, declares is saved', async () => { + const { currency_code: _code, ...withoutCode } = invoice('sib').fields; + const h = await bootWithInvoice({ ...invoice('sib'), fields: withoutCode }); + await saveExtension(h, { own_code: { name: 'own_code', type: 'text', label: 'Code', ...CODE }, fee: fee('own_code') }); + expect(registered(h, 'sib_invoice')?.fields?.fee?.currencyConfig?.currencyField).toBe('own_code'); + + const other = await bootWithInvoice({ ...invoice('sib'), fields: withoutCode }); + other.engine.registry.registerObject({ name: 'sib_invoice', fields: { ext_code: { name: 'ext_code', type: 'text', label: 'Code', ...CODE } } } as never, X, undefined, 'extend'); + await saveExtension(other, { fee: fee('ext_code') }); + expect(registered(other, 'sib_invoice')?.fields?.fee?.currencyConfig?.currencyField).toBe('ext_code'); + }); + + it('the owner re-saved without the code field a registered extension\'s amount names is refused, naming the package that adds the amount', async () => { + const h = await bootWithInvoice(); + h.engine.registry.registerObject({ name: 'sib_invoice', fields: { fee: fee('currency_code') } } as never, X, undefined, 'extend'); + const { currency_code: _code, ...withoutCode } = invoice('sib').fields; + const refusal = h.engine.registry.objectRegistrationRefusal({ ...invoice('sib'), fields: withoutCode } as never, P, 'own', { againstRegistry: true }); + expect(refusal).toMatchObject({ name: 'RecordCurrencyFollowRefusedError', status: 422, code: 'INVALID_METADATA', objectName: 'sib_invoice', fieldName: 'fee' }); + expect(refusal?.message).toContain(`package '${X}'`); + }); + + // A single save asks with its slot left empty (`before: null`), so it does + // not get the run's R7 comparison: a pointer already dangling when the save + // arrives (registered unasked, as a cold boot registers it) refuses both an + // unchanged re-publish of that extension and an unchanged owner save. + it('a published single save is refused over a sibling pointer that already dangles: the extension\'s unchanged re-publish, and the owner\'s unchanged save', async () => { + const h = await bootWithInvoice(); + h.engine.registry.registerObject({ name: 'sib_invoice', fields: { fee: fee('zz_missing') } } as never, P, undefined, 'extend'); + expect(registered(h, 'sib_invoice')?.fields?.fee?.currencyConfig?.currencyField).toBe('zz_missing'); + + const republish = await caught(() => saveExtension(h, { fee: fee('zz_missing') })); + expect(republish).toMatchObject({ status: 422, code: 'INVALID_METADATA', name: 'RecordCurrencyFollowRefusedError', objectName: 'sib_invoice', fieldName: 'fee' }); + expect(activeRow(h, 'object_extension', 'sib_invoice', P)).toBeUndefined(); + + const other = await bootWithInvoice(); + other.engine.registry.registerObject({ name: 'sib_invoice', fields: { fee: fee('zz_missing') } } as never, X, undefined, 'extend'); + // Asked as the single save asks it (a protocol re-save of the owner first meets the destructive-change + // door, which reads the extension's column as one the body would drop). + const ownerSave = other.engine.registry.objectRegistrationRefusal(invoice('sib') as never, P, 'own', { againstRegistry: true }); + expect(ownerSave).toMatchObject({ status: 422, code: 'INVALID_METADATA', name: 'RecordCurrencyFollowRefusedError', objectName: 'sib_invoice', fieldName: 'fee' }); + expect(String(ownerSave?.message)).toContain(`package '${X}'`); + }); +}); diff --git a/packages/objectql/src/record-currency-aggregate-door.ts b/packages/objectql/src/record-currency-aggregate-door.ts index 3d547dd623e..564929038d4 100644 --- a/packages/objectql/src/record-currency-aggregate-door.ts +++ b/packages/objectql/src/record-currency-aggregate-door.ts @@ -83,10 +83,12 @@ import { StandardErrorCode } from '@objectstack/spec/api'; import { + isRecordCurrencyCodeField, isTenantCurrencyAmount, recordCurrencyDynamicRollupNotHomeError, recordCurrencyFollowedCodeError, recordCurrencyUnfollowedRollupError, + VALUE_DOMAIN_FIELD_TYPES, } from '@objectstack/spec/data'; import { recordCurrencyFieldOf, recordCurrencyPathOf, type RecordCurrencyPath } from './validation/record-currency-code.js'; @@ -458,6 +460,44 @@ export function recordCurrencyFollowRefusalOverEnvironmentObjects( ); } +/** The code fields of `fields`, as the prescription names them (the spec's own wording, `record-currency-path.ts`). */ +function siblingCodeFieldCandidates(fields: Record): string { + const names = Object.keys(fields).filter((k) => isRecordCurrencyCodeField(fields[k])); + return names.length > 0 + ? `candidates: ${names.map((n) => `'${n}'`).join(', ')}` + : 'it has none; declare one, conventionally `currency_code: Field.text({ valueDomain: \'iso_4217_currency\' })`'; +} + +/** + * [ADR-0144 D2] (b) The refusal of a record-mode amount `field` of `object` + * whose one-segment `currencyField` `pointer` names no other field of + * `fields` (the object as served), or a field that holds no ISO 4217 code + * (`isRecordCurrencyCodeField`); `undefined` when it names a code field. The + * served-object twin of `ObjectSchema`'s sibling-pointer refusal, which judges + * the authored field map and so cannot see a field an owner or another + * extension supplies to an extension's amount. + */ +function recordCurrencySiblingCodeError( + object: string, + field: string, + pointer: string, + fields: Record, +): string | undefined { + const where = `Object '${object}' field '${field}' currencyConfig.currencyField`; + const target = pointer !== field && Object.prototype.hasOwnProperty.call(fields, pointer) ? fields[pointer] : undefined; + if (target === null || typeof target !== 'object') { + return `${where}: '${pointer}' names no other field of '${object}' as it is served (its own fields and every ` + + `enabled extension's), so the amount has no code to read and every write of it would be refused. Name the ` + + `field of '${object}' that holds each record's ISO 4217 code — ${siblingCodeFieldCandidates(fields)}.`; + } + if (isRecordCurrencyCodeField(target)) return undefined; + const codeTypes = [...VALUE_DOMAIN_FIELD_TYPES].map((t) => `\`${t}\``).join(' or '); + return `${where}: '${pointer}' names '${object}.${pointer}', a '${String((target as { type?: unknown }).type)}' ` + + 'field that does not hold an ISO 4217 code, so a write could store any value as the currency. A record ' + + `currency is a ${codeTypes} field declaring \`valueDomain: 'iso_4217_currency'\` on '${object}' — ` + + `${siblingCodeFieldCandidates(fields)}.`; +} + /** A `summary` field declaring `currencyConfig.currencyMode: 'record'`. */ function declaresRecordCurrency(def: unknown): boolean { const config = (def as { currencyConfig?: unknown } | null)?.currencyConfig; @@ -491,7 +531,7 @@ export interface RecordCurrencyFollowRegistryView { /** * [ADR-0144 D2 and D6, amended] The refusal for an object layer about to * register (or one of a unit just registered, asked with the whole unit in - * the view), or `undefined`. Two pairs, each judged at whichever registration + * the view), or `undefined`. Each pair is judged at whichever registration * completes it; a pair with an end not registered yet is no verdict: * * - (a) a record-mode amount whose `currencyField` is the path @@ -502,6 +542,16 @@ export interface RecordCurrencyFollowRegistryView { * child registered. Every write of such an amount is otherwise refused * `ERR_CURRENCY_CODE_REQUIRED` (no code to read) or labelled with whatever * the field holds; + * - (b) a record-mode amount whose `currencyField` is ONE segment, a sibling + * name, that names no other field of the object as served, or a field that + * holds no ISO 4217 code ({@link recordCurrencySiblingCodeError}). + * `ObjectSchema` refuses it on an object body, against the authored field + * map; an `extend` contribution's pointer may name a field only its owner + * or another extension declares, so `ObjectExtensionSchema` leaves it to + * this door, which reads the object as served. Judged at the registration + * of any of the object's layers. Every write of such an amount is + * otherwise refused `ERR_CURRENCY_CODE_REQUIRED`, prescribing a field no + * write can fill; * - (c) a `summary` declaring `currencyMode: 'record'` that rolls up `sum` / * `avg` / `min` / `max` of a child field following no record's currency (a * `fixed` amount, a `dynamic` one, a plain number). Judged at the parent's @@ -583,7 +633,7 @@ export function recordCurrencyFollowRefusal( * well as the pointer: a run that re-points the pair's master_detail onto * another parent makes a new pair, so it is that run's to answer for. */ -function followPairKey(kind: 'follow' | 'rollup' | 'dynamic', object: string, field: string, target: string): string { +function followPairKey(kind: 'follow' | 'sibling' | 'rollup' | 'dynamic', object: string, field: string, target: string): string { return `${kind}\u0000${object}\u0000${field}\u0000${target}`; } @@ -638,6 +688,22 @@ function* followRefusalsOf( if (message !== undefined) yield [followPairKey('follow', name, field, `${path.master}.${String(pointer)}`), new RecordCurrencyFollowRefusedError(name, field, message)]; } + // (b) within the object: its sibling pointers, against the fields it is served with. + for (const [field, def] of Object.entries(own)) { + const pointer = recordCurrencyFieldOf(def); + if (pointer === undefined || recordCurrencyPathOf(pointer, own) !== undefined) continue; + const message = recordCurrencySiblingCodeError(name, field, pointer, own); + if (message === undefined) continue; + // As R6 names it: an amount an extension adds is named with its package, + // so an owner's author learns whose field the change leaves without a code. + const extendedBy = view.extensionPackageOf(name, field); + yield [followPairKey('sibling', name, field, pointer), new RecordCurrencyFollowRefusedError( + name, + field, + extendedBy === undefined ? message : `${message} '${name}.${field}' is added to '${name}' by package '${extendedBy}'.`, + )]; + } + // The other ends, already registered: (a) at the parent, (c) and (d) at the child. for (const other of view.all()) { const otherName = typeof other.name === 'string' ? other.name : undefined; diff --git a/packages/spec/src/migrations/entries/semantic/18.record-currency-sibling-extension-judged-as-served.ts b/packages/spec/src/migrations/entries/semantic/18.record-currency-sibling-extension-judged-as-served.ts new file mode 100644 index 00000000000..5675c49045a --- /dev/null +++ b/packages/spec/src/migrations/entries/semantic/18.record-currency-sibling-extension-judged-as-served.ts @@ -0,0 +1,45 @@ +// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license. + +import type { SemanticMigration } from '../../types.js'; + +// The upgrade-guide entry of the record-currency follow door (ADR-0144 D2) as +// it now judges the ONE-SEGMENT `currencyField` of an amount an extension adds: +// against the object as the server serves it. No D2 conversion: which field +// holds each record's currency code is the author's to say. +export const entry: SemanticMigration = { + id: 'record-currency-sibling-extension-judged-as-served', + surface: + 'data.Field.currencyConfig on a field an `objectExtensions` entry (or a stored `object_extension` item) adds to ' + + 'an object: a record-mode amount whose `currencyField` is one segment, a sibling field name, judged against the ' + + 'object as the server serves it (its base, every enabled extension, and the incoming body). Where it is asked: ' + + 'a published single save of an `object_extension` item through the `/meta` doors (PUT ' + + '/api/v1/meta/object_extension/NAME), the batch writers, and an install, upgrade or reload on a running server. ' + + 'Also the owner of the extended object, re-registering without the code field an extension\'s amount names. Not ' + + 'the cold boot', + replacement: + 'Name in `currencyField` a field of the extended object that declares `valueDomain: \'iso_4217_currency\'` (the ' + + 'refusal lists the candidates), or add such a field in the same extension and name it. When the owner of the ' + + 'extended object is refused because it drops or de-codes the field an extension\'s amount names, the refusal ' + + 'names that package: keep the field, or have that package move its amount first. When the owner is refused ' + + 'over an extension\'s amount it did not change (a published single save of the owner while that amount already ' + + 'names no code field), the correction is the extension\'s package: it is saved or upgraded with the pointer ' + + 'corrected, or uninstalled, and the owner is then saved again unchanged', + reason: + 'An object body whose record-mode amount names a sibling field it does not declare, or one that holds no ISO ' + + '4217 code, is refused 422 INVALID_METADATA at parse. An extension cannot be judged there, because its pointer ' + + 'may name a field only the owner declares, and the served-object door judged only the two-segment path. Such an ' + + 'extension was saved 200 and served, and every later write of the amount was refused ERR_CURRENCY_CODE_REQUIRED, ' + + 'prescribing a write into a field that does not exist. The door now judges the sibling pointer against the ' + + 'object as served, so the save is refused 422 INVALID_METADATA naming the field and the object\'s code-field ' + + 'candidates, and a pointer naming a code field the owner or another enabled extension declares is saved as ' + + 'before. An install, upgrade or reload that leaves such a pointer as it found it is not refused over it. A ' + + 'single save and the batch writers judge against the slot left empty, so re-publishing an unchanged extension ' + + 'whose pointer a cold boot admitted is refused there, and so is a published single save of the owner while an ' + + 'extension\'s amount names no code field, as for the two-segment path. Packages installed before this ' + + 'release keep loading at every boot, which is not asked. There is no mechanical rewrite: only the author knows ' + + 'which field holds the code', + acceptanceCriteria: + 'PUT /api/v1/meta/object_extension/OBJECT?package=PKG with a record-mode amount whose currencyField names the ' + + 'object\'s code field (for example `currency_code`) answers 200, the served object carries the amount, and a ' + + 'write of the amount with a code in that field is stored', +};