HI Sandip,
I have used the following code, but it has been inserted with Default Distribution , even though i have added PayableDistribution.
static void Main()
{
// Create an instance of the service
var wsDynamicsGP = new DynamicsGPClient();
// Create a context with which to call the service
var context = new Context();
// Specify which company to use (sample company)
var companyKey = new CompanyKey {Id = (-1)};
// Set up the context object
context.OrganizationKey = (OrganizationKey)companyKey;
// Create a payables document key object to identify the payables invoice
var invoiceKey = new PayablesDocumentKey { Id = "00000000000000462" }; //.ToString(CultureInfo.InvariantCulture) };
// Create a batch key
var batchKey = new BatchKey {Id = "PAYABLES BATCH"};
// Create a vendor key
var vendorKey = new VendorKey {Id = "ADVANCED0001"};
// Create a money amount object for the transaction (Purchase Amount)
var purchaseAmount = new MoneyAmount {Currency = "USD", Value = 250m};
// setup my credit and debit values
var creditAmount = new MoneyAmount {Currency = "USD", Value = 100m};
Amount aCredit = creditAmount;
var debitAmount = new MoneyAmount {Currency = "USD", Value = 100m};
Amount aDebit = debitAmount;
// Create a payables invoice object
var payablesInvoice = new PayablesInvoice();
var distributions = new PayablesDistribution[2];
distributions[0] = new PayablesDistribution();
distributions[1] = new PayablesDistribution();
var disTypeKey = new DistributionTypeKey { Id = 6 };
var gKey = new GLAccountNumberKey {Id = "700-7001-00"};
var g2Key = new GLAccountNumberKey {Id = "000-1100-00"};
distributions[0].CompanyKey = companyKey;
distributions[0].DistributionTypeKey = disTypeKey;
distributions[0].GLAccountKey = gKey;
distributions[0].DebitAmount = aDebit;
distributions[1].CompanyKey = companyKey;
distributions[1].DistributionTypeKey = disTypeKey;
distributions[1].GLAccountKey = g2Key;
distributions[1].CreditAmount = aCredit;
// Populate the invoice properties
payablesInvoice.Key = invoiceKey;
payablesInvoice.BatchKey = batchKey;
payablesInvoice.VendorKey = vendorKey;
payablesInvoice.VendorDocumentNumber = "DOCUMENT15";
payablesInvoice.PurchasesAmount = purchaseAmount;
payablesInvoice.Distributions = distributions;
// Get the create policy for payables invoices
Policy payablesInvoiceCreatePolicy = wsDynamicsGP.GetPolicyByOperation("CreatePayablesInvoice", context);
// Create the payables invoice
wsDynamicsGP.CreatePayablesInvoice(payablesInvoice, context, payablesInvoiceCreatePolicy);
// Close the service
if (wsDynamicsGP.State != CommunicationState.Faulted)
{
wsDynamicsGP.Close();
}
}
Thanks
Sekar V