FIX_view api
This commit is contained in:
parent
f1a57d1d8c
commit
b3884f32c4
File diff suppressed because one or more lines are too long
@ -2153,6 +2153,33 @@ class ApiService {
|
|||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<Map<String, dynamic>> getViewInvoiceList(dynamic data) async {
|
||||||
|
if (_token == null) {
|
||||||
|
await _initializeToken();
|
||||||
|
}
|
||||||
|
|
||||||
|
final Map<String, dynamic> map =
|
||||||
|
data is Map ? Map<String, dynamic>.from(data) : <String, dynamic>{};
|
||||||
|
final invoiceId = map['invoice_id'];
|
||||||
|
final managerId = map['manager_id'];
|
||||||
|
|
||||||
|
final queryParameters = <String, String>{
|
||||||
|
if (invoiceId != null) 'invoice_id': invoiceId.toString(),
|
||||||
|
if (managerId != null) 'manager_id': managerId.toString(),
|
||||||
|
};
|
||||||
|
|
||||||
|
final url = Uri.parse('${Env.apiUrl}invoice/view').replace(
|
||||||
|
queryParameters: queryParameters,
|
||||||
|
);
|
||||||
|
|
||||||
|
final headers = {
|
||||||
|
'Authorization': 'Bearer $_token',
|
||||||
|
'app-signature': Env.App_Signature,
|
||||||
|
};
|
||||||
|
|
||||||
|
return _makeGetRequest(url, headers);
|
||||||
|
}
|
||||||
|
|
||||||
Future<Map<String, dynamic>> getCreateOrUpdate(data) async {
|
Future<Map<String, dynamic>> getCreateOrUpdate(data) async {
|
||||||
final url = Uri.parse('${Env.apiUrl}invoice/create-or-update');
|
final url = Uri.parse('${Env.apiUrl}invoice/create-or-update');
|
||||||
// final url = Uri.parse('http://localhost/nhance_partner_be/invoice/create-or-update');
|
// final url = Uri.parse('http://localhost/nhance_partner_be/invoice/create-or-update');
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
import 'package:flutter/gestures.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
import 'package:go_router/go_router.dart';
|
import 'package:go_router/go_router.dart';
|
||||||
@ -76,15 +77,43 @@ class _PayOutDetailsViewState extends ConsumerState<PayOutDetailsView> {
|
|||||||
'invoice_id': invoiceId,
|
'invoice_id': invoiceId,
|
||||||
'manager_id': managerId,
|
'manager_id': managerId,
|
||||||
};
|
};
|
||||||
final response = await apiService.getCommissionRateList(jsondata);
|
final response = await apiService.getViewInvoiceList(jsondata);
|
||||||
if (response['status'] == 'success') {
|
if (response['status'] == 'success') {
|
||||||
final totPolicy = (response['total_policies'] ?? 0).toString();
|
final payload = response['data'];
|
||||||
final totalCommiss = response['total_commission'];
|
List<Map<String, dynamic>> items = [];
|
||||||
|
Map<String, dynamic>? invoiceMap;
|
||||||
|
|
||||||
|
if (payload is Map) {
|
||||||
|
final m = Map<String, dynamic>.from(payload);
|
||||||
|
invoiceMap = m['invoice'] is Map
|
||||||
|
? Map<String, dynamic>.from(m['invoice'] as Map)
|
||||||
|
: null;
|
||||||
|
final rawItems = m['items'];
|
||||||
|
if (rawItems is List) {
|
||||||
|
items = rawItems
|
||||||
|
.map((e) => Map<String, dynamic>.from(e as Map))
|
||||||
|
.toList();
|
||||||
|
}
|
||||||
|
} else if (payload is List) {
|
||||||
|
items = List<Map<String, dynamic>>.from(payload);
|
||||||
|
}
|
||||||
|
|
||||||
|
num commissionSum = 0;
|
||||||
|
for (final row in items) {
|
||||||
|
commissionSum +=
|
||||||
|
num.tryParse(row['commission_amount']?.toString() ?? '0') ?? 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
final totPolicy = (invoiceMap?['total_policies'] ?? items.length)
|
||||||
|
.toString();
|
||||||
|
final totalCommiss =
|
||||||
|
invoiceMap?['total_commission'] ?? commissionSum;
|
||||||
|
|
||||||
setState(() {
|
setState(() {
|
||||||
totalPolicies = totPolicy;
|
totalPolicies = totPolicy;
|
||||||
totalCommission = totalCommiss;
|
totalCommission = totalCommiss;
|
||||||
masterPolicies = List<Map<String, dynamic>>.from(response['data'] ?? []);
|
masterPolicies = items;
|
||||||
filteredPolicies = List<Map<String, dynamic>>.from(response['data'] ?? []);
|
filteredPolicies = List<Map<String, dynamic>>.from(items);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
setState(() {
|
setState(() {
|
||||||
@ -200,48 +229,39 @@ class _PayOutDetailsViewState extends ConsumerState<PayOutDetailsView> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _policyTableBody() {
|
Widget _policyRow(Map<String, dynamic> p) {
|
||||||
return SizedBox(
|
return Container(
|
||||||
height: MediaQuery.of(context).size.height * 0.65,
|
height: 38,
|
||||||
child: ListView.builder(
|
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||||
itemCount: filteredPolicies.length,
|
decoration: const BoxDecoration(
|
||||||
itemBuilder: (context, index) {
|
color: Colors.white,
|
||||||
final p = filteredPolicies[index];
|
border: Border(bottom: BorderSide(color: Color(0xFFf9fafb))),
|
||||||
return Container(
|
),
|
||||||
height: 38,
|
child: Row(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
children: [
|
||||||
decoration: const BoxDecoration(
|
_cell(p['policy_no']?.toString(), colPolicy),
|
||||||
color: Colors.white,
|
_cell(_formatDate(p['issued_date']?.toString()), colDate),
|
||||||
border: Border(bottom: BorderSide(color: Color(0xFFf9fafb))),
|
_cell(
|
||||||
|
(p['agent_code'] != null && p['agent_name'] != null)
|
||||||
|
? '${p['agent_code']} - ${p['agent_name']}'
|
||||||
|
: (p['agent_name'] ?? '-').toString(),
|
||||||
|
colAgent,
|
||||||
|
),
|
||||||
|
_cell(p['customer_name']?.toString(), colCustomer),
|
||||||
|
_cell('₹${p['premium_amount']}', colPremium),
|
||||||
|
SizedBox(
|
||||||
|
width: colCommission,
|
||||||
|
child: Text(
|
||||||
|
'₹${_displayText(p['commission_amount'])}',
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
style: const TextStyle(
|
||||||
|
fontSize: 11,
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
color: Color(0xFF009B77),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
child: Row(
|
),
|
||||||
children: [
|
],
|
||||||
_cell(p['policy_no']?.toString(), colPolicy),
|
|
||||||
_cell(_formatDate(p['issued_date']?.toString()), colDate),
|
|
||||||
_cell(
|
|
||||||
(p['agent_code'] != null && p['agent_name'] != null)
|
|
||||||
? '${p['agent_code']} - ${p['agent_name']}'
|
|
||||||
: (p['agent_name'] ?? '-').toString(),
|
|
||||||
colAgent,
|
|
||||||
),
|
|
||||||
_cell(p['customer_name']?.toString(), colCustomer),
|
|
||||||
_cell('₹${p['premium_amount']}', colPremium),
|
|
||||||
SizedBox(
|
|
||||||
width: colCommission,
|
|
||||||
child: Text(
|
|
||||||
'₹${_displayText(p['commission_amount'])}',
|
|
||||||
overflow: TextOverflow.ellipsis,
|
|
||||||
style: const TextStyle(
|
|
||||||
fontSize: 11,
|
|
||||||
fontWeight: FontWeight.w600,
|
|
||||||
color: Color(0xFF009B77),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -339,21 +359,65 @@ class _PayOutDetailsViewState extends ConsumerState<PayOutDetailsView> {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Card(
|
Expanded(
|
||||||
color: Colors.white,
|
child: Card(
|
||||||
shape: RoundedRectangleBorder(
|
color: Colors.white,
|
||||||
borderRadius: BorderRadius.circular(12),
|
clipBehavior: Clip.antiAlias,
|
||||||
),
|
shape: RoundedRectangleBorder(
|
||||||
elevation: 0,
|
borderRadius: BorderRadius.circular(12),
|
||||||
child: SingleChildScrollView(
|
),
|
||||||
scrollDirection: Axis.horizontal,
|
elevation: 0,
|
||||||
child: SizedBox(
|
child: ScrollConfiguration(
|
||||||
width: _tableMinWidth,
|
behavior: const MaterialScrollBehavior().copyWith(
|
||||||
child: Column(
|
dragDevices: {
|
||||||
children: [
|
PointerDeviceKind.mouse,
|
||||||
_policyTableHeader(),
|
PointerDeviceKind.touch,
|
||||||
_policyTableBody(),
|
PointerDeviceKind.trackpad,
|
||||||
],
|
},
|
||||||
|
),
|
||||||
|
child: LayoutBuilder(
|
||||||
|
builder: (context, constraints) {
|
||||||
|
// Same pattern as enquiry list: nested axis scroll views
|
||||||
|
// avoids broken vertical gestures on web/desktop.
|
||||||
|
return SingleChildScrollView(
|
||||||
|
scrollDirection: Axis.horizontal,
|
||||||
|
primary: false,
|
||||||
|
child: SingleChildScrollView(
|
||||||
|
scrollDirection: Axis.vertical,
|
||||||
|
primary: false,
|
||||||
|
child: ConstrainedBox(
|
||||||
|
constraints: BoxConstraints(
|
||||||
|
minWidth: _tableMinWidth,
|
||||||
|
minHeight: constraints.maxHeight.isFinite
|
||||||
|
? constraints.maxHeight
|
||||||
|
: 0,
|
||||||
|
),
|
||||||
|
child: Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
_policyTableHeader(),
|
||||||
|
if (filteredPolicies.isEmpty)
|
||||||
|
const Padding(
|
||||||
|
padding: EdgeInsets.all(24),
|
||||||
|
child: Center(
|
||||||
|
child: Text(
|
||||||
|
'No policies in this payout',
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 12,
|
||||||
|
color: Colors.blueGrey,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
else
|
||||||
|
...filteredPolicies.map(_policyRow),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@ -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