Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/CodexaCP/DG_WEB/llms.txt

Use this file to discover all available pages before exploring further.

The Commercial Orders module is the commercial backbone of Dragon Guard WMS. It manages the four core business entities — customers, sellers, sales order documents, and purchase order documents — and provides the linkage layer that connects outgoing shipments to real commercial transactions. All entities are company-aware: every record is scoped to an active_company_id through ApiControllerBase, preventing cross-tenant data exposure. The MAUI handheld is not involved in this phase; all operations are handled through the Angular web frontend.

Entity Model

The module is built around four entities, each with its own identity key and duplicate-control rules.

Customer

Identified by CompanyId + CustomerNo. Duplicate control is applied on tax ID and external identity.

Seller

Identified by CompanyId + SellerCode. Duplicate control is applied on email and external identity.

Sales Order

Header + lines tracking customer, seller, dates, notes, totals, and Business Central (BC) identifiers.

Purchase Order

Header + lines tracking vendor snapshot, dates, notes, totals, and BC identifiers.

Entity Reference

Customer

FieldDescription
CompanyIdTenant company scope
CustomerNoUnique customer code within the company
NameCustomer display name
TaxIdTax identification number (duplicate-controlled)
ExternalIdentityThird-party system identifier (duplicate-controlled)
AddressRegistered address
ContactPrimary contact information
StatusActive / Inactive

Seller

FieldDescription
CompanyIdTenant company scope
SellerCodeUnique seller code within the company
NameSeller display name
EmailSeller email address (duplicate-controlled)
ExternalIdentityThird-party system identifier (duplicate-controlled)
StatusActive / Inactive

Sales Order Header / Line

FieldDescription
CompanyIdTenant company scope
SalesOrderNoAuto-generated document number
CustomerId / CustomerNameLinked customer (snapshot at creation)
SellerId / SellerCodeAssigned seller (snapshot at creation)
OrderDate / ShipDateKey dates
NotesFree-text notes
TotalsLine-aggregated document totals
BcIdentifiersBusiness Central reference fields

Purchase Order Header / Line

FieldDescription
CompanyIdTenant company scope
PurchaseOrderNoAuto-generated document number
VendorNo / VendorNameVendor snapshot at document creation
TaxIdVendor tax ID at creation time
Address / ContactVendor contact snapshot
OrderDate / ReceiveDateKey dates
NotesFree-text notes
TotalsLine-aggregated document totals
BcIdentifiersBusiness Central reference fields

Snapshot Rule

Document creation stores a point-in-time snapshot of master data. When a sales order is created, the customer name, tax ID, address, and contact are copied into the document record. Subsequent changes to the customer master record do not modify existing documents. The same rule applies to vendor data on purchase orders and seller data on sales orders. This ensures that historical documents remain accurate and auditable regardless of future master-data edits.

Vendor Master

Although there is no dedicated Vendor entity exposed in the frontend at this phase, the purchase order stores a full vendor snapshot at creation time using the following fields:
FieldDescription
CompanyIdTenant company scope
VendorNoUnique vendor code
NameVendor name
TaxIdTax identification (snapshot)
AddressRegistered address (snapshot)
ContactPrimary contact (snapshot)
StatusActive / Inactive

Frontend Module Structure

All commercial order components live under src/app/sales/. The table below maps each functional area to its frontend location.
AreaLocation in sales/Description
Sales order listsales-orders/Paginated list of all sales orders for the active company
Sales order create / detailsales-orders/create or sales-orders/:idForm for creating and viewing sales order headers and lines
Customer maintenancecustomers/Create, list, and edit customers
Seller maintenancesellers/Create, list, and edit sellers
Purchase order listpurchase-orders/Paginated list of all purchase orders
Purchase order createpurchase-orders/createForm for creating purchase order headers and lines
Shipment create (sales link)shipments/createIncludes the sales-order lookup dialog for linking shipments
The shipment create page (shipments/create) embeds a sales-order lookup dialog that allows an operator to search for and attach an existing sales order to the new shipment. When a sales order is selected, the backend validates that the order belongs to the active company and populates commercial fields from the order snapshot.

Shipment documents (ShipmentHeaders) support an optional SalesOrderId and SalesOrderNo field.
The shipment is created as a standalone outbound document. Customer name and commercial fields are entered manually. No commercial validation is performed against the sales order layer.

Duplicate Validation

The backend enforces uniqueness constraints and returns localized error keys when violations occur. The web UI resolves these keys through the Angular i18n layer and displays them in a blocking modal.
Error KeyEntityDuplicate Field
validation.salesOrderDuplicateSales OrderDuplicate document reference or BC identifier
validation.customerDuplicateCustomerTax ID or external identity already registered for the company

Database Migrations

On application startup, Wms.Api calls Database.Migrate() to apply any pending Entity Framework migrations automatically. No manual migration steps are required for new deployments or updates. This ensures the schema is always in sync with the current version of the backend without operator intervention.

API Endpoints

All endpoints are company-aware through ApiControllerBase. The companyId claim is read from the JWT and applied server-side — it does not need to be passed as an explicit query parameter on POST and PUT requests.
MethodEndpointEntityPurpose
GET/api/customersCustomerList all customers for the active company
POST/api/customersCustomerCreate a new customer
PUT/api/customers/{id}CustomerUpdate an existing customer
GET/api/sellersSellerList all sellers for the active company
POST/api/sellersSellerCreate a new seller
PUT/api/sellers/{id}SellerUpdate an existing seller
GET/api/sales-ordersSales OrderList all sales orders for the active company
POST/api/sales-ordersSales OrderCreate a new sales order with lines
PUT/api/sales-orders/{id}Sales OrderUpdate an existing sales order
GET/api/purchase-ordersPurchase OrderList all purchase orders for the active company
POST/api/purchase-ordersPurchase OrderCreate a new purchase order with lines
PUT/api/purchase-orders/{id}Purchase OrderUpdate an existing purchase order
GET/api/shipmentheadersShipmentList shipments (see Shipments module)
POST/api/shipmentheadersShipmentCreate shipment, optionally linked to sales order
POST /api/sales-orders
Authorization: Bearer {token}
Content-Type: application/json

{
  "customerId": 12,
  "sellerId": 3,
  "orderDate": "2025-06-01",
  "shipDate": "2025-06-10",
  "notes": "Urgent delivery",
  "lines": [
    { "itemId": 88, "quantity": 100, "unitPrice": 15.00 }
  ]
}
POST /api/customers
Authorization: Bearer {token}
Content-Type: application/json

{
  "customerNo": "C-00042",
  "name": "Retail Partner S.A.",
  "taxId": "RUC-0001234567",
  "address": "Av. Principal 123, Ciudad",
  "contact": "[email protected]",
  "status": "Active"
}

Build docs developers (and LLMs) love