private void AdjustSelectedInvoice(AdjustInputDetails adjustInputDetails) { BaseValidator validator = new BaseValidator(); if (!validator.AdjustInvoice(adjustInputDetails)) { ShowError(validator.ClientException, AdjustLineItemError); return; } MessageBoxResult msgResult; if (userdata.IsMultipleLineItemAdjust) { msgResult = MessageBox.Show("Are you sure you want to adjust this line items?", "Adjustment Confirmation", MessageBoxButton.OKCancel); } else { msgResult = MessageBox.Show("Are you sure you want to adjust these line item?", "Adjustment Confirmation", MessageBoxButton.OKCancel); } if (msgResult == MessageBoxResult.Cancel) { EnableApplicationBar(); return; } string postData = JsonConvert.SerializeObject(adjustInputDetails); try { ServiceInvoker.InvokeServiceUsingPost("api/t360/LineItem/AdjustLineItems", postData, false, delegate(object a, ServiceEventArgs serviceEventArgs) { ServiceResponse result = serviceEventArgs.Result; if (result.Status) { Deployment.Current.Dispatcher.BeginInvoke(() => { EnableApplicationBar(); NavigationService.GoBack(); }); } else { List <Error> resultError = result.ErrorDetails; ShowError(new AppException(resultError), AdjustLineItemError); if (resultError[0] != null && T360ErrorCodes.NotInReviewerQueue == resultError[0].Code) { Deployment.Current.Dispatcher.BeginInvoke(() => { RedirectToInvoiceList(); }); } } }); } catch (Exception ex) { ShowError((AppException)ex); } }
public bool AdjustInvoice(AdjustInputDetails adjustInvoice) { if (string.IsNullOrEmpty(adjustInvoice.AdjustmentAmount) || "-0".Equals(adjustInvoice.AdjustmentAmount) || "0".Equals(adjustInvoice.AdjustmentAmount)) { AddError(T360ErrorCodes.AdjustAmountEmpty); } else if (adjustInvoice.AdjustmentAmount.Trim() == "-") { AddError(T360ErrorCodes.AdjustAmountEmpty); } else if (string.IsNullOrEmpty(adjustInvoice.ReasonId)) { AddError(T360ErrorCodes.ReasonEmpty); } return(NoErrors); }
private AdjustInputDetails GetData() { InvoiceBasicInfo invoiceSummary = (InvoiceBasicInfo)PhoneApplicationService.Current.State[SelectedInvoice]; string adjustmentType; if (IsPercentageSelected) { adjustmentType = "%"; } else { adjustmentType = "$"; } string adjustmentStyle; if (adjustByRadioButton.IsChecked == true) { adjustmentStyle = "Adjust By"; } else { adjustmentStyle = "Adjust To"; } string adjustmentMode = ""; string strNetTotal = lineitemNetAmount; if (strNetTotal.StartsWith("(")) { strNetTotal = strNetTotal.Substring(1, strNetTotal.Length - 2); } if (strNetTotal.StartsWith("$") || strNetTotal.StartsWith("€")) { strNetTotal = strNetTotal.Substring(1, strNetTotal.Length - 1); } ReasonCode reason; AdjustInputDetails adjustInputDetails = new AdjustInputDetails(); string adjustAmount = string.IsNullOrWhiteSpace(adjustTextBox.Text) ? "0" : adjustTextBox.Text; adjustInputDetails.LineItemIds = new List <string>(); if (userdata.IsMultipleLineItemAdjust) { adjustInputDetails.LineItemIds = adjustMultiple.SelectedLineItemIds; adjustInputDetails.IsMultiSelectEnabled = true; } else { LineItemInputDetails selectedLineItem = new LineItemInputDetails((string)PhoneApplicationService.Current.State[SelectedInvoiceId], (string)PhoneApplicationService.Current.State[SelectedLineItemId]); adjustInputDetails.LineItemIds.Add(selectedLineItem.LineItemId); adjustInputDetails.IsMultiSelectEnabled = false; } adjustInputDetails.InvoiceId = invoiceSummary.InvoiceId; adjustInputDetails.AdjustmentAmount = this.IsMinusSelected ? "-" + Convert.ToDouble(adjustAmount.Trim()).ToString(CultureInfo.InvariantCulture) : Convert.ToDouble(adjustAmount.Trim()).ToString(CultureInfo.InvariantCulture); adjustInputDetails.AdjustmentMode = adjustmentMode; adjustInputDetails.AdjustmentStyle = adjustmentStyle; adjustInputDetails.AdjustmentType = adjustmentType; adjustInputDetails.NetTotal = strNetTotal; adjustInputDetails.NarrativeText = narrativeTextBox.Text.Trim(); if (reasonListPicker.Items.Count == 0) { adjustInputDetails.ReasonId = string.Empty; } else { reason = reasonListPicker.SelectedItem as ReasonCode; adjustInputDetails.ReasonId = reason.Id.ToString(); } return(adjustInputDetails); }
private AdjustInputDetails GetData() { InvoiceBasicInfo invoiceSummary = (InvoiceBasicInfo)PhoneApplicationService.Current.State[SelectedInvoice]; string adjustmentType; if (IsPercentageSelected) { adjustmentType = "%"; } else { adjustmentType = "$"; } string adjustmentStyle; if (adjustByRadioButton.IsChecked == true) { adjustmentStyle = "Adjust By"; } else { adjustmentStyle = "Adjust To"; } string adjustmentMode; if (IsFeeSelected) { adjustmentMode = "Fees"; } else { adjustmentMode = "Expense"; } string strNetTotal = IsFeeSelected ? invoiceSummary.BilledFees : invoiceSummary.BilledExpenses; if (strNetTotal.StartsWith("(")) { strNetTotal = strNetTotal.Substring(1, strNetTotal.Length - 2); } if (strNetTotal.StartsWith("$") || strNetTotal.StartsWith("€")) { strNetTotal = strNetTotal.Substring(1, strNetTotal.Length - 1); } ReasonCode reason; AdjustInputDetails adjustInputDetails; string adjustAmount = string.IsNullOrWhiteSpace(adjustTextBox.Text) ? "0" : adjustTextBox.Text; if (reasonListPicker.Items.Count == 0) { adjustInputDetails = new AdjustInputDetails() { InvoiceId = invoiceSummary.InvoiceId, ReasonId = string.Empty, AdjustmentAmount = this.IsMinusSelected ? "-" + Convert.ToDouble(adjustAmount.Trim()).ToString(CultureInfo.InvariantCulture) : Convert.ToDouble(adjustAmount.Trim()).ToString(CultureInfo.InvariantCulture), AdjustmentMode = adjustmentMode, AdjustmentStyle = adjustmentStyle, AdjustmentType = adjustmentType, NetTotal = strNetTotal, NarrativeText = narrativeTextBox.Text.Trim() }; } else { reason = reasonListPicker.SelectedItem as ReasonCode; adjustInputDetails = new AdjustInputDetails() { InvoiceId = invoiceSummary.InvoiceId, ReasonId = reason.Id.ToString(), AdjustmentAmount = this.IsMinusSelected ? "-" + Convert.ToDouble(adjustAmount.Trim()).ToString(CultureInfo.InvariantCulture) : Convert.ToDouble(adjustAmount.Trim()).ToString(CultureInfo.InvariantCulture), AdjustmentMode = adjustmentMode, AdjustmentStyle = adjustmentStyle, AdjustmentType = adjustmentType, NetTotal = strNetTotal, NarrativeText = narrativeTextBox.Text.Trim() }; } return(adjustInputDetails); }
private AdjustInputDetails GetData() { string adjustmentType; if (IsPercentageSelected) { adjustmentType = "%"; } else { adjustmentType = "$"; } string adjustmentStyle; if (adjustByRadioButton.IsChecked == true) { adjustmentStyle = "Adjust By"; } else { adjustmentStyle = "Adjust To"; } string adjustmentMode; string strNetTotal; string InvoiceId; if (Source == Model.Base.Source.LINE_ITEM_MULTI_ADJUST_CONFIRMATION || Source == Model.Base.Source.LINE_ITEM_SINGLE_ADJUST) { strNetTotal = LineItemAdjustDetails.NetAmount; adjustmentMode = string.Empty; InvoiceId = LineItemAdjustDetails.InvoiceDetails.InvoiceId.ToString(); } else { if (IsFeeSelected) { adjustmentMode = "Fees"; } else { adjustmentMode = "Expense"; } strNetTotal = IsFeeSelected ? InvoiceDetails.BilledFees : InvoiceDetails.BilledExpenses; InvoiceId = InvoiceDetails.InvoiceId.ToString(); } if (strNetTotal.StartsWith("(")) { strNetTotal = strNetTotal.Substring(1, strNetTotal.Length - 2); } if (strNetTotal.StartsWith("$") || strNetTotal.StartsWith("€")) { strNetTotal = strNetTotal.Substring(1, strNetTotal.Length - 1); } ReasonCode reason; string adjustAmount = string.IsNullOrWhiteSpace(adjustTextBox.Text) ? "0" : adjustTextBox.Text; AdjustInputDetails adjustInputDetails = new AdjustInputDetails() { InvoiceId = InvoiceId, AdjustmentAmount = this.IsMinusSelected ? "-" + Convert.ToDouble(adjustAmount.Trim()).ToString(CultureInfo.InvariantCulture) : Convert.ToDouble(adjustAmount.Trim()).ToString(CultureInfo.InvariantCulture), AdjustmentMode = adjustmentMode, AdjustmentStyle = adjustmentStyle, AdjustmentType = adjustmentType, NetTotal = strNetTotal, NarrativeText = narrativeTextBox.Text.Trim() }; adjustInputDetails.LineItemIds = Source == Model.Base.Source.LINE_ITEM_MULTI_ADJUST_CONFIRMATION || Source == Model.Base.Source.LINE_ITEM_SINGLE_ADJUST ? LineItemAdjustDetails.SelectedLineItemIds : null; if (reasonListPicker.Items.Count == 0) { adjustInputDetails.ReasonId = string.Empty; } else { reason = reasonListPicker.SelectedItem as ReasonCode; adjustInputDetails.ReasonId = reason.Id.ToString(); } return(adjustInputDetails); }