Skip to content

Commit 61dc6e5

Browse files
authored
Merge pull request #4 from lakasir/feature/redesign-and-add-reprint-in-history
feature(history):
2 parents 77929ab + e17d6e3 commit 61dc6e5

17 files changed

+660
-461
lines changed

lib/api/requests/product_stock_request.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ class ProductStockRequest {
22
final int stock;
33
final String? type;
44
final String? date;
5-
final String? initialPrice;
6-
final String? sellingPrice;
5+
final double? initialPrice;
6+
final double? sellingPrice;
77

88
ProductStockRequest({
99
required this.stock,

lib/controllers/products/stocks/product_stock_controller.dart

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import 'dart:convert';
22

33
import 'package:flutter/material.dart';
4+
import 'package:flutter_masked_text2/flutter_masked_text2.dart';
45
import 'package:get/get.dart';
56
import 'package:lakasir/Exceptions/validation.dart';
67
import 'package:lakasir/api/requests/product_stock_request.dart';
@@ -20,11 +21,11 @@ class ProductStockController extends GetxController {
2021
final _productController = Get.put(ProductController());
2122
final RxList<StockResponse> stocks = <StockResponse>[].obs;
2223
TextEditingController dateInputEditingController = TextEditingController();
23-
TextEditingController initialPriceInputEditingController =
24-
TextEditingController();
2524
TextEditingController stockInputEditingController = TextEditingController();
26-
TextEditingController sellingPriceInputEditingController =
27-
TextEditingController();
25+
MoneyMaskedTextController sellingPriceInputEditingController =
26+
MoneyMaskedTextController(initialValue: 0.0);
27+
MoneyMaskedTextController initialPriceInputEditingController =
28+
MoneyMaskedTextController(initialValue: 0.0);
2829
final Rx<String> type = 'in'.obs;
2930
final Rx<StockErrorResponse> stockErrorResponse = StockErrorResponse().obs;
3031

@@ -55,8 +56,8 @@ class ProductStockController extends GetxController {
5556
ProductStockRequest(
5657
type: type.value,
5758
stock: int.parse(stockInputEditingController.text),
58-
initialPrice: initialPriceInputEditingController.text,
59-
sellingPrice: sellingPriceInputEditingController.text,
59+
initialPrice: initialPriceInputEditingController.numberValue,
60+
sellingPrice: sellingPriceInputEditingController.numberValue,
6061
date: dateInputEditingController.text,
6162
),
6263
);
@@ -93,8 +94,8 @@ class ProductStockController extends GetxController {
9394

9495
void clear() {
9596
dateInputEditingController.clear();
96-
initialPriceInputEditingController.clear();
97+
initialPriceInputEditingController.updateValue(0.0);
98+
sellingPriceInputEditingController.updateValue(0.0);
9799
stockInputEditingController.clear();
98-
sellingPriceInputEditingController.clear();
99100
}
100101
}

lib/messages.dart

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ class Messages extends Translations {
5757
'transaction_cashier': 'Cashier',
5858
'transaction_history': 'Transaction History',
5959
'transaction_list': 'Transaction List',
60+
'transaction_items': 'Items',
6061
'transaction_analytics': 'Transaction Analytics',
6162
'transaction_analytics_filter_today': 'Today',
6263
'transaction_analytics_filter_yesterday': 'Yesterday',
@@ -141,8 +142,13 @@ class Messages extends Translations {
141142
'field_stock_info':
142143
'If you enable this, stock will be used as product without stock',
143144
'field_last_initial_price': 'The last initial price',
145+
'field_last_initial_price_info':
146+
'Leave it empty to use the last price',
144147
'field_initial_price': 'Initial Price',
145148
'field_selling_price': 'Selling Price',
149+
'field_last_selling_price': 'The last selling price',
150+
'field_last_selling_price_info':
151+
'Leave it empty to use the last price',
146152
'field_category': 'Category',
147153
'field_select_category': 'Select Category',
148154
'field_type': 'Type',
@@ -252,6 +258,8 @@ class Messages extends Translations {
252258
'global_validation_field_not_connected': 'Printer not connected',
253259
'global_connected': 'Printer connected',
254260
'global_not_connected': 'Printer not connected',
261+
're-print': 'Re-print',
262+
'share': 'Share',
255263
},
256264
'id_ID': {
257265
'auth': 'Otentikasi',
@@ -307,6 +315,7 @@ class Messages extends Translations {
307315
'transaction_cashier': 'Kasir',
308316
'transaction_history': 'Riwayat Transaksi',
309317
'transaction_list': 'Dafar Transaksi',
318+
'transaction_items': 'Barang',
310319
'transaction_analytics': 'Analitik Transaksi',
311320
'transaction_analytics_filter_today': 'Hari Ini',
312321
'transaction_analytics_filter_yesterday': 'Kemarin',
@@ -392,8 +401,13 @@ class Messages extends Translations {
392401
'field_stock_info':
393402
'Jika anda mengaktifkan ini, stok akan digunakan sebagai produk tanpa stok',
394403
'field_last_initial_price': 'Harga awal terakhir',
404+
'field_last_initial_price_info':
405+
'Biarkan kosong untuk menggunakan harga terakhir',
395406
'field_initial_price': 'Harga Awal',
396407
'field_selling_price': 'Harga Jual',
408+
'field_last_selling_price': 'Harga Jual Terakhir',
409+
'field_last_selling_price_info':
410+
'Biarkan kosong untuk menggunakan harga terakhir',
397411
'field_category': 'Kategori',
398412
'field_select_category': 'Pilih Kategori',
399413
'field_type': 'Tipe',
@@ -502,6 +516,8 @@ class Messages extends Translations {
502516
'global_validation_field_not_connected': 'Printer tidak terhubung',
503517
'global_connected': 'Printer terhubung',
504518
'global_not_connected': 'Printer tidak terhubung',
519+
're-print': 'Cetak Ulang',
520+
'share': 'Bagikan',
505521
},
506522
};
507523
}

lib/screens/products/detail_stock_screen.dart

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ class _DetailStockScreenState extends State<DetailStockScreen> {
3535
void fetchDetail() async {
3636
final ProductResponse products = Get.arguments;
3737
await _productStockController.get(products.id);
38+
setState(() {
39+
_productDetailController.product.value = products;
40+
});
3841
}
3942

4043
@override
@@ -73,7 +76,8 @@ class _DetailStockScreenState extends State<DetailStockScreen> {
7376
maxLines: 4,
7477
),
7578
Text(
76-
'field_stock: ${_productDetailController.product.value.stock}',
79+
'field_stock:'.tr +
80+
_productDetailController.product.value.stock.toString(),
7781
style: const TextStyle(
7882
fontSize: 14,
7983
fontWeight: FontWeight.w200,
@@ -86,14 +90,11 @@ class _DetailStockScreenState extends State<DetailStockScreen> {
8690
),
8791
),
8892
],
89-
imagebox: Hero(
90-
tag: 'product-${_productDetailController.product.value.id}',
91-
child: SizedBox(
92-
height: 90,
93-
width: 90,
94-
child: MyImage(
95-
images: _productDetailController.product.value.image,
96-
),
93+
imagebox: SizedBox(
94+
height: 90,
95+
width: 90,
96+
child: MyImage(
97+
images: _productDetailController.product.value.image,
9798
),
9899
),
99100
),
@@ -417,6 +418,7 @@ class _ActionModalStockState extends State<ActionModalStock> {
417418
controller: widget.productStockController
418419
.initialPriceInputEditingController,
419420
label: "field_initial_price".tr,
421+
info: "field_last_initial_price_info".tr,
420422
keyboardType: TextInputType.number,
421423
errorText: widget.productStockController
422424
.stockErrorResponse.value.initialPrice ??
@@ -441,6 +443,7 @@ class _ActionModalStockState extends State<ActionModalStock> {
441443
controller: widget.productStockController
442444
.sellingPriceInputEditingController,
443445
label: "field_selling_price".tr,
446+
info: "field_last_selling_price_info".tr,
444447
keyboardType: TextInputType.number,
445448
errorText: widget.productStockController
446449
.stockErrorResponse.value.sellingPrice ??

lib/screens/setting/printers/add_printer_page_screen.dart

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import 'package:lakasir/widgets/image_picker.dart';
1313
import 'package:lakasir/widgets/layout.dart';
1414
import 'package:lakasir/widgets/select_input_feld.dart';
1515
import 'package:lakasir/widgets/text_field.dart';
16-
import 'package:image/image.dart' as img;
1716
import 'package:path_provider/path_provider.dart';
1817

1918
class AddPrinterPageScreen extends StatefulWidget {
@@ -180,35 +179,6 @@ class _AddPrinterPageScreenState extends State<AddPrinterPageScreen> {
180179
return file.path;
181180
}
182181

183-
Future<String> moveImageToDirectory(
184-
String imagePath, String targetDirectory) async {
185-
// Get the file object for the image
186-
File imageFile = File(imagePath);
187-
188-
// Check if the image file exists
189-
if (!await imageFile.exists()) {
190-
throw const FileSystemException('Image file does not exist.');
191-
}
192-
193-
// Get the target directory
194-
Directory directory = Directory(targetDirectory);
195-
196-
// Check if the target directory exists
197-
if (!await directory.exists()) {
198-
// Create the target directory if it doesn't exist
199-
await directory.create(recursive: true);
200-
}
201-
202-
// Generate a new file path in the target directory
203-
String newFilePath = '${directory.path}/${imageFile.path.split('/').last}';
204-
205-
// Move the image file to the target directory
206-
await imageFile.rename(newFilePath);
207-
208-
// Return the new file path
209-
return newFilePath;
210-
}
211-
212182
@override
213183
Widget build(BuildContext context) {
214184
return Layout(

lib/screens/setting/printers/print_receipt.dart

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@ class PrintReceipt {
1313

1414
void print(
1515
TransactionHistoryResponse transactionHistoryResponse,
16-
Printer printer,
17-
) async {
16+
Printer printer, {
17+
copy = false,
18+
}) async {
1819
if (printer.logopath!.isNotEmpty) {
1920
await bluetooth.printImage(printer.logopath!);
2021
}
@@ -120,6 +121,13 @@ class PrintReceipt {
120121
1,
121122
1,
122123
);
124+
if (copy!) {
125+
await bluetooth.printCustom(
126+
"Copy",
127+
1,
128+
0,
129+
);
130+
}
123131
await bluetooth.paperCut();
124132
}
125133
}

0 commit comments

Comments
 (0)