private AcumaticaMemo RetrieveCreditMemoWithMissingId(ShopifyRefund refundRecord) { var acumaticaCreditMemo = refundRecord.AcumaticaMemo; if (acumaticaCreditMemo.AcumaticaRefNbr == AcumaticaSyncConstants.UnknownRefNbr) { var customerOrder = refundRecord.ShopifyRefundId.ToString(); var invoices = _invoiceClient.RetrieveInvoiceByCustomerOrder(customerOrder); if (invoices.Count == 0) { _syncOrderRepository.DeleteMemoPaymentRecord(refundRecord.MonsterId); throw new Exception( $"Shopify {refundRecord.MonsterId} sync to Acumatica Credit Memo false record detected"); } if (invoices.Count > 1) { throw new Exception($"Multiple Acumatica Memo records with Customer Order Number {customerOrder}"); } var correctedReferenceNbr = invoices.First().ReferenceNbr.value; _syncOrderRepository.UpdateMemoRecordRefNbr(refundRecord.MonsterId, correctedReferenceNbr); acumaticaCreditMemo.AcumaticaRefNbr = correctedReferenceNbr; } return(acumaticaCreditMemo); }