payout export btn
This commit is contained in:
parent
061b02a1c4
commit
016a049a5c
File diff suppressed because one or more lines are too long
@ -5,8 +5,8 @@ class Env {
|
|||||||
);
|
);
|
||||||
static const String apiUrl = String.fromEnvironment(
|
static const String apiUrl = String.fromEnvironment(
|
||||||
'API_URL',
|
'API_URL',
|
||||||
// defaultValue: 'https://partner.nhanceindia.in/partner_api/api/', /* Live build (enable index.html line 18) */
|
defaultValue: 'https://partner.nhanceindia.in/partner_api/api/', /* Live build (enable index.html line 18) */
|
||||||
defaultValue: 'https://venbait.in/nhance/partner/dev/api/', /* Test build (enable index.html line 19) */
|
// defaultValue: 'https://venbait.in/nhance/partner/dev/api/', /* Test build (enable index.html line 19) */
|
||||||
// defaultValue: 'http://localhost/nhance_partner_be/', /* localhost build (enable index.html line 19) */
|
// defaultValue: 'http://localhost/nhance_partner_be/', /* localhost build (enable index.html line 19) */
|
||||||
);
|
);
|
||||||
// static const String baseUrl = String.fromEnvironment(
|
// static const String baseUrl = String.fromEnvironment(
|
||||||
|
|||||||
@ -2928,6 +2928,33 @@ class ApiService {
|
|||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// GET `policy/commissionPayoutReportExport` — same optional query as [fetchPayoutReportList].
|
||||||
|
Future<void> downloadCommissionPayoutReportExport({
|
||||||
|
String? fromDate,
|
||||||
|
String? toDate,
|
||||||
|
String? agentId,
|
||||||
|
String? payoutRaised,
|
||||||
|
}) async {
|
||||||
|
final query = <String, String>{};
|
||||||
|
if (fromDate != null && fromDate.isNotEmpty) {
|
||||||
|
query['from_date'] = fromDate;
|
||||||
|
}
|
||||||
|
if (toDate != null && toDate.isNotEmpty) {
|
||||||
|
query['to_date'] = toDate;
|
||||||
|
}
|
||||||
|
if (agentId != null && agentId.trim().isNotEmpty) {
|
||||||
|
query['agent_id'] = agentId.trim();
|
||||||
|
}
|
||||||
|
if (payoutRaised != null && payoutRaised.isNotEmpty) {
|
||||||
|
query['payout_raised'] = payoutRaised;
|
||||||
|
}
|
||||||
|
final suffix = query.isEmpty ? '' : '?${Uri(queryParameters: query).query}';
|
||||||
|
await getPdfDownload(
|
||||||
|
'policy/commissionPayoutReportExport$suffix',
|
||||||
|
'commission_payout_report',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
Future<void> generatePolicyExcel(managerId, fromDate, toDate, searchValue,flag,insurer) async {
|
Future<void> generatePolicyExcel(managerId, fromDate, toDate, searchValue,flag,insurer) async {
|
||||||
final url = Uri.parse(
|
final url = Uri.parse(
|
||||||
'${Env.apiUrl}reports/policy-excel?manager_id=$managerId&from_date=${fromDate ?? ''}&to_date=${toDate ?? ''}&search=${searchValue ?? ''}&show_policy_report=${flag ?? ''}&insurer_id=${insurer ?? ''}',
|
'${Env.apiUrl}reports/policy-excel?manager_id=$managerId&from_date=${fromDate ?? ''}&to_date=${toDate ?? ''}&search=${searchValue ?? ''}&show_policy_report=${flag ?? ''}&insurer_id=${insurer ?? ''}',
|
||||||
|
|||||||
@ -12,7 +12,6 @@ import '../../layouts/responsive_layout.dart';
|
|||||||
import '../../providers/manager_provider.dart';
|
import '../../providers/manager_provider.dart';
|
||||||
import '../../providers/userRoleProvider.dart';
|
import '../../providers/userRoleProvider.dart';
|
||||||
import '../../themes/indicators/date_range_picker_field.dart';
|
import '../../themes/indicators/date_range_picker_field.dart';
|
||||||
import '../../themes/indicators/export_btn.dart';
|
|
||||||
import '../../themes/indicators/search_field_theme.dart';
|
import '../../themes/indicators/search_field_theme.dart';
|
||||||
|
|
||||||
/// Payout report — layout and styling aligned with [policylist] policy list screen.
|
/// Payout report — layout and styling aligned with [policylist] policy list screen.
|
||||||
@ -633,7 +632,7 @@ class _PayoutReportScreenState extends ConsumerState<PayoutReportScreen> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// API sometimes returns payout + UTR in one string (e.g. `5000.00UTR20260401164749`).
|
/// API sometimes returns payout + UTR in one string (e.g. `5000.00UTR20260401164749`).
|
||||||
/// Normalizes into separate display values for PAYOUT and UTR NO columns (and export).
|
/// Normalizes into separate display values for PAYOUT and UTR NO columns.
|
||||||
({String payout, String utr}) _payoutAndUtr(Map<String, dynamic> row) {
|
({String payout, String utr}) _payoutAndUtr(Map<String, dynamic> row) {
|
||||||
const utrKeys = ['utr_no', 'utr', 'utr_number'];
|
const utrKeys = ['utr_no', 'utr', 'utr_number'];
|
||||||
const payoutKeys = ['commission_amount', 'payout', 'commission'];
|
const payoutKeys = ['commission_amount', 'payout', 'commission'];
|
||||||
@ -763,70 +762,14 @@ class _PayoutReportScreenState extends ConsumerState<PayoutReportScreen> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _onExport() async {
|
Future<void> _onExport() async {
|
||||||
if (!_hasSearched) {
|
if (!_validateFiltersForSearch()) return;
|
||||||
ToastHelper.showWarningToast(
|
|
||||||
context,
|
|
||||||
'Load report data with Search before exporting.',
|
|
||||||
);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (_filtered.isEmpty) {
|
|
||||||
ToastHelper.showWarningToast(
|
|
||||||
context,
|
|
||||||
'No rows to export. Adjust search or filters, or run Search again.',
|
|
||||||
);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
final stamp = DateFormat('yyyyMMdd_HHmmss').format(DateTime.now());
|
|
||||||
final fileName = 'payout_report_$stamp';
|
|
||||||
|
|
||||||
// [ExcelExporter] reverses the list before writing; pass reversed filtered
|
|
||||||
// rows so the file order matches the on-screen table (top → bottom).
|
|
||||||
final exportInput = _filtered.reversed.map((r) {
|
|
||||||
final m = Map<String, dynamic>.from(r);
|
|
||||||
final pu = _payoutAndUtr(m);
|
|
||||||
m['commission_amount'] = pu.payout;
|
|
||||||
m['utr_no'] = pu.utr;
|
|
||||||
return m;
|
|
||||||
}).toList();
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await ExcelExporter.exportToExcel(
|
await apiService.downloadCommissionPayoutReportExport(
|
||||||
sheetName: 'Payout Report',
|
fromDate: _dateToIso(_startController.text),
|
||||||
fileName: fileName,
|
toDate: _dateToIso(_endController.text),
|
||||||
data: exportInput,
|
agentId: _agentIdForApi(),
|
||||||
displayHeaders: const [
|
payoutRaised: _payoutRaised,
|
||||||
'S No',
|
|
||||||
'Policy No',
|
|
||||||
'Reg No',
|
|
||||||
'Weight',
|
|
||||||
'Fuel Type',
|
|
||||||
'Vehicle Type',
|
|
||||||
'Premium',
|
|
||||||
'Payout',
|
|
||||||
'UTR No',
|
|
||||||
'Paid/Received',
|
|
||||||
],
|
|
||||||
keys: const [
|
|
||||||
'sno',
|
|
||||||
'policy_no',
|
|
||||||
'reg_no',
|
|
||||||
'weight',
|
|
||||||
'fuel_type',
|
|
||||||
'vehicle_type',
|
|
||||||
'premium',
|
|
||||||
'commission_amount',
|
|
||||||
'utr_no',
|
|
||||||
'received_or_not',
|
|
||||||
],
|
|
||||||
valueFormatters: {
|
|
||||||
'received_or_not': (v, _) => _receivedDisplayLabel(v),
|
|
||||||
},
|
|
||||||
);
|
);
|
||||||
if (mounted) {
|
|
||||||
ToastHelper.showSuccessToast(context, 'Export finished');
|
|
||||||
}
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (mounted) {
|
if (mounted) {
|
||||||
ToastHelper.showErrorToast(context, 'Export failed: $e');
|
ToastHelper.showErrorToast(context, 'Export failed: $e');
|
||||||
|
|||||||
22
pubspec.lock
22
pubspec.lock
@ -117,10 +117,10 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: characters
|
name: characters
|
||||||
sha256: faf38497bda5ead2a8c7615f4f7939df04333478bf32e4173fcb06d428b5716b
|
sha256: f71061c654a3380576a52b451dd5532377954cf9dbd272a78fc8479606670803
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.4.1"
|
version: "1.4.0"
|
||||||
charcode:
|
charcode:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -780,26 +780,26 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: matcher
|
name: matcher
|
||||||
sha256: dc0b7dc7651697ea4ff3e69ef44b0407ea32c487a39fff6a4004fa585e901861
|
sha256: dc58c723c3c24bf8d3e2d3ad3f2f9d7bd9cf43ec6feaa64181775e60190153f2
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.12.19"
|
version: "0.12.17"
|
||||||
material_color_utilities:
|
material_color_utilities:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: material_color_utilities
|
name: material_color_utilities
|
||||||
sha256: "9c337007e82b1889149c82ed242ed1cb24a66044e30979c44912381e9be4c48b"
|
sha256: f7142bb1154231d7ea5f96bc7bde4bda2a0945d2806bb11670e30b850d56bdec
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.13.0"
|
version: "0.11.1"
|
||||||
meta:
|
meta:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: meta
|
name: meta
|
||||||
sha256: "23f08335362185a5ea2ad3a4e597f1375e78bce8a040df5c600c8d3552ef2394"
|
sha256: e3641ec5d63ebf0d9b41bd43201a66e3fc79a65db5f61fc181f04cd27aab950c
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.17.0"
|
version: "1.16.0"
|
||||||
mime:
|
mime:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -1297,10 +1297,10 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: test_api
|
name: test_api
|
||||||
sha256: "8161c84903fd860b26bfdefb7963b3f0b68fee7adea0f59ef805ecca346f0c7a"
|
sha256: "522f00f556e73044315fa4585ec3270f1808a4b186c936e612cab0b565ff1e00"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.7.10"
|
version: "0.7.6"
|
||||||
toastification:
|
toastification:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
@ -1502,5 +1502,5 @@ packages:
|
|||||||
source: hosted
|
source: hosted
|
||||||
version: "3.1.3"
|
version: "3.1.3"
|
||||||
sdks:
|
sdks:
|
||||||
dart: ">=3.9.0-0 <4.0.0"
|
dart: ">=3.8.1 <4.0.0"
|
||||||
flutter: ">=3.32.0"
|
flutter: ">=3.32.0"
|
||||||
|
|||||||
@ -15,8 +15,8 @@
|
|||||||
the `--base-href` argument provided to `flutter build`.
|
the `--base-href` argument provided to `flutter build`.
|
||||||
-->
|
-->
|
||||||
<!-- <base href="$FLUTTER_BASE_HREF"> -->
|
<!-- <base href="$FLUTTER_BASE_HREF"> -->
|
||||||
<!-- <base href="/partner/"> --> <!-- Live build: also check env.dart (line 8) -->
|
<base href="/partner/"> Live build: also check env.dart (line 8)
|
||||||
<base href="/nhance/partner/app/">
|
<!-- <base href="/nhance/partner/app/"> -->
|
||||||
<!-- <base href="{Env.baseHref}">-->
|
<!-- <base href="{Env.baseHref}">-->
|
||||||
|
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user