Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics GP (Archived)

Sales Invoice Unit Pricing

(0) ShareShare
ReportReport
Posted on by 585

Hi,

I am using the Web Service API to create a Sales Invoice. For some reason, my unit cost is $750 and my extended price is the same. The correct price is $1500. Where is this $750 coming from?

7041.5_2D00_25_2D00_2013-1_2D00_35_2D00_50-PM.jpg

*This post is locked for comments

  • jmawebtech Profile Picture
    jmawebtech 585 on at
    RE: Sales Invoice Unit Pricing

    Here is my code:

           public void CreateSalesInvoice(JMAOrder ord, string batchK, string customerID)

           {

               SalesInvoice salesInvoice;

               SalesDocumentTypeKey salesInvoiceType;

               CustomerKey customerKey;

               BatchKey batchKey;

               SalesInvoiceLine salesInvoiceLine;

               ItemKey invoiceItem;

               Quantity invoiceCount;

               // 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;

               GPCustomers gp = new GPCustomers(wsDynamicsGP, context);

               customerKey = gp.CreateGPCustomer(ord, customerID);

               // Set the customer key property of the sales order object

               salesInvoice.CustomerKey = customerKey;

               // Create a batch key

               batchKey = new BatchKey();

               batchKey.Id = batchK;

               // Set the batch key property of the sales invoice object

               salesInvoice.BatchKey = batchKey;

               List<SalesInvoiceLine> soLines = new List<SalesInvoiceLine>();

               foreach (JMAOrderDetail jd in ord.OrderDetails)

               {

                   GPItems gpi = new GPItems(wsDynamicsGP, jma, context, errorMessageDataSource);

                   ItemKey ik = gpi.CreateInventoryItem(jd.Product);

                   // Create a sales order line to specify the ordered item

                   salesInvoiceLine = new SalesInvoiceLine();

                   // Set the item key property of the sales order line object

                   salesInvoiceLine.ItemKey = ik;

                   //salesInvoiceLine.UnitPrice = new MoneyAmount { Value = jd.PriceExclTax };

                   //salesInvoiceLine.ExtendedCost = new MoneyAmount { Value = jd.PriceExclTax };

                   salesInvoiceLine.IsNonInventory = false;

                   salesInvoiceLine.UnitCost = null;

                   salesInvoiceLine.WarehouseKey = new WarehouseKey { Id = jma.MSDynamicsGPDefaultWarehouse };

                   // Create a sales order quantity object

                   invoiceCount = new Quantity();

                   invoiceCount.Value = jd.Quantity;

                   // Set the quantity of the sales order line object

                   salesInvoiceLine.Quantity = invoiceCount;

                   soLines.Add(salesInvoiceLine);

               }

               // Add the sales invoice line array to the sales line object

               salesInvoice.Lines = soLines.ToArray();

               List<SalesPayment> payments = new List<SalesPayment>();

               SalesPayment sp = new SalesPayment();

               sp.PaymentAmount = new MoneyAmount { Value = ord.Total };

               //- Invalid PaymentType. 4=Cash Payment, 5=Check Payment, or 6=Credit Card Payment are valid values.

               sp.Type = SalesPaymentType.PaymentCardPayment;

               sp.Date = DateTime.Now;

               PaymentCardType[] cList = wsDynamicsGP.GetPaymentCardTypeList(new PaymentCardTypeCriteria(), context);

               sp.PaymentCardTypeKey = cList.FirstOrDefault().Key;

               payments.Add(sp);

               salesInvoice.Payments = payments.ToArray();

               // Get the create policy for the sales invoice object

               salesInvoiceCreatePolicy = wsDynamicsGP.GetPolicyByOperation("CreateSalesInvoice", context);

               // Create the sales invoice

               wsDynamicsGP.CreateSalesInvoice(salesInvoice, context, salesInvoiceCreatePolicy);

           }

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,516 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,409 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans