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); }
private void PushMemoReleaseAndUpdateSync(ShopifyRefund refundRecord) { try { // Workarounds for Acumatica bug that prevents storage of Payment Nbr // var acumaticaMemo = RetrieveCreditMemoWithMissingId(refundRecord); // Release the actual Memo // _invoiceClient.ReleaseInvoice(acumaticaMemo.AcumaticaRefNbr, acumaticaMemo.AcumaticaDocType); _syncOrderRepository.MemoIsReleased(acumaticaMemo.ShopifyRefundMonsterId); _syncOrderRepository.ResetOrderErrorCount(refundRecord.ShopifyOrderId); } catch (Exception ex) { _systemLogger.Error(ex); _logService.Log($"Encounter error syncing {refundRecord.LogDescriptor()}"); _syncOrderRepository.IncreaseOrderErrorCount(refundRecord.ShopifyOrderId); return; } }
public static string DetectedNewShopifyRefund(ShopifyRefund refund) { return($"Detected new {refund.LogDescriptor()}"); }
public static string ReleaseAcumaticaMemo(ShopifyRefund refund) { return($"Releasing Acumatica Memo for {refund.LogDescriptor()}"); }
public static string CreateAcumaticaMemo(ShopifyRefund refund) { return($"Creating Acumatica Memo from {refund.LogDescriptor()}"); }