read method

Future<void> read()

Implementation

Future<void> read() async {
  state.loading();
  await UServices.hotel.readDormBedInvoice(
    p: UDormBedInvoiceReadParams(
      pageNumber: pageNumber.value,
      pageSize: pageSize,
      contractId: contract?.id,
      isPaid: statusFilter == UAdminInvoiceStatusFilter.paid ? true : (statusFilter == UAdminInvoiceStatusFilter.all ? null : false),
      isOverdue: statusFilter == UAdminInvoiceStatusFilter.overdue ? true : null,
      minDueDate: minDueDate,
      maxDueDate: maxDueDate,
      minDebtAmount: minDebtController.isNullOrEmpty() ? null : minDebtController.numDouble(),
      maxDebtAmount: maxDebtController.isNullOrEmpty() ? null : maxDebtController.numDouble(),
      selectorArgs: const InvoiceSelectorArgs(contract: ContractSelectorArgs(user: UserSelectorArgs())),
    ),
    onOk: (UResponse<List<UDormBedInvoiceResponse>> r) {
      list = r.result ?? <UDormBedInvoiceResponse>[];
      setTotalPages(r.totalCount);
      setListState(isEmpty: list.isEmpty);
    },
    onError: (UResponse<dynamic> e) => setError(e.message),
    onException: (String e) => setError(),
  );
  if (contract != null) await _refreshSummary();
}