Documents (DOC)
The doc submodule of acc owns the generic document/line tree that every document-shaped record in the ERP plugs into — purchase orders, sales orders, transport orders, work orders, invoices, deliveries, stock issues, partner statements, and so on. A Document is the header (with type, code, date, department, partner, optional external-system reference); a DocumentLine is one row of that document, with an optional source line pointing at the document line it was derived from. The submodule also defines the document-aspect interfaces that other modules implement to opt into shared document behaviour.
Concepts
DocumentThe header of a document tree, identified by the pair (
documentType,documentCode). Carries the date, department, partner, and optional external-system reference. ThedocumentIdis a stable UUID that survives renames.Document TypeAn enum that names what kind of document this is —
SINV,PORD,WORD,SDEL, etc. Drives how readers and writers in other submodules treat the row.Document OriginWhether the document was entered manually, generated by the system, or imported from an external system.
Document LineA single row of a document, identified by (
document,lineNumber). May reference a source document line (the line this one was derived from) and a derived root document line (the original line at the top of the source chain).Document AspectA cross-cutting interface implemented by other modules' document/line entities and view models so they can share the document-aspect framework’s behaviours (number-series allocation on save, default date on create, …).
Entities
Document (Document)
The header of a document tree.
| Field | Description |
|---|---|
| The kind of document — see Document Types below. |
| Business code allocated for the document (composite business key with |
| A stable UUID for the document; final. |
| Document date. |
| Issuing department. |
| Owning company (operational, internal — derived from the department). |
| Optional counter-party. |
| Whether the document originated outside the ERP. Default |
| Optional UUID from the external system. |
| Optional code from the external system. |
| The contained |
Document Types (DocumentType)
| Code | Name |
|---|---|
| Purchase Invoice |
| Sales Invoice |
| Purchase Order |
| Purchase Quotation |
| Purchase Receipt |
| Sales Contact |
| Sales Order |
| Sales Quotation |
| Sales Delivery |
| Transport Order |
| Work Order |
| Stock Issue |
| Stock Receipt |
| Timesheet |
| Partner Statement |
| Sentinel: no document type |
Document Origin (DocumentOrigin)
| Code | Name | Meaning |
|---|---|---|
| Manual | Created by hand from the UI. |
| Generated | Created by the system as part of a downstream flow. |
| Imported | Imported from an external system. |
Document Line (DocumentLine)
A single row of a document.
| Field | Description |
|---|---|
| Owning document (composite business key with |
| The 1-based line number within the document. |
| Optional line this one was derived from (final). |
| Optional line number from the external system. |
| Derived root of the source-line chain — the original line all the way at the top (business-information field). |
Functionality
Document creation and removal
DocumentWriterService.createDocument allocates a fresh Document for the supplied type / code / id / date / department. createDocumentLine adds a line under a document, optionally linking it to a source document line. removeDocumentLine deletes a line. These are the seams every document-issuing flow (sales order, purchase order, …) calls into to mint headers and rows.
Document aspect
DocumentAspectService is a reusable behaviour that sibling document submodules opt into through the DocumentViewModelAspect, DocumentEntityAspect, and DocumentLineEntityAspect interfaces. It centralizes:
Default document date on create —
afterCreateRecordsets thedocumentDateto the current execution date if the form left it blank.Number-series allocation on save —
getNumberSeriesresolves a configured view-model path to aNumberSeriesso the framework can allocate the next freedocumentCodewhen the document is saved.Document-aspect glue — additional
before-save/after-savehooks that invokeCOM_LOG_CommandApi.createFirstFreeCodewhen needed.
The pattern lets every document submodule (sales orders, purchase orders, invoices, …) share the same lifecycle without duplicating the code.
Public API
ACC_DOC_QueryApi
Read-side facade.
| Method | Description |
|---|---|
| Document by type + code, or |
| Document line by document + line number, or |
ACC_DOC_CommandApi
Write-side facade.
| Method | Description |
|---|---|
| Allocates a new |
| Adds a line to a document, optionally linked to a source line. |
| Deletes a document line. |
Document aspect extension
The submodule exposes a set of marker interfaces for other modules to implement so they can plug into the document-aspect framework:
HasDocumentLineImplemented by entities that wrap a
DocumentLine.HasSourceDocumentLineImplemented by entities that always have a non-null source document line.
HasOptionalSourceDocumentLineImplemented by entities whose source document line is optional.
DocumentEntityAspect/DocumentLineEntityAspect/DocumentViewModelAspectAspect interfaces consumed by
DocumentAspectServiceto drive default-date and number-series allocation.
ViewModel actions
The submodule defines view models for Document and DocumentLine but does not declare any custom UI actions.