Skip to main content

Direct Goods Receipt

Direct Goods Receipt records stock that enters the selected branch without starting from a branch-transfer document. The user creates the receipt from product inventory context, assigns quantity and batch data, then submits a stock-in payload to the API/MST layer.

App Entry Points

AppTarget
MobileGoodsReceiptList -> GoodsReceiptDetail
POS TerminalgoodsReceipt -> GoodsReceiptDetailForm

End-To-End Workflow

Key Business Rules

RuleBehavior
Batch sourceThe user must enter a Container No. or vehicle plate before adding products. The app uses the last four digits as the batch suffix.
Batch prefixThe prefix comes from generateBatchCode(getSelectedWhsGrpCode(branch), receiptDate) so the selected branch and receipt date affect the final batch number.
Product sourceProducts come from branch inventory context plus dummy products; filtering keeps company-compatible products.
Product add quantityThe selected product quantity must be greater than 0.
Receipt line quantitySubmit blocks blank quantities and negative quantities. 0 can be submitted only through the explicit zero-batch behavior below.
Batch requiredSubmit blocks lines with no batch rows, blank batch numbers, blank batch quantities, negative batch quantities, or duplicate batch numbers.
Zero-batch branchA line that has batch rows but cal === 0 asks for confirmation; after confirmation the payload sends the original line quantity and no useful batch quantity for that line.
Deposit warehouseNon-main branch/deposit context uses deposit due-date fields. Mobile validates expiry/due dates before submit; Terminal currently carries deposit dates in payload and enforces the quantity/batch guards in this form.
Extra batch quantityFor normal items, if batch total is greater than line quantity, the payload splits the excess into an extra line with lineNum: -1. For BT- items, the submitted line uses the batch total directly.

Payload Shape

The submit handler sends branch and user identity with normalized numeric item values.

Important implementation notes:

  • admissionDate is the submitted receipt-date key; the obsolete addmisionDate key is not sent.
  • dueDate is included only for deposit warehouse flows. Both admissionDate and dueDate are submitted as YYYY-MM-DDTHH:mm:ss.
  • Lines with batch rows and cal === 0 are sent without batch data after explicit user confirmation.
  • receiptDate defaults to the start of the current day but can be changed before generating/submitting batch dates.

Field Dictionary And Provenance

This covers every field Mobile and POS Terminal read or send in this flow. It excludes future backend-only response properties allowed by the model index signature. The selected document comes from GET /goods-receipt-po?branchId={selectedBranchId}; both apps spread that document into the POST /stock-in payload, then override the fields below.

FieldMeaningSource / submit rule
companyDocument company codePassed through from goods-receipt-po.
docEntry, docNumInternal ID and PO numberPassed through from the response.
docDate, docDueDate, taxDateDocument, due, and tax datesPassed through from the response.
cardCode, cardName, commentsSupplier identity and document commentPassed through from the response.
numAtCardSupplier reference numberPassed through from goods-receipt-po; this flow does not generate it.
branchIdDocument branch IDPassed through; selected branch ID scopes the list request.
branchCode, branchNameReceiving warehouse-group code/nameOverridden from selected whsGrpCode/whsGrpName, falling back to the document.
userCode, userName, whsEmpNameRecording user and warehouse employeeCurrent logged-in user; code falls back to the document.
payloadBeforeImmutable pre-edit JSON snapshotCreated with JSON.stringify(goodsReceipt) in the detail screen.

Lines and batches

FieldMeaningSource / submit rule
lines[].lineNumDocument line sequenceFrom API; user-added lines use -1; sorted before submit.
itemCode, itemDescriptionItem identityExisting line API data, or selected inventory/dummy product.
quantity, weightReceived quantity and weightConverted to numbers; normally batch total (cal), but the original line quantity is retained for no/zero-batch flow.
uomCode, uomEntryUnit code and IDExisting line or selected product salUom*.
warehouseCodeReceiving warehouseExisting line; new line uses product warehouse, then branch code, then warehouse group.
costingCodecostingCode5, poRemarksCost centers and PO line noteExisting API line; new cost-center values start blank.
batchNumbers[].batchNumber, quantityBatch ID and received batch quantityUser-selected/entered; new generated values use warehouse/date plus container/plate suffix.
admissionDateReceipt dateSelected receiptDate, submitted as YYYY-MM-DDTHH:mm:ss.
manufacturingDate, expiryDate, dueDateBatch manufacture, expiry, and deposit due datesBatch editor/existing data; dueDate is sent only for deposit/non-main warehouses and uses YYYY-MM-DDTHH:mm:ss.

Permissions And Guards

TopicBehavior
Terminal menu keygoodsReceipt
deptCode menu set-2, 1, 2, 3, 4, 7, 29, 21, 8, 9, 12, 22, 27, 28
Branch ruleallowNonMainBranch = true; on a non-main selected warehouse the menu is accessible even when the user's deptCode is not in the stock menu set.
Full non-main accessUsers with non-main warehouse full access can pass menu access checks across these stock menus.
Required local stateSelected branch and user are loaded from local storage before submit.

Mobile vs POS Terminal

TopicMobilePOS Terminal
NavigationDedicated stack screensHomeScreen split-pane detail form
Product addFull-screen picker/modal flowDetail panel modal flow
Batch behaviorQuantity, duplicate batch, and date validationQuantity and duplicate batch guards; deposit dates are carried in payload
UX after saveReturn/replace list screenRefresh list pane and close detail

Developer Handoff Map

AreaCode
Mobile list/detailapps/mobile/src/screens/goodsReceiptStack/goodsReceiptListScreen, goodsReceiptDetailScreen
Terminal detailapps/pos-terminal/src/screens/HomeScreen/GoodsReceiptDetailForm.tsx
Mobile serviceapps/mobile/src/services/goodsReceipt.ts
Terminal serviceapps/pos-terminal/src/services/goodsReceipt.ts / goodsReceipts.ts
Shared rules@bsr/utils batch helpers, utils date/quantity validators