Skip to main content

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: MGCLatticePurchaseOrderPostingService A 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: PurchQty The quantity left to post, never negative.
NameTypeOptionalDescription
_purchLinePurchLineNoThe purchase line.
_documentStatusDocumentStatusNoThe 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: Map A map from purchase line RecId to the requested quantity; empty when the request carries no lines.
NameTypeOptionalDescription
_purchTablePurchTableNoThe purchase order.
_linesListNoThe request's MGCLatticePurchPostingLineContract lines; may be null.
_documentStatusDocumentStatusNoThe 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
NameTypeOptionalDescription
_purchIdPurchIdNoThe purchase order.
_requestedMapNoThe map from resolveRequestedPurchLines; not empty.

hasProductReceipts​

Whether the purchase order has a posted product receipt.

  • Visibility: public
  • Returns: boolean true when a product receipt exists.
NameTypeOptionalDescription
_purchIdPurchIdNoThe 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: MGCLatticeOrderOperationResponseContract An MGCLatticeOrderOperationResponseContract indicating success or failure with details.
NameTypeOptionalDescription
_requestMGCLatticePurchaseOrderConfirmRequestContractNoThe 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: MGCLatticeOrderOperationResponseContract An MGCLatticeOrderOperationResponseContract indicating success or failure with details.
NameTypeOptionalDescription
_requestMGCLatticePurchaseOrderPackingReceiptRequestContractNoThe 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: MGCLatticeOrderOperationResponseContract An MGCLatticeOrderOperationResponseContract indicating success or failure with details.
NameTypeOptionalDescription
_requestMGCLatticePurchaseOrderInvoiceRequestContractNoThe 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: MGCLatticeStatusQueryResponseContract An MGCLatticeStatusQueryResponseContract with the purchase order status and detail information.
NameTypeOptionalDescription
_requestMGCLatticeStatusQueryRequestContractNoThe 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: MGCLatticeBulkOperationResponseContract An MGCLatticeBulkOperationResponseContract containing per-item results.
NameTypeOptionalDescription
_requestsListNoList 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: MGCLatticeBulkOperationResponseContract An MGCLatticeBulkOperationResponseContract containing per-item results.
NameTypeOptionalDescription
_requestsListNoList 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: MGCLatticeBulkOperationResponseContract An MGCLatticeBulkOperationResponseContract containing per-item results.
NameTypeOptionalDescription
_requestsListNoList 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: MGCLatticeOrderOperationResponseContract An MGCLatticeOrderOperationResponseContract: DocumentId is the purchase order and PostedDocumentId the canceled product receipt number.
NameTypeOptionalDescription
_requestMGCLatticePurchaseProductReceiptCancelRequestContractNoThe 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: MGCLatticeBulkOperationResponseContract An MGCLatticeBulkOperationResponseContract containing per-item results.
NameTypeOptionalDescription
_requestsListNoList 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: MGCLatticeOrderOperationResponseContract An 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.
NameTypeOptionalDescription
_requestMGCLatticePurchasePrepaymentInvoiceRequestContractNoThe 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: MGCLatticeBulkOperationResponseContract An MGCLatticeBulkOperationResponseContract containing per-item results.
NameTypeOptionalDescription
_requestsListNoList of MGCLatticePurchasePrepaymentInvoiceRequestContract.