(KEY_SETTLEMENT_METHOD)
22 | }
23 |
24 | return settlementMethod ?: defaultSettlementMethod
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/main/java/ru/evotor/framework/core/action/event/receipt/payment/system/result/PaymentSystemPaymentErrorResult.kt:
--------------------------------------------------------------------------------
1 | package ru.evotor.framework.core.action.event.receipt.payment.system.result
2 |
3 | import android.os.Bundle
4 |
5 | class PaymentSystemPaymentErrorResult(
6 | val errorDescription: String?
7 | ) : PaymentSystemPaymentResult(ResultType.ERROR) {
8 | override fun toBundle(): Bundle {
9 | val result = super.toBundle()
10 | result.putString(KEY_ERROR_DESCRIPTION, errorDescription)
11 | return result
12 | }
13 |
14 | companion object {
15 | private val KEY_ERROR_DESCRIPTION = "errorDescription"
16 |
17 | fun create(bundle: Bundle?): PaymentSystemPaymentErrorResult? {
18 | if (bundle == null) {
19 | return null
20 | }
21 | val errorDescription = bundle.getString(KEY_ERROR_DESCRIPTION, null)
22 | return PaymentSystemPaymentErrorResult(errorDescription)
23 | }
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/src/main/java/ru/evotor/framework/receipt/print_extras/PrintExtraPlacePositionAllSubpositionsFooter.kt:
--------------------------------------------------------------------------------
1 | package ru.evotor.framework.receipt.print_extras
2 |
3 | import android.os.Bundle
4 |
5 | /**
6 | * Печатная информация будет добавлена после позиции в чеке и после всех её модификаторов (подпозиций)
7 | */
8 | class PrintExtraPlacePositionAllSubpositionsFooter(
9 | val positionUuid: String?
10 | ) : PrintExtraPlace(PrintExtraPlaceType.POSITION_ALL_SUBPOSITIONS_FOOTER) {
11 | companion object {
12 | val KEY_POSITION_UUID = "positionUuid"
13 |
14 | fun addToBundle(bundle: Bundle, place: PrintExtraPlacePositionAllSubpositionsFooter): Bundle =
15 | bundle.apply { putString(KEY_POSITION_UUID, place.positionUuid) }
16 |
17 | fun fromBundle(bundle: Bundle): PrintExtraPlacePositionAllSubpositionsFooter? =
18 | bundle.getString(KEY_POSITION_UUID)?.let {
19 | PrintExtraPlacePositionAllSubpositionsFooter(it)
20 | }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/src/main/java/ru/evotor/framework/device/scanner/event/BarcodeScanRequestedEvent.kt:
--------------------------------------------------------------------------------
1 | package ru.evotor.framework.device.scanner.event
2 |
3 | import android.os.Bundle
4 | import ru.evotor.framework.common.event.IntegrationEvent
5 |
6 | class BarcodeScanRequestedEvent : IntegrationEvent() {
7 | override fun toBundle() = Bundle()
8 |
9 | class Result(val barcode: String) : IntegrationEvent.Result() {
10 | override fun toBundle() = Bundle().apply {
11 | putString(KEY_BARCODE, barcode)
12 | }
13 |
14 | companion object {
15 | private const val KEY_BARCODE = "BARCODE"
16 |
17 | @JvmStatic
18 | fun from(bundle: Bundle?) = bundle?.let {
19 | Result(it.getString(KEY_BARCODE) ?: return@let null)
20 | }
21 | }
22 | }
23 |
24 | companion object {
25 | @JvmStatic
26 | fun from(bundle: Bundle?) = bundle?.let {
27 | BarcodeScanRequestedEvent()
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/src/main/java/ru/evotor/framework/core/action/event/receipt/merges/PositionsMergeEventResult.kt:
--------------------------------------------------------------------------------
1 | package ru.evotor.framework.core.action.event.receipt.merges
2 |
3 | import android.os.Bundle
4 | import ru.evotor.IBundlable
5 | import ru.evotor.framework.core.action.event.receipt.changes.receipt.SetExtra
6 |
7 | /**
8 | * Created by ivan on 26.06.17.
9 | */
10 |
11 | class PositionsMergeEventResult(val extra: SetExtra?) : IBundlable {
12 | override fun toBundle(): Bundle {
13 | val result = Bundle()
14 | result.putBundle(KEY_RECEIPT_EXTRA, extra?.toBundle())
15 | return result
16 | }
17 |
18 | companion object {
19 | private val KEY_RECEIPT_EXTRA = "extra"
20 |
21 | fun create(bundle: Bundle?): PositionsMergeEventResult? {
22 | return if (bundle == null) {
23 | null
24 | } else {
25 | PositionsMergeEventResult(SetExtra.from(bundle.getBundle(KEY_RECEIPT_EXTRA)))
26 | }
27 | }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/main/java/ru/evotor/framework/core/action/event/cash_drawer/CashDrawerOpenEvent.java:
--------------------------------------------------------------------------------
1 | package ru.evotor.framework.core.action.event.cash_drawer;
2 |
3 |
4 | import android.os.Bundle;
5 |
6 | import androidx.annotation.NonNull;
7 | import androidx.annotation.Nullable;
8 |
9 | /**
10 | * @deprecated Используйте {@link ru.evotor.framework.device.cash_drawer.event.CashDrawerOpenedEvent}
11 | */
12 | @Deprecated
13 | public class CashDrawerOpenEvent extends CashDrawerEvent {
14 | public static final String BROADCAST_ACTION_CASH_DRAWER_OPEN = "evotor.intent.action.cashDrawer.OPEN";
15 |
16 | public CashDrawerOpenEvent(int cashDrawerId) {
17 | super(cashDrawerId);
18 | }
19 |
20 | private CashDrawerOpenEvent(@NonNull Bundle extras) {
21 | super(extras);
22 | }
23 |
24 | @Nullable
25 | public static CashDrawerOpenEvent create(@Nullable Bundle bundle) {
26 | if (bundle == null) {
27 | return null;
28 | }
29 | return new CashDrawerOpenEvent(bundle);
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /Users/a.kuznetsov/Library/Android/sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
19 | # Uncomment this to preserve the line number information for
20 | # debugging stack traces.
21 | #-keepattributes SourceFile,LineNumberTable
22 |
23 | # If you keep the line number information, uncomment this to
24 | # hide the original source file name.
25 | #-renamesourcefileattribute SourceFile
26 |
--------------------------------------------------------------------------------
/src/main/java/ru/evotor/framework/device/scanner/event/handler/service/ScannerIntegrationService.kt:
--------------------------------------------------------------------------------
1 | package ru.evotor.framework.device.scanner.event.handler.service
2 |
3 | import android.os.Bundle
4 | import ru.evotor.framework.common.event.handler.service.IntegrationServiceV2
5 | import ru.evotor.framework.core.RequiresIntentAction
6 | import ru.evotor.framework.device.scanner.event.BarcodeScanRequestedEvent
7 |
8 | abstract class ScannerIntegrationService : IntegrationServiceV2() {
9 | @RequiresIntentAction(ACTION_BARCODE_SCAN_REQUEST)
10 | abstract fun handleBarcodeScanRequestedEvent(event: BarcodeScanRequestedEvent): BarcodeScanRequestedEvent.Result?
11 |
12 | override fun onEvent(action: String, bundle: Bundle) = when (action) {
13 | ACTION_BARCODE_SCAN_REQUEST -> BarcodeScanRequestedEvent.from(bundle)?.let { handleBarcodeScanRequestedEvent(it) }
14 | else -> null
15 | }
16 |
17 | companion object {
18 | const val ACTION_BARCODE_SCAN_REQUEST = "evotor.intent.action.BARCODE_SCAN_REQUEST"
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/src/main/java/ru/evotor/framework/core/RequiresIntentAction.kt:
--------------------------------------------------------------------------------
1 | package ru.evotor.framework.core
2 |
3 | /**
4 | * Прикрепляется к обработчикам событий широковещательного приёмника и интеграционного сервиса.
5 | * Означает, что если вы собираетесь реализовать аннотированный метод, вам нужно зарегистрировать
6 | * ваш широковещательный приёмник с указанным действием в intent-filter. Пример
7 | * регистрации широковещательного приёмника с действием
8 | * evotor.intent.action.receipt.sell.OPENED:
9 | *
10 | * {@code
11 | *
15 | *
16 | *
17 | *
18 | *
19 | *
20 | * }
21 | *
22 | */
23 | internal annotation class RequiresIntentAction(
24 | /**
25 | * Действие
26 | */
27 | val action: String
28 | )
29 |
--------------------------------------------------------------------------------
/src/main/java/ru/evotor/framework/core/action/event/receipt/error_card_payment/ErrorPaymentByCardEvent.kt:
--------------------------------------------------------------------------------
1 | package ru.evotor.framework.core.action.event.receipt.error_card_payment
2 |
3 | import android.os.Bundle
4 | import ru.evotor.IBundlable
5 |
6 | class ErrorPaymentByCardEvent : IBundlable {
7 | override fun toBundle(): Bundle {
8 | return Bundle()
9 | }
10 |
11 | companion object {
12 | /**
13 | * Разрешение для обработки события ошибки безналичной платежной системы
14 | *
15 | * Указывайте разрешение в манифесте приложения, в элементе `` до элемента ``.
16 | */
17 | const val NAME_PERMISSION = "ru.evotor.permission.handle.ERROR_PAYMENT_BY_CARD"
18 | const val NAME = "evo.v2.receipt.errorPaymentByCard"
19 |
20 | fun create(bundle: Bundle?): ErrorPaymentByCardEvent? {
21 | if (bundle == null) {
22 | return null
23 | }
24 | return ErrorPaymentByCardEvent()
25 | }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/main/java/ru/evotor/framework/core/action/event/receipt/discount/ReceiptDiscountEventProcessor.java:
--------------------------------------------------------------------------------
1 | package ru.evotor.framework.core.action.event.receipt.discount;
2 |
3 | import android.os.Bundle;
4 | import android.os.RemoteException;
5 |
6 | import androidx.annotation.NonNull;
7 | import androidx.annotation.Nullable;
8 | import ru.evotor.framework.core.action.processor.ActionProcessor;
9 |
10 | public abstract class ReceiptDiscountEventProcessor extends ActionProcessor {
11 | @Override
12 | public void process(@NonNull String action, @Nullable Bundle bundle, @NonNull Callback callback) throws RemoteException {
13 | ReceiptDiscountEvent event = ReceiptDiscountEvent.create(bundle);
14 |
15 | if (event == null) {
16 | callback.skip();
17 | return;
18 | }
19 |
20 | call(
21 | action,
22 | event,
23 | callback
24 | );
25 | }
26 |
27 | public abstract void call(@NonNull String action, @NonNull ReceiptDiscountEvent event, @NonNull Callback callback);
28 | }
29 |
30 |
--------------------------------------------------------------------------------
/src/main/java/ru/evotor/framework/receipt/PrintGroupSubTable.kt:
--------------------------------------------------------------------------------
1 | package ru.evotor.framework.receipt
2 |
3 | object PrintGroupSubTable {
4 | const val COLUMN_IDENTIFIER = "PRINT_GROUP_IDENTIFIER"
5 | const val COLUMN_TYPE = "PRINT_GROUP_TYPE"
6 | const val COLUMN_ORG_NAME = "PRINT_GROUP_ORG_NAME"
7 | const val COLUMN_ORG_INN = "PRINT_GROUP_ORG_INN"
8 | const val COLUMN_ORG_ADDRESS = "PRINT_GROUP_ORG_ADDRESS"
9 | const val COLUMN_TAXATION_SYSTEM = "PRINT_GROUP_TAXATION_SYSTEM"
10 | const val COLUMN_SHOULD_PRINT_RECEIPT = "PRINT_GROUP_SHOULD_PRINT_RECEIPT"
11 | const val COLUMN_PURCHASER_NAME = "PURCHASER_NAME"
12 | const val COLUMN_PURCHASER_DOCUMENT_NUMBER = "PURCHASER_DOCUMENT_NUMBER"
13 | const val COLUMN_PURCHASER_INN_NUMBER = "PURCHASER_INN_NUMBER"
14 | const val COLUMN_PURCHASER_BIRTH_DATE = "PURCHASER_BIRTH_DATE"
15 | const val COLUMN_PURCHASER_DOCUMENT_TYPE_CODE = "PURCHASER_DOCUMENT_TYPE_CODE"
16 | const val COLUMN_PURCHASER_TYPE = "PURCHASER_TYPE"
17 | const val COLUMN_RECEIPT_FROM_INTERNET = "PRINT_GROUP_RECEIPT_FROM_INTERNET"
18 | }
19 |
--------------------------------------------------------------------------------
/src/main/java/ru/evotor/framework/receipt/formation/api/move_receipt_to_payment_stage/MoveCurrentReceiptDraftToPaymentStageException.kt:
--------------------------------------------------------------------------------
1 | package ru.evotor.framework.receipt.formation.api.move_receipt_to_payment_stage
2 |
3 | class MoveCurrentReceiptDraftToPaymentStageException(
4 | val code: Int,
5 | message: String
6 | ) : Exception(message) {
7 | companion object {
8 | /**
9 | * Некорректные входные данные
10 | */
11 | const val CODE_INVALID_INPUT_DATA = -2
12 |
13 | /**
14 | * Сотрудник не авторизован
15 | */
16 | const val CODE_EMPLOYEE_NOT_AUTHORIZED = -3
17 |
18 | /**
19 | * Касса выполняет другую операцию
20 | */
21 | const val CODE_KKT_IS_BUSY = -4
22 |
23 | /**
24 | * Неопознанная ошибка
25 | */
26 | const val CODE_UNIDENTIFIED_ERROR = -1
27 |
28 | /**
29 | * Для текущего чека невозможно выполнить переход к оплате и печати
30 | */
31 | const val CODE_MOVE_TO_PAYMENT_UNAVAILABLE_FOR_RECEIPT = -5
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/src/main/java/ru/evotor/framework/core/ICanStartActivity.kt:
--------------------------------------------------------------------------------
1 | package ru.evotor.framework.core
2 |
3 | import android.content.Context
4 | import android.content.Intent
5 | import android.os.Bundle
6 | import java.lang.ref.WeakReference
7 |
8 | /**
9 | * Created by a.kuznetsov on 26/04/2017.
10 | */
11 | interface ICanStartActivity {
12 | fun startActivity(intent: Intent)
13 |
14 | fun startActivity(intent: Intent, options: Bundle?)
15 | }
16 |
17 | open class ActivityStarter(
18 | context: Context,
19 | private val isNewTask: Boolean = true
20 | ) : ICanStartActivity {
21 | private val contextRef = WeakReference(context)
22 |
23 | override fun startActivity(intent: Intent) {
24 | startActivity(intent, null)
25 | }
26 |
27 | override fun startActivity(intent: Intent, options: Bundle?) {
28 | if (isNewTask) {
29 | intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
30 | }
31 | contextRef.get()?.startActivity(intent, options)
32 | ?: throw IllegalStateException("Context has been deleted by garbage collector")
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/src/main/java/ru/evotor/framework/counterparties/collaboration/agent_scheme/mapper/PrincipalMapper.kt:
--------------------------------------------------------------------------------
1 | package ru.evotor.framework.counterparties.collaboration.agent_scheme.mapper
2 |
3 | import android.os.Bundle
4 | import ru.evotor.framework.counterparties.collaboration.agent_scheme.Principal
5 | import ru.evotor.framework.counterparties.mapper.CounterpartyMapper
6 |
7 | internal object PrincipalMapper {
8 | fun read(bundle: Bundle?): Principal? =
9 | bundle?.let {
10 | Principal(
11 | uuid = CounterpartyMapper.readUuid(it),
12 | counterpartyType = CounterpartyMapper.readCounterpartyType(it),
13 | fullName = CounterpartyMapper.readFullName(it),
14 | shortName = CounterpartyMapper.readShortName(it) ?: "",
15 | inn = CounterpartyMapper.readInn(it) ?: return null,
16 | kpp = CounterpartyMapper.readKpp(it),
17 | phones = CounterpartyMapper.readPhones(it) ?: return null,
18 | addresses = CounterpartyMapper.readAddresses(it)
19 | )
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 | # IDE (e.g. Android Studio) users:
3 | # Gradle settings configured through the IDE *will override*
4 | # any settings specified in this file.
5 | # For more details on how to configure your build environment visit
6 | # http://www.gradle.org/docs/current/userguide/build_environment.html
7 | # Specifies the JVM arguments used for the daemon process.
8 | # The setting is particularly useful for tweaking memory settings.
9 | # Default value: -Xmx10248m -XX:MaxPermSize=256m
10 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
11 | # When configured, Gradle will run in incubating parallel mode.
12 | # This option should only be used with decoupled projects. More details, visit
13 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
14 | # org.gradle.parallel=true
15 | android.enableJetifier=true
16 | android.useAndroidX=true
17 |
18 | # Kotlin code style for this project: "official" or "obsolete":
19 | kotlin.code.style=official
20 |
21 | org.gradle.jvmargs=-Xmx1536M
--------------------------------------------------------------------------------
/src/main/java/ru/evotor/framework/settings/SettingsProviderContracts.kt:
--------------------------------------------------------------------------------
1 | package ru.evotor.framework.settings
2 |
3 | import android.net.Uri
4 |
5 | /**
6 | * Контракты контент-провайдера настроек EvotorPos.
7 | */
8 | enum class SettingsProviderContracts(
9 | val path: String,
10 | val columnName: String
11 | ) {
12 | /**
13 | * Количество печати слип-чеков.
14 | */
15 | SLIPS_AMOUNT_PROVIDER(
16 | "SLIPS_AMOUNT_PATH",
17 | "SLIPS_AMOUNT_COLUMN"
18 | ),
19 |
20 | /**
21 | * Опция "Разрешить отрицательные остатки".
22 | */
23 | NEGATIVE_BALANCE_PROVIDER(
24 | "NEGATIVE_BALANCE_PATH",
25 | "NEGATIVE_BALANCE_COLUMN"
26 | );
27 |
28 | @Suppress("MemberVisibilityCanBePrivate")
29 | companion object {
30 | const val AUTHORITY = "ru.evotor.evotorpos.settings"
31 | const val DEPRECATED_AUTHORITY = "ru.evotor.settings.SlipsAmountInfo"
32 |
33 | internal val BASE_URI = Uri.parse("content://$AUTHORITY")
34 | internal val DEPRECATED_BASE_URI = Uri.parse("content://$DEPRECATED_AUTHORITY")
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/src/main/aidl/ru/evotor/devices/commons/IPrinterService.aidl:
--------------------------------------------------------------------------------
1 | package ru.evotor.devices.commons;
2 |
3 | import android.graphics.Bitmap;
4 |
5 | import ru.evotor.devices.commons.printer.PrinterDocument;
6 | import ru.evotor.devices.commons.result.ResultInt;
7 | import ru.evotor.devices.commons.result.ResultVoid;
8 |
9 | interface IPrinterService {
10 |
11 | /**
12 | * Возвращает количество печатных символов, которые помещаются на 1 строке
13 | *
14 | * @param deviceId - номер устройства
15 | */
16 | ResultInt getAllowableSymbolsLineLength(int deviceId);
17 |
18 | /**
19 | * Возвращает доступную для печати ширину бумаги в пикселях
20 | *
21 | * @param deviceId - номер устройства
22 | */
23 | ResultInt getAllowablePixelLineLength(int deviceId);
24 |
25 | /**
26 | * Печатает указанный массив объектов (текст, изображения, штрихкоды)
27 | *
28 | * @param deviceId - номер устройства
29 | * @param printedObjects - объекты для печати
30 | */
31 | ResultVoid printDocument(int deviceId, in PrinterDocument printerDocument);
32 |
33 | }
34 |
--------------------------------------------------------------------------------
/src/main/java/ru/evotor/framework/core/action/datamapper/PaymentPerformerMapper.kt:
--------------------------------------------------------------------------------
1 | package ru.evotor.framework.core.action.datamapper
2 |
3 | import android.os.Bundle
4 | import ru.evotor.framework.component.PaymentPerformer
5 |
6 | object PaymentPerformerMapper {
7 | private const val KEY_PAYMENT_SYSTEM = "paymentSystem"
8 |
9 | fun toBundle(paymentPerformer: PaymentPerformer): Bundle =
10 | IntegrationComponentMapper.toBundle(paymentPerformer).apply {
11 | putBundle(KEY_PAYMENT_SYSTEM, PaymentSystemMapper.toBundle(paymentPerformer.paymentSystem))
12 | }
13 |
14 | fun fromBundle(bundle: Bundle?): PaymentPerformer? =
15 | bundle?.let {
16 | PaymentPerformer(
17 | PaymentSystemMapper.from(bundle.getBundle(KEY_PAYMENT_SYSTEM)),
18 | IntegrationComponentMapper.readPackageName(bundle),
19 | IntegrationComponentMapper.readComponentName(bundle),
20 | IntegrationComponentMapper.readAppUuid(bundle),
21 | IntegrationComponentMapper.readAppName(bundle)
22 | )
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/src/main/java/ru/evotor/framework/core/action/datamapper/TaxNumberMapper.java:
--------------------------------------------------------------------------------
1 | package ru.evotor.framework.core.action.datamapper;
2 |
3 | import android.os.Bundle;
4 |
5 | import androidx.annotation.Nullable;
6 | import ru.evotor.framework.Utils;
7 | import ru.evotor.framework.receipt.TaxNumber;
8 |
9 |
10 | public final class TaxNumberMapper {
11 |
12 | private static final String KEY_TAX_NUMBER = "taxNumber";
13 |
14 | @Nullable
15 | public static TaxNumber from(@Nullable Bundle bundle) {
16 | if (bundle == null) {
17 | return null;
18 | }
19 | String taxNumber = bundle.getString(KEY_TAX_NUMBER);
20 |
21 | return Utils.safeValueOf(TaxNumber.class, taxNumber, null);
22 | }
23 |
24 | @Nullable
25 | public static Bundle toBundle(@Nullable TaxNumber taxNumber) {
26 | if (taxNumber == null) {
27 | return null;
28 | }
29 | Bundle bundle = new Bundle();
30 | bundle.putString(KEY_TAX_NUMBER, taxNumber.name());
31 |
32 | return bundle;
33 | }
34 |
35 | private TaxNumberMapper() {
36 | }
37 |
38 | }
39 |
--------------------------------------------------------------------------------
/src/main/java/ru/evotor/framework/core/action/event/receipt/changes/receipt/SetExtra.kt:
--------------------------------------------------------------------------------
1 | package ru.evotor.framework.core.action.event.receipt.changes.receipt
2 |
3 | import android.os.Bundle
4 | import org.json.JSONObject
5 | import ru.evotor.framework.core.action.event.receipt.changes.IChange
6 |
7 | /**
8 | * Добавляет в чек дополнительные поля в виде валидного JSON-объекта.
9 | */
10 | data class SetExtra(val extra: JSONObject?) : IChange {
11 | override fun toBundle(): Bundle {
12 | return Bundle().apply {
13 | putString(
14 | KEY_EXTRA,
15 | extra?.toString()
16 | )
17 | }
18 | }
19 |
20 | override fun getType(): IChange.Type {
21 | return IChange.Type.SET_EXTRA
22 | }
23 |
24 | companion object {
25 | const val KEY_EXTRA = "extra"
26 |
27 | @JvmStatic
28 | fun from(bundle: Bundle?): SetExtra? {
29 | bundle ?: return null
30 |
31 | return SetExtra(
32 | bundle.getString(KEY_EXTRA)?.let { JSONObject(it) }
33 | )
34 | }
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/src/main/java/ru/evotor/framework/component/PaymentDelegator.kt:
--------------------------------------------------------------------------------
1 | package ru.evotor.framework.component
2 |
3 | import android.os.Bundle
4 | import ru.evotor.IBundlable
5 | import ru.evotor.framework.core.action.datamapper.PaymentDelegatorMapper
6 |
7 | /**
8 | * Компонент (служба, операция и т.д.) интеграционного приложения, осуществляющий делегирование платежей другим приложениям. Например, приложение "Комбооплата".
9 | *
10 | * @param packageName Название пакета
11 | * @param componentName Название компонента (служба, операция и т.д.)
12 | * @param appUuid Уникальный идентификатора приложения в Облаке
13 | * @param appName Название приложения
14 | */
15 | class PaymentDelegator(
16 | packageName: String?,
17 | componentName: String?,
18 | appUuid: String?,
19 | appName: String?
20 | ) : IntegrationComponent(packageName, componentName, appUuid, appName), IBundlable {
21 | override fun toBundle(): Bundle {
22 | return PaymentDelegatorMapper.toBundle(this)
23 | }
24 |
25 | companion object {
26 | fun from(bundle: Bundle?) = PaymentDelegatorMapper.fromBundle(bundle)
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/src/main/java/ru/evotor/framework/device/scanner/event/BarcodeReceivedEvent.kt:
--------------------------------------------------------------------------------
1 | package ru.evotor.framework.device.scanner.event
2 |
3 | import android.os.Bundle
4 |
5 | import ru.evotor.IBundlable
6 |
7 | /**
8 | * Событие получения штрихкода.
9 | *
10 | * Происходит при сканировании штрихкода сканером штрихкодов, подключённым к смарт-терминалу.
11 | *
12 | * Обрабатывать это событие можно с помощью широковещательного приёмника событий сканера штрихкодов:
13 | * [ru.evotor.framework.device.scanner.event.handler.receiver.ScannerBroadcastReceiver]
14 | *
15 | * @param barcode отсканированный штрихкод
16 | */
17 | class BarcodeReceivedEvent(val barcode: String) : IBundlable {
18 | override fun toBundle(): Bundle {
19 | val result = Bundle()
20 | result.putString(KEY_BARCODE, barcode)
21 | return result
22 | }
23 |
24 | companion object {
25 | private const val KEY_BARCODE = "ScannedCode"
26 |
27 | fun from(bundle: Bundle?): BarcodeReceivedEvent? = bundle?.let {
28 | BarcodeReceivedEvent(it.getString(KEY_BARCODE) ?: return null)
29 | }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/src/main/java/ru/evotor/framework/receipt/position/PartialRealization.kt:
--------------------------------------------------------------------------------
1 | package ru.evotor.framework.receipt.position
2 |
3 | import android.os.Bundle
4 | import ru.evotor.IBundlable
5 | import ru.evotor.framework.optBigDecimal
6 | import java.math.BigDecimal
7 |
8 | /**
9 | * Частичное выбытие
10 | */
11 | data class PartialRealization(
12 | /**
13 | * Количество товара в упаковке всего. Необходимое для заполнения поле,
14 | * при частичной продаже маркированного товара.
15 | */
16 | val quantityInPackage: BigDecimal
17 | ) : IBundlable {
18 | override fun toBundle(): Bundle = Bundle().apply {
19 | putString(KEY_QUANTITY_IN_PACKAGE, quantityInPackage.toPlainString())
20 | }
21 |
22 | companion object {
23 | private const val KEY_QUANTITY_IN_PACKAGE = "QuantityInPackage"
24 |
25 | @JvmStatic
26 | fun from(bundle: Bundle?): PartialRealization? = bundle?.let {
27 | val quantityInPackage = it.optBigDecimal(KEY_QUANTITY_IN_PACKAGE) ?: BigDecimal.ZERO
28 |
29 | PartialRealization(quantityInPackage = quantityInPackage)
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/src/main/java/ru/evotor/framework/core/action/event/receipt/discount_required/ReceiptDiscountRequiredEventResult.kt:
--------------------------------------------------------------------------------
1 | package ru.evotor.framework.core.action.event.receipt.discount_required
2 |
3 | import android.content.ComponentName
4 | import android.os.Bundle
5 | import ru.evotor.IBundlable
6 |
7 | class ReceiptDiscountRequiredEventResult(
8 | val componentName: ComponentName
9 | ) : IBundlable {
10 | override fun toBundle(): Bundle {
11 | return Bundle().also {
12 | it.putParcelable(KEY_COMPONENT_NAME, componentName)
13 | }
14 | }
15 |
16 | companion object {
17 | private const val KEY_COMPONENT_NAME = "KEY_COMPONENT_NAME"
18 |
19 | fun create(bundle: Bundle?): ReceiptDiscountRequiredEventResult? {
20 | bundle ?: return null
21 |
22 | val componentName = bundle.getParcelable(KEY_COMPONENT_NAME)
23 | ?: throw IllegalStateException("Bundle doesn't contain the necessary data to create ReceiptDiscountRequiredEventResult")
24 |
25 | return ReceiptDiscountRequiredEventResult(componentName)
26 | }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/src/main/java/ru/evotor/framework/receipt/position/event/PositionEvent.kt:
--------------------------------------------------------------------------------
1 | package ru.evotor.framework.receipt.position.event
2 |
3 | import android.os.Bundle
4 |
5 | import ru.evotor.IBundlable
6 | import ru.evotor.framework.core.action.datamapper.PositionMapper
7 | import ru.evotor.framework.receipt.Position
8 |
9 | abstract class PositionEvent internal constructor(
10 | val receiptUuid: String,
11 | val position: Position
12 | ) : IBundlable {
13 | override fun toBundle(): Bundle {
14 | val result = Bundle()
15 | result.putString(KEY_RECEIPT_UUID, receiptUuid)
16 | result.putBundle(KEY_POSITION, PositionMapper.toBundle(position))
17 | return result
18 | }
19 |
20 | companion object {
21 | private const val KEY_RECEIPT_UUID = "receiptUuid"
22 |
23 | private const val KEY_POSITION = "position"
24 |
25 | internal fun getReceiptUuid(bundle: Bundle): String? =
26 | bundle.getString(KEY_RECEIPT_UUID, null)
27 |
28 | internal fun getPosition(bundle: Bundle): Position? =
29 | PositionMapper.from(bundle.getBundle(KEY_POSITION))
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/src/main/java/ru/evotor/framework/core/action/event/cash_drawer/CashDrawerEvent.java:
--------------------------------------------------------------------------------
1 | package ru.evotor.framework.core.action.event.cash_drawer;
2 |
3 | import android.os.Bundle;
4 |
5 | import androidx.annotation.NonNull;
6 | import ru.evotor.IBundlable;
7 |
8 | /**
9 | * @deprecated Используйте {@link ru.evotor.framework.device.cash_drawer.event.CashDrawerEvent}
10 | */
11 | @Deprecated
12 | public abstract class CashDrawerEvent implements IBundlable {
13 | private static final String KEY_CASH_DRAWER_ID = "cashDrawerId";
14 |
15 | private final int cashDrawerId;
16 |
17 | CashDrawerEvent(@NonNull Bundle extras) {
18 | this(
19 | extras.getInt(KEY_CASH_DRAWER_ID, -1)
20 | );
21 | }
22 |
23 | CashDrawerEvent(int cashDrawerId) {
24 | this.cashDrawerId = cashDrawerId;
25 | }
26 |
27 | @Override
28 | @NonNull
29 | public Bundle toBundle() {
30 | Bundle result = new Bundle();
31 | result.putInt(KEY_CASH_DRAWER_ID, cashDrawerId);
32 | return result;
33 | }
34 |
35 | public int getCashDrawerId() {
36 | return cashDrawerId;
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/src/main/java/ru/evotor/framework/core/action/event/receipt/receipt_edited/ReceiptPaymentPartsEditedEvent.java:
--------------------------------------------------------------------------------
1 | package ru.evotor.framework.core.action.event.receipt.receipt_edited;
2 |
3 |
4 | import android.os.Bundle;
5 |
6 | import androidx.annotation.NonNull;
7 | import androidx.annotation.Nullable;
8 |
9 | public class ReceiptPaymentPartsEditedEvent extends ReceiptEvent {
10 | public static final String BROADCAST_ACTION_SELL_RECEIPT = "evotor.intent.action.receipt.sell.paymentParts.EDITED";
11 | public static final String BROADCAST_ACTION_PAYBACK_RECEIPT = "evotor.intent.action.receipt.payback.paymentParts.EDITED";
12 |
13 | public ReceiptPaymentPartsEditedEvent(@NonNull String receiptUuid) {
14 | super(receiptUuid);
15 | }
16 |
17 | @Nullable
18 | public static ReceiptPaymentPartsEditedEvent create(@Nullable Bundle bundle) {
19 | if (bundle == null) {
20 | return null;
21 | }
22 | String receiptUuid = getReceiptUuid(bundle);
23 | if (receiptUuid == null) {
24 | return null;
25 | }
26 | return new ReceiptPaymentPartsEditedEvent(receiptUuid);
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/src/main/java/ru/evotor/framework/core/IntegrationManagerFuture.java:
--------------------------------------------------------------------------------
1 | package ru.evotor.framework.core;
2 |
3 | import android.os.Bundle;
4 |
5 | public interface IntegrationManagerFuture {
6 |
7 | Result getResult() throws IntegrationException;
8 |
9 | class Result {
10 | private final Type type;
11 | private final Error error;
12 | private final Bundle data;
13 |
14 | public Result(Bundle data) {
15 | this(Type.OK, null, data);
16 | }
17 |
18 | public Result(Error error) {
19 | this(Type.ERROR, error, null);
20 | }
21 |
22 | public Result(Type type, Error error, Bundle data) {
23 | this.type = type;
24 | this.error = error;
25 | this.data = data;
26 | }
27 |
28 | public Type getType() {
29 | return type;
30 | }
31 |
32 | public Bundle getData() {
33 | return data;
34 | }
35 |
36 | public Error getError() {
37 | return error;
38 | }
39 |
40 | public enum Type {
41 | OK,
42 | ERROR
43 | }
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/src/main/java/ru/evotor/framework/core/action/event/receipt/changes/IChange.kt:
--------------------------------------------------------------------------------
1 | package ru.evotor.framework.core.action.event.receipt.changes
2 |
3 | import ru.evotor.IBundlable
4 |
5 | interface IChange : IBundlable {
6 | /**
7 | * Возвращает тип изменения чека.
8 | */
9 | fun getType(): Type
10 |
11 | /**
12 | * Возможные типы изменения чека.
13 | */
14 | enum class Type {
15 | /**
16 | * Добавление позиции в чек.
17 | */
18 | POSITION_ADD,
19 |
20 | /**
21 | * Удаление позиции из чека.
22 | */
23 | POSITION_REMOVE,
24 |
25 | /**
26 | * Изменение позиции чека.
27 | */
28 | POSITION_EDIT,
29 |
30 | /**
31 | * Запись дополнительных полей в чек.
32 | */
33 | SET_EXTRA,
34 | SET_POSITION_PRINT_GROUP,
35 | SET_PAYMENT_PURPOSE_PRINT_GROUP,
36 |
37 | /**
38 | * Добавление дополнительных полей для печати в чеке.
39 | */
40 | SET_PRINT_EXTRA,
41 | SET_PURCHASER_CONTACT_DATA,
42 | SET_INTERNET_REQUISITES,
43 | UNKNOWN
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/src/main/java/ru/evotor/framework/core/action/event/receipt/before_positions_edited/BeforePositionsEditedEventProcessor.java:
--------------------------------------------------------------------------------
1 | package ru.evotor.framework.core.action.event.receipt.before_positions_edited;
2 |
3 | import android.os.Bundle;
4 | import android.os.RemoteException;
5 |
6 | import androidx.annotation.NonNull;
7 | import androidx.annotation.Nullable;
8 | import ru.evotor.framework.core.action.processor.ActionProcessor;
9 |
10 | /**
11 | * Процессор (класс для обработки) события изменения чека: {@link BeforePositionsEditedEvent}.
12 | */
13 | public abstract class BeforePositionsEditedEventProcessor extends ActionProcessor {
14 |
15 | @Override
16 | public void process(@NonNull String action, @Nullable Bundle bundle, @NonNull Callback callback) throws RemoteException {
17 | BeforePositionsEditedEvent event = BeforePositionsEditedEvent.create(bundle);
18 | if (event == null) {
19 | callback.skip();
20 | return;
21 | }
22 | call(action, event, callback);
23 | }
24 |
25 | public abstract void call(@NonNull String action, @NonNull BeforePositionsEditedEvent event, @NonNull Callback callback);
26 | }
27 |
28 |
--------------------------------------------------------------------------------
/src/main/java/ru/evotor/devices/commons/printer/printable/PrintableText.java:
--------------------------------------------------------------------------------
1 | package ru.evotor.devices.commons.printer.printable;
2 |
3 | import android.os.Parcel;
4 |
5 | public class PrintableText implements IPrintable {
6 |
7 | /**
8 | * текст для печати
9 | */
10 | private final String text;
11 |
12 | public PrintableText(String text) {
13 | this.text = text;
14 | }
15 |
16 | private PrintableText(Parcel parcel) {
17 | text = parcel.readString();
18 | }
19 |
20 | public String getText() {
21 | return text;
22 | }
23 |
24 | @Override
25 | public int describeContents() {
26 | return 0;
27 | }
28 |
29 | @Override
30 | public void writeToParcel(Parcel parcel, int i) {
31 | parcel.writeString(text);
32 | }
33 |
34 | public static final Creator CREATOR = new Creator() {
35 |
36 | public PrintableText createFromParcel(Parcel in) {
37 | return new PrintableText(in);
38 | }
39 |
40 | public PrintableText[] newArray(int size) {
41 | return new PrintableText[size];
42 | }
43 | };
44 |
45 | }
46 |
--------------------------------------------------------------------------------
/src/main/java/ru/evotor/framework/core/action/event/receipt/jewelry/SendJewelryEventResult.kt:
--------------------------------------------------------------------------------
1 | package ru.evotor.framework.core.action.event.receipt.jewelry
2 |
3 | import android.os.Bundle
4 | import ru.evotor.IBundlable
5 | import ru.evotor.devices.commons.printer.printable.IPrintable
6 | import ru.evotor.framework.core.action.datamapper.PrintablesMapper
7 |
8 | /**
9 | * Результат обработки события [SendJewelryEvent].
10 | */
11 | class SendJewelryEventResult(
12 | val printableReport: Array?
13 | ) : IBundlable {
14 | override fun toBundle(): Bundle {
15 | val bundle = Bundle()
16 | printableReport?.let {
17 | bundle.putBundle(KEY_PRINTABLE_REPORT, PrintablesMapper.toBundle(it))
18 | }
19 | return bundle
20 | }
21 |
22 | companion object {
23 | private const val KEY_PRINTABLE_REPORT = "printableReport"
24 |
25 | fun create(bundle: Bundle?): SendJewelryEventResult? = bundle?.let {
26 | val printableReport = PrintablesMapper.fromBundle(bundle.getBundle(KEY_PRINTABLE_REPORT))
27 | return SendJewelryEventResult(
28 | printableReport
29 | )
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/src/main/java/ru/evotor/framework/counterparties/Counterparty.kt:
--------------------------------------------------------------------------------
1 | package ru.evotor.framework.counterparties
2 |
3 | import android.os.Bundle
4 | import ru.evotor.IBundlable
5 | import ru.evotor.framework.counterparties.mapper.CounterpartyMapper
6 | import java.util.*
7 |
8 | /**
9 | * Контрагент
10 | */
11 | abstract class Counterparty : IBundlable {
12 | abstract val uuid: UUID?
13 |
14 | abstract val counterpartyType: Type?
15 |
16 | abstract val fullName: String?
17 |
18 | abstract val shortName: String?
19 |
20 | abstract val inn: String?
21 |
22 | abstract val kpp: String?
23 |
24 | abstract val phones: List?
25 |
26 | abstract val addresses: List?
27 |
28 | /**
29 | * Тип контрагента
30 | */
31 | enum class Type {
32 | /**
33 | * Юридическое лицо
34 | */
35 | LEGAL_ENTITY,
36 |
37 | /**
38 | * Индивидуальный предприниматель
39 | */
40 | INDIVIDUAL_ENTREPRENEUR,
41 |
42 | /**
43 | * Государственный орган
44 | */
45 | GOVERNMENT_AGENCY
46 | }
47 |
48 | override fun toBundle(): Bundle = CounterpartyMapper.write(this)
49 | }
50 |
--------------------------------------------------------------------------------
/src/main/java/ru/evotor/framework/system/mode/DeviceModeApi.kt:
--------------------------------------------------------------------------------
1 | package ru.evotor.framework.system.mode
2 |
3 | import android.content.Context
4 |
5 | object DeviceModeApi {
6 | /**
7 | * Режим работы терминала - смарт-терминал
8 | */
9 | const val MODE_ST = "ST"
10 |
11 | /**
12 | * * Режим работы терминала - фискальный регистратор
13 | */
14 | const val MODE_FR = "FR"
15 |
16 | /**
17 | * Возвращает текущий режим работы терминала, если применимо, иначе - null
18 | */
19 | @JvmStatic
20 | fun getCurrentDeviceMode(context: Context): String? {
21 | return try {
22 | context.contentResolver.query(
23 | DeviceModeContract.QUERY_URI,
24 | arrayOf(DeviceModeContract.COLUMN_MODE),
25 | null,
26 | null,
27 | null
28 | )?.use { c ->
29 | if (c.moveToNext()) {
30 | c.getString(c.getColumnIndex(DeviceModeContract.COLUMN_MODE))
31 | } else {
32 | null
33 | }
34 | }
35 | } catch (t: Throwable) {
36 | null
37 | }
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/src/main/java/ru/evotor/framework/core/action/event/receipt/receipt_edited/ReceiptEvent.java:
--------------------------------------------------------------------------------
1 | package ru.evotor.framework.core.action.event.receipt.receipt_edited;
2 |
3 | import android.os.Bundle;
4 |
5 | import androidx.annotation.NonNull;
6 | import androidx.annotation.Nullable;
7 | import ru.evotor.IBundlable;
8 |
9 | /**
10 | * @deprecated Используйте {@link ru.evotor.framework.receipt.event.ReceiptEvent}
11 | */
12 | @Deprecated
13 | public abstract class ReceiptEvent implements IBundlable {
14 | private static final String KEY_RECEIPT_UUID = "receiptUuid";
15 |
16 | @NonNull
17 | private final String receiptUuid;
18 |
19 | @Nullable
20 | static String getReceiptUuid(@NonNull Bundle bundle) {
21 | return bundle.getString(KEY_RECEIPT_UUID, null);
22 | }
23 |
24 | ReceiptEvent(@NonNull String receiptUuid) {
25 | this.receiptUuid = receiptUuid;
26 | }
27 |
28 | @NonNull
29 | public Bundle toBundle() {
30 | Bundle result = new Bundle();
31 | result.putString(KEY_RECEIPT_UUID, receiptUuid);
32 | return result;
33 | }
34 |
35 | @NonNull
36 | public String getReceiptUuid() {
37 | return receiptUuid;
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/src/main/java/ru/evotor/framework/core/action/event/receipt/jewelry/SendJewelryEventProcessor.kt:
--------------------------------------------------------------------------------
1 | package ru.evotor.framework.core.action.event.receipt.jewelry
2 |
3 | import android.os.Bundle
4 | import ru.evotor.framework.core.action.processor.ActionProcessor
5 |
6 | /**
7 | * Обработчик события [SendJewelryEvent].
8 | */
9 | abstract class SendJewelryEventProcessor : ActionProcessor() {
10 | override fun process(action: String, bundle: Bundle?, callback: ActionProcessor.Callback) {
11 | val event = SendJewelryEvent.from(bundle) ?: run {
12 | callback.skip()
13 | return
14 | }
15 | call(action, event, callback)
16 | }
17 |
18 | /**
19 | * Используйте метод, чтобы обработать событие [SendJewelryEvent] и сохранить результат [SendJewelryEventResult].
20 | * @param action
21 | * @param event экземпляр события о выбытии ювелирных изделий.
22 | * @param callback функция обратного вызова. Методы функции позволяют пропускать обработку события, возвращать результат,
23 | * запускать операции и обрабатывать ошибки.
24 | */
25 | abstract fun call(action: String, event: SendJewelryEvent, callback: ActionProcessor.Callback)
26 | }
27 |
--------------------------------------------------------------------------------
/src/main/java/ru/evotor/framework/kkt/api/AsyncHandler.kt:
--------------------------------------------------------------------------------
1 | package ru.evotor.framework.kkt.api
2 |
3 | import android.content.AsyncQueryHandler
4 | import android.content.Context
5 | import android.database.Cursor
6 | import ru.evotor.framework.core.IntegrationLibraryMappingException
7 | import ru.evotor.framework.kkt.provider.KktContract
8 | import ru.evotor.framework.optList
9 |
10 | class AsyncHandler(context: Context, private val callback: (serial: String, reg: String) -> Unit) :
11 | AsyncQueryHandler(context.contentResolver) {
12 | override fun onQueryComplete(token: Int, cookie: Any?, cursor: Cursor?) {
13 | cursor?.use {
14 | it.moveToFirst()
15 |
16 | val serialNumber = it.optList(KktContract.COLUMN_SERIAL_NUMBER)
17 | ?: throw IntegrationLibraryMappingException(KktContract.COLUMN_SERIAL_NUMBER)
18 |
19 | val regNumber = it.optList(KktContract.COLUMN_REGISTER_NUMBER)
20 | ?: throw IntegrationLibraryMappingException(KktContract.COLUMN_REGISTER_NUMBER)
21 |
22 | callback(serialNumber[0], regNumber[0])
23 | }
24 | }
25 |
26 | companion object {
27 | internal const val KKT_INFO_TOKEN = 0
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/main/java/ru/evotor/framework/core/action/datamapper/PositionAttributesMapper.kt:
--------------------------------------------------------------------------------
1 | package ru.evotor.framework.core.action.datamapper
2 |
3 | import android.os.Bundle
4 | import ru.evotor.framework.inventory.AttributeValue
5 |
6 | object PositionAttributesMapper {
7 | @JvmStatic
8 | fun fromBundle(attributes: Bundle?): Map? {
9 | attributes?.let { bundle ->
10 | bundle.classLoader = AttributeValue::class.java.classLoader
11 | return HashMap().apply {
12 | attributes.keySet().forEach { key ->
13 | val value = attributes.getParcelable(key) as AttributeValue?
14 | value?.let {
15 | this[key] = it
16 | }
17 | }
18 | }
19 | } ?: return null
20 | }
21 |
22 | @JvmStatic
23 | fun toBundle(attributes: Map?): Bundle? {
24 | attributes?.let {
25 | return Bundle().apply {
26 | attributes.keys.forEach {
27 | this.putParcelable(it, attributes[it])
28 | }
29 | }
30 | } ?: return null
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/src/main/java/ru/evotor/framework/core/action/event/inventory/ProductEvent.java:
--------------------------------------------------------------------------------
1 | package ru.evotor.framework.core.action.event.inventory;
2 |
3 | import android.os.Bundle;
4 |
5 | import androidx.annotation.NonNull;
6 | import androidx.annotation.Nullable;
7 | import ru.evotor.IBundlable;
8 |
9 | /**
10 | * @deprecated Используйте {@link ru.evotor.framework.inventory.event.ProductEvent}
11 | */
12 | @Deprecated
13 | public abstract class ProductEvent implements IBundlable {
14 | private static final String KEY_PRODUCT_UUID = "productUuid";
15 |
16 | @Nullable
17 | private final String productUuid;
18 |
19 | public ProductEvent(@Nullable String productUuid) {
20 | this.productUuid = productUuid;
21 | }
22 |
23 | @Nullable
24 | static String getProductUuid(@Nullable Bundle bundle) {
25 | return bundle == null ? null : bundle.getString(KEY_PRODUCT_UUID);
26 | }
27 |
28 | @NonNull
29 | @Override
30 | public Bundle toBundle() {
31 | Bundle result = new Bundle();
32 | result.putString(KEY_PRODUCT_UUID, productUuid);
33 | return result;
34 | }
35 |
36 | @Nullable
37 | public String getProductUuid() {
38 | return productUuid;
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/src/main/java/ru/evotor/framework/core/action/event/cash_operations/CashOperationEvent.java:
--------------------------------------------------------------------------------
1 | package ru.evotor.framework.core.action.event.cash_operations;
2 |
3 | import android.os.Bundle;
4 |
5 | import androidx.annotation.NonNull;
6 | import androidx.annotation.Nullable;
7 | import ru.evotor.IBundlable;
8 |
9 | /**
10 | * @deprecated Используйте {@link ru.evotor.framework.kkt.event.CashOperationEvent}
11 | */
12 | @Deprecated
13 | public abstract class CashOperationEvent implements IBundlable {
14 | private static final String KEY_DOCUMENT_UUID = "documentUuid";
15 |
16 | @NonNull
17 | private final String documentUuid;
18 |
19 | CashOperationEvent(@NonNull String documentUuid) {
20 | this.documentUuid = documentUuid;
21 | }
22 |
23 | @Nullable
24 | static String getDocumentUuid(@Nullable Bundle bundle) {
25 | return bundle == null ? null : bundle.getString(KEY_DOCUMENT_UUID);
26 | }
27 |
28 | @Override
29 | @NonNull
30 | public Bundle toBundle() {
31 | Bundle result = new Bundle();
32 | result.putString(KEY_DOCUMENT_UUID, documentUuid);
33 | return result;
34 | }
35 |
36 | @NonNull
37 | public String getDocumentUuid() {
38 | return documentUuid;
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/src/main/java/ru/evotor/framework/core/action/event/receipt/payment/combined/result/PaymentDelegatorCanceledEventResult.kt:
--------------------------------------------------------------------------------
1 | package ru.evotor.framework.core.action.event.receipt.payment.combined.result
2 |
3 | import android.os.Bundle
4 | import ru.evotor.framework.core.action.event.receipt.changes.receipt.SetExtra
5 |
6 | class PaymentDelegatorCanceledEventResult(
7 | val paymentUuid: String,
8 | extra: SetExtra?
9 | ) : PaymentDelegatorEventResult(ResultType.CANCEL, extra) {
10 | override fun toBundle(): Bundle {
11 | val result = super.toBundle()
12 | result.putString(KEY_PAYMENT_UUID, paymentUuid)
13 | return result
14 | }
15 |
16 | companion object {
17 | private const val KEY_PAYMENT_UUID = "paymentUuid"
18 |
19 | fun create(bundle: Bundle?): PaymentDelegatorCanceledEventResult? {
20 | if (bundle == null) {
21 | return null
22 | }
23 | return bundle.getString(KEY_PAYMENT_UUID)
24 | ?.let {
25 | PaymentDelegatorCanceledEventResult(
26 | it,
27 | SetExtra.from(bundle.getBundle(KEY_RECEIPT_EXTRA))
28 | )
29 | }
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/src/main/java/ru/evotor/framework/receipt/position/LocalModuleInfo.kt:
--------------------------------------------------------------------------------
1 | package ru.evotor.framework.receipt.position
2 |
3 | import android.os.Bundle
4 | import ru.evotor.IBundlable
5 |
6 | /**
7 | * Данные о локальном модуле ЧЗ
8 | */
9 | data class LocalModuleInfo(
10 | /**
11 | * Идентификатор экземпляра ЛМ ЧЗ
12 | */
13 | val inst: String,
14 | /**
15 | * Версия базы ЛМ ЧЗ, на которой осуществлялась проверка
16 | */
17 | val lmChzDbVersion: String
18 | ) : IBundlable {
19 | override fun toBundle(): Bundle = Bundle().apply {
20 | putString(KEY_LM_CHZ_ID, inst)
21 | putString(KEY_LM_CHZ_DB_VERSION, lmChzDbVersion)
22 | }
23 |
24 | companion object {
25 | private const val KEY_LM_CHZ_ID = "LmChzId"
26 | private const val KEY_LM_CHZ_DB_VERSION = "LmChzDbVersion"
27 |
28 | @JvmStatic
29 | fun from(bundle: Bundle?): LocalModuleInfo? = bundle?.let {
30 | val inst = it.getString(KEY_LM_CHZ_ID) ?: return null
31 | val lmChzDbVersion = it.getString(KEY_LM_CHZ_DB_VERSION) ?: return null
32 |
33 | LocalModuleInfo(
34 | inst = inst,
35 | lmChzDbVersion = lmChzDbVersion
36 | )
37 | }
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/src/main/java/ru/evotor/framework/counterparties/collaboration/agent_scheme/mapper/TransactionOperatorMapper.kt:
--------------------------------------------------------------------------------
1 | package ru.evotor.framework.counterparties.collaboration.agent_scheme.mapper
2 |
3 | import android.os.Bundle
4 | import ru.evotor.framework.counterparties.collaboration.agent_scheme.TransactionOperator
5 | import ru.evotor.framework.counterparties.mapper.CounterpartyMapper
6 |
7 | internal object TransactionOperatorMapper {
8 | fun read(bundle: Bundle?): TransactionOperator? =
9 | bundle?.let {
10 | TransactionOperator(
11 | uuid = CounterpartyMapper.readUuid(it),
12 | counterpartyType = CounterpartyMapper.readCounterpartyType(it),
13 | fullName = CounterpartyMapper.readFullName(it),
14 | shortName = CounterpartyMapper.readShortName(it),
15 | inn = CounterpartyMapper.readInn(it),
16 | kpp = CounterpartyMapper.readKpp(it),
17 | phones = CounterpartyMapper.readPhones(it),
18 | addresses = CounterpartyMapper.readAddresses(it)
19 | )
20 | }
21 |
22 | fun convertToNull(transactionOperator: TransactionOperator): TransactionOperator? =
23 | CounterpartyMapper.convertToNull(transactionOperator)
24 | }
25 |
--------------------------------------------------------------------------------
/src/main/java/ru/evotor/Parcelables.kt:
--------------------------------------------------------------------------------
1 | package ru.evotor
2 |
3 | import android.os.Parcel
4 | import android.os.Parcelable
5 |
6 | inline fun Parcel.readParcelable(): T? {
7 | return readParcelable(this, T::class.java)
8 | }
9 |
10 | fun readParcelable(parcel: Parcel, clazzT: Class): T? {
11 | val dataPosition = parcel.dataPosition()
12 | return try {
13 | parcel.readParcelable(clazzT.classLoader)
14 | } catch (t: Throwable) {
15 | parcel.setDataPosition(dataPosition)
16 | parcel.readValue(clazzT.classLoader) as? T
17 | }
18 | }
19 |
20 | fun Parcel.writeAliased(p: Parcelable?, flags: Int) {
21 | writeParcelable(p, flags)
22 | }
23 |
24 | fun Parcel.readAliased(creator: Parcelable.Creator): T? {
25 | val ignoredClass = readString() ?: return null
26 | println("read class $ignoredClass, but ignore this and read with $creator")
27 | return creator.createFromParcel(this)
28 | }
29 |
30 | fun Parcel.writeAliasedArray(value: Array?, flags: Int) {
31 | writeParcelableArray(value, flags)
32 | }
33 |
34 | fun Parcel.readParcelableArray(clazz: Class): Array? {
35 | return readParcelableArray(clazz.classLoader)
36 | }
37 |
--------------------------------------------------------------------------------
/src/main/java/ru/evotor/framework/users/UserMapper.kt:
--------------------------------------------------------------------------------
1 | package ru.evotor.framework.users
2 |
3 | import android.database.Cursor
4 | import ru.evotor.framework.optString
5 |
6 | internal object UserMapper {
7 | fun createGrant(cursor: Cursor): Grant {
8 | return Grant(
9 | title = cursor.getString(cursor.getColumnIndex(GrantsTable.ROW_TITLE)),
10 | roleUuid = cursor.getString(cursor.getColumnIndex(GrantsTable.ROW_ROLE_UUID))
11 | )
12 | }
13 |
14 | fun createUser(cursor: Cursor): User {
15 | return User(
16 | uuid = cursor.getString(cursor.getColumnIndex(UsersTable.ROW_USER_UUID)),
17 | secondName = cursor.optString(UsersTable.ROW_USER_SECOND_NAME),
18 | firstName = cursor.optString(UsersTable.ROW_USER_FIRST_NAME),
19 | inn = cursor.optString(UsersTable.ROW_USER_INN),
20 | phone = cursor.optString(UsersTable.ROW_USER_PHONE),
21 | pin = cursor.optString(UsersTable.ROW_USER_PIN),
22 | roleUuid = cursor.getString(cursor.getColumnIndex(UsersTable.ROW_ROLE_UUID)),
23 | roleTitle = cursor.getString(cursor.getColumnIndex(UsersTable.ROW_ROLE_TITLE)),
24 | position = cursor.optString(UsersTable.ROW_USER_POSITION)
25 | )
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/main/java/ru/evotor/integrations/BarcodeBroadcastReceiver.kt:
--------------------------------------------------------------------------------
1 | package ru.evotor.integrations
2 |
3 | import android.content.BroadcastReceiver
4 | import android.content.Context
5 | import android.content.Intent
6 | import android.content.IntentFilter
7 |
8 | /**
9 | * Created by nixan on 28.04.17.
10 | */
11 |
12 | abstract class BarcodeBroadcastReceiver : BroadcastReceiver() {
13 | override fun onReceive(context: Context?, intent: Intent?) {
14 | intent?.extras?.getString(EXTRA_SCANNED_CODE)?.let { code ->
15 | if (code.isNotEmpty()) {
16 | onBarcodeReceived(code, context)
17 | }
18 | }
19 | }
20 |
21 | public abstract fun onBarcodeReceived(barcode: String, context: Context?)
22 |
23 | companion object {
24 | @JvmField
25 | public val ACTION_SCANNED = "ru.evotor.devices.ScannedCode"
26 |
27 | @JvmField
28 | public val EXTRA_SCANNED_CODE = "ScannedCode"
29 |
30 | @JvmField
31 | public val SENDER_PERMISSION = "ru.evotor.devices.SCANNER_SENDER"
32 |
33 | @JvmField
34 | public val RECEIVER_PERMISSION = "ru.evotor.devices.SCANNER_RECEIVER"
35 |
36 | @JvmField
37 | public val BARCODE_INTENT_FILTER = IntentFilter(ACTION_SCANNED)
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | [](https://jitpack.io/#evotor/integration-library)
2 | [](https://gitter.im/evotor/integration-library.svg)
3 |
4 | В build.gradle проекта добавьте ссылку на репозиторий jitpack:
5 |
6 | ```
7 | allprojects {
8 | repositories {
9 | jcenter()
10 | maven { url 'https://jitpack.io' }
11 | }
12 | }
13 | ```
14 |
15 | в модуле `build.gradle` добавьте зависимость и укажите точную версию:
16 |
17 | ```
18 | dependencies {
19 | implementation 'com.github.evotor:integration-library:v0.6.+'
20 | }
21 | ```
22 |
23 | и укажите minSdkVersion проекта:
24 | ```
25 | defaultConfig {
26 | minSdkVersion 23
27 | ...
28 | }
29 | ```
30 |
31 | В этом проекте описаны все необходимые интерфейсы, константы и пр., необходимые для работы с оборудованием на смарт-терминале Эвотор.
32 | Разделы проекта:
33 |
34 | 1. Разработка приложений.
35 | 1.1. [SDK для принтера Эвотор](https://github.com/evotor/integration-library/blob/master/Read_me_files/README_printer.md#1011)
36 |
37 | ###### Более подробную информацию по разрабатке своих решений для бизнеса на платформе Эвотор, Вы можете найти на нашем сайте для разработчиков: https://developer.evotor.ru/
38 |
--------------------------------------------------------------------------------
/src/main/java/ru/evotor/framework/calculator/PercentCalculator.java:
--------------------------------------------------------------------------------
1 | package ru.evotor.framework.calculator;
2 |
3 | import java.math.BigDecimal;
4 | import java.util.Objects;
5 |
6 | import androidx.annotation.NonNull;
7 |
8 | public abstract class PercentCalculator {
9 | private static final BigDecimal HUNDRED = new BigDecimal("100");
10 | private static final int PERCENT_PRECISION = 6;
11 |
12 | public static BigDecimal calcPercent(BigDecimal total, BigDecimal part) {
13 | if (total.compareTo(BigDecimal.ZERO) == 0) {
14 | return BigDecimal.ZERO;
15 | }
16 | return part.multiply(HUNDRED).divide(total, PERCENT_PRECISION, BigDecimal.ROUND_HALF_UP);
17 | }
18 |
19 | public static BigDecimal add(BigDecimal value1, BigDecimal value2) {
20 | return value1.add(value2);
21 | }
22 |
23 | public static BigDecimal toBigDecimal(double value) {
24 | BigDecimal bigDecimalValue = BigDecimal.valueOf(value);
25 | return bigDecimalValue.setScale(PERCENT_PRECISION, BigDecimal.ROUND_HALF_UP);
26 | }
27 |
28 | @NonNull
29 | public static BigDecimal round(@NonNull BigDecimal value) {
30 | Objects.requireNonNull(value);
31 | return value.setScale(PERCENT_PRECISION, BigDecimal.ROUND_HALF_UP);
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/src/main/java/ru/evotor/framework/core/action/event/receipt/changes/position/PositionRemove.kt:
--------------------------------------------------------------------------------
1 | package ru.evotor.framework.core.action.event.receipt.changes.position
2 |
3 | import android.os.Bundle
4 | import ru.evotor.framework.core.action.event.receipt.changes.IChange
5 |
6 | /**
7 | * Удаляет позицию из чека.
8 | * @param positionUuid – идентификатор позиции, которую требуется удалить.
9 | */
10 | data class PositionRemove(
11 | private val positionUuid: String
12 | ) : IPositionChange {
13 | override fun toBundle(): Bundle {
14 | return Bundle().apply {
15 | putString(
16 | KEY_POSITION_UUID,
17 | positionUuid
18 | )
19 | }
20 | }
21 |
22 | override fun getPositionUuid(): String? {
23 | return positionUuid
24 | }
25 |
26 | override fun getType(): IChange.Type {
27 | return IChange.Type.POSITION_REMOVE
28 | }
29 |
30 | companion object {
31 | const val KEY_POSITION_UUID = "positionUuid"
32 |
33 | @JvmStatic
34 | fun from(bundle: Bundle?): PositionRemove? {
35 | bundle ?: return null
36 |
37 | return PositionRemove(
38 | bundle.getString(KEY_POSITION_UUID) ?: return null
39 | )
40 | }
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/src/main/java/ru/evotor/framework/counterparties/collaboration/agent_scheme/mapper/SubagentMapper.kt:
--------------------------------------------------------------------------------
1 | package ru.evotor.framework.counterparties.collaboration.agent_scheme.mapper
2 |
3 | import android.os.Bundle
4 | import ru.evotor.framework.counterparties.collaboration.agent_scheme.Subagent
5 | import ru.evotor.framework.counterparties.mapper.CounterpartyMapper
6 |
7 | internal object SubagentMapper {
8 | private const val KEY_TYPE = "TYPE"
9 |
10 | fun read(bundle: Bundle?): Subagent? =
11 | bundle?.let {
12 | Subagent(
13 | uuid = CounterpartyMapper.readUuid(it),
14 | type = Subagent.Type.values()[it.getInt(KEY_TYPE)],
15 | counterpartyType = CounterpartyMapper.readCounterpartyType(it),
16 | fullName = CounterpartyMapper.readFullName(it),
17 | shortName = CounterpartyMapper.readShortName(it),
18 | inn = CounterpartyMapper.readInn(it),
19 | kpp = CounterpartyMapper.readKpp(it),
20 | phones = CounterpartyMapper.readPhones(it),
21 | addresses = CounterpartyMapper.readAddresses(it)
22 | )
23 | }
24 |
25 | fun write(subagent: Subagent, bundle: Bundle) = bundle.apply {
26 | this.putInt(KEY_TYPE, subagent.type.ordinal)
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/src/main/java/ru/evotor/framework/receipt/formation/event/DiscountScreenAdditionalItemsEvent.kt:
--------------------------------------------------------------------------------
1 | package ru.evotor.framework.receipt.formation.event
2 |
3 | import android.os.Bundle
4 | import ru.evotor.framework.common.event.IntegrationEvent
5 |
6 | /**
7 | * Событие, которое смарт-терминал рассылает при нажатии на иконку приложения на экране оплаты чеков продажи или возврата.
8 | *
9 | * Подпишитесь на это событие чтобы запускать операции или службы своего приложения.
10 | *
11 | * Обрабатывайте событие с помощью соответствующих методов служб [ru.evotor.framework.receipt.formation.event.handler.service.SellIntegrationService] и [ru.evotor.framework.receipt.formation.event.handler.service.PaybackIntegrationService].
12 | */
13 | data class DiscountScreenAdditionalItemsEvent(
14 | val receiptUuid: String
15 | ) : IntegrationEvent() {
16 | override fun toBundle() = Bundle().apply {
17 | putString(KEY_RECEIPT_UUID, receiptUuid)
18 | }
19 |
20 | companion object {
21 | const val KEY_RECEIPT_UUID = "KEY_RECEIPT_UUID"
22 |
23 | @JvmStatic
24 | fun from(bundle: Bundle?) = bundle?.let {
25 | DiscountScreenAdditionalItemsEvent(
26 | receiptUuid = it.getString(KEY_RECEIPT_UUID)
27 | ?: return null
28 | )
29 | }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/src/main/java/ru/evotor/devices/commons/printer/printable/PrintableImage.java:
--------------------------------------------------------------------------------
1 | package ru.evotor.devices.commons.printer.printable;
2 |
3 | import android.graphics.Bitmap;
4 | import android.os.Parcel;
5 |
6 | import ru.evotor.ParcelablesKt;
7 |
8 | public class PrintableImage implements IPrintable {
9 |
10 | /**
11 | * картинка для печати
12 | */
13 | private final Bitmap bitmap;
14 |
15 | public PrintableImage(Bitmap bitmap) {
16 | this.bitmap = bitmap;
17 | }
18 |
19 | private PrintableImage(Parcel parcel) {
20 | bitmap = ParcelablesKt.readAliased(parcel, Bitmap.CREATOR);
21 | }
22 |
23 | public Bitmap getBitmap() {
24 | return bitmap;
25 | }
26 |
27 | @Override
28 | public int describeContents() {
29 | return 0;
30 | }
31 |
32 | @Override
33 | public void writeToParcel(Parcel parcel, int i) {
34 | ParcelablesKt.writeAliased(parcel, bitmap, 0);
35 | }
36 |
37 | public static final Creator CREATOR = new Creator() {
38 |
39 | public PrintableImage createFromParcel(Parcel in) {
40 | return new PrintableImage(in);
41 | }
42 |
43 | public PrintableImage[] newArray(int size) {
44 | return new PrintableImage[size];
45 | }
46 | };
47 |
48 | }
49 |
--------------------------------------------------------------------------------
/src/main/java/ru/evotor/framework/core/action/event/receipt/changes/position/PositionEdit.kt:
--------------------------------------------------------------------------------
1 | package ru.evotor.framework.core.action.event.receipt.changes.position
2 |
3 | import android.os.Bundle
4 | import ru.evotor.framework.core.action.datamapper.PositionMapper
5 | import ru.evotor.framework.core.action.event.receipt.changes.IChange
6 | import ru.evotor.framework.receipt.Position
7 |
8 | /**
9 | * Изменяет позицию в чеке.
10 | * @param position – позиция.
11 | */
12 | data class PositionEdit(val position: Position) : IPositionChange {
13 | override fun toBundle(): Bundle {
14 | return Bundle().apply {
15 | putBundle(
16 | PositionMapper.KEY_POSITION,
17 | PositionMapper.toBundle(position)
18 | )
19 | }
20 | }
21 |
22 | override fun getPositionUuid(): String? {
23 | return position.uuid
24 | }
25 |
26 | override fun getType(): IChange.Type {
27 | return IChange.Type.POSITION_EDIT
28 | }
29 |
30 | companion object {
31 | @JvmStatic
32 | fun from(bundle: Bundle?): PositionEdit? {
33 | bundle ?: return null
34 |
35 | return PositionEdit(
36 | PositionMapper.from(bundle.getBundle(PositionMapper.KEY_POSITION)) ?: return null
37 | )
38 | }
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/src/main/java/ru/evotor/framework/core/action/event/receipt/payment/system/result/PaymentSystemPaymentResult.kt:
--------------------------------------------------------------------------------
1 | package ru.evotor.framework.core.action.event.receipt.payment.system.result
2 |
3 | import android.os.Bundle
4 | import ru.evotor.IBundlable
5 | import ru.evotor.framework.Utils
6 |
7 | abstract class PaymentSystemPaymentResult(
8 | val resultType: ResultType
9 | ) : IBundlable {
10 | override fun toBundle(): Bundle {
11 | val result = Bundle()
12 | result.putString(KEY_RESULT_TYPE, resultType.name)
13 | return result
14 | }
15 |
16 | public enum class ResultType {
17 | UNKNOWN,
18 | OK,
19 | ERROR
20 | }
21 |
22 | companion object {
23 | private val KEY_RESULT_TYPE = "resultType"
24 |
25 | fun create(bundle: Bundle?): PaymentSystemPaymentResult? {
26 | if (bundle == null) {
27 | return null
28 | }
29 | val resultType = Utils.safeValueOf(ResultType::class.java, bundle.getString(KEY_RESULT_TYPE, null), ResultType.UNKNOWN)
30 | return when (resultType) {
31 | ResultType.OK -> PaymentSystemPaymentOkResult.create(bundle)
32 | ResultType.ERROR -> PaymentSystemPaymentErrorResult.create(bundle)
33 | else -> null
34 | }
35 | }
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/src/main/java/ru/evotor/framework/core/action/command/print_cash_command/PrintCashIncomeCommandResult.kt:
--------------------------------------------------------------------------------
1 | package ru.evotor.framework.core.action.command.print_cash_command
2 |
3 | import android.os.Bundle
4 | import ru.evotor.IBundlable
5 |
6 | class PrintCashIncomeCommandResult : IBundlable {
7 | override fun toBundle(): Bundle =
8 | Bundle()
9 |
10 | companion object {
11 | /**
12 | * Поле "получатель" не может быть пустым
13 | */
14 | const val ERROR_CODE_EMPTY_PARTNER_NAME = -1
15 |
16 | /**
17 | * Поле "основание" не может быть пустым
18 | */
19 | const val ERROR_CODE_EMPTY_DESCRIPTION = -2
20 |
21 | /**
22 | * Сумма не может быть равна 0
23 | */
24 | const val ERROR_CODE_ZERO_SUM = -3
25 |
26 | /**
27 | * Ошибка при регистрации документа внесения
28 | */
29 | const val ERROR_CODE_DOCUMENT_NOT_REGISTERED = -4
30 |
31 | /**
32 | * Ошибка при работе с ККМ
33 | */
34 | const val ERROR_CODE_KKM_ERROR = -5
35 |
36 | fun create(bundle: Bundle?): PrintCashIncomeCommandResult? {
37 | return if (bundle == null) {
38 | null
39 | } else {
40 | PrintCashIncomeCommandResult()
41 | }
42 | }
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/src/main/java/ru/evotor/framework/core/action/event/receipt/changes/position/PositionAdd.kt:
--------------------------------------------------------------------------------
1 | package ru.evotor.framework.core.action.event.receipt.changes.position
2 |
3 | import android.os.Bundle
4 | import ru.evotor.framework.core.action.datamapper.PositionMapper
5 | import ru.evotor.framework.core.action.event.receipt.changes.IChange
6 | import ru.evotor.framework.receipt.Position
7 |
8 | /**
9 | * Добавляет позицию в чек.
10 | * @param position – позиция.
11 | */
12 | data class PositionAdd(val position: Position) : IPositionChange {
13 | override fun toBundle(): Bundle {
14 | return Bundle().apply {
15 | putBundle(
16 | PositionMapper.KEY_POSITION,
17 | PositionMapper.toBundle(position)
18 | )
19 | }
20 | }
21 |
22 | override fun getPositionUuid(): String? {
23 | return position.uuid
24 | }
25 |
26 | override fun getType(): IChange.Type {
27 | return IChange.Type.POSITION_ADD
28 | }
29 |
30 | companion object {
31 | @JvmStatic
32 | fun from(bundle: Bundle?): PositionAdd? {
33 | bundle ?: return null
34 |
35 | return PositionAdd(
36 | PositionMapper.from(
37 | bundle.getBundle(PositionMapper.KEY_POSITION)
38 | ) ?: return null
39 | )
40 | }
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/src/main/java/ru/evotor/framework/calculator/QuantityCalculator.java:
--------------------------------------------------------------------------------
1 | package ru.evotor.framework.calculator;
2 |
3 | import java.math.BigDecimal;
4 | import java.util.Objects;
5 |
6 | import androidx.annotation.NonNull;
7 |
8 | public abstract class QuantityCalculator {
9 |
10 | private static final int QUANTITY_PRECISION = 3;
11 |
12 | public static BigDecimal add(BigDecimal value1, BigDecimal value2) {
13 | return value1.add(value2);
14 | }
15 |
16 | public static BigDecimal subtract(BigDecimal value, BigDecimal subtrahend) {
17 | return value.subtract(subtrahend);
18 | }
19 |
20 | public static BigDecimal divide(BigDecimal quantity, BigDecimal divisor) {
21 | return quantity.divide(divisor, QUANTITY_PRECISION, BigDecimal.ROUND_HALF_UP);
22 | }
23 |
24 | public static BigDecimal multiply(BigDecimal quantity, BigDecimal multiplicand) {
25 | return quantity.multiply(multiplicand).setScale(QUANTITY_PRECISION, BigDecimal.ROUND_HALF_UP);
26 | }
27 |
28 | @NonNull
29 | public static BigDecimal toBigDecimal(double value) {
30 | return round(BigDecimal.valueOf(value));
31 | }
32 |
33 | @NonNull
34 | public static BigDecimal round(@NonNull BigDecimal value) {
35 | Objects.requireNonNull(value);
36 | return value.setScale(QUANTITY_PRECISION, BigDecimal.ROUND_HALF_UP);
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/src/main/java/ru/evotor/framework/core/action/event/receipt/receipt_edited/ReceiptPrintGroupEditedEvent.java:
--------------------------------------------------------------------------------
1 | package ru.evotor.framework.core.action.event.receipt.receipt_edited;
2 |
3 |
4 | import android.os.Bundle;
5 |
6 | import androidx.annotation.NonNull;
7 | import androidx.annotation.Nullable;
8 |
9 | public class ReceiptPrintGroupEditedEvent extends ReceiptEvent {
10 | public static final String BROADCAST_ACTION_SELL_RECEIPT = "evotor.intent.action.receipt.sell.printGroup.EDITED";
11 | public static final String BROADCAST_ACTION_PAYBACK_RECEIPT = "evotor.intent.action.receipt.payback.printGroup.EDITED";
12 | public static final String BROADCAST_ACTION_BUY_RECEIPT = "evotor.intent.action.receipt.buy.printGroup.EDITED";
13 | public static final String BROADCAST_ACTION_BUYBACK_RECEIPT = "evotor.intent.action.receipt.buyback.printGroup.EDITED";
14 |
15 | public ReceiptPrintGroupEditedEvent(@NonNull String receiptUuid) {
16 | super(receiptUuid);
17 | }
18 |
19 | @Nullable
20 | public static ReceiptPrintGroupEditedEvent create(@Nullable Bundle bundle) {
21 | if (bundle == null) {
22 | return null;
23 | }
24 | String receiptUuid = getReceiptUuid(bundle);
25 | if (receiptUuid == null) {
26 | return null;
27 | }
28 | return new ReceiptPrintGroupEditedEvent(receiptUuid);
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/src/main/java/ru/evotor/framework/core/action/event/receipt/receipt_edited/ReceiptOpenedEvent.java:
--------------------------------------------------------------------------------
1 | package ru.evotor.framework.core.action.event.receipt.receipt_edited;
2 |
3 |
4 | import android.os.Bundle;
5 |
6 | import androidx.annotation.NonNull;
7 | import androidx.annotation.Nullable;
8 |
9 | /**
10 | * @deprecated Используйте {@link ru.evotor.framework.receipt.event.ReceiptCreatedEvent}
11 | */
12 | @Deprecated
13 | public class ReceiptOpenedEvent extends ReceiptEvent {
14 | public static final String BROADCAST_ACTION_SELL_RECEIPT = "evotor.intent.action.receipt.sell.OPENED";
15 | public static final String BROADCAST_ACTION_PAYBACK_RECEIPT = "evotor.intent.action.receipt.payback.OPENED";
16 | public static final String BROADCAST_ACTION_BUY_RECEIPT = "evotor.intent.action.receipt.buy.OPENED";
17 | public static final String BROADCAST_ACTION_BUYBACK_RECEIPT = "evotor.intent.action.receipt.buyback.OPENED";
18 |
19 | public ReceiptOpenedEvent(@NonNull String receiptUuid) {
20 | super(receiptUuid);
21 | }
22 |
23 | @Nullable
24 | public static ReceiptOpenedEvent create(@Nullable Bundle bundle) {
25 | if (bundle == null) {
26 | return null;
27 | }
28 | String receiptUuid = getReceiptUuid(bundle);
29 | if (receiptUuid == null) {
30 | return null;
31 | }
32 | return new ReceiptOpenedEvent(receiptUuid);
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/src/main/java/ru/evotor/framework/inventory/event/handler/receiver/InventoryBroadcastReceiver.kt:
--------------------------------------------------------------------------------
1 | package ru.evotor.framework.inventory.event.handler.receiver
2 |
3 | import android.content.Context
4 | import android.os.Bundle
5 | import ru.evotor.framework.core.RequiresIntentAction
6 | import ru.evotor.framework.core.BroadcastEventReceiver
7 | import ru.evotor.framework.inventory.event.ProductCardOpenedEvent
8 |
9 | /**
10 | * Широковещательный приёмник товароучётных событий.
11 | * @see Использование широковещательного приёмника
12 | */
13 | open class InventoryBroadcastReceiver : BroadcastEventReceiver() {
14 | /**
15 | * Обработчик событий открытия карточки товара.
16 | */
17 | @RequiresIntentAction(ACTION_PRODUCT_CARD_OPENED)
18 | protected open fun handleProductCardOpenedEvent(context: Context, event: ProductCardOpenedEvent) = Unit
19 |
20 | final override fun onEvent(context: Context, action: String, bundle: Bundle) {
21 | when (action) {
22 | ACTION_PRODUCT_CARD_OPENED -> handleProductCardOpenedEvent(
23 | context,
24 | ProductCardOpenedEvent.from(bundle)
25 | ?: return
26 | )
27 | }
28 | }
29 |
30 | companion object {
31 | const val ACTION_PRODUCT_CARD_OPENED = "evotor.intent.action.inventory.CARD_OPEN"
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/src/main/java/ru/evotor/framework/core/action/event/receipt/error_card_payment/actions/PaymentByCardErrorAction.kt:
--------------------------------------------------------------------------------
1 | package ru.evotor.framework.core.action.event.receipt.error_card_payment.actions
2 |
3 | import android.os.Bundle
4 |
5 | /**
6 | * Команда обработки ошибки оплаты по карте.
7 | * При передаче этой команды будет показан диалог с ошибкой.
8 | * Если был передан cancelTimeout, то по истечении будет нажата кнопка "ОТМЕНА".
9 | */
10 | class PaymentByCardErrorAction(
11 | // таймаут нажатия на кнопку "ОТМЕНА" в секундах
12 | val cancelTimeout: UInt? = null
13 | ) : IHandleEventResultAction {
14 | override fun getType(): IHandleEventResultAction.Type {
15 | return IHandleEventResultAction.Type.SHOW_ERROR_SCREEN_ACTION
16 | }
17 |
18 | override fun toBundle(): Bundle {
19 | return Bundle().also {
20 | if (cancelTimeout != null) {
21 | it.putLong(KEY_TIMEOUT, cancelTimeout.toLong())
22 | }
23 | }
24 | }
25 |
26 | companion object {
27 | private const val KEY_TIMEOUT = "timeout"
28 |
29 | fun from(bundle: Bundle): PaymentByCardErrorAction {
30 | var timeout: Long? = bundle.getLong(KEY_TIMEOUT, -1L)
31 | if (timeout == -1L) {
32 | timeout = null
33 | }
34 | return PaymentByCardErrorAction(
35 | timeout?.toUInt()
36 | )
37 | }
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/src/main/java/ru/evotor/framework/device/cash_drawer/event/handler/receiver/CashDrawerBroadcastReceiver.kt:
--------------------------------------------------------------------------------
1 | package ru.evotor.framework.device.cash_drawer.event.handler.receiver
2 |
3 | import android.content.Context
4 | import android.os.Bundle
5 | import ru.evotor.framework.core.RequiresIntentAction
6 | import ru.evotor.framework.core.BroadcastEventReceiver
7 | import ru.evotor.framework.device.cash_drawer.event.CashDrawerOpenedEvent
8 |
9 | /**
10 | * Широковещательный приёмник событий денежного ящика.
11 | * @see Использование широковещательного приёмника
12 | */
13 | abstract class CashDrawerBroadcastReceiver : BroadcastEventReceiver() {
14 | /**
15 | * Обработчик событий открытия денежного ящика.
16 | */
17 | @RequiresIntentAction(ACTION_CASH_DRAWER_OPENED)
18 | protected abstract fun handleCashDrawerOpenedEvent(context: Context, event: CashDrawerOpenedEvent)
19 |
20 | final override fun onEvent(context: Context, action: String, bundle: Bundle) {
21 | when (action) {
22 | ACTION_CASH_DRAWER_OPENED -> handleCashDrawerOpenedEvent(
23 | context,
24 | CashDrawerOpenedEvent.from(bundle)
25 | ?: return
26 | )
27 | }
28 | }
29 |
30 | companion object {
31 | const val ACTION_CASH_DRAWER_OPENED = "evotor.intent.action.cashDrawer.OPEN"
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/src/main/java/ru/evotor/framework/receipt/position/mapper/MarksCheckingInfoMapper.kt:
--------------------------------------------------------------------------------
1 | package ru.evotor.framework.receipt.position.mapper
2 |
3 | import android.database.Cursor
4 | import ru.evotor.framework.optLong
5 | import ru.evotor.framework.optString
6 | import ru.evotor.framework.receipt.PositionTable
7 | import ru.evotor.framework.receipt.position.LocalModuleInfo
8 | import ru.evotor.framework.receipt.position.MarksCheckingInfo
9 |
10 | object MarksCheckingInfoMapper {
11 | internal fun fromCursor(cursor: Cursor): MarksCheckingInfo? {
12 | val checkId = cursor.optString(PositionTable.COLUMN_MARKS_CHECKING_INFO_CHECK_ID)
13 | ?: return null
14 | val checkTimestamp = cursor.optLong(PositionTable.COLUMN_MARKS_CHECKING_INFO_CHECK_TIMESTAMP)
15 | ?: return null
16 | val inst = cursor.optString(PositionTable.COLUMN_MARKS_CHECKING_INFO_CHECK_INST)
17 | val lmChzDbVersion = cursor.optString(PositionTable.COLUMN_MARKS_CHECKING_INFO_CHECK_LM_CHZ_DB_VERSION)
18 | val localModuleInfo = if (inst != null && lmChzDbVersion != null) {
19 | LocalModuleInfo(
20 | inst,
21 | lmChzDbVersion
22 | )
23 | } else {
24 | null
25 | }
26 | return MarksCheckingInfo(
27 | checkId = checkId,
28 | checkTimestamp = checkTimestamp,
29 | localModuleInfo = localModuleInfo
30 | )
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/src/main/java/ru/evotor/framework/core/action/event/receipt/receipt_edited/ReceiptClearedEvent.java:
--------------------------------------------------------------------------------
1 | package ru.evotor.framework.core.action.event.receipt.receipt_edited;
2 |
3 |
4 | import android.os.Bundle;
5 |
6 | import androidx.annotation.NonNull;
7 | import androidx.annotation.Nullable;
8 |
9 | /**
10 | * @deprecated Используйте {@link ru.evotor.framework.receipt.event.ReceiptDeletedEvent}
11 | */
12 | @Deprecated
13 | public class ReceiptClearedEvent extends ReceiptEvent {
14 | public static final String BROADCAST_ACTION_SELL_RECEIPT_CLEARED = "evotor.intent.action.receipt.sell.CLEARED";
15 | public static final String BROADCAST_ACTION_PAYBACK_RECEIPT_CLEARED = "evotor.intent.action.receipt.payback.CLEARED";
16 | public static final String BROADCAST_ACTION_BUY_RECEIPT_CLEARED = "evotor.intent.action.receipt.buy.CLEARED";
17 | public static final String BROADCAST_ACTION_BUYBACK_RECEIPT_CLEARED = "evotor.intent.action.receipt.buyback.CLEARED";
18 |
19 | public ReceiptClearedEvent(@NonNull String receiptUuid) {
20 | super(receiptUuid);
21 | }
22 |
23 | @Nullable
24 | public static ReceiptClearedEvent create(@Nullable Bundle bundle) {
25 | if (bundle == null) {
26 | return null;
27 | }
28 | String receiptUuid = getReceiptUuid(bundle);
29 | if (receiptUuid == null) {
30 | return null;
31 | }
32 | return new ReceiptClearedEvent(receiptUuid);
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/src/main/java/ru/evotor/framework/core/action/event/receipt/receipt_edited/ReceiptClosedEvent.java:
--------------------------------------------------------------------------------
1 | package ru.evotor.framework.core.action.event.receipt.receipt_edited;
2 |
3 |
4 | import android.os.Bundle;
5 |
6 | import androidx.annotation.NonNull;
7 | import androidx.annotation.Nullable;
8 |
9 | /**
10 | * @deprecated Используйте {@link ru.evotor.framework.receipt.event.ReceiptCompletedEvent}
11 | */
12 | @Deprecated
13 | public class ReceiptClosedEvent extends ReceiptEvent {
14 | public static final String BROADCAST_ACTION_SELL_RECEIPT_CLOSED = "evotor.intent.action.receipt.sell.RECEIPT_CLOSED";
15 | public static final String BROADCAST_ACTION_PAYBACK_RECEIPT_CLOSED = "evotor.intent.action.receipt.payback.RECEIPT_CLOSED";
16 | public static final String BROADCAST_ACTION_BUY_RECEIPT_CLOSED = "evotor.intent.action.receipt.buy.RECEIPT_CLOSED";
17 | public static final String BROADCAST_ACTION_BUYBACK_RECEIPT_CLOSED = "evotor.intent.action.receipt.buyback.RECEIPT_CLOSED";
18 |
19 | public ReceiptClosedEvent(@NonNull String receiptUuid) {
20 | super(receiptUuid);
21 | }
22 |
23 | @Nullable
24 | public static ReceiptClosedEvent create(@Nullable Bundle bundle) {
25 | if (bundle == null) {
26 | return null;
27 | }
28 | String receiptUuid = getReceiptUuid(bundle);
29 | if (receiptUuid == null) {
30 | return null;
31 | }
32 | return new ReceiptClosedEvent(receiptUuid);
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/src/main/java/ru/evotor/framework/inventory/ProductTable.kt:
--------------------------------------------------------------------------------
1 | package ru.evotor.framework.inventory
2 |
3 | import android.net.Uri
4 |
5 | /**
6 | * Created by a.kuznetsov on 26/03/2017.
7 | */
8 | object ProductTable {
9 | @JvmField val URI = Uri.withAppendedPath(InventoryApi.BASE_URI, "Commodity")
10 |
11 | @JvmField val COMMODITY_BARCODE_URI = Uri.withAppendedPath(InventoryApi.BASE_URI, "CommodityBarcode")
12 |
13 | const val ROW_UUID = "UUID"
14 | const val ROW_CODE = "CODE"
15 | const val ROW_TYPE = "TYPE"
16 | const val ROW_PARENT_UUID = "PARENT_UUID"
17 | const val ROW_IS_GROUP = "IS_GROUP"
18 | const val ROW_NAME = "NAME"
19 | const val ROW_DESCRIPTION = "DESCRIPTION"
20 | const val ROW_PRICE_OUT = "PRICE_OUT"
21 | const val ROW_COST_PRICE = "COST_PRICE"
22 | const val ROW_QUANTITY = "QUANTITY"
23 | const val ROW_MEASURE_NAME = "MEASURE_NAME"
24 | const val ROW_MEASURE_PRECISION = "MEASURE_PRECISION"
25 | const val ROW_MEASURE_CODE = "MEASURE_CODE"
26 | const val ROW_ALCOHOL_BY_VOLUME = "ALCOHOL_BY_VOLUME"
27 | const val ROW_ALCOHOL_PRODUCT_KIND_CODE = "ALCOHOL_PRODUCT_KIND_CODE"
28 | const val ROW_TARE_VOLUME = "TARE_VOLUME"
29 | const val ROW_TAX_NUMBER = "TAX_NUMBER"
30 | const val ROW_CLASSIFICATION_CODE = "CLASSIFICATION_CODE"
31 | const val ROW_ALLOW_PARTIAL_SALE = "ALLOW_PARTIAL_SALE"
32 | const val ROW_IS_EXCISABLE = "IS_EXCISABLE"
33 | const val ROW_IS_AGE_LIMITED = "IS_AGE_LIMITED"
34 | }
35 |
--------------------------------------------------------------------------------
/src/main/java/ru/evotor/framework/receipt/attribute/VeterinaryAttribute.kt:
--------------------------------------------------------------------------------
1 | package ru.evotor.framework.receipt.attribute
2 |
3 | import android.os.Bundle
4 | import ru.evotor.IBundlable
5 | import ru.evotor.framework.receipt.position.mapper.VeterinaryAttributeMapper
6 |
7 | /**
8 | * Дополнительные реквизиты, которые необходимы для формирования структурного тега 1260 для ветеринарных препаратов
9 | */
10 | data class VeterinaryAttribute(
11 | /**
12 | * Тип документа, по которому отпускается препарат
13 | */
14 | val type: VeterinaryDocumentType,
15 | /**
16 | * Номер документа, не более 70 символов
17 | */
18 | val documentNumber: String,
19 | /**
20 | * Дата документа в формате ГГММДД
21 | */
22 | val documentDate: String
23 | ) : IBundlable {
24 | override fun toBundle(): Bundle = VeterinaryAttributeMapper.writeToBundle(this)
25 |
26 | companion object {
27 | /**
28 | * Текущая версия объекта VeterinaryAttribute.
29 | */
30 | const val VERSION = 1
31 |
32 | @JvmStatic
33 | fun from(bundle: Bundle?): VeterinaryAttribute? = VeterinaryAttributeMapper.readFromBundle(bundle)
34 | }
35 |
36 | /**
37 | * Тип документа, по которому отпускается препарат
38 | */
39 | enum class VeterinaryDocumentType {
40 | /**
41 | * Рецепт
42 | */
43 | VPR,
44 |
45 | /**
46 | * Требование
47 | */
48 | VPT
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/src/main/java/ru/evotor/framework/receipt/event/ApplyDiscountToReceiptEvent.kt:
--------------------------------------------------------------------------------
1 | package ru.evotor.framework.receipt.event
2 |
3 | import android.os.Bundle
4 |
5 | /**
6 | * Событие применения скидки к чеку.
7 | *
8 | * Происходит в результате применения скидки на чек.
9 | *
10 | * Обрабатывать это событие можно с помощью следующих широковещательных приёмников:
11 | * [ru.evotor.framework.receipt.event.handler.receiver.SellReceiptBroadcastReceiver]
12 | * [ru.evotor.framework.receipt.event.handler.receiver.PaybackReceiptBroadcastReceiver]
13 | * [ru.evotor.framework.receipt.event.handler.receiver.BuyReceiptBroadcastReceiver]
14 | * [ru.evotor.framework.receipt.event.handler.receiver.BuybackReceiptBroadcastReceiver]
15 | * [ru.evotor.framework.receipt.event.handler.receiver.CorrectionIncomeReceiptBroadcastReceiver]
16 | * [ru.evotor.framework.receipt.event.handler.receiver.CorrectionOutcomeReceiptBroadcastReceiver]
17 | * [ru.evotor.framework.receipt.event.handler.receiver.CorrectionReturnIncomeReceiptBroadcastReceiver]
18 | * [ru.evotor.framework.receipt.event.handler.receiver.CorrectionReturnOutcomeReceiptBroadcastReceiver]
19 | *
20 | * @param receiptUuid uuid чека
21 | */
22 | class ApplyDiscountToReceiptEvent(receiptUuid: String) : ReceiptEvent(receiptUuid) {
23 | companion object {
24 | fun from(bundle: Bundle?): ApplyDiscountToReceiptEvent? = bundle?.let {
25 | ApplyDiscountToReceiptEvent(ReceiptEvent.getReceiptUuid(it) ?: return null)
26 | }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/src/main/java/ru/evotor/framework/core/action/datamapper/ExtraKeyMapper.java:
--------------------------------------------------------------------------------
1 | package ru.evotor.framework.core.action.datamapper;
2 |
3 | import android.os.Bundle;
4 |
5 | import androidx.annotation.Nullable;
6 | import ru.evotor.framework.receipt.ExtraKey;
7 |
8 | public final class ExtraKeyMapper {
9 | private static final String KEY_IDENTITY = "identity";
10 | private static final String KEY_APP_ID = "appId";
11 | private static final String KEY_DESCRIPTION = "description";
12 |
13 | @Nullable
14 | public static ExtraKey from(@Nullable Bundle bundle) {
15 | if (bundle == null) {
16 | return null;
17 | }
18 | String identity = bundle.getString(KEY_IDENTITY);
19 | String appId = bundle.getString(KEY_APP_ID);
20 | String description = bundle.getString(KEY_DESCRIPTION);
21 | return new ExtraKey(
22 | identity,
23 | appId,
24 | description
25 | );
26 | }
27 |
28 | @Nullable
29 | public static Bundle toBundle(@Nullable ExtraKey extraKey) {
30 | if (extraKey == null) {
31 | return null;
32 | }
33 | Bundle bundle = new Bundle();
34 | bundle.putString(KEY_IDENTITY, extraKey.getIdentity());
35 | bundle.putString(KEY_APP_ID, extraKey.getAppId());
36 | bundle.putString(KEY_DESCRIPTION, extraKey.getDescription());
37 |
38 | return bundle;
39 | }
40 |
41 | private ExtraKeyMapper() {
42 | }
43 |
44 | }
45 |
--------------------------------------------------------------------------------
/src/main/java/ru/evotor/framework/core/action/command/print_cash_command/PrintCashOutcomeCommandResult.kt:
--------------------------------------------------------------------------------
1 | package ru.evotor.framework.core.action.command.print_cash_command
2 |
3 | import android.os.Bundle
4 | import ru.evotor.IBundlable
5 |
6 | class PrintCashOutcomeCommandResult : IBundlable {
7 | override fun toBundle(): Bundle = Bundle()
8 |
9 | companion object {
10 | /**
11 | * Поле "получатель" не может быть пустым
12 | */
13 | const val ERROR_CODE_EMPTY_PARTNER_NAME = -1
14 |
15 | /**
16 | * Поле "основание" не может быть пустым
17 | */
18 | const val ERROR_CODE_EMPTY_DESCRIPTION = -2
19 |
20 | /**
21 | * Сумма не может быть равна 0
22 | */
23 | const val ERROR_CODE_ZERO_SUM = -3
24 |
25 | /**
26 | * Указанный id категории платежа не найден в справочнике
27 | */
28 | const val ERROR_CODE_WRONG_PAYMENT_CATEGORY_ID = -4
29 |
30 | /**
31 | * Ошибка при регистрации документа внесения
32 | */
33 | const val ERROR_CODE_DOCUMENT_NOT_REGISTERED = -5
34 |
35 | /**
36 | * Ошибка при работе с ККМ
37 | */
38 | const val ERROR_CODE_KKM_ERROR = -6
39 |
40 | fun create(bundle: Bundle?): PrintCashOutcomeCommandResult? {
41 | return if (bundle == null) {
42 | null
43 | } else {
44 | PrintCashOutcomeCommandResult()
45 | }
46 | }
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/src/main/java/ru/evotor/framework/receipt/event/ReceiptCreatedEvent.kt:
--------------------------------------------------------------------------------
1 | package ru.evotor.framework.receipt.event
2 |
3 | import android.os.Bundle
4 |
5 | /**
6 | * Событие создания чека.
7 | *
8 | * Происходит при создании нового чека в системе смарт-терминала,
9 | * например, при открытии приложения "Продажа".
10 | *
11 | * Обрабатывать это событие можно с помощью следующих широковещательных приёмников:
12 | * [ru.evotor.framework.receipt.event.handler.receiver.SellReceiptBroadcastReceiver]
13 | * [ru.evotor.framework.receipt.event.handler.receiver.PaybackReceiptBroadcastReceiver]
14 | * [ru.evotor.framework.receipt.event.handler.receiver.BuyReceiptBroadcastReceiver]
15 | * [ru.evotor.framework.receipt.event.handler.receiver.BuybackReceiptBroadcastReceiver]
16 | * [ru.evotor.framework.receipt.event.handler.receiver.CorrectionIncomeReceiptBroadcastReceiver]
17 | * [ru.evotor.framework.receipt.event.handler.receiver.CorrectionOutcomeReceiptBroadcastReceiver]
18 | * [ru.evotor.framework.receipt.event.handler.receiver.CorrectionReturnIncomeReceiptBroadcastReceiver]
19 | * [ru.evotor.framework.receipt.event.handler.receiver.CorrectionReturnOutcomeReceiptBroadcastReceiver]
20 | *
21 | * @param receiptUuid uuid чека
22 | */
23 | class ReceiptCreatedEvent(receiptUuid: String) : ReceiptEvent(receiptUuid) {
24 | companion object {
25 | fun from(bundle: Bundle?): ReceiptCreatedEvent? = bundle?.let {
26 | ReceiptCreatedEvent(ReceiptEvent.getReceiptUuid(it) ?: return null)
27 | }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/main/java/ru/evotor/devices/commons/result/ResultVoid.java:
--------------------------------------------------------------------------------
1 | package ru.evotor.devices.commons.result;
2 |
3 | import android.os.Parcel;
4 | import android.os.Parcelable;
5 |
6 | import ru.evotor.devices.commons.exception.DeviceServiceException;
7 |
8 | public class ResultVoid extends AbstractResult implements Parcelable {
9 |
10 | private final ErrorDescription errorDescription;
11 |
12 | public ResultVoid(DeviceServiceException exc) {
13 | this.errorDescription = packException(exc);
14 | }
15 |
16 | private ResultVoid(Parcel parcel) {
17 | errorDescription = new ErrorDescription(parcel);
18 | }
19 |
20 | public void processAnswer() throws DeviceServiceException {
21 | this.unpackException();
22 | }
23 |
24 | @Override
25 | public ErrorDescription getErrorDescription() {
26 | return errorDescription;
27 | }
28 |
29 | @Override
30 | public void writeToParcel(Parcel parcel, int i) {
31 | if (errorDescription != null) {
32 | errorDescription.writeToParcel(parcel);
33 | }
34 | }
35 |
36 | @Override
37 | public int describeContents() {
38 | return 0;
39 | }
40 |
41 | public static final Creator CREATOR = new Creator() {
42 |
43 | public ResultVoid createFromParcel(Parcel in) {
44 | return new ResultVoid(in);
45 | }
46 |
47 | public ResultVoid[] newArray(int size) {
48 | return new ResultVoid[size];
49 | }
50 | };
51 |
52 | }
53 |
--------------------------------------------------------------------------------
/src/main/java/ru/evotor/framework/receipt/event/ReceiptCompletedEvent.kt:
--------------------------------------------------------------------------------
1 | package ru.evotor.framework.receipt.event
2 |
3 | import android.os.Bundle
4 |
5 | /**
6 | * Событие завершения чека.
7 | *
8 | * Происходит при успешном завершении формирования чека в системе смарт-терминала,
9 | * например, при успешном совершении продажи.
10 | *
11 | * Обрабатывать это событие можно с помощью следующих широковещательных приёмников:
12 | * [ru.evotor.framework.receipt.event.handler.receiver.SellReceiptBroadcastReceiver]
13 | * [ru.evotor.framework.receipt.event.handler.receiver.PaybackReceiptBroadcastReceiver]
14 | * [ru.evotor.framework.receipt.event.handler.receiver.BuyReceiptBroadcastReceiver]
15 | * [ru.evotor.framework.receipt.event.handler.receiver.BuybackReceiptBroadcastReceiver]
16 | * [ru.evotor.framework.receipt.event.handler.receiver.CorrectionIncomeReceiptBroadcastReceiver]
17 | * [ru.evotor.framework.receipt.event.handler.receiver.CorrectionOutcomeReceiptBroadcastReceiver]
18 | * [ru.evotor.framework.receipt.event.handler.receiver.CorrectionReturnIncomeReceiptBroadcastReceiver]
19 | * [ru.evotor.framework.receipt.event.handler.receiver.CorrectionReturnOutcomeReceiptBroadcastReceiver]
20 | *
21 | * @param receiptUuid uuid чека
22 | */
23 | class ReceiptCompletedEvent(receiptUuid: String) : ReceiptEvent(receiptUuid) {
24 | companion object {
25 | fun from(bundle: Bundle?): ReceiptCompletedEvent? = bundle?.let {
26 | ReceiptCompletedEvent(ReceiptEvent.getReceiptUuid(it) ?: return null)
27 | }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/main/java/ru/evotor/devices/commons/scales/Weight.java:
--------------------------------------------------------------------------------
1 | package ru.evotor.devices.commons.scales;
2 |
3 | import android.os.Parcel;
4 |
5 | import java.math.BigDecimal;
6 |
7 | import ru.evotor.devices.commons.result.AbstractInnerParcelable;
8 |
9 | public class Weight extends AbstractInnerParcelable {
10 |
11 | // вес, возвращённый весами
12 | private final BigDecimal weightInGrams;
13 | // поддерживали ли весы флаг стабильности при последнем взвешивании
14 | private final boolean supportStable;
15 | // было ли последнее взвешивание стабильным
16 | private final boolean stable;
17 |
18 | public Weight(BigDecimal weightInGrams, boolean supportStable, boolean stable) {
19 | this.weightInGrams = weightInGrams;
20 | this.supportStable = supportStable;
21 | this.stable = stable;
22 | }
23 |
24 | public BigDecimal getWeightInGrams() {
25 | return weightInGrams;
26 | }
27 |
28 | public boolean isSupportStable() {
29 | return supportStable;
30 | }
31 |
32 | public boolean isStable() {
33 | return stable;
34 | }
35 |
36 | public void writeToParcel(Parcel parcel) {
37 | parcel.writeSerializable(weightInGrams);
38 | parcel.writeInt(supportStable ? 1 : 0);
39 | parcel.writeInt(stable ? 1 : 0);
40 | }
41 |
42 | public Weight(Parcel parcel) {
43 | weightInGrams = (BigDecimal) parcel.readSerializable();
44 | supportStable = parcel.readInt() == 1;
45 | stable = parcel.readInt() == 1;
46 | }
47 |
48 | }
49 |
--------------------------------------------------------------------------------
/src/main/java/ru/evotor/framework/receipt/position/PreferentialMedicine.kt:
--------------------------------------------------------------------------------
1 | package ru.evotor.framework.receipt.position
2 |
3 | import android.os.Bundle
4 | import ru.evotor.IBundlable
5 | import ru.evotor.framework.receipt.position.PreferentialMedicine.PreferentialMedicineType
6 | import ru.evotor.framework.receipt.position.mapper.PreferentialMedicineMapper
7 | import java.math.BigDecimal
8 |
9 | /**
10 | * Льгота для позиции, используется при продаже лекарственных препаратов
11 | */
12 | data class PreferentialMedicine(
13 | /**
14 | * Тип льготы
15 | */
16 | val type: PreferentialMedicineType,
17 | /**
18 | * Сумма льготы.
19 | * Указывается только в случае рецепта с частичной льготой [PreferentialMedicineType.PARTIAL_PREFERENTIAL_MEDICINE]
20 | *
21 | * Это десятичное число с фиксированной точностью 2 знака после десятичного разделителя целой и дробной части.
22 | * Например, при субсидии 123 руб 00 коп значение 123.00
23 | */
24 | val preferentialValue: BigDecimal? = null
25 | ) : IBundlable {
26 | override fun toBundle(): Bundle = PreferentialMedicineMapper.writeToBundle(this)
27 |
28 | companion object {
29 | @JvmStatic
30 | fun from(bundle: Bundle?): PreferentialMedicine? = PreferentialMedicineMapper.readFromBundle(bundle)
31 | }
32 |
33 | /**
34 | * Тип льготы
35 | */
36 | enum class PreferentialMedicineType {
37 | FULL_PREFERENTIAL_MEDICINE,
38 | PARTIAL_PREFERENTIAL_MEDICINE,
39 | NON_PREFERENTIAL_MEDICINE
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/.editorconfig:
--------------------------------------------------------------------------------
1 | # indicate this is the root of the project
2 | # Если установлена в true, парсер не будет искать другие конфиги родительских папках
3 | root = true
4 |
5 | # noinspection EditorConfigKeyCorrectness
6 | [*.{kt,kts}]
7 | # possible values: number (e.g. 2), "unset" (makes ktlint ignore indentation completely)
8 | indent_size = 4
9 |
10 | # true (recommended) / false. Позволяет убедиться, что в конце файла всегда будет новая строка.
11 | insert_final_newline = true
12 |
13 | # Позволяет убрать пробелы из концов строк.
14 | trim_trailing_whitespace = true
15 |
16 | # possible values: number (e.g. 120) (package name, imports & comments are ignored), "off"
17 | # it's automatically set to 100 on `ktlint --android ...` (per Android Kotlin Style Guide)
18 | max_line_length = off
19 |
20 | ktlint_standard_package-name = disabled
21 | ktlint_standard_import-ordering = disabled
22 | ktlint_standard_multiline-expression-wrapping = disabled
23 | ktlint_standard_annotation = disabled
24 | ktlint_standard_function-type-modifier-spacing = disabled
25 | ktlint_standard_no-wildcard-imports = disabled
26 | ktlint_standard_trailing-comma-on-declaration-site = disabled
27 | ktlint_standard_trailing-comma-on-call-site = disabled
28 | ktlint_standard_function-signature = disabled
29 | ktlint_standard_parameter-list-wrapping = disabled
30 | ktlint_standard_chain-method-continuation = disabled
31 | ktlint_standard_function-expression-body = disabled
32 | ktlint_standard_class-signature = disabled
33 | ktlint_argument_list_wrapping_ignore_when_parameter_count_greater_or_equal_than = 8
--------------------------------------------------------------------------------
/src/main/java/ru/evotor/framework/core/action/event/receipt/payment/combined/result/PaymentDelegatorSelectedEventResult.kt:
--------------------------------------------------------------------------------
1 | package ru.evotor.framework.core.action.event.receipt.payment.combined.result
2 |
3 | import android.os.Bundle
4 | import ru.evotor.framework.core.action.datamapper.PaymentPurposeMapper
5 | import ru.evotor.framework.core.action.event.receipt.changes.receipt.SetExtra
6 | import ru.evotor.framework.payment.PaymentPurpose
7 |
8 | class PaymentDelegatorSelectedEventResult(
9 | val paymentPurpose: PaymentPurpose,
10 | extra: SetExtra?
11 | ) : PaymentDelegatorEventResult(ResultType.SELECTED, extra) {
12 | override fun toBundle(): Bundle {
13 | val result = super.toBundle()
14 | result.putBundle(KEY_PAYMENT_PURPOSE, PaymentPurposeMapper.toBundle(paymentPurpose))
15 | return result
16 | }
17 |
18 | companion object {
19 | private const val KEY_PAYMENT_PURPOSE = "paymentPurpose"
20 |
21 | fun create(bundle: Bundle?): PaymentDelegatorSelectedEventResult? {
22 | if (bundle == null) {
23 | return null
24 | }
25 | val paymentPurpose = bundle.getBundle(KEY_PAYMENT_PURPOSE)
26 | ?.let { PaymentPurposeMapper.from(it) }
27 | if (paymentPurpose != null) {
28 | return PaymentDelegatorSelectedEventResult(
29 | paymentPurpose,
30 | SetExtra.from(bundle.getBundle(KEY_RECEIPT_EXTRA))
31 | )
32 | }
33 | return null
34 | }
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/src/main/java/ru/evotor/framework/receipt/event/ReceiptDeletedEvent.kt:
--------------------------------------------------------------------------------
1 | package ru.evotor.framework.receipt.event
2 |
3 | import android.os.Bundle
4 |
5 | /**
6 | * Событие удаления чека.
7 | *
8 | * Происходит при удалении незавершенного чека из системы смарт-терминала,
9 | * например, при нажатии на кнопку "Удалить чек" в интерфейсе приложения "Продажа".
10 | *
11 | * Обрабатывать это событие можно с помощью следующих широковещательных приёмников:
12 | * [ru.evotor.framework.receipt.event.handler.receiver.SellReceiptBroadcastReceiver]
13 | * [ru.evotor.framework.receipt.event.handler.receiver.PaybackReceiptBroadcastReceiver]
14 | * [ru.evotor.framework.receipt.event.handler.receiver.BuyReceiptBroadcastReceiver]
15 | * [ru.evotor.framework.receipt.event.handler.receiver.BuybackReceiptBroadcastReceiver]
16 | * [ru.evotor.framework.receipt.event.handler.receiver.CorrectionIncomeReceiptBroadcastReceiver]
17 | * [ru.evotor.framework.receipt.event.handler.receiver.CorrectionOutcomeReceiptBroadcastReceiver]
18 | * [ru.evotor.framework.receipt.event.handler.receiver.CorrectionReturnIncomeReceiptBroadcastReceiver]
19 | * [ru.evotor.framework.receipt.event.handler.receiver.CorrectionReturnOutcomeReceiptBroadcastReceiver]
20 | *
21 | * @param receiptUuid uuid чека
22 | */
23 | class ReceiptDeletedEvent(receiptUuid: String) : ReceiptEvent(receiptUuid) {
24 | companion object {
25 | fun from(bundle: Bundle?): ReceiptDeletedEvent? = bundle?.let {
26 | ReceiptDeletedEvent(ReceiptEvent.getReceiptUuid(it) ?: return null)
27 | }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/main/java/ru/evotor/framework/core/action/event/receipt/payment/combined/result/PaymentDelegatorForwardedEventResult.kt:
--------------------------------------------------------------------------------
1 | package ru.evotor.framework.core.action.event.receipt.payment.combined.result
2 |
3 | import android.os.Bundle
4 | import ru.evotor.framework.component.PaymentDelegator
5 | import ru.evotor.framework.core.action.datamapper.PaymentDelegatorMapper
6 | import ru.evotor.framework.core.action.event.receipt.changes.receipt.SetExtra
7 |
8 | class PaymentDelegatorForwardedEventResult(
9 | val paymentDelegator: PaymentDelegator,
10 | extra: SetExtra?
11 | ) : PaymentDelegatorEventResult(ResultType.FORWARDED, extra) {
12 | override fun toBundle(): Bundle {
13 | val result = super.toBundle()
14 | result.putBundle(KEY_PAYMENT_DELEGATOR, PaymentDelegatorMapper.toBundle(paymentDelegator))
15 | return result
16 | }
17 |
18 | companion object {
19 | private const val KEY_PAYMENT_DELEGATOR = "paymentDelegator"
20 |
21 | fun create(bundle: Bundle?): PaymentDelegatorForwardedEventResult? {
22 | if (bundle == null) {
23 | return null
24 | }
25 | val paymentDelegator = bundle.getBundle(KEY_PAYMENT_DELEGATOR)
26 | ?.let { PaymentDelegator.from(it) }
27 | if (paymentDelegator != null) {
28 | return PaymentDelegatorForwardedEventResult(
29 | paymentDelegator,
30 | SetExtra.from(bundle.getBundle(KEY_RECEIPT_EXTRA))
31 | )
32 | }
33 | return null
34 | }
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/src/main/java/ru/evotor/framework/core/action/event/receipt/error_card_payment/ErrorPaymentByCardEventResult.kt:
--------------------------------------------------------------------------------
1 | package ru.evotor.framework.core.action.event.receipt.error_card_payment
2 |
3 | import android.os.Bundle
4 | import android.os.Parcelable
5 | import ru.evotor.IBundlable
6 | import ru.evotor.framework.core.action.event.receipt.error_card_payment.actions.IHandleEventResultAction
7 | import ru.evotor.framework.core.action.event.receipt.error_card_payment.actions.ErrorPaymentByCardActionMapper
8 |
9 | class ErrorPaymentByCardEventResult(
10 | val actions: List
11 | ) : IBundlable {
12 | override fun toBundle(): Bundle {
13 | val bundle = Bundle()
14 | val actionsParcelable = arrayOfNulls(actions.size)
15 | for (i in actionsParcelable.indices) {
16 | val action: IHandleEventResultAction = actions[i]
17 | actionsParcelable[i] = ErrorPaymentByCardActionMapper.toBundle(action)
18 | }
19 | bundle.putParcelableArray(KEY_ACTIONS, actionsParcelable)
20 | return bundle
21 | }
22 |
23 | companion object {
24 | private const val KEY_ACTIONS = "actions"
25 |
26 | fun create(bundle: Bundle?): ErrorPaymentByCardEventResult? {
27 | if (bundle == null) {
28 | return null
29 | }
30 | val actionsParcelable =
31 | bundle.getParcelableArray(KEY_ACTIONS)
32 | val actions = ErrorPaymentByCardActionMapper.create(actionsParcelable)
33 | return ErrorPaymentByCardEventResult(actions)
34 | }
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/src/main/java/ru/evotor/framework/core/action/datamapper/IntegrationComponentMapper.kt:
--------------------------------------------------------------------------------
1 | package ru.evotor.framework.core.action.datamapper
2 |
3 | import android.os.Bundle
4 | import ru.evotor.framework.component.IntegrationComponent
5 |
6 | object IntegrationComponentMapper {
7 | private const val KEY_PACKAGE_NAME = "packageName"
8 | private const val KEY_COMPONENT_NAME = "componentName"
9 | private const val KEY_APP_UUID = "appUuid"
10 | private const val KEY_APP_NAME = "appName"
11 |
12 | fun toBundle(integrationComponent: IntegrationComponent): Bundle =
13 | Bundle().apply {
14 | putString(KEY_PACKAGE_NAME, integrationComponent.packageName)
15 | putString(KEY_COMPONENT_NAME, integrationComponent.componentName)
16 | putString(KEY_APP_UUID, integrationComponent.appUuid)
17 | putString(KEY_APP_NAME, integrationComponent.appName)
18 | }
19 |
20 | fun fromBundle(bundle: Bundle?): IntegrationComponent? =
21 | bundle?.let {
22 | IntegrationComponent(
23 | bundle.getString(KEY_PACKAGE_NAME),
24 | bundle.getString(KEY_COMPONENT_NAME),
25 | bundle.getString(KEY_APP_UUID),
26 | bundle.getString(KEY_APP_NAME)
27 | )
28 | }
29 |
30 | fun readPackageName(bundle: Bundle?) = bundle?.getString(KEY_PACKAGE_NAME)
31 |
32 | fun readComponentName(bundle: Bundle?) = bundle?.getString(KEY_COMPONENT_NAME)
33 |
34 | fun readAppUuid(bundle: Bundle?) = bundle?.getString(KEY_APP_UUID)
35 |
36 | fun readAppName(bundle: Bundle?) = bundle?.getString(KEY_APP_NAME)
37 | }
38 |
--------------------------------------------------------------------------------
/src/main/java/ru/evotor/framework/core/IntegrationManager.java:
--------------------------------------------------------------------------------
1 | package ru.evotor.framework.core;
2 |
3 | import android.app.Activity;
4 | import android.content.ComponentName;
5 | import android.os.Bundle;
6 | import android.os.Handler;
7 |
8 | import ru.evotor.IBundlable;
9 |
10 | import java.util.Map;
11 |
12 | /**
13 | * Created by a.kuznetsov on 18/04/2017.
14 | */
15 |
16 | public interface IntegrationManager {
17 | String KEY_INTENT_DATA = "intentData";
18 | String KEY_INTEGRATION_RESPONSE = "integrationResponse";
19 | String KEY_SOURCE_DATA = "sourceData";
20 | String KEY_INTENT = "intent";
21 | String KEY_OPTIONS = "options";
22 | String KEY_SKIP = "skip";
23 | String KEY_DATA = "data";
24 |
25 | public IntegrationManagerFuture call(
26 | String action,
27 | ComponentName componentName,
28 | IBundlable data,
29 | Activity activity,
30 | IntegrationManagerCallback callback,
31 | Handler handler);
32 |
33 | public IntegrationManagerFuture call(
34 | String action,
35 | ComponentName componentName,
36 | Bundle data,
37 | Map packageSpecificTimeouts,
38 | ICanStartActivity activity,
39 | IntegrationManagerCallback callback,
40 | Handler handler);
41 |
42 | public IntegrationManagerFuture call(
43 | String action,
44 | ComponentName componentName,
45 | IBundlable data,
46 | ICanStartActivity activity,
47 | IntegrationManagerCallback callback,
48 | Handler handler);
49 |
50 | }
51 |
--------------------------------------------------------------------------------
/src/main/java/ru/evotor/framework/counterparties/collaboration/agent_scheme/Principal.kt:
--------------------------------------------------------------------------------
1 | package ru.evotor.framework.counterparties.collaboration.agent_scheme
2 |
3 | import android.os.Bundle
4 | import ru.evotor.framework.counterparties.Counterparty
5 | import ru.evotor.framework.counterparties.collaboration.agent_scheme.mapper.PrincipalMapper
6 | import ru.evotor.framework.kkt.FiscalRequisite
7 | import ru.evotor.framework.kkt.FiscalTags
8 | import java.util.*
9 |
10 | /**
11 | * Принципал (поставщик)
12 | */
13 | data class Principal(
14 | /**
15 | * Uuid контрагента
16 | */
17 | override val uuid: UUID? = null,
18 | /**
19 | * Тип контрагента
20 | */
21 | override val counterpartyType: Counterparty.Type? = null,
22 | /**
23 | * Наименование полное
24 | */
25 | override val fullName: String? = null,
26 | /**
27 | * Наименование краткое
28 | */
29 | @FiscalRequisite(tag = FiscalTags.PRINCIPAL_NAME)
30 | override val shortName: String,
31 | /**
32 | * ИНН
33 | */
34 | @FiscalRequisite(tag = FiscalTags.PRINCIPAL_INN)
35 | override val inn: String,
36 | /**
37 | * КПП
38 | */
39 | override val kpp: String? = null,
40 | /**
41 | * Телефоны
42 | */
43 | @FiscalRequisite(tag = FiscalTags.PRINCIPAL_PHONE, flags = FiscalRequisite.FLAG_MULTIPLE_VALUES)
44 | override val phones: List,
45 | /**
46 | * Адреса
47 | */
48 | override val addresses: List? = null
49 | ) : Counterparty() {
50 | companion object {
51 | fun from(bundle: Bundle?): Principal? = PrincipalMapper.read(bundle)
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/src/main/java/ru/evotor/framework/counterparties/collaboration/agent_scheme/mapper/AgentMapper.kt:
--------------------------------------------------------------------------------
1 | package ru.evotor.framework.counterparties.collaboration.agent_scheme.mapper
2 |
3 | import android.os.Bundle
4 | import ru.evotor.framework.counterparties.collaboration.agent_scheme.Agent
5 | import ru.evotor.framework.counterparties.mapper.CounterpartyMapper
6 |
7 | internal object AgentMapper {
8 | private const val KEY_TYPE = "TYPE"
9 |
10 | fun read(bundle: Bundle?): Agent? =
11 | bundle?.let {
12 | Agent(
13 | uuid = CounterpartyMapper.readUuid(it),
14 | type = if (it.containsKey(KEY_TYPE)) {
15 | Agent.Type.values()[it.getInt(KEY_TYPE)]
16 | } else {
17 | null
18 | },
19 | counterpartyType = CounterpartyMapper.readCounterpartyType(it),
20 | fullName = CounterpartyMapper.readFullName(it),
21 | shortName = CounterpartyMapper.readShortName(it),
22 | inn = CounterpartyMapper.readInn(it),
23 | kpp = CounterpartyMapper.readKpp(it),
24 | phones = CounterpartyMapper.readPhones(it),
25 | addresses = CounterpartyMapper.readAddresses(it)
26 | )
27 | }
28 |
29 | fun write(agent: Agent, bundle: Bundle) = bundle.apply {
30 | agent.type?.let { this.putInt(KEY_TYPE, it.ordinal) }
31 | }
32 |
33 | fun convertToNull(agent: Agent): Agent? =
34 | if (CounterpartyMapper.convertToNull(agent) == null && agent.type == null) {
35 | null
36 | } else {
37 | agent
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/src/main/java/ru/evotor/devices/commons/exception/error_extension/UsbHubStateErrorExtension.java:
--------------------------------------------------------------------------------
1 | package ru.evotor.devices.commons.exception.error_extension;
2 |
3 |
4 | import android.os.Parcel;
5 |
6 | public class UsbHubStateErrorExtension extends AbstractErrorExtension {
7 |
8 | private final UsbHubState state;
9 |
10 | public UsbHubStateErrorExtension(UsbHubState state) {
11 | this.state = state;
12 | }
13 |
14 | public UsbHubStateErrorExtension(Parcel parcel) {
15 | UsbHubState state;
16 | try {
17 | state = UsbHubState.valueOf(parcel.readString());
18 | } catch (IllegalArgumentException exc) {
19 | state = null;
20 | }
21 | this.state = state;
22 | }
23 |
24 | @Override
25 | public void writeToParcel(Parcel parcel) {
26 | parcel.writeString(state.name());
27 | }
28 |
29 | public UsbHubState getState() {
30 | return state;
31 | }
32 |
33 | public enum UsbHubState {
34 |
35 | /**
36 | * ожидаем инициализации хотя бы одного устройства в течении некоторого интервала времени
37 | */
38 | WAITING_FOR_DEVICE_BEFORE_RELOAD,
39 |
40 | /**
41 | * usb-хаб перезагружается
42 | */
43 | RELOADING,
44 |
45 | /**
46 | * usb-хаб перезагружен, ожидаем инициализации хотя бы одного устройства в течении некоторого интервала времени
47 | */
48 | WAITING_FOR_DEVICE_AFTER_RELOAD,
49 |
50 | /**
51 | * usb-хаб перезагружен, устройства не появились на шине за установленный период ожидания
52 | */
53 | HARDWARE_ERROR
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/src/main/java/ru/evotor/framework/receipt/position/ImportationData.kt:
--------------------------------------------------------------------------------
1 | package ru.evotor.framework.receipt.position
2 |
3 | import android.os.Bundle
4 | import ru.evotor.IBundlable
5 | import ru.evotor.framework.kkt.FiscalRequisite
6 | import ru.evotor.framework.kkt.FiscalTags
7 |
8 | /**
9 | * Данные об импорте продукции
10 | * Применяются к позиции чека.
11 | */
12 | data class ImportationData(
13 | /**
14 | * Код страны происхождения товара
15 | * Тег 1230
16 | */
17 | @FiscalRequisite(tag = FiscalTags.COUNTRY_ORIGIN_CODE)
18 | val countryOriginCode: String,
19 | /**
20 | * Номер таможенной декларации
21 | * Тег 1231
22 | */
23 | @FiscalRequisite(tag = FiscalTags.CUSTOM_DECLARATION_NUMBER)
24 | val customsDeclarationNumber: String
25 | ) : IBundlable {
26 | override fun toBundle(): Bundle = Bundle().apply {
27 | putString(KEY_COUNTRY_ORIGIN_CODE, countryOriginCode)
28 | putString(KEY_CUSTOM_DECLARATION_NUMBER, customsDeclarationNumber)
29 | }
30 |
31 | companion object {
32 | private const val KEY_COUNTRY_ORIGIN_CODE = "COUNTRY_ORIGIN_CODE"
33 | private const val KEY_CUSTOM_DECLARATION_NUMBER = "CUSTOM_DECLARATION_NUMBER"
34 |
35 | @JvmStatic
36 | fun from(bundle: Bundle?): ImportationData? {
37 | return bundle?.let {
38 | val countryOriginCode = it.getString(KEY_COUNTRY_ORIGIN_CODE) ?: return null
39 | val customDeclarationNumber = it.getString(KEY_CUSTOM_DECLARATION_NUMBER) ?: return null
40 |
41 | ImportationData(countryOriginCode, customDeclarationNumber)
42 | }
43 | }
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/src/main/java/ru/evotor/framework/core/action/event/receipt/changes/receipt/print_extra/SetPrintExtra.kt:
--------------------------------------------------------------------------------
1 | package ru.evotor.framework.core.action.event.receipt.changes.receipt.print_extra
2 |
3 | import android.os.Bundle
4 | import ru.evotor.devices.commons.printer.printable.IPrintable
5 | import ru.evotor.framework.core.action.datamapper.PrintExtraPlaceMapper
6 | import ru.evotor.framework.core.action.datamapper.PrintablesMapper
7 | import ru.evotor.framework.core.action.event.receipt.changes.IChange
8 | import ru.evotor.framework.receipt.print_extras.PrintExtraPlace
9 |
10 | class SetPrintExtra(
11 | val printPlace: PrintExtraPlace,
12 | val printables: Array
13 | ) : IChange {
14 | override fun getType() = IChange.Type.SET_PRINT_EXTRA
15 |
16 | override fun toBundle(): Bundle =
17 | Bundle().apply {
18 | putBundle(KEY_PRINT_PLACE, PrintExtraPlaceMapper.toBundle(printPlace))
19 | putBundle(KEY_PRINTABLES, PrintablesMapper.toBundle(printables))
20 | }
21 |
22 | companion object {
23 | const val KEY_PRINT_PLACE = "printPlace"
24 | const val KEY_PRINTABLES = "printables"
25 |
26 | @JvmStatic
27 | fun from(bundle: Bundle?): SetPrintExtra? {
28 | bundle ?: return null
29 |
30 | val printPlace = PrintExtraPlaceMapper.fromBundle(bundle.getBundle(KEY_PRINT_PLACE))
31 | val printables = PrintablesMapper.fromBundle(bundle.getBundle(KEY_PRINTABLES))
32 |
33 | if (printPlace == null || printables == null) {
34 | return null
35 | }
36 |
37 | return SetPrintExtra(printPlace, printables)
38 | }
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/src/main/java/ru/evotor/framework/core/action/command/print_unprinted_document/PrintUnprintedDocumentCommand.kt:
--------------------------------------------------------------------------------
1 | package ru.evotor.framework.core.action.command.print_unprinted_document
2 |
3 | import android.content.Context
4 | import android.os.Bundle
5 | import android.os.Handler
6 | import android.os.Looper
7 | import ru.evotor.IBundlable
8 | import ru.evotor.framework.core.ActivityStarter
9 | import ru.evotor.framework.core.IntegrationManagerCallback
10 | import ru.evotor.framework.core.IntegrationManagerImpl
11 |
12 | class PrintUnprintedDocumentCommand : IBundlable {
13 | fun process(context: Context, callback: IntegrationManagerCallback) {
14 | val componentNameList = IntegrationManagerImpl.convertImplicitIntentToExplicitIntent(
15 | NAME,
16 | context.applicationContext
17 | )
18 | if (componentNameList == null || componentNameList.isEmpty()) {
19 | return
20 | }
21 | IntegrationManagerImpl(context.applicationContext)
22 | .call(
23 | NAME,
24 | componentNameList[0],
25 | this,
26 | ActivityStarter(context),
27 | callback,
28 | Handler(Looper.getMainLooper())
29 | )
30 | }
31 |
32 | override fun toBundle(): Bundle {
33 | return Bundle()
34 | }
35 |
36 | companion object {
37 | const val NAME = "evo.v2.unprinted_document.print"
38 |
39 | @JvmStatic
40 | fun create(bundle: Bundle?): PrintUnprintedDocumentCommand? {
41 | return bundle?.let {
42 | PrintUnprintedDocumentCommand()
43 | }
44 | }
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/src/main/java/ru/evotor/framework/receipt/formation/event/CurrentReceiptDraftMovementToPaymentStageRequestedEvent.kt:
--------------------------------------------------------------------------------
1 | package ru.evotor.framework.receipt.formation.event
2 |
3 | import android.os.Bundle
4 | import ru.evotor.IBundlable
5 | import ru.evotor.framework.component.PaymentDelegator
6 | import ru.evotor.framework.component.PaymentPerformer
7 | import ru.evotor.framework.core.action.datamapper.PaymentDelegatorMapper
8 | import ru.evotor.framework.core.action.datamapper.PaymentPerformerMapper
9 |
10 | class CurrentReceiptDraftMovementToPaymentStageRequestedEvent internal constructor(
11 | val paymentDelegator: PaymentDelegator?,
12 | val paymentPerformer: PaymentPerformer?
13 | ) : IBundlable {
14 | override fun toBundle(): Bundle = Bundle().apply {
15 | paymentDelegator?.let { putBundle(KEY_PAYMENT_DELEGATOR, PaymentDelegatorMapper.toBundle(it)) }
16 | paymentPerformer?.let { putBundle(KEY_PAYMENT_PERFORMER, PaymentPerformerMapper.toBundle(it)) }
17 | }
18 |
19 | companion object {
20 | fun from(bundle: Bundle?): CurrentReceiptDraftMovementToPaymentStageRequestedEvent? = bundle?.let { b ->
21 | CurrentReceiptDraftMovementToPaymentStageRequestedEvent(
22 | b.getBundle(KEY_PAYMENT_DELEGATOR)?.let {
23 | PaymentDelegatorMapper.fromBundle(it)
24 | },
25 | b.getBundle(KEY_PAYMENT_PERFORMER)?.let {
26 | PaymentPerformerMapper.fromBundle(it)
27 | }
28 | )
29 | }
30 |
31 | private const val KEY_PAYMENT_PERFORMER = "paymentPerformer"
32 | private const val KEY_PAYMENT_DELEGATOR = "paymentDelegator"
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/src/main/java/ru/evotor/framework/core/action/event/receipt/position_edited/PositionAddedEvent.java:
--------------------------------------------------------------------------------
1 | package ru.evotor.framework.core.action.event.receipt.position_edited;
2 |
3 |
4 | import android.os.Bundle;
5 |
6 | import androidx.annotation.NonNull;
7 | import androidx.annotation.Nullable;
8 |
9 | import ru.evotor.framework.receipt.Position;
10 |
11 | /**
12 | * @deprecated Используйте {@link ru.evotor.framework.receipt.position.event.PositionAddedEvent}
13 | */
14 | @Deprecated
15 | public class PositionAddedEvent extends PositionEvent {
16 | public static final String BROADCAST_ACTION_SELL_RECEIPT = "evotor.intent.action.receipt.sell.POSITION_ADDED";
17 | public static final String BROADCAST_ACTION_PAYBACK_RECEIPT = "evotor.intent.action.receipt.payback.POSITION_ADDED";
18 | public static final String BROADCAST_ACTION_BUY_RECEIPT = "evotor.intent.action.receipt.buy.POSITION_ADDED";
19 | public static final String BROADCAST_ACTION_BUYBACK_RECEIPT = "evotor.intent.action.receipt.buyback.POSITION_ADDED";
20 |
21 | @Nullable
22 | public static PositionAddedEvent create(@Nullable Bundle extras) {
23 | if (extras == null) {
24 | return null;
25 | }
26 | String receiptUuid = getReceiptUuid(extras);
27 | if (receiptUuid == null) {
28 | return null;
29 | }
30 | Position position = getPosition(extras);
31 | if (position == null) {
32 | return null;
33 | }
34 | return new PositionAddedEvent(receiptUuid, position);
35 | }
36 |
37 | public PositionAddedEvent(@NonNull String receiptUuid, @NonNull Position position) {
38 | super(receiptUuid, position);
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/src/main/java/ru/evotor/devices/commons/result/ResultInt.java:
--------------------------------------------------------------------------------
1 | package ru.evotor.devices.commons.result;
2 |
3 | import android.os.Parcel;
4 | import android.os.Parcelable;
5 |
6 | import ru.evotor.devices.commons.exception.DeviceServiceException;
7 |
8 | public class ResultInt extends AbstractResult implements Parcelable {
9 |
10 | private final int result;
11 | private final ErrorDescription errorDescription;
12 |
13 | public ResultInt(int result, DeviceServiceException exc) {
14 | this.result = result;
15 | this.errorDescription = packException(exc);
16 | }
17 |
18 | private ResultInt(Parcel parcel) {
19 | result = parcel.readInt();
20 | errorDescription = new ErrorDescription(parcel);
21 | }
22 |
23 | public int getResult() throws DeviceServiceException {
24 | this.unpackException();
25 | return result;
26 | }
27 |
28 | @Override
29 | public ErrorDescription getErrorDescription() {
30 | return errorDescription;
31 | }
32 |
33 | @Override
34 | public void writeToParcel(Parcel parcel, int i) {
35 | parcel.writeInt(result);
36 | if (errorDescription != null) {
37 | errorDescription.writeToParcel(parcel);
38 | }
39 | }
40 |
41 | @Override
42 | public int describeContents() {
43 | return 0;
44 | }
45 |
46 | public static final Creator CREATOR = new Creator() {
47 |
48 | public ResultInt createFromParcel(Parcel in) {
49 | return new ResultInt(in);
50 | }
51 |
52 | public ResultInt[] newArray(int size) {
53 | return new ResultInt[size];
54 | }
55 | };
56 |
57 | }
58 |
--------------------------------------------------------------------------------
/src/main/java/ru/evotor/framework/core/action/event/receipt/merges/PositionsMerge.kt:
--------------------------------------------------------------------------------
1 | package ru.evotor.framework.core.action.event.receipt.merges
2 |
3 | import android.os.Parcel
4 | import android.os.Parcelable
5 | import ru.evotor.framework.core.IntegrationLibraryParsingException
6 | import ru.evotor.framework.receipt.Position
7 | import ru.evotor.readAliased
8 | import ru.evotor.writeAliased
9 |
10 | /**
11 | * Created by ivan on 26.06.17.
12 | *
13 | * Класс представляет собой результат склеивания 2-х и более позиций в чеке для оповещения интеграций
14 | * before - список позиций, которые будут склеены
15 | * after - результат склейки
16 | */
17 |
18 | class PositionsMerge(val before: List, val after: Position) : Parcelable {
19 | override fun writeToParcel(parcel: Parcel, i: Int) {
20 | parcel.writeList(before)
21 | parcel.writeAliased(after, Parcelable.PARCELABLE_WRITE_RETURN_VALUE)
22 | }
23 |
24 | companion object {
25 | @JvmField
26 | val CREATOR: Parcelable.Creator = object : Parcelable.Creator {
27 | override fun createFromParcel(parcel: Parcel): PositionsMerge {
28 | val before = ArrayList()
29 | parcel.readList(before as List<*>, Position::class.java.classLoader)
30 | val after = parcel.readAliased(Position.CREATOR) ?: throw IntegrationLibraryParsingException(PositionsMerge::class.java)
31 | return PositionsMerge(before, after)
32 | }
33 |
34 | override fun newArray(size: Int): Array = arrayOfNulls(size)
35 | }
36 | }
37 |
38 | override fun describeContents(): Int = 0
39 | }
40 |
--------------------------------------------------------------------------------
/src/main/java/ru/evotor/framework/core/action/event/receipt/position_edited/PositionEditedEvent.java:
--------------------------------------------------------------------------------
1 | package ru.evotor.framework.core.action.event.receipt.position_edited;
2 |
3 |
4 | import android.os.Bundle;
5 |
6 | import androidx.annotation.NonNull;
7 | import androidx.annotation.Nullable;
8 |
9 | import ru.evotor.framework.receipt.Position;
10 |
11 | /**
12 | * @deprecated Используйте {@link ru.evotor.framework.receipt.position.event.PositionUpdatedEvent}
13 | */
14 | @Deprecated
15 | public class PositionEditedEvent extends PositionEvent {
16 | public static final String BROADCAST_ACTION_SELL_RECEIPT = "evotor.intent.action.receipt.sell.POSITION_EDITED";
17 | public static final String BROADCAST_ACTION_PAYBACK_RECEIPT = "evotor.intent.action.receipt.payback.POSITION_EDITED";
18 | public static final String BROADCAST_ACTION_BUY_RECEIPT = "evotor.intent.action.receipt.buy.POSITION_EDITED";
19 | public static final String BROADCAST_ACTION_BUYBACK_RECEIPT = "evotor.intent.action.receipt.buyback.POSITION_EDITED";
20 |
21 | @Nullable
22 | public static PositionEditedEvent create(@Nullable Bundle extras) {
23 | if (extras == null) {
24 | return null;
25 | }
26 | String receiptUuid = getReceiptUuid(extras);
27 | if (receiptUuid == null) {
28 | return null;
29 | }
30 | Position position = getPosition(extras);
31 | if (position == null) {
32 | return null;
33 | }
34 | return new PositionEditedEvent(receiptUuid, position);
35 | }
36 |
37 | public PositionEditedEvent(@NonNull String receiptUuid, @NonNull Position position) {
38 | super(receiptUuid, position);
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/src/main/java/ru/evotor/framework/calculator/MoneyCalculator.java:
--------------------------------------------------------------------------------
1 | package ru.evotor.framework.calculator;
2 |
3 | import java.math.BigDecimal;
4 | import java.util.Objects;
5 |
6 | import androidx.annotation.NonNull;
7 |
8 | public abstract class MoneyCalculator {
9 |
10 | private static final BigDecimal HUNDRED = new BigDecimal("100");
11 | public static final int MONEY_PRECISION = 2;
12 |
13 | public static BigDecimal add(BigDecimal value1, BigDecimal value2) {
14 | return value1.add(value2);
15 | }
16 |
17 | public static BigDecimal subtract(BigDecimal value, BigDecimal subtrahend) {
18 | return value.subtract(subtrahend);
19 | }
20 |
21 | public static BigDecimal divide(BigDecimal money, BigDecimal divisor) {
22 | return money.divide(divisor, MONEY_PRECISION, BigDecimal.ROUND_HALF_UP);
23 | }
24 |
25 | public static BigDecimal multiply(BigDecimal money, BigDecimal multiplicand) {
26 | return money.multiply(multiplicand).setScale(MONEY_PRECISION, BigDecimal.ROUND_HALF_UP);
27 | }
28 |
29 | public static BigDecimal calcPart(BigDecimal total, BigDecimal percent) {
30 | return total.multiply(percent).divide(HUNDRED, MONEY_PRECISION, BigDecimal.ROUND_HALF_UP);
31 | }
32 |
33 | public static BigDecimal toBigDecimal(double value) {
34 | BigDecimal bigDecimalValue = BigDecimal.valueOf(value);
35 | return bigDecimalValue.setScale(MONEY_PRECISION, BigDecimal.ROUND_HALF_UP);
36 | }
37 |
38 | @NonNull
39 | public static BigDecimal round(@NonNull BigDecimal value) {
40 | Objects.requireNonNull(value);
41 | return value.setScale(MONEY_PRECISION, BigDecimal.ROUND_HALF_UP);
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/src/main/java/ru/evotor/framework/core/action/event/receipt/position_edited/PositionRemovedEvent.java:
--------------------------------------------------------------------------------
1 | package ru.evotor.framework.core.action.event.receipt.position_edited;
2 |
3 |
4 | import android.os.Bundle;
5 |
6 | import androidx.annotation.NonNull;
7 | import androidx.annotation.Nullable;
8 |
9 | import ru.evotor.framework.receipt.Position;
10 |
11 | /**
12 | * @deprecated Используйте {@link ru.evotor.framework.receipt.position.event.PositionRemovedEvent}
13 | */
14 | @Deprecated
15 | public class PositionRemovedEvent extends PositionEvent {
16 | public static final String BROADCAST_ACTION_SELL_RECEIPT = "evotor.intent.action.receipt.sell.POSITION_REMOVED";
17 | public static final String BROADCAST_ACTION_PAYBACK_RECEIPT = "evotor.intent.action.receipt.payback.POSITION_REMOVED";
18 | public static final String BROADCAST_ACTION_BUY_RECEIPT = "evotor.intent.action.receipt.buy.POSITION_REMOVED";
19 | public static final String BROADCAST_ACTION_BUYBACK_RECEIPT = "evotor.intent.action.receipt.buyback.POSITION_REMOVED";
20 |
21 | @Nullable
22 | public static PositionRemovedEvent create(@Nullable Bundle extras) {
23 | if (extras == null) {
24 | return null;
25 | }
26 | String receiptUuid = getReceiptUuid(extras);
27 | if (receiptUuid == null) {
28 | return null;
29 | }
30 | Position position = getPosition(extras);
31 | if (position == null) {
32 | return null;
33 | }
34 | return new PositionRemovedEvent(receiptUuid, position);
35 | }
36 |
37 | public PositionRemovedEvent(@NonNull String receiptUuid, @NonNull Position position) {
38 | super(receiptUuid, position);
39 | }
40 | }
41 |
--------------------------------------------------------------------------------