private void ResetFormView_Tapped(object sender, EventArgs e) { if (SettingsService.Instance.ApplicationMode == ApplicationModeEnum.Pipeline) { Filter = new SettlementsFilterModel { StartDate = null, EndDate = null }; } else { Filter = new SettlementsFilterModel(); } }
private bool IsFilterDifferentFromLast(SettlementsFilterModel currentFilter) { if (_previousFilter == null) { return(true); } if (_previousFilter.EndDate != currentFilter.EndDate) { return(true); } if (_previousFilter.StartDate != currentFilter.StartDate) { return(true); } return(false); }
public SettlementsFilterView() { InitializeComponent(); Filter = new SettlementsFilterModel(); SortColumns = new ObservableCollection <SortColumnItem> { new SortColumnItem(SettlementsSortColumns.AccountNumber, nameof(AppResources.AccountNumber).Translate()), new SortColumnItem(SettlementsSortColumns.Account, nameof(AppResources.Account).Translate()), new SortColumnItem(SettlementsSortColumns.PaidBy, nameof(AppResources.PaidBy).Translate()), new SortColumnItem(SettlementsSortColumns.Date, nameof(AppResources.Date).Translate()), new SortColumnItem(SettlementsSortColumns.MoneyOnAccount, nameof(AppResources.MoneyOnAccount).Translate()), new SortColumnItem(SettlementsSortColumns.Note, nameof(AppResources.Note).Translate()), }; Children[0].BindingContext = this; Filter.SelectedSortColumn = _sortColumns[3]; }
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; } }
private async Task OnSearch(SettlementsFilterModel filter) { await Load(filter); ShowFilter = false; }