Recording and managing contracts – system description

Header and child tables of a contract, save steps and the value match, automatic numbering, content scope and deletion.

Customer and supplier contracts with lines, phases, phase-line allocation and deposit. Finalised module; the content scope is the contract's company_client_id.

Data model

Table names carry the installation's own prefix in the database.

TableRole
contractheader: client, direction, partner, subject, number, currency, value, status
contract_partiesparties with direction-based roles
contract_itemlines (resolved from product / service)
contract_phase, contract_phase_itemphases and phase-line allocation
contract_deposit, contract_penalty, contract_document, contract_vehicledeposit, penalty, document and vehicle rows
doc, doc_linkdocuments shown in the list

Process

  1. List: filters company group, company, filter_client_id, filter_customer_id, filter_auto_renew, filter_certification_required, filter_data; scope to the content right's companies (getAllowedScopeValues); documents with document/document list, unlinking with edit.
  2. Save: client and subject required; client in scope (ownerInScope); where the price profile makes the header value meaningful (works or flat fee), the non-optional lines must total the value within ±0.01 (error_value_mismatch).
  3. addContract(): adds missing columns (ensureSchema), direction-based roles, automatic number (V-YYYY-NNNN customer, SZ-YYYY-NNNN supplier, continuous per client), then writes parties, lines, phases, allocation and deposit (delete + rewrite). editContract() rewrites the child tables the same way.
  4. Status: 0/1 (setStatus).
  5. Delete: ids outside the scope are skipped; deleteContract() deletes the child rows, then the contract, physically.

Permissions

  • Function rights: list, edit (also the Add button), save canSave(), delete, debug; searches: companysearch, partnersearch (list), productsearch, propertysearch, servicesearch (edit), groupcompanies.
  • Content scope: contractInScope, ownerInScope.

Known limitations

  • Deletion does not check referencing invoices.
  • The keys certify, export, invoice and the BASE-classified statusdelete exist only in the catalogue; they have no endpoint.
Related topics: contract contracting parties