// Update PeriodCategory with SalesDownPaymentInterimAccount and PurchaseDownPaymentInterimAccount
PeriodCategoryParamsCollection oPeriodCategoryColl;
PeriodCategory oPerCategory;
// Get Period Category Collection
oPeriodCategoryColl = MainModule.oCmpSrv.GetPeriods();
// Get the current period category, e.g. the first category
oPerCategory = MainModule.oCmpSrv.GetPeriod(oPeriodCategoryColl.Item(0));
// SalesDownPaymentInterimAccount is a new property, mandatory for DownPayment process
oPerCategory.SalesDownPaymentInterimAccount = "2000";
// PurchaseDownPaymentInterimAccount is a new property, mandatory for DownPayment process
oPerCategory.PurchaseDownPaymentInterimAccount = "2000";
MainModule.oCmpSrv.UpdatePeriod(oPerCategory);
// Add a BP
SAPbobsCOM.BusinessPartners oBP;
oBP = (SAPbobsCOM.BusinessPartners)MainModule.oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oBusinessPartners);
oBP.CardCode = "efrat";
// DownPaymentClearAct is an existing property, mandatory for DownPayment process
oBP.DownPaymentClearAct = "1000";
//DownPaymentInterimAccount is a new property, mandatory for DownPayment process
oBP.DownPaymentInterimAccount = "1000";
oBP.Add();
// Add two items
SAPbobsCOM.Items oItem1, oItem2;
oItem1 = (SAPbobsCOM.Items)MainModule.oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oItems);
oItem1.ItemCode = "item1";
oItem1.InventoryItem = BoYesNoEnum.tNO;
oItem1.Add();
oItem2 = (SAPbobsCOM.Items)MainModule.oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oItems);
oItem2.ItemCode = "item2";
oItem2.InventoryItem = BoYesNoEnum.tNO;
oItem2.Add();
// Add a DownPayment invoice
SAPbobsCOM.Documents oDP;
oDP = (SAPbobsCOM.Documents)MainModule.oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oDownPayments);
// Set Down Payment Header Values
oDP.CardCode = "efrat";
oDP.DownPaymentType = DownPaymentTypeEnum.dptInvoice;
// Set Down Payment Line Values
// For VatGroup A1, the DownPayment has a line with 1 item1 of unit price $10.
oDP.Lines.ItemCode = "item1";
oDP.Lines.Quantity = 1;
oDP.Lines.UnitPrice = 10;
oDP.Lines.VatGroup = "A1";
oDP.Lines.Add();
//For VatGroup A2, the DownPayment has a line with 1 item2 of unit price $10.
oDP.Lines.ItemCode = "item2";
oDP.Lines.Quantity = 1;
oDP.Lines.UnitPrice = 10;
oDP.Lines.VatGroup = "A2";
oDP.Add();
string sNewObjCode = "";
// Retrieve the key of the last added record, here the DocNum of DownPayment invoice created in the step
MainModule.oCompany.GetNewObjectCode(out sNewObjCode);
int tmpKey = Convert.ToInt32(sNewObjCode);
// Pay the DownPayment invoice
SAPbobsCOM.Payments oPay;
oPay = (SAPbobsCOM.Payments)MainModule.oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oIncomingPayments);
oPay.CardCode = "efrat";
// Set the Downpayment we created to be paid
oPay.Invoices.DocEntry = tmpKey;
oPay.Invoices.InvoiceType = BoRcptInvTypes.it_DownPayment;
oPay.CashAccount = "1000";
oPay.CashSum = 30;
oPay.Add();
// Add invoice with down payment
SAPbobsCOM.Documents oINV;
oINV = (SAPbobsCOM.Documents)MainModule.oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oInvoices);
oINV.CardCode = "efrat";
oINV.DocType = SAPbobsCOM.BoDocumentTypes.dDocument_Items;
// For VatGroup A1, the invoice has 1 item1 with unit price $10.
oINV.Lines.ItemCode = "item1";
oINV.Lines.Quantity = 1;
oINV.Lines.UnitPrice = 10;
oINV.Lines.VatGroup = "A1";
oINV.Lines.Add();
// For VatGroup A2, the invoice has 1 item2 with unit price $20.
oINV.Lines.ItemCode = "item2";
oINV.Lines.Quantity = 1;
oINV.Lines.UnitPrice = 20;
oINV.Lines.VatGroup = "A2";
// Link to the invoice the DownPayment that was paid.
SAPbobsCOM.DownPaymentsToDraw dpm = oINV.DownPaymentsToDraw;
dpm.DocEntry = tmpKey;
// Draw totally $5 from the DownPayment
dpm.AmountToDraw = 5;
// Distribute the total amount to draw according to different VatGroups
// DownPaymentsToDrawDetails is a new sub-object of DownPaymentsToDraw
SAPbobsCOM.DownPaymentsToDrawDetails dpDetails = dpm.DownPaymentsToDrawDetails;
// Add a DownPaymentsToDrawDetails line
// Draw $2 from VatGroup A1 of the DownPayment in step 4
dpDetails.VatGroupCode = "A1";
dpDetails.AmountToDraw = 2.0;
dpDetails.Add();
// Add a DownPaymentsToDrawDetails line
//Draw $3 from VatGroup A2 of the DownPayment in step 4
dpDetails.VatGroupCode = "A2";
dpDetails.AmountToDraw = 3.0;
// Add the invoice
oINV.Add();
SAP® Business One is the trademark(s) or registered trademark(s) of SAP AG in Germany and in several other countries. Contact This website is not affiliated with, maintained, authorized, endorsed or sponsored by SAP AG or any of its affiliates