Ejemplo n.º 1
0
        public void Calculate()
        {
            try
            {
                if (InvoiceSummary.BilledFees == null || InvoiceSummary.BilledExpenses == null)
                {
                    return;
                }

                string adjustAmount = AdjustedAmount.ToString();

                WillAdjustNegative();

                double billedAmount = AdjustmentToggleType == AdjustmentToggleType.Fees
                              ? (double.Parse(CleanNetTotal(RemoveCurrencySymbol(InvoiceSummary.BilledFees, true), true), CultureInfo.CurrentCulture))
                              : (double.Parse(CleanNetTotal(RemoveCurrencySymbol(InvoiceSummary.BilledExpenses, true), true), CultureInfo.CurrentCulture));

                if (AdjustmentType == AdjustmentType.Straight)
                {
                    if (AdjustmentByTo == AdjustmentByTo.AdjustBy)
                    {
                        if (AdjustmentSign == AdjustmentSign.Positive)
                        {
                            NetAmount = (billedAmount + AdjustedAmount).ToString();
                        }
                        else
                        {
                            NetAmount = (billedAmount - AdjustedAmount).ToString();
                        }
                    }
                    else
                    {
                        NetAmount = (billedAmount.ToString().Replace(GroupSeparator, "")).ToString();
                    }
                }
                //Percentage
                else
                {
                    CalculatePercentageAmount(GroupSeparator, billedAmount);
                }
                if ("0".Equals(NetAmount))
                {
                    NetAmount = InvoiceSummary.CurrencySymbol + " " + NetAmount;
                }
                else
                {
                    NetAmount = InvoiceSummary.CurrencySymbol +
                                CleanNetTotal(RemoveCurrencySymbol(String.Format("{0:c}", Convert.ToDecimal(NetAmount)), false), true);
                }
            }
            catch (Exception ex)
            {
                string message = getMessages(ex);
                ShowErrorMessage(message, Constants.AdjustmentFailed);
            }
        }
Ejemplo n.º 2
0
        public async void SaveAdjustment()
        {
            try
            {
                T360Validator.ValidateAdjustInvoice(AdjustedAmount.ToString(), SelectedReasonId);

                var isOk = await ShowConfirmationMessage(Constants.AdjustConfirmationMsg, Constants.AdjustmentConfirmation);

                if (!isOk)
                {
                    return;
                }

                IsBusy         = true;
                AdjustmentInfo = new InvoiceAdjustment();
                AdjustmentInfo.NarrativeText    = NarrativeText;
                AdjustmentInfo.AdjustmentStyle  = AdjustmentByTo;
                AdjustmentInfo.InvoiceId        = this.InvoiceSummary.InvoiceId.ToString();
                AdjustmentInfo.AdjustmentAmount = AdjustmentSign == AdjustmentSign.Positive
                                                ? Convert.ToDouble(AdjustedAmount).ToString(CultureInfo.InvariantCulture)
                                                : "-" + Convert.ToDouble(AdjustedAmount).ToString(CultureInfo.InvariantCulture);
                AdjustmentInfo.ReasonId       = SelectedReasonId;
                AdjustmentInfo.NetTotal       = CleanNetTotal(NetAmount, true);
                AdjustmentInfo.AdjustmentMode = AdjustmentToggleType;
                AdjustmentInfo.AdjustmentType = AdjustmentType;

                var serializableData = GetAdjustmentSerializationData(AdjustmentInfo);
                var data             = await ServiceInvoker.Instance.InvokeServiceUsingPost <string>(ServiceInvoker.Instance.AppendUrl(ServiceInvoker.AdjustInvoiceService), serializableData, true, false);

                IsBusy = false;
                Messenger.Default.Send <ResetListParameter>(new ResetListParameter()
                {
                });
                Navigator.Navigate(Destination.InvoiceListView, ExistingViewBehavior.Remove, new object[] { });
            }
            catch (T360Exception ex)
            {
                string message = getMessages(ex);
                ShowErrorMessage(message, Constants.AdjustmentFailed);
            }
        }