<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Create Draft Payment linked to invoice (DI API) (C#) in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/create-draft-payment-linked-to-invoice-di-api-c/m-p/12126752#M1974787</link>
    <description>&lt;P&gt;Hi, I need to create draft payments using DI API, I can do it in "PayNoDoc" and "Account" payments. But I can't link Payment to partner's invoice(s). Here is my code:&lt;/P&gt;
  &lt;PRE&gt;&lt;CODE&gt;private void CreateDraftPaymentAcc()
        {
            if (CheckIfValidDraftData())
            {
                //https://answers.sap.com/questions/11145336/creacion-de-documento-preliminar-sdk.html
                //Mandatory fields in SAP Business One: CardCode, CashSum, TransferAccount, and TransferSum.

                Int32 lRetCode, temp, nErr;
                String strDocEntry, errMsg;

                SAPbobsCOM.Payments DraftPayment = oCompany.GetBusinessObject(BoObjectTypes.oPaymentsDrafts);

                // Common Data
                DraftPayment.DocObjectCode = (fldPaymentType.SelectedIndex == IncomingPayments) ?
                    BoPaymentsObjectType.bopot_IncomingPayments : BoPaymentsObjectType.bopot_OutgoingPayments;

                if (fldDocType.SelectedIndex == NormalPayment || fldDocType.SelectedIndex == NormalAdvance)
                    DraftPayment.DocType = (fldPaymentType.SelectedIndex == IncomingPayments) ? BoRcptTypes.rCustomer : BoRcptTypes.rSupplier;
                else if (fldDocType.SelectedIndex == AccountPayment)
                    DraftPayment.DocType = BoRcptTypes.rAccount;
                else if (fldDocType.SelectedIndex == RefundPayment)
                    DraftPayment.DocType = (fldPaymentType.SelectedIndex == IncomingPayments) ? BoRcptTypes.rSupplier : BoRcptTypes.rCustomer;
                DraftPayment.TransferDate = Convert.ToDateTime(fldTaxDate.Text); // Fecha de Transferencia
                DraftPayment.TaxDate = Convert.ToDateTime(fldTaxDate.Text); // Fecha de Documento
                DraftPayment.DocDate = Convert.ToDateTime(fldDocDate.Text);  // Fecha de Contabilización
                DraftPayment.TransferReference = fldTransferReference.Text;
                DraftPayment.TransferSum = Convert.ToDouble(fldTransferSum.Text);
                DraftPayment.TransferAccount = fldTransferAccount.SelectedValue.ToString();
                DraftPayment.Remarks = fldComments.Text;
                DraftPayment.HandWritten = SAPbobsCOM.BoYesNoEnum.tNO;

                // NormalPayment
                if (fldDocType.SelectedIndex == NormalPayment)
                {
                    DraftPayment.Invoices.Add();
                    DraftPayment.Invoices.DocEntry = 1038; // Hardcoded test!
                }// NormalAdvance
                if (fldDocType.SelectedIndex == NormalAdvance)
                {
                    DraftPayment.ControlAccount = (fldPaymentType.SelectedIndex == IncomingPayments) ? 
                        NormalAdvanceAccountCustomers : NormalAdvanceAccountSuppliers;
                }
                // AccountPayment
                if (fldDocType.SelectedIndex == AccountPayment)
                {
                    DraftPayment.AccountPayments.AccountCode = fldControlAccount.SelectedValue.ToString();
                    DraftPayment.AccountPayments.SumPaid = Convert.ToDouble(fldTransferSum.Text);
                    DraftPayment.AccountPayments.Decription = fldDecription.Text; // Info detallada / Comentarios documento
                    DraftPayment.CardName = fldCardName.Text;
                }
                else
                {
                    DraftPayment.CardCode = fldCardCode.SelectedValue.ToString();
                }
                // OutgoingPayments IGTF (Only)
                if (fldPaymentType.SelectedIndex == OutgoingPayments)
                {
                    DraftPayment.UserFields.Fields.Item("U_CTS_ImptGTF").Value = (fldU_CTS_ImptGTF.Checked) ? "Y" : "N";
                }

                lRetCode = DraftPayment.Add();

                oCompany.GetLastError(out nErr, out errMsg);
                if (nErr != 0)
                    ShowError("Found error:" + nErr + ", " + errMsg);
                else
                {
                    oCompany.GetNewObjectCode(out strDocEntry);
                    temp = Convert.ToInt32(strDocEntry);
                    ShowMsg("Documento fue creado con el número de documento preliminar " +
                            strDocEntry.ToString());
                }
            }
        }&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;How I can find and link partner's invoices to payment?&lt;/P&gt;</description>
    <pubDate>Tue, 17 Dec 2019 21:04:41 GMT</pubDate>
    <dc:creator>former_member620204</dc:creator>
    <dc:date>2019-12-17T21:04:41Z</dc:date>
    <item>
      <title>Create Draft Payment linked to invoice (DI API) (C#)</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/create-draft-payment-linked-to-invoice-di-api-c/m-p/12126752#M1974787</link>
      <description>&lt;P&gt;Hi, I need to create draft payments using DI API, I can do it in "PayNoDoc" and "Account" payments. But I can't link Payment to partner's invoice(s). Here is my code:&lt;/P&gt;
  &lt;PRE&gt;&lt;CODE&gt;private void CreateDraftPaymentAcc()
        {
            if (CheckIfValidDraftData())
            {
                //https://answers.sap.com/questions/11145336/creacion-de-documento-preliminar-sdk.html
                //Mandatory fields in SAP Business One: CardCode, CashSum, TransferAccount, and TransferSum.

                Int32 lRetCode, temp, nErr;
                String strDocEntry, errMsg;

                SAPbobsCOM.Payments DraftPayment = oCompany.GetBusinessObject(BoObjectTypes.oPaymentsDrafts);

                // Common Data
                DraftPayment.DocObjectCode = (fldPaymentType.SelectedIndex == IncomingPayments) ?
                    BoPaymentsObjectType.bopot_IncomingPayments : BoPaymentsObjectType.bopot_OutgoingPayments;

                if (fldDocType.SelectedIndex == NormalPayment || fldDocType.SelectedIndex == NormalAdvance)
                    DraftPayment.DocType = (fldPaymentType.SelectedIndex == IncomingPayments) ? BoRcptTypes.rCustomer : BoRcptTypes.rSupplier;
                else if (fldDocType.SelectedIndex == AccountPayment)
                    DraftPayment.DocType = BoRcptTypes.rAccount;
                else if (fldDocType.SelectedIndex == RefundPayment)
                    DraftPayment.DocType = (fldPaymentType.SelectedIndex == IncomingPayments) ? BoRcptTypes.rSupplier : BoRcptTypes.rCustomer;
                DraftPayment.TransferDate = Convert.ToDateTime(fldTaxDate.Text); // Fecha de Transferencia
                DraftPayment.TaxDate = Convert.ToDateTime(fldTaxDate.Text); // Fecha de Documento
                DraftPayment.DocDate = Convert.ToDateTime(fldDocDate.Text);  // Fecha de Contabilización
                DraftPayment.TransferReference = fldTransferReference.Text;
                DraftPayment.TransferSum = Convert.ToDouble(fldTransferSum.Text);
                DraftPayment.TransferAccount = fldTransferAccount.SelectedValue.ToString();
                DraftPayment.Remarks = fldComments.Text;
                DraftPayment.HandWritten = SAPbobsCOM.BoYesNoEnum.tNO;

                // NormalPayment
                if (fldDocType.SelectedIndex == NormalPayment)
                {
                    DraftPayment.Invoices.Add();
                    DraftPayment.Invoices.DocEntry = 1038; // Hardcoded test!
                }// NormalAdvance
                if (fldDocType.SelectedIndex == NormalAdvance)
                {
                    DraftPayment.ControlAccount = (fldPaymentType.SelectedIndex == IncomingPayments) ? 
                        NormalAdvanceAccountCustomers : NormalAdvanceAccountSuppliers;
                }
                // AccountPayment
                if (fldDocType.SelectedIndex == AccountPayment)
                {
                    DraftPayment.AccountPayments.AccountCode = fldControlAccount.SelectedValue.ToString();
                    DraftPayment.AccountPayments.SumPaid = Convert.ToDouble(fldTransferSum.Text);
                    DraftPayment.AccountPayments.Decription = fldDecription.Text; // Info detallada / Comentarios documento
                    DraftPayment.CardName = fldCardName.Text;
                }
                else
                {
                    DraftPayment.CardCode = fldCardCode.SelectedValue.ToString();
                }
                // OutgoingPayments IGTF (Only)
                if (fldPaymentType.SelectedIndex == OutgoingPayments)
                {
                    DraftPayment.UserFields.Fields.Item("U_CTS_ImptGTF").Value = (fldU_CTS_ImptGTF.Checked) ? "Y" : "N";
                }

                lRetCode = DraftPayment.Add();

                oCompany.GetLastError(out nErr, out errMsg);
                if (nErr != 0)
                    ShowError("Found error:" + nErr + ", " + errMsg);
                else
                {
                    oCompany.GetNewObjectCode(out strDocEntry);
                    temp = Convert.ToInt32(strDocEntry);
                    ShowMsg("Documento fue creado con el número de documento preliminar " +
                            strDocEntry.ToString());
                }
            }
        }&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;How I can find and link partner's invoices to payment?&lt;/P&gt;</description>
      <pubDate>Tue, 17 Dec 2019 21:04:41 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/create-draft-payment-linked-to-invoice-di-api-c/m-p/12126752#M1974787</guid>
      <dc:creator>former_member620204</dc:creator>
      <dc:date>2019-12-17T21:04:41Z</dc:date>
    </item>
  </channel>
</rss>

