perubahan denomuretor on pos sale
This commit is contained in:
@@ -5,7 +5,6 @@ import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:flutter_svg/flutter_svg.dart';
|
||||
import 'package:flutter_typeahead/flutter_typeahead.dart';
|
||||
import 'package:mobile_pos/constant.dart';
|
||||
import 'package:mobile_pos/currency.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
import '../../Const/api_config.dart';
|
||||
@@ -33,6 +32,16 @@ import '../../model/business_info_model.dart';
|
||||
import '../Home/home.dart';
|
||||
import '../../Provider/profile_provider.dart';
|
||||
|
||||
/// Format a number as Indonesian Rupiah for display only.
|
||||
/// Example: 12500.75 → "Rp 12.500"
|
||||
String formatRupiah(num value) {
|
||||
final intStr = value.round().toString().replaceAllMapped(
|
||||
RegExp(r'(\d)(?=(\d{3})+(?!\d))'),
|
||||
(m) => '${m[1]}.',
|
||||
);
|
||||
return 'Rp $intStr';
|
||||
}
|
||||
|
||||
class PosSaleScreen extends ConsumerStatefulWidget {
|
||||
const PosSaleScreen({super.key});
|
||||
|
||||
@@ -272,7 +281,7 @@ class _PosSaleScreenState extends ConsumerState<PosSaleScreen> {
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Text(
|
||||
'(${providerData.cartItemList.length} Items): $currency${providerData.getTotalAmount()}',
|
||||
'(${providerData.cartItemList.length} Items): ${formatRupiah(num.tryParse(providerData.getTotalAmount().toString()) ?? 0)}',
|
||||
style: const TextStyle(color: Colors.white, fontSize: 14),
|
||||
),
|
||||
],
|
||||
@@ -900,26 +909,26 @@ class _PosSaleScreenState extends ConsumerState<PosSaleScreen> {
|
||||
),
|
||||
Text(
|
||||
() {
|
||||
// Update: Price Display Logic
|
||||
// Display-only: format as Indonesian Rupiah (Rp x.xxx.xxx,xx)
|
||||
if (isCombo) {
|
||||
return '$currency${product.productSalePrice ?? 0}';
|
||||
return formatRupiah(product.productSalePrice ?? 0);
|
||||
}
|
||||
|
||||
final customerType = selectedCustomer?.type ?? '';
|
||||
final stock = product.stocks?.isNotEmpty == true ? product.stocks!.last : null;
|
||||
|
||||
if (stock == null) return '$currency${0.00}';
|
||||
if (stock == null) return formatRupiah(0);
|
||||
|
||||
if (customerType.contains('Retailer')) {
|
||||
return '$currency${stock.productSalePrice ?? 0}';
|
||||
return formatRupiah(stock.productSalePrice ?? 0);
|
||||
} else if (customerType.contains('Dealer')) {
|
||||
return '$currency${stock.productDealerPrice ?? 0}';
|
||||
return formatRupiah(stock.productDealerPrice ?? 0);
|
||||
} else if (customerType.contains('Wholesaler')) {
|
||||
return '$currency${stock.productWholeSalePrice ?? 0}';
|
||||
return formatRupiah(stock.productWholeSalePrice ?? 0);
|
||||
} else if (customerType.contains('Supplier')) {
|
||||
return '$currency${stock.productPurchasePrice ?? 0}';
|
||||
return formatRupiah(stock.productPurchasePrice ?? 0);
|
||||
} else {
|
||||
return '$currency${stock.productSalePrice ?? 0}';
|
||||
return formatRupiah(stock.productSalePrice ?? 0);
|
||||
}
|
||||
}(),
|
||||
style: _theme.textTheme.titleSmall?.copyWith(
|
||||
@@ -1113,7 +1122,7 @@ class _PosSaleScreenState extends ConsumerState<PosSaleScreen> {
|
||||
|
||||
// 5. Value Original
|
||||
Text(
|
||||
'$currency${originalTotal.toStringAsFixed(2)}',
|
||||
formatRupiah(originalTotal),
|
||||
style: TextStyle(
|
||||
color: kSubPeraColor,
|
||||
fontSize: 12,
|
||||
@@ -1124,7 +1133,7 @@ class _PosSaleScreenState extends ConsumerState<PosSaleScreen> {
|
||||
// 6. Value VAT/Tax
|
||||
if (itemVAT > 0) ...[
|
||||
Text(
|
||||
'VAT: $currency${itemVAT.toStringAsFixed(2)}',
|
||||
'VAT: ${formatRupiah(itemVAT)}',
|
||||
style: TextStyle(
|
||||
color: kSubPeraColor,
|
||||
fontSize: 10,
|
||||
@@ -1135,7 +1144,7 @@ class _PosSaleScreenState extends ConsumerState<PosSaleScreen> {
|
||||
|
||||
// 7. Sum (Value Original + VAT/Tax)
|
||||
Text(
|
||||
'$currency${finalTotal.toStringAsFixed(2)}',
|
||||
formatRupiah(finalTotal),
|
||||
style: const TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
color: kMainColor,
|
||||
@@ -1198,7 +1207,7 @@ class _PosSaleScreenState extends ConsumerState<PosSaleScreen> {
|
||||
child: FittedBox(
|
||||
fit: BoxFit.scaleDown,
|
||||
child: Text(
|
||||
'$currency${providerData.getTotalAmount()}',
|
||||
formatRupiah(num.tryParse(providerData.getTotalAmount().toString()) ?? 0),
|
||||
style: const TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.bold,
|
||||
|
||||
Reference in New Issue
Block a user