Closed TawTeuf closed 8 years ago
Looking at that code I'd fully expect it to be creating an invoice with 2 items every time. You have a for loop that will run for 2 iterations (you've hard coded this). In the for loop you are adding a line on each iteration with this line:
salesInvoice.salesInvoiceLines.Entries.Add(orderLine);
If you want to add more lines you need to construct further salesInvoiceLine instances, set the appropriate details on them and add them to the salesInvoice.salesInvoiceLines.Entries as per the above line.
Hope that helps.
Hi, This is because of the way you are adding the lines to the invoice object. You first need to add the lines to the lines feed then once all the lines are in the feed assign the feed to the lines collection.
Something like:
salesInvoiceFeedEntry salesInvoice = new salesInvoiceFeedEntry(); salesInvoiceLinesFeed orderLines = new salesInvoiceLineFeed();
for (int i = 0; i < 2; i++) { string strProdCode = ""; salesInvoiceLineFeedEntry orderLine = new salesInvoiceLineFeedEntry(); if (i == 0) strProdCode = "P001"; else strProdCode = "P002";
orderLine.type = "Standard";
orderLine.text = commodity.description;
orderLine.commodity = commodityReference;
orderLine.quantity = 2;
orderLine.netTotal = 50;
orderLine.taxTotal = 10;
orderLine.grossTotal = 60;
orderLines.Entries.Add(orderLine);
}
salesInvoice.salesInvoiceLines = orderLines;
Obviously not fully working but you should get the principal.
Thanks you....will try it and revert back if i am having some issues
Sent from my Samsung device
-------- Original message -------- From: asterix187 notifications@github.com Date: 10/08/2016 22:49 (GMT+04:00) To: "Sage/SData-2.0" SData-2.0@noreply.github.com Cc: TawTeuf tawteuf@live.com, Author author@noreply.github.com Subject: Re: [Sage/SData-2.0] Invoice with multiple lines (#62)
Hi, This is because of the way you are adding the lines to the invoice object. You first need to add the lines to the lines feed then once all the lines are in the feed assign the feed to the lines collection.
Something like:
salesInvoiceFeedEntry salesInvoice = new salesInvoiceFeedEntry(); salesInvoiceLinesFeed orderLines = new salesInvoiceLineFeed();
for (int i = 0; i < 2; i++) { string strProdCode = ""; salesInvoiceLineFeedEntry orderLine = new salesInvoiceLineFeedEntry(); if (i == 0) strProdCode = "P001"; else strProdCode = "P002";
orderLine.type = "Standard"; orderLine.text = commodity.description; orderLine.commodity = commodityReference; orderLine.quantity = 2; orderLine.netTotal = 50; orderLine.taxTotal = 10; orderLine.grossTotal = 60;
salesInvoiceLinesFeed.Entries.Add(orderLine);
}
salesInvoice.salesInvoiceLines = salesInvoiceLinesFeed;
Obviously not working but you should get the principal.
You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/Sage/SData-2.0/issues/62#issuecomment-238965454, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AT-2eGjFCANa_2h97gANYlarqEgf0bCiks5qeh0lgaJpZM4JhSX4.
Hello, I am new to sage 50 sdata. I have gone through different comments from this blog and now I have begin to understand how to make invoices using sdata through c#. My Problem is that how can i input multiple items on the same invoice.
My Code is : public void AddInvoice() { salesInvoiceFeedEntry salesInvoice = new salesInvoiceFeedEntry();
its always saving the last product ( 2 lines with same item)