Esempio n. 1
0
        private ValidationResult ReadyToReleaseMemo(AdjustmentAction adjustmentAction)
        {
            var validation = new Validation <AdjustmentAction>()
                             .Add(x => !x.AcumaticaRefNbr.IsNullOrEmpty(), "Cannot Release Memo until it is synced with Acumatica");

            return(validation.Run(adjustmentAction));
        }
Esempio n. 2
0
        /// <inheritdoc/>
        public string ToDelimitedString()
        {
            CultureInfo culture = CultureInfo.CurrentCulture;

            return(string.Format(
                       culture,
                       StringHelper.StringFormatSequence(0, 16, Configuration.FieldSeparator),
                       Id,
                       ProviderAdjustmentNumber?.ToDelimitedString(),
                       PayerAdjustmentNumber?.ToDelimitedString(),
                       AdjustmentSequenceNumber.HasValue ? AdjustmentSequenceNumber.Value.ToString(culture) : null,
                       AdjustmentCategory?.ToDelimitedString(),
                       AdjustmentAmount?.ToDelimitedString(),
                       AdjustmentQuantity?.ToDelimitedString(),
                       AdjustmentReasonPa?.ToDelimitedString(),
                       AdjustmentDescription,
                       OriginalValue.HasValue ? OriginalValue.Value.ToString(Consts.NumericFormat, culture) : null,
                       SubstituteValue.HasValue ? SubstituteValue.Value.ToString(Consts.NumericFormat, culture) : null,
                       AdjustmentAction?.ToDelimitedString(),
                       ProviderAdjustmentNumberCrossReference?.ToDelimitedString(),
                       ProviderProductServiceLineItemNumberCrossReference?.ToDelimitedString(),
                       AdjustmentDate.HasValue ? AdjustmentDate.Value.ToString(Consts.DateTimeFormatPrecisionSecond, culture) : null,
                       ResponsibleOrganization?.ToDelimitedString()
                       ).TrimEnd(Configuration.FieldSeparator.ToCharArray()));
        }
        private void ProcessAdjustmentMemo(AdjustmentAction action)
        {
            if (action.ActionCode == ActionCode.None)
            {
                return;
            }

            if (action.ActionCode == ActionCode.CreateInAcumatica &&
                action.MemoType == AdjustmentMemoType.CreditMemo && action.IsValid)
            {
                // Create Acumatica Refund payload
                //
                var refund =
                    _syncOrderRepository.RetrieveShopifyRefundWithNoTracking(action.ShopifyRefundId);

                var memoWrite = BuildCreditMemo(refund);

                //_invoiceClient.RetrieveInvoiceAndTaxes("000015", "CRM");

                // Push to Acumatica and write Sync Record
                //
                _logService.Log(LogBuilder.CreateAcumaticaMemo(refund));
                PushMemoAndWriteSync(refund, memoWrite);
            }
        }
 private void ProcessAdjustMemoRelease(AdjustmentAction action)
 {
     if (action.ActionCode == ActionCode.ReleaseInAcumatica && action.IsValid)
     {
         var refund = _syncOrderRepository.RetrieveShopifyRefundWithNoTracking(action.ShopifyRefundId);
         _logService.Log(LogBuilder.ReleaseAcumaticaMemo(refund));
         PushMemoReleaseAndUpdateSync(refund);
     }
 }
Esempio n. 5
0
        private List <AdjustmentAction> BuildRefundAdjustmentActions(ShopifyOrder orderRecord)
        {
            var output = new List <AdjustmentAction>();

            foreach (var creditAdj in orderRecord.CreditAdustmentRefunds())
            {
                var action = new AdjustmentAction();
                action.ActionCode      = ActionCode.None;
                action.ShopifyOrderId  = orderRecord.ShopifyOrderId;
                action.ShopifyRefundId = creditAdj.ShopifyRefundId;

                action.MemoType   = AdjustmentMemoType.CreditMemo;
                action.MemoAmount = creditAdj.CreditAdjustment;


                if (creditAdj.AcumaticaMemo == null)
                {
                    action.ActionCode = ActionCode.CreateInAcumatica;
                }

                if (creditAdj.AcumaticaMemo != null)
                {
                    action.AcumaticaRefNbr  = creditAdj.AcumaticaMemo.AcumaticaRefNbr;
                    action.AcumaticaDocType = creditAdj.AcumaticaMemo.AcumaticaDocType;
                    action.AcumaticaHref
                        = _acumaticaUrlService.AcumaticaInvoiceUrl(
                              SalesInvoiceType.Credit_Memo, creditAdj.AcumaticaMemo.AcumaticaRefNbr);
                }

                if (creditAdj.AcumaticaMemo != null &&
                    !creditAdj.AcumaticaMemo.NeedManualApply &&
                    creditAdj.AcumaticaMemo.NeedRelease)
                {
                    action.ActionCode = ActionCode.ReleaseInAcumatica;
                }

                if (creditAdj.AcumaticaMemo != null &&
                    creditAdj.AcumaticaMemo.NeedManualApply)
                {
                    action.ActionCode = ActionCode.NeedManualApply;
                }

                output.Add(action);
            }

            foreach (var debitAdj in orderRecord.DebitAdustmentRefunds())
            {
                var action = new AdjustmentAction();
                action.ActionCode = ActionCode.CreateInAcumatica;
                action.MemoType   = AdjustmentMemoType.DebitMemo;
                action.MemoAmount = debitAdj.DebitAdjustment;

                output.Add(action);
            }

            return(output);
        }
Esempio n. 6
0
        public void Validate(RootAction rootAction, AdjustmentAction adjustmentAction)
        {
            adjustmentAction.Validation = new ValidationResult();

            if (adjustmentAction.ActionCode == ActionCode.CreateInAcumatica)
            {
                adjustmentAction.Validation = ReadyToCreateMemo(rootAction);
                return;
            }

            if (adjustmentAction.ActionCode == ActionCode.ReleaseInAcumatica)
            {
                adjustmentAction.Validation = ReadyToReleaseMemo(adjustmentAction);
                return;
            }
        }