Compare commits
2 Commits
adbd0724af
...
ccebba6ba7
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ccebba6ba7 | ||
|
|
00bd4c417e |
@ -26,6 +26,8 @@ import com.utsmm.kbz.ui.core_viewmodel.SharedViewModel;
|
|||||||
import com.utsmm.kbz.util.DecimalDigitsInputFilter;
|
import com.utsmm.kbz.util.DecimalDigitsInputFilter;
|
||||||
import com.utsmm.kbz.util.TransactionUtil;
|
import com.utsmm.kbz.util.TransactionUtil;
|
||||||
|
|
||||||
|
import java.text.DecimalFormat;
|
||||||
|
|
||||||
|
|
||||||
public class QRRefundDetailFragment extends DataBindingFragment {
|
public class QRRefundDetailFragment extends DataBindingFragment {
|
||||||
|
|
||||||
@ -43,6 +45,8 @@ public class QRRefundDetailFragment extends DataBindingFragment {
|
|||||||
private EditText etReferenceNo, etOriginalAmount, etRefundAmount, etRefundReason;
|
private EditText etReferenceNo, etOriginalAmount, etRefundAmount, etRefundReason;
|
||||||
private LinearLayout originalAmountLayout, refundAmountLayout;
|
private LinearLayout originalAmountLayout, refundAmountLayout;
|
||||||
|
|
||||||
|
private String originalRefundAmount;
|
||||||
|
|
||||||
private boolean isPartialRefund = false;
|
private boolean isPartialRefund = false;
|
||||||
|
|
||||||
|
|
||||||
@ -122,6 +126,10 @@ public class QRRefundDetailFragment extends DataBindingFragment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void initData() {
|
private void initData() {
|
||||||
|
double realAmount = payDetail.getAmount() / 100.0;
|
||||||
|
DecimalFormat df = new DecimalFormat("0.00");
|
||||||
|
originalRefundAmount = df.format(realAmount);
|
||||||
|
|
||||||
payDetail = TransactionUtil.getInstance().initWalletTransaction(TransactionsType.MMQR_REFUND);
|
payDetail = TransactionUtil.getInstance().initWalletTransaction(TransactionsType.MMQR_REFUND);
|
||||||
payDetail.setInvoiceNo(SystemParamsOperation.getInstance().getIncrementInvoiceNum());
|
payDetail.setInvoiceNo(SystemParamsOperation.getInstance().getIncrementInvoiceNum());
|
||||||
|
|
||||||
@ -144,8 +152,8 @@ public class QRRefundDetailFragment extends DataBindingFragment {
|
|||||||
} else {
|
} else {
|
||||||
// Hide amount fields for original refund
|
// Hide amount fields for original refund
|
||||||
isPartialRefund = false;
|
isPartialRefund = false;
|
||||||
originalAmountLayout.setVisibility(View.GONE);
|
originalAmountLayout.setVisibility(View.VISIBLE);
|
||||||
refundAmountLayout.setVisibility(View.GONE);
|
refundAmountLayout.setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -162,6 +170,8 @@ public class QRRefundDetailFragment extends DataBindingFragment {
|
|||||||
|
|
||||||
String referenceNo = etReferenceNo.getText().toString().trim();
|
String referenceNo = etReferenceNo.getText().toString().trim();
|
||||||
String refundReason = etRefundReason.getText().toString().trim();
|
String refundReason = etRefundReason.getText().toString().trim();
|
||||||
|
String originalAmountStr = etOriginalAmount.getText().toString().trim();
|
||||||
|
String refundAmountStr = etRefundAmount.getText().toString().trim();
|
||||||
|
|
||||||
// Validate reference number
|
// Validate reference number
|
||||||
if (referenceNo.isEmpty()) {
|
if (referenceNo.isEmpty()) {
|
||||||
@ -171,8 +181,8 @@ public class QRRefundDetailFragment extends DataBindingFragment {
|
|||||||
|
|
||||||
if (isPartialRefund) {
|
if (isPartialRefund) {
|
||||||
// Partial refund validation
|
// Partial refund validation
|
||||||
String originalAmountStr = etOriginalAmount.getText().toString().trim();
|
// String originalAmountStr = etOriginalAmount.getText().toString().trim();
|
||||||
String refundAmountStr = etRefundAmount.getText().toString().trim();
|
// String refundAmountStr = etRefundAmount.getText().toString().trim();
|
||||||
|
|
||||||
if (originalAmountStr.isEmpty()) {
|
if (originalAmountStr.isEmpty()) {
|
||||||
kPayViewModel.invalidAmountMsg.setValue("Enter original amount");
|
kPayViewModel.invalidAmountMsg.setValue("Enter original amount");
|
||||||
@ -207,12 +217,16 @@ public class QRRefundDetailFragment extends DataBindingFragment {
|
|||||||
kPayViewModel.setQrRefund(qrRefund);
|
kPayViewModel.setQrRefund(qrRefund);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
QRRefund qrRefund = new QRRefund(referenceNo, "0", etOriginalAmount.getText().toString().trim(), refundReason);
|
// String originalAmountStr = etOriginalAmount.getText().toString().trim();
|
||||||
|
// String refundAmountStr = etRefundAmount.getText().toString().trim();
|
||||||
|
|
||||||
|
QRRefund qrRefund = new QRRefund(referenceNo, refundAmountStr, originalRefundAmount, refundReason);
|
||||||
|
|
||||||
kPayViewModel.setQrRefund(qrRefund);
|
kPayViewModel.setQrRefund(qrRefund);
|
||||||
}
|
}
|
||||||
sharedViewModel.transactionsType.setValue(TransactionsType.MMQR_REFUND);
|
sharedViewModel.transactionsType.setValue(TransactionsType.MMQR_REFUND);
|
||||||
kPayViewModel.setPayDetail(payDetail);
|
kPayViewModel.setPayDetail(payDetail);
|
||||||
|
// sharedViewModel.amount.setValue(refundAmountStr);
|
||||||
routeId = R.id.action_qrRefundDetail_inputPasswordFragment;
|
routeId = R.id.action_qrRefundDetail_inputPasswordFragment;
|
||||||
safeNavigateToRouteId();
|
safeNavigateToRouteId();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -127,7 +127,7 @@ public class QRRefundProcessFragment extends DataBindingFragment {
|
|||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
.subscribe(
|
.subscribe(
|
||||||
response -> {
|
response -> {
|
||||||
handleRefundResponse(response, referenceNo);
|
handleRefundResponse(response, referenceNo, originalAmount);
|
||||||
},
|
},
|
||||||
throwable -> {
|
throwable -> {
|
||||||
LogUtil.e(TAG, "Refund error: " + throwable.getMessage());
|
LogUtil.e(TAG, "Refund error: " + throwable.getMessage());
|
||||||
@ -141,14 +141,12 @@ public class QRRefundProcessFragment extends DataBindingFragment {
|
|||||||
refundDisposable.add(refundDi);
|
refundDisposable.add(refundDi);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleRefundResponse(KPayRefund.RefundResponse response, String referenceNo) {
|
private void handleRefundResponse(KPayRefund.RefundResponse response, String referenceNo, String orgAmount) {
|
||||||
if (response != null && response.getResponse() != null && "REFUND_SUCCESS".equalsIgnoreCase(response.getResponse().getRefundStatus())) {
|
if (response != null && response.getResponse() != null && "REFUND_SUCCESS".equalsIgnoreCase(response.getResponse().getRefundStatus())) {
|
||||||
LogUtil.d(TAG, "Refund successful!");
|
LogUtil.d(TAG, "Refund successful!");
|
||||||
|
|
||||||
String refundAmount = response.getResponse().getRefundAmount();
|
String refundAmount = response.getResponse().getRefundAmount();
|
||||||
Log.d(TAG, "refund amount -> " + refundAmount);
|
|
||||||
long text = POSUtil.getInstance().convertAmount(refundAmount);
|
long text = POSUtil.getInstance().convertAmount(refundAmount);
|
||||||
Log.d(TAG, "refund amount but long -> " + text);
|
|
||||||
|
|
||||||
String dateTime = SystemDateTime.getTodayDateFormat() + " " + SystemDateTime.getTodayTimeFormat();
|
String dateTime = SystemDateTime.getTodayDateFormat() + " " + SystemDateTime.getTodayTimeFormat();
|
||||||
payDetail.setTC(response.getResponse().getRefundStatus());
|
payDetail.setTC(response.getResponse().getRefundStatus());
|
||||||
@ -185,6 +183,7 @@ public class QRRefundProcessFragment extends DataBindingFragment {
|
|||||||
if (response != null && response.getResponse() != null && response.getResponse().getMsg() != null) {
|
if (response != null && response.getResponse() != null && response.getResponse().getMsg() != null) {
|
||||||
errorMsg = response.getResponse().getMsg();
|
errorMsg = response.getResponse().getMsg();
|
||||||
}
|
}
|
||||||
|
|
||||||
payDetail.setTradeResultDes(errorMsg);
|
payDetail.setTradeResultDes(errorMsg);
|
||||||
EReceiptRequest request = EReceiptUtil.getInstance().generateQRRefundReceipt(
|
EReceiptRequest request = EReceiptUtil.getInstance().generateQRRefundReceipt(
|
||||||
"0",
|
"0",
|
||||||
@ -196,7 +195,7 @@ public class QRRefundProcessFragment extends DataBindingFragment {
|
|||||||
TransResultStatus.FAIL
|
TransResultStatus.FAIL
|
||||||
);
|
);
|
||||||
sharedViewModel.pushReceipt(request);
|
sharedViewModel.pushReceipt(request);
|
||||||
|
sharedViewModel.amount.setValue(orgAmount);
|
||||||
sharedViewModel.payDetail.setValue(payDetail);
|
sharedViewModel.payDetail.setValue(payDetail);
|
||||||
navigateToNext();
|
navigateToNext();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -819,6 +819,8 @@ public abstract class BaseXPrint {
|
|||||||
print2ColumnsString("Refund Total:MMK", PrintUtils.getInstance().getSeparatorOnlyNumberFormat(refundTotal));
|
print2ColumnsString("Refund Total:MMK", PrintUtils.getInstance().getSeparatorOnlyNumberFormat(refundTotal));
|
||||||
dashBreak();
|
dashBreak();
|
||||||
print2ColumnsString("Sale Total :MMK", PrintUtils.getInstance().getSeparatorOnlyNumberFormat(totalAmount));
|
print2ColumnsString("Sale Total :MMK", PrintUtils.getInstance().getSeparatorOnlyNumberFormat(totalAmount));
|
||||||
|
dashBreak();
|
||||||
|
print2ColumnsString("Grand Total :MMK", PrintUtils.getInstance().getSeparatorOnlyNumberFormat(totalAmount - refundTotal));
|
||||||
dashBreakEnding();
|
dashBreakEnding();
|
||||||
// emptyLine(2);
|
// emptyLine(2);
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user