auto settlement fixed
This commit is contained in:
parent
2093fb214a
commit
962bfbc6c5
@ -19,3 +19,15 @@
|
|||||||
* show reversal status in trans records
|
* show reversal status in trans records
|
||||||
* error_slip_print enable/disable in tms
|
* error_slip_print enable/disable in tms
|
||||||
* auto_settlement enable/disable in tms
|
* auto_settlement enable/disable in tms
|
||||||
|
|
||||||
|
### version 3.5
|
||||||
|
* "always with you" in mob receipt logo
|
||||||
|
* "..." full width in both P2 and P3 preview screens
|
||||||
|
* JCB logo added in Card Capture Screen
|
||||||
|
* "-" in void, refund and cash adv amounts
|
||||||
|
* disable sale button if amount is 0 or 0.00
|
||||||
|
* changed date formats to dd/mm/yy to dd/mm/yyyy
|
||||||
|
* changed keyboard design in reprint any transactions
|
||||||
|
|
||||||
|
### version 3.6
|
||||||
|
* auto-settlement for both P2 and P3
|
||||||
@ -23,6 +23,7 @@
|
|||||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_DATA_SYNC" />
|
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_DATA_SYNC" />
|
||||||
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
|
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
|
||||||
<uses-permission android:name="android.permission.SCHEDULE_EXACT_ALARM" />
|
<uses-permission android:name="android.permission.SCHEDULE_EXACT_ALARM" />
|
||||||
|
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
|
||||||
|
|
||||||
<uses-permission android:name="android.permission.CAMERA" />
|
<uses-permission android:name="android.permission.CAMERA" />
|
||||||
|
|
||||||
@ -43,6 +44,11 @@
|
|||||||
android:supportsRtl="true"
|
android:supportsRtl="true"
|
||||||
android:theme="@style/Theme.MOBPOS">
|
android:theme="@style/Theme.MOBPOS">
|
||||||
<receiver android:name=".auto_settlement.AlarmReceiver" android:exported="false"/>
|
<receiver android:name=".auto_settlement.AlarmReceiver" android:exported="false"/>
|
||||||
|
<receiver android:name=".auto_settlement.BootReceiver" android:exported="true">
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.BOOT_COMPLETED" />
|
||||||
|
</intent-filter>
|
||||||
|
</receiver>
|
||||||
<service android:name=".auto_settlement.AutoSettleService" android:exported="false" android:foregroundServiceType="dataSync" />
|
<service android:name=".auto_settlement.AutoSettleService" android:exported="false" android:foregroundServiceType="dataSync" />
|
||||||
<activity
|
<activity
|
||||||
android:name="com.mob.utsmyanmar.MainActivity"
|
android:name="com.mob.utsmyanmar.MainActivity"
|
||||||
|
|||||||
@ -75,7 +75,7 @@ class MainActivity : ComponentActivity() {
|
|||||||
|
|
||||||
private fun scheduleSettlementAlarm() {
|
private fun scheduleSettlementAlarm() {
|
||||||
if (!SystemParamsOperation.getInstance().isAutoSettlement()) {
|
if (!SystemParamsOperation.getInstance().isAutoSettlement()) {
|
||||||
SettlementScheduler.schedule(this)
|
SettlementScheduler.cancel(this)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -91,6 +91,7 @@ class MainActivity : ComponentActivity() {
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
SettlementScheduler.scheduleFallback(this)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,16 @@
|
|||||||
|
package com.mob.utsmyanmar.auto_settlement
|
||||||
|
|
||||||
|
import android.content.BroadcastReceiver
|
||||||
|
import android.content.Context
|
||||||
|
import android.content.Intent
|
||||||
|
import sunmi.sunmiui.utils.LogUtil
|
||||||
|
|
||||||
|
class BootReceiver : BroadcastReceiver() {
|
||||||
|
override fun onReceive(context: Context?, intent: Intent?) {
|
||||||
|
if (intent?.action != Intent.ACTION_BOOT_COMPLETED) return
|
||||||
|
val appContext = context ?: return
|
||||||
|
|
||||||
|
LogUtil.d(BootReceiver::class.java.simpleName, "Boot completed, rescheduling settlement alarm")
|
||||||
|
SettlementScheduler.schedule(appContext)
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -11,6 +11,7 @@ import java.util.Calendar
|
|||||||
|
|
||||||
object SettlementScheduler {
|
object SettlementScheduler {
|
||||||
private const val FALLBACK_ALERT_TIME = "23:30:00"
|
private const val FALLBACK_ALERT_TIME = "23:30:00"
|
||||||
|
private const val REQUEST_CODE = 100
|
||||||
|
|
||||||
fun schedule(context: Context): Boolean {
|
fun schedule(context: Context): Boolean {
|
||||||
if (!SystemParamsOperation.getInstance().isAutoSettlement()) {
|
if (!SystemParamsOperation.getInstance().isAutoSettlement()) {
|
||||||
@ -24,15 +25,49 @@ object SettlementScheduler {
|
|||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S &&
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S &&
|
||||||
!alarmManager.canScheduleExactAlarms()
|
!alarmManager.canScheduleExactAlarms()
|
||||||
) {
|
) {
|
||||||
|
return scheduleFallback(context)
|
||||||
|
}
|
||||||
|
|
||||||
|
val calendar = nextAlarmCalendar() ?: return false
|
||||||
|
val pendingIntent = alarmPendingIntent(context)
|
||||||
|
|
||||||
|
alarmManager.setExactAndAllowWhileIdle(
|
||||||
|
AlarmManager.RTC_WAKEUP,
|
||||||
|
calendar.timeInMillis,
|
||||||
|
pendingIntent
|
||||||
|
)
|
||||||
|
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
fun scheduleFallback(context: Context): Boolean {
|
||||||
|
if (!SystemParamsOperation.getInstance().isAutoSettlement()) {
|
||||||
|
cancel(context)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
val configuredTime = parseTime(
|
val alarmManager =
|
||||||
// SystemParamsOperation.getInstance().clearBatchTime
|
context.getSystemService(Context.ALARM_SERVICE) as AlarmManager
|
||||||
"21:35:00"
|
|
||||||
) ?: parseTime(FALLBACK_ALERT_TIME)!!
|
|
||||||
|
|
||||||
val calendar = Calendar.getInstance().apply {
|
val calendar = nextAlarmCalendar() ?: return false
|
||||||
|
val pendingIntent = alarmPendingIntent(context)
|
||||||
|
|
||||||
|
alarmManager.setAndAllowWhileIdle(
|
||||||
|
AlarmManager.RTC_WAKEUP,
|
||||||
|
calendar.timeInMillis,
|
||||||
|
pendingIntent
|
||||||
|
)
|
||||||
|
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun nextAlarmCalendar(): Calendar? {
|
||||||
|
val configuredTime = parseTime(
|
||||||
|
SystemParamsOperation.getInstance().clearBatchTime
|
||||||
|
// "15:45:00"
|
||||||
|
) ?: parseTime(FALLBACK_ALERT_TIME) ?: return null
|
||||||
|
|
||||||
|
return Calendar.getInstance().apply {
|
||||||
set(Calendar.HOUR_OF_DAY, configuredTime.first)
|
set(Calendar.HOUR_OF_DAY, configuredTime.first)
|
||||||
set(Calendar.MINUTE, configuredTime.second)
|
set(Calendar.MINUTE, configuredTime.second)
|
||||||
set(Calendar.SECOND, configuredTime.third)
|
set(Calendar.SECOND, configuredTime.third)
|
||||||
@ -42,30 +77,18 @@ object SettlementScheduler {
|
|||||||
add(Calendar.DAY_OF_MONTH, 1)
|
add(Calendar.DAY_OF_MONTH, 1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun alarmPendingIntent(context: Context): PendingIntent {
|
||||||
|
val intent = Intent(context, AlarmReceiver::class.java)
|
||||||
|
|
||||||
val intent = Intent(
|
return PendingIntent.getBroadcast(
|
||||||
context,
|
context,
|
||||||
AlarmReceiver::class.java
|
REQUEST_CODE,
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
val pendingIntent = PendingIntent.getBroadcast(
|
|
||||||
context,
|
|
||||||
100,
|
|
||||||
intent,
|
intent,
|
||||||
PendingIntent.FLAG_UPDATE_CURRENT or
|
PendingIntent.FLAG_UPDATE_CURRENT or
|
||||||
PendingIntent.FLAG_IMMUTABLE
|
PendingIntent.FLAG_IMMUTABLE
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
alarmManager.setExactAndAllowWhileIdle(
|
|
||||||
AlarmManager.RTC_WAKEUP,
|
|
||||||
calendar.timeInMillis,
|
|
||||||
pendingIntent
|
|
||||||
)
|
|
||||||
|
|
||||||
return true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun parseTime(value: String): Triple<Int, Int, Int>? {
|
private fun parseTime(value: String): Triple<Int, Int, Int>? {
|
||||||
|
|||||||
@ -3,6 +3,8 @@ package com.mob.utsmyanmar.ui.dashboard
|
|||||||
import android.os.Build
|
import android.os.Build
|
||||||
import android.os.Handler
|
import android.os.Handler
|
||||||
import android.os.Looper
|
import android.os.Looper
|
||||||
|
import androidmads.library.qrgenearator.QRGContents
|
||||||
|
import androidmads.library.qrgenearator.QRGEncoder
|
||||||
import androidx.annotation.RequiresApi
|
import androidx.annotation.RequiresApi
|
||||||
import androidx.compose.foundation.Image
|
import androidx.compose.foundation.Image
|
||||||
import androidx.compose.foundation.background
|
import androidx.compose.foundation.background
|
||||||
@ -46,6 +48,7 @@ import androidx.compose.runtime.setValue
|
|||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.draw.clip
|
import androidx.compose.ui.draw.clip
|
||||||
|
import androidx.compose.ui.graphics.asImageBitmap
|
||||||
import androidx.compose.ui.layout.ContentScale
|
import androidx.compose.ui.layout.ContentScale
|
||||||
import androidx.compose.ui.res.painterResource
|
import androidx.compose.ui.res.painterResource
|
||||||
import androidx.compose.ui.text.font.FontWeight
|
import androidx.compose.ui.text.font.FontWeight
|
||||||
@ -359,6 +362,38 @@ fun DashboardScreen2(
|
|||||||
trailingIcon = {},
|
trailingIcon = {},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Spacer(modifier = Modifier.height(16.dp))
|
||||||
|
val adUrl = "https://www.mobmyanmar.com/"
|
||||||
|
val qrBitmap = remember {
|
||||||
|
runCatching {
|
||||||
|
val encoder = QRGEncoder(adUrl, null, QRGContents.Type.TEXT, 256)
|
||||||
|
encoder.colorBlack = android.graphics.Color.BLACK
|
||||||
|
encoder.colorWhite = android.graphics.Color.WHITE
|
||||||
|
encoder.bitmap.asImageBitmap()
|
||||||
|
}.getOrNull()
|
||||||
|
}
|
||||||
|
qrBitmap?.let { bitmap ->
|
||||||
|
Column(
|
||||||
|
horizontalAlignment = Alignment.CenterHorizontally,
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.padding(horizontal = 16.dp)
|
||||||
|
) {
|
||||||
|
Image(
|
||||||
|
bitmap = bitmap,
|
||||||
|
contentDescription = "Scan for User Guide",
|
||||||
|
modifier = Modifier.size(150.dp)
|
||||||
|
)
|
||||||
|
Spacer(modifier = Modifier.height(4.dp))
|
||||||
|
Text(
|
||||||
|
text = "Scan for Offers",
|
||||||
|
style = MaterialTheme.typography.labelSmall,
|
||||||
|
color = Color.Gray
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Spacer(modifier = Modifier.height(8.dp))
|
||||||
|
|
||||||
Spacer(modifier = Modifier.weight(1f))
|
Spacer(modifier = Modifier.weight(1f))
|
||||||
Text(
|
Text(
|
||||||
text = "v${BuildConfig.VERSION_NAME}",
|
text = "v${BuildConfig.VERSION_NAME}",
|
||||||
|
|||||||
@ -436,7 +436,14 @@ fun AppNavGraph(
|
|||||||
SettlementScreen(
|
SettlementScreen(
|
||||||
sharedViewModel = sharedViewModel,
|
sharedViewModel = sharedViewModel,
|
||||||
settlementViewMode = settlementViewMode,
|
settlementViewMode = settlementViewMode,
|
||||||
onBack = { navController.popBackStack(Routes.Dashboard.route,false) },
|
onBack = {
|
||||||
|
onAutoSettlementHandled()
|
||||||
|
if (!navController.popBackStack(Routes.Dashboard.route, false)) {
|
||||||
|
navController.navigate(Routes.Dashboard.route) {
|
||||||
|
launchSingleTop = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
autoStartSettlement = autoSettlementRequested,
|
autoStartSettlement = autoSettlementRequested,
|
||||||
onStartSettlement = {
|
onStartSettlement = {
|
||||||
sharedViewModel.transactionsType.value = TransactionsType.SETTLEMENT
|
sharedViewModel.transactionsType.value = TransactionsType.SETTLEMENT
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user