Hi ievgen,
This is the code.
CallContext callcontext = new CallContext();
callcontext.Company = "MFI";
PurchaseInvoiceServiceClient client = new PurchaseInvoiceServiceClient();
AxdPurchaseInvoice purchaseInvoice = new AxdPurchaseInvoice();
AxdEntity_LedgerJournalTable journalHeader = new AxdEntity_LedgerJournalTable();
journalHeader.JournalType = AxdEnum_LedgerJournalType.VendInvoiceRegister;
journalHeader.JournalTypeSpecified = true;
journalHeader.JournalName = "Vend_Inv";
IList<AxdEntity_LedgerJournalTrans> journalLines = new List<AxdEntity_LedgerJournalTrans>();
for (int i = 0; i < vendorGlDistributions.Count; i++)
{
AxdEntity_LedgerJournalTrans journalLine = new AxdEntity_LedgerJournalTrans();
if (i == 0)
{
journalLine.AccountType = AxdEnum_LedgerJournalACType.Vend;
}
else
{
journalLine.AccountType = AxdEnum_LedgerJournalACType.Ledger;
}
if (journalLine.AccountType == AxdEnum_LedgerJournalACType.Vend)
{
journalLine.AccountTypeSpecified = true;
journalLine.Company = "MFI";
AxdType_MultiTypeAccount account = new AxdType_MultiTypeAccount();
account.Account = vendorInforation.VendorAccount;
account.DisplayValue = vendorInforation.VendorAccount;
journalLine.Invoice = vendorInforation.InvoiceId;
journalLine.AmountCurDebit = vendorGlDistributions[0].Debit;
journalLine.AmountCurDebitSpecified = true;
}
else if (journalLine.AccountType == AxdEnum_LedgerJournalACType.Ledger)
{
journalLine.AccountTypeSpecified = true;
journalLine.Company = "MFI";
AxdType_MultiTypeAccount account = new AxdType_MultiTypeAccount();
account.DisplayValue = "010220-009-009004";
account.Account = vendorInforation.VendorAccount;
account.DisplayValue = vendorInforation.VendorAccount;
journalLine.LedgerDimension = account;
}
journalLines.Add(journalLine);
}
journalHeader.LedgerJournalTrans = new AxdEntity_LedgerJournalTrans[1] { journalLine };
journalHeader.LedgerJournalTrans = journalLines.ToArray();
purchaseInvoice.LedgerJournalTable = new AxdEntity_LedgerJournalTable[1] { journalHeader };
try
{
EntityKey[] entitykey = client.create(callcontext, purchaseInvoice);
journalBatchNumer = entitykey[0].KeyData[0].Value;
}
catch (Exception exception)
{
}
return journalBatchNumer;
Please check this code and guide.