feat: update
This commit is contained in:
parent
e19d788f47
commit
2eceb0bc0c
@ -121,17 +121,17 @@ class PaymentSplitBillRequest {
|
||||
|
||||
class SplitItem {
|
||||
final String orderItemId;
|
||||
final int quantity;
|
||||
final int amount;
|
||||
|
||||
SplitItem({
|
||||
required this.orderItemId,
|
||||
required this.quantity,
|
||||
required this.amount,
|
||||
});
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'order_item_id': orderItemId,
|
||||
'quantity': quantity,
|
||||
'amount': amount,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@ -468,7 +468,7 @@ class _PaymentPageState extends State<PaymentPage> {
|
||||
items: itemPending
|
||||
?.map((item) => SplitItem(
|
||||
orderItemId: item.id ?? "",
|
||||
quantity: item.quantity ?? 0,
|
||||
amount: item.unitPrice ?? 0,
|
||||
))
|
||||
.toList() ??
|
||||
[],
|
||||
|
||||
@ -285,8 +285,8 @@ class SalesListOrder extends StatelessWidget {
|
||||
|
||||
switch (status) {
|
||||
case "pending":
|
||||
backgroundColor = Colors.orange.withOpacity(0.1);
|
||||
textColor = Colors.orange.shade700;
|
||||
backgroundColor = Colors.white;
|
||||
textColor = Colors.white;
|
||||
displayText = "Pending";
|
||||
icon = Icons.access_time;
|
||||
break;
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
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';
|
||||
import 'package:enaklo_pos/core/extensions/string_ext.dart';
|
||||
import 'package:enaklo_pos/data/models/response/order_response_model.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
@ -31,29 +32,18 @@ class SalesPayment extends StatelessWidget {
|
||||
color: AppColors.primary,
|
||||
),
|
||||
),
|
||||
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,
|
||||
),
|
||||
),
|
||||
),
|
||||
_buildPaymentStatus(),
|
||||
],
|
||||
),
|
||||
const SpaceHeight(12),
|
||||
...List.generate(
|
||||
order?.payments?.length ?? 0,
|
||||
(index) => _buildPaymentItem(order?.payments?[index] ?? Payment()),
|
||||
(index) => Padding(
|
||||
padding: const EdgeInsets.only(bottom: 8.0),
|
||||
child: _buildPaymentItem(order?.payments?[index] ?? Payment()),
|
||||
),
|
||||
),
|
||||
const SpaceHeight(12),
|
||||
const SpaceHeight(4),
|
||||
const Divider(),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
@ -96,6 +86,43 @@ class SalesPayment extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
Container _buildPaymentStatus() {
|
||||
switch (order?.paymentStatus) {
|
||||
case 'completed':
|
||||
return Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
|
||||
decoration: BoxDecoration(
|
||||
color: AppColors.green.withOpacity(0.2),
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
),
|
||||
child: Text(
|
||||
(order?.paymentStatus ?? "").toTitleCase(),
|
||||
style: TextStyle(
|
||||
fontSize: 10,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: AppColors.green,
|
||||
),
|
||||
),
|
||||
);
|
||||
default:
|
||||
return Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.amber.shade100,
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
),
|
||||
child: Text(
|
||||
(order?.paymentStatus ?? "").toTitleCase(),
|
||||
style: TextStyle(
|
||||
fontSize: 10,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.amber.shade800,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Row _buildPaymentItem(Payment payment) {
|
||||
return Row(
|
||||
children: [
|
||||
|
||||
@ -39,6 +39,7 @@ class _SplitBillPageState extends State<SplitBillPage> {
|
||||
// Per Amount Split Data
|
||||
TextEditingController amountController = TextEditingController();
|
||||
int splitAmount = 0;
|
||||
int remainingAmount = 0;
|
||||
|
||||
List<OrderItem> getOrderItemPending() =>
|
||||
widget.order.orderItems
|
||||
@ -46,9 +47,24 @@ class _SplitBillPageState extends State<SplitBillPage> {
|
||||
.toList() ??
|
||||
[];
|
||||
|
||||
init() {
|
||||
setState(() {
|
||||
remainingAmount =
|
||||
(widget.order.totalAmount ?? 0) - (widget.order.totalPaid ?? 0);
|
||||
selectedSplitType = widget.order.splitType == 'AMOUNT' ? 1 : 0;
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
init();
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
amountController.dispose();
|
||||
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@ -210,13 +226,7 @@ class _SplitBillPageState extends State<SplitBillPage> {
|
||||
SizedBox(height: 24),
|
||||
|
||||
// Split Type Selection
|
||||
Row(
|
||||
children: [
|
||||
_buildSplitTypeButton('Per Produk', 0),
|
||||
SizedBox(width: 16),
|
||||
_buildSplitTypeButton('Per Jumlah', 1),
|
||||
],
|
||||
),
|
||||
_buildRowButtonSplit(),
|
||||
|
||||
SizedBox(height: 32),
|
||||
|
||||
@ -263,6 +273,23 @@ class _SplitBillPageState extends State<SplitBillPage> {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildRowButtonSplit() {
|
||||
switch (widget.order.splitType) {
|
||||
case 'AMOUNT':
|
||||
return _buildSplitTypeButton('Per Jumlah', 1);
|
||||
case 'ITEM':
|
||||
return _buildSplitTypeButton('Per Produk', 0);
|
||||
default:
|
||||
return Row(
|
||||
children: [
|
||||
_buildSplitTypeButton('Per Produk', 0),
|
||||
SizedBox(width: 16),
|
||||
_buildSplitTypeButton('Per Jumlah', 1),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Widget _buildCustomer(BuildContext context) {
|
||||
return Container(
|
||||
padding: EdgeInsets.all(16),
|
||||
@ -681,7 +708,7 @@ class _SplitBillPageState extends State<SplitBillPage> {
|
||||
),
|
||||
),
|
||||
Text(
|
||||
'Rp ${_formatCurrency((widget.order.totalAmount ?? 0) - splitAmount)}',
|
||||
'Rp ${_formatCurrency((remainingAmount) - splitAmount)}',
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
color: AppColorSplitBill.textSecondary,
|
||||
@ -797,7 +824,8 @@ class _SplitBillPageState extends State<SplitBillPage> {
|
||||
}
|
||||
} else {
|
||||
// Per Amount Split
|
||||
int totalAmount = widget.order.totalAmount ?? 0;
|
||||
int totalAmount =
|
||||
(widget.order.totalAmount ?? 0) - (widget.order.totalPaid ?? 0);
|
||||
|
||||
if (splitAmount > 0 && splitAmount <= totalAmount) {
|
||||
// Create split order object with the specified amount
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user