Skip to content

Commit

Permalink
feature(selling-detail): adjust the detail to show discount
Browse files Browse the repository at this point in the history
  • Loading branch information
sheenazien8 committed Jun 23, 2024
1 parent 15660ea commit 84f9dd6
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 41 deletions.
11 changes: 11 additions & 0 deletions lib/api/responses/transactions/selling_detail.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,15 @@ class SellingDetail {
: null,
);
}

String buildRowPrice() {
var priceText = "${formatPrice(price, isSymbol: false)} x $quantity";

if (discountPrice != 0) {
priceText =
"($priceText) -\n${formatPrice(discountPrice, isSymbol: false)} ";
}

return priceText;
}
}
4 changes: 4 additions & 0 deletions lib/screens/menu_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import 'package:heroicons/heroicons.dart';
import 'package:lakasir/controllers/auths/auth_controller.dart';
import 'package:lakasir/controllers/profiles/profile_controller.dart';
import 'package:lakasir/controllers/setting_controller.dart';
import 'package:lakasir/controllers/settings/print_controller.dart';
import 'package:lakasir/utils/colors.dart';
import 'package:lakasir/widgets/layout.dart';
import 'package:lakasir/widgets/my_card_list.dart';
Expand Down Expand Up @@ -68,17 +69,20 @@ class _MenuScreenState extends State<MenuScreen> {
SettingController settingController = Get.put(SettingController());
final AuthController _authController = Get.put(AuthController());
final ProfileController _profileController = Get.put(ProfileController());
final PrintController _printController = Get.put(PrintController());

@override
void initState() {
super.initState();
_authController.fetchPermissions();
_printController.fetchPrinters();
}

@override
void dispose() {
super.dispose();
_authController.fetchPermissions();
_printController.fetchPrinters();
}

@override
Expand Down
3 changes: 2 additions & 1 deletion lib/screens/setting/printers/add_printer_page_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,8 @@ class _AddPrinterPageScreenState extends State<AddPrinterPageScreen> {
Container(
margin: const EdgeInsets.only(bottom: 10),
child: MyTextField(
textInputAction: TextInputAction.none,
keyboardType: TextInputType.multiline,
textInputAction: TextInputAction.newline,
maxLines: 4,
controller: _printerController.footerController,
label: 'field_footer'.tr,
Expand Down
75 changes: 40 additions & 35 deletions lib/screens/transactions/history/detail_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ class _HistoryDetailScreenState extends State<HistoryDetailScreen> {
});
}
});
} else {
show("printer_error".tr, color: error);
}
}

Expand Down Expand Up @@ -137,16 +139,17 @@ class _HistoryDetailScreenState extends State<HistoryDetailScreen> {
(e) => DetailTransactionItem(
discountPrice: formatPrice(e.discountPrice),
productName: e.product!.name,
quantity: "${e.quantity} x ${formatPrice(e.price / e.quantity)}",
subTotal: formatPrice(e.price),
quantity: e.buildRowPrice(),
subTotal: formatPrice(e.discountPrice),
),
)
.toList(),
tax: "${history.tax!}%",
discount: "(${formatPrice(history.totalDiscount)})",
subTotal: formatPrice(
history.totalPrice! - (history.totalPrice! * history.tax! / 100),
),
total: formatPrice(history.totalPrice!),
total: formatPrice(history.grandTotalPrice!),
payedMoney: formatPrice(history.payedMoney!),
change: formatPrice(history.moneyChange!),
note: history.note,
Expand All @@ -158,42 +161,44 @@ class _HistoryDetailScreenState extends State<HistoryDetailScreen> {
Widget build(BuildContext context) {
return Layout(
title: "transaction_detail".tr,
child: ListView(
children: [
_detailTransaction(),
const SizedBox(height: 20),
Row(
children: [
Flexible(
child: MyFilledButton(
color: grey,
isLoading: sharedLoading,
onPressed: captureAndShareWidget,
child: Row(
children: [
Text("share".tr),
const SizedBox(width: 10),
const Icon(Icons.share),
],
child: SingleChildScrollView(
child: Column(
children: [
_detailTransaction(),
const SizedBox(height: 20),
Row(
children: [
Flexible(
child: MyFilledButton(
color: grey,
isLoading: sharedLoading,
onPressed: captureAndShareWidget,
child: Row(
children: [
Text("share".tr),
const SizedBox(width: 10),
const Icon(Icons.share),
],
),
),
),
),
const SizedBox(width: 10),
Flexible(
child: MyFilledButton(
onPressed: rePrint,
child: Row(
children: [
Text("re-print".tr),
const SizedBox(width: 10),
const Icon(Icons.print),
],
const SizedBox(width: 10),
Flexible(
child: MyFilledButton(
onPressed: rePrint,
child: Row(
children: [
Text("re-print".tr),
const SizedBox(width: 10),
const Icon(Icons.print),
],
),
),
),
),
],
),
],
],
),
],
),
),
);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/screens/transactions/history/history_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ class CardList extends StatelessWidget {
),
const SizedBox(height: 10),
Text(
"Total Price: ${formatPrice(history.totalPrice!, isSymbol: false)}",
"Total Price: ${formatPrice(history.grandTotalPrice!, isSymbol: false)}",
style: const TextStyle(
fontWeight: FontWeight.w400,
),
Expand Down
9 changes: 5 additions & 4 deletions lib/widgets/detail_transaction.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:lakasir/controllers/auths/auth_controller.dart';
import 'package:lakasir/utils/utils.dart';

class DetailTransaction extends StatefulWidget {
const DetailTransaction({
Expand Down Expand Up @@ -136,15 +137,15 @@ class _DetailTransactionState extends State<DetailTransaction> {
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text("Subtotal".tr, style: _normalStyle),
Text(widget.subTotal, style: _boldStyle)
Text("discount".tr, style: _normalStyle),
Text(widget.discount, style: _boldStyle)
],
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text("discount".tr, style: _normalStyle),
Text(widget.discount, style: _boldStyle)
Text("Subtotal".tr, style: _normalStyle),
Text(widget.subTotal, style: _boldStyle)
],
),
Row(
Expand Down

0 comments on commit 84f9dd6

Please sign in to comment.