MGCLatticePurchaseOrderPostingService
Custom service for purchase order posting operations including confirmation, product receipt, and invoicing. A request without lines posts the whole order. A product receipt or invoice request with lines posts only the selected lines and their quantities: each line is resolved to exactly one order line and its quantity is written to that line's receive-now quantity before a PurchUpdate::ReceiveNow update (see resolveRequestedPurchLines). A purchase order confirmation always covers the whole order (Microsoft's confirmation takes no quantity specification), so a confirmation request with lines is refused. An invoice of an order with product receipts is built from the receipts (PurchUpdate::PackingSlip), so its request lines must name exactly the received, uninvoiced quantities. The product receipt and invoice numbers the request carries are the posted document numbers; the response returns the posted confirmation, product receipt or invoice number as PostedDocumentId. cancelPurchaseProductReceipt cancels a posted product receipt the way the product receipt journal's Cancel does (PostedDocumentId = the canceled product receipt). postPurchasePrepaymentInvoice sets up the order's prepayment when it has none and posts a vendor prepayment invoice for it, the way the order's Prepayment and Prepayment invoice actions do (PostedDocumentId = the voucher of the posted prepayment invoice).
Methods
new
Initializes a new instance of the MGCLatticePurchaseOrderPostingService class.
- Visibility:
public - Returns:
void
No parameters.
construct
Creates a new instance of the MGCLatticePurchaseOrderPostingService class.
- Visibility:
public - Returns:
MGCLatticePurchaseOrderPostingServiceA new MGCLatticePurchaseOrderPostingService instance.
No parameters.
postablePurchQty
The quantity, in the purchase unit, that a posting of _documentStatus can still take from a purchase line: the quantity not yet received for a confirmation or product receipt, plus the quantity received but not yet invoiced for an invoice. Return lines carry negative quantities, so the size of the quantity is returned.
- Visibility:
public - Returns:
PurchQtyThe quantity left to post, never negative.
| Name | Type | Optional | Description |
|---|---|---|---|
_purchLine | PurchLine | No | The purchase line. |
_documentStatus | DocumentStatus | No | The document being posted. |
resolveRequestedPurchLines
Resolves the selected request lines to the order lines they name (see findRequestedPurchLine) and checks each requested quantity: it must be greater than zero and at most the quantity left to post (postablePurchQty), and no two request lines may name the same order line. A line is selected unless it says IsSelected: false (the contract defaults it to true); unselected lines are skipped, and a request whose lines are all unselected is refused, so it never posts the whole order. Every violation fails the request as ValidationFailed before anything is written.
- Visibility:
public - Returns:
MapA map from purchase line RecId to the requested quantity; empty when the request carries no lines.
| Name | Type | Optional | Description |
|---|---|---|---|
_purchTable | PurchTable | No | The purchase order. |
_lines | List | No | The request's MGCLatticePurchPostingLineContract lines; may be null. |
_documentStatus | DocumentStatus | No | The document being posted. |
assertRequestMatchesUninvoicedReceipts
For an invoice built from product receipts (PurchUpdate::PackingSlip): checks that the request lines name exactly what that update invoices - every line with a received, uninvoiced quantity, each with exactly that quantity. Partial invoicing of receipts would need receipt matching per line, which the receipt-based update does not take from the request; refusing the request keeps the invoice from silently covering more than was asked.
- Visibility:
public - Returns:
void
| Name | Type | Optional | Description |
|---|---|---|---|
_purchId | PurchId | No | The purchase order. |
_requested | Map | No | The map from resolveRequestedPurchLines; not empty. |
hasProductReceipts
Whether the purchase order has a posted product receipt.
- Visibility:
public - Returns:
booleantrue when a product receipt exists.
| Name | Type | Optional | Description |
|---|---|---|---|
_purchId | PurchId | No | The purchase order. |
confirmPurchaseOrder
Confirms a purchase order by posting the confirmation journal via PurchFormLetter. A confirmation always covers the whole order: Microsoft's purchase order confirmation takes no quantity specification (PurchFormletterParmDataPurchOrder.parmSpecQty forces All), so a request with Lines is refused as ValidationFailed instead of confirming more than it names. The confirmation number is returned as PostedDocumentId.
- Visibility:
public - Returns:
MGCLatticeOrderOperationResponseContractAn MGCLatticeOrderOperationResponseContract indicating success or failure with details.
| Name | Type | Optional | Description |
|---|---|---|---|
_request | MGCLatticePurchaseOrderConfirmRequestContract | No | The request containing PurchaseOrderId, PostingDate, optional Lines, and standard header fields. |
postPurchasePackingSlip
Posts a product receipt for a purchase order using PurchFormLetter with DocumentStatus::PackingSlip, under the request's PackingSlipId. Without request lines everything not yet received is received; with lines, only the selected lines and quantities. The posted product receipt number is returned as PostedDocumentId.
- Visibility:
public - Returns:
MGCLatticeOrderOperationResponseContractAn MGCLatticeOrderOperationResponseContract indicating success or failure with details.
| Name | Type | Optional | Description |
|---|---|---|---|
_request | MGCLatticePurchaseOrderPackingReceiptRequestContract | No | The request containing PurchaseOrderId, PackingSlipId, PostingDate, optional Lines, and standard header fields. |
invoicePurchaseOrder
Posts an invoice for a purchase order using PurchFormLetter with DocumentStatus::Invoice, under the request's InvoiceId. An order with product receipts is invoiced from them; request lines must then name exactly the received, uninvoiced quantities. An order without receipts is invoiced for its ordered quantity, or - with request lines - for the selected lines and quantities. InvoiceId (the vendor's invoice number) is required; the posted invoice number is returned as PostedDocumentId.
- Visibility:
public - Returns:
MGCLatticeOrderOperationResponseContractAn MGCLatticeOrderOperationResponseContract indicating success or failure with details.
| Name | Type | Optional | Description |
|---|---|---|---|
_request | MGCLatticePurchaseOrderInvoiceRequestContract | No | The request containing PurchaseOrderId, InvoiceId, PostingDate, optional Lines, and standard header fields. |
getPurchaseOrderStatus
Queries the current status of a purchase order including confirmation, receipt, and invoice dates.
- Visibility:
public - Returns:
MGCLatticeStatusQueryResponseContractAn MGCLatticeStatusQueryResponseContract with the purchase order status and detail information.
| Name | Type | Optional | Description |
|---|---|---|---|
_request | MGCLatticeStatusQueryRequestContract | No | The request containing DocumentId (PurchId) and standard header fields. |
confirmPurchaseOrderBatch
Confirms multiple purchase orders in a single bulk operation. A missing (null) item fails on its own as ValidationFailed (addBulkNullItemResult) without stopping the batch.
- Visibility:
public - Returns:
MGCLatticeBulkOperationResponseContractAn MGCLatticeBulkOperationResponseContract containing per-item results.
| Name | Type | Optional | Description |
|---|---|---|---|
_requests | List | No | List of MGCLatticePurchaseOrderConfirmRequestContract. |
postPurchasePackingSlipBatch
Posts product receipts for multiple purchase orders in a single bulk operation. A missing (null) item fails on its own as ValidationFailed (addBulkNullItemResult) without stopping the batch.
- Visibility:
public - Returns:
MGCLatticeBulkOperationResponseContractAn MGCLatticeBulkOperationResponseContract containing per-item results.
| Name | Type | Optional | Description |
|---|---|---|---|
_requests | List | No | List of MGCLatticePurchaseOrderPackingReceiptRequestContract. |
invoicePurchaseOrderBatch
Invoices multiple purchase orders in a single bulk operation. A missing (null) item fails on its own as ValidationFailed (addBulkNullItemResult) without stopping the batch.
- Visibility:
public - Returns:
MGCLatticeBulkOperationResponseContractAn MGCLatticeBulkOperationResponseContract containing per-item results.
| Name | Type | Optional | Description |
|---|---|---|---|
_requests | List | No | List of MGCLatticePurchaseOrderInvoiceRequestContract. |
cancelPurchaseProductReceipt
Cancels a posted product receipt the way Purchase order > Product receipt journal > Cancel does: the standard product receipt posting runs as a cancellation (PurchFormLetter_PackingSlip with the versioning update type Cancel, as the PurchFormLetter_PackingSlipCancel action and Microsoft's test library run it), which reverses the receipt, its inventory and its ledger postings and adds a version with zero quantities to the receipt. The request names the purchase order (or its external key) and optionally the product receipt; without one, the order's only product receipt that can be canceled is canceled.
- Visibility:
public - Returns:
MGCLatticeOrderOperationResponseContractAn MGCLatticeOrderOperationResponseContract: DocumentId is the purchase order and PostedDocumentId the canceled product receipt number.
| Name | Type | Optional | Description |
|---|---|---|---|
_request | MGCLatticePurchaseProductReceiptCancelRequestContract | No | The request containing PurchaseOrderId (or PurchaseOrderIdExternalKey), optional ProductReceiptId, and standard header fields. |
cancelPurchaseProductReceiptBatch
Cancels several product receipts in a single bulk operation; each item runs as one cancelPurchaseProductReceipt. A missing (null) item fails on its own as ValidationFailed (addBulkNullItemResult) without stopping the batch.
- Visibility:
public - Returns:
MGCLatticeBulkOperationResponseContractAn MGCLatticeBulkOperationResponseContract containing per-item results.
| Name | Type | Optional | Description |
|---|---|---|---|
_requests | List | No | List of MGCLatticePurchaseProductReceiptCancelRequestContract. |
postPurchasePrepaymentInvoice
Posts a vendor prepayment invoice for a purchase order, the way Purchase order > Purchase > Prepayment and Invoice > Prepayment invoice do: an order without a prepayment gets the one the request describes (a percentage of the order total or a fixed amount, posted with a procurement category; PurchPrepayTable), and the prepayment amount still available to invoice is posted as a vendor invoice of type VendorAdvance under the vendor's invoice number. The prepayment and the invoice are created and posted in one transaction, so a failed posting leaves neither behind.
- Visibility:
public - Returns:
MGCLatticeOrderOperationResponseContractAn MGCLatticeOrderOperationResponseContract: DocumentId is the purchase order and PostedDocumentId the voucher of the posted prepayment invoice (VendInvoiceJour.LedgerVoucher); the message names the invoice number and amount.
| Name | Type | Optional | Description |
|---|---|---|---|
_request | MGCLatticePurchasePrepaymentInvoiceRequestContract | No | The request containing PurchaseOrderId (or PurchaseOrderIdExternalKey), VendorInvoiceNumber, PrepaymentPercent or PrepaymentAmount and PrepaymentCategoryName (for an order without a prepayment), optional PrepaymentCategoryHierarchyName, PrepaymentDescription, InvoiceDate and PostingDate, and standard header fields. |
postPurchasePrepaymentInvoiceBatch
Posts prepayment invoices for several purchase orders in a single bulk operation; each item runs as one postPurchasePrepaymentInvoice. A missing (null) item fails on its own as ValidationFailed (addBulkNullItemResult) without stopping the batch.
- Visibility:
public - Returns:
MGCLatticeBulkOperationResponseContractAn MGCLatticeBulkOperationResponseContract containing per-item results.
| Name | Type | Optional | Description |
|---|---|---|---|
_requests | List | No | List of MGCLatticePurchasePrepaymentInvoiceRequestContract. |