Solution
BE-terna Fashion Purchase Matrix
Setup (English) | How it works (English)
What is the purpose of this module
The Purchase Matrix module provides matrix-based quantity entry and store distribution for Fashion purchase orders. It lets users enter quantities for an item across colours, sizes or item lots, dates, and locations without creating every purchase line manually.
Users open the matrix from an item line on a purchase order. Depending on the selected matrix recording type, the module builds either a size-run matrix from item variants or an item-lot matrix from lot definitions. Locations can be selected individually or through a location group, and quantities can be entered directly, copied between locations or colours, or suggested from location weights.
While the matrix is open, headers, lines, and entries are held in temporary records. Saving the matrix updates the purchase lines and persists the matrix data for the purchase order. For size-run recording, completing matrix input creates Fashion item distributions when quantities are assigned to locations other than the purchase order location, optionally stores those distributions, removes the working matrix data, and marks the purchase order as completed for matrix input. Item-lot recording is available for matrix entry and purchase-line updates, but its automatic matrix-to-distribution transfer and storage are not fully implemented; see the setup guide and how the PurchaseMatrix works.
The module prevents concurrent matrix editing through recording locks. It also prevents release of a purchase order while matrix entries still exist, so matrix input must be completed before the order can be released.
Architecture overview
graph LR;
%% Nodes
title["Purchase Matrix architecture"]
purchaseLine["Purchase order item line"]
matrixAction["Matrix action"]
matrixPage["Purch Matrix page"]
matrixMgt["Purchase Order Matrix Mgt"]
matrixHeader[("Purch Matrix Header")]
matrixLine[("Purch Matrix Line")]
matrixEntry[("Purchase Order Matrix Entry")]
itemSize["Purchase Order Matrix Item Size"]
itemLot["Purchase Order Matrix Item Lot"]
distributionType["Matrix Distribution Type enum"]
distributionInterface["IMatrixDistribution"]
distributionImpl["Distribution implementations"]
purchaseLines[("Purchase Lines")]
complete["Complete Matrix Input"]
creationType["Item Distribution Creation Type mapping"]
fillInterface["IFillDistributionFromMatrix"]
itemDistribution[("Fashion Item Distribution")]
locks[("Purchase Order Matrix Recording Lock")]
%% Flow
title -.- purchaseLine
linkStyle 0 stroke:#ffffff
purchaseLine ==> matrixAction
matrixAction ==> matrixPage
matrixPage ==> matrixMgt
matrixMgt == "creates and releases" ==> locks
matrixMgt == "loads and persists" ==> matrixHeader
matrixMgt == "loads and persists" ==> matrixLine
matrixMgt == "loads and persists" ==> matrixEntry
matrixPage == "size-run recording" ==> itemSize
matrixPage == "item-lot recording" ==> itemLot
matrixHeader ==> distributionType
distributionType ==> distributionInterface
distributionInterface ==> distributionImpl
itemSize == "Save Changes" ==> purchaseLines
itemLot == "Save Changes" ==> purchaseLines
matrixEntry ==> complete
complete ==> creationType
creationType ==> fillInterface
fillInterface ==> itemDistribution
complete == "clears working data" ==> matrixHeader
complete == "clears working data" ==> matrixLine
complete == "clears working data" ==> matrixEntry
%% Classes
class title btProcessTitle
class purchaseLine,matrixAction,matrixPage,matrixMgt,matrixHeader,matrixLine,matrixEntry,itemSize,itemLot,distributionType,distributionInterface,distributionImpl,purchaseLines,complete,creationType,fillInterface,itemDistribution,locks btProcessActive
The main responsibilities are split as follows:
Purch Matrixis the user-facing matrix page. It initializes the matrix for the selected purchase line, presents the size-run or item-lot subpage, manages matrix actions, and asks whether unsaved changes should be saved when the page closes.Purchase Order Matrix Mgtowns matrix initialization, persistence, recording locks, distribution dispatch, completion, and shared validation.Purchase Order Matrix Item Sizebuilds and processes matrices based on item variants and size runs.Purchase Order Matrix Item Lotbuilds and processes matrices based on Fashion item lots.Purch Matrix Header,Purch Matrix Line, andPurchase Order Matrix Entrystore the matrix parameters, row structure, and entered quantities.Matrix Distribution Typeselects anIMatrixDistributionimplementation. The standard weighted implementation suggests quantities from location weights and handles distribution remainders.Item Distr. Creation Typemaps each matrix recording type to the implementations that create matrix data from purchase lines and convert completed matrix entries into Fashion item distributions.Purch Matrix Source Typedelegates filtering and deletion for supported source records such as purchase headers, purchase lines, and matrix records.- Purchase document event subscribers clean up related matrix data, integrate with item distribution creation, preserve relevant state when documents are copied, and block release while matrix input is unfinished.
Setup and Conditions
The app install code creates one Purchase Order Matrix Setup record per company and initializes the standard item-distribution mappings:
Size Run Horizontalmaps toItem Size.Item Lotmaps toItem Lot.Size Run Verticalmaps toItem Size.
The company setup contains these settings:
Purchase Order Matrix Reset Typecontrols how matrix data is reset.Store Distributionscontrols whether item distributions created during completion are stored immediately.Matrix Recording by Sliding (< >)controls whether users can move through assigned colours as separate matrix views. It is enabled by default.Item Distribution Creation Typesopens the mapping between matrix recording types and item-distribution creation types.
Each matrix user also requires configuration on User Setup:
Allow Matrix Recordingauthorizes matrix entry.Matrix Recording Typedefines whether the user records by horizontal size run, vertical size run, or item lot.Max. Matrix Column Countlimits the displayed matrix columns from 1 to 32.Release Matrix Lock Allowedauthorizes manual release of another matrix recording lock.
The purchase order stores the selected Distribution Direction and Matrix Recording Type. These values cannot be changed after matrix entries exist. Matrix entry requires an open purchase order, an item purchase line, the required Fashion item setup, and a configured user.
Matrix Lifecycle
- Opening the matrix validates the purchase line and user setup, creates a recording lock, and initializes matrix headers for the assigned colours.
- The module loads existing matrix headers, lines, and entries into temporary records. If no lines exist yet, it generates them from item variants or item lots.
- The user selects locations or a location group and records, copies, or calculates quantities.
Save Changeswrites the entered quantities to purchase lines and persists the matrix headers, lines, and entries. Unsaved changes can also be saved when the matrix page closes.- Closing the page removes the recording lock.
Complete Matrix Inputoptionally creates and stores Fashion item distributions, deletes the persisted working matrix data, and marksMatrix Input Completedon the purchase order. This action cannot be undone.- A purchase order with remaining matrix entries cannot be released. The entries must first be completed or deliberately reset through the provided actions.
How to Use and Extend the Module
How to Use
- Open
Purchase Order Matrix Setupand review the reset behavior, distribution storage, sliding mode, and item-distribution mappings. - Configure
Allow Matrix Recording,Matrix Recording Type,Max. Matrix Column Count, and, where required,Release Matrix Lock Allowedfor each user onUser Setup. - Create or open a purchase order and set its location, distribution direction, and matrix recording type.
- Add an item line and choose
Matrixor pressAlt+M. - Select locations with
Get LocationsorGet Location Group. - Enter quantities directly or use the copy and distribution actions. Weighted distribution is available through the
Weight (Location)distribution type. - Choose
Save Changesto update the purchase lines and retain the matrix for later editing. - Choose
Complete Matrix Inputon the purchase order when entry is finished. The module creates item distributions when required, clears the working matrix records, and marks matrix input as completed. - Use
Matrix Headers,Matrix Lines, andMatrix Entriesto inspect persisted matrix data. UseDelete Matrix DataorRelease Matrix Lockonly when the corresponding recovery action is intentionally required. - To rebuild a matrix from existing item purchase lines, use
Create Matrix Data from Lines.
How to Extend
To add another matrix distribution algorithm:
- Create a codeunit that implements
IMatrixDistribution. - Implement quantity distribution and clearing for both item-colour and item-lot data.
- Extend
Matrix Distribution Typewith a new value and assign the codeunit as its implementation. - Add tests for calculation, rounding or remainder handling, clearing, and both supported matrix layouts where applicable.
To add another matrix recording and item-distribution creation path:
- Extend
Matrix Recording Typewith the new recording mode. - Implement
ICreateMatrixDatato reconstruct temporary matrix data from purchase lines. - Implement
IFillDistributionFromMatrixto create, populate, and optionally store Fashion item distributions. - Extend
Item Distr. Creation Typewith a value that maps both interfaces to the new implementations. - Add the recording-type-to-creation-type mapping through
Item Distr. Creation Type.InsertDistributionType(...), normally from a subscriber to its initialization event. - Extend the matrix page and processing logic only where the new recording layout requires behavior beyond the existing size-run and item-lot paths.
- Add tests for initialization, saving, recreation from purchase lines, completion, and release blocking.
To support another matrix source record:
- Create an implementation of
IPurchMatrixSourceTypethat applies the source-specific filters for locks, headers, lines, and entries. - Extend
Purch Matrix Source Typeand assign the new implementation. - Verify lock creation and release, existence checks, and cascading cleanup for the new source.
Prefer the module’s published integration events when only a step in the existing workflow must be adjusted. Events are available around item-distribution mapping initialization, matrix processing, purchase-order release checks, and distribution record creation.