Not able to update Sales Invoice record when trying to set Posting Date as it gives the below error
"The deferral schedule falls outside the accounting periods that have been set up for the company."
Please see the below code:
DateTime lastSalesInvoiceDate = DateTime.UtcNow.Date;
//Posting Date
string postingDate = lastSalesInvoiceDate.Month + "/" + lastSalesInvoiceDate.Day + "/" + lastSalesInvoiceDate.Year;
//Posting Date
salesInvoice_Ws.Posting_Date = Convert.ToDateTime(postingDate);
//Posting Date specified
salesInvoice_Ws.Posting_DateSpecified = true;
//Execute Update
_salesInvoiceService.Update(ref salesInvoice_Ws);
Any help will be appreciated
Thanks!