fixed pegination and for rejected status no data displayed
This commit is contained in:
parent
034de5a601
commit
fe950c5b07
@ -89,21 +89,26 @@ class PaymentRequestController extends GetxController {
|
|||||||
// First page, replace the list
|
// First page, replace the list
|
||||||
paymentRequests.assignAll(response.data.data);
|
paymentRequests.assignAll(response.data.data);
|
||||||
} else {
|
} else {
|
||||||
// Insert new data at the top for latest first
|
// Append next page items at the end
|
||||||
paymentRequests.insertAll(0, response.data.data);
|
paymentRequests.addAll(response.data.data);
|
||||||
|
}
|
||||||
|
|
||||||
|
// If returned data is less than page size, no more data
|
||||||
|
if (response.data.data.length < _pageSize) {
|
||||||
|
_hasMoreData = false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (_pageNumber == 1) {
|
if (_pageNumber == 1) {
|
||||||
errorMessage.value = 'No payment requests found.';
|
errorMessage.value = 'No payment requests found.';
|
||||||
} else {
|
|
||||||
_hasMoreData = false;
|
|
||||||
}
|
}
|
||||||
|
_hasMoreData = false;
|
||||||
}
|
}
|
||||||
} catch (e, stack) {
|
} catch (e, stack) {
|
||||||
errorMessage.value = 'Failed to fetch payment requests.';
|
errorMessage.value = 'Failed to fetch payment requests.';
|
||||||
logSafe("Exception in _fetchPaymentRequestsFromApi: $e",
|
logSafe("Exception in _fetchPaymentRequestsFromApi: $e",
|
||||||
level: LogLevel.error);
|
level: LogLevel.error);
|
||||||
logSafe("StackTrace: $stack", level: LogLevel.debug);
|
logSafe("StackTrace: $stack", level: LogLevel.debug);
|
||||||
|
_hasMoreData = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -113,29 +113,37 @@ class PaymentRequestData {
|
|||||||
: null,
|
: null,
|
||||||
dueDate: DateTime.parse(json['dueDate']),
|
dueDate: DateTime.parse(json['dueDate']),
|
||||||
project: Project.fromJson(json['project']),
|
project: Project.fromJson(json['project']),
|
||||||
recurringPayment: json['recurringPayment'],
|
recurringPayment: json['recurringPayment'] != null
|
||||||
|
? RecurringPayment.fromJson(json['recurringPayment'])
|
||||||
|
: null,
|
||||||
expenseCategory: ExpenseCategory.fromJson(json['expenseCategory']),
|
expenseCategory: ExpenseCategory.fromJson(json['expenseCategory']),
|
||||||
expenseStatus: ExpenseStatus.fromJson(json['expenseStatus']),
|
expenseStatus: ExpenseStatus.fromJson(json['expenseStatus']),
|
||||||
paidTransactionId: json['paidTransactionId'],
|
paidTransactionId: json['paidTransactionId'],
|
||||||
paidAt: json['paidAt'] != null ? DateTime.parse(json['paidAt']) : null,
|
paidAt: json['paidAt'] != null ? DateTime.parse(json['paidAt']) : null,
|
||||||
paidBy: json['paidBy'] != null ? User.fromJson(json['paidBy']) : null,
|
paidBy: json['paidBy'] != null ? User.fromJson(json['paidBy']) : null,
|
||||||
isAdvancePayment: json['isAdvancePayment'],
|
isAdvancePayment: json['isAdvancePayment'] ?? false,
|
||||||
createdAt: DateTime.parse(json['createdAt']),
|
createdAt: DateTime.parse(json['createdAt']),
|
||||||
createdBy: User.fromJson(json['createdBy']),
|
createdBy: User.fromJson(json['createdBy']),
|
||||||
updatedAt: DateTime.parse(json['updatedAt']),
|
updatedAt: DateTime.parse(json['updatedAt']),
|
||||||
updatedBy:
|
updatedBy:
|
||||||
json['updatedBy'] != null ? User.fromJson(json['updatedBy']) : null,
|
json['updatedBy'] != null ? User.fromJson(json['updatedBy']) : null,
|
||||||
nextStatus: (json['nextStatus'] as List<dynamic>)
|
nextStatus: (json['nextStatus'] != null
|
||||||
|
? (json['nextStatus'] as List<dynamic>)
|
||||||
.map((e) => NextStatus.fromJson(e))
|
.map((e) => NextStatus.fromJson(e))
|
||||||
.toList(),
|
.toList()
|
||||||
updateLogs: (json['updateLogs'] as List<dynamic>)
|
: <NextStatus>[]),
|
||||||
|
updateLogs: (json['updateLogs'] != null
|
||||||
|
? (json['updateLogs'] as List<dynamic>)
|
||||||
.map((e) => UpdateLog.fromJson(e))
|
.map((e) => UpdateLog.fromJson(e))
|
||||||
.toList(),
|
.toList()
|
||||||
attachments: (json['attachments'] as List<dynamic>)
|
: <UpdateLog>[]),
|
||||||
|
attachments: (json['attachments'] != null
|
||||||
|
? (json['attachments'] as List<dynamic>)
|
||||||
.map((e) => Attachment.fromJson(e))
|
.map((e) => Attachment.fromJson(e))
|
||||||
.toList(),
|
.toList()
|
||||||
isActive: json['isActive'],
|
: <Attachment>[]),
|
||||||
isExpenseCreated: json['isExpenseCreated'],
|
isActive: json['isActive'] ?? true,
|
||||||
|
isExpenseCreated: json['isExpenseCreated'] ?? false,
|
||||||
);
|
);
|
||||||
|
|
||||||
Map<String, dynamic> toJson() => {
|
Map<String, dynamic> toJson() => {
|
||||||
@ -169,6 +177,35 @@ class PaymentRequestData {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class RecurringPayment {
|
||||||
|
String id;
|
||||||
|
String recurringPaymentUID;
|
||||||
|
double amount;
|
||||||
|
bool isVariable;
|
||||||
|
|
||||||
|
RecurringPayment({
|
||||||
|
required this.id,
|
||||||
|
required this.recurringPaymentUID,
|
||||||
|
required this.amount,
|
||||||
|
required this.isVariable,
|
||||||
|
});
|
||||||
|
|
||||||
|
factory RecurringPayment.fromJson(Map<String, dynamic> json) =>
|
||||||
|
RecurringPayment(
|
||||||
|
id: json['id'],
|
||||||
|
recurringPaymentUID: json['recurringPaymentUID'],
|
||||||
|
amount: (json['amount'] as num).toDouble(),
|
||||||
|
isVariable: json['isVariable'],
|
||||||
|
);
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() => {
|
||||||
|
'id': id,
|
||||||
|
'recurringPaymentUID': recurringPaymentUID,
|
||||||
|
'amount': amount,
|
||||||
|
'isVariable': isVariable,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
class Currency {
|
class Currency {
|
||||||
String id;
|
String id;
|
||||||
String currencyCode;
|
String currencyCode;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user