private void PushMemoAndWriteSync(ShopifyRefund refundRecord, Invoice invoice) { // Push to Acumatica // string resultJson; try { resultJson = _invoiceClient.WriteInvoice(invoice.SerializeToJson()); } catch (Exception ex) { _systemLogger.Error(ex); _logService.Log($"Encounter error syncing memo for {refundRecord.LogDescriptor()}"); return; } var result = resultJson.DeserializeFromJson <Invoice>(); var existingRecord = _syncOrderRepository.RetreiveMemo(refundRecord.MonsterId); if (existingRecord == null) { // Create Monster Sync Record // var newRecord = new AcumaticaMemo(); newRecord.ShopifyRefundMonsterId = refundRecord.MonsterId; if (result == null) { // Workaround for Acumatica Bug // newRecord.AcumaticaRefNbr = AcumaticaSyncConstants.UnknownRefNbr; } else { newRecord.AcumaticaRefNbr = result.ReferenceNbr.value; } newRecord.AcumaticaDocType = invoice.Type.value; newRecord.AcumaticaAmount = (decimal)invoice.Amount.value; newRecord.NeedRelease = true; newRecord.NeedManualApply = true; newRecord.DateCreated = DateTime.UtcNow; newRecord.LastUpdated = DateTime.UtcNow; _syncOrderRepository.InsertMemo(newRecord); } else { //existingRecord.AcumaticaAppliedToOrder = (decimal)payment.AmountAppliedToOrder; existingRecord.LastUpdated = DateTime.UtcNow; _syncOrderRepository.SaveChanges(); } _syncOrderRepository.ResetOrderErrorCount(refundRecord.ShopifyOrderId); }