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

Document

The header of a document tree, identified by the pair (documentType, documentCode). Carries the date, department, partner, and optional external-system reference. The documentId is a stable UUID that survives renames.

Document Type

An 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 Origin

Whether the document was entered manually, generated by the system, or imported from an external system.

Document Line

A 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 Aspect

A 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

DOC entities

Document (Document)

The header of a document tree.

FieldDescription

documentType

The kind of document — see Document Types below.

documentCode

Business code allocated for the document (composite business key with documentType).

documentId

A stable UUID for the document; final.

documentDate

Document date.

department

Issuing department.

company

Owning company (operational, internal — derived from the department).

partner

Optional counter-party.

externalDocument

Whether the document originated outside the ERP. Default false.

externalDocumentId

Optional UUID from the external system.

externalDocumentCode

Optional code from the external system.

documentLines

The contained DocumentLine rows.

Document Types (DocumentType)

CodeName

PINV

Purchase Invoice

SINV

Sales Invoice

PORD

Purchase Order

PQUO

Purchase Quotation

PREC

Purchase Receipt

SCNT

Sales Contact

SORD

Sales Order

SQUO

Sales Quotation

SDEL

Sales Delivery

TORD

Transport Order

WORD

Work Order

IISS

Stock Issue

IREC

Stock Receipt

TSHT

Timesheet

PSTA

Partner Statement

NONE

Sentinel: no document type

Document Origin (DocumentOrigin)

CodeNameMeaning

M

Manual

Created by hand from the UI.

G

Generated

Created by the system as part of a downstream flow.

I

Imported

Imported from an external system.

Document Line (DocumentLine)

A single row of a document.

FieldDescription

document

Owning document (composite business key with lineNumber).

lineNumber

The 1-based line number within the document.

sourceDocumentLine

Optional line this one was derived from (final).

externalLineNumber

Optional line number from the external system.

biRootDocumentLine

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 createafterCreateRecord sets the documentDate to the current execution date if the form left it blank.

  • Number-series allocation on savegetNumberSeries resolves a configured view-model path to a NumberSeries so the framework can allocate the next free documentCode when the document is saved.

  • Document-aspect glue — additional before-save / after-save hooks that invoke COM_LOG_CommandApi.createFirstFreeCode when 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.

MethodDescription

findByDocumentTypeAndDocumentCode(DocumentType, DocumentCode)

Document by type + code, or null.

findByDocumentAndLineNumber(Document, DocumentLineNumber)

Document line by document + line number, or null.

ACC_DOC_CommandApi

Write-side facade.

MethodDescription

createDocument(…​)

Allocates a new Document header for a type / code / id / date / department.

createDocumentLine(…​)

Adds a line to a document, optionally linked to a source line.

removeDocumentLine(…​)

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:

HasDocumentLine

Implemented by entities that wrap a DocumentLine.

HasSourceDocumentLine

Implemented by entities that always have a non-null source document line.

HasOptionalSourceDocumentLine

Implemented by entities whose source document line is optional.

DocumentEntityAspect / DocumentLineEntityAspect / DocumentViewModelAspect

Aspect interfaces consumed by DocumentAspectService to 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.