dev #1
@ -121,17 +121,17 @@ class PaymentSplitBillRequest {
|
|||||||
|
|
||||||
class SplitItem {
|
class SplitItem {
|
||||||
final String orderItemId;
|
final String orderItemId;
|
||||||
final int quantity;
|
final int amount;
|
||||||
|
|
||||||
SplitItem({
|
SplitItem({
|
||||||
required this.orderItemId,
|
required this.orderItemId,
|
||||||
required this.quantity,
|
required this.amount,
|
||||||
});
|
});
|
||||||
|
|
||||||
Map<String, dynamic> toJson() {
|
Map<String, dynamic> toJson() {
|
||||||
return {
|
return {
|
||||||
'order_item_id': orderItemId,
|
'order_item_id': orderItemId,
|
||||||
'quantity': quantity,
|
'amount': amount,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -468,7 +468,7 @@ class _PaymentPageState extends State<PaymentPage> {
|
|||||||
items: itemPending
|
items: itemPending
|
||||||
?.map((item) => SplitItem(
|
?.map((item) => SplitItem(
|
||||||
orderItemId: item.id ?? "",
|
orderItemId: item.id ?? "",
|
||||||
quantity: item.quantity ?? 0,
|
amount: item.unitPrice ?? 0,
|
||||||
))
|
))
|
||||||
.toList() ??
|
.toList() ??
|
||||||
[],
|
[],
|
||||||
|
|||||||
@ -285,8 +285,8 @@ class SalesListOrder extends StatelessWidget {
|
|||||||
|
|
||||||
switch (status) {
|
switch (status) {
|
||||||
case "pending":
|
case "pending":
|
||||||
backgroundColor = Colors.orange.withOpacity(0.1);
|
backgroundColor = Colors.white;
|
||||||
textColor = Colors.orange.shade700;
|
textColor = Colors.white;
|
||||||
displayText = "Pending";
|
displayText = "Pending";
|
||||||
icon = Icons.access_time;
|
icon = Icons.access_time;
|
||||||
break;
|
break;
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
import 'package:enaklo_pos/core/components/spaces.dart';
|
import 'package:enaklo_pos/core/components/spaces.dart';
|
||||||
import 'package:enaklo_pos/core/constants/colors.dart';
|
import 'package:enaklo_pos/core/constants/colors.dart';
|
||||||
import 'package:enaklo_pos/core/extensions/int_ext.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:enaklo_pos/data/models/response/order_response_model.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
@ -31,29 +32,18 @@ class SalesPayment extends StatelessWidget {
|
|||||||
color: AppColors.primary,
|
color: AppColors.primary,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Container(
|
_buildPaymentStatus(),
|
||||||
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,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
const SpaceHeight(12),
|
const SpaceHeight(12),
|
||||||
...List.generate(
|
...List.generate(
|
||||||
order?.payments?.length ?? 0,
|
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(),
|
const Divider(),
|
||||||
Row(
|
Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
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) {
|
Row _buildPaymentItem(Payment payment) {
|
||||||
return Row(
|
return Row(
|
||||||
children: [
|
children: [
|
||||||
|
|||||||
@ -39,6 +39,7 @@ class _SplitBillPageState extends State<SplitBillPage> {
|
|||||||
// Per Amount Split Data
|
// Per Amount Split Data
|
||||||
TextEditingController amountController = TextEditingController();
|
TextEditingController amountController = TextEditingController();
|
||||||
int splitAmount = 0;
|
int splitAmount = 0;
|
||||||
|
int remainingAmount = 0;
|
||||||
|
|
||||||
List<OrderItem> getOrderItemPending() =>
|
List<OrderItem> getOrderItemPending() =>
|
||||||
widget.order.orderItems
|
widget.order.orderItems
|
||||||
@ -46,9 +47,24 @@ class _SplitBillPageState extends State<SplitBillPage> {
|
|||||||
.toList() ??
|
.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
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
amountController.dispose();
|
amountController.dispose();
|
||||||
|
|
||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -210,13 +226,7 @@ class _SplitBillPageState extends State<SplitBillPage> {
|
|||||||
SizedBox(height: 24),
|
SizedBox(height: 24),
|
||||||
|
|
||||||
// Split Type Selection
|
// Split Type Selection
|
||||||
Row(
|
_buildRowButtonSplit(),
|
||||||
children: [
|
|
||||||
_buildSplitTypeButton('Per Produk', 0),
|
|
||||||
SizedBox(width: 16),
|
|
||||||
_buildSplitTypeButton('Per Jumlah', 1),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
|
|
||||||
SizedBox(height: 32),
|
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) {
|
Widget _buildCustomer(BuildContext context) {
|
||||||
return Container(
|
return Container(
|
||||||
padding: EdgeInsets.all(16),
|
padding: EdgeInsets.all(16),
|
||||||
@ -681,7 +708,7 @@ class _SplitBillPageState extends State<SplitBillPage> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
Text(
|
Text(
|
||||||
'Rp ${_formatCurrency((widget.order.totalAmount ?? 0) - splitAmount)}',
|
'Rp ${_formatCurrency((remainingAmount) - splitAmount)}',
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 14,
|
fontSize: 14,
|
||||||
color: AppColorSplitBill.textSecondary,
|
color: AppColorSplitBill.textSecondary,
|
||||||
@ -797,7 +824,8 @@ class _SplitBillPageState extends State<SplitBillPage> {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Per Amount Split
|
// Per Amount Split
|
||||||
int totalAmount = widget.order.totalAmount ?? 0;
|
int totalAmount =
|
||||||
|
(widget.order.totalAmount ?? 0) - (widget.order.totalPaid ?? 0);
|
||||||
|
|
||||||
if (splitAmount > 0 && splitAmount <= totalAmount) {
|
if (splitAmount > 0 && splitAmount <= totalAmount) {
|
||||||
// Create split order object with the specified amount
|
// Create split order object with the specified amount
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user