Invoice status is not changing Sage 50 SDK

SUGGESTED

Hi I am using Sage.Peachtree.API for integration between Sage 2018 and my custom .Net application, when I try to save Receipt, it saved successfully through sdk but it dose not make any change in Invoice status. payments are also showing in Receipt List, but Invoice keeps status as unpaid.

Kindly guide me if I am doing something wrong, as it was working fine few weeks back.

for refeference

try
{
// Set receipt proeprties
if (m_cashReceipt == null)
{
m_cashReceipt = clsPTCompany.Company.Factories.ReceiptFactory.Create();
}

// Get selected customer
Customer customer = null;

var SelectedCust = GetCheckedCustomer(Customer); 
if (SelectedCust != null)
{
customer = SelectedCust;
m_cashReceipt.CustomerReference = ((Customer)SelectedCust).Key;
m_cashReceipt.MainAddress.Name = SelectedCust.Name;
m_cashReceipt.MainAddress.Address.Address1 = SelectedCust.BillToContact.Address.Address1;
}

m_cashReceipt.ReceiptNumber = ReceiptNumber;
m_cashReceipt.ReferenceNumber = Reference;
m_cashReceipt.PaymentMethod = PaymentMethod;
m_cashReceipt.Date = Date;

// get account list
EntityList<Account> acctList = clsPTCompany.Company.Factories.AccountFactory.List();
acctList.Load();
var SelectedAccount = from account in acctList
where account.ID == CashAccount
select account;
if (SelectedAccount.FirstOrDefault() != null)
{
m_cashReceipt.AccountReference = ((Account)SelectedAccount.FirstOrDefault()).Key;
}
var SelectedDiscountAccount = from account in acctList
where account.ID == GLAccount
select account;
Account ARAccount = null;
if (SelectedDiscountAccount.FirstOrDefault() != null)
{
ARAccount = ((Account)SelectedDiscountAccount.FirstOrDefault());
//m_cashReceipt.DiscountAccountReference = ((Account)SelectedDiscountAccount.FirstOrDefault()).Key;
}

// Add each overdue invoice paid
foreach (var item in slInvoices)
{
bool IsChecked = true;

if (IsChecked)
{
if (item.Key == null)
continue;

string invoiceNumber = item.Key;
SalesInvoice invoice = GetCheckedInvoice(customer, invoiceNumber);
if (invoice == null)
continue;

// New invoice line
ReceiptInvoiceLine invoiceLine = m_cashReceipt.AddInvoiceLine(invoice);
if (invoice.AccountReference != null)
{
invoiceLine.AccountReference = ARAccount != null ? ARAccount.Key : null;
invoiceLine.Description = Description;

invoiceLine.AmountPaid = item.Value;
}
}
}

foreach (var item in slCreditMemos)
// Save receipt
m_cashReceipt.Save();
}