Как установить коды GL в счете-фактуре продаж в Microsoft Dynamics GP?
Я использую Microsoft Dynamics GP 2015. У нас есть проект C# .Net для создания счета-фактуры через веб-сервисы. У бухгалтерии есть следующий запрос: «Мы хотели бы закодировать доход для {элемента} в код GL xx-xx-xxxx». Глядя на код для создания счета-фактуры, я не вижу места для установки кода GL. Я предположил, что коды GL могут быть установлены для элемента в GP, но мне сказали «посмотреть, можно ли установить коды распределения или учетных записей во время создания». Можно ли как-то установить код GL в счете-фактуре? Если да, то какой код для установки кода GL?
Вот код, который я изменяю:
private string createGPSalesInvoice(ItemReceived itemsReceived, DateTime salesOrderDate)
{
CompanyKey companyKey;
companyKey = new CompanyKey();
Context context;
SalesInvoice salesInvoice;
SalesDocumentTypeKey salesInvoiceType;
CustomerKey customerKey;
customerKey = new CustomerKey();
BatchKey batchKey;
SalesInvoiceLine salesInvoiceLine;
ItemKey invoiceItem;
Quantity invoiceCount;
Policy salesInvoiceCreatePolicy;
salesInvoiceCreatePolicy = new Policy();
string salesInvoiceNumber = "";
try
{
// Create an instance of the service
DynamicsGPClient wsDynamicsGP = new DynamicsGPClient();
// Create a context with which to call the service
context = new Context();
// Specify which company to use (sample company)
companyKey.Id = xxx;
// Set up the context object
context.OrganizationKey = (OrganizationKey)companyKey;
// Create a sales invoice object
salesInvoice = new SalesInvoice();
// Create a sales document type key for the sales invoice
salesInvoiceType = new SalesDocumentTypeKey();
salesInvoiceType.Type = SalesDocumentType.Invoice;
// Populate the document type key for the sales invoice
salesInvoice.DocumentTypeKey = salesInvoiceType;
// Create a customer key
customerKey.Id = xxx;
// Set the customer key property of the sales invoice
salesInvoice.CustomerKey = customerKey;
salesInvoice.PostedDate = parms.endDate;
// Create a batch key
batchKey = new BatchKey();
batchKey.Id = xxx;
// Set the batch key property of the sales invoice object
salesInvoice.BatchKey = batchKey;
// Create a sales invoice line to specify the invoiced item
salesInvoiceLine = new SalesInvoiceLine();
// Create an item key
invoiceItem = new ItemKey();
invoiceItem.Id = itemsReceived.GPPartNumber;
// Set the item key property of the sales invoice line object
salesInvoiceLine.ItemKey = invoiceItem;
// Create a sales invoice quatity object
invoiceCount = new Quantity();
invoiceCount.Value = itemsReceived.Quantity;
// Set the quantity of the sales invoice line object
salesInvoiceLine.Quantity = invoiceCount;
MoneyAmount unitCost = new MoneyAmount()
{
Value = itemsReceived.CostEach
};
salesInvoiceLine.UnitPrice = unitCost;
// Create an array of sales invoice lines
// Initialize the array with the sales invoice line object
SalesInvoiceLine[] invoiceLines = { salesInvoiceLine };
// Add the sales invoice line array to the sales line object
salesInvoice.Lines = invoiceLines;
try
{
// Get the create policy for the sales invoice object
salesInvoiceCreatePolicy = wsDynamicsGP.GetPolicyByOperation("CreateSalesInvoice", context);
}
catch (Exception ex)
{
throw ex;
}
try
{
// Create the sales invoice
wsDynamicsGP.CreateSalesInvoice(salesInvoice, context, salesInvoiceCreatePolicy);
}
catch (Exception ex)
{
throw ex;
}
//CREATE A RESTRICION OF THE BATCH ID TO FIND THE SALES DOC JUST CREATED
LikeRestrictionOfstring batchKeyRestriction = new LikeRestrictionOfstring();
batchKeyRestriction.EqualValue = batchKey.Id;
//CREATE SEARCH CRITERIA
SalesDocumentCriteria salesDocumentCriteria = new SalesDocumentCriteria();
salesDocumentCriteria.BatchId = batchKeyRestriction;
try
{
SalesDocumentSummary[] salesDocumentSummary = wsDynamicsGP.GetSalesDocumentList(salesDocumentCriteria, context);
salesInvoiceNumber = salesDocumentSummary.FirstOrDefault().Key.Id;
}
catch (Exception ex)
{
throw ex;
}
// Close the service
if (wsDynamicsGP.State != CommunicationState.Faulted)
{
wsDynamicsGP.Close();
}
return salesInvoiceNumber;
}
catch (Exception ex)
{
throw ex;
}
}