duel currency fix for detail report
This commit is contained in:
parent
175ebab148
commit
1aac919c47
@ -77,6 +77,35 @@
|
||||
tools:text="000045" />
|
||||
|
||||
</LinearLayout>
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:paddingVertical="4dp">
|
||||
|
||||
<TextView
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="Currency"
|
||||
android:textColor="@color/colorPrimary"
|
||||
android:textSize="13sp"
|
||||
android:fontFamily="monospace"
|
||||
android:textAlignment="center"
|
||||
tools:text="Currency" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="@{POSUtil.getInstance().currencyCodeToText(payDetail.currencyCode)}"
|
||||
android:textColor="@color/colorPrimary"
|
||||
android:textSize="13sp"
|
||||
android:fontFamily="monospace"
|
||||
android:textAlignment="center"
|
||||
tools:text="MMK" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<!-- Data Row 3: Transaction Type and Amount -->
|
||||
<LinearLayout
|
||||
|
||||
@ -45,6 +45,7 @@ import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
@ -856,30 +857,37 @@ public abstract class BaseXPrint {
|
||||
printer.appendPrnStr(new String(new char[29]).replace("\0", "."), fontNormal, AlignEnum.CENTER, false);
|
||||
}
|
||||
|
||||
class CurrencySummary {
|
||||
long total = 0;
|
||||
int count = 0;
|
||||
}
|
||||
protected void printTransDetailReport(List<PayDetail> lists, HostType hostType) {
|
||||
|
||||
|
||||
if (hostType == HostType.MPU || hostType == HostType.VISA_MASTER) {
|
||||
// Use the same line-by-line style as QR detail report
|
||||
} else if (hostType == HostType.QR) {
|
||||
// print2ColumnsString("PAYMENT NAME", "");
|
||||
// print2ColumnsString("DATE", "TIME");
|
||||
// print2ColumnsString("TRANSACTION", "TRACE NO");
|
||||
// print2ColumnsString("TRXN ID", "");
|
||||
// print2ColumnsString("AMOUNT", "");
|
||||
// ✅ Summary holder (total + count per currency)
|
||||
class CurrencySummary {
|
||||
long total = 0;
|
||||
int count = 0;
|
||||
}
|
||||
|
||||
|
||||
// breakingLine();
|
||||
|
||||
long totalAmount = 0;
|
||||
Map<String, CurrencySummary> currencyMap = new HashMap<>();
|
||||
|
||||
for (PayDetail pay : lists) {
|
||||
boolean isNeedMinusSign = pay.getTransactionType() == TransactionsType.VOID.value || pay.getTransactionType() == TransactionsType.REFUND.value || pay.getTransactionType() == TransactionsType.MMQR_REFUND.value;
|
||||
boolean isDecimalEnabled = SystemParamsOperation.getInstance().isQrDecimalEnable();
|
||||
|
||||
boolean isNeedMinusSign =
|
||||
pay.getTransactionType() == TransactionsType.VOID.value ||
|
||||
pay.getTransactionType() == TransactionsType.REFUND.value ||
|
||||
pay.getTransactionType() == TransactionsType.MMQR_REFUND.value;
|
||||
|
||||
boolean isDecimalEnabledQr = SystemParamsOperation.getInstance().isQrDecimalEnable();
|
||||
String currency = currencyCodeToText(pay.getCurrencyCode());
|
||||
|
||||
// =============================
|
||||
// PRINT DETAIL
|
||||
// =============================
|
||||
if (hostType == HostType.MPU || hostType == HostType.VISA_MASTER) {
|
||||
|
||||
boolean isDecimalEnabledCard = SystemParamsOperation.getInstance().getDecimalEnable();
|
||||
|
||||
printString("CARD TYPE:" + pay.getAccountType());
|
||||
printString("CARD NO :" + PrintUtils.getInstance().maskCardNumberPciDss(pay.getCardNo()));
|
||||
printString("TRACE NO :" + pay.getVoucherNo());
|
||||
@ -888,11 +896,10 @@ public abstract class BaseXPrint {
|
||||
printString("TYPE :" + pay.getTransType().replace("_", " "));
|
||||
printString("AMOUNT :" +
|
||||
(isNeedMinusSign
|
||||
? "-" + PrintUtils.getInstance()
|
||||
.getSeparatorNumberFormat(pay.getAmount(), isDecimalEnabledCard)
|
||||
: PrintUtils.getInstance()
|
||||
.getSeparatorNumberFormat(pay.getAmount(), isDecimalEnabledCard))
|
||||
+ " " + "MMK");
|
||||
? "-" + PrintUtils.getInstance().getSeparatorNumberFormat(pay.getAmount(), isDecimalEnabledCard)
|
||||
: PrintUtils.getInstance().getSeparatorNumberFormat(pay.getAmount(), isDecimalEnabledCard))
|
||||
+ " " + currency);
|
||||
|
||||
dotBreak();
|
||||
|
||||
} else if (hostType == HostType.QR) {
|
||||
@ -902,62 +909,86 @@ public abstract class BaseXPrint {
|
||||
printString("SOURCE :" +
|
||||
(pay.getTransactionType() == TransactionsType.MMQR_REFUND.value
|
||||
? "QR PAYMENT"
|
||||
: pay.getCustomerMobile())
|
||||
);
|
||||
// printString("TXN NAME:" + pay.getTransType().replace("_", " "));
|
||||
: pay.getCustomerMobile()));
|
||||
printString("DATE :" + POSUtil.getInstance().formatDisplayDate(pay.getTransDate()) + " " + pay.getTransTime());
|
||||
printString("TRACE NO:" + pay.getVoucherNo());
|
||||
|
||||
if (pay.getTransactionType() == TransactionsType.MMQR_REFUND.value) {
|
||||
printString("RRN :" + pay.getReferNo());
|
||||
}
|
||||
|
||||
printString("AMOUNT :" +
|
||||
(isNeedMinusSign
|
||||
? "-" + PrintUtils.getInstance()
|
||||
.getSeparatorNumberFormat(pay.getAmount(), isDecimalEnabled)
|
||||
: PrintUtils.getInstance()
|
||||
.getSeparatorNumberFormat(pay.getAmount(), isDecimalEnabled))
|
||||
+ " " +"MMK");
|
||||
? "-" + PrintUtils.getInstance().getSeparatorNumberFormat(pay.getAmount(), isDecimalEnabledQr)
|
||||
: PrintUtils.getInstance().getSeparatorNumberFormat(pay.getAmount(), isDecimalEnabledQr))
|
||||
+ " " + currency);
|
||||
|
||||
dotBreak();
|
||||
|
||||
// if (pay.getTransactionType() == TransactionsType.MMQR_REFUND.value) {
|
||||
// print2ColumnsString("QR PAYMENT", "");
|
||||
// } else {
|
||||
// print2ColumnsString(pay.getCustomerMobile(), "");
|
||||
// }
|
||||
// print2ColumnsString(pay.getTransDate(), pay.getTransTime());
|
||||
// print2ColumnsString(pay.getTransType().replace("_", " "), pay.getVoucherNo());
|
||||
// if (pay.getTransactionType() == TransactionsType.MMQR_REFUND.value) {
|
||||
// print2ColumnsString(pay.getReferNo() + "(RRN)", "");
|
||||
// print2ColumnsString(isNeedMinusSign ? "-" + PrintUtils.getInstance().getSeparatorNumberFormat(pay.getAmount(), isDecimalEnabled) : "" + PrintUtils.getInstance().getSeparatorNumberFormat(pay.getAmount(), isDecimalEnabled), "");
|
||||
// } else {
|
||||
// print2ColumnsString(pay.getQrTransId(), "");
|
||||
// print2ColumnsString(isNeedMinusSign ? "-" + PrintUtils.getInstance().getSeparatorNumberFormat(pay.getAmount(), isDecimalEnabled) : "" + PrintUtils.getInstance().getSeparatorNumberFormat(pay.getAmount(), isDecimalEnabled) , "");
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
emptyLine(1);
|
||||
|
||||
// =============================
|
||||
// ✅ ACCUMULATE TOTAL + COUNT PER CURRENCY
|
||||
// =============================
|
||||
CurrencySummary summary = currencyMap.getOrDefault(currency, new CurrencySummary());
|
||||
|
||||
if (isNeedMinusSign) {
|
||||
totalAmount -= pay.getAmount();
|
||||
summary.total -= pay.getAmount();
|
||||
} else {
|
||||
totalAmount += pay.getAmount();
|
||||
}
|
||||
summary.total += pay.getAmount();
|
||||
}
|
||||
|
||||
summary.count++; // ✅ count per currency
|
||||
|
||||
currencyMap.put(currency, summary);
|
||||
}
|
||||
|
||||
// =============================
|
||||
// PRINT SUMMARY
|
||||
// =============================
|
||||
if (hostType == HostType.MPU || hostType == HostType.VISA_MASTER) {
|
||||
|
||||
boolean isDecimalEnabled = SystemParamsOperation.getInstance().getDecimalEnable();
|
||||
|
||||
print2ColumnsString("CARD", "");
|
||||
print3ColumnsString("TYPE ", "COUNT", "AMOUNT");
|
||||
print3ColumnsString("CARD", " " + countStringFormat(lists.size()), "MMK " + PrintUtils.getInstance().getSeparatorNumberFormat(totalAmount, isDecimalEnabled), true);
|
||||
|
||||
for (Map.Entry<String, CurrencySummary> entry : currencyMap.entrySet()) {
|
||||
|
||||
String currency = entry.getKey();
|
||||
CurrencySummary summary = entry.getValue();
|
||||
|
||||
print3ColumnsString(
|
||||
"CARD",
|
||||
" " + countStringFormat(summary.count),
|
||||
currency + " " + PrintUtils.getInstance()
|
||||
.getSeparatorNumberFormat(summary.total, isDecimalEnabled),
|
||||
true
|
||||
);
|
||||
}
|
||||
|
||||
} else if (hostType == HostType.QR) {
|
||||
|
||||
boolean isDecimalEnabled = SystemParamsOperation.getInstance().isQrDecimalEnable();
|
||||
|
||||
print2ColumnsString("PAYMENT", "");
|
||||
print3ColumnsString("TYPE ", "COUNT", "AMOUNT");
|
||||
// emptyLine(1);
|
||||
print3ColumnsString("QR PAY", " "+ countStringFormat(lists.size()), "MMK " + PrintUtils.getInstance().getSeparatorNumberFormat(totalAmount, isDecimalEnabled), true);
|
||||
|
||||
for (Map.Entry<String, CurrencySummary> entry : currencyMap.entrySet()) {
|
||||
|
||||
String currency = entry.getKey();
|
||||
CurrencySummary summary = entry.getValue();
|
||||
|
||||
print3ColumnsString(
|
||||
"QR PAY",
|
||||
" " + countStringFormat(summary.count),
|
||||
currency + " " + PrintUtils.getInstance()
|
||||
.getSeparatorNumberFormat(summary.total, isDecimalEnabled),
|
||||
true
|
||||
);
|
||||
}
|
||||
}
|
||||
// emptyLine(2);
|
||||
}
|
||||
|
||||
protected void printQRSettlementTransDetail(List<QRSettleData> lists) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user