public async Task Load() { try { IsBusy = true; if (_loadFromServer) { InvoicesFilterModel filter = new InvoicesFilterModel { Number = _invoice.Key, Status = new KeyValuePair <InvoicesQueryContextStatus, string>(InvoicesQueryContextStatus.None, null) }; var result = await Api.GetInvoiceList(filter); if (!result.Successful.GetValueOrDefault()) { await Alert.DisplayApiCallError(result.ExceptionMessage, result.ValidationErrors); return; } if ((!result.Data?.Any()) ?? true) { await Alert.ShowMessage("Server did not return an invoice"); return; } var invoice = result.Data.First().CloneToType <InvoiceModel, Invoice>(); Invoice = invoice; } var listResponse = await Api.GetInvoiceLines(_invoice); Invoice.Lines = listResponse.Data; long.TryParse(_invoice.RecId, out var invoiceLongId); InvoiceSettlementsQueryContext settlementContext = new InvoiceSettlementsQueryContext { CustomerInfo = Api.GetCustomerContext(), InvoiceRecId = invoiceLongId }; var settlementResult = await Api.GetInvoiceSettlements(settlementContext); if (!settlementResult.Successful.GetValueOrDefault()) { await Alert.DisplayApiCallError(settlementResult.ExceptionMessage, settlementResult.ValidationErrors); return; } Settlements = new ObservableCollection <InvoiceSettlement>(settlementResult.Data); NoResults = !_settlements.Any(); } catch (Exception e) { await Alert.DisplayError(e); } finally { IsBusy = false; } }
public async Task Load(SettlementsFilterModel filter = null, SortColumnItem sortColumnItem = null) { try { IsBusy = true; if (sortColumnItem != null) { _sortColumnItem = sortColumnItem; } else if (_sortColumnItem == null) { _sortColumnItem = new SortColumnItem(SettlementsSortColumns.Date, null) { Ascending = true }; } filter = filter ?? new SettlementsFilterModel(); if (IsFilterDifferentFromLast(filter)) { var context = new CreditCardPaymentsQueryContext { CustomerInfo = Api.GetCustomerContext(), FromDate = filter.StartDate, ToDate = filter.EndDate, }; var result = await Api.GetPayments(context); if (!result.Successful.GetValueOrDefault()) { await Alert.DisplayApiCallError(result.ExceptionMessage, result.ValidationErrors, nameof(AppResources.ServerError)); return; } InvoiceSettlementsQueryContext settlementContext = new InvoiceSettlementsQueryContext { CustomerInfo = Api.GetCustomerContext(), FromDate = filter.StartDate, ToDate = filter.EndDate }; var settlementResult = await Api.GetInvoiceSettlements(settlementContext); if (!settlementResult.Successful.GetValueOrDefault()) { await Alert.DisplayApiCallError(settlementResult.ExceptionMessage, settlementResult.ValidationErrors); return; } var completed = result.Data.Where(p => p.Settled.GetValueOrDefault()).ToList(); PendingList = new ObservableCollection <InvoicePaymentView>(SortList(_sortColumnItem, result.Data.Except(completed))); Completed = new ObservableCollection <InvoicePaymentView>(SortList(_sortColumnItem, completed)); SettledList = new ObservableCollection <InvoiceSettlement>(settlementResult.Data); _previousFilter = filter; return; } PendingList = new ObservableCollection <InvoicePaymentView>(SortList(_sortColumnItem, _pendingList)); Completed = new ObservableCollection <InvoicePaymentView>(SortList(_sortColumnItem, _completed)); } catch (Exception e) { await Alert.DisplayError(e); } finally { IsBusy = false; } }
public async Task <ApiResponseOfListOfInvoiceSettlement> GetInvoiceSettlements(InvoiceSettlementsQueryContext context) { return(await AXClient.Instance.GetInvoiceSettlementsAsync(context).ConfigureAwait(false)); }