Skip to content

Purchase Returns

Backlog fieldValue
Story IDAP-PUR-005
EpicPurchase
Story typeBusiness workflow
Review statusDraft - business analyst and business owner review required
Source evidenceAppsPortal.Apis controller, application command/query handlers, validators, domain entities, and matching MFE workflow where available
Last source review2026-07-10

User story

As accounts-payable users, I want to return eligible purchased quantities and post the supplier credit effect so that stock and payables are corrected without exceeding the source invoice.

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

  1. Only authorized users can view or execute the feature's actions.
  2. Required business data, active dependencies, tenant/branch scope, and current document state are validated.
  3. Invalid requests return actionable validation errors without applying a partial change.
  4. Search, list, view, print, and export operations use the same authorized business scope.
  5. Material create, edit, status, approval, posting, reversal, and integration actions are auditable where applicable.
  6. Financial or stock effects are applied atomically and no more than once.

Posting details

  1. Validate Draft return, posted source invoice, open period, vendor, positive quantities within remaining returnable quantity, taxes, and sufficient matching warehouse/tracking stock.
  2. Resolve Vendor Payable from vendor then category, Landed Cost Expense from service item then item category, and tax from Tax then Tax Group.
  3. Delegate posted Stock Out to Inventory: debit Goods in Transit/returned landed expense and credit Warehouse GL while reducing stock.
  4. Purchase builds the commercial return journal, debits Vendor Payable, reverses tax and purchase value, links Stock Out/journals, and updates source return quantities/status.
  5. All effects commit together; stock shortage, over-return, missing account, or delegate failure leaves the return Draft and source unchanged.

General ledger posting

ComponentDebitCreditCondition
Vendor reversalVendor PayablePurchase/GIT or expense reversalPayable vendor then category.
Tax reversalVendor Payable/tax clearingInput TaxDirection follows original tax; Tax then Tax Group.
Storable-item issueGoods in Transit / returned landed expenseWarehouse GLDelegated Stock Out at returned inventory cost.
Service returnVendor PayableExpense reversalNo Warehouse GL entry.

Other module and document effects

AreaEffectConditional/no effect
InventoryStorable lines create Stock Out and consume layers/tracking.Service lines create no Stock Out.
Source Purchase InvoiceUpdates returned quantity and partial/full return status.Over-return is blocked.
Vendor/FinanceReduces payable/due balance.Cash refund requires separate Payment In unless another workflow supplies it.

Core acceptance scenarios

  1. Given a Draft return against a posted purchase with sufficient returnable quantity and warehouse stock, when the user clicks Post, then Stock Out, purchase-return journal, landed/tax reversal, vendor balance, and source return status commit together.
  2. Given requested quantity exceeds source remaining quantity or warehouse availability, when the operation is attempted, then Post is rejected without reducing either source quantity or stock.
  3. 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.

Required and conditional data

An eligible posted Purchase Invoice, Draft return, vendor, open-period date, returnable lines, positive quantities within remaining purchased quantity, and correct warehouse/UOM/tracking for storable items are required. Reason/notes are optional; tax and landed-cost reversal data are conditional.

Account resolution and Post effects

  • Vendor payable: vendor then vendor category.
  • Inventory: linked Stock Out credits Warehouse GL and debits Goods in Transit.
  • Landed-cost return portion: service item expense then item category expense, grouped by account/cost center.
  • VAT: tax account then group account according to reversal effect.

Post decreases stock using current batch WMA cost in the return builder, creates/links Stock Out, reverses purchase/landed/tax value, debits vendor payable, updates source invoice returned quantities/status, marks Posted, and commits atomically. It fails on insufficient stock, excessive return quantity, missing accounts/tax/tracking, closed period, or non-Draft state.

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/pageComponentModeRoute permission/guardMapping confidenceSource
(module default)PurchaseReturnListComponentList/navigationPermission: AppPurchasePermissions.ReturnInvoice_List; Guards: PolicyAuthGuardExplicit frontend feature ruleapps/purchase/src/app/remote-entry/purchase-transactions/purchase-transactions.module.ts:122
addAddReturnPurchaseComponentAddPermission: AppPurchasePermissions.ReturnInvoice_Add; Guards: PolicyAuthGuardExplicit frontend feature ruleapps/purchase/src/app/remote-entry/purchase-transactions/purchase-transactions.module.ts:132
edit/:idEditReturnPurchaseComponentEditPermission: AppPurchasePermissions.ReturnInvoice_Edit; Guards: PolicyAuthGuard, preventPostedGuardExplicit frontend feature ruleapps/purchase/src/app/remote-entry/purchase-transactions/purchase-transactions.module.ts:143
return-purchase-invoiceMainReturnPurchaseComponentList/navigationPermission: AppPurchasePermissions.ReturnInvoice_List; Guards: PolicyAuthGuardExplicit frontend feature ruleapps/purchase/src/app/remote-entry/purchase-transactions/purchase-transactions.module.ts:112
view/:idPurchaseReturnViewComponentView/detailPermission: AppPurchasePermissions.ReturnInvoice_View; Guards: PolicyAuthGuardExplicit frontend feature ruleapps/purchase/src/app/remote-entry/purchase-transactions/purchase-transactions.module.ts:155

Observed frontend fields and validation

ComponentControlObserved frontend ruleComponent source
AddReturnPurchaseComponentinvoiceDateRequired in component validatorapps/purchase/src/app/remote-entry/purchase-transactions/pages/return-purchase-invoice/add-return-purchase/add-return-purchase.component.ts
AddReturnPurchaseComponentpaymentTermNameVisible control; optional or API-dependentapps/purchase/src/app/remote-entry/purchase-transactions/pages/return-purchase-invoice/add-return-purchase/add-return-purchase.component.ts
AddReturnPurchaseComponentreturnDescriptionVisible control; optional or API-dependentapps/purchase/src/app/remote-entry/purchase-transactions/pages/return-purchase-invoice/add-return-purchase/add-return-purchase.component.ts
AddReturnPurchaseComponentreturnQuantityVisible control; optional or API-dependentapps/purchase/src/app/remote-entry/purchase-transactions/pages/return-purchase-invoice/add-return-purchase/add-return-purchase.component.ts
AddReturnPurchaseComponentvendorIdRequired in component validatorapps/purchase/src/app/remote-entry/purchase-transactions/pages/return-purchase-invoice/add-return-purchase/add-return-purchase.component.ts
AddReturnPurchaseComponentwarehouseIdVisible control; optional or API-dependentapps/purchase/src/app/remote-entry/purchase-transactions/pages/return-purchase-invoice/add-return-purchase/add-return-purchase.component.ts
EditReturnPurchaseComponentinvoiceDateRequired in component validatorapps/purchase/src/app/remote-entry/purchase-transactions/pages/return-purchase-invoice/edit-return-purchase/edit-return-purchase.component.ts
EditReturnPurchaseComponentreturnDescriptionVisible control; optional or API-dependentapps/purchase/src/app/remote-entry/purchase-transactions/pages/return-purchase-invoice/edit-return-purchase/edit-return-purchase.component.ts
EditReturnPurchaseComponentreturnQuantityVisible control; optional or API-dependentapps/purchase/src/app/remote-entry/purchase-transactions/pages/return-purchase-invoice/edit-return-purchase/edit-return-purchase.component.ts
PurchaseReturnViewComponentcurrencyVisible control; optional or API-dependentapps/purchase/src/app/remote-entry/purchase-transactions/pages/return-purchase-invoice/purchase-return-view/purchase-return-view.component.ts
PurchaseReturnViewComponentcurrencyRateVisible control; optional or API-dependentapps/purchase/src/app/remote-entry/purchase-transactions/pages/return-purchase-invoice/purchase-return-view/purchase-return-view.component.ts
PurchaseReturnViewComponentinvoiceCodeVisible control; optional or API-dependentapps/purchase/src/app/remote-entry/purchase-transactions/pages/return-purchase-invoice/purchase-return-view/purchase-return-view.component.ts
PurchaseReturnViewComponentinvoiceDateVisible control; optional or API-dependentapps/purchase/src/app/remote-entry/purchase-transactions/pages/return-purchase-invoice/purchase-return-view/purchase-return-view.component.ts
PurchaseReturnViewComponentinvoiceDescriptionVisible control; optional or API-dependentapps/purchase/src/app/remote-entry/purchase-transactions/pages/return-purchase-invoice/purchase-return-view/purchase-return-view.component.ts
PurchaseReturnViewComponentvendorIdVisible control; optional or API-dependentapps/purchase/src/app/remote-entry/purchase-transactions/pages/return-purchase-invoice/purchase-return-view/purchase-return-view.component.ts
PurchaseReturnViewComponentvendorNameVisible control; optional or API-dependentapps/purchase/src/app/remote-entry/purchase-transactions/pages/return-purchase-invoice/purchase-return-view/purchase-return-view.component.ts
PurchaseReturnViewComponentwarehouseIdVisible control; optional or API-dependentapps/purchase/src/app/remote-entry/purchase-transactions/pages/return-purchase-invoice/purchase-return-view/purchase-return-view.component.ts

Observed frontend actions

ComponentClick action/handlerBusiness review requirementComponent source
AddReturnPurchaseComponentdeleteRowAvailable 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/purchase/src/app/remote-entry/purchase-transactions/pages/return-purchase-invoice/add-return-purchase/add-return-purchase.component.ts
EditReturnPurchaseComponentdeleteRowAvailable 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/purchase/src/app/remote-entry/purchase-transactions/pages/return-purchase-invoice/edit-return-purchase/edit-return-purchase.component.ts
EditReturnPurchaseComponentrouteTojournalNavigate only when a linked journal ID exists and the user can view Accounting; otherwise the action is absent/disabled and no transaction data changes.apps/purchase/src/app/remote-entry/purchase-transactions/pages/return-purchase-invoice/edit-return-purchase/edit-return-purchase.component.ts
EditReturnPurchaseComponentrouteToStockOutNavigate only when the transaction produced a linked Stock In/Stock Out record and Inventory view permission is available; service-only/no-stock cases expose no stock link.apps/purchase/src/app/remote-entry/purchase-transactions/pages/return-purchase-invoice/edit-return-purchase/edit-return-purchase.component.ts
PurchaseReturnListComponentonDeleteAvailable 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/purchase/src/app/remote-entry/purchase-transactions/pages/return-purchase-invoice/purchase-return-list/purchase-return-list.component.ts
PurchaseReturnListComponentonEditOpen 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/purchase/src/app/remote-entry/purchase-transactions/pages/return-purchase-invoice/purchase-return-list/purchase-return-list.component.ts
PurchaseReturnListComponentonPostAvailable 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/purchase/src/app/remote-entry/purchase-transactions/pages/return-purchase-invoice/purchase-return-list/purchase-return-list.component.ts
PurchaseReturnListComponentonViewOpen 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/purchase/src/app/remote-entry/purchase-transactions/pages/return-purchase-invoice/purchase-return-list/purchase-return-list.component.ts
PurchaseReturnListComponentprintoutGenerate 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/purchase/src/app/remote-entry/purchase-transactions/pages/return-purchase-invoice/purchase-return-list/purchase-return-list.component.ts
PurchaseReturnListComponentrouteToJournalentryViewOpen 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/purchase/src/app/remote-entry/purchase-transactions/pages/return-purchase-invoice/purchase-return-list/purchase-return-list.component.ts
PurchaseReturnListComponentrouteToStockOuttryViewOpen 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/purchase/src/app/remote-entry/purchase-transactions/pages/return-purchase-invoice/purchase-return-list/purchase-return-list.component.ts
PurchaseReturnViewComponentrouteToJournalentryViewOpen 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/purchase/src/app/remote-entry/purchase-transactions/pages/return-purchase-invoice/purchase-return-view/purchase-return-view.component.ts
PurchaseReturnViewComponentrouteToPurchaseInvoiceViewOpen 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/purchase/src/app/remote-entry/purchase-transactions/pages/return-purchase-invoice/purchase-return-view/purchase-return-view.component.ts
PurchaseReturnViewComponentrouteToStockOuttryViewOpen 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/purchase/src/app/remote-entry/purchase-transactions/pages/return-purchase-invoice/purchase-return-view/purchase-return-view.component.ts

Page-specific frontend acceptance criteria

  1. (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: AppPurchasePermissions.ReturnInvoice_List; Guards: PolicyAuthGuard
  2. add - Add: Render permitted fields, required indicators, defaults, dependent lookups, validation, Save/Cancel, loading, success, and API-error states. Security observed: Permission: AppPurchasePermissions.ReturnInvoice_Add; Guards: PolicyAuthGuard
  3. 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: AppPurchasePermissions.ReturnInvoice_Edit; Guards: PolicyAuthGuard, preventPostedGuard
  4. return-purchase-invoice - 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: AppPurchasePermissions.ReturnInvoice_List; Guards: PolicyAuthGuard
  5. 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: AppPurchasePermissions.ReturnInvoice_View; Guards: PolicyAuthGuard

Internal Documentation — Microtec