Click or drag to resize

MPInterfaceCreatePurchaseDocumentFromPurchaseProcess Method

Creates a new purchase document based on the open positions in the purchase process. The interface only filters the accounting positions by date.

The object will be created, but not stored. Please call bImportPurchaseProcessDocument(clsImportPurchaseProcessDocument, clsImportBaseeImportMode) for the import.

Namespace:  MARIInterface
Assembly:  MARIInterface (in MARIInterface.dll) Version: 8.0.0.100
Syntax
public clsImportPurchaseProcessDocument CreatePurchaseDocumentFromPurchaseProcess(
	int PurchaseProcessID,
	DateTime FilterPositionsByDate,
	clsImportSalesContractDocumenteDocTypes PurchaseDocumentType,
	clsImportSalesContractDocumenteFilterBalanceMode PositionFilterMode,
	int BaseDocumentID
)

Parameters

PurchaseProcessID
Type: SystemInt32
Unique field for the purchase process.
FilterPositionsByDate
Type: SystemDateTime
Filter all positions by this date
PurchaseDocumentType
Type: MARIInterfaceclsImportSalesContractDocumenteDocTypes
Document type of the new object.
PositionFilterMode
Type: MARIInterfaceclsImportSalesContractDocumenteFilterBalanceMode
Calculate the position selection based on clsImportSalesContractDocumenteFilterBalanceMode.
BaseDocumentID
Type: SystemInt32
Link to the MARIProject document as a base (currenty only purchase orders are allowed)

Return Value

Type: clsImportPurchaseProcessDocument
Remarks

  1. Based on the positions of the purchase process all or filtered positions will be selected. The clsImportPurchaseProcessDocument will be created in a first step, with no efect.
  2. Now you can change the new document and its positions. For example enter the REFNumber and the DocumentDate to the object.
    • When you add positions, the must be linked to a purchase process position. Use PositionReference.
    • New positions must have the same ItemCode as the position in the purchase process. On services the corresponding item code to the service.
  3. To create the coresponding SBO document, set TransferERP=true.
  4. Use bImportPurchaseProcessDocument(clsImportPurchaseProcessDocument, clsImportBaseeImportMode) to create the document.
    • The document in MARIProject will be saved.
    • The corresponding item bookings will be created. Errors accure, when the phase is closed or the project manager is not allowed to book. Only purchase process positions linked to sales contract positions can be processed.
    • The document is transfered to SBO. Please consider the DI-API requirements. (32/64 bit, license, link of MARIProject user to SBO user).

Examples
Create Purchase Order
private int CreatePurchaseOrder(int lPOProcessID, DateTime dtDocumentDate) {
    Log($"CreatePurchaseOrder(lPOProcessID={lPOProcessID},{dtDocumentDate.ToShortDateString()})");

    clsImportPurchaseProcessDocument oNewPODoc;
    DateTime dtFilterPos = new DateTime(2016, 7, 1);
    clsImportSalesContractDocument.eDocTypes nDocType = clsImportSalesContractDocument.eDocTypes.PurchaseOrder;
    clsImportSalesContractDocument.eFilterBalanceMode nFilterBalance = clsImportSalesContractDocument.eFilterBalanceMode.NoFilterByQty;

    //The interface will now open the purchase process and creates a new PO document based on the BalaceMode
    oNewPODoc = oMPInterface.CreatePurchaseDocumentFromPurchaseProcess(lPOProcessID, dtFilterPos, nDocType, nFilterBalance,/*BaseDoc*/ 0);

    //add the external information
    oNewPODoc.DocumentDate = dtDocumentDate;
    oNewPODoc.PostingDate = dtDocumentDate;
    oNewPODoc.DocDueDate = new DateTime(2016, 8, 1); //delivery date for the print out

    //change del date in the positiosn
    foreach (clsImportPurchaseProcessDocumentPositions oPos in oNewPODoc.Positions) {
        oPos.DeliveryDate = new DateTime(2016, 8, 1);
    }

    //Create SBO document out of the MARIProject document
    oNewPODoc.TransferERP = true;

    if (oMPInterface.bImportPurchaseProcessDocument(oNewPODoc, clsImportBase.eImportMode.ValidateAndImport)) {
        Log($"CreatePurchaseOrder MPDocID={oNewPODoc.DocumentID}, SBO DocEntry={oNewPODoc.DocEntry}");
        return oNewPODoc.DocumentID;
    } else {
        LogFail("CreatePurchaseOrder: " + oMPInterface.oErrors.PrintErrors());
    }
    return 0;
}
A/P Invoice example
private int CreatePODocumentForPOProcess(int lPOProcessID, int lPurchaseOrderDocID, DateTime dtDocumentDate) {
    Log($"CreatePODocumentForPOProcess({lPOProcessID}, {lPurchaseOrderDocID}, {dtDocumentDate.ToShortDateString()})");

    clsImportPurchaseProcessDocument oNewPODoc;
    DateTime dtFilterPos = new DateTime(2016, 7, 1);
    clsImportSalesContractDocument.eDocTypes nDocType = clsImportSalesContractDocument.eDocTypes.AP_Invoice;
    clsImportSalesContractDocument.eFilterBalanceMode nFilterBalance = clsImportSalesContractDocument.eFilterBalanceMode.QuantityByBaseDocument;

    //The interface will now open the purchase process and creats a new PO document based on the BalaceMode
    oNewPODoc = oMPInterface.CreatePurchaseDocumentFromPurchaseProcess(lPOProcessID, dtFilterPos, nDocType, nFilterBalance, lPurchaseOrderDocID);

    //add the external information
    oNewPODoc.REFNumber = "123456"; // external AP Invoice number
    oNewPODoc.DocumentDate = dtDocumentDate;
    oNewPODoc.PostingDate = dtDocumentDate;
    oNewPODoc.JournalRemark = "Journal Remark";

    //Create SBO document out of the MARIProject document
    oNewPODoc.TransferERP = true;

    //example to add a new text line. Adding other position types needs a reference to the sales contract position.
    clsImportPurchaseProcessDocumentPositions oNewPos = new clsImportPurchaseProcessDocumentPositions();
    oNewPos.PositionType = clsImportSalesContractDocumentPositions.ePosTypes.Text;
    oNewPos.MPPositionType = clsImportProjectContractPosition.eContractPositionType.TextPosition;
    oNewPos.AccountingInfo = "My text";
    oNewPODoc.AddPosition(oNewPos);

    if (oMPInterface.bImportPurchaseProcessDocument(oNewPODoc, clsImportBase.eImportMode.ValidateAndImport)) {
        Log($"bImportPurchaseProcessDocument: MPDocID={oNewPODoc.DocumentID}, SBO DocEntry={oNewPODoc.DocEntry}");
        return oNewPODoc.DocumentID;
    } else {
        LogFail("bImportPurchaseProcessDocument: " + oMPInterface.oErrors.PrintErrors());
    }
    return 0;
}
See Also