Refund Module Completed
parent
64da8f1804
commit
897bd30879
@ -0,0 +1,6 @@
|
||||
<svg width="13" height="13" viewBox="0 0 13 13" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M6.27093 0C5.84568 0 5.45483 0.1098 5.02235 0.298705C4.60293 0.481904 4.11656 0.75258 3.50481 1.09303L1.08855 2.43771C0.752306 2.62483 0.470904 2.85985 0.277588 3.17675C0.0833075 3.49522 9.35953e-05 3.8601 9.35953e-05 4.26946L4.69e-05 4.30801C-0.00022378 4.45702 -0.000498354 4.60817 0.0354227 4.74338C0.125815 5.08363 0.341219 5.30294 0.605033 5.42048C0.842686 5.52636 1.10087 5.54167 1.29468 5.54167L11.2472 5.54167C11.441 5.54167 11.6992 5.52636 11.9368 5.42048C12.2006 5.30294 12.416 5.08363 12.5064 4.74338C12.5424 4.60817 12.5421 4.45702 12.5418 4.308L12.5418 4.26946C12.5418 3.8601 12.4585 3.49522 12.2643 3.17675C12.071 2.85985 11.7895 2.62483 11.4533 2.43771L9.03706 1.09304C8.4253 0.752584 7.93892 0.481906 7.51951 0.298705C7.08703 0.1098 6.69617 0 6.27093 0ZM6.26856 2.77083C5.94639 2.77083 5.68522 3.032 5.68522 3.35417C5.68522 3.67633 5.94639 3.9375 6.26856 3.9375H6.27379C6.59596 3.9375 6.85713 3.67633 6.85713 3.35417C6.85713 3.032 6.59596 2.77083 6.27379 2.77083H6.26856Z" fill="#2E3039"/>
|
||||
<path d="M0 11.9583C0 10.9918 0.979377 10.2083 2.1875 10.2083L10.3542 10.2083C11.5623 10.2083 12.5417 10.9918 12.5417 11.9583C12.5417 12.2805 12.2152 12.5417 11.8125 12.5417L0.729166 12.5417C0.326458 12.5417 0 12.2805 0 11.9583Z" fill="#2E3039"/>
|
||||
<path d="M4.14174 9.47917L2.18748 9.47917C1.94632 9.47917 1.71199 9.50844 1.48786 9.56362C1.33338 9.60165 1.25615 9.62066 1.21144 9.58563C1.16674 9.5506 1.16674 9.4759 1.16674 9.3265L1.16674 6.39686C1.16674 6.38875 1.16674 6.3847 1.16687 6.3819C1.16982 6.32046 1.21636 6.27392 1.27781 6.27097C1.2806 6.27083 1.28532 6.27083 1.29475 6.27083L4.14174 6.27083C4.25173 6.27083 4.30673 6.27083 4.3409 6.305C4.37507 6.33918 4.37507 6.39417 4.37507 6.50417L4.37507 9.24583C4.37507 9.35583 4.37507 9.41083 4.3409 9.445C4.30673 9.47917 4.25173 9.47917 4.14174 9.47917Z" fill="#2E3039"/>
|
||||
<path d="M11.0539 9.56366C10.8298 9.50845 10.5954 9.47917 10.3541 9.47917H8.40007C8.29008 9.47917 8.23508 9.47917 8.20091 9.445C8.16674 9.41083 8.16674 9.35583 8.16674 9.24583V6.50417C8.16674 6.39417 8.16674 6.33918 8.20091 6.305C8.23508 6.27083 8.29008 6.27083 8.40007 6.27083L11.2473 6.27083C11.2565 6.27083 11.2611 6.27083 11.2639 6.27096C11.3254 6.27385 11.3721 6.32048 11.3749 6.38204L11.3751 6.38713L11.3751 6.39668V9.32654C11.3751 9.47595 11.3751 9.55066 11.3304 9.58569C11.2857 9.62072 11.2084 9.6017 11.0539 9.56366Z" fill="#2E3039"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 2.5 KiB |
|
Before Width: | Height: | Size: 2.9 KiB After Width: | Height: | Size: 2.9 KiB |
@ -0,0 +1,5 @@
|
||||
<svg width="14" height="14" viewBox="0 0 14 14" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<rect width="14" height="14" rx="3" fill="#ED1C2B"/>
|
||||
<path d="M2.54806 11.4479C2.54806 11.4479 2.98492 11.4447 3.29241 11.4447L5.6242 11.456C5.90252 11.456 6.13431 11.1644 6.14737 10.7432L6.15002 8.82325C6.15002 8.41389 6.3357 8.09359 6.6236 8.0753L7.33877 8.06967C7.62708 8.08716 7.825 8.41147 7.825 8.81822L7.82316 10.7484C7.83581 11.1695 8.03006 11.4443 8.30981 11.4443L11.4488 11.4527L11.4545 9.08021C11.4545 8.67205 11.2554 8.35497 10.9648 8.33628L9.70382 8.33004C9.4249 8.33004 9.20555 8.03991 9.19372 7.61828L9.18882 6.97649C9.20269 6.55546 9.42326 6.26593 9.7028 6.26593L10.9707 6.26955C11.2588 6.25126 11.4465 5.91608 11.4465 5.50853L11.4496 2.54687C11.346 2.71407 11.2043 2.85519 11.0357 2.95905C10.8671 3.06291 10.6763 3.12666 10.4784 3.14524L8.34613 3.14343C8.06843 3.14343 7.83602 3.44181 7.82296 3.86283L7.82296 5.76468C7.8099 6.1849 7.59178 6.48228 7.31285 6.48228L6.66767 6.47745C6.38793 6.47745 6.1643 6.18973 6.15165 5.77072L6.15328 3.84795C6.14063 3.42673 5.91904 3.14423 5.63991 3.14423L2.54562 3.14564L2.54562 5.51094C2.54562 5.9195 2.73925 6.24663 3.02817 6.26553L4.29609 6.2603C4.58277 6.2788 4.7858 6.61578 4.7858 7.02213L4.78192 7.56962C4.78192 7.97798 4.58604 8.30471 4.29793 8.32321L3.02797 8.32019C2.73905 8.3403 2.54541 8.662 2.54541 9.07036L2.54806 11.4479Z" fill="white"/>
|
||||
<path d="M2.54806 11.4479C2.54806 11.4479 2.98492 11.4447 3.29241 11.4447L5.6242 11.456C5.90252 11.456 6.13431 11.1644 6.14737 10.7432L6.15002 8.82325C6.15002 8.41389 6.3357 8.09359 6.6236 8.0753L7.33877 8.06967C7.62708 8.08716 7.825 8.41147 7.825 8.81822L7.82316 10.7484C7.83581 11.1695 8.03006 11.4443 8.30981 11.4443L11.4488 11.4527L11.4545 9.08021C11.4545 8.67205 11.2554 8.35497 10.9648 8.33628L9.70382 8.33004C9.4249 8.33004 9.20555 8.03991 9.19372 7.61828L9.18882 6.97649C9.20269 6.55546 9.42326 6.26593 9.7028 6.26593L10.9707 6.26955C11.2588 6.25126 11.4465 5.91608 11.4465 5.50853L11.4496 2.54687C11.346 2.71407 11.2043 2.85519 11.0357 2.95905C10.8671 3.06291 10.6763 3.12666 10.4784 3.14524L8.34613 3.14343C8.06843 3.14343 7.83602 3.44181 7.82296 3.86283L7.82296 5.76468C7.8099 6.1849 7.59178 6.48228 7.31285 6.48228L6.66767 6.47745C6.38793 6.47745 6.1643 6.18973 6.15165 5.77072L6.15328 3.84795C6.14063 3.42673 5.91904 3.14423 5.63991 3.14423L2.54562 3.14564L2.54562 5.51094C2.54562 5.9195 2.73925 6.24663 3.02817 6.26553L4.29609 6.2603C4.58277 6.2788 4.7858 6.61578 4.7858 7.02213L4.78192 7.56962C4.78192 7.97798 4.58604 8.30471 4.29793 8.32321L3.02797 8.32019C2.73905 8.3403 2.54541 8.662 2.54541 9.07036L2.54806 11.4479Z" fill="white"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 2.6 KiB |
@ -0,0 +1,23 @@
|
||||
class IsRefundableInvoiceObject {
|
||||
final String? errorCode;
|
||||
final bool? isRefundable;
|
||||
final String? message;
|
||||
final int? statusCode;
|
||||
|
||||
IsRefundableInvoiceObject({
|
||||
this.errorCode,
|
||||
this.isRefundable,
|
||||
this.message,
|
||||
this.statusCode,
|
||||
});
|
||||
|
||||
factory IsRefundableInvoiceObject.fromJson(Map<String, dynamic> json) {
|
||||
return IsRefundableInvoiceObject(
|
||||
errorCode: json['ErrorCode'] as String?,
|
||||
isRefundable: json['IsRefundable'] as bool?,
|
||||
message: json['Message'] as String?,
|
||||
statusCode: json['StatusCode'] as int?,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,283 @@
|
||||
import 'package:easy_localization/easy_localization.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:hmg_patient_app_new/core/app_assets.dart';
|
||||
import 'package:hmg_patient_app_new/core/utils/date_util.dart';
|
||||
import 'package:hmg_patient_app_new/core/utils/size_utils.dart';
|
||||
import 'package:hmg_patient_app_new/core/utils/utils.dart';
|
||||
import 'package:hmg_patient_app_new/extensions/string_extensions.dart';
|
||||
import 'package:hmg_patient_app_new/extensions/widget_extensions.dart';
|
||||
import 'package:hmg_patient_app_new/features/refund_request/models/resp_models/refund_request_list_response_model.dart';
|
||||
import 'package:hmg_patient_app_new/generated/locale_keys.g.dart';
|
||||
import 'package:hmg_patient_app_new/theme/colors.dart';
|
||||
import 'package:hmg_patient_app_new/widgets/appbar/collapsing_list_view.dart';
|
||||
import 'package:hmg_patient_app_new/widgets/chip/app_custom_chip_widget.dart';
|
||||
|
||||
class RefundRequestDetailScreen extends StatelessWidget {
|
||||
final RefundInvoiceModel invoice;
|
||||
|
||||
const RefundRequestDetailScreen({super.key, required this.invoice});
|
||||
|
||||
String _formatDate(String? rawDate) {
|
||||
if (rawDate == null || rawDate.isEmpty) return '';
|
||||
try {
|
||||
final date = DateUtil.convertStringToDate(rawDate);
|
||||
return DateFormat('MMM dd, yyyy').format(date);
|
||||
} catch (_) {
|
||||
return rawDate;
|
||||
}
|
||||
}
|
||||
|
||||
String rawDateForAdvance(String? rawDate) {
|
||||
if (rawDate == null || rawDate.isEmpty) return '';
|
||||
try {
|
||||
final date = DateTime.parse(rawDate);
|
||||
return DateFormat('MMM dd, yyyy').format(date);
|
||||
} catch (_) {
|
||||
return rawDate;
|
||||
}
|
||||
}
|
||||
|
||||
Color getStatusColor(int status) {
|
||||
Color statusColor = AppColors.textColor;
|
||||
if (status == 3) {
|
||||
statusColor = AppColors.statusRejectedColor;
|
||||
} else if (status == 2) {
|
||||
statusColor = AppColors.statusCompletedColor;
|
||||
} else if (status == 1) {
|
||||
statusColor = AppColors.statusPendingColor;
|
||||
}
|
||||
return statusColor;
|
||||
}
|
||||
|
||||
String getRefundDestinationIcon(String refundDestination) {
|
||||
String icon = "";
|
||||
|
||||
if (refundDestination.toLowerCase().contains("wallet")) {
|
||||
icon = AppAssets.habibLogoOnly;
|
||||
} else if (refundDestination.toLowerCase().contains("bank")) {
|
||||
icon = AppAssets.bankIconOnly;
|
||||
}
|
||||
|
||||
return icon;
|
||||
}
|
||||
|
||||
Widget _buildInvoiceCard(BuildContext context, RefundInvoiceModel? invoice, {bool isLoading = false}) {
|
||||
final isInvoiceType = (invoice?.refundTypeId ?? 0) == 1;
|
||||
final isWalletType = (invoice?.refundTypeId ?? 0) == 2;
|
||||
final referenceNo = (invoice?.referenceNumber ?? '');
|
||||
final lastUpdated = _formatDate(invoice?.lastUpdated);
|
||||
final invoicePayload = invoice?.invoiceRequestPayload;
|
||||
final walletPayload = invoice?.walletRequestPayload;
|
||||
final totalProcedures = (invoicePayload?.proceduresList?.length.toString() ?? '');
|
||||
final statusName = (invoice?.requestStatusName ?? '');
|
||||
final statusId = (invoice?.requestStatusId ?? 1);
|
||||
final refundDestination = (invoice?.refundDestination ?? '');
|
||||
final refundType = invoice?.refundType ?? '';
|
||||
|
||||
return AnimatedContainer(
|
||||
duration: const Duration(milliseconds: 300),
|
||||
curve: Curves.easeInOut,
|
||||
decoration: RoundedRectangleBorder().toSmoothCornerDecoration(color: AppColors.whiteColor, borderRadius: 24.r, hasShadow: false),
|
||||
child: Padding(
|
||||
padding: EdgeInsets.all(16.w),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
AppCustomChipWidget(
|
||||
icon: "",
|
||||
labelText: statusName,
|
||||
textColor: getStatusColor(statusId),
|
||||
backgroundColor: getStatusColor(statusId).withValues(alpha: 0.2),
|
||||
),
|
||||
" $lastUpdated"
|
||||
.toText12(
|
||||
color: AppColors.textColorLight,
|
||||
isBold: false,
|
||||
)
|
||||
.toShimmer2(isShow: isLoading),
|
||||
],
|
||||
),
|
||||
SizedBox(height: 8.h),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
"${LocaleKeys.referenceNo.tr(context: context)} $referenceNo"
|
||||
.toText16(
|
||||
color: AppColors.textColor,
|
||||
isBold: true,
|
||||
)
|
||||
.toShimmer2(isShow: isLoading),
|
||||
// lastUpdated.toText12(color: AppColors.textColorLight).toShimmer2(isShow: isLoading),
|
||||
],
|
||||
),
|
||||
SizedBox(height: 8.h),
|
||||
Wrap(
|
||||
spacing: 6.w,
|
||||
runSpacing: 6.h,
|
||||
children: [
|
||||
if (!isLoading && refundDestination.isNotEmpty)
|
||||
AppCustomChipWidget(icon: getRefundDestinationIcon(refundDestination), iconHasColor: false, labelText: refundDestination),
|
||||
if (refundType.isNotEmpty) AppCustomChipWidget(icon: "", labelText: "$refundType ${LocaleKeys.refund.tr()}"),
|
||||
if (isInvoiceType && invoicePayload != null) ...[
|
||||
if (totalProcedures.isNotEmpty) AppCustomChipWidget(icon: "", labelText: "$totalProcedures ${LocaleKeys.procedures.tr()}"),
|
||||
if (invoicePayload.project != null && invoicePayload.project!.isNotEmpty)
|
||||
AppCustomChipWidget(icon: '', labelText: invoicePayload.project ?? ''),
|
||||
if (invoicePayload.clinicName != null && invoicePayload.clinicName!.isNotEmpty)
|
||||
AppCustomChipWidget(icon: '', labelText: invoicePayload.clinicName ?? ''),
|
||||
if (invoicePayload.doctorName != null && invoicePayload.doctorName!.isNotEmpty)
|
||||
AppCustomChipWidget(icon: '', labelText: invoicePayload.doctorName ?? ''),
|
||||
// AppCustomChipWidget(icon: '', labelText: invoicePayload?.refundTypeName ?? ''),
|
||||
] else if (isWalletType && walletPayload != null) ...[
|
||||
AppCustomChipWidget(icon: '', labelText: walletPayload.project ?? ''),
|
||||
// AppCustomChipWidget(icon: '', labelText: invoicePayload?.refundTypeName ?? ''),
|
||||
],
|
||||
],
|
||||
),
|
||||
SizedBox(height: 16.h),
|
||||
if (isInvoiceType) ...[
|
||||
Utils.getPaymentAmountWithSymbol(
|
||||
isExpanded: false,
|
||||
('${invoicePayload?.totalRefundAmount ?? 0}').toText20(isBold: true, color: AppColors.textColor),
|
||||
AppColors.textColor,
|
||||
14,
|
||||
isSaudiCurrency: true,
|
||||
)
|
||||
] else ...[
|
||||
Utils.getPaymentAmountWithSymbol(
|
||||
isExpanded: false,
|
||||
('${walletPayload?.totalRefundAmount ?? 0}').toText20(isBold: true, color: AppColors.textColor),
|
||||
AppColors.textColor,
|
||||
14,
|
||||
isSaudiCurrency: true,
|
||||
)
|
||||
]
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget buildListDetails(BuildContext context, RefundInvoiceModel? invoice, {bool isLoading = false}) {
|
||||
final isInvoiceType = (invoice?.refundTypeId ?? 0) == 1;
|
||||
final isWalletType = (invoice?.refundTypeId ?? 0) == 2;
|
||||
final invoicePayload = invoice?.invoiceRequestPayload;
|
||||
final walletPayload = invoice?.walletRequestPayload;
|
||||
|
||||
bool shouldShowPadding = (isWalletType && walletPayload != null) || (isInvoiceType && invoicePayload != null);
|
||||
return AnimatedContainer(
|
||||
duration: const Duration(milliseconds: 300),
|
||||
curve: Curves.easeInOut,
|
||||
decoration: RoundedRectangleBorder().toSmoothCornerDecoration(
|
||||
color: AppColors.whiteColor,
|
||||
borderRadius: 24.r,
|
||||
hasShadow: false,
|
||||
),
|
||||
child: Padding(
|
||||
padding: EdgeInsets.all(shouldShowPadding ? 16.w : 0),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
// Summary info
|
||||
if (isInvoiceType && invoicePayload != null) ...[
|
||||
// Procedures header
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
LocaleKeys.procedure.tr(context: context).toText12(color: AppColors.textColor, isBold: true),
|
||||
LocaleKeys.amountOnly.tr(context: context).toText12(color: AppColors.textColor, isBold: true),
|
||||
],
|
||||
),
|
||||
SizedBox(height: 16.h),
|
||||
Divider(color: AppColors.bottomNAVBorder, height: 1, thickness: 1),
|
||||
SizedBox(height: 16.h),
|
||||
if (invoicePayload.proceduresList != null && invoicePayload.proceduresList!.isNotEmpty)
|
||||
...invoicePayload.proceduresList!.map((p) => _buildProcedureRow(context, p)),
|
||||
],
|
||||
if (isWalletType && walletPayload != null) ...[
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Expanded(child: LocaleKeys.advanceNumber.tr(context: context).toText12(color: AppColors.textColor, isBold: true)),
|
||||
SizedBox(
|
||||
width: 80.w,
|
||||
child:
|
||||
LocaleKeys.amountOnly.tr(context: context).toText12(color: AppColors.textColor, isBold: true, textAlignment: TextAlign.end),
|
||||
),
|
||||
],
|
||||
),
|
||||
SizedBox(height: 16.h),
|
||||
Divider(color: AppColors.bottomNAVBorder, height: 1, thickness: 1),
|
||||
SizedBox(height: 16.h),
|
||||
if (walletPayload.advancesList != null && walletPayload.advancesList!.isNotEmpty)
|
||||
...walletPayload.advancesList!.map((a) => _buildAdvanceRow(context, a)),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildProcedureRow(BuildContext context, InvoiceRefundProcedure procedure) {
|
||||
return Padding(
|
||||
padding: EdgeInsets.symmetric(vertical: 6.h),
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Expanded(
|
||||
flex: 3,
|
||||
child: (procedure.procedureName ?? '-').toText12(color: AppColors.textColor),
|
||||
),
|
||||
SizedBox(width: 8.w),
|
||||
(procedure.patientPaidAmount?.toString() ?? '-').toText12(color: AppColors.textColor, isBold: true),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildAdvanceRow(BuildContext context, WalletAdvanceItem advance) {
|
||||
return Padding(
|
||||
padding: EdgeInsets.symmetric(vertical: 6.h),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
(advance.advanceNo ?? '').toText12(color: AppColors.textColor),
|
||||
if (advance.advanceDate != null && advance.advanceDate!.isNotEmpty)
|
||||
rawDateForAdvance(advance.advanceDate!).toText10(color: AppColors.greyTextColor),
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
width: 80.w,
|
||||
child: (advance.balanceAmount?.toStringAsFixed(2) ?? '').toText12(color: AppColors.textColor, isBold: true, textAlignment: TextAlign.end),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return CollapsingListView(
|
||||
title: LocaleKeys.refundDetails.tr(context: context),
|
||||
isLeading: true,
|
||||
child: SingleChildScrollView(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
_buildInvoiceCard(context, invoice),
|
||||
SizedBox(height: 16.h),
|
||||
buildListDetails(context, invoice),
|
||||
],
|
||||
).paddingSymmetrical(24.w, 0),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue