Compare commits
No commits in common. "8022fa6b322a82e6fc8ba9ef6d6e40c1910e4bcb" and "7586df207e98b4b3473731ff24c1f65a91c2388b" have entirely different histories.
8022fa6b32
...
7586df207e
@ -23,7 +23,7 @@ if (flutterVersionName == null) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
android {
|
android {
|
||||||
namespace "com.appscale.pos"
|
namespace "com.example.enaklo_pos"
|
||||||
compileSdkVersion 35
|
compileSdkVersion 35
|
||||||
ndkVersion flutter.ndkVersion
|
ndkVersion flutter.ndkVersion
|
||||||
|
|
||||||
@ -42,7 +42,7 @@ android {
|
|||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
|
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
|
||||||
applicationId "com.appscale.pos"
|
applicationId "com.example.enaklo_pos"
|
||||||
// You can update the following values to match your application needs.
|
// You can update the following values to match your application needs.
|
||||||
// For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
|
// For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
|
||||||
minSdkVersion 21
|
minSdkVersion 21
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
package com.appscale.pos
|
package com.example.enaklo_pos
|
||||||
|
|
||||||
import io.flutter.embedding.android.FlutterActivity
|
import io.flutter.embedding.android.FlutterActivity
|
||||||
|
|
||||||
|
|||||||
@ -3,7 +3,6 @@ import 'dart:developer';
|
|||||||
import 'package:enaklo_pos/core/extensions/string_ext.dart';
|
import 'package:enaklo_pos/core/extensions/string_ext.dart';
|
||||||
import 'package:enaklo_pos/core/utils/printer_service.dart';
|
import 'package:enaklo_pos/core/utils/printer_service.dart';
|
||||||
import 'package:enaklo_pos/data/dataoutputs/print_dataoutputs.dart';
|
import 'package:enaklo_pos/data/dataoutputs/print_dataoutputs.dart';
|
||||||
import 'package:enaklo_pos/data/datasources/auth_local_datasource.dart';
|
|
||||||
import 'package:enaklo_pos/data/datasources/product_local_datasource.dart';
|
import 'package:enaklo_pos/data/datasources/product_local_datasource.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:enaklo_pos/presentation/home/models/product_quantity.dart';
|
import 'package:enaklo_pos/presentation/home/models/product_quantity.dart';
|
||||||
@ -21,11 +20,17 @@ Future<void> onPrint(
|
|||||||
final barPrinter =
|
final barPrinter =
|
||||||
await ProductLocalDatasource.instance.getPrinterByCode('bar');
|
await ProductLocalDatasource.instance.getPrinterByCode('bar');
|
||||||
|
|
||||||
|
log("Checker printer: ${checkerPrinter?.toMap()}");
|
||||||
|
log("Kitchen printer: ${kitchenPrinter?.toMap()}");
|
||||||
|
log("Bar printer: ${barPrinter?.toMap()}");
|
||||||
|
|
||||||
// Checker printer
|
// Checker printer
|
||||||
if (checkerPrinter != null) {
|
if (checkerPrinter != null) {
|
||||||
try {
|
try {
|
||||||
final printValue = await PrintDataoutputs.instance.printChecker(
|
final printValue = await PrintDataoutputs.instance.printChecker(
|
||||||
productQuantity,
|
productQuantity
|
||||||
|
.where((e) => e.product.printerType == "checker")
|
||||||
|
.toList(),
|
||||||
order.tableNumber ?? "",
|
order.tableNumber ?? "",
|
||||||
order.orderNumber ?? "",
|
order.orderNumber ?? "",
|
||||||
'kasir',
|
'kasir',
|
||||||
@ -48,7 +53,9 @@ Future<void> onPrint(
|
|||||||
if (kitchenPrinter != null) {
|
if (kitchenPrinter != null) {
|
||||||
try {
|
try {
|
||||||
final printValue = await PrintDataoutputs.instance.printKitchen(
|
final printValue = await PrintDataoutputs.instance.printKitchen(
|
||||||
productQuantity,
|
productQuantity
|
||||||
|
.where((e) => e.product.printerType == "kitchen")
|
||||||
|
.toList(),
|
||||||
order.tableNumber!,
|
order.tableNumber!,
|
||||||
order.orderNumber ?? "",
|
order.orderNumber ?? "",
|
||||||
'kasir',
|
'kasir',
|
||||||
@ -70,7 +77,7 @@ Future<void> onPrint(
|
|||||||
if (barPrinter != null) {
|
if (barPrinter != null) {
|
||||||
try {
|
try {
|
||||||
final printValue = await PrintDataoutputs.instance.printBar(
|
final printValue = await PrintDataoutputs.instance.printBar(
|
||||||
productQuantity,
|
productQuantity.where((e) => e.product.printerType == "bar").toList(),
|
||||||
order.tableNumber ?? "",
|
order.tableNumber ?? "",
|
||||||
order.orderNumber ?? "",
|
order.orderNumber ?? "",
|
||||||
'kasir',
|
'kasir',
|
||||||
@ -87,37 +94,3 @@ Future<void> onPrint(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> onPrintRecipt(
|
|
||||||
context, {
|
|
||||||
required Order order,
|
|
||||||
required String paymentMethod,
|
|
||||||
required int nominalBayar,
|
|
||||||
required int kembalian,
|
|
||||||
required int taxPercentage,
|
|
||||||
}) async {
|
|
||||||
final receiptPrinter =
|
|
||||||
await ProductLocalDatasource.instance.getPrinterByCode('receipt');
|
|
||||||
final authData = await AuthLocalDataSource().getAuthData();
|
|
||||||
|
|
||||||
if (receiptPrinter != null) {
|
|
||||||
try {
|
|
||||||
final printValue = await PrintDataoutputs.instance.printOrderV4(
|
|
||||||
order,
|
|
||||||
authData.user?.name ?? "",
|
|
||||||
paymentMethod,
|
|
||||||
nominalBayar,
|
|
||||||
kembalian,
|
|
||||||
taxPercentage,
|
|
||||||
receiptPrinter.paper.toIntegerFromText,
|
|
||||||
);
|
|
||||||
await PrinterService()
|
|
||||||
.printWithPrinter(receiptPrinter, printValue, context);
|
|
||||||
} catch (e) {
|
|
||||||
log("Error printing receipt order: $e");
|
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
|
||||||
SnackBar(content: Text('Error printing receipt order: $e')),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@ -1,6 +1,5 @@
|
|||||||
import 'dart:math';
|
import 'dart:math';
|
||||||
|
|
||||||
import 'package:enaklo_pos/data/models/response/order_response_model.dart';
|
|
||||||
import 'package:esc_pos_utils_plus/esc_pos_utils_plus.dart';
|
import 'package:esc_pos_utils_plus/esc_pos_utils_plus.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:enaklo_pos/core/extensions/int_ext.dart';
|
import 'package:enaklo_pos/core/extensions/int_ext.dart';
|
||||||
@ -740,263 +739,6 @@ class PrintDataoutputs {
|
|||||||
return bytes;
|
return bytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<List<int>> printOrderV4(
|
|
||||||
Order order,
|
|
||||||
String chashierName,
|
|
||||||
String paymentMethod,
|
|
||||||
int nominalBayar,
|
|
||||||
int kembalian,
|
|
||||||
int taxPercentage,
|
|
||||||
int paper,
|
|
||||||
) async {
|
|
||||||
List<int> bytes = [];
|
|
||||||
|
|
||||||
final profile = await CapabilityProfile.load();
|
|
||||||
final generator =
|
|
||||||
Generator(paper == 58 ? PaperSize.mm58 : PaperSize.mm80, profile);
|
|
||||||
|
|
||||||
bytes += generator.reset();
|
|
||||||
|
|
||||||
bytes += generator.text('Guapatlu Khas Bakmi Jambi',
|
|
||||||
styles: const PosStyles(
|
|
||||||
bold: true,
|
|
||||||
align: PosAlign.center,
|
|
||||||
height: PosTextSize.size1,
|
|
||||||
width: PosTextSize.size1,
|
|
||||||
));
|
|
||||||
|
|
||||||
bytes += generator.text('Gading Boulevard w2, No 25, Jakarta',
|
|
||||||
styles: const PosStyles(bold: false, align: PosAlign.center));
|
|
||||||
bytes += generator.text('085-77777-3839',
|
|
||||||
styles: const PosStyles(bold: false, align: PosAlign.center));
|
|
||||||
|
|
||||||
bytes += generator.text(
|
|
||||||
paper == 80
|
|
||||||
? '------------------------------------------------'
|
|
||||||
: '--------------------------------',
|
|
||||||
styles: const PosStyles(bold: false, align: PosAlign.center));
|
|
||||||
|
|
||||||
bytes += generator.row([
|
|
||||||
PosColumn(
|
|
||||||
text: DateFormat('dd MMM yyyy').format(DateTime.now()),
|
|
||||||
width: 6,
|
|
||||||
styles: const PosStyles(align: PosAlign.left),
|
|
||||||
),
|
|
||||||
PosColumn(
|
|
||||||
text: DateFormat('HH:mm').format(DateTime.now()),
|
|
||||||
width: 6,
|
|
||||||
styles: const PosStyles(align: PosAlign.right),
|
|
||||||
),
|
|
||||||
]);
|
|
||||||
bytes += generator.row([
|
|
||||||
PosColumn(
|
|
||||||
text: 'Receipt Number',
|
|
||||||
width: 6,
|
|
||||||
styles: const PosStyles(align: PosAlign.left),
|
|
||||||
),
|
|
||||||
PosColumn(
|
|
||||||
text: 'JF-${DateFormat('yyyyMMddhhmm').format(DateTime.now())}',
|
|
||||||
width: 6,
|
|
||||||
styles: const PosStyles(align: PosAlign.right),
|
|
||||||
),
|
|
||||||
]);
|
|
||||||
|
|
||||||
bytes += generator.row([
|
|
||||||
PosColumn(
|
|
||||||
text: 'Order ID',
|
|
||||||
width: 6,
|
|
||||||
styles: const PosStyles(align: PosAlign.left),
|
|
||||||
),
|
|
||||||
PosColumn(
|
|
||||||
text: Random().nextInt(100000).toString(),
|
|
||||||
width: 6,
|
|
||||||
styles: const PosStyles(align: PosAlign.right),
|
|
||||||
),
|
|
||||||
]);
|
|
||||||
bytes += generator.row([
|
|
||||||
PosColumn(
|
|
||||||
text: 'Bill Name',
|
|
||||||
width: 6,
|
|
||||||
styles: const PosStyles(align: PosAlign.left),
|
|
||||||
),
|
|
||||||
PosColumn(
|
|
||||||
text: order.metadata?['customer_name'] ?? '',
|
|
||||||
width: 6,
|
|
||||||
styles: const PosStyles(align: PosAlign.right),
|
|
||||||
),
|
|
||||||
]);
|
|
||||||
bytes += generator.row([
|
|
||||||
PosColumn(
|
|
||||||
text: 'Collected By',
|
|
||||||
width: 6,
|
|
||||||
styles: const PosStyles(align: PosAlign.left),
|
|
||||||
),
|
|
||||||
PosColumn(
|
|
||||||
text: chashierName,
|
|
||||||
width: 6,
|
|
||||||
styles: const PosStyles(align: PosAlign.right),
|
|
||||||
),
|
|
||||||
]);
|
|
||||||
bytes += generator.row([
|
|
||||||
PosColumn(
|
|
||||||
text: 'Pembayaran',
|
|
||||||
width: 8,
|
|
||||||
styles: const PosStyles(align: PosAlign.left),
|
|
||||||
),
|
|
||||||
PosColumn(
|
|
||||||
text: paymentMethod,
|
|
||||||
width: 4,
|
|
||||||
styles: const PosStyles(align: PosAlign.right),
|
|
||||||
),
|
|
||||||
]);
|
|
||||||
|
|
||||||
bytes += generator.text(
|
|
||||||
paper == 80
|
|
||||||
? '------------------------------------------------'
|
|
||||||
: '--------------------------------',
|
|
||||||
styles: const PosStyles(bold: false, align: PosAlign.center));
|
|
||||||
bytes += generator.text('Dine In',
|
|
||||||
styles: const PosStyles(bold: true, align: PosAlign.center));
|
|
||||||
bytes += generator.text(
|
|
||||||
paper == 80
|
|
||||||
? '------------------------------------------------'
|
|
||||||
: '--------------------------------',
|
|
||||||
styles: const PosStyles(bold: false, align: PosAlign.center));
|
|
||||||
for (final product in (order.orderItems ?? <OrderItem>[])) {
|
|
||||||
bytes += generator.row([
|
|
||||||
PosColumn(
|
|
||||||
text: '${product.quantity} x ${product.productName}',
|
|
||||||
width: 8,
|
|
||||||
styles: const PosStyles(bold: true, align: PosAlign.left),
|
|
||||||
),
|
|
||||||
PosColumn(
|
|
||||||
text: (product.totalPrice ?? 0).currencyFormatRpV2,
|
|
||||||
width: 4,
|
|
||||||
styles: const PosStyles(bold: true, align: PosAlign.right),
|
|
||||||
),
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
bytes += generator.text(
|
|
||||||
paper == 80
|
|
||||||
? '------------------------------------------------'
|
|
||||||
: '--------------------------------',
|
|
||||||
styles: const PosStyles(bold: false, align: PosAlign.center));
|
|
||||||
|
|
||||||
bytes += generator.row([
|
|
||||||
PosColumn(
|
|
||||||
text: 'Subtotal ${order.orderItems?.length ?? "0"} Product',
|
|
||||||
width: 6,
|
|
||||||
styles: const PosStyles(align: PosAlign.left),
|
|
||||||
),
|
|
||||||
PosColumn(
|
|
||||||
text: (order.subtotal ?? 0).currencyFormatRpV2,
|
|
||||||
width: 6,
|
|
||||||
styles: const PosStyles(align: PosAlign.right),
|
|
||||||
),
|
|
||||||
]);
|
|
||||||
|
|
||||||
bytes += generator.row([
|
|
||||||
PosColumn(
|
|
||||||
text: 'Discount',
|
|
||||||
width: 6,
|
|
||||||
styles: const PosStyles(align: PosAlign.left),
|
|
||||||
),
|
|
||||||
PosColumn(
|
|
||||||
text: (order.discountAmount ?? 0).currencyFormatRpV2,
|
|
||||||
width: 6,
|
|
||||||
styles: const PosStyles(align: PosAlign.right),
|
|
||||||
),
|
|
||||||
]);
|
|
||||||
|
|
||||||
// Only show tax if it's greater than 0
|
|
||||||
if ((order.taxAmount ?? 0) > 0) {
|
|
||||||
bytes += generator.row([
|
|
||||||
PosColumn(
|
|
||||||
text: 'Tax PB1 ($taxPercentage%)',
|
|
||||||
width: 6,
|
|
||||||
styles: const PosStyles(align: PosAlign.left),
|
|
||||||
),
|
|
||||||
PosColumn(
|
|
||||||
text: (order.taxAmount ?? 0).currencyFormatRpV2,
|
|
||||||
width: 6,
|
|
||||||
styles: const PosStyles(align: PosAlign.right),
|
|
||||||
),
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Only show service charge if it's greater than 0
|
|
||||||
// if (serviceCharge > 0) {
|
|
||||||
// bytes += generator.row([
|
|
||||||
// PosColumn(
|
|
||||||
// text: 'Service Charge($serviceChargePercentage%)',
|
|
||||||
// width: 6,
|
|
||||||
// styles: const PosStyles(align: PosAlign.left),
|
|
||||||
// ),
|
|
||||||
// PosColumn(
|
|
||||||
// text: serviceCharge.currencyFormatRpV2,
|
|
||||||
// width: 6,
|
|
||||||
// styles: const PosStyles(align: PosAlign.right),
|
|
||||||
// ),
|
|
||||||
// ]);
|
|
||||||
// }
|
|
||||||
bytes += generator.text(
|
|
||||||
paper == 80
|
|
||||||
? '------------------------------------------------'
|
|
||||||
: '--------------------------------',
|
|
||||||
styles: const PosStyles(bold: false, align: PosAlign.center));
|
|
||||||
bytes += generator.row([
|
|
||||||
PosColumn(
|
|
||||||
text: 'Total',
|
|
||||||
width: 6,
|
|
||||||
styles: const PosStyles(bold: true, align: PosAlign.left),
|
|
||||||
),
|
|
||||||
PosColumn(
|
|
||||||
text: '${order.totalAmount ?? ""}'.currencyFormatRpV2,
|
|
||||||
width: 6,
|
|
||||||
styles: const PosStyles(bold: true, align: PosAlign.right),
|
|
||||||
),
|
|
||||||
]);
|
|
||||||
bytes += generator.row([
|
|
||||||
PosColumn(
|
|
||||||
text: 'Dibayar',
|
|
||||||
width: 6,
|
|
||||||
styles: const PosStyles(align: PosAlign.left),
|
|
||||||
),
|
|
||||||
PosColumn(
|
|
||||||
text: nominalBayar.currencyFormatRpV2,
|
|
||||||
width: 6,
|
|
||||||
styles: const PosStyles(align: PosAlign.right),
|
|
||||||
),
|
|
||||||
]);
|
|
||||||
bytes += generator.row([
|
|
||||||
PosColumn(
|
|
||||||
text: 'Kembali',
|
|
||||||
width: 6,
|
|
||||||
styles: const PosStyles(align: PosAlign.left),
|
|
||||||
),
|
|
||||||
PosColumn(
|
|
||||||
text: kembalian.currencyFormatRpV2,
|
|
||||||
width: 6,
|
|
||||||
styles: const PosStyles(align: PosAlign.right),
|
|
||||||
),
|
|
||||||
]);
|
|
||||||
bytes += generator.text(
|
|
||||||
paper == 80
|
|
||||||
? '------------------------------------------------'
|
|
||||||
: '--------------------------------',
|
|
||||||
styles: const PosStyles(bold: false, align: PosAlign.center));
|
|
||||||
// bytes += generator.text('Notes',
|
|
||||||
// styles: const PosStyles(bold: false, align: PosAlign.center));
|
|
||||||
// bytes += generator.text('Pass Wifi: fic14jilid2',
|
|
||||||
// styles: const PosStyles(bold: false, align: PosAlign.center));
|
|
||||||
// //terima kasih
|
|
||||||
// bytes += generator.text('Terima Kasih',
|
|
||||||
// styles: const PosStyles(bold: true, align: PosAlign.center));
|
|
||||||
paper == 80 ? bytes += generator.feed(3) : bytes += generator.feed(1);
|
|
||||||
bytes += generator.cut();
|
|
||||||
return bytes;
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<List<int>> printQRIS(
|
Future<List<int>> printQRIS(
|
||||||
int totalPrice, Uint8List imageQris, int paper) async {
|
int totalPrice, Uint8List imageQris, int paper) async {
|
||||||
List<int> bytes = [];
|
List<int> bytes = [];
|
||||||
|
|||||||
@ -220,8 +220,7 @@ class OrderRemoteDatasource {
|
|||||||
return const Left('Gagal membuat pesanan');
|
return const Left('Gagal membuat pesanan');
|
||||||
}
|
}
|
||||||
} on DioException catch (e) {
|
} on DioException catch (e) {
|
||||||
final errorMessage =
|
final errorMessage = e.response?.data['message'] ?? 'Kesalahan jaringan';
|
||||||
e.response?.data['message'] ?? 'Terjadi kesalahan, coba lagi nanti.';
|
|
||||||
log("đź’Ą Dio error: ${e.message}");
|
log("đź’Ą Dio error: ${e.message}");
|
||||||
log("đź’Ą Dio response: ${e.response?.data}");
|
log("đź’Ą Dio response: ${e.response?.data}");
|
||||||
return Left(errorMessage);
|
return Left(errorMessage);
|
||||||
@ -255,8 +254,7 @@ class OrderRemoteDatasource {
|
|||||||
return const Left('Gagal membuat pembayaran');
|
return const Left('Gagal membuat pembayaran');
|
||||||
}
|
}
|
||||||
} on DioException catch (e) {
|
} on DioException catch (e) {
|
||||||
final errorMessage =
|
final errorMessage = e.response?.data['message'] ?? 'Kesalahan jaringan';
|
||||||
e.response?.data['message'] ?? 'Terjadi kesalahan, coba lagi nanti.';
|
|
||||||
log("đź’Ą Dio error: ${e.message}");
|
log("đź’Ą Dio error: ${e.message}");
|
||||||
log("đź’Ą Dio response: ${e.response?.data}");
|
log("đź’Ą Dio response: ${e.response?.data}");
|
||||||
return Left(errorMessage);
|
return Left(errorMessage);
|
||||||
@ -386,8 +384,7 @@ class OrderRemoteDatasource {
|
|||||||
return const Left('Gagal membuat pesanan');
|
return const Left('Gagal membuat pesanan');
|
||||||
}
|
}
|
||||||
} on DioException catch (e) {
|
} on DioException catch (e) {
|
||||||
final errorMessage =
|
final errorMessage = e.response?.data['message'] ?? 'Kesalahan jaringan';
|
||||||
e.response?.data['message'] ?? 'Terjadi kesalahan, coba lagi nanti.';
|
|
||||||
log("đź’Ą Dio error: ${e.message}");
|
log("đź’Ą Dio error: ${e.message}");
|
||||||
log("đź’Ą Dio response: ${e.response?.data}");
|
log("đź’Ą Dio response: ${e.response?.data}");
|
||||||
return Left(errorMessage);
|
return Left(errorMessage);
|
||||||
@ -427,8 +424,7 @@ class OrderRemoteDatasource {
|
|||||||
return const Left('Gagal menambahkan pesanan pesanan');
|
return const Left('Gagal menambahkan pesanan pesanan');
|
||||||
}
|
}
|
||||||
} on DioException catch (e) {
|
} on DioException catch (e) {
|
||||||
final errorMessage =
|
final errorMessage = e.response?.data['message'] ?? 'Kesalahan jaringan';
|
||||||
e.response?.data['message'] ?? 'Terjadi kesalahan, coba lagi nanti.';
|
|
||||||
log("đź’Ą Dio error: ${e.message}");
|
log("đź’Ą Dio error: ${e.message}");
|
||||||
log("đź’Ą Dio response: ${e.response?.data}");
|
log("đź’Ą Dio response: ${e.response?.data}");
|
||||||
return Left(errorMessage);
|
return Left(errorMessage);
|
||||||
@ -480,8 +476,7 @@ class OrderRemoteDatasource {
|
|||||||
return const Left('Gagal refund');
|
return const Left('Gagal refund');
|
||||||
}
|
}
|
||||||
} on DioException catch (e) {
|
} on DioException catch (e) {
|
||||||
final errorMessage =
|
final errorMessage = e.response?.data['message'] ?? 'Kesalahan jaringan';
|
||||||
e.response?.data['message'] ?? 'Terjadi kesalahan, coba lagi nanti.';
|
|
||||||
log("đź’Ą Dio error: ${e.message}");
|
log("đź’Ą Dio error: ${e.message}");
|
||||||
log("đź’Ą Dio response: ${e.response?.data}");
|
log("đź’Ą Dio response: ${e.response?.data}");
|
||||||
return Left(errorMessage);
|
return Left(errorMessage);
|
||||||
@ -529,8 +524,7 @@ class OrderRemoteDatasource {
|
|||||||
return const Left('Gagal refund');
|
return const Left('Gagal refund');
|
||||||
}
|
}
|
||||||
} on DioException catch (e) {
|
} on DioException catch (e) {
|
||||||
final errorMessage =
|
final errorMessage = e.response?.data['message'] ?? 'Kesalahan jaringan';
|
||||||
e.response?.data['message'] ?? 'Terjadi kesalahan, coba lagi nanti.';
|
|
||||||
log("đź’Ą Dio error: ${e.message}");
|
log("đź’Ą Dio error: ${e.message}");
|
||||||
log("đź’Ą Dio response: ${e.response?.data}");
|
log("đź’Ą Dio response: ${e.response?.data}");
|
||||||
return Left(errorMessage);
|
return Left(errorMessage);
|
||||||
|
|||||||
@ -69,35 +69,24 @@ class _OutletDialogState extends State<OutletDialog> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
SpaceHeight(24),
|
SpaceHeight(24),
|
||||||
BlocListener<UserUpdateOutletBloc, UserUpdateOutletState>(
|
BlocBuilder<UserUpdateOutletBloc, UserUpdateOutletState>(
|
||||||
listener: (context, state) {
|
builder: (context, state) {
|
||||||
state.maybeWhen(
|
return state.maybeWhen(
|
||||||
orElse: () {},
|
orElse: () => Button.filled(
|
||||||
success: () {
|
onPressed: selectedOutlet == null
|
||||||
context.pop();
|
? null
|
||||||
},
|
: () {
|
||||||
|
context.read<UserUpdateOutletBloc>().add(
|
||||||
|
UserUpdateOutletEvent.update(
|
||||||
|
selectedOutlet!.id ?? ""));
|
||||||
|
},
|
||||||
|
label: 'Terapkan',
|
||||||
|
),
|
||||||
|
loading: () => Center(
|
||||||
|
child: CircularProgressIndicator(),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
child:
|
|
||||||
BlocBuilder<UserUpdateOutletBloc, UserUpdateOutletState>(
|
|
||||||
builder: (context, state) {
|
|
||||||
return state.maybeWhen(
|
|
||||||
orElse: () => Button.filled(
|
|
||||||
onPressed: selectedOutlet == null
|
|
||||||
? null
|
|
||||||
: () {
|
|
||||||
context.read<UserUpdateOutletBloc>().add(
|
|
||||||
UserUpdateOutletEvent.update(
|
|
||||||
selectedOutlet!.id ?? ""));
|
|
||||||
},
|
|
||||||
label: 'Terapkan',
|
|
||||||
),
|
|
||||||
loading: () => Center(
|
|
||||||
child: CircularProgressIndicator(),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|||||||
@ -51,7 +51,7 @@ class VariantDialog extends StatelessWidget {
|
|||||||
Text(
|
Text(
|
||||||
(variant.priceModifier ?? 0).currencyFormatRpV2,
|
(variant.priceModifier ?? 0).currencyFormatRpV2,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: AppColors.black,
|
color: AppColors.grey,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|||||||
@ -961,23 +961,6 @@ class _ConfirmPaymentPageState extends State<ConfirmPaymentPage> {
|
|||||||
) =>
|
) =>
|
||||||
products,
|
products,
|
||||||
);
|
);
|
||||||
int tax = state.maybeWhen(
|
|
||||||
orElse: () => 0,
|
|
||||||
loaded: (
|
|
||||||
products,
|
|
||||||
discountModel,
|
|
||||||
discount,
|
|
||||||
discountAmount,
|
|
||||||
tax,
|
|
||||||
serviceCharge,
|
|
||||||
totalQuantity,
|
|
||||||
totalPrice,
|
|
||||||
draftName,
|
|
||||||
orderType,
|
|
||||||
deliveryType,
|
|
||||||
) =>
|
|
||||||
tax,
|
|
||||||
);
|
|
||||||
|
|
||||||
return Container(
|
return Container(
|
||||||
padding: EdgeInsets.all(16),
|
padding: EdgeInsets.all(16),
|
||||||
@ -1035,11 +1018,6 @@ class _ConfirmPaymentPageState extends State<ConfirmPaymentPage> {
|
|||||||
.pushReplacement(SuccessOrderPage(
|
.pushReplacement(SuccessOrderPage(
|
||||||
productQuantity: items,
|
productQuantity: items,
|
||||||
order: data,
|
order: data,
|
||||||
paymentMethod:
|
|
||||||
selectedPaymentMethod?.name ?? "",
|
|
||||||
nominalBayar: totalPriceController
|
|
||||||
.text.toIntegerFromText,
|
|
||||||
taxPercentage: tax,
|
|
||||||
));
|
));
|
||||||
},
|
},
|
||||||
error: (message) => AppFlushbar.showError(
|
error: (message) => AppFlushbar.showError(
|
||||||
|
|||||||
@ -127,6 +127,7 @@ class _HomePageState extends State<HomePage> {
|
|||||||
orElse: () {},
|
orElse: () {},
|
||||||
loading: () {},
|
loading: () {},
|
||||||
success: () {
|
success: () {
|
||||||
|
context.pop();
|
||||||
Future.delayed(Duration(milliseconds: 300), () {
|
Future.delayed(Duration(milliseconds: 300), () {
|
||||||
AppFlushbar.showSuccess(context, 'Outlet berhasil diubah');
|
AppFlushbar.showSuccess(context, 'Outlet berhasil diubah');
|
||||||
context
|
context
|
||||||
|
|||||||
@ -23,17 +23,15 @@ class ProductCard extends StatelessWidget {
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return GestureDetector(
|
return GestureDetector(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
if (data.isActive == true) {
|
if (data.variants!.isEmpty) {
|
||||||
if (data.variants!.isEmpty) {
|
context.read<CheckoutBloc>().add(
|
||||||
context.read<CheckoutBloc>().add(
|
CheckoutEvent.addItem(data, null),
|
||||||
CheckoutEvent.addItem(data, null),
|
);
|
||||||
);
|
} else {
|
||||||
} else {
|
showDialog(
|
||||||
showDialog(
|
context: context,
|
||||||
context: context,
|
builder: (context) => VariantDialog(product: data),
|
||||||
builder: (context) => VariantDialog(product: data),
|
);
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
child: Container(
|
child: Container(
|
||||||
@ -163,14 +161,6 @@ class ProductCard extends StatelessWidget {
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
if (data.isActive == false)
|
|
||||||
Container(
|
|
||||||
width: double.infinity,
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
borderRadius: BorderRadius.all(Radius.circular(8.0)),
|
|
||||||
color: AppColors.grey.withOpacity(0.5),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@ -11,18 +11,8 @@ import 'package:flutter/material.dart';
|
|||||||
class SuccessOrderPage extends StatefulWidget {
|
class SuccessOrderPage extends StatefulWidget {
|
||||||
final List<ProductQuantity> productQuantity;
|
final List<ProductQuantity> productQuantity;
|
||||||
final Order order;
|
final Order order;
|
||||||
final String paymentMethod;
|
const SuccessOrderPage(
|
||||||
final int nominalBayar;
|
{super.key, required this.order, required this.productQuantity});
|
||||||
final int taxPercentage;
|
|
||||||
|
|
||||||
const SuccessOrderPage({
|
|
||||||
super.key,
|
|
||||||
required this.order,
|
|
||||||
required this.productQuantity,
|
|
||||||
required this.paymentMethod,
|
|
||||||
required this.nominalBayar,
|
|
||||||
required this.taxPercentage,
|
|
||||||
});
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<SuccessOrderPage> createState() => _SuccessOrderPageState();
|
State<SuccessOrderPage> createState() => _SuccessOrderPageState();
|
||||||
@ -1001,15 +991,6 @@ class _SuccessOrderPageState extends State<SuccessOrderPage>
|
|||||||
child: InkWell(
|
child: InkWell(
|
||||||
borderRadius: BorderRadius.circular(16),
|
borderRadius: BorderRadius.circular(16),
|
||||||
onTap: () async {
|
onTap: () async {
|
||||||
onPrintRecipt(
|
|
||||||
context,
|
|
||||||
order: widget.order,
|
|
||||||
paymentMethod: widget.paymentMethod,
|
|
||||||
nominalBayar: widget.nominalBayar,
|
|
||||||
kembalian: widget.nominalBayar -
|
|
||||||
(widget.order.totalAmount ?? 0),
|
|
||||||
taxPercentage: widget.taxPercentage,
|
|
||||||
);
|
|
||||||
onPrint(
|
onPrint(
|
||||||
context,
|
context,
|
||||||
productQuantity: widget.productQuantity,
|
productQuantity: widget.productQuantity,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user