150 lines
4.5 KiB
Dart
Raw Normal View History

2025-08-02 10:50:48 +07:00
import 'package:enaklo_pos/core/components/spaces.dart';
import 'package:enaklo_pos/core/constants/colors.dart';
import 'package:enaklo_pos/core/extensions/int_ext.dart';
2025-08-03 14:39:15 +07:00
import 'package:enaklo_pos/data/models/response/order_response_model.dart';
2025-08-02 10:50:48 +07:00
import 'package:flutter/material.dart';
class SalesPayment extends StatelessWidget {
2025-08-03 14:39:15 +07:00
final Order? order;
2025-08-02 10:50:48 +07:00
const SalesPayment({super.key, this.order});
@override
Widget build(BuildContext context) {
return Container(
2025-08-08 10:29:17 +07:00
width: double.infinity,
2025-08-02 10:50:48 +07:00
padding: const EdgeInsets.all(16),
decoration: BoxDecoration(
2025-08-08 10:29:17 +07:00
color: Colors.white,
2025-08-02 10:50:48 +07:00
borderRadius: BorderRadius.circular(8),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
2025-08-08 10:29:17 +07:00
'Informasi Pembayaran',
style: TextStyle(
2025-08-02 10:50:48 +07:00
fontSize: 16,
2025-08-08 10:29:17 +07:00
fontWeight: FontWeight.bold,
color: AppColors.primary,
2025-08-02 10:50:48 +07:00
),
),
2025-08-08 10:29:17 +07:00
Container(
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
decoration: BoxDecoration(
color: Colors.amber.shade100,
borderRadius: BorderRadius.circular(4),
),
child: Text(
order?.paymentStatus ?? "",
style: TextStyle(
fontSize: 10,
fontWeight: FontWeight.bold,
color: Colors.amber.shade800,
),
2025-08-02 10:50:48 +07:00
),
),
],
),
2025-08-08 10:29:17 +07:00
const SpaceHeight(12),
...List.generate(
order?.payments?.length ?? 0,
(index) => _buildPaymentItem(order?.payments?[index] ?? Payment()),
),
const SpaceHeight(12),
const Divider(),
2025-08-02 10:50:48 +07:00
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
2025-08-08 10:29:17 +07:00
'Jumlah yang Dibayar',
style: TextStyle(color: Colors.grey.shade700),
2025-08-02 10:50:48 +07:00
),
Text(
2025-08-08 10:29:17 +07:00
(order?.totalPaid ?? 0).currencyFormatRpV2,
style: TextStyle(fontWeight: FontWeight.w500),
2025-08-02 10:50:48 +07:00
),
],
),
2025-08-08 10:29:17 +07:00
if (((order?.totalAmount ?? 0) - (order?.totalPaid ?? 0)) != 0) ...[
const SpaceHeight(4),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
'Sisa Tagihan',
style: TextStyle(
color: Colors.red.shade700,
fontWeight: FontWeight.w500,
),
),
Text(
((order?.totalAmount ?? 0) - (order?.totalPaid ?? 0))
.currencyFormatRpV2,
style: TextStyle(
color: Colors.red.shade700,
fontWeight: FontWeight.w500,
),
),
],
),
],
],
),
);
}
Row _buildPaymentItem(Payment payment) {
return Row(
children: [
Container(
width: 32,
height: 32,
decoration: BoxDecoration(
color: Colors.green.shade100,
borderRadius: BorderRadius.circular(4),
),
child: Icon(
Icons.payments,
color: Colors.green.shade700,
size: 16,
2025-08-02 10:50:48 +07:00
),
2025-08-08 10:29:17 +07:00
),
const SizedBox(width: 12),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
2025-08-02 10:50:48 +07:00
children: [
Text(
2025-08-08 10:29:17 +07:00
payment.paymentMethodName ?? "",
style: TextStyle(
fontSize: 14,
fontWeight: FontWeight.w500,
2025-08-02 10:50:48 +07:00
),
),
2025-08-08 10:29:17 +07:00
if ((payment.splitTotal ?? 0) > 1)
Text(
'Split ${payment.splitNumber ?? 0} of ${payment.splitTotal ?? 0}',
style: TextStyle(
fontSize: 12,
color: Colors.grey.shade600,
),
2025-08-02 10:50:48 +07:00
),
],
),
2025-08-08 10:29:17 +07:00
),
Text(
(payment.amount ?? 0).currencyFormatRpV2,
style: TextStyle(
fontSize: 14,
fontWeight: FontWeight.w600,
color: AppColors.green,
),
),
],
2025-08-02 10:50:48 +07:00
);
}
}