Appearance
Sales Orders
| Backlog field | Value |
|---|---|
| Story ID | AP-SAL-012 |
| Epic | Sales |
| Story type | Business workflow |
| Review status | Draft - business analyst and business owner review required |
| Source evidence | AppsPortal.Apis controller, application command/query handlers, validators, domain entities, and matching MFE workflow where available |
| Last source review | 2026-07-10 |
User story
As sales users, I want to create, approve, track, and fulfill customer orders so that commitments are controlled before invoicing.
Posting reference: AppsPortal Posting Ledger explains debit/credit construction. Delegation and Interaction Contracts explains module ownership, delegated commands, linked records, commit boundaries, and reversal propagation.
Acceptance criteria
- Only authorized users can view or execute the feature's actions.
- Required business data, active dependencies, tenant/branch scope, and current document state are validated.
- Invalid requests return actionable validation errors without applying a partial change.
- Search, list, view, print, and export operations use the same authorized business scope.
- Material create, edit, status, approval, posting, reversal, and integration actions are auditable where applicable.
- Financial or stock effects are applied atomically and no more than once.
Posting details
- Sales Order Post is an approval/commitment operation and creates no revenue journal, receivable, payment, or stock movement.
- Validate customer, date, currency/rate, price/discount authority, lines, quantities, optional workflow approval, and commercial rules.
- Mark the order Posted/approved and expose remaining quantities for Sales Invoice fulfillment.
- Later invoices reduce remaining order quantity and may close lines/order.
- Over-invoicing and modification/cancellation of fulfilled quantities are rejected.
General ledger posting
| Condition | Debit | Credit | Result |
|---|---|---|---|
| Sales Order Post | - | - | No GL entry, receivable, revenue, tax, COGS, or payment is created. |
Other module and document effects
| Area | Effect | Conditional/no effect |
|---|---|---|
| Inventory | No Stock Out and no reservation movement from Post itself. | Availability may be validated/displayed only. |
| Sales Invoice | Exposes approved remaining quantities; later invoices reduce them and close fulfilled lines/order. | Standalone invoices do not affect this order. |
| Customer/Finance | Commercial commitment only. | No balance, credit consumption, due schedule, or cash movement until invoice/payment. |
Core acceptance scenarios
- Given a valid Draft sales order, when the sales user submits/posts it, then the commitment and remaining fulfillment quantities become effective without GL, receivable, or stock posting.
- Given invoicing exceeds the remaining order quantity, when the operation is attempted, then the excess is rejected.
- Given the same Post request is retried after success, when the source is no longer Draft, then no duplicate journal, stock, balance, payment, or lifecycle effect is created.
Business rules
Required
Draft order, customer, date, currency/rate, and at least one positive item/service line are required.
Optional or conditional
Warehouse, price policy, salesperson, tax, discount, payment term, delivery, project, notes, and approval are conditional.
Action behavior
Save/Post records commitment but creates no stock/receivable/GL effect until invoice/fulfillment.
Blocking rule or downstream effect
Fulfillment updates remaining quantities and prevents over-invoicing/canceling fulfilled lines.
Frontend page coverage
The following UI coverage is sourced from the pulled MFE route configuration. A Module-level supporting artifact mapping is evidence of a reachable screen, but requires BA confirmation that it belongs to this story rather than a more specific feature story.
| Route/page | Component | Mode | Route permission/guard | Mapping confidence | Source |
|---|---|---|---|---|---|
| (module default) | SalesOrderListComponent | List/navigation | Permission: AppSalesPermissions.SalesOrder_List; Guards: PolicyAuthGuard | Explicit frontend feature rule | apps/sales/src/app/remote-entry/transaction/transaction.module.ts:421 |
| add | AddSalesOrderComponent | Add | Permission: AppSalesPermissions.SalesOrder_Add; Guards: PolicyAuthGuard | Explicit frontend feature rule | apps/sales/src/app/remote-entry/transaction/transaction.module.ts:432 |
| edit/:id | EditSalesOrderComponent | Edit | Permission: AppSalesPermissions.SalesOrder_Edit; Guards: PolicyAuthGuard, preventPostedGuard | Explicit frontend feature rule | apps/sales/src/app/remote-entry/transaction/transaction.module.ts:443 |
| sales-order | MainSalesOrderComponent | List/navigation | Permission: AppSalesPermissions.SalesOrder_List; Guards: PolicyAuthGuard | Explicit frontend feature rule | apps/sales/src/app/remote-entry/transaction/transaction.module.ts:412 |
| view/:id | ViewSalesOrderComponent | View/detail | Permission: AppSalesPermissions.SalesOrder_View; Guards: PolicyAuthGuard | Explicit frontend feature rule | apps/sales/src/app/remote-entry/transaction/transaction.module.ts:455 |
Observed frontend fields and validation
| Component | Control | Observed frontend rule | Component source |
|---|---|---|---|
| MainFormDataSectionComponent | currencyId | Required in component validator | apps/sales/src/app/remote-entry/transaction/components/main-form-data-section/main-form-data-section.component.ts |
| MainFormDataSectionComponent | customerId | Required in component validator | apps/sales/src/app/remote-entry/transaction/components/main-form-data-section/main-form-data-section.component.ts |
| MainFormDataSectionComponent | description | Visible control; optional or API-dependent | apps/sales/src/app/remote-entry/transaction/components/main-form-data-section/main-form-data-section.component.ts |
| MainFormDataSectionComponent | expiryDate | Visible control; optional or API-dependent | apps/sales/src/app/remote-entry/transaction/components/main-form-data-section/main-form-data-section.component.ts |
| MainFormDataSectionComponent | orderDate | Required in component validator | apps/sales/src/app/remote-entry/transaction/components/main-form-data-section/main-form-data-section.component.ts |
| MainFormDataSectionComponent | paymentTermId | Required in component validator | apps/sales/src/app/remote-entry/transaction/components/main-form-data-section/main-form-data-section.component.ts |
| MainFormDataSectionComponent | pricePolicyId | Required in component validator | apps/sales/src/app/remote-entry/transaction/components/main-form-data-section/main-form-data-section.component.ts |
| MainFormDataSectionComponent | salesmanId | Visible control; optional or API-dependent | apps/sales/src/app/remote-entry/transaction/components/main-form-data-section/main-form-data-section.component.ts |
| MainFormDataSectionComponent | termsAndConditions | Visible control; optional or API-dependent | apps/sales/src/app/remote-entry/transaction/components/main-form-data-section/main-form-data-section.component.ts |
| TableDetailsSectionComponent | barCode | Visible control; optional or API-dependent | apps/sales/src/app/remote-entry/transaction/components/table-details-section/table-details-section.component.ts |
| TableDetailsSectionComponent | discountAmount | Visible control; optional or API-dependent | apps/sales/src/app/remote-entry/transaction/components/table-details-section/table-details-section.component.ts |
| TableDetailsSectionComponent | itemId | Required in component validator | apps/sales/src/app/remote-entry/transaction/components/table-details-section/table-details-section.component.ts |
| TableDetailsSectionComponent | price | Conditionally required/validated in component | apps/sales/src/app/remote-entry/transaction/components/table-details-section/table-details-section.component.ts |
| TableDetailsSectionComponent | quantity | Required in component validator | apps/sales/src/app/remote-entry/transaction/components/table-details-section/table-details-section.component.ts |
| TableDetailsSectionComponent | uomId | Required in component validator | apps/sales/src/app/remote-entry/transaction/components/table-details-section/table-details-section.component.ts |
Observed frontend actions
| Component | Click action/handler | Business review requirement | Component source |
|---|---|---|---|
| HeaderViewSalesOrderComponent | onOpenAttachment | Document the enabled state, permission, input context, resulting API or navigation effect, success refresh, and concrete failure behavior for this handler. | apps/sales/src/app/remote-entry/transaction/components/header-view-sales-order/header-view-sales-order.component.ts |
| MainFormDataSectionComponent | addDiscount | Document the enabled state, permission, input context, resulting API or navigation effect, success refresh, and concrete failure behavior for this handler. | apps/sales/src/app/remote-entry/transaction/components/main-form-data-section/main-form-data-section.component.ts |
| MainFormDataSectionComponent | onOpenAttachment | Document the enabled state, permission, input context, resulting API or navigation effect, success refresh, and concrete failure behavior for this handler. | apps/sales/src/app/remote-entry/transaction/components/main-form-data-section/main-form-data-section.component.ts |
| MainFormDataSectionComponent | openCustomerAdvancedSearch | Document the enabled state, permission, input context, resulting API or navigation effect, success refresh, and concrete failure behavior for this handler. | apps/sales/src/app/remote-entry/transaction/components/main-form-data-section/main-form-data-section.component.ts |
| SalesOrderListComponent | onDelete | Available only in deletable states with Delete permission; identify the record in confirmation, call delete once, remove/refresh the list row on success, and retain the row with the API reason on failure. | apps/sales/src/app/remote-entry/transaction/pages/sales-order/sales-order-list/sales-order-list.component.ts |
| SalesOrderListComponent | onEdit | Open the identified editable record only with Edit permission; posted/locked records remain blocked by route or action state and list context must be recoverable on return. | apps/sales/src/app/remote-entry/transaction/pages/sales-order/sales-order-list/sales-order-list.component.ts |
| SalesOrderListComponent | onVeiw | Open the authorized record in view mode with its status, totals, lines, source and generated-document links; handle deleted, forbidden, and missing records without exposing stale data. | apps/sales/src/app/remote-entry/transaction/pages/sales-order/sales-order-list/sales-order-list.component.ts |
| SalesOrderListComponent | postSalesOrder | Available only for a postable Draft and Post permission; confirm the document, prevent a second submission, call the posting API, and refresh status, journal/stock links, and row actions. Failure must keep the pre-post state. | apps/sales/src/app/remote-entry/transaction/pages/sales-order/sales-order-list/sales-order-list.component.ts |
| SalesOrderListComponent | printout | Generate the printout for the selected record and authorized branch/tenant; use posted/current values and surface print, template, ZATCA/ETA, or popup failures without changing transaction state. | apps/sales/src/app/remote-entry/transaction/pages/sales-order/sales-order-list/sales-order-list.component.ts |
| SalesOrderListComponent | toSalesInvoice | Document the enabled state, permission, input context, resulting API or navigation effect, success refresh, and concrete failure behavior for this handler. | apps/sales/src/app/remote-entry/transaction/pages/sales-order/sales-order-list/sales-order-list.component.ts |
| TableDetailsSectionComponent | addDiscount | Document the enabled state, permission, input context, resulting API or navigation effect, success refresh, and concrete failure behavior for this handler. | apps/sales/src/app/remote-entry/transaction/components/table-details-section/table-details-section.component.ts |
| TableDetailsSectionComponent | onAddLine | Add one initialized detail row without changing existing rows; apply defaults and line validators, preserve stable row identity, and exclude incomplete rows from Save/Post. | apps/sales/src/app/remote-entry/transaction/components/table-details-section/table-details-section.component.ts |
| TableDetailsSectionComponent | onDeleteRow | Available only in deletable states with Delete permission; identify the record in confirmation, call delete once, remove/refresh the list row on success, and retain the row with the API reason on failure. | apps/sales/src/app/remote-entry/transaction/components/table-details-section/table-details-section.component.ts |
| TableDetailsSectionComponent | openDialog | Open the item/lookup/tracking dialog with the current warehouse, item, UOM, and remaining quantity context; accepted values must return to the correct line and cancel must not mutate it. | apps/sales/src/app/remote-entry/transaction/components/table-details-section/table-details-section.component.ts |
Page-specific frontend acceptance criteria
- (module default) - List/navigation: Load an authorized paged/searchable list or navigation page; preserve filters/sort/paging and expose only permitted row and bulk actions. Security observed: Permission: AppSalesPermissions.SalesOrder_List; Guards: PolicyAuthGuard
- add - Add: Render permitted fields, required indicators, defaults, dependent lookups, validation, Save/Cancel, loading, success, and API-error states. Security observed: Permission: AppSalesPermissions.SalesOrder_Add; Guards: PolicyAuthGuard
- edit/:id - Edit: Load the identified record, enforce state/permission field locks, preserve concurrency identity, validate changes, and return without losing filters. Security observed: Permission: AppSalesPermissions.SalesOrder_Edit; Guards: PolicyAuthGuard, preventPostedGuard
- sales-order - List/navigation: Load an authorized paged/searchable list or navigation page; preserve filters/sort/paging and expose only permitted row and bulk actions. Security observed: Permission: AppSalesPermissions.SalesOrder_List; Guards: PolicyAuthGuard
- view/:id - View/detail: Load an authorized immutable/detail representation with status-aware actions, linked records, print/export where exposed, and not-found/forbidden handling. Security observed: Permission: AppSalesPermissions.SalesOrder_View; Guards: PolicyAuthGuard