perubahan denomuretor on pos sale

This commit is contained in:
2026-04-04 23:44:16 +07:00
parent 517ed3bea3
commit d912b1f63a
20 changed files with 350 additions and 142 deletions

View File

@@ -16,7 +16,6 @@ import '../../Const/api_config.dart';
import '../../GlobalComponents/glonal_popup.dart';
import '../../constant.dart' as mainConstant;
import '../../constant.dart';
import '../../currency.dart';
import '../../model/business_info_model.dart' as binfo;
import '../../model/sale_transaction_model.dart';
import '../../thermal priting invoices/model/print_transaction_model.dart';
@@ -28,6 +27,16 @@ import '../language/language_provider.dart';
import '../../Provider/product_provider.dart';
import '../Home/home.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 SalesInvoiceDetails extends StatefulWidget {
const SalesInvoiceDetails({
super.key,
@@ -654,7 +663,7 @@ class _SalesInvoiceDetailsState extends State<SalesInvoiceDetails> {
Expanded(
flex: 2,
child: Text(
'$currency${mainConstant.formatPointNumber(saleDetail.discount ?? 0, addComma: true)}',
_formatRupiah(saleDetail.discount ?? 0),
textAlign: TextAlign.center,
style: _theme.textTheme.titleLarge?.copyWith(
fontWeight: FontWeight.w500,
@@ -678,7 +687,7 @@ class _SalesInvoiceDetailsState extends State<SalesInvoiceDetails> {
Expanded(
flex: 2,
child: Text(
'$currency${mainConstant.formatPointNumber(totalPrice, addComma: true)}',
_formatRupiah(totalPrice),
style: _theme.textTheme.bodyLarge?.copyWith(
fontWeight: FontWeight.w600,
fontSize: fontSizeForPrinter(widget.businessInfo.data?.invoiceSize),
@@ -702,7 +711,7 @@ class _SalesInvoiceDetailsState extends State<SalesInvoiceDetails> {
text: '${lang.S.of(context).subTotal} : ',
children: [
TextSpan(
text: '$currency${mainConstant.formatPointNumber(getTotalForOldInvoice())}',
text: _formatRupiah(getTotalForOldInvoice()),
),
],
),
@@ -726,11 +735,11 @@ class _SalesInvoiceDetailsState extends State<SalesInvoiceDetails> {
),
children: [
TextSpan(
text: '$currency${mainConstant.formatPointNumber(
text: _formatRupiah(
(widget.saleTransaction.discountAmount ?? 0) +
getReturndDiscountAmount() +
getTotalItemDiscount(),
)}',
),
),
],
),
@@ -754,7 +763,7 @@ class _SalesInvoiceDetailsState extends State<SalesInvoiceDetails> {
),
children: [
TextSpan(
text: '$currency${mainConstant.formatPointNumber(widget.saleTransaction.vatAmount ?? 0)}',
text: _formatRupiah(widget.saleTransaction.vatAmount ?? 0),
),
],
),
@@ -778,8 +787,7 @@ class _SalesInvoiceDetailsState extends State<SalesInvoiceDetails> {
),
children: [
TextSpan(
text:
'$currency${mainConstant.formatPointNumber(widget.saleTransaction.shippingCharge ?? 0)}',
text: _formatRupiah(widget.saleTransaction.shippingCharge ?? 0),
),
],
),
@@ -808,8 +816,7 @@ class _SalesInvoiceDetailsState extends State<SalesInvoiceDetails> {
),
children: [
TextSpan(
text:
'$currency${mainConstant.formatPointNumber(widget.saleTransaction.actualTotalAmount ?? 0)}',
text: _formatRupiah(widget.saleTransaction.actualTotalAmount ?? 0),
),
],
),
@@ -834,7 +841,7 @@ class _SalesInvoiceDetailsState extends State<SalesInvoiceDetails> {
children: [
TextSpan(
text:
'$currency${!(widget.saleTransaction.roundingAmount?.isNegative ?? true) ? '+' : ''}${mainConstant.formatPointNumber(widget.saleTransaction.roundingAmount ?? 0)}',
'${!(widget.saleTransaction.roundingAmount?.isNegative ?? true) ? '+' : ''}${_formatRupiah(widget.saleTransaction.roundingAmount ?? 0)}',
),
],
),
@@ -857,8 +864,7 @@ class _SalesInvoiceDetailsState extends State<SalesInvoiceDetails> {
text: '${lang.S.of(context).totalAmount} : ',
children: [
TextSpan(
text:
'$currency${mainConstant.formatPointNumber(getTotalReturndAmount() + (widget.saleTransaction.totalAmount ?? 0))}',
text: _formatRupiah(getTotalReturndAmount() + (widget.saleTransaction.totalAmount ?? 0)),
),
],
),
@@ -1023,7 +1029,7 @@ class _SalesInvoiceDetailsState extends State<SalesInvoiceDetails> {
Expanded(
flex: 2,
child: Text(
'$currency${(widget.saleTransaction.salesReturns?[i].salesReturnDetails?[detailIndex].returnAmount ?? 0)}',
_formatRupiah(widget.saleTransaction.salesReturns?[i].salesReturnDetails?[detailIndex].returnAmount ?? 0),
textAlign: TextAlign.end,
style: _theme.textTheme.bodyLarge?.copyWith(
fontWeight: FontWeight.w600,
@@ -1048,7 +1054,7 @@ class _SalesInvoiceDetailsState extends State<SalesInvoiceDetails> {
text: '${lang.S.of(context).totalReturnAmount} : ',
children: [
TextSpan(
text: '$currency${mainConstant.formatPointNumber(getTotalReturndAmount())}',
text: _formatRupiah(getTotalReturndAmount()),
),
],
),
@@ -1069,8 +1075,7 @@ class _SalesInvoiceDetailsState extends State<SalesInvoiceDetails> {
style: const TextStyle(fontWeight: FontWeight.w600),
children: [
TextSpan(
text:
'$currency${mainConstant.formatPointNumber(widget.saleTransaction.totalAmount ?? 0)}',
text: _formatRupiah(widget.saleTransaction.totalAmount ?? 0),
),
],
),
@@ -1090,8 +1095,11 @@ class _SalesInvoiceDetailsState extends State<SalesInvoiceDetails> {
text: '${lang.S.of(context).receivedAmount} : ',
children: [
TextSpan(
text:
'$currency${mainConstant.formatPointNumber(((widget.saleTransaction.totalAmount ?? 0) - (widget.saleTransaction.dueAmount ?? 0)) + (widget.saleTransaction.changeAmount ?? 0))}',
text: _formatRupiah(
((widget.saleTransaction.totalAmount ?? 0) -
(widget.saleTransaction.dueAmount ?? 0)) +
(widget.saleTransaction.changeAmount ?? 0),
),
),
],
),
@@ -1113,8 +1121,7 @@ class _SalesInvoiceDetailsState extends State<SalesInvoiceDetails> {
text: '${lang.S.of(context).due} : ',
children: [
TextSpan(
text:
'$currency${mainConstant.formatPointNumber(widget.saleTransaction.dueAmount ?? 0)}',
text: _formatRupiah(widget.saleTransaction.dueAmount ?? 0),
),
],
),
@@ -1136,8 +1143,7 @@ class _SalesInvoiceDetailsState extends State<SalesInvoiceDetails> {
text: '${_lang.changeAmount} : ',
children: [
TextSpan(
text:
'$currency${mainConstant.formatPointNumber(widget.saleTransaction.changeAmount ?? 0)}',
text: _formatRupiah(widget.saleTransaction.changeAmount ?? 0),
),
],
),