├── .editorconfig ├── .gitignore ├── README.md ├── Read_me_files └── README_printer.md ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── packages.md ├── proguard-rules.pro └── src ├── main ├── AndroidManifest.xml ├── aidl │ └── ru │ │ └── evotor │ │ ├── devices │ │ └── commons │ │ │ ├── IPrinterService.aidl │ │ │ ├── IScalesService.aidl │ │ │ ├── printer │ │ │ └── PrinterDocument.aidl │ │ │ └── result │ │ │ ├── ResultBoolean.aidl │ │ │ ├── ResultDouble.aidl │ │ │ ├── ResultInt.aidl │ │ │ ├── ResultIntArray.aidl │ │ │ ├── ResultLong.aidl │ │ │ ├── ResultString.aidl │ │ │ ├── ResultVoid.aidl │ │ │ └── ResultWeight.aidl │ │ └── framework │ │ └── core │ │ ├── IIntegrationManager.aidl │ │ └── IIntegrationManagerResponse.aidl ├── java │ └── ru │ │ └── evotor │ │ ├── IBundlable.kt │ │ ├── UuidValidationUtils.kt │ │ ├── devices │ │ └── commons │ │ │ ├── ConnectionWrapper.java │ │ │ ├── Constants.java │ │ │ ├── DeviceServiceConnector.java │ │ │ ├── exception │ │ │ ├── DeviceNotFoundException.java │ │ │ ├── DeviceServiceException.java │ │ │ ├── DeviceServiceOperationOnMainThreadException.java │ │ │ ├── DeviceServiceRuntimeException.java │ │ │ ├── DriverException.java │ │ │ ├── NoPermanentInfoException.java │ │ │ ├── ServiceNotConnectedException.java │ │ │ ├── UnknownException.java │ │ │ ├── UsbHubProblemException.java │ │ │ └── error_extension │ │ │ │ ├── AbstractErrorExtension.java │ │ │ │ ├── DriverExceptionErrorExtension.java │ │ │ │ └── UsbHubStateErrorExtension.java │ │ │ ├── printer │ │ │ ├── PrinterDocument.java │ │ │ └── printable │ │ │ │ ├── IPrintable.java │ │ │ │ ├── PrintableBarcode.java │ │ │ │ ├── PrintableImage.java │ │ │ │ └── PrintableText.java │ │ │ ├── result │ │ │ ├── AbstractInnerParcelable.java │ │ │ ├── AbstractResult.java │ │ │ ├── ErrorDescription.java │ │ │ ├── ErrorDescriptionPacker.java │ │ │ ├── ResultBoolean.java │ │ │ ├── ResultDouble.java │ │ │ ├── ResultInt.java │ │ │ ├── ResultIntArray.java │ │ │ ├── ResultLong.java │ │ │ ├── ResultString.java │ │ │ ├── ResultVoid.java │ │ │ └── ResultWeight.java │ │ │ ├── scales │ │ │ └── Weight.java │ │ │ └── services │ │ │ ├── AbstractService.java │ │ │ ├── IPrinterServiceWrapper.java │ │ │ ├── IScalesServiceWrapper.java │ │ │ ├── PrinterService.java │ │ │ └── ScalesService.java │ │ ├── framework │ │ ├── BundleExt.kt │ │ ├── ColorUtils.kt │ │ ├── CursorExt.kt │ │ ├── Document.kt │ │ ├── FiscalDocument.kt │ │ ├── FutureFeature.kt │ │ ├── ParcelableUtils.kt │ │ ├── Utils.java │ │ ├── calculator │ │ │ ├── MoneyCalculator.java │ │ │ ├── PercentCalculator.java │ │ │ └── QuantityCalculator.java │ │ ├── common │ │ │ └── event │ │ │ │ ├── IntegrationEvent.kt │ │ │ │ └── handler │ │ │ │ └── service │ │ │ │ └── IntegrationServiceV2.kt │ │ ├── component │ │ │ ├── IntegrationComponent.kt │ │ │ ├── PaymentDelegator.kt │ │ │ ├── PaymentDelegatorApi.kt │ │ │ ├── PaymentPerformer.kt │ │ │ ├── PaymentPerformerApi.kt │ │ │ ├── PaymentPerformerTable.kt │ │ │ └── viewdata │ │ │ │ ├── IntegrationComponentViewData.kt │ │ │ │ ├── IntegrationComponentViewDataApi.kt │ │ │ │ └── PaymentPerformerViewData.kt │ │ ├── core │ │ │ ├── BroadcastEventReceiver.kt │ │ │ ├── ContextExt.kt │ │ │ ├── Error.java │ │ │ ├── ICanStartActivity.kt │ │ │ ├── IntegrationActivity.java │ │ │ ├── IntegrationAppCompatActivity.java │ │ │ ├── IntegrationException.java │ │ │ ├── IntegrationLibraryException.kt │ │ │ ├── IntegrationLibraryMappingException.kt │ │ │ ├── IntegrationLibraryParsingException.kt │ │ │ ├── IntegrationManager.java │ │ │ ├── IntegrationManagerCallback.java │ │ │ ├── IntegrationManagerFuture.java │ │ │ ├── IntegrationManagerImpl.java │ │ │ ├── IntegrationResponse.java │ │ │ ├── IntegrationService.java │ │ │ ├── RequiresIntentAction.kt │ │ │ └── action │ │ │ │ ├── command │ │ │ │ ├── close_bank_session │ │ │ │ │ ├── CloseBankSessionCommand.kt │ │ │ │ │ └── CloseBankSessionCommandResult.kt │ │ │ │ ├── open_receipt_command │ │ │ │ │ ├── OpenBuyReceiptCommand.java │ │ │ │ │ ├── OpenBuybackReceiptCommand.java │ │ │ │ │ ├── OpenCorrectionIncomeReceiptCommand.kt │ │ │ │ │ ├── OpenCorrectionOutcomeReceiptCommand.kt │ │ │ │ │ ├── OpenCorrectionReturnIncomeReceiptCommand.kt │ │ │ │ │ ├── OpenCorrectionReturnOutcomeReceiptCommand.kt │ │ │ │ │ ├── OpenPaybackReceiptCommand.java │ │ │ │ │ ├── OpenReceiptCommandResult.java │ │ │ │ │ └── OpenSellReceiptCommand.java │ │ │ │ ├── print_cash_command │ │ │ │ │ ├── PrintCashIncomeCommandResult.kt │ │ │ │ │ ├── PrintCashIncomeDocumentCommand.kt │ │ │ │ │ ├── PrintCashOutcomeCommandResult.kt │ │ │ │ │ └── PrintCashOutcomeDocumentCommand.kt │ │ │ │ ├── print_receipt_command │ │ │ │ │ ├── PrintBuyReceiptCommand.kt │ │ │ │ │ ├── PrintBuybackReceiptCommand.kt │ │ │ │ │ ├── PrintCorrectionIncomeReceiptCommand.kt │ │ │ │ │ ├── PrintCorrectionOutcomeReceiptCommand.kt │ │ │ │ │ ├── PrintCorrectionReturnIncomeReceiptCommand.kt │ │ │ │ │ ├── PrintCorrectionReturnOutcomeReceiptCommand.kt │ │ │ │ │ ├── PrintPaybackReceiptCommand.kt │ │ │ │ │ ├── PrintReceiptCommand.kt │ │ │ │ │ ├── PrintReceiptCommandErrorData.kt │ │ │ │ │ ├── PrintReceiptCommandErrorDataFactory.kt │ │ │ │ │ ├── PrintReceiptCommandResult.java │ │ │ │ │ └── PrintSellReceiptCommand.kt │ │ │ │ ├── print_unprinted_document │ │ │ │ │ ├── PrintUnprintedDocumentCommand.kt │ │ │ │ │ └── PrintUnprintedDocumentCommandResult.kt │ │ │ │ └── print_z_report_command │ │ │ │ │ ├── PrintZReportCommand.kt │ │ │ │ │ ├── PrintZReportCommandErrorData.kt │ │ │ │ │ ├── PrintZReportCommandErrorDataFactory.kt │ │ │ │ │ └── PrintZReportCommandResult.kt │ │ │ │ ├── datamapper │ │ │ │ ├── ChangesMapper.kt │ │ │ │ ├── ExtraKeyMapper.java │ │ │ │ ├── IntegrationComponentMapper.kt │ │ │ │ ├── MarkMapper.kt │ │ │ │ ├── PaymentDelegatorMapper.kt │ │ │ │ ├── PaymentMapper.java │ │ │ │ ├── PaymentPerformerMapper.kt │ │ │ │ ├── PaymentPurposeMapper.java │ │ │ │ ├── PaymentSystemMapper.java │ │ │ │ ├── PositionAttributesMapper.kt │ │ │ │ ├── PositionMapper.java │ │ │ │ ├── PrintExtraPlaceMapper.kt │ │ │ │ ├── PrintGroupMapper.java │ │ │ │ ├── PrintReceiptMapper.java │ │ │ │ ├── PrintablesMapper.kt │ │ │ │ ├── ReceiptHeaderMapper.java │ │ │ │ ├── ReceiptMapper.java │ │ │ │ ├── SettlementMethodMapper.kt │ │ │ │ ├── TaxMapper.java │ │ │ │ └── TaxNumberMapper.java │ │ │ │ ├── event │ │ │ │ ├── cash_drawer │ │ │ │ │ ├── CashDrawerEvent.java │ │ │ │ │ └── CashDrawerOpenEvent.java │ │ │ │ ├── cash_operations │ │ │ │ │ ├── CashInEvent.java │ │ │ │ │ ├── CashOperationEvent.java │ │ │ │ │ └── CashOutEvent.java │ │ │ │ ├── inventory │ │ │ │ │ ├── ProductCardOpenedEvent.java │ │ │ │ │ └── ProductEvent.java │ │ │ │ ├── receipt │ │ │ │ │ ├── before_positions_edited │ │ │ │ │ │ ├── BeforePositionsEditedEvent.java │ │ │ │ │ │ ├── BeforePositionsEditedEventProcessor.java │ │ │ │ │ │ └── BeforePositionsEditedEventResult.java │ │ │ │ │ ├── changes │ │ │ │ │ │ ├── IChange.kt │ │ │ │ │ │ ├── UnknownChange.kt │ │ │ │ │ │ ├── position │ │ │ │ │ │ │ ├── IPositionChange.kt │ │ │ │ │ │ │ ├── PositionAdd.kt │ │ │ │ │ │ │ ├── PositionEdit.kt │ │ │ │ │ │ │ └── PositionRemove.kt │ │ │ │ │ │ └── receipt │ │ │ │ │ │ │ ├── SetExtra.kt │ │ │ │ │ │ │ ├── SetPrintGroup.kt │ │ │ │ │ │ │ ├── SetPurchaserContactData.kt │ │ │ │ │ │ │ └── print_extra │ │ │ │ │ │ │ └── SetPrintExtra.kt │ │ │ │ │ ├── discount │ │ │ │ │ │ ├── ReceiptDiscountEvent.java │ │ │ │ │ │ ├── ReceiptDiscountEventProcessor.java │ │ │ │ │ │ └── ReceiptDiscountEventResult.java │ │ │ │ │ ├── discount_required │ │ │ │ │ │ ├── ReceiptDiscountRequiredEvent.kt │ │ │ │ │ │ ├── ReceiptDiscountRequiredEventProcessor.kt │ │ │ │ │ │ └── ReceiptDiscountRequiredEventResult.kt │ │ │ │ │ ├── error_card_payment │ │ │ │ │ │ ├── ErrorPaymentByCardEvent.kt │ │ │ │ │ │ ├── ErrorPaymentByCardEventProcessor.kt │ │ │ │ │ │ ├── ErrorPaymentByCardEventResult.kt │ │ │ │ │ │ └── actions │ │ │ │ │ │ │ ├── ErrorPaymentByCardActionMapper.kt │ │ │ │ │ │ │ ├── IHandleEventResultAction.kt │ │ │ │ │ │ │ └── PaymentByCardErrorAction.kt │ │ │ │ │ ├── jewelry │ │ │ │ │ │ ├── SendJewelryEvent.kt │ │ │ │ │ │ ├── SendJewelryEventProcessor.kt │ │ │ │ │ │ └── SendJewelryEventResult.kt │ │ │ │ │ ├── merges │ │ │ │ │ │ ├── PositionsMerge.kt │ │ │ │ │ │ ├── PositionsMergeEvent.kt │ │ │ │ │ │ ├── PositionsMergeEventProcessor.kt │ │ │ │ │ │ └── PositionsMergeEventResult.kt │ │ │ │ │ ├── payment │ │ │ │ │ │ ├── PaymentEvent.java │ │ │ │ │ │ ├── PaymentSelectedEvent.java │ │ │ │ │ │ ├── PaymentSelectedEventProcessor.java │ │ │ │ │ │ ├── PaymentSelectedEventResult.java │ │ │ │ │ │ ├── combined │ │ │ │ │ │ │ ├── PaybackPaymentDelegatorEventProcessor.kt │ │ │ │ │ │ │ ├── PaymentDelegatorEventProcessor.kt │ │ │ │ │ │ │ ├── event │ │ │ │ │ │ │ │ ├── PaybackPaymentDelegatorEvent.kt │ │ │ │ │ │ │ │ ├── PaymentDelegatorEvent.kt │ │ │ │ │ │ │ │ └── PaymentDelegatorPaybackData.kt │ │ │ │ │ │ │ └── result │ │ │ │ │ │ │ │ ├── PaymentDelegatorCanceledAllEventResult.kt │ │ │ │ │ │ │ │ ├── PaymentDelegatorCanceledEventResult.kt │ │ │ │ │ │ │ │ ├── PaymentDelegatorEventResult.kt │ │ │ │ │ │ │ │ └── PaymentDelegatorSelectedEventResult.kt │ │ │ │ │ │ └── system │ │ │ │ │ │ │ ├── PaymentSystemProcessor.kt │ │ │ │ │ │ │ ├── event │ │ │ │ │ │ │ ├── PaymentSystemEvent.kt │ │ │ │ │ │ │ ├── PaymentSystemPaybackCancelEvent.kt │ │ │ │ │ │ │ ├── PaymentSystemPaybackEvent.kt │ │ │ │ │ │ │ ├── PaymentSystemSellCancelEvent.kt │ │ │ │ │ │ │ └── PaymentSystemSellEvent.kt │ │ │ │ │ │ │ └── result │ │ │ │ │ │ │ ├── PaymentSystemPaymentErrorResult.kt │ │ │ │ │ │ │ ├── PaymentSystemPaymentOkResult.kt │ │ │ │ │ │ │ └── PaymentSystemPaymentResult.kt │ │ │ │ │ ├── position_edited │ │ │ │ │ │ ├── PositionAddedEvent.java │ │ │ │ │ │ ├── PositionEditedEvent.java │ │ │ │ │ │ ├── PositionEvent.java │ │ │ │ │ │ └── PositionRemovedEvent.java │ │ │ │ │ ├── print_extra │ │ │ │ │ │ ├── PrintExtraRequiredEvent.kt │ │ │ │ │ │ ├── PrintExtraRequiredEventProcessor.kt │ │ │ │ │ │ └── PrintExtraRequiredEventResult.kt │ │ │ │ │ ├── print_group │ │ │ │ │ │ ├── PrintGroupEvent.java │ │ │ │ │ │ ├── PrintGroupRequiredEvent.java │ │ │ │ │ │ ├── PrintGroupRequiredEventProcessor.java │ │ │ │ │ │ └── PrintGroupRequiredEventResult.java │ │ │ │ │ └── receipt_edited │ │ │ │ │ │ ├── ReceiptClearedEvent.java │ │ │ │ │ │ ├── ReceiptClosedEvent.java │ │ │ │ │ │ ├── ReceiptEvent.java │ │ │ │ │ │ ├── ReceiptOpenedEvent.java │ │ │ │ │ │ ├── ReceiptPaymentPartsEditedEvent.java │ │ │ │ │ │ └── ReceiptPrintGroupEditedEvent.java │ │ │ │ ├── session │ │ │ │ │ ├── BankSessionClosedEvent.kt │ │ │ │ │ ├── SessionClosedEvent.java │ │ │ │ │ └── SessionEvent.java │ │ │ │ └── users │ │ │ │ │ ├── UserChangedEvent.java │ │ │ │ │ └── UserEvent.java │ │ │ │ └── processor │ │ │ │ └── ActionProcessor.java │ │ ├── counterparties │ │ │ ├── Counterparty.kt │ │ │ ├── collaboration │ │ │ │ └── agent_scheme │ │ │ │ │ ├── Agent.kt │ │ │ │ │ ├── Principal.kt │ │ │ │ │ ├── Subagent.kt │ │ │ │ │ ├── TransactionOperator.kt │ │ │ │ │ └── mapper │ │ │ │ │ ├── AgentMapper.kt │ │ │ │ │ ├── PrincipalMapper.kt │ │ │ │ │ ├── SubagentMapper.kt │ │ │ │ │ └── TransactionOperatorMapper.kt │ │ │ └── mapper │ │ │ │ └── CounterpartyMapper.kt │ │ ├── device │ │ │ ├── cash_drawer │ │ │ │ └── event │ │ │ │ │ ├── CashDrawerEvent.kt │ │ │ │ │ ├── CashDrawerOpenedEvent.kt │ │ │ │ │ └── handler │ │ │ │ │ └── receiver │ │ │ │ │ └── CashDrawerBroadcastReceiver.kt │ │ │ ├── display │ │ │ │ ├── DisplayApi.kt │ │ │ │ └── Displays.kt │ │ │ └── scanner │ │ │ │ └── event │ │ │ │ ├── BarcodeReceivedEvent.kt │ │ │ │ ├── BarcodeScanRequestedEvent.kt │ │ │ │ └── handler │ │ │ │ ├── receiver │ │ │ │ └── ScannerBroadcastReceiver.kt │ │ │ │ └── service │ │ │ │ └── ScannerIntegrationService.kt │ │ ├── features │ │ │ ├── FeaturesApi.kt │ │ │ └── provider │ │ │ │ └── FeaturesContract.kt │ │ ├── fs │ │ │ ├── FsFiscalizationDocument.kt │ │ │ └── api │ │ │ │ └── FsApi.kt │ │ ├── inventory │ │ │ ├── AlcoCodeTable.kt │ │ │ ├── AttributeValue.kt │ │ │ ├── AttributeWithValues.kt │ │ │ ├── BarcodeTable.kt │ │ │ ├── InventoryApi.kt │ │ │ ├── ProductExtra.kt │ │ │ ├── ProductExtraTable.kt │ │ │ ├── ProductItem.kt │ │ │ ├── ProductMapper.kt │ │ │ ├── ProductQuery.kt │ │ │ ├── ProductTable.kt │ │ │ ├── ProductType.java │ │ │ ├── event │ │ │ │ ├── ProductCardOpenedEvent.kt │ │ │ │ ├── ProductEvent.kt │ │ │ │ └── handler │ │ │ │ │ └── receiver │ │ │ │ │ └── InventoryBroadcastReceiver.kt │ │ │ └── field │ │ │ │ ├── DictionaryField.kt │ │ │ │ ├── Field.kt │ │ │ │ ├── FieldTable.kt │ │ │ │ └── TextField.kt │ │ ├── kkt │ │ │ ├── FfdVersion.kt │ │ │ ├── FiscalRequisite.kt │ │ │ ├── FiscalTags.kt │ │ │ ├── api │ │ │ │ ├── AsyncHandler.kt │ │ │ │ ├── DocumentRegistrationCallback.kt │ │ │ │ ├── DocumentRegistrationException.kt │ │ │ │ └── KktApi.kt │ │ │ ├── event │ │ │ │ ├── CashInsertedEvent.kt │ │ │ │ ├── CashOperationEvent.kt │ │ │ │ ├── CashWithdrawnEvent.kt │ │ │ │ ├── CorrectionReceiptRegistrationRequestedEvent.kt │ │ │ │ └── handler │ │ │ │ │ ├── receiver │ │ │ │ │ └── KktBroadcastReceiver.kt │ │ │ │ │ └── service │ │ │ │ │ └── KktBacksideIntegrationService.kt │ │ │ └── provider │ │ │ │ └── KktContract.kt │ │ ├── mapper │ │ │ ├── DocumentMapper.kt │ │ │ └── FiscalDocumentMapper.kt │ │ ├── navigation │ │ │ └── NavigationApi.kt │ │ ├── payment │ │ │ ├── AdditionalTransactionData.kt │ │ │ ├── CashlessInfo.kt │ │ │ ├── PaymentAccount.java │ │ │ ├── PaymentPurpose.java │ │ │ ├── PaymentSystem.java │ │ │ ├── PaymentSystemApi.kt │ │ │ ├── PaymentSystemTable.kt │ │ │ └── PaymentType.java │ │ ├── provider │ │ │ ├── DocumentContract.kt │ │ │ └── FiscalDocumentContract.kt │ │ ├── receipt │ │ │ ├── ExtraKey.java │ │ │ ├── FiscalReceipt.kt │ │ │ ├── Measure.kt │ │ │ ├── MedicineAdditionalDetails.kt │ │ │ ├── MedicineAttribute.kt │ │ │ ├── MedicineAttributeSubTable.kt │ │ │ ├── NonFiscalReceipt.kt │ │ │ ├── Payment.kt │ │ │ ├── PaymentTable.kt │ │ │ ├── Position.java │ │ │ ├── PositionTable.kt │ │ │ ├── PrintGroup.java │ │ │ ├── PrintGroupSubTable.kt │ │ │ ├── Purchaser.kt │ │ │ ├── Receipt.kt │ │ │ ├── ReceiptApi.kt │ │ │ ├── ReceiptDiscountTable.kt │ │ │ ├── ReceiptHeaderTable.kt │ │ │ ├── SettlementType.kt │ │ │ ├── Tax.java │ │ │ ├── TaxNumber.kt │ │ │ ├── TaxationSystem.java │ │ │ ├── TimeRange.kt │ │ │ ├── attribute │ │ │ │ └── VeterinaryAttribute.kt │ │ │ ├── correction │ │ │ │ └── CorrectionType.kt │ │ │ ├── event │ │ │ │ ├── ApplyDiscountToReceiptEvent.kt │ │ │ │ ├── ReceiptCompletedEvent.kt │ │ │ │ ├── ReceiptCreatedEvent.kt │ │ │ │ ├── ReceiptDeletedEvent.kt │ │ │ │ ├── ReceiptEvent.kt │ │ │ │ └── handler │ │ │ │ │ └── receiver │ │ │ │ │ ├── BuyReceiptBroadcastReceiver.kt │ │ │ │ │ ├── BuybackReceiptBroadcastReceiver.kt │ │ │ │ │ ├── CorrectionIncomeReceiptBroadcastReceiver.kt │ │ │ │ │ ├── CorrectionOutcomeReceiptBroadcastReceiver.kt │ │ │ │ │ ├── CorrectionReturnIncomeReceiptBroadcastReceiver.kt │ │ │ │ │ ├── CorrectionReturnOutcomeReceiptBroadcastReceiver.kt │ │ │ │ │ ├── PaybackReceiptBroadcastReceiver.kt │ │ │ │ │ ├── ReceiptBroadcastReceiver.kt │ │ │ │ │ └── SellReceiptBroadcastReceiver.kt │ │ │ ├── formation │ │ │ │ ├── ReceiptDraft.kt │ │ │ │ ├── api │ │ │ │ │ ├── BuyApi.kt │ │ │ │ │ ├── PaybackApi.kt │ │ │ │ │ ├── SellApi.kt │ │ │ │ │ ├── move_receipt_to_payment_stage │ │ │ │ │ │ ├── MoveCurrentReceiptDraftToPaymentStageCallback.kt │ │ │ │ │ │ └── MoveCurrentReceiptDraftToPaymentStageException.kt │ │ │ │ │ └── trigger_receipt_discount_event │ │ │ │ │ │ ├── TriggerReceiptDiscountEventCallback.kt │ │ │ │ │ │ └── TriggerReceiptDiscountEventException.kt │ │ │ │ └── event │ │ │ │ │ ├── CurrentReceiptDraftMovementToPaymentStageRequestedEvent.kt │ │ │ │ │ ├── DiscountScreenAdditionalItemsEvent.kt │ │ │ │ │ ├── ReturnDeliveryRequisitesForReceiptRequestedEvent.kt │ │ │ │ │ ├── ReturnMedicineAttributeEvent.kt │ │ │ │ │ ├── ReturnPositionsForBarcodeRequestedEvent.kt │ │ │ │ │ ├── ReturnPurchaserRequisitesForPrintGroupRequestedEvent.kt │ │ │ │ │ ├── TriggerReceiptDiscountEventRequestedEvent.kt │ │ │ │ │ └── handler │ │ │ │ │ └── service │ │ │ │ │ ├── BuyBacksideIntegrationService.kt │ │ │ │ │ ├── BuyIntegrationService.kt │ │ │ │ │ ├── BuybackIntegrationService.kt │ │ │ │ │ ├── BuybackWithBuyIntegrationService.kt │ │ │ │ │ ├── CorrectionIncomeIntegrationService.kt │ │ │ │ │ ├── CorrectionOutcomeIntegrationService.kt │ │ │ │ │ ├── CorrectionReturnIncomeIntegrationService.kt │ │ │ │ │ ├── CorrectionReturnOutcomeIntegrationService.kt │ │ │ │ │ ├── PaybackBacksideIntegrationService.kt │ │ │ │ │ ├── PaybackIntegrationService.kt │ │ │ │ │ ├── PaybackWithSellIntegrationService.kt │ │ │ │ │ ├── SellBacksideIntegrationService.kt │ │ │ │ │ ├── SellIntegrationService.kt │ │ │ │ │ └── TriggerReceiptDiscountEventIntegrationService.kt │ │ │ ├── mapper │ │ │ │ └── FiscalReceiptMapper.kt │ │ │ ├── position │ │ │ │ ├── AgentRequisites.kt │ │ │ │ ├── ImportationData.kt │ │ │ │ ├── Mark.kt │ │ │ │ ├── MarksCheckingInfo.kt │ │ │ │ ├── PartialRealization.kt │ │ │ │ ├── PreferentialMedicine.kt │ │ │ │ ├── SettlementMethod.kt │ │ │ │ ├── VatRate.kt │ │ │ │ ├── event │ │ │ │ │ ├── PositionAddedEvent.kt │ │ │ │ │ ├── PositionEvent.kt │ │ │ │ │ ├── PositionRemovedEvent.kt │ │ │ │ │ └── PositionUpdatedEvent.kt │ │ │ │ ├── mapper │ │ │ │ │ ├── AgentRequisitesMapper.kt │ │ │ │ │ ├── MarksCheckingInfoMapper.kt │ │ │ │ │ ├── PositionPartialRealizationMapper.kt │ │ │ │ │ ├── PreferentialMedicineMapper.kt │ │ │ │ │ ├── SettlementMethodMapper.kt │ │ │ │ │ └── VeterinaryAttributeMapper.kt │ │ │ │ └── provider │ │ │ │ │ └── AgentRequisitesContract.kt │ │ │ ├── print_extras │ │ │ │ ├── PrintExtraPlace.kt │ │ │ │ ├── PrintExtraPlacePositionAllSubpositionsFooter.kt │ │ │ │ ├── PrintExtraPlacePositionFooter.kt │ │ │ │ ├── PrintExtraPlacePrintGroupHeader.kt │ │ │ │ ├── PrintExtraPlacePrintGroupSummary.kt │ │ │ │ ├── PrintExtraPlacePrintGroupTop.kt │ │ │ │ └── PrintExtraPlaceType.kt │ │ │ ├── provider │ │ │ │ └── FiscalReceiptContract.kt │ │ │ └── slip │ │ │ │ └── SlipsAmountApi.kt │ │ ├── settings │ │ │ ├── SettingsApi.kt │ │ │ └── SettingsProviderContracts.kt │ │ ├── system │ │ │ ├── SystemStateApi.kt │ │ │ ├── SystemStateTable.kt │ │ │ └── mode │ │ │ │ ├── DeviceModeApi.kt │ │ │ │ └── DeviceModeContract.kt │ │ └── users │ │ │ ├── Grant.kt │ │ │ ├── GrantQuery.kt │ │ │ ├── GrantsProviderColumns.kt │ │ │ ├── GrantsTable.kt │ │ │ ├── RolesProviderColumns.kt │ │ │ ├── RolesTable.kt │ │ │ ├── User.kt │ │ │ ├── UserApi.kt │ │ │ ├── UserMapper.kt │ │ │ ├── UserQuery.kt │ │ │ ├── UsersContentProviderContract.kt │ │ │ ├── UsersProviderColumns.kt │ │ │ └── UsersTable.kt │ │ └── integrations │ │ └── BarcodeBroadcastReceiver.kt └── res │ └── values │ ├── colors.xml │ └── strings.xml └── test └── java └── ru └── evotor └── framework └── receipt └── position └── AgentRequisitesTest.kt /.editorconfig: -------------------------------------------------------------------------------- 1 | # indicate this is the root of the project 2 | # Если установлена в true, парсер не будет искать другие конфиги родительских папках 3 | root = true 4 | 5 | [*.{kt, kts}] 6 | # possible values: number (e.g. 2), "unset" (makes ktlint ignore indentation completely) 7 | indent_size = 4 8 | 9 | # true (recommended) / false. Позволяет убедиться, что в конце файла всегда будет новая строка. 10 | insert_final_newline = true 11 | 12 | # Позволяет убрать пробелы из концов строк. 13 | trim_trailing_whitespace = true 14 | 15 | # possible values: number (e.g. 120) (package name, imports & comments are ignored), "off" 16 | # it's automatically set to 100 on `ktlint --android ...` (per Android Kotlin Style Guide) 17 | max_line_length = off 18 | 19 | disabled_rules = no-wildcard-imports -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | codeiris 2 | *.iml 3 | .gradle 4 | /local.properties 5 | .DS_Store 6 | /build 7 | /captures 8 | /.idea 9 | */build 10 | projectFilesBackup/ 11 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![](https://jitpack.io/v/evotor/integration-library.svg)](https://jitpack.io/#evotor/integration-library) 2 | [![Gitter](https://badges.gitter.im/evotor/integration-library.svg)](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 | -------------------------------------------------------------------------------- /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 -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/evotor/integration-library/f57a51b097aef3bc22177f68336eaa958d2934b8/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Fri Sep 09 13:53:43 MSK 2022 2 | distributionBase=GRADLE_USER_HOME 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip 4 | distributionPath=wrapper/dists 5 | zipStorePath=wrapper/dists 6 | zipStoreBase=GRADLE_USER_HOME 7 | -------------------------------------------------------------------------------- /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/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/aidl/ru/evotor/devices/commons/IScalesService.aidl: -------------------------------------------------------------------------------- 1 | package ru.evotor.devices.commons; 2 | 3 | import ru.evotor.devices.commons.result.ResultWeight; 4 | 5 | interface IScalesService { 6 | 7 | /** 8 | * Получить вес и прочие характеристики 9 | * 10 | * @param deviceId - номер устройства 11 | */ 12 | ResultWeight getWeight(int deviceId); 13 | 14 | } 15 | -------------------------------------------------------------------------------- /src/main/aidl/ru/evotor/devices/commons/printer/PrinterDocument.aidl: -------------------------------------------------------------------------------- 1 | package ru.evotor.devices.commons.printer; 2 | 3 | parcelable PrinterDocument; -------------------------------------------------------------------------------- /src/main/aidl/ru/evotor/devices/commons/result/ResultBoolean.aidl: -------------------------------------------------------------------------------- 1 | package ru.evotor.devices.commons.result; 2 | 3 | parcelable ResultBoolean; -------------------------------------------------------------------------------- /src/main/aidl/ru/evotor/devices/commons/result/ResultDouble.aidl: -------------------------------------------------------------------------------- 1 | package ru.evotor.devices.commons.result; 2 | 3 | parcelable ResultDouble; -------------------------------------------------------------------------------- /src/main/aidl/ru/evotor/devices/commons/result/ResultInt.aidl: -------------------------------------------------------------------------------- 1 | package ru.evotor.devices.commons.result; 2 | 3 | parcelable ResultInt; -------------------------------------------------------------------------------- /src/main/aidl/ru/evotor/devices/commons/result/ResultIntArray.aidl: -------------------------------------------------------------------------------- 1 | package ru.evotor.devices.commons.result; 2 | 3 | parcelable ResultIntArray; -------------------------------------------------------------------------------- /src/main/aidl/ru/evotor/devices/commons/result/ResultLong.aidl: -------------------------------------------------------------------------------- 1 | package ru.evotor.devices.commons.result; 2 | 3 | parcelable ResultLong; -------------------------------------------------------------------------------- /src/main/aidl/ru/evotor/devices/commons/result/ResultString.aidl: -------------------------------------------------------------------------------- 1 | package ru.evotor.devices.commons.result; 2 | 3 | parcelable ResultString; -------------------------------------------------------------------------------- /src/main/aidl/ru/evotor/devices/commons/result/ResultVoid.aidl: -------------------------------------------------------------------------------- 1 | package ru.evotor.devices.commons.result; 2 | 3 | parcelable ResultVoid; -------------------------------------------------------------------------------- /src/main/aidl/ru/evotor/devices/commons/result/ResultWeight.aidl: -------------------------------------------------------------------------------- 1 | package ru.evotor.devices.commons.result; 2 | 3 | parcelable ResultWeight; -------------------------------------------------------------------------------- /src/main/aidl/ru/evotor/framework/core/IIntegrationManager.aidl: -------------------------------------------------------------------------------- 1 | package ru.evotor.framework.core; 2 | 3 | 4 | import ru.evotor.framework.core.IIntegrationManagerResponse; 5 | import android.os.Bundle; 6 | 7 | interface IIntegrationManager { 8 | void call(in IIntegrationManagerResponse response, String action, in Bundle bundle); 9 | } 10 | -------------------------------------------------------------------------------- /src/main/aidl/ru/evotor/framework/core/IIntegrationManagerResponse.aidl: -------------------------------------------------------------------------------- 1 | package ru.evotor.framework.core; 2 | import android.os.Bundle; 3 | 4 | oneway interface IIntegrationManagerResponse { 5 | void onResult(in Bundle value); 6 | void onError(int errorCode, String errorMessage, in Bundle data); 7 | } -------------------------------------------------------------------------------- /src/main/java/ru/evotor/IBundlable.kt: -------------------------------------------------------------------------------- 1 | package ru.evotor 2 | 3 | import android.os.Bundle 4 | 5 | 6 | interface IBundlable { 7 | fun toBundle(): Bundle 8 | } -------------------------------------------------------------------------------- /src/main/java/ru/evotor/UuidValidationUtils.kt: -------------------------------------------------------------------------------- 1 | package ru.evotor 2 | 3 | import java.util.regex.Pattern 4 | 5 | object UuidValidationUtils { 6 | 7 | private val UUID_REGEX: Pattern = Pattern.compile("^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$") 8 | 9 | @JvmStatic 10 | @Throws(IncorrectUuidException::class) 11 | fun checkUuid(uuid: String) { 12 | if (!UUID_REGEX.matcher(uuid).matches()) { 13 | throw IncorrectUuidException(uuid) 14 | } 15 | } 16 | } 17 | 18 | class IncorrectUuidException(value: String?) 19 | : IllegalArgumentException("Invalid UUID String $value : UUID has to be represented by standard 36-char representation") 20 | -------------------------------------------------------------------------------- /src/main/java/ru/evotor/devices/commons/ConnectionWrapper.java: -------------------------------------------------------------------------------- 1 | package ru.evotor.devices.commons; 2 | 3 | import ru.evotor.devices.commons.services.IPrinterServiceWrapper; 4 | import ru.evotor.devices.commons.services.IScalesServiceWrapper; 5 | 6 | public interface ConnectionWrapper { 7 | void onPrinterServiceConnected(IPrinterServiceWrapper printerService); 8 | 9 | void onPrinterServiceDisconnected(); 10 | 11 | void onScalesServiceConnected(IScalesServiceWrapper scalesService); 12 | 13 | void onScalesServiceDisconnected(); 14 | 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/ru/evotor/devices/commons/Constants.java: -------------------------------------------------------------------------------- 1 | package ru.evotor.devices.commons; 2 | 3 | public final class Constants { 4 | 5 | public static final String ACTION_DEVICE_LIST_CHANGED = "ru.evotor.devices.DeviceConfigChanged"; 6 | 7 | public static final int DEFAULT_DEVICE_INDEX = -1; 8 | 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/ru/evotor/devices/commons/exception/DeviceNotFoundException.java: -------------------------------------------------------------------------------- 1 | package ru.evotor.devices.commons.exception; 2 | 3 | /** 4 | * Не найдено указанное устройство 5 | */ 6 | public class DeviceNotFoundException extends DeviceServiceException { 7 | public DeviceNotFoundException() { 8 | super(); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/ru/evotor/devices/commons/exception/DeviceServiceException.java: -------------------------------------------------------------------------------- 1 | package ru.evotor.devices.commons.exception; 2 | 3 | /** 4 | * Родительский класс всех возможных исключений, которые могут быть выброшены при работе с DeviceServiceConnector 5 | */ 6 | public abstract class DeviceServiceException extends Exception { 7 | 8 | public DeviceServiceException() { 9 | super(); 10 | } 11 | 12 | public DeviceServiceException(String message) { 13 | super(message); 14 | } 15 | 16 | public DeviceServiceException(Exception e) { 17 | super(e); 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/ru/evotor/devices/commons/exception/DeviceServiceOperationOnMainThreadException.java: -------------------------------------------------------------------------------- 1 | package ru.evotor.devices.commons.exception; 2 | 3 | import android.os.Looper; 4 | 5 | public class DeviceServiceOperationOnMainThreadException extends RuntimeException { 6 | public DeviceServiceOperationOnMainThreadException() { 7 | super("It is forbidden to perform operations with device service in the main thread, it can be time-consuming"); 8 | } 9 | 10 | public static void throwIfMainThread() { 11 | if (Looper.getMainLooper() == Looper.myLooper()) { 12 | throw new DeviceServiceOperationOnMainThreadException(); 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/ru/evotor/devices/commons/exception/DeviceServiceRuntimeException.java: -------------------------------------------------------------------------------- 1 | package ru.evotor.devices.commons.exception; 2 | 3 | public class DeviceServiceRuntimeException extends DeviceServiceException { 4 | 5 | public DeviceServiceRuntimeException(RuntimeException exc) { 6 | super(exc); 7 | } 8 | 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/ru/evotor/devices/commons/exception/DriverException.java: -------------------------------------------------------------------------------- 1 | package ru.evotor.devices.commons.exception; 2 | 3 | /** 4 | * Ошибка при выполнении метода в драйвере устройства 5 | */ 6 | public class DriverException extends DeviceServiceException { 7 | 8 | private final String driverMessage; 9 | 10 | public DriverException(String driverMessage) { 11 | super(); 12 | this.driverMessage = driverMessage; 13 | } 14 | 15 | public String getDriverMessage() { 16 | return driverMessage; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/ru/evotor/devices/commons/exception/NoPermanentInfoException.java: -------------------------------------------------------------------------------- 1 | package ru.evotor.devices.commons.exception; 2 | 3 | /** 4 | * Нельзя получить PermanentInfo для данного типа устройств 5 | */ 6 | public class NoPermanentInfoException extends DeviceServiceException { 7 | public NoPermanentInfoException() { 8 | super(); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/ru/evotor/devices/commons/exception/ServiceNotConnectedException.java: -------------------------------------------------------------------------------- 1 | package ru.evotor.devices.commons.exception; 2 | 3 | /** 4 | * Нет подключения к DeviceService 5 | */ 6 | public class ServiceNotConnectedException extends DeviceServiceException { 7 | public ServiceNotConnectedException(String message) { 8 | super(message); 9 | } 10 | 11 | public ServiceNotConnectedException(Exception e) { 12 | super(e); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/ru/evotor/devices/commons/exception/UnknownException.java: -------------------------------------------------------------------------------- 1 | package ru.evotor.devices.commons.exception; 2 | 3 | /** 4 | * Неизвестная ошибка 5 | */ 6 | public class UnknownException extends DeviceServiceException { 7 | public UnknownException(String message) { 8 | super(message); 9 | } 10 | 11 | public UnknownException(Exception e) { 12 | super(e); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/ru/evotor/devices/commons/exception/UsbHubProblemException.java: -------------------------------------------------------------------------------- 1 | package ru.evotor.devices.commons.exception; 2 | 3 | import ru.evotor.devices.commons.exception.error_extension.UsbHubStateErrorExtension; 4 | 5 | /** 6 | * Не найдено указанное устройство, и в системе отсутвуют USB-устройства. 7 | * Возможно, это проблема USB-хаба, которая может быть решена программной перезагрузкой. 8 | * Текущий статус этой перезагрузки можно посмотреть в поле {@link UsbHubStateErrorExtension.UsbHubState usbHubState} 9 | */ 10 | public class UsbHubProblemException extends DeviceServiceException { 11 | 12 | private final UsbHubStateErrorExtension.UsbHubState usbHubState; 13 | 14 | public UsbHubProblemException(UsbHubStateErrorExtension.UsbHubState usbHubState) { 15 | super(); 16 | this.usbHubState = usbHubState; 17 | } 18 | 19 | public UsbHubStateErrorExtension.UsbHubState getUsbHubState() { 20 | return usbHubState; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/ru/evotor/devices/commons/exception/error_extension/AbstractErrorExtension.java: -------------------------------------------------------------------------------- 1 | package ru.evotor.devices.commons.exception.error_extension; 2 | 3 | import android.os.Parcel; 4 | 5 | public abstract class AbstractErrorExtension { 6 | public AbstractErrorExtension() { 7 | } 8 | 9 | public AbstractErrorExtension(Parcel parcel) { 10 | } 11 | 12 | public abstract void writeToParcel(Parcel parcel); 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/ru/evotor/devices/commons/exception/error_extension/DriverExceptionErrorExtension.java: -------------------------------------------------------------------------------- 1 | package ru.evotor.devices.commons.exception.error_extension; 2 | 3 | 4 | import android.os.Parcel; 5 | 6 | public class DriverExceptionErrorExtension extends AbstractErrorExtension { 7 | 8 | private final String driverMessage; 9 | 10 | public DriverExceptionErrorExtension(String driverMessage) { 11 | this.driverMessage = driverMessage; 12 | } 13 | 14 | public DriverExceptionErrorExtension(Parcel parcel) { 15 | this(parcel.readString()); 16 | } 17 | 18 | public String getDriverMessage() { 19 | return driverMessage; 20 | } 21 | 22 | @Override 23 | public void writeToParcel(Parcel parcel) { 24 | parcel.writeString(driverMessage); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /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/devices/commons/printer/printable/IPrintable.java: -------------------------------------------------------------------------------- 1 | package ru.evotor.devices.commons.printer.printable; 2 | 3 | import android.os.Parcelable; 4 | 5 | public interface IPrintable extends Parcelable { 6 | } 7 | -------------------------------------------------------------------------------- /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 | public class PrintableImage implements IPrintable { 7 | 8 | /** 9 | * картинка для печати 10 | */ 11 | private final Bitmap bitmap; 12 | 13 | public PrintableImage(Bitmap bitmap) { 14 | this.bitmap = bitmap; 15 | } 16 | 17 | private PrintableImage(Parcel parcel) { 18 | bitmap = parcel.readParcelable(Bitmap.class.getClassLoader()); 19 | } 20 | 21 | public Bitmap getBitmap() { 22 | return bitmap; 23 | } 24 | 25 | @Override 26 | public int describeContents() { 27 | return 0; 28 | } 29 | 30 | @Override 31 | public void writeToParcel(Parcel parcel, int i) { 32 | parcel.writeParcelable(bitmap, 0); 33 | } 34 | 35 | public static final Creator CREATOR = new Creator() { 36 | 37 | public PrintableImage createFromParcel(Parcel in) { 38 | return new PrintableImage(in); 39 | } 40 | 41 | public PrintableImage[] newArray(int size) { 42 | return new PrintableImage[size]; 43 | } 44 | }; 45 | 46 | } 47 | -------------------------------------------------------------------------------- /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/devices/commons/result/AbstractInnerParcelable.java: -------------------------------------------------------------------------------- 1 | package ru.evotor.devices.commons.result; 2 | 3 | import android.os.Parcel; 4 | 5 | public abstract class AbstractInnerParcelable { 6 | public AbstractInnerParcelable() { 7 | } 8 | 9 | public AbstractInnerParcelable(Parcel parcel) { 10 | } 11 | 12 | public abstract void writeToParcel(Parcel parcel); 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/ru/evotor/devices/commons/result/AbstractResult.java: -------------------------------------------------------------------------------- 1 | package ru.evotor.devices.commons.result; 2 | 3 | import ru.evotor.devices.commons.exception.DeviceServiceException; 4 | 5 | public abstract class AbstractResult { 6 | 7 | public ErrorDescription packException(DeviceServiceException exc) { 8 | return ErrorDescriptionPacker.packException(exc); 9 | } 10 | 11 | protected void unpackException() throws DeviceServiceException { 12 | ErrorDescription errorDescription = this.getErrorDescription(); 13 | DeviceServiceException exception = ErrorDescriptionPacker.unpackException(errorDescription); 14 | if (exception != null) { 15 | throw exception; 16 | } 17 | } 18 | 19 | abstract ErrorDescription getErrorDescription(); 20 | 21 | } -------------------------------------------------------------------------------- /src/main/java/ru/evotor/devices/commons/result/ErrorDescription.java: -------------------------------------------------------------------------------- 1 | package ru.evotor.devices.commons.result; 2 | 3 | import android.os.Parcel; 4 | 5 | import ru.evotor.devices.commons.exception.error_extension.AbstractErrorExtension; 6 | 7 | public class ErrorDescription extends AbstractInnerParcelable { 8 | 9 | private final int errorCode; 10 | private final String errorUserDescription; 11 | private final AbstractErrorExtension errorExtension; 12 | 13 | public ErrorDescription(int errorCode, String errorUserDescription) { 14 | this(errorCode, errorUserDescription, null); 15 | } 16 | 17 | public ErrorDescription(int errorCode, String errorUserDescription, AbstractErrorExtension errorExtension) { 18 | this.errorCode = errorCode; 19 | this.errorUserDescription = errorUserDescription; 20 | this.errorExtension = errorExtension; 21 | } 22 | 23 | public ErrorDescription(Parcel parcel) { 24 | errorCode = parcel.readInt(); 25 | errorUserDescription = parcel.readString(); 26 | errorExtension = ErrorDescriptionPacker.createErrorExtension(errorCode, parcel); 27 | } 28 | 29 | public int getErrorCode() { 30 | return errorCode; 31 | } 32 | 33 | public String getErrorUserDescription() { 34 | return errorUserDescription; 35 | } 36 | 37 | public AbstractErrorExtension getErrorExtension() { 38 | return errorExtension; 39 | } 40 | 41 | public void writeToParcel(Parcel parcel) { 42 | parcel.writeInt(errorCode); 43 | parcel.writeString(errorUserDescription); 44 | if (errorExtension != null) { 45 | errorExtension.writeToParcel(parcel); 46 | } 47 | } 48 | 49 | } -------------------------------------------------------------------------------- /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/devices/commons/result/ResultLong.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 ResultLong extends AbstractResult implements Parcelable { 9 | 10 | private final long result; 11 | private final ErrorDescription errorDescription; 12 | 13 | public ResultLong(long result, DeviceServiceException exc) { 14 | this.result = result; 15 | this.errorDescription = packException(exc); 16 | } 17 | 18 | private ResultLong(Parcel parcel) { 19 | result = parcel.readLong(); 20 | errorDescription = new ErrorDescription(parcel); 21 | } 22 | 23 | public long getResult() throws DeviceServiceException { 24 | this.unpackException(); 25 | return this.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.writeLong(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 ResultLong createFromParcel(Parcel in) { 49 | return new ResultLong(in); 50 | } 51 | 52 | public ResultLong[] newArray(int size) { 53 | return new ResultLong[size]; 54 | } 55 | }; 56 | 57 | } 58 | -------------------------------------------------------------------------------- /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/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/devices/commons/services/IPrinterServiceWrapper.java: -------------------------------------------------------------------------------- 1 | package ru.evotor.devices.commons.services; 2 | 3 | import ru.evotor.devices.commons.exception.DeviceServiceException; 4 | import ru.evotor.devices.commons.printer.PrinterDocument; 5 | 6 | public interface IPrinterServiceWrapper { 7 | int getAllowableSymbolsLineLength(int deviceId) throws DeviceServiceException; 8 | 9 | int getAllowablePixelLineLength(int deviceId) throws DeviceServiceException; 10 | 11 | void printDocument(int deviceId, PrinterDocument printerDocument) throws DeviceServiceException; 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/ru/evotor/devices/commons/services/IScalesServiceWrapper.java: -------------------------------------------------------------------------------- 1 | package ru.evotor.devices.commons.services; 2 | 3 | import ru.evotor.devices.commons.exception.DeviceServiceException; 4 | import ru.evotor.devices.commons.scales.Weight; 5 | 6 | public interface IScalesServiceWrapper { 7 | Weight getWeight(int deviceId) throws DeviceServiceException; 8 | } 9 | -------------------------------------------------------------------------------- /src/main/java/ru/evotor/framework/ColorUtils.kt: -------------------------------------------------------------------------------- 1 | package ru.evotor.framework 2 | 3 | import android.graphics.Color 4 | import androidx.annotation.ColorInt 5 | 6 | /** 7 | * Created by Khaustov on 06.02.18. 8 | */ 9 | object ColorUtils { 10 | 11 | private const val RED_MULTIPLIER = 0.299 12 | private const val GREEN_MULTIPLIER = 0.587 13 | private const val BLUE_MULTIPLIER = 0.114 14 | private const val RGB_MAX_COLOR_VALUE = 255 15 | 16 | @JvmStatic 17 | @ColorInt 18 | fun getContrastColor(@ColorInt color: Int): Int { 19 | val rgbValue = 1 - (RED_MULTIPLIER * Color.red(color) + GREEN_MULTIPLIER * Color.green(color) 20 | + BLUE_MULTIPLIER * Color.blue(color)) / RGB_MAX_COLOR_VALUE 21 | return if (rgbValue < 0.5) Color.BLACK else Color.WHITE 22 | } 23 | } -------------------------------------------------------------------------------- /src/main/java/ru/evotor/framework/Document.kt: -------------------------------------------------------------------------------- 1 | package ru.evotor.framework 2 | 3 | import android.os.Bundle 4 | import ru.evotor.IBundlable 5 | import ru.evotor.framework.mapper.DocumentMapper 6 | import java.util.* 7 | 8 | abstract class Document internal constructor(): IBundlable { 9 | @FutureFeature("Uuid документа, зарегистрированного в системе Эвотор") 10 | protected open val uuid: UUID? = null 11 | 12 | override fun toBundle(): Bundle = DocumentMapper.write(this) 13 | } -------------------------------------------------------------------------------- /src/main/java/ru/evotor/framework/FiscalDocument.kt: -------------------------------------------------------------------------------- 1 | package ru.evotor.framework 2 | 3 | import android.os.Bundle 4 | import ru.evotor.framework.mapper.FiscalDocumentMapper 5 | import java.util.* 6 | 7 | abstract class FiscalDocument internal constructor() : Document() { 8 | abstract val documentNumber: Long 9 | abstract val creationDate: Date 10 | abstract val kktRegistrationNumber: Long 11 | abstract val sessionNumber: Long 12 | abstract val fiscalStorageNumber: Long 13 | abstract val fiscalIdentifier: Long 14 | 15 | override fun toBundle(): Bundle = FiscalDocumentMapper.write(this) 16 | } -------------------------------------------------------------------------------- /src/main/java/ru/evotor/framework/FutureFeature.kt: -------------------------------------------------------------------------------- 1 | package ru.evotor.framework 2 | 3 | /** 4 | * То, что вскоре, возможно, будет реализовано. 5 | * Чтобы можно было понять, в каком направлении развивается АПИ. 6 | */ 7 | internal annotation class FutureFeature(val description: String) -------------------------------------------------------------------------------- /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/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/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/common/event/IntegrationEvent.kt: -------------------------------------------------------------------------------- 1 | package ru.evotor.framework.common.event 2 | 3 | import ru.evotor.IBundlable 4 | 5 | abstract class IntegrationEvent internal constructor() : IBundlable { 6 | 7 | abstract class Result internal constructor() : IBundlable 8 | } -------------------------------------------------------------------------------- /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(packageName: String?, 16 | componentName: String?, 17 | appUuid: String?, 18 | appName: String? 19 | ) : IntegrationComponent(packageName, componentName, appUuid, appName), IBundlable { 20 | override fun toBundle(): Bundle { 21 | return PaymentDelegatorMapper.toBundle(this) 22 | } 23 | 24 | companion object { 25 | fun from(bundle: Bundle?) = PaymentDelegatorMapper.fromBundle(bundle) 26 | } 27 | } -------------------------------------------------------------------------------- /src/main/java/ru/evotor/framework/component/PaymentPerformerTable.kt: -------------------------------------------------------------------------------- 1 | package ru.evotor.framework.component 2 | 3 | object PaymentPerformerTable { 4 | const val COLUMN_PACKAGE_NAME = "PAYMENT_PERFORMER_PACKAGE_NAME" 5 | const val COLUMN_COMPONENT_NAME = "PAYMENT_PERFORMER_COMPONENT_NAME" 6 | const val COLUMN_APP_UUID = "PAYMENT_PERFORMER_APP_UUID" 7 | const val COLUMN_APP_NAME = "PAYMENT_PERFORMER_APP_NAME" 8 | } -------------------------------------------------------------------------------- /src/main/java/ru/evotor/framework/component/viewdata/IntegrationComponentViewData.kt: -------------------------------------------------------------------------------- 1 | package ru.evotor.framework.component.viewdata 2 | 3 | import android.graphics.drawable.Drawable 4 | 5 | open class IntegrationComponentViewData( 6 | val icon: Drawable?, 7 | val backgroundColor: Int?, 8 | val textColor: Int? 9 | ) -------------------------------------------------------------------------------- /src/main/java/ru/evotor/framework/component/viewdata/PaymentPerformerViewData.kt: -------------------------------------------------------------------------------- 1 | package ru.evotor.framework.component.viewdata 2 | 3 | import android.graphics.drawable.Drawable 4 | import ru.evotor.framework.component.PaymentPerformer 5 | 6 | class PaymentPerformerViewData( 7 | val paymentPerformer: PaymentPerformer, 8 | icon: Drawable?, 9 | backgroundColor: Int?, 10 | textColor: Int? 11 | ) : IntegrationComponentViewData(icon, backgroundColor, textColor) -------------------------------------------------------------------------------- /src/main/java/ru/evotor/framework/core/BroadcastEventReceiver.kt: -------------------------------------------------------------------------------- 1 | package ru.evotor.framework.core 2 | 3 | import android.content.BroadcastReceiver 4 | import android.content.Context 5 | import android.content.Intent 6 | import android.os.Bundle 7 | 8 | abstract class BroadcastEventReceiver : BroadcastReceiver() { 9 | 10 | final override fun onReceive(context: Context, intent: Intent) { 11 | val action = intent.action 12 | val extras = intent.extras 13 | if (action != null && extras != null) { 14 | onEvent(context, action, extras) 15 | } 16 | } 17 | 18 | protected abstract fun onEvent(context: Context, action: String, bundle: Bundle) 19 | 20 | } -------------------------------------------------------------------------------- /src/main/java/ru/evotor/framework/core/ContextExt.kt: -------------------------------------------------------------------------------- 1 | package ru.evotor.framework.core 2 | 3 | import android.content.ComponentName 4 | import android.content.Context 5 | import android.content.Intent 6 | import android.os.Handler 7 | import android.os.Looper 8 | import ru.evotor.IBundlable 9 | 10 | internal fun Context.startIntegrationService( 11 | action: String, 12 | event: IBundlable, 13 | callback: IntegrationManagerCallback 14 | ) = this.packageManager 15 | .queryIntentServices(Intent(action), 0) 16 | .takeIf { it.isNotEmpty() } 17 | ?.first() 18 | ?.let { 19 | ComponentName(it.serviceInfo.packageName, it.serviceInfo.name) 20 | } 21 | ?.let { componentName -> 22 | IntegrationManagerImpl(this).call( 23 | action, 24 | componentName, 25 | event, 26 | ActivityStarter(this, false), 27 | callback, 28 | Handler(Looper.getMainLooper()) 29 | ) 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/ru/evotor/framework/core/Error.java: -------------------------------------------------------------------------------- 1 | package ru.evotor.framework.core; 2 | 3 | import android.os.Bundle; 4 | 5 | import androidx.annotation.NonNull; 6 | import androidx.annotation.Nullable; 7 | 8 | public final class Error { 9 | private final int code; 10 | @NonNull 11 | private final String message; 12 | @Nullable 13 | private final Bundle data; 14 | 15 | public Error(int code, @NonNull String message, @Nullable Bundle data) { 16 | this.code = code; 17 | this.message = message; 18 | this.data = data; 19 | } 20 | 21 | public int getCode() { 22 | return code; 23 | } 24 | 25 | @NonNull 26 | public String getMessage() { 27 | return message; 28 | } 29 | 30 | @Nullable 31 | public Bundle getData() { 32 | return data; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /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 | fun startActivity(intent: Intent, options: Bundle?) 14 | } 15 | 16 | open class ActivityStarter( 17 | context: Context, 18 | private val isNewTask: Boolean = true 19 | ) : ICanStartActivity { 20 | 21 | private val contextRef = WeakReference(context) 22 | override fun startActivity(intent: Intent) { 23 | startActivity(intent, null) 24 | } 25 | 26 | override fun startActivity(intent: Intent, options: Bundle?) { 27 | if (isNewTask) { 28 | intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) 29 | } 30 | contextRef.get()?.startActivity(intent, options) 31 | ?: throw IllegalStateException("Context has been deleted by garbage collector") 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/ru/evotor/framework/core/IntegrationException.java: -------------------------------------------------------------------------------- 1 | package ru.evotor.framework.core; 2 | 3 | /** 4 | * Created by a.kuznetsov on 11/04/2017. 5 | */ 6 | 7 | public class IntegrationException extends Exception { 8 | public IntegrationException() { 9 | super(); 10 | } 11 | 12 | public IntegrationException(Throwable cause) { 13 | super(cause); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/ru/evotor/framework/core/IntegrationLibraryException.kt: -------------------------------------------------------------------------------- 1 | package ru.evotor.framework.core 2 | 3 | internal abstract class IntegrationLibraryException(message: String) : RuntimeException(message) -------------------------------------------------------------------------------- /src/main/java/ru/evotor/framework/core/IntegrationLibraryMappingException.kt: -------------------------------------------------------------------------------- 1 | package ru.evotor.framework.core 2 | 3 | private const val CAUSE = "*" 4 | 5 | private const val BASE_MESSAGE = "Found $CAUSE that is not supported in current integration-library. Try to update your integration-library to resolve this error." 6 | 7 | /** 8 | * Исключение, возникающее при расхождении протокола взаимодействия между сторонним приложенем и системным приложением СТ. 9 | * 10 | * Причиной возникновения, скорее всего, является устаревшая версия integration-library в стороннем приложении. 11 | * 12 | * Если после обновления integration-library исключение не перестало возникать, свяжитесь с техподдержкой Эвотора. 13 | */ 14 | internal class IntegrationLibraryMappingException(cause: String) : IntegrationLibraryException(BASE_MESSAGE.replace(CAUSE, cause)) -------------------------------------------------------------------------------- /src/main/java/ru/evotor/framework/core/IntegrationLibraryParsingException.kt: -------------------------------------------------------------------------------- 1 | package ru.evotor.framework.core 2 | 3 | /** 4 | * Исключение, возникающее при расхождении протокола взаимодействия между сторонним приложенем и системным приложением СТ. 5 | * 6 | * Причиной возникновения, скорее всего, является устаревшая версия integration-library в стороннем приложении. 7 | * Или неверная передача данных. 8 | * 9 | * Если после обновления integration-library исключение не перестало возникать, сверьтесь с тех.документацией на сайте. 10 | */ 11 | internal class IntegrationLibraryParsingException(clazz: Class<*>) 12 | : IntegrationLibraryException( 13 | "Field in $clazz is required and must not be null." 14 | ) -------------------------------------------------------------------------------- /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 java.util.Map; 9 | 10 | import ru.evotor.IBundlable; 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 | } -------------------------------------------------------------------------------- /src/main/java/ru/evotor/framework/core/IntegrationManagerCallback.java: -------------------------------------------------------------------------------- 1 | package ru.evotor.framework.core; 2 | 3 | public interface IntegrationManagerCallback { 4 | void run(IntegrationManagerFuture future); 5 | } 6 | -------------------------------------------------------------------------------- /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/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/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 | */ 15 | const val ERROR_CODE_EMPTY_PARTNER_NAME = -1 16 | 17 | /** 18 | * Поле "основание" не может быть пустым 19 | */ 20 | const val ERROR_CODE_EMPTY_DESCRIPTION = -2 21 | 22 | /** 23 | * Сумма не может быть равна 0 24 | */ 25 | const val ERROR_CODE_ZERO_SUM = -3 26 | 27 | /** 28 | * Ошибка при регистрации документа внесения 29 | */ 30 | const val ERROR_CODE_DOCUMENT_NOT_REGISTERED = -4 31 | 32 | /** 33 | * Ошибка при работе с ККМ 34 | */ 35 | const val ERROR_CODE_KKM_ERROR = -5 36 | 37 | fun create(bundle: Bundle?): PrintCashIncomeCommandResult? { 38 | return if (bundle == null) { 39 | null 40 | } else { 41 | PrintCashIncomeCommandResult() 42 | } 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /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 | */ 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 | * Указанный id категории платежа не найден в справочнике 28 | */ 29 | const val ERROR_CODE_WRONG_PAYMENT_CATEGORY_ID = -4 30 | 31 | /** 32 | * Ошибка при регистрации документа внесения 33 | */ 34 | const val ERROR_CODE_DOCUMENT_NOT_REGISTERED = -5 35 | 36 | /** 37 | * Ошибка при работе с ККМ 38 | */ 39 | const val ERROR_CODE_KKM_ERROR = -6 40 | 41 | fun create(bundle: Bundle?): PrintCashOutcomeCommandResult? { 42 | return if (bundle == null) { 43 | null 44 | } else { 45 | PrintCashOutcomeCommandResult() 46 | } 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/ru/evotor/framework/core/action/command/print_receipt_command/PrintReceiptCommandErrorData.kt: -------------------------------------------------------------------------------- 1 | package ru.evotor.framework.core.action.command.print_receipt_command 2 | 3 | 4 | sealed class PrintReceiptCommandErrorData { 5 | class KktError(val kktErrorCode: Int?, val kktErrorDescription: String?) : PrintReceiptCommandErrorData() 6 | } -------------------------------------------------------------------------------- /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 | 14 | fun process(context: Context, callback: IntegrationManagerCallback) { 15 | val componentNameList = IntegrationManagerImpl.convertImplicitIntentToExplicitIntent( 16 | NAME, 17 | context.applicationContext 18 | ) 19 | if (componentNameList == null || componentNameList.isEmpty()) { 20 | return 21 | } 22 | IntegrationManagerImpl(context.applicationContext) 23 | .call( 24 | NAME, 25 | componentNameList[0], 26 | this, 27 | ActivityStarter(context), 28 | callback, 29 | Handler(Looper.getMainLooper()) 30 | ) 31 | } 32 | 33 | override fun toBundle(): Bundle { 34 | return Bundle() 35 | } 36 | 37 | companion object { 38 | 39 | const val NAME = "evo.v2.unprinted_document.print" 40 | 41 | @JvmStatic 42 | fun create(bundle: Bundle?): PrintUnprintedDocumentCommand? { 43 | return bundle?.let { 44 | PrintUnprintedDocumentCommand() 45 | } 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/main/java/ru/evotor/framework/core/action/command/print_unprinted_document/PrintUnprintedDocumentCommandResult.kt: -------------------------------------------------------------------------------- 1 | package ru.evotor.framework.core.action.command.print_unprinted_document 2 | 3 | import android.os.Bundle 4 | import ru.evotor.IBundlable 5 | 6 | class PrintUnprintedDocumentCommandResult: IBundlable { 7 | 8 | override fun toBundle(): Bundle { 9 | return Bundle() 10 | } 11 | 12 | companion object { 13 | 14 | /** 15 | * ККМ в данный момент выполняет другую операцию 16 | */ 17 | const val ERROR_CODE_KKM_IS_BUSY = -1 18 | 19 | /** 20 | * Ошибка печати 21 | */ 22 | const val ERROR_CODE_PRINT_DOCUMENT_FAILED = -2 23 | 24 | @JvmStatic 25 | fun create(bundle: Bundle?): PrintUnprintedDocumentCommandResult? { 26 | return bundle?.let { 27 | PrintUnprintedDocumentCommandResult() 28 | } 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/ru/evotor/framework/core/action/command/print_z_report_command/PrintZReportCommandErrorData.kt: -------------------------------------------------------------------------------- 1 | package ru.evotor.framework.core.action.command.print_z_report_command 2 | 3 | 4 | sealed class PrintZReportCommandErrorData { 5 | class KktError(val kktErrorCode: Int?, val kktErrorDescription: String?) : PrintZReportCommandErrorData() 6 | } -------------------------------------------------------------------------------- /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/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 | } -------------------------------------------------------------------------------- /src/main/java/ru/evotor/framework/core/action/datamapper/MarkMapper.kt: -------------------------------------------------------------------------------- 1 | package ru.evotor.framework.core.action.datamapper 2 | 3 | import android.os.Bundle 4 | import ru.evotor.framework.receipt.position.Mark 5 | 6 | object MarkMapper { 7 | 8 | private const val KEY_MARK_ENTITY = "markEntity" 9 | 10 | @JvmStatic 11 | fun toBundle(mark: Mark?): Bundle = 12 | Bundle().apply { 13 | putParcelable(KEY_MARK_ENTITY, mark) 14 | } 15 | 16 | @JvmStatic 17 | fun fromBundle(bundle: Bundle?): Mark? { 18 | return bundle?.let { 19 | it.classLoader = Mark::class.java.classLoader 20 | it.getParcelable(KEY_MARK_ENTITY) 21 | } 22 | } 23 | } -------------------------------------------------------------------------------- /src/main/java/ru/evotor/framework/core/action/datamapper/PaymentDelegatorMapper.kt: -------------------------------------------------------------------------------- 1 | package ru.evotor.framework.core.action.datamapper 2 | 3 | import android.os.Bundle 4 | import ru.evotor.framework.component.PaymentDelegator 5 | 6 | object PaymentDelegatorMapper { 7 | fun fromBundle(bundle: Bundle?) = 8 | bundle?.let { 9 | PaymentDelegator( 10 | IntegrationComponentMapper.readPackageName(bundle), 11 | IntegrationComponentMapper.readComponentName(bundle), 12 | IntegrationComponentMapper.readAppUuid(bundle), 13 | IntegrationComponentMapper.readAppName(bundle) 14 | ) 15 | } 16 | 17 | fun toBundle(paymentDelegator: PaymentDelegator) = 18 | IntegrationComponentMapper.toBundle(paymentDelegator) 19 | } -------------------------------------------------------------------------------- /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 | } -------------------------------------------------------------------------------- /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 | 7 | object PositionAttributesMapper { 8 | 9 | @JvmStatic 10 | fun fromBundle(attributes: Bundle?): Map? { 11 | attributes?.let { bundle -> 12 | bundle.classLoader = AttributeValue::class.java.classLoader 13 | return HashMap().apply { 14 | attributes.keySet().forEach { key -> 15 | val value = attributes.getParcelable(key) as AttributeValue? 16 | value?.let { 17 | this[key] = it 18 | } 19 | } 20 | } 21 | } ?: return null 22 | } 23 | 24 | 25 | @JvmStatic 26 | fun toBundle(attributes: Map?): Bundle? { 27 | attributes?.let { 28 | return Bundle().apply { 29 | attributes.keys.forEach { 30 | this.putParcelable(it, attributes[it]) 31 | } 32 | } 33 | } ?: return null 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/ru/evotor/framework/core/action/datamapper/SettlementMethodMapper.kt: -------------------------------------------------------------------------------- 1 | package ru.evotor.framework.core.action.datamapper 2 | 3 | import android.os.Bundle 4 | import ru.evotor.framework.receipt.position.SettlementMethod 5 | 6 | object SettlementMethodMapper { 7 | 8 | private const val KEY_SETTLEMENT_METHOD = "settlementMethod" 9 | 10 | @JvmStatic 11 | fun toBundle(settlementMethod: SettlementMethod): Bundle = 12 | Bundle().apply { 13 | putParcelable(KEY_SETTLEMENT_METHOD, settlementMethod) 14 | } 15 | 16 | @JvmStatic 17 | fun fromBundle(bundle: Bundle?): SettlementMethod { 18 | val defaultSettlementMethod = SettlementMethod.FullSettlement() 19 | 20 | val settlementMethod = bundle?.let { 21 | it.classLoader = SettlementMethod::class.java.classLoader 22 | it.getParcelable(KEY_SETTLEMENT_METHOD) 23 | } 24 | 25 | return settlementMethod ?: defaultSettlementMethod 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /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/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/cash_drawer/CashDrawerOpenEvent.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 androidx.annotation.Nullable; 7 | 8 | /** 9 | * @deprecated Используйте {@link ru.evotor.framework.device.cash_drawer.event.CashDrawerOpenedEvent} 10 | */ 11 | @Deprecated 12 | public class CashDrawerOpenEvent extends CashDrawerEvent { 13 | public static final String BROADCAST_ACTION_CASH_DRAWER_OPEN = "evotor.intent.action.cashDrawer.OPEN"; 14 | 15 | public CashDrawerOpenEvent(int cashDrawerId) { 16 | super(cashDrawerId); 17 | } 18 | 19 | private CashDrawerOpenEvent(@NonNull Bundle extras) { 20 | super(extras); 21 | } 22 | 23 | @Nullable 24 | public static CashDrawerOpenEvent create(@Nullable Bundle bundle) { 25 | if (bundle == null) { 26 | return null; 27 | } 28 | return new CashDrawerOpenEvent(bundle); 29 | } 30 | } -------------------------------------------------------------------------------- /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/inventory/ProductCardOpenedEvent.java: -------------------------------------------------------------------------------- 1 | package ru.evotor.framework.core.action.event.inventory; 2 | 3 | import android.os.Bundle; 4 | 5 | import androidx.annotation.Nullable; 6 | 7 | /** 8 | * @deprecated Используйте {@link ru.evotor.framework.inventory.event.ProductCardOpenedEvent} 9 | */ 10 | @Deprecated 11 | public class ProductCardOpenedEvent extends ProductEvent { 12 | public static final String BROADCAST_ACTION_PRODUCT_CARD_OPENED = "evotor.intent.action.inventory.CARD_OPEN"; 13 | 14 | public ProductCardOpenedEvent(@Nullable String productUuid) { 15 | super(productUuid); 16 | } 17 | 18 | @Nullable 19 | public static ProductCardOpenedEvent create(@Nullable Bundle bundle) { 20 | if (bundle == null) { 21 | return null; 22 | } 23 | return new ProductCardOpenedEvent(getProductUuid(bundle)); 24 | } 25 | } -------------------------------------------------------------------------------- /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/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/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 | POSITION_REMOVE, 23 | /** 24 | * Изменение позиции чека. 25 | */ 26 | POSITION_EDIT, 27 | /** 28 | * Запись дополнительных полей в чек. 29 | */ 30 | SET_EXTRA, 31 | SET_POSITION_PRINT_GROUP, 32 | SET_PAYMENT_PURPOSE_PRINT_GROUP, 33 | /** 34 | * Добавление дополнительных полей для печати в чеке. 35 | */ 36 | SET_PRINT_EXTRA, 37 | SET_PURCHASER_CONTACT_DATA, 38 | UNKNOWN 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/ru/evotor/framework/core/action/event/receipt/changes/UnknownChange.kt: -------------------------------------------------------------------------------- 1 | package ru.evotor.framework.core.action.event.receipt.changes 2 | 3 | import android.os.Bundle 4 | 5 | /** 6 | * Created by a.kuznetsov on 23/05/2017. 7 | */ 8 | 9 | class UnknownChange(val typeName: String, val bundle: Bundle) : IChange { 10 | 11 | override fun getType(): IChange.Type { 12 | return IChange.Type.UNKNOWN 13 | } 14 | 15 | override fun toBundle(): Bundle { 16 | return bundle 17 | } 18 | 19 | companion object { 20 | @JvmStatic 21 | fun from(typeName: String?, bundle: Bundle?): UnknownChange? { 22 | typeName ?: return null 23 | bundle ?: return null 24 | 25 | return UnknownChange( 26 | typeName, 27 | bundle 28 | ) 29 | } 30 | } 31 | 32 | 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/ru/evotor/framework/core/action/event/receipt/changes/position/IPositionChange.kt: -------------------------------------------------------------------------------- 1 | package ru.evotor.framework.core.action.event.receipt.changes.position 2 | 3 | import ru.evotor.framework.core.action.event.receipt.changes.IChange 4 | 5 | /** 6 | * 7 | */ 8 | interface IPositionChange : IChange { 9 | /** 10 | * Возвращает идентификатор позиции. 11 | */ 12 | fun getPositionUuid(): String? 13 | } -------------------------------------------------------------------------------- /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 | 14 | override fun toBundle(): Bundle { 15 | return Bundle().apply { 16 | putBundle( 17 | PositionMapper.KEY_POSITION, 18 | PositionMapper.toBundle(position) 19 | ) 20 | } 21 | } 22 | 23 | override fun getPositionUuid(): String? { 24 | return position.uuid 25 | } 26 | 27 | override fun getType(): IChange.Type { 28 | return IChange.Type.POSITION_ADD 29 | } 30 | 31 | companion object { 32 | @JvmStatic 33 | fun from(bundle: Bundle?): PositionAdd? { 34 | bundle ?: return null 35 | 36 | return PositionAdd( 37 | PositionMapper.from( 38 | bundle.getBundle(PositionMapper.KEY_POSITION) 39 | ) ?: return null 40 | ) 41 | } 42 | } 43 | } -------------------------------------------------------------------------------- /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 | 14 | override fun toBundle(): Bundle { 15 | return Bundle().apply { 16 | putBundle( 17 | PositionMapper.KEY_POSITION, 18 | PositionMapper.toBundle(position) 19 | ) 20 | } 21 | } 22 | 23 | override fun getPositionUuid(): String? { 24 | return position.uuid 25 | } 26 | 27 | override fun getType(): IChange.Type { 28 | return IChange.Type.POSITION_EDIT 29 | } 30 | 31 | companion object { 32 | @JvmStatic 33 | fun from(bundle: Bundle?): PositionEdit? { 34 | bundle ?: return null 35 | 36 | return PositionEdit( 37 | PositionMapper.from(bundle.getBundle(PositionMapper.KEY_POSITION)) ?: return null 38 | ) 39 | } 40 | } 41 | } -------------------------------------------------------------------------------- /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 | 14 | override fun toBundle(): Bundle { 15 | return Bundle().apply { 16 | putString( 17 | KEY_POSITION_UUID, 18 | positionUuid 19 | ) 20 | } 21 | } 22 | 23 | override fun getPositionUuid(): String? { 24 | return positionUuid 25 | } 26 | 27 | override fun getType(): IChange.Type { 28 | return IChange.Type.POSITION_REMOVE 29 | } 30 | 31 | companion object { 32 | const val KEY_POSITION_UUID = "positionUuid" 33 | 34 | @JvmStatic 35 | fun from(bundle: Bundle?): PositionRemove? { 36 | bundle ?: return null 37 | 38 | return PositionRemove( 39 | bundle.getString(KEY_POSITION_UUID) ?: return null 40 | ) 41 | } 42 | } 43 | } -------------------------------------------------------------------------------- /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 | 12 | override fun toBundle(): Bundle { 13 | return Bundle().apply { 14 | putString( 15 | KEY_EXTRA, 16 | extra?.toString() 17 | ) 18 | } 19 | } 20 | 21 | override fun getType(): IChange.Type { 22 | return IChange.Type.SET_EXTRA 23 | } 24 | 25 | companion object { 26 | const val KEY_EXTRA = "extra" 27 | 28 | @JvmStatic 29 | fun from(bundle: Bundle?): SetExtra? { 30 | bundle ?: return null 31 | 32 | return SetExtra( 33 | bundle.getString(KEY_EXTRA)?.let { JSONObject(it) } 34 | ) 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /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 | 15 | override fun getType() = IChange.Type.SET_PRINT_EXTRA 16 | 17 | override fun toBundle(): Bundle = 18 | Bundle().apply { 19 | putBundle(KEY_PRINT_PLACE, PrintExtraPlaceMapper.toBundle(printPlace)) 20 | putBundle(KEY_PRINTABLES, PrintablesMapper.toBundle(printables)) 21 | } 22 | 23 | companion object { 24 | 25 | const val KEY_PRINT_PLACE = "printPlace" 26 | const val KEY_PRINTABLES = "printables" 27 | 28 | @JvmStatic 29 | fun from(bundle: Bundle?): SetPrintExtra? { 30 | bundle ?: return null 31 | 32 | val printPlace = PrintExtraPlaceMapper.fromBundle(bundle.getBundle(KEY_PRINT_PLACE)) 33 | val printables = PrintablesMapper.fromBundle(bundle.getBundle(KEY_PRINTABLES)) 34 | 35 | if (printPlace == null || printables == null) { 36 | return null 37 | } 38 | 39 | return SetPrintExtra(printPlace, printables) 40 | } 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /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/core/action/event/receipt/discount_required/ReceiptDiscountRequiredEventProcessor.kt: -------------------------------------------------------------------------------- 1 | package ru.evotor.framework.core.action.event.receipt.discount_required 2 | 3 | import android.os.Bundle 4 | import android.os.RemoteException 5 | import ru.evotor.framework.core.action.processor.ActionProcessor 6 | 7 | abstract class ReceiptDiscountRequiredEventProcessor : ActionProcessor() { 8 | @Throws(RemoteException::class) 9 | override fun process(action: String, bundle: Bundle?, callback: ActionProcessor.Callback) { 10 | val event = ReceiptDiscountRequiredEvent.create(bundle) 11 | if (event == null) { 12 | callback.skip() 13 | return 14 | } 15 | call( 16 | action, 17 | event, 18 | callback 19 | ) 20 | } 21 | 22 | abstract fun call(action: String, event: ReceiptDiscountRequiredEvent, callback: ActionProcessor.Callback) 23 | } 24 | 25 | -------------------------------------------------------------------------------- /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 | } 30 | -------------------------------------------------------------------------------- /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 | 8 | override fun toBundle(): Bundle { 9 | return Bundle() 10 | } 11 | 12 | companion object { 13 | 14 | /** 15 | * Разрешение для обработки события ошибки безналичной платежной системы 16 | * 17 | * Указывайте разрешение в манифесте приложения, в элементе `` до элемента ``. 18 | */ 19 | const val NAME_PERMISSION = "ru.evotor.permission.handle.ERROR_PAYMENT_BY_CARD" 20 | const val NAME = "evo.v2.receipt.errorPaymentByCard" 21 | 22 | fun create(bundle: Bundle?): ErrorPaymentByCardEvent? { 23 | if(bundle == null) { 24 | return null 25 | } 26 | return ErrorPaymentByCardEvent() 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/ru/evotor/framework/core/action/event/receipt/error_card_payment/ErrorPaymentByCardEventProcessor.kt: -------------------------------------------------------------------------------- 1 | package ru.evotor.framework.core.action.event.receipt.error_card_payment 2 | 3 | import android.os.Bundle 4 | import android.os.RemoteException 5 | import ru.evotor.framework.core.action.processor.ActionProcessor 6 | 7 | abstract class ErrorPaymentByCardEventProcessor : ActionProcessor() { 8 | 9 | @Throws(RemoteException::class) 10 | override fun process(action: String, bundle: Bundle?, callback: ActionProcessor.Callback) { 11 | val event = ErrorPaymentByCardEvent.create(bundle) 12 | if (event == null) { 13 | callback.skip() 14 | return 15 | } 16 | call(action, event, callback) 17 | } 18 | 19 | abstract fun call(action: String, event: ErrorPaymentByCardEvent, callback: ActionProcessor.Callback) 20 | } 21 | -------------------------------------------------------------------------------- /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 | 13 | 14 | override fun toBundle(): Bundle { 15 | val bundle = Bundle() 16 | val actionsParcelable = arrayOfNulls(actions.size) 17 | for (i in actionsParcelable.indices) { 18 | val action: IHandleEventResultAction = actions[i] 19 | actionsParcelable[i] = ErrorPaymentByCardActionMapper.toBundle(action) 20 | } 21 | bundle.putParcelableArray(KEY_ACTIONS, actionsParcelable) 22 | return bundle 23 | } 24 | 25 | companion object { 26 | private const val KEY_ACTIONS = "actions" 27 | 28 | fun create(bundle: Bundle?): ErrorPaymentByCardEventResult? { 29 | if (bundle == null) { 30 | return null 31 | } 32 | val actionsParcelable = 33 | bundle.getParcelableArray(KEY_ACTIONS) 34 | val actions = ErrorPaymentByCardActionMapper.create(actionsParcelable) 35 | return ErrorPaymentByCardEventResult(actions) 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/ru/evotor/framework/core/action/event/receipt/error_card_payment/actions/IHandleEventResultAction.kt: -------------------------------------------------------------------------------- 1 | package ru.evotor.framework.core.action.event.receipt.error_card_payment.actions 2 | 3 | import ru.evotor.IBundlable 4 | 5 | interface IHandleEventResultAction : IBundlable { 6 | 7 | fun getType(): Type 8 | 9 | enum class Type { 10 | /** 11 | * Показ диалога ошибки с таймаутом 12 | */ 13 | SHOW_ERROR_SCREEN_ACTION 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /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 | val cancelTimeout: UInt? = null // таймаут нажатия на кнопку "ОТМЕНА" в секундах 12 | ) : IHandleEventResultAction { 13 | 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 | 28 | private const val KEY_TIMEOUT = "timeout" 29 | 30 | fun from(bundle: Bundle): PaymentByCardErrorAction { 31 | var timeout: Long? = bundle.getLong(KEY_TIMEOUT, -1L) 32 | if (timeout == -1L) { 33 | timeout = null 34 | } 35 | return PaymentByCardErrorAction( 36 | timeout?.toUInt() 37 | ) 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /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 | 11 | override fun process(action: String, bundle: Bundle?, callback: ActionProcessor.Callback) { 12 | val event = SendJewelryEvent.from(bundle) ?: run { 13 | callback.skip() 14 | return 15 | } 16 | call(action, event, callback) 17 | } 18 | 19 | /** 20 | * Используйте метод, чтобы обработать событие [SendJewelryEvent] и сохранить результат [SendJewelryEventResult]. 21 | * @param action 22 | * @param event экземпляр события о выбытии ювелирных изделий. 23 | * @param callback функция обратного вызова. Методы функции позволяют пропускать обработку события, возвращать результат, 24 | * запускать операции и обрабатывать ошибки. 25 | */ 26 | abstract fun call(action: String, event: SendJewelryEvent, callback: ActionProcessor.Callback) 27 | 28 | } 29 | -------------------------------------------------------------------------------- /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 | 15 | override fun toBundle(): Bundle { 16 | val bundle = Bundle() 17 | printableReport?.let { 18 | bundle.putBundle(KEY_PRINTABLE_REPORT, PrintablesMapper.toBundle(it)) 19 | } 20 | return bundle 21 | } 22 | 23 | companion object { 24 | private const val KEY_PRINTABLE_REPORT = "printableReport" 25 | 26 | fun create(bundle: Bundle?): SendJewelryEventResult? = bundle?.let { 27 | val printableReport = PrintablesMapper.fromBundle(bundle.getBundle(KEY_PRINTABLE_REPORT)) 28 | return SendJewelryEventResult( 29 | printableReport 30 | ) 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /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 | 8 | /** 9 | * Created by ivan on 26.06.17. 10 | */ 11 | 12 | /** 13 | * Класс представляет собой результат склеивания 2-х и более позиций в чеке для оповещения интеграций 14 | * before - список позиций, которые будут склеены 15 | * after - результат склейки 16 | */ 17 | 18 | class PositionsMerge(val before: List, val after: Position) : Parcelable { 19 | 20 | override fun writeToParcel(parcel: Parcel, i: Int) { 21 | parcel.writeList(before) 22 | parcel.writeParcelable(after, Parcelable.PARCELABLE_WRITE_RETURN_VALUE) 23 | } 24 | 25 | companion object { 26 | 27 | @JvmField 28 | val CREATOR: Parcelable.Creator = object : Parcelable.Creator { 29 | override fun createFromParcel(parcel: Parcel): PositionsMerge { 30 | val before = ArrayList() 31 | parcel.readList(before as List<*>, Position::class.java.classLoader) 32 | val after = parcel.readParcelable(Position::class.java.classLoader) ?: throw IntegrationLibraryParsingException(PositionsMerge::class.java) 33 | return PositionsMerge(before, after) 34 | } 35 | 36 | override fun newArray(size: Int): Array = arrayOfNulls(size) 37 | } 38 | } 39 | 40 | override fun describeContents(): Int = 0 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/ru/evotor/framework/core/action/event/receipt/merges/PositionsMergeEventProcessor.kt: -------------------------------------------------------------------------------- 1 | package ru.evotor.framework.core.action.event.receipt.merges 2 | 3 | import android.os.Bundle 4 | import ru.evotor.framework.core.action.processor.ActionProcessor 5 | 6 | /** 7 | * Created by ivan on 26.06.17. 8 | */ 9 | 10 | abstract class PositionsMergeEventProcessor : ActionProcessor() { 11 | 12 | override fun process(action: String, bundle: Bundle?, callback: ActionProcessor.Callback) { 13 | val event = PositionsMergeEvent.create(bundle) ?: run { 14 | callback.skip() 15 | return 16 | } 17 | 18 | call(action, event, callback) 19 | } 20 | 21 | abstract fun call(action: String, event: PositionsMergeEvent, callback: ActionProcessor.Callback) 22 | } -------------------------------------------------------------------------------- /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 | 13 | override fun toBundle(): Bundle { 14 | val result = Bundle() 15 | result.putBundle(KEY_RECEIPT_EXTRA, extra?.toBundle()) 16 | return result 17 | } 18 | 19 | companion object { 20 | private val KEY_RECEIPT_EXTRA = "extra" 21 | 22 | fun create(bundle: Bundle?): PositionsMergeEventResult? { 23 | return if (bundle == null) 24 | null 25 | else 26 | PositionsMergeEventResult(SetExtra.from(bundle.getBundle(KEY_RECEIPT_EXTRA))) 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/ru/evotor/framework/core/action/event/receipt/payment/PaymentSelectedEventProcessor.java: -------------------------------------------------------------------------------- 1 | package ru.evotor.framework.core.action.event.receipt.payment; 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 PaymentSelectedEvent}. 12 | * 13 | * @see "Разделение чека на несколько платежей" 14 | */ 15 | public abstract class PaymentSelectedEventProcessor extends ActionProcessor { 16 | @Override 17 | public void process(@NonNull String action, @Nullable Bundle bundle, @NonNull Callback callback) throws RemoteException { 18 | PaymentSelectedEvent event = PaymentSelectedEvent.create(bundle); 19 | 20 | if (event == null) { 21 | callback.skip(); 22 | return; 23 | } 24 | 25 | call( 26 | action, 27 | event, 28 | callback 29 | ); 30 | } 31 | 32 | /** 33 | * Используйте метод, чтобы обработать событие {@link PaymentSelectedEvent} и сохранить результат {@link PaymentSelectedEventResult}. 34 | * @param action 35 | * @param event экземпляр события выбора оплаты. 36 | * @param callback функция обратного вызова. Методы функции позволяют пропускать обработку события, возвращать результат, 37 | * запускать операции и обрабатывать ошибки. 38 | */ 39 | public abstract void call(@NonNull String action, @NonNull PaymentSelectedEvent event, @NonNull Callback callback); 40 | } 41 | 42 | -------------------------------------------------------------------------------- /src/main/java/ru/evotor/framework/core/action/event/receipt/payment/combined/PaybackPaymentDelegatorEventProcessor.kt: -------------------------------------------------------------------------------- 1 | package ru.evotor.framework.core.action.event.receipt.payment.combined 2 | 3 | import android.os.Bundle 4 | import ru.evotor.framework.core.action.event.receipt.payment.combined.event.PaybackPaymentDelegatorEvent 5 | import ru.evotor.framework.core.action.processor.ActionProcessor 6 | 7 | abstract class PaybackPaymentDelegatorEventProcessor : ActionProcessor() { 8 | override fun process(action: String, bundle: Bundle?, callback: Callback) { 9 | val event = PaybackPaymentDelegatorEvent.create(bundle) ?: run { 10 | callback.skip() 11 | return 12 | } 13 | 14 | call(action, event, callback) 15 | } 16 | 17 | abstract fun call(action: String, event: PaybackPaymentDelegatorEvent, callback: ActionProcessor.Callback) 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/ru/evotor/framework/core/action/event/receipt/payment/combined/PaymentDelegatorEventProcessor.kt: -------------------------------------------------------------------------------- 1 | package ru.evotor.framework.core.action.event.receipt.payment.combined 2 | 3 | import android.os.Bundle 4 | import ru.evotor.framework.core.action.event.receipt.payment.combined.event.PaymentDelegatorEvent 5 | import ru.evotor.framework.core.action.processor.ActionProcessor 6 | 7 | abstract class PaymentDelegatorEventProcessor : ActionProcessor() { 8 | override fun process(action: String, bundle: Bundle?, callback: Callback) { 9 | val event = PaymentDelegatorEvent.create(bundle) ?: run { 10 | callback.skip() 11 | return 12 | } 13 | call( 14 | action, 15 | event, 16 | callback 17 | ) 18 | } 19 | 20 | abstract fun call(action: String, event: PaymentDelegatorEvent, callback: ActionProcessor.Callback) 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/ru/evotor/framework/core/action/event/receipt/payment/combined/result/PaymentDelegatorCanceledAllEventResult.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 PaymentDelegatorCanceledAllEventResult(extra: SetExtra?) : PaymentDelegatorEventResult(ResultType.CANCEL_ALL, extra) { 7 | companion object { 8 | 9 | fun create(bundle: Bundle?): PaymentDelegatorCanceledAllEventResult? { 10 | if (bundle == null) { 11 | return null 12 | } 13 | return PaymentDelegatorCanceledAllEventResult(SetExtra.from(bundle.getBundle(KEY_RECEIPT_EXTRA))) 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /src/main/java/ru/evotor/framework/core/action/event/receipt/payment/combined/result/PaymentDelegatorEventResult.kt: -------------------------------------------------------------------------------- 1 | package ru.evotor.framework.core.action.event.receipt.payment.combined.result 2 | 3 | import android.os.Bundle 4 | import ru.evotor.IBundlable 5 | import ru.evotor.framework.Utils 6 | import ru.evotor.framework.core.action.event.receipt.changes.receipt.SetExtra 7 | 8 | abstract class PaymentDelegatorEventResult( 9 | val resultType: ResultType, 10 | val extra: SetExtra? 11 | ) : IBundlable { 12 | 13 | override fun toBundle(): Bundle { 14 | val result = Bundle() 15 | result.putBundle(KEY_RECEIPT_EXTRA, extra?.toBundle()) 16 | result.putString(KEY_RESULT_TYPE, resultType.name) 17 | return result 18 | } 19 | 20 | public enum class ResultType { 21 | UNKNOWN, SELECTED, CANCEL, CANCEL_ALL 22 | } 23 | 24 | companion object { 25 | private const val KEY_RESULT_TYPE = "resultType" 26 | const val KEY_RECEIPT_EXTRA = "extra" 27 | 28 | fun create(bundle: Bundle?): PaymentDelegatorEventResult? { 29 | if (bundle == null) { 30 | return null 31 | } 32 | val resultType = Utils.safeValueOf(ResultType::class.java, bundle.getString(KEY_RESULT_TYPE, null), ResultType.UNKNOWN) 33 | return when (resultType) { 34 | ResultType.SELECTED -> PaymentDelegatorSelectedEventResult.create(bundle) 35 | ResultType.CANCEL -> PaymentDelegatorCanceledEventResult.create(bundle) 36 | ResultType.CANCEL_ALL -> PaymentDelegatorCanceledAllEventResult.create(bundle) 37 | else -> null 38 | } 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /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/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 | 9 | override fun toBundle(): Bundle { 10 | val result = super.toBundle() 11 | result.putString(KEY_ERROR_DESCRIPTION, errorDescription) 12 | return result 13 | } 14 | 15 | companion object { 16 | private val KEY_ERROR_DESCRIPTION = "errorDescription" 17 | 18 | fun create(bundle: Bundle?): PaymentSystemPaymentErrorResult? { 19 | if (bundle == null) { 20 | return null 21 | } 22 | val errorDescription = bundle.getString(KEY_ERROR_DESCRIPTION, null) 23 | return PaymentSystemPaymentErrorResult(errorDescription) 24 | } 25 | } 26 | } -------------------------------------------------------------------------------- /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 | 11 | override fun toBundle(): Bundle { 12 | val result = Bundle() 13 | result.putString(KEY_RESULT_TYPE, resultType.name) 14 | return result 15 | } 16 | 17 | public enum class ResultType { 18 | UNKNOWN, OK, ERROR 19 | } 20 | 21 | companion object { 22 | private val KEY_RESULT_TYPE = "resultType" 23 | 24 | fun create(bundle: Bundle?): PaymentSystemPaymentResult? { 25 | if (bundle == null) { 26 | return null 27 | } 28 | val resultType = Utils.safeValueOf(ResultType::class.java, bundle.getString(KEY_RESULT_TYPE, null), ResultType.UNKNOWN) 29 | return when (resultType) { 30 | ResultType.OK -> PaymentSystemPaymentOkResult.create(bundle) 31 | ResultType.ERROR -> PaymentSystemPaymentErrorResult.create(bundle) 32 | else -> null 33 | } 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /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 | import android.os.Bundle; 4 | 5 | import androidx.annotation.NonNull; 6 | import androidx.annotation.Nullable; 7 | import ru.evotor.framework.receipt.Position; 8 | 9 | /** 10 | * @deprecated Используйте {@link ru.evotor.framework.receipt.position.event.PositionAddedEvent} 11 | */ 12 | @Deprecated 13 | public class PositionAddedEvent extends PositionEvent { 14 | public static final String BROADCAST_ACTION_SELL_RECEIPT = "evotor.intent.action.receipt.sell.POSITION_ADDED"; 15 | public static final String BROADCAST_ACTION_PAYBACK_RECEIPT = "evotor.intent.action.receipt.payback.POSITION_ADDED"; 16 | public static final String BROADCAST_ACTION_BUY_RECEIPT = "evotor.intent.action.receipt.buy.POSITION_ADDED"; 17 | public static final String BROADCAST_ACTION_BUYBACK_RECEIPT = "evotor.intent.action.receipt.buyback.POSITION_ADDED"; 18 | 19 | @Nullable 20 | public static PositionAddedEvent create(@Nullable Bundle extras) { 21 | if (extras == null) { 22 | return null; 23 | } 24 | String receiptUuid = getReceiptUuid(extras); 25 | if (receiptUuid == null) { 26 | return null; 27 | } 28 | Position position = getPosition(extras); 29 | if (position == null) { 30 | return null; 31 | } 32 | return new PositionAddedEvent(receiptUuid, position); 33 | } 34 | 35 | public PositionAddedEvent(@NonNull String receiptUuid, @NonNull Position position) { 36 | super(receiptUuid, position); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /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 | import android.os.Bundle; 4 | 5 | import androidx.annotation.NonNull; 6 | import androidx.annotation.Nullable; 7 | import ru.evotor.framework.receipt.Position; 8 | 9 | /** 10 | * @deprecated Используйте {@link ru.evotor.framework.receipt.position.event.PositionUpdatedEvent} 11 | */ 12 | @Deprecated 13 | public class PositionEditedEvent extends PositionEvent { 14 | public static final String BROADCAST_ACTION_SELL_RECEIPT = "evotor.intent.action.receipt.sell.POSITION_EDITED"; 15 | public static final String BROADCAST_ACTION_PAYBACK_RECEIPT = "evotor.intent.action.receipt.payback.POSITION_EDITED"; 16 | public static final String BROADCAST_ACTION_BUY_RECEIPT = "evotor.intent.action.receipt.buy.POSITION_EDITED"; 17 | public static final String BROADCAST_ACTION_BUYBACK_RECEIPT = "evotor.intent.action.receipt.buyback.POSITION_EDITED"; 18 | 19 | @Nullable 20 | public static PositionEditedEvent create(@Nullable Bundle extras) { 21 | if (extras == null) { 22 | return null; 23 | } 24 | String receiptUuid = getReceiptUuid(extras); 25 | if (receiptUuid == null) { 26 | return null; 27 | } 28 | Position position = getPosition(extras); 29 | if (position == null) { 30 | return null; 31 | } 32 | return new PositionEditedEvent(receiptUuid, position); 33 | } 34 | 35 | public PositionEditedEvent(@NonNull String receiptUuid, @NonNull Position position) { 36 | super(receiptUuid, position); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /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 | import android.os.Bundle; 4 | 5 | import androidx.annotation.NonNull; 6 | import androidx.annotation.Nullable; 7 | import ru.evotor.framework.receipt.Position; 8 | 9 | /** 10 | * @deprecated Используйте {@link ru.evotor.framework.receipt.position.event.PositionRemovedEvent} 11 | */ 12 | @Deprecated 13 | public class PositionRemovedEvent extends PositionEvent { 14 | public static final String BROADCAST_ACTION_SELL_RECEIPT = "evotor.intent.action.receipt.sell.POSITION_REMOVED"; 15 | public static final String BROADCAST_ACTION_PAYBACK_RECEIPT = "evotor.intent.action.receipt.payback.POSITION_REMOVED"; 16 | public static final String BROADCAST_ACTION_BUY_RECEIPT = "evotor.intent.action.receipt.buy.POSITION_REMOVED"; 17 | public static final String BROADCAST_ACTION_BUYBACK_RECEIPT = "evotor.intent.action.receipt.buyback.POSITION_REMOVED"; 18 | 19 | @Nullable 20 | public static PositionRemovedEvent create(@Nullable Bundle extras) { 21 | if (extras == null) { 22 | return null; 23 | } 24 | String receiptUuid = getReceiptUuid(extras); 25 | if (receiptUuid == null) { 26 | return null; 27 | } 28 | Position position = getPosition(extras); 29 | if (position == null) { 30 | return null; 31 | } 32 | return new PositionRemovedEvent(receiptUuid, position); 33 | } 34 | 35 | public PositionRemovedEvent(@NonNull String receiptUuid, @NonNull Position position) { 36 | super(receiptUuid, position); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/ru/evotor/framework/core/action/event/receipt/print_extra/PrintExtraRequiredEventProcessor.kt: -------------------------------------------------------------------------------- 1 | package ru.evotor.framework.core.action.event.receipt.print_extra 2 | 3 | import android.os.Bundle 4 | import ru.evotor.framework.core.action.processor.ActionProcessor 5 | 6 | abstract class PrintExtraRequiredEventProcessor : ActionProcessor() { 7 | 8 | override fun process(action: String, bundle: Bundle?, callback: ActionProcessor.Callback) { 9 | val event = PrintExtraRequiredEvent.create(bundle) ?: run { 10 | callback.skip() 11 | return 12 | } 13 | call(action, event, callback) 14 | } 15 | 16 | abstract fun call(action: String, event: PrintExtraRequiredEvent, callback: ActionProcessor.Callback) 17 | 18 | } -------------------------------------------------------------------------------- /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 | import android.os.Bundle; 4 | 5 | import androidx.annotation.NonNull; 6 | import androidx.annotation.Nullable; 7 | 8 | /** 9 | * @deprecated Используйте {@link ru.evotor.framework.receipt.event.ReceiptDeletedEvent} 10 | */ 11 | @Deprecated 12 | public class ReceiptClearedEvent extends ReceiptEvent { 13 | public static final String BROADCAST_ACTION_SELL_RECEIPT_CLEARED = "evotor.intent.action.receipt.sell.CLEARED"; 14 | public static final String BROADCAST_ACTION_PAYBACK_RECEIPT_CLEARED = "evotor.intent.action.receipt.payback.CLEARED"; 15 | public static final String BROADCAST_ACTION_BUY_RECEIPT_CLEARED = "evotor.intent.action.receipt.buy.CLEARED"; 16 | public static final String BROADCAST_ACTION_BUYBACK_RECEIPT_CLEARED = "evotor.intent.action.receipt.buyback.CLEARED"; 17 | 18 | public ReceiptClearedEvent(@NonNull String receiptUuid) { 19 | super(receiptUuid); 20 | } 21 | 22 | @Nullable 23 | public static ReceiptClearedEvent create(@Nullable Bundle bundle) { 24 | if (bundle == null) { 25 | return null; 26 | } 27 | String receiptUuid = getReceiptUuid(bundle); 28 | if (receiptUuid == null) { 29 | return null; 30 | } 31 | return new ReceiptClearedEvent(receiptUuid); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /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 | import android.os.Bundle; 4 | 5 | import androidx.annotation.NonNull; 6 | import androidx.annotation.Nullable; 7 | 8 | /** 9 | * @deprecated Используйте {@link ru.evotor.framework.receipt.event.ReceiptCompletedEvent} 10 | */ 11 | @Deprecated 12 | public class ReceiptClosedEvent extends ReceiptEvent { 13 | public static final String BROADCAST_ACTION_SELL_RECEIPT_CLOSED = "evotor.intent.action.receipt.sell.RECEIPT_CLOSED"; 14 | public static final String BROADCAST_ACTION_PAYBACK_RECEIPT_CLOSED = "evotor.intent.action.receipt.payback.RECEIPT_CLOSED"; 15 | public static final String BROADCAST_ACTION_BUY_RECEIPT_CLOSED = "evotor.intent.action.receipt.buy.RECEIPT_CLOSED"; 16 | public static final String BROADCAST_ACTION_BUYBACK_RECEIPT_CLOSED = "evotor.intent.action.receipt.buyback.RECEIPT_CLOSED"; 17 | 18 | public ReceiptClosedEvent(@NonNull String receiptUuid) { 19 | super(receiptUuid); 20 | } 21 | 22 | @Nullable 23 | public static ReceiptClosedEvent create(@Nullable Bundle bundle) { 24 | if (bundle == null) { 25 | return null; 26 | } 27 | String receiptUuid = getReceiptUuid(bundle); 28 | if (receiptUuid == null) { 29 | return null; 30 | } 31 | return new ReceiptClosedEvent(receiptUuid); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /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/receipt_edited/ReceiptOpenedEvent.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 | 8 | /** 9 | * @deprecated Используйте {@link ru.evotor.framework.receipt.event.ReceiptCreatedEvent} 10 | */ 11 | @Deprecated 12 | public class ReceiptOpenedEvent extends ReceiptEvent { 13 | public static final String BROADCAST_ACTION_SELL_RECEIPT = "evotor.intent.action.receipt.sell.OPENED"; 14 | public static final String BROADCAST_ACTION_PAYBACK_RECEIPT = "evotor.intent.action.receipt.payback.OPENED"; 15 | public static final String BROADCAST_ACTION_BUY_RECEIPT = "evotor.intent.action.receipt.buy.OPENED"; 16 | public static final String BROADCAST_ACTION_BUYBACK_RECEIPT = "evotor.intent.action.receipt.buyback.OPENED"; 17 | 18 | public ReceiptOpenedEvent(@NonNull String receiptUuid) { 19 | super(receiptUuid); 20 | } 21 | 22 | @Nullable 23 | public static ReceiptOpenedEvent create(@Nullable Bundle bundle) { 24 | if (bundle == null) { 25 | return null; 26 | } 27 | String receiptUuid = getReceiptUuid(bundle); 28 | if (receiptUuid == null) { 29 | return null; 30 | } 31 | return new ReceiptOpenedEvent(receiptUuid); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /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 | import android.os.Bundle; 4 | 5 | import androidx.annotation.NonNull; 6 | import androidx.annotation.Nullable; 7 | 8 | public class ReceiptPaymentPartsEditedEvent extends ReceiptEvent { 9 | public static final String BROADCAST_ACTION_SELL_RECEIPT = "evotor.intent.action.receipt.sell.paymentParts.EDITED"; 10 | public static final String BROADCAST_ACTION_PAYBACK_RECEIPT = "evotor.intent.action.receipt.payback.paymentParts.EDITED"; 11 | 12 | public ReceiptPaymentPartsEditedEvent(@NonNull String receiptUuid) { 13 | super(receiptUuid); 14 | } 15 | 16 | @Nullable 17 | public static ReceiptPaymentPartsEditedEvent create(@Nullable Bundle bundle) { 18 | if (bundle == null) { 19 | return null; 20 | } 21 | String receiptUuid = getReceiptUuid(bundle); 22 | if (receiptUuid == null) { 23 | return null; 24 | } 25 | return new ReceiptPaymentPartsEditedEvent(receiptUuid); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /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 | import android.os.Bundle; 4 | 5 | import androidx.annotation.NonNull; 6 | import androidx.annotation.Nullable; 7 | 8 | public class ReceiptPrintGroupEditedEvent extends ReceiptEvent { 9 | public static final String BROADCAST_ACTION_SELL_RECEIPT = "evotor.intent.action.receipt.sell.printGroup.EDITED"; 10 | public static final String BROADCAST_ACTION_PAYBACK_RECEIPT = "evotor.intent.action.receipt.payback.printGroup.EDITED"; 11 | public static final String BROADCAST_ACTION_BUY_RECEIPT = "evotor.intent.action.receipt.buy.printGroup.EDITED"; 12 | public static final String BROADCAST_ACTION_BUYBACK_RECEIPT = "evotor.intent.action.receipt.buyback.printGroup.EDITED"; 13 | 14 | public ReceiptPrintGroupEditedEvent(@NonNull String receiptUuid) { 15 | super(receiptUuid); 16 | } 17 | 18 | @Nullable 19 | public static ReceiptPrintGroupEditedEvent create(@Nullable Bundle bundle) { 20 | if (bundle == null) { 21 | return null; 22 | } 23 | String receiptUuid = getReceiptUuid(bundle); 24 | if (receiptUuid == null) { 25 | return null; 26 | } 27 | return new ReceiptPrintGroupEditedEvent(receiptUuid); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/ru/evotor/framework/core/action/event/session/SessionClosedEvent.java: -------------------------------------------------------------------------------- 1 | package ru.evotor.framework.core.action.event.session; 2 | 3 | import android.os.Bundle; 4 | 5 | import androidx.annotation.NonNull; 6 | import androidx.annotation.Nullable; 7 | 8 | public class SessionClosedEvent extends SessionEvent { 9 | public static final String BROADCAST_ACTION_SESSION_CLOSED = "evotor.intent.action.reports.SESSION_CLOSED"; 10 | 11 | public SessionClosedEvent() { 12 | super(); 13 | } 14 | 15 | private SessionClosedEvent(@NonNull Bundle extra) { 16 | super(extra); 17 | } 18 | 19 | @Nullable 20 | public static SessionClosedEvent create(@Nullable Bundle bundle) { 21 | if (bundle == null) { 22 | return null; 23 | } 24 | return new SessionClosedEvent(bundle); 25 | } 26 | } -------------------------------------------------------------------------------- /src/main/java/ru/evotor/framework/core/action/event/session/SessionEvent.java: -------------------------------------------------------------------------------- 1 | package ru.evotor.framework.core.action.event.session; 2 | 3 | import android.os.Bundle; 4 | 5 | import androidx.annotation.NonNull; 6 | import ru.evotor.IBundlable; 7 | 8 | public abstract class SessionEvent implements IBundlable { 9 | 10 | protected SessionEvent() { 11 | 12 | } 13 | 14 | protected SessionEvent(@NonNull Bundle extras) { 15 | } 16 | 17 | @NonNull 18 | @Override 19 | public Bundle toBundle() { 20 | return new Bundle(); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/ru/evotor/framework/core/action/event/users/UserChangedEvent.java: -------------------------------------------------------------------------------- 1 | package ru.evotor.framework.core.action.event.users; 2 | 3 | import android.os.Bundle; 4 | 5 | import androidx.annotation.NonNull; 6 | import androidx.annotation.Nullable; 7 | 8 | public class UserChangedEvent extends UserEvent { 9 | public static final String BROADCAST_ACTION_USER_CHANGED = "evotor.intent.event.user.CHANGED"; 10 | 11 | public UserChangedEvent() { 12 | super(); 13 | } 14 | 15 | private UserChangedEvent(@NonNull Bundle extra) { 16 | super(extra); 17 | } 18 | 19 | @Nullable 20 | public static UserChangedEvent create(@Nullable Bundle bundle) { 21 | if (bundle == null) { 22 | return null; 23 | } 24 | return new UserChangedEvent(bundle); 25 | } 26 | } -------------------------------------------------------------------------------- /src/main/java/ru/evotor/framework/core/action/event/users/UserEvent.java: -------------------------------------------------------------------------------- 1 | package ru.evotor.framework.core.action.event.users; 2 | 3 | import android.os.Bundle; 4 | 5 | import androidx.annotation.NonNull; 6 | import ru.evotor.IBundlable; 7 | 8 | public abstract class UserEvent implements IBundlable { 9 | 10 | protected UserEvent() { 11 | 12 | } 13 | 14 | protected UserEvent(@NonNull Bundle extras) { 15 | } 16 | 17 | @NonNull 18 | @Override 19 | public Bundle toBundle() { 20 | return new Bundle(); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /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 | } -------------------------------------------------------------------------------- /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 | 9 | fun read(bundle: Bundle?): Principal? = 10 | bundle?.let { 11 | Principal( 12 | uuid = CounterpartyMapper.readUuid(it), 13 | counterpartyType = CounterpartyMapper.readCounterpartyType(it), 14 | fullName = CounterpartyMapper.readFullName(it), 15 | shortName = CounterpartyMapper.readShortName(it) ?: "", 16 | inn = CounterpartyMapper.readInn(it) ?: return null, 17 | kpp = CounterpartyMapper.readKpp(it), 18 | phones = CounterpartyMapper.readPhones(it) ?: return null, 19 | addresses = CounterpartyMapper.readAddresses(it) 20 | ) 21 | } 22 | 23 | } -------------------------------------------------------------------------------- /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 | 9 | private const val KEY_TYPE = "TYPE" 10 | 11 | fun read(bundle: Bundle?): Subagent? = 12 | bundle?.let { 13 | Subagent( 14 | uuid = CounterpartyMapper.readUuid(it), 15 | type = Subagent.Type.values()[it.getInt(KEY_TYPE)], 16 | counterpartyType = CounterpartyMapper.readCounterpartyType(it), 17 | fullName = CounterpartyMapper.readFullName(it), 18 | shortName = CounterpartyMapper.readShortName(it), 19 | inn = CounterpartyMapper.readInn(it), 20 | kpp = CounterpartyMapper.readKpp(it), 21 | phones = CounterpartyMapper.readPhones(it), 22 | addresses = CounterpartyMapper.readAddresses(it) 23 | ) 24 | } 25 | 26 | fun write(subagent: Subagent, bundle: Bundle) = bundle.apply { 27 | this.putInt(KEY_TYPE, subagent.type.ordinal) 28 | } 29 | 30 | } -------------------------------------------------------------------------------- /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 | 9 | fun read(bundle: Bundle?): TransactionOperator? = 10 | bundle?.let { 11 | TransactionOperator( 12 | uuid = CounterpartyMapper.readUuid(it), 13 | counterpartyType = CounterpartyMapper.readCounterpartyType(it), 14 | fullName = CounterpartyMapper.readFullName(it), 15 | shortName = CounterpartyMapper.readShortName(it), 16 | inn = CounterpartyMapper.readInn(it), 17 | kpp = CounterpartyMapper.readKpp(it), 18 | phones = CounterpartyMapper.readPhones(it), 19 | addresses = CounterpartyMapper.readAddresses(it) 20 | ) 21 | } 22 | 23 | fun convertToNull(transactionOperator: TransactionOperator): TransactionOperator? = 24 | CounterpartyMapper.convertToNull(transactionOperator) 25 | 26 | } -------------------------------------------------------------------------------- /src/main/java/ru/evotor/framework/device/cash_drawer/event/CashDrawerEvent.kt: -------------------------------------------------------------------------------- 1 | package ru.evotor.framework.device.cash_drawer.event 2 | 3 | import android.os.Bundle 4 | 5 | import ru.evotor.IBundlable 6 | 7 | abstract class CashDrawerEvent internal constructor(val cashDrawerId: Int) : IBundlable { 8 | 9 | override fun toBundle(): Bundle { 10 | val result = Bundle() 11 | result.putInt(KEY_CASH_DRAWER_ID, cashDrawerId) 12 | return result 13 | } 14 | 15 | companion object { 16 | 17 | private const val KEY_CASH_DRAWER_ID = "cashDrawerId" 18 | 19 | internal fun getCashDrawerId(bundle: Bundle) = bundle.getInt(KEY_CASH_DRAWER_ID, -1) 20 | 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/ru/evotor/framework/device/cash_drawer/event/CashDrawerOpenedEvent.kt: -------------------------------------------------------------------------------- 1 | package ru.evotor.framework.device.cash_drawer.event 2 | 3 | import android.os.Bundle 4 | 5 | /** 6 | * Событие открытия денежного ящика. 7 | * 8 | * Происходит при открытии денежного ящика, подключённого к смарт-терминалу. 9 | * 10 | * Обрабатывать это событие можно с помощью широковещательного приёмника событий денежного ящика: 11 | * [ru.evotor.framework.device.cash_drawer.event.handler.receiver.CashDrawerBroadcastReceiver] 12 | * 13 | * @param cashDrawerId идентификатор денежного ящика (по умолчанию -1) 14 | */ 15 | class CashDrawerOpenedEvent(cashDrawerId: Int) : CashDrawerEvent(cashDrawerId) { 16 | companion object { 17 | fun from(bundle: Bundle?): CashDrawerOpenedEvent? = bundle?.let { 18 | CashDrawerOpenedEvent(CashDrawerEvent.getCashDrawerId(it)) 19 | } 20 | } 21 | } -------------------------------------------------------------------------------- /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 | */ 18 | @RequiresIntentAction(ACTION_CASH_DRAWER_OPENED) 19 | protected abstract fun handleCashDrawerOpenedEvent(context: Context, event: CashDrawerOpenedEvent) 20 | 21 | final override fun onEvent(context: Context, action: String, bundle: Bundle) { 22 | when (action) { 23 | ACTION_CASH_DRAWER_OPENED -> handleCashDrawerOpenedEvent(context, CashDrawerOpenedEvent.from(bundle) 24 | ?: return) 25 | } 26 | } 27 | 28 | companion object { 29 | const val ACTION_CASH_DRAWER_OPENED = "evotor.intent.action.cashDrawer.OPEN" 30 | } 31 | 32 | } -------------------------------------------------------------------------------- /src/main/java/ru/evotor/framework/device/display/Displays.kt: -------------------------------------------------------------------------------- 1 | package ru.evotor.framework.device.display 2 | 3 | enum class Displays { 4 | CASHIER, 5 | CUSTOMER 6 | } 7 | -------------------------------------------------------------------------------- /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 | 19 | override fun toBundle(): Bundle { 20 | val result = Bundle() 21 | result.putString(KEY_BARCODE, barcode) 22 | return result 23 | } 24 | 25 | companion object { 26 | 27 | private const val KEY_BARCODE = "ScannedCode" 28 | 29 | fun from(bundle: Bundle?): BarcodeReceivedEvent? = bundle?.let { 30 | BarcodeReceivedEvent(it.getString(KEY_BARCODE) ?: return null) 31 | } 32 | 33 | } 34 | 35 | } -------------------------------------------------------------------------------- /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 | 11 | override fun toBundle() = Bundle().apply { 12 | putString(KEY_BARCODE, barcode) 13 | } 14 | 15 | companion object { 16 | private const val KEY_BARCODE = "BARCODE" 17 | 18 | @JvmStatic 19 | fun from(bundle: Bundle?) = bundle?.let { 20 | Result(it.getString(KEY_BARCODE) ?: return@let null) 21 | } 22 | } 23 | } 24 | 25 | companion object { 26 | 27 | @JvmStatic 28 | fun from(bundle: Bundle?) = bundle?.let { 29 | BarcodeScanRequestedEvent() 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/ru/evotor/framework/device/scanner/event/handler/receiver/ScannerBroadcastReceiver.kt: -------------------------------------------------------------------------------- 1 | package ru.evotor.framework.device.scanner.event.handler.receiver 2 | 3 | import android.annotation.SuppressLint 4 | import android.content.Context 5 | import android.os.Bundle 6 | import androidx.annotation.RequiresPermission 7 | import ru.evotor.framework.core.BroadcastEventReceiver 8 | import ru.evotor.framework.core.RequiresIntentAction 9 | import ru.evotor.framework.device.scanner.event.BarcodeReceivedEvent 10 | 11 | /** 12 | * Широковещательный приёмник событий сканера штрихкодов. 13 | * @see Использование широковещательного приёмника 14 | */ 15 | abstract class ScannerBroadcastReceiver : BroadcastEventReceiver() { 16 | 17 | /** 18 | * Обработчик событий получения штрихкода. 19 | */ 20 | @RequiresPermission(RECEIVER_PERMISSION) 21 | @RequiresIntentAction(ACTION_BARCODE_RECEIVED) 22 | protected abstract fun handleBarcodeReceivedEvent(context: Context, event: BarcodeReceivedEvent) 23 | 24 | @SuppressLint("MissingPermission") 25 | final override fun onEvent(context: Context, action: String, bundle: Bundle) { 26 | when (action) { 27 | ACTION_BARCODE_RECEIVED -> handleBarcodeReceivedEvent(context, BarcodeReceivedEvent.from(bundle) 28 | ?: return) 29 | } 30 | } 31 | 32 | companion object { 33 | 34 | const val ACTION_BARCODE_RECEIVED = "ru.evotor.devices.ScannedCode" 35 | 36 | const val SENDER_PERMISSION = "ru.evotor.devices.SCANNER_SENDER" 37 | 38 | const val RECEIVER_PERMISSION = "ru.evotor.devices.SCANNER_RECEIVER" 39 | 40 | } 41 | 42 | } -------------------------------------------------------------------------------- /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 | 10 | @RequiresIntentAction(ACTION_BARCODE_SCAN_REQUEST) 11 | abstract fun handleBarcodeScanRequestedEvent(event: BarcodeScanRequestedEvent): BarcodeScanRequestedEvent.Result? 12 | 13 | override fun onEvent(action: String, bundle: Bundle) = when (action) { 14 | ACTION_BARCODE_SCAN_REQUEST -> BarcodeScanRequestedEvent.from(bundle)?.let { handleBarcodeScanRequestedEvent(it) } 15 | else -> null 16 | } 17 | 18 | companion object { 19 | 20 | const val ACTION_BARCODE_SCAN_REQUEST = "evotor.intent.action.BARCODE_SCAN_REQUEST" 21 | } 22 | } -------------------------------------------------------------------------------- /src/main/java/ru/evotor/framework/inventory/AlcoCodeTable.kt: -------------------------------------------------------------------------------- 1 | package ru.evotor.framework.inventory 2 | 3 | import android.net.Uri 4 | 5 | internal object AlcoCodeTable { 6 | @JvmField val URI = Uri.withAppendedPath(ru.evotor.framework.inventory.InventoryApi.BASE_URI, "AlcoCode") 7 | const val COLUMN_ALCO_CODE = "ALCO_CODE" 8 | const val COLUMN_COMMODITY_UUID = "COMMODITY_UUID" 9 | } -------------------------------------------------------------------------------- /src/main/java/ru/evotor/framework/inventory/BarcodeTable.kt: -------------------------------------------------------------------------------- 1 | package ru.evotor.framework.inventory 2 | 3 | import android.net.Uri 4 | 5 | object BarcodeTable { 6 | @JvmField val URI = Uri.withAppendedPath(ru.evotor.framework.inventory.InventoryApi.BASE_URI, "Barcode") 7 | const val ROW_BARCODE = "BARCODE" 8 | } 9 | -------------------------------------------------------------------------------- /src/main/java/ru/evotor/framework/inventory/ProductExtra.kt: -------------------------------------------------------------------------------- 1 | package ru.evotor.framework.inventory 2 | 3 | /** 4 | * Created by a.kuznetsov on 26/03/2017. 5 | */ 6 | data class ProductExtra( 7 | val uuid: String, 8 | val name: String?, 9 | val commodityUUID: String, 10 | val fieldUUID: String, 11 | val fieldValue: Any?, 12 | val data: String? 13 | ) -------------------------------------------------------------------------------- /src/main/java/ru/evotor/framework/inventory/ProductExtraTable.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 | 9 | object ProductExtraTable { 10 | @JvmField val URI = Uri.withAppendedPath(InventoryApi.BASE_URI, "CommodityExtra") 11 | 12 | const val ROW_UUID = "UUID" 13 | const val ROW_NAME = "NAME" 14 | const val ROW_PRODUCT_UUID = "COMMODITY_UUID" 15 | const val ROW_FIELD_UUID = "FIELD_UUID" 16 | const val ROW_FIELD_VALUE = "FIELD_VALUE" 17 | const val ROW_DATA = "DATA" 18 | } -------------------------------------------------------------------------------- /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 | const val ROW_UUID = "UUID" 12 | const val ROW_CODE = "CODE" 13 | const val ROW_TYPE = "TYPE" 14 | const val ROW_PARENT_UUID = "PARENT_UUID" 15 | const val ROW_IS_GROUP = "IS_GROUP" 16 | const val ROW_NAME = "NAME" 17 | const val ROW_DESCRIPTION = "DESCRIPTION" 18 | const val ROW_PRICE_OUT = "PRICE_OUT" 19 | const val ROW_COST_PRICE = "COST_PRICE" 20 | const val ROW_QUANTITY = "QUANTITY" 21 | const val ROW_MEASURE_NAME = "MEASURE_NAME" 22 | const val ROW_MEASURE_PRECISION = "MEASURE_PRECISION" 23 | const val ROW_MEASURE_CODE = "MEASURE_CODE" 24 | const val ROW_ALCOHOL_BY_VOLUME = "ALCOHOL_BY_VOLUME" 25 | const val ROW_ALCOHOL_PRODUCT_KIND_CODE = "ALCOHOL_PRODUCT_KIND_CODE" 26 | const val ROW_TARE_VOLUME = "TARE_VOLUME" 27 | const val ROW_TAX_NUMBER = "TAX_NUMBER" 28 | const val ROW_CLASSIFICATION_CODE = "CLASSIFICATION_CODE" 29 | const val ROW_ALLOW_PARTIAL_REALIZATION = "ALLOW_PARTIAL_REALIZATION" 30 | const val ROW_IS_EXCISABLE = "IS_EXCISABLE" 31 | const val ROW_IS_AGE_LIMITED = "IS_AGE_LIMITED" 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/ru/evotor/framework/inventory/event/ProductCardOpenedEvent.kt: -------------------------------------------------------------------------------- 1 | package ru.evotor.framework.inventory.event 2 | 3 | import android.os.Bundle 4 | 5 | /** 6 | * Событие открытия карточки товара. 7 | * 8 | * Происходит при открытии карточки товара в интерфейсе приложения "Товары". 9 | * 10 | * Обрабатывать это событие можно с помощью широковещательного приёмника товароучётных событий: 11 | * [ru.evotor.framework.inventory.event.handler.receiver.InventoryBroadcastReceiver] 12 | * 13 | * @param productUuid uuid товара 14 | */ 15 | class ProductCardOpenedEvent(productUuid: String) : ProductEvent(productUuid) { 16 | companion object { 17 | fun from(bundle: Bundle?): ProductCardOpenedEvent? = bundle?.let { 18 | ProductCardOpenedEvent(ProductEvent.getProductUuid(it) ?: return null) 19 | } 20 | } 21 | } -------------------------------------------------------------------------------- /src/main/java/ru/evotor/framework/inventory/event/ProductEvent.kt: -------------------------------------------------------------------------------- 1 | package ru.evotor.framework.inventory.event 2 | 3 | import android.os.Bundle 4 | 5 | import ru.evotor.IBundlable 6 | 7 | abstract class ProductEvent internal constructor(val productUuid: String?) : IBundlable { 8 | 9 | override fun toBundle(): Bundle { 10 | val result = Bundle() 11 | result.putString(KEY_PRODUCT_UUID, productUuid) 12 | return result 13 | } 14 | 15 | companion object { 16 | 17 | private const val KEY_PRODUCT_UUID = "productUuid" 18 | 19 | internal fun getProductUuid(bundle: Bundle): String? = bundle.getString(KEY_PRODUCT_UUID) 20 | 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /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 | */ 18 | @RequiresIntentAction(ACTION_PRODUCT_CARD_OPENED) 19 | protected open fun handleProductCardOpenedEvent(context: Context, event: ProductCardOpenedEvent) = Unit 20 | 21 | final override fun onEvent(context: Context, action: String, bundle: Bundle) { 22 | when (action) { 23 | ACTION_PRODUCT_CARD_OPENED -> handleProductCardOpenedEvent(context, ProductCardOpenedEvent.from(bundle) 24 | ?: return) 25 | } 26 | } 27 | 28 | companion object { 29 | const val ACTION_PRODUCT_CARD_OPENED = "evotor.intent.action.inventory.CARD_OPEN" 30 | } 31 | 32 | } -------------------------------------------------------------------------------- /src/main/java/ru/evotor/framework/inventory/field/DictionaryField.kt: -------------------------------------------------------------------------------- 1 | package ru.evotor.framework.inventory.field 2 | 3 | class DictionaryField( 4 | name: String?, 5 | fieldUUID: String, 6 | title: String?, 7 | val multiple: Boolean, 8 | val items: Array 9 | ) : Field( 10 | name, 11 | fieldUUID, 12 | title, 13 | Type.DICTIONARY_FIELD 14 | ) { 15 | class Item( 16 | val title: String, 17 | val value: Any, 18 | val data: Any? 19 | ) 20 | } -------------------------------------------------------------------------------- /src/main/java/ru/evotor/framework/inventory/field/Field.kt: -------------------------------------------------------------------------------- 1 | package ru.evotor.framework.inventory.field 2 | 3 | abstract class Field( 4 | val name: String?, 5 | val fieldUUID: String, 6 | val title: String?, 7 | val type: Type 8 | ) { 9 | enum class Type { 10 | TEXT_FIELD, 11 | DICTIONARY_FIELD 12 | } 13 | 14 | override fun equals(other: Any?): Boolean { 15 | if (this === other) return true 16 | if (other?.javaClass != javaClass) return false 17 | 18 | other as Field 19 | 20 | if (fieldUUID != other.fieldUUID) return false 21 | 22 | return true 23 | } 24 | 25 | override fun hashCode(): Int { 26 | return fieldUUID.hashCode() 27 | } 28 | 29 | } -------------------------------------------------------------------------------- /src/main/java/ru/evotor/framework/inventory/field/FieldTable.kt: -------------------------------------------------------------------------------- 1 | package ru.evotor.framework.inventory.field 2 | 3 | import android.net.Uri 4 | import ru.evotor.framework.inventory.InventoryApi 5 | 6 | /** 7 | * Created by a.kuznetsov on 26/03/2017. 8 | */ 9 | 10 | object FieldTable { 11 | val URI = Uri.withAppendedPath(InventoryApi.BASE_URI, "Field") 12 | 13 | const val ROW_NAME = "NAME" 14 | const val ROW_FIELD_UUID = "FIELD_UUID" 15 | const val ROW_TITLE = "TITLE" 16 | const val ROW_TYPE = "TYPE" 17 | const val ROW_SPECIFIC_DATA = "SPECIFIC_DATA" 18 | 19 | const val TYPE_TEXT_FIELD = 1 20 | const val TYPE_DICTIONARY = 2 21 | } -------------------------------------------------------------------------------- /src/main/java/ru/evotor/framework/inventory/field/TextField.kt: -------------------------------------------------------------------------------- 1 | package ru.evotor.framework.inventory.field 2 | 3 | class TextField( 4 | name: String?, 5 | fieldUUID: String, 6 | title: String?, 7 | val data: String? 8 | ) : Field( 9 | name, 10 | fieldUUID, 11 | title, 12 | Type.TEXT_FIELD 13 | ) -------------------------------------------------------------------------------- /src/main/java/ru/evotor/framework/kkt/FfdVersion.kt: -------------------------------------------------------------------------------- 1 | package ru.evotor.framework.kkt 2 | 3 | /** 4 | * Версия ФФД 5 | */ 6 | enum class FfdVersion { 7 | V_1_0_0, // deprecated 8 | V_1_0_5, 9 | V_1_1_0, // unrealised by fiscal department 10 | V_1_2_0 11 | } -------------------------------------------------------------------------------- /src/main/java/ru/evotor/framework/kkt/FiscalRequisite.kt: -------------------------------------------------------------------------------- 1 | package ru.evotor.framework.kkt 2 | 3 | /** 4 | * Означает, что значение анотированной переменной было записано (если она была получена при 5 | * соответствующем обращении к БД СТ), либо будет записано (при передаче её в соответствующий метод 6 | * АПИ) в кассу в качестве одного или нескольких (в некоторых случаях при повторения аннотации) 7 | * фискальных реквизитов. 8 | */ 9 | @Repeatable 10 | @Retention(AnnotationRetention.SOURCE) 11 | internal annotation class FiscalRequisite( 12 | /** 13 | * Фискальный тег 14 | */ 15 | val tag: Int, 16 | 17 | /** 18 | * Флаги 19 | */ 20 | val flags: Int = NO_FLAGS 21 | ) { 22 | companion object { 23 | private const val NO_FLAGS = 0 24 | 25 | /** 26 | * Означает, что фискальный реквизит может иметь несколько значений. 27 | */ 28 | internal const val FLAG_MULTIPLE_VALUES = 2 29 | } 30 | } -------------------------------------------------------------------------------- /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 | 13 | override fun onQueryComplete(token: Int, cookie: Any?, cursor: Cursor?) { 14 | cursor?.use { 15 | it.moveToFirst() 16 | 17 | val serialNumber = it.optList(KktContract.COLUMN_SERIAL_NUMBER) 18 | ?: throw IntegrationLibraryMappingException(KktContract.COLUMN_SERIAL_NUMBER) 19 | 20 | val regNumber = it.optList(KktContract.COLUMN_REGISTER_NUMBER) 21 | ?: throw IntegrationLibraryMappingException(KktContract.COLUMN_REGISTER_NUMBER) 22 | 23 | callback(serialNumber[0], regNumber[0]) 24 | } 25 | } 26 | 27 | companion object { 28 | internal const val KKT_INFO_TOKEN = 0 29 | } 30 | } -------------------------------------------------------------------------------- /src/main/java/ru/evotor/framework/kkt/api/DocumentRegistrationCallback.kt: -------------------------------------------------------------------------------- 1 | package ru.evotor.framework.kkt.api 2 | 3 | import java.util.* 4 | 5 | interface DocumentRegistrationCallback { 6 | fun onSuccess(documentUuid: UUID?) 7 | fun onError(error: DocumentRegistrationException) 8 | } -------------------------------------------------------------------------------- /src/main/java/ru/evotor/framework/kkt/event/CashInsertedEvent.kt: -------------------------------------------------------------------------------- 1 | package ru.evotor.framework.kkt.event 2 | 3 | import android.os.Bundle 4 | import java.math.BigDecimal 5 | 6 | /** 7 | * Событие внесения наличности в кассу. 8 | * 9 | * Происходит при снятии кассового отчёта о внесении наличности в кассу. 10 | * 11 | * Обрабатывать это событие можно с помощью широковещательного приёмника событий кассы: 12 | * [ru.evotor.framework.kkt.event.handler.receiver.KktBroadcastReceiver] 13 | * 14 | * @param documentUuid uuid снятого отчета 15 | * @param total сумма внесённой наличности 16 | */ 17 | class CashInsertedEvent(documentUuid: String, total: BigDecimal) : CashOperationEvent(documentUuid, total) { 18 | companion object { 19 | fun from(bundle: Bundle?): CashInsertedEvent? = bundle?.let { 20 | CashInsertedEvent( 21 | getDocumentUuid(it) ?: return null, 22 | getTotal(it) ?: return null 23 | ) 24 | } 25 | } 26 | } -------------------------------------------------------------------------------- /src/main/java/ru/evotor/framework/kkt/event/CashOperationEvent.kt: -------------------------------------------------------------------------------- 1 | package ru.evotor.framework.kkt.event 2 | 3 | import android.os.Bundle 4 | 5 | import ru.evotor.IBundlable 6 | import ru.evotor.framework.getMoney 7 | import java.math.BigDecimal 8 | 9 | abstract class CashOperationEvent internal constructor(val documentUuid: String, val total: BigDecimal) : IBundlable { 10 | 11 | override fun toBundle(): Bundle { 12 | val result = Bundle() 13 | result.putString(KEY_DOCUMENT_UUID, documentUuid) 14 | result.putString(KEY_TOTAL, total.toPlainString()) 15 | return result 16 | } 17 | 18 | companion object { 19 | 20 | private const val KEY_DOCUMENT_UUID = "documentUuid" 21 | 22 | private const val KEY_TOTAL = "total" 23 | 24 | internal fun getDocumentUuid(bundle: Bundle): String? = bundle.getString(KEY_DOCUMENT_UUID) 25 | 26 | internal fun getTotal(bundle: Bundle): BigDecimal? = bundle.getMoney(KEY_TOTAL) 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/ru/evotor/framework/kkt/event/CashWithdrawnEvent.kt: -------------------------------------------------------------------------------- 1 | package ru.evotor.framework.kkt.event 2 | 3 | import android.os.Bundle 4 | import java.math.BigDecimal 5 | 6 | /** 7 | * Событие изъятия наличности из кассы. 8 | * 9 | * Происходит при снятии кассового отчёта об изъятии наличности из кассы. 10 | * 11 | * Обрабатывать это событие можно с помощью широковещательного приёмника событий кассы: 12 | * [ru.evotor.framework.kkt.event.handler.receiver.KktBroadcastReceiver] 13 | * 14 | * @param documentUuid uuid снятого отчета 15 | * @param total сумма изъятой наличности 16 | */ 17 | class CashWithdrawnEvent(documentUuid: String, total: BigDecimal) : CashOperationEvent(documentUuid, total) { 18 | companion object { 19 | fun from(bundle: Bundle?): CashWithdrawnEvent? = bundle?.let { 20 | CashWithdrawnEvent( 21 | getDocumentUuid(it) ?: return null, 22 | getTotal(it) ?: return null 23 | ) 24 | } 25 | } 26 | } -------------------------------------------------------------------------------- /src/main/java/ru/evotor/framework/kkt/event/handler/service/KktBacksideIntegrationService.kt: -------------------------------------------------------------------------------- 1 | package ru.evotor.framework.kkt.event.handler.service 2 | 3 | class KktBacksideIntegrationService { 4 | companion object { 5 | const val ACTION_CORRECTION_RECEIPT_REGISTRATION_REQUESTED = "evotor.intent.action.CORRECTION_RECEIPT_REGISTRATION_REQUESTED" 6 | } 7 | } -------------------------------------------------------------------------------- /src/main/java/ru/evotor/framework/mapper/DocumentMapper.kt: -------------------------------------------------------------------------------- 1 | package ru.evotor.framework.mapper 2 | 3 | import android.os.Bundle 4 | import ru.evotor.framework.Document 5 | import ru.evotor.framework.optSerializable 6 | import java.util.* 7 | 8 | internal object DocumentMapper { 9 | private const val KEY_UUID = "UUID" 10 | 11 | fun readUuid(bundle: Bundle?): UUID? = bundle?.optSerializable(KEY_UUID) 12 | 13 | fun write(document: Document) = Bundle().apply { 14 | } 15 | } -------------------------------------------------------------------------------- /src/main/java/ru/evotor/framework/payment/PaymentSystemTable.kt: -------------------------------------------------------------------------------- 1 | package ru.evotor.framework.payment 2 | 3 | import android.net.Uri 4 | 5 | object PaymentSystemTable { 6 | @JvmField val URI = Uri.withAppendedPath(PaymentSystemApi.BASE_URI, "paymentSystems") 7 | const val COLUMN_PAYMENT_SYSTEM_ID = "PAYMENT_SYSTEM_ID" 8 | const val COLUMN_PAYMENT_SYSTEM_USER_DESCRIPTION = "PAYMENT_SYSTEM_USER_DESCRIPTION" 9 | const val COLUMN_PAYMENT_TYPE = "PAYMENT_TYPE" 10 | const val COLUMN_ACCOUNT_ID = "ACCOUNT_ID" 11 | const val COLUMN_ACCOUNT_USER_DESCRIPTION = "ACCOUNT_USER_DESCRIPTION" 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/ru/evotor/framework/payment/PaymentType.java: -------------------------------------------------------------------------------- 1 | package ru.evotor.framework.payment; 2 | 3 | /** 4 | * Тип оплаты (значение указывается в чеке как тип оплаты). 5 | */ 6 | public enum PaymentType { 7 | /** 8 | * Неизвестно. По-умолчанию 9 | */ 10 | UNKNOWN, 11 | 12 | /** 13 | * Наличными средствами 14 | */ 15 | CASH, 16 | 17 | /** 18 | * Безналичными средствами 19 | */ 20 | ELECTRON, 21 | 22 | /** 23 | * Предоплатой (зачетом аванса) 24 | */ 25 | ADVANCE, 26 | 27 | /** 28 | * Постоплатой (в кредит) 29 | */ 30 | CREDIT, 31 | 32 | /** 33 | * Встречным предоставлением 34 | */ 35 | COUNTEROFFER 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/ru/evotor/framework/provider/DocumentContract.kt: -------------------------------------------------------------------------------- 1 | package ru.evotor.framework.provider 2 | 3 | import android.net.Uri 4 | 5 | internal object DocumentContract { 6 | private const val AUTHORITY = "ru.evotor.framework.document" 7 | 8 | val URI: Uri = Uri.parse("content://$AUTHORITY") 9 | 10 | const val COLUMN_UUID = "UUID" 11 | } -------------------------------------------------------------------------------- /src/main/java/ru/evotor/framework/provider/FiscalDocumentContract.kt: -------------------------------------------------------------------------------- 1 | package ru.evotor.framework.provider 2 | 3 | import android.net.Uri 4 | 5 | internal object FiscalDocumentContract { 6 | private const val AUTHORITY = "ru.evotor.framework.document.fiscal" 7 | 8 | val URI: Uri = Uri.parse("content://$AUTHORITY") 9 | 10 | const val COLUMN_DOCUMENT_NUMBER = "DOCUMENT_NUMBER" 11 | const val COLUMN_CREATION_DATE = "CREATION_DATE" 12 | const val COLUMN_KKT_REGISTRATION_NUMBER = "KKT_REGISTRATION_NUMBER" 13 | const val COLUMN_SESSION_NUMBER = "SESSION_NUMBER" 14 | const val COLUMN_FISCAL_STORAGE_NUMBER = "FISCAL_STORAGE_NUMBER" 15 | const val COLUMN_FISCAL_IDENTIFIER = "FISCAL_IDENTIFIER" 16 | } -------------------------------------------------------------------------------- /src/main/java/ru/evotor/framework/receipt/MedicineAttributeSubTable.kt: -------------------------------------------------------------------------------- 1 | package ru.evotor.framework.receipt 2 | 3 | object MedicineAttributeSubTable { 4 | const val COLUMN_SUBJECT_ID = "SUBJECT_ID" 5 | const val COLUMN_PREFERENTIAL_MEDICINE_TYPE = "PREFERENTIAL_MEDICINE_TYPE" 6 | const val COLUMN_MEDICINE_DOCUMENT_NUMBER = "MEDICINE_DOCUMENT_NUMBER" 7 | const val COLUMN_MEDICINE_DOCUMENT_DATE = "MEDICINE_DOCUMENT_DATE" 8 | const val COLUMN_MEDICINE_SERIAL_NUMBER = "MEDICINE_SERIAL_NUMBER" 9 | } -------------------------------------------------------------------------------- /src/main/java/ru/evotor/framework/receipt/NonFiscalReceipt.kt: -------------------------------------------------------------------------------- 1 | package ru.evotor.framework.receipt 2 | 3 | import ru.evotor.framework.Document 4 | import ru.evotor.framework.FutureFeature 5 | import java.util.* 6 | 7 | @FutureFeature("Нефискальный чек (квитанция)") 8 | private data class NonFiscalReceipt(override val uuid: UUID) : Document() -------------------------------------------------------------------------------- /src/main/java/ru/evotor/framework/receipt/PaymentTable.kt: -------------------------------------------------------------------------------- 1 | package ru.evotor.framework.receipt 2 | 3 | object PaymentTable { 4 | const val COLUMN_UUID = "PAYMENT_UUID" 5 | const val COLUMN_VALUE = "PAYMENT_VALUE" 6 | const val COLUMN_PURPOSED_IDENTIFIER = "PAYMENT_PURPOSED_IDENTIFIER" 7 | const val COLUMN_ACCOUNT_ID = "PAYMENT_ACCOUNT_ID" 8 | const val COLUMN_ACCOUNT_USER_DESCRIPTION = "PAYMENT_ACCOUNT_USER_DESCRIPTION" 9 | const val COLUMN_VALUE_BY_PRINT_GROUP = "PAYMENT_VALUE_BY_PRINT_GROUP" 10 | const val COLUMN_CHANGE_BY_PRINT_GROUP = "PAYMENT_CHANGE_BY_PRINT_GROUP" 11 | const val COLUMN_IDENTIFIER = "IDENTIFIER" 12 | const val COLUMN_CASHLESS_INFO_UUID = "CASHLESS_INFO_UUID" 13 | const val COLUMN_CASHLESS_INFO_DESCRIPTION = "CASHLESS_INFO_DESCRIPTION" 14 | const val COLUMN_CASHLESS_INFO_METHOD = "CASHLESS_INFO_METHOD" 15 | } 16 | -------------------------------------------------------------------------------- /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 | } 18 | -------------------------------------------------------------------------------- /src/main/java/ru/evotor/framework/receipt/ReceiptDiscountTable.kt: -------------------------------------------------------------------------------- 1 | package ru.evotor.framework.receipt 2 | 3 | object ReceiptDiscountTable { 4 | const val POSITION_DISCOUNT_UUID_COLUMN_NAME = "POSITION_UUID" 5 | const val DISCOUNT_COLUMN_NAME = "DISCOUNT" 6 | } -------------------------------------------------------------------------------- /src/main/java/ru/evotor/framework/receipt/ReceiptHeaderTable.kt: -------------------------------------------------------------------------------- 1 | package ru.evotor.framework.receipt 2 | 3 | object ReceiptHeaderTable { 4 | const val COLUMN_UUID = "UUID" 5 | const val COLUMN_BASE_RECEIPT_UUID = "BASE_RECEIPT_UUID" 6 | const val COLUMN_NUMBER = "NUMBER" 7 | const val COLUMN_TYPE = "TYPE" 8 | const val COLUMN_DATE = "DATE" 9 | const val COLUMN_CLIENT_EMAIL = "CLIENT_EMAIL" 10 | const val COLUMN_CLIENT_PHONE = "CLIENT_PHONE" 11 | const val COLUMN_EXTRA = "EXTRA" 12 | const val COLUMN_SESSION_NUMBER = "SESSION_NUMBER" 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/ru/evotor/framework/receipt/SettlementType.kt: -------------------------------------------------------------------------------- 1 | package ru.evotor.framework.receipt 2 | 3 | /** 4 | * Тип расчёта 5 | */ 6 | enum class SettlementType { 7 | /** 8 | * Приход 9 | */ 10 | INCOME, 11 | 12 | /** 13 | * Возврат прихода 14 | */ 15 | RETURN_OF_INCOME, 16 | 17 | /** 18 | * Расход 19 | */ 20 | OUTCOME, 21 | 22 | /** 23 | * Возврат расхода 24 | */ 25 | RETURN_OF_OUTCOME, 26 | 27 | /** 28 | * Коррекция прихода 29 | */ 30 | CORRECTION_INCOME, 31 | 32 | /** 33 | * Коррекция расхода 34 | */ 35 | CORRECTION_OUTCOME, 36 | 37 | /** 38 | * Коррекция возврата прихода 39 | */ 40 | CORRECTION_RETURN_INCOME, 41 | 42 | /** 43 | * Коррекция возврата расхода 44 | */ 45 | CORRECTION_RETURN_OUTCOME 46 | } -------------------------------------------------------------------------------- /src/main/java/ru/evotor/framework/receipt/TaxationSystem.java: -------------------------------------------------------------------------------- 1 | package ru.evotor.framework.receipt; 2 | 3 | public enum TaxationSystem { 4 | COMMON, 5 | SIMPLIFIED_INCOME, 6 | SIMPLIFIELD_INCOME_OUTCOME, 7 | SINGLE_IMPUTED_INCOME, 8 | SINGLE_AGRICULTURE, 9 | PATENT 10 | } -------------------------------------------------------------------------------- /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 | 25 | override fun toBundle(): Bundle = VeterinaryAttributeMapper.writeToBundle(this) 26 | 27 | companion object { 28 | /** 29 | * Текущая версия объекта VeterinaryAttribute. 30 | */ 31 | const val VERSION = 1 32 | 33 | @JvmStatic 34 | fun from(bundle: Bundle?): VeterinaryAttribute? = VeterinaryAttributeMapper.readFromBundle(bundle) 35 | } 36 | 37 | /** 38 | * Тип документа, по которому отпускается препарат 39 | */ 40 | enum class VeterinaryDocumentType { 41 | /** 42 | * Рецепт 43 | */ 44 | VPR, 45 | 46 | /** 47 | * Требование 48 | */ 49 | VPT 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/ru/evotor/framework/receipt/correction/CorrectionType.kt: -------------------------------------------------------------------------------- 1 | package ru.evotor.framework.receipt.correction 2 | 3 | enum class CorrectionType { 4 | BY_SELF, 5 | BY_PRESCRIBED 6 | } -------------------------------------------------------------------------------- /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/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 | } -------------------------------------------------------------------------------- /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 | } -------------------------------------------------------------------------------- /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/receipt/event/ReceiptEvent.kt: -------------------------------------------------------------------------------- 1 | package ru.evotor.framework.receipt.event 2 | 3 | import android.os.Bundle 4 | 5 | import ru.evotor.IBundlable 6 | 7 | abstract class ReceiptEvent internal constructor(val receiptUuid: String) : IBundlable { 8 | 9 | override fun toBundle(): Bundle { 10 | val result = Bundle() 11 | result.putString(KEY_RECEIPT_UUID, receiptUuid) 12 | return result 13 | } 14 | 15 | companion object { 16 | 17 | private const val KEY_RECEIPT_UUID = "receiptUuid" 18 | 19 | internal fun getReceiptUuid(bundle: Bundle): String? = 20 | bundle.getString(KEY_RECEIPT_UUID, null) 21 | 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/ru/evotor/framework/receipt/formation/ReceiptDraft.kt: -------------------------------------------------------------------------------- 1 | package ru.evotor.framework.receipt.formation 2 | 3 | import ru.evotor.framework.FutureFeature 4 | 5 | @FutureFeature("Несформированный чек (до момента регистриции в кассе и/или печати)") 6 | private class ReceiptDraft -------------------------------------------------------------------------------- /src/main/java/ru/evotor/framework/receipt/formation/api/move_receipt_to_payment_stage/MoveCurrentReceiptDraftToPaymentStageCallback.kt: -------------------------------------------------------------------------------- 1 | package ru.evotor.framework.receipt.formation.api.move_receipt_to_payment_stage 2 | 3 | interface MoveCurrentReceiptDraftToPaymentStageCallback { 4 | fun onSuccess() 5 | fun onError(error: MoveCurrentReceiptDraftToPaymentStageException) 6 | } 7 | -------------------------------------------------------------------------------- /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/receipt/formation/api/trigger_receipt_discount_event/TriggerReceiptDiscountEventCallback.kt: -------------------------------------------------------------------------------- 1 | package ru.evotor.framework.receipt.formation.api.trigger_receipt_discount_event 2 | 3 | interface TriggerReceiptDiscountEventCallback { 4 | 5 | fun onSuccess() 6 | 7 | fun onError(error: TriggerReceiptDiscountEventException) 8 | } 9 | -------------------------------------------------------------------------------- /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 | } -------------------------------------------------------------------------------- /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 | 17 | override fun toBundle() = Bundle().apply { 18 | putString(KEY_RECEIPT_UUID, receiptUuid) 19 | } 20 | 21 | companion object { 22 | const val KEY_RECEIPT_UUID = "KEY_RECEIPT_UUID" 23 | 24 | @JvmStatic 25 | fun from(bundle: Bundle?) = bundle?.let { 26 | DiscountScreenAdditionalItemsEvent( 27 | receiptUuid = it.getString(KEY_RECEIPT_UUID) 28 | ?: return null 29 | ) 30 | } 31 | } 32 | 33 | } -------------------------------------------------------------------------------- /src/main/java/ru/evotor/framework/receipt/formation/event/handler/service/BuyBacksideIntegrationService.kt: -------------------------------------------------------------------------------- 1 | package ru.evotor.framework.receipt.formation.event.handler.service 2 | 3 | class BuyBacksideIntegrationService { 4 | companion object { 5 | const val ACTION_MOVE_CURRENT_BUY_RECEIPT_DRAFT_TO_PAYMENT_STAGE = "evotor.intent.action.MOVE_CURRENT_BUY_RECEIPT_DRAFT_TO_PAYMENT_STAGE" 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /src/main/java/ru/evotor/framework/receipt/formation/event/handler/service/PaybackBacksideIntegrationService.kt: -------------------------------------------------------------------------------- 1 | package ru.evotor.framework.receipt.formation.event.handler.service 2 | 3 | class PaybackBacksideIntegrationService { 4 | companion object { 5 | const val ACTION_MOVE_CURRENT_PAYBACK_RECEIPT_DRAFT_TO_PAYMENT_STAGE = "evotor.intent.action.MOVE_CURRENT_PAYBACK_RECEIPT_DRAFT_TO_PAYMENT_STAGE" 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /src/main/java/ru/evotor/framework/receipt/formation/event/handler/service/SellBacksideIntegrationService.kt: -------------------------------------------------------------------------------- 1 | package ru.evotor.framework.receipt.formation.event.handler.service 2 | 3 | class SellBacksideIntegrationService { 4 | companion object { 5 | const val ACTION_MOVE_CURRENT_RECEIPT_DRAFT_TO_PAYMENT_STAGE = "evotor.intent.action.MOVE_CURRENT_SELL_RECEIPT_DRAFT_TO_PAYMENT_STAGE" 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /src/main/java/ru/evotor/framework/receipt/formation/event/handler/service/TriggerReceiptDiscountEventIntegrationService.kt: -------------------------------------------------------------------------------- 1 | package ru.evotor.framework.receipt.formation.event.handler.service 2 | 3 | class TriggerReceiptDiscountEventIntegrationService { 4 | 5 | companion object { 6 | const val ACTION_TRIGGER_RECEIPT_DISCOUNT_EVENT = "evotor.intent.action.ACTION_TRIGGER_RECEIPT_DISCOUNT_EVENT" 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /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 | 27 | override fun toBundle(): Bundle = Bundle().apply { 28 | putString(KEY_COUNTRY_ORIGIN_CODE, countryOriginCode) 29 | putString(KEY_CUSTOM_DECLARATION_NUMBER, customsDeclarationNumber) 30 | } 31 | 32 | companion object { 33 | private const val KEY_COUNTRY_ORIGIN_CODE = "COUNTRY_ORIGIN_CODE" 34 | private const val KEY_CUSTOM_DECLARATION_NUMBER = "CUSTOM_DECLARATION_NUMBER" 35 | 36 | @JvmStatic 37 | fun from(bundle: Bundle?): ImportationData? { 38 | return bundle?.let { 39 | val countryOriginCode = it.getString(KEY_COUNTRY_ORIGIN_CODE) ?: return null 40 | val customDeclarationNumber = it.getString(KEY_CUSTOM_DECLARATION_NUMBER) ?: return null 41 | 42 | ImportationData(countryOriginCode, customDeclarationNumber) 43 | } 44 | } 45 | } 46 | 47 | } -------------------------------------------------------------------------------- /src/main/java/ru/evotor/framework/receipt/position/MarksCheckingInfo.kt: -------------------------------------------------------------------------------- 1 | package ru.evotor.framework.receipt.position 2 | 3 | import android.os.Bundle 4 | import ru.evotor.IBundlable 5 | import ru.evotor.framework.optLong 6 | 7 | /** 8 | * Данные об онлайн-проверке марки 9 | */ 10 | data class MarksCheckingInfo( 11 | /** 12 | * Идентификатор онлайн-проверки марки 13 | */ 14 | val checkId: String, 15 | /** 16 | * Время онлайн проверки 17 | */ 18 | val checkTimestamp: Long 19 | ) : IBundlable { 20 | override fun toBundle(): Bundle = Bundle().apply { 21 | putString(KEY_CHECK_ID, checkId) 22 | putLong(KEY_TIMESTAMP, checkTimestamp) 23 | } 24 | 25 | companion object { 26 | 27 | private const val KEY_CHECK_ID = "CheckId" 28 | private const val KEY_TIMESTAMP = "Timestamp" 29 | 30 | @JvmStatic 31 | fun from(bundle: Bundle?): MarksCheckingInfo? = bundle?.let { 32 | val checkId = it.getString(KEY_CHECK_ID) ?: return null 33 | val checkTimestamp = it.optLong(KEY_TIMESTAMP) ?: return null 34 | 35 | MarksCheckingInfo(checkId = checkId, checkTimestamp = checkTimestamp) 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /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 | 19 | override fun toBundle(): Bundle = Bundle().apply { 20 | putString(KEY_QUANTITY_IN_PACKAGE, quantityInPackage.toPlainString()) 21 | } 22 | 23 | companion object { 24 | 25 | private const val KEY_QUANTITY_IN_PACKAGE = "QuantityInPackage" 26 | 27 | @JvmStatic 28 | fun from(bundle: Bundle?): PartialRealization? = bundle?.let { 29 | val quantityInPackage = it.optBigDecimal(KEY_QUANTITY_IN_PACKAGE) ?: BigDecimal.ZERO 30 | 31 | PartialRealization(quantityInPackage = quantityInPackage) 32 | } 33 | } 34 | } -------------------------------------------------------------------------------- /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 | 27 | override fun toBundle(): Bundle = PreferentialMedicineMapper.writeToBundle(this) 28 | 29 | companion object { 30 | 31 | @JvmStatic 32 | fun from(bundle: Bundle?): PreferentialMedicine? = PreferentialMedicineMapper.readFromBundle(bundle) 33 | } 34 | 35 | /** 36 | * Тип льготы 37 | */ 38 | enum class PreferentialMedicineType { 39 | FULL_PREFERENTIAL_MEDICINE, 40 | PARTIAL_PREFERENTIAL_MEDICINE, 41 | NON_PREFERENTIAL_MEDICINE 42 | } 43 | } -------------------------------------------------------------------------------- /src/main/java/ru/evotor/framework/receipt/position/VatRate.kt: -------------------------------------------------------------------------------- 1 | package ru.evotor.framework.receipt.position 2 | 3 | enum class VatRate { 4 | WITHOUT_VAT, 5 | VAT_0, 6 | VAT_10, 7 | VAT_10_110, 8 | VAT_18, 9 | VAT_18_118, 10 | VAT_20, 11 | VAT_20_120, 12 | VAT_5, 13 | VAT_7, 14 | VAT_5_105, 15 | VAT_7_107 16 | } 17 | -------------------------------------------------------------------------------- /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 | 14 | override fun toBundle(): Bundle { 15 | val result = Bundle() 16 | result.putString(KEY_RECEIPT_UUID, receiptUuid) 17 | result.putBundle(KEY_POSITION, PositionMapper.toBundle(position)) 18 | return result 19 | } 20 | 21 | companion object { 22 | 23 | private const val KEY_RECEIPT_UUID = "receiptUuid" 24 | 25 | private const val KEY_POSITION = "position" 26 | 27 | internal fun getReceiptUuid(bundle: Bundle): String? = 28 | bundle.getString(KEY_RECEIPT_UUID, null) 29 | 30 | internal fun getPosition(bundle: Bundle): Position? = 31 | PositionMapper.from(bundle.getBundle(KEY_POSITION)) 32 | 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /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.MarksCheckingInfo 8 | 9 | object MarksCheckingInfoMapper { 10 | internal fun fromCursor(cursor: Cursor): MarksCheckingInfo? { 11 | val checkId = cursor.optString(PositionTable.COLUMN_MARKS_CHECKING_INFO_CHECK_ID) 12 | ?: return null 13 | val checkTimestamp = cursor.optLong(PositionTable.COLUMN_MARKS_CHECKING_INFO_CHECK_TIMESTAMP) 14 | ?: return null 15 | return MarksCheckingInfo( 16 | checkId = checkId, 17 | checkTimestamp = checkTimestamp 18 | ) 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/ru/evotor/framework/receipt/position/mapper/PositionPartialRealizationMapper.kt: -------------------------------------------------------------------------------- 1 | package ru.evotor.framework.receipt.position.mapper 2 | 3 | import android.database.Cursor 4 | import ru.evotor.framework.optQuantity 5 | import ru.evotor.framework.receipt.PositionTable 6 | import ru.evotor.framework.receipt.position.PartialRealization 7 | 8 | internal object PositionPartialRealizationMapper { 9 | 10 | internal fun fromCursor(cursor: Cursor): PartialRealization? { 11 | val quantityInPackage = cursor.optQuantity(PositionTable.COLUMN_PARTIAL_QUANTITY_IN_PACKAGE) 12 | ?: return null 13 | return PartialRealization( 14 | quantityInPackage = quantityInPackage 15 | ) 16 | } 17 | } -------------------------------------------------------------------------------- /src/main/java/ru/evotor/framework/receipt/print_extras/PrintExtraPlace.kt: -------------------------------------------------------------------------------- 1 | package ru.evotor.framework.receipt.print_extras 2 | 3 | /** 4 | * Класс-родитель для указания на место в чеке, куда будет добавлена дополнительная печатная информация 5 | */ 6 | abstract class PrintExtraPlace(val placeType: PrintExtraPlaceType) -------------------------------------------------------------------------------- /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 | 12 | companion object { 13 | val KEY_POSITION_UUID = "positionUuid" 14 | 15 | fun addToBundle(bundle: Bundle, place: PrintExtraPlacePositionAllSubpositionsFooter): Bundle = 16 | bundle.apply { putString(KEY_POSITION_UUID, place.positionUuid) } 17 | 18 | fun fromBundle(bundle: Bundle): PrintExtraPlacePositionAllSubpositionsFooter? = 19 | bundle.getString(KEY_POSITION_UUID)?.let { 20 | PrintExtraPlacePositionAllSubpositionsFooter(it) 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/ru/evotor/framework/receipt/print_extras/PrintExtraPlacePositionFooter.kt: -------------------------------------------------------------------------------- 1 | package ru.evotor.framework.receipt.print_extras 2 | 3 | import android.os.Bundle 4 | 5 | /** 6 | * Печатная информация будет добавлена сразу после позиции в чеке, до списка её модификаторов (подпозиций) 7 | */ 8 | class PrintExtraPlacePositionFooter( 9 | val positionUuid: String? 10 | ) : PrintExtraPlace(PrintExtraPlaceType.POSITION_FOOTER) { 11 | 12 | companion object { 13 | val KEY_POSITION_UUID = "positionUuid" 14 | 15 | fun addToBundle(bundle: Bundle, place: PrintExtraPlacePositionFooter): Bundle = 16 | bundle.apply { putString(KEY_POSITION_UUID, place.positionUuid) } 17 | 18 | fun fromBundle(bundle: Bundle): PrintExtraPlacePositionFooter? = 19 | bundle.getString(KEY_POSITION_UUID)?.let { 20 | PrintExtraPlacePositionFooter(it) 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/ru/evotor/framework/receipt/print_extras/PrintExtraPlacePrintGroupHeader.kt: -------------------------------------------------------------------------------- 1 | package ru.evotor.framework.receipt.print_extras 2 | 3 | import android.os.Bundle 4 | 5 | /** 6 | * Печатная информация будет добавлена в верхней части чека: после текста "Кассовый чек", до имени пользователя 7 | */ 8 | class PrintExtraPlacePrintGroupHeader( 9 | val printGroupId: String? 10 | ) : PrintExtraPlace(PrintExtraPlaceType.PRINT_GROUP_HEADER) { 11 | 12 | companion object { 13 | val KEY_PRINT_GROUP_ID = "printGroupId" 14 | 15 | fun addToBundle(bundle: Bundle, place: PrintExtraPlacePrintGroupHeader): Bundle = 16 | bundle.apply { putString(KEY_PRINT_GROUP_ID, place.printGroupId) } 17 | 18 | fun fromBundle(bundle: Bundle): PrintExtraPlacePrintGroupHeader? = 19 | PrintExtraPlacePrintGroupHeader(bundle.getString(KEY_PRINT_GROUP_ID)) 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/ru/evotor/framework/receipt/print_extras/PrintExtraPlacePrintGroupSummary.kt: -------------------------------------------------------------------------------- 1 | package ru.evotor.framework.receipt.print_extras 2 | 3 | import android.os.Bundle 4 | 5 | /** 6 | * Печатная информация будет добавлена в нижней части чека, после итога и списка отплат, до поля "всего оплачено" 7 | */ 8 | class PrintExtraPlacePrintGroupSummary( 9 | val printGroupId: String? 10 | ) : PrintExtraPlace(PrintExtraPlaceType.PRINT_GROUP_SUMMARY) { 11 | 12 | companion object { 13 | val KEY_PRINT_GROUP_ID = "printGroupId" 14 | 15 | fun addToBundle(bundle: Bundle, place: PrintExtraPlacePrintGroupSummary): Bundle = 16 | bundle.apply { putString(KEY_PRINT_GROUP_ID, place.printGroupId) } 17 | 18 | fun fromBundle(bundle: Bundle): PrintExtraPlacePrintGroupSummary? = 19 | PrintExtraPlacePrintGroupSummary(bundle.getString(KEY_PRINT_GROUP_ID)) 20 | } 21 | } -------------------------------------------------------------------------------- /src/main/java/ru/evotor/framework/receipt/print_extras/PrintExtraPlacePrintGroupTop.kt: -------------------------------------------------------------------------------- 1 | package ru.evotor.framework.receipt.print_extras 2 | 3 | import android.os.Bundle 4 | 5 | /** 6 | * Печатная информация будет добавлена сверху от чека: после клише, до текста "Кассовый чек" 7 | */ 8 | class PrintExtraPlacePrintGroupTop( 9 | val printGroupId: String? 10 | ) : PrintExtraPlace(PrintExtraPlaceType.PRINT_GROUP_TOP) { 11 | 12 | companion object { 13 | val KEY_PRINT_GROUP_ID = "printGroupId" 14 | 15 | fun addToBundle(bundle: Bundle, place: PrintExtraPlacePrintGroupTop): Bundle = 16 | bundle.apply { putString(KEY_PRINT_GROUP_ID, place.printGroupId) } 17 | 18 | fun fromBundle(bundle: Bundle): PrintExtraPlacePrintGroupTop? = 19 | PrintExtraPlacePrintGroupTop(bundle.getString(KEY_PRINT_GROUP_ID)) 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/ru/evotor/framework/receipt/print_extras/PrintExtraPlaceType.kt: -------------------------------------------------------------------------------- 1 | package ru.evotor.framework.receipt.print_extras 2 | 3 | /** 4 | * Тип места в чеке, куда будет добавлена дополнительная печатная информация 5 | */ 6 | enum class PrintExtraPlaceType { 7 | PRINT_GROUP_TOP, 8 | PRINT_GROUP_HEADER, 9 | PRINT_GROUP_SUMMARY, 10 | POSITION_FOOTER, 11 | POSITION_ALL_SUBPOSITIONS_FOOTER 12 | } -------------------------------------------------------------------------------- /src/main/java/ru/evotor/framework/receipt/provider/FiscalReceiptContract.kt: -------------------------------------------------------------------------------- 1 | package ru.evotor.framework.receipt.provider 2 | 3 | import android.net.Uri 4 | import ru.evotor.framework.provider.FiscalDocumentContract 5 | 6 | internal object FiscalReceiptContract { 7 | private const val PATH = "receipt" 8 | 9 | val URI: Uri = Uri.withAppendedPath(FiscalDocumentContract.URI, PATH) 10 | 11 | const val COLUMN_SETTLEMENT_TYPE = "SETTLEMENT_TYPE" 12 | } -------------------------------------------------------------------------------- /src/main/java/ru/evotor/framework/receipt/slip/SlipsAmountApi.kt: -------------------------------------------------------------------------------- 1 | package ru.evotor.framework.receipt.slip 2 | 3 | import android.content.Context 4 | import ru.evotor.framework.settings.SettingsApi 5 | 6 | @Deprecated("Используйте SettingsApi", replaceWith = ReplaceWith("SettingsApi")) 7 | object SlipsAmountApi { 8 | fun getSlipsAmount(context: Context): Int? = SettingsApi.getSlipsAmount(context) 9 | } 10 | -------------------------------------------------------------------------------- /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 | */ 16 | SLIPS_AMOUNT_PROVIDER( 17 | "SLIPS_AMOUNT_PATH", 18 | "SLIPS_AMOUNT_COLUMN" 19 | ), 20 | 21 | /** 22 | * Опция "Разрешить отрицательные остатки". 23 | */ 24 | NEGATIVE_BALANCE_PROVIDER( 25 | "NEGATIVE_BALANCE_PATH", 26 | "NEGATIVE_BALANCE_COLUMN" 27 | ); 28 | 29 | @Suppress("MemberVisibilityCanBePrivate") 30 | companion object { 31 | const val AUTHORITY = "ru.evotor.evotorpos.settings" 32 | const val DEPRECATED_AUTHORITY = "ru.evotor.settings.SlipsAmountInfo" 33 | 34 | internal val BASE_URI = Uri.parse("content://$AUTHORITY") 35 | internal val DEPRECATED_BASE_URI = Uri.parse("content://$DEPRECATED_AUTHORITY") 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/ru/evotor/framework/system/SystemStateTable.kt: -------------------------------------------------------------------------------- 1 | package ru.evotor.framework.system 2 | 3 | import android.net.Uri 4 | 5 | object SystemStateTable { 6 | const val IS_SESSION_OPENED_COLUMN_NAME = "IS_SESSION_OPENED" 7 | const val LAST_SESSION_NUMBER_COLUMN_NAME = "LAST_SESSION_NUMBER" 8 | 9 | const val IS_SESSION_OPENED_PATH = "IsSessionOpened" 10 | const val LAST_SESSION_NUMBER_PATH = "LastSessionNumber" 11 | 12 | @JvmField 13 | val IS_SESSION_OPENED_URI = Uri.withAppendedPath(SystemStateApi.BASE_URI, IS_SESSION_OPENED_PATH) 14 | @JvmField 15 | val LAST_SESSION_NUMBER_URI = Uri.withAppendedPath(SystemStateApi.BASE_URI, LAST_SESSION_NUMBER_PATH) 16 | } -------------------------------------------------------------------------------- /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 | */ 10 | const val MODE_ST = "ST" 11 | 12 | /** 13 | * * Режим работы терминала - фискальный регистратор 14 | */ 15 | const val MODE_FR = "FR" 16 | 17 | /** 18 | * Возвращает текущий режим работы терминала, если применимо, иначе - null 19 | */ 20 | @JvmStatic 21 | fun getCurrentDeviceMode(context: Context): String? { 22 | return try { 23 | context.contentResolver.query( 24 | DeviceModeContract.QUERY_URI, 25 | arrayOf(DeviceModeContract.COLUMN_MODE), 26 | null, null, null 27 | )?.use { c -> 28 | if (c.moveToNext()) { 29 | c.getString(c.getColumnIndex(DeviceModeContract.COLUMN_MODE)) 30 | } else { 31 | null 32 | } 33 | } 34 | } catch (t: Throwable) { 35 | null 36 | } 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/ru/evotor/framework/system/mode/DeviceModeContract.kt: -------------------------------------------------------------------------------- 1 | package ru.evotor.framework.system.mode 2 | 3 | import android.net.Uri 4 | 5 | object DeviceModeContract { 6 | 7 | val AUTHORITY = "ru.evotor.external.integrations" 8 | val PATH = "mode_fr" 9 | val COLUMN_MODE = "mode" 10 | 11 | val QUERY_URI = Uri.parse("content://$AUTHORITY/$PATH") 12 | 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/ru/evotor/framework/users/Grant.kt: -------------------------------------------------------------------------------- 1 | package ru.evotor.framework.users 2 | 3 | /** 4 | * Описывает права доступа к функциям смарт-терминала. 5 | * 6 | * @see ["Права приложения"](https://developer.evotor.ru/docs/doc_app_grants.html) 7 | */ 8 | data class Grant( 9 | /** 10 | * Название права. 11 | */ 12 | val title: String, 13 | /** 14 | * Идентификатор роли, которой соответствует право. 15 | */ 16 | val roleUuid: String 17 | ) -------------------------------------------------------------------------------- /src/main/java/ru/evotor/framework/users/GrantQuery.kt: -------------------------------------------------------------------------------- 1 | package ru.evotor.framework.users 2 | 3 | import ru.evotor.query.Cursor 4 | import ru.evotor.query.FilterBuilder 5 | 6 | class GrantQuery(authenticatedUsersOnly: Boolean = false) : FilterBuilder( 7 | if (authenticatedUsersOnly) GrantsTable.URI_GRANTS_OF_AUTHENTICATED_USER else GrantsTable.URI) { 8 | 9 | @JvmField 10 | val title = addFieldFilter(GrantsTable.ROW_TITLE) 11 | @JvmField 12 | val roleUuid = addFieldFilter(GrantsTable.ROW_ROLE_UUID) 13 | 14 | override val currentQuery: GrantQuery 15 | get() = this 16 | 17 | class SortOrder : FilterBuilder.SortOrder() { 18 | 19 | @JvmField 20 | val title = addFieldSorter(GrantsTable.ROW_TITLE) 21 | @JvmField 22 | val roleUuid = addFieldSorter(GrantsTable.ROW_ROLE_UUID) 23 | 24 | override val currentSortOrder: SortOrder 25 | get() = this 26 | 27 | } 28 | 29 | override fun getValue(cursor: Cursor): Grant? { 30 | return UserMapper.createGrant(cursor) 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/ru/evotor/framework/users/GrantsProviderColumns.kt: -------------------------------------------------------------------------------- 1 | package ru.evotor.framework.users 2 | 3 | import android.provider.BaseColumns 4 | 5 | interface GrantsProviderColumns : BaseColumns { 6 | companion object { 7 | const val roleUUID = "roleUUID" 8 | const val grantTitle = "grantTitle" 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/ru/evotor/framework/users/GrantsTable.kt: -------------------------------------------------------------------------------- 1 | package ru.evotor.framework.users 2 | 3 | import android.net.Uri 4 | 5 | object GrantsTable { 6 | @JvmField val URI = Uri.withAppendedPath(UsersContentProviderContract.BASE_URI, "grants") 7 | @JvmField val URI_GRANTS_OF_AUTHENTICATED_USER = Uri.withAppendedPath(URI, "authenticated") 8 | 9 | const val ROW_ROLE_UUID = "ROLE_UUID" 10 | const val ROW_TITLE = "TITLE" 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/ru/evotor/framework/users/RolesProviderColumns.kt: -------------------------------------------------------------------------------- 1 | package ru.evotor.framework.users 2 | 3 | import android.provider.BaseColumns 4 | 5 | interface RolesProviderColumns : BaseColumns { 6 | companion object { 7 | const val UUID = "UUID" 8 | const val roleTitle = "roleTitle" 9 | const val status = "status" 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/ru/evotor/framework/users/RolesTable.kt: -------------------------------------------------------------------------------- 1 | package ru.evotor.framework.users 2 | 3 | import android.net.Uri 4 | 5 | object RolesTable { 6 | @JvmField val URI = Uri.withAppendedPath(UsersContentProviderContract.BASE_URI, "roles") 7 | 8 | const val ROW_UUID = "UUID" 9 | const val ROW_TITLE = "TITLE" 10 | } 11 | -------------------------------------------------------------------------------- /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 | 8 | fun createGrant(cursor: Cursor): Grant { 9 | return Grant( 10 | title = cursor.getString(cursor.getColumnIndex(GrantsTable.ROW_TITLE)), 11 | roleUuid = cursor.getString(cursor.getColumnIndex(GrantsTable.ROW_ROLE_UUID)) 12 | ) 13 | } 14 | 15 | fun createUser(cursor: Cursor): User { 16 | return User( 17 | uuid = cursor.getString(cursor.getColumnIndex(UsersTable.ROW_USER_UUID)), 18 | secondName = cursor.optString(UsersTable.ROW_USER_SECOND_NAME), 19 | firstName = cursor.optString(UsersTable.ROW_USER_FIRST_NAME), 20 | inn = cursor.optString(UsersTable.ROW_USER_INN), 21 | phone = cursor.optString(UsersTable.ROW_USER_PHONE), 22 | pin = cursor.optString(UsersTable.ROW_USER_PIN), 23 | roleUuid = cursor.getString(cursor.getColumnIndex(UsersTable.ROW_ROLE_UUID)), 24 | roleTitle = cursor.getString(cursor.getColumnIndex(UsersTable.ROW_ROLE_TITLE)), 25 | position = cursor.optString(UsersTable.ROW_USER_POSITION) 26 | ) 27 | } 28 | } -------------------------------------------------------------------------------- /src/main/java/ru/evotor/framework/users/UsersContentProviderContract.kt: -------------------------------------------------------------------------------- 1 | package ru.evotor.framework.users 2 | 3 | import android.net.Uri 4 | 5 | object UsersContentProviderContract { 6 | @JvmField val BASE_URI: Uri = Uri.parse("content://ru.evotor.users") 7 | } 8 | -------------------------------------------------------------------------------- /src/main/java/ru/evotor/framework/users/UsersProviderColumns.kt: -------------------------------------------------------------------------------- 1 | package ru.evotor.framework.users 2 | 3 | import android.provider.BaseColumns 4 | 5 | interface UsersProviderColumns : BaseColumns { 6 | companion object { 7 | const val userUUID = "userUUID" 8 | const val surname = "surname" 9 | const val name = "name" 10 | const val inn = "inn" 11 | const val phone = "phone" 12 | const val PIN = "PIN" 13 | const val roleUUID = "roleUUID" 14 | const val position = "position" 15 | const val status = "status" 16 | const val isAuthenticated = "isAuthenticated" 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/ru/evotor/framework/users/UsersTable.kt: -------------------------------------------------------------------------------- 1 | package ru.evotor.framework.users 2 | 3 | import android.net.Uri 4 | 5 | object UsersTable { 6 | @JvmField val URI: Uri = Uri.withAppendedPath(UsersContentProviderContract.BASE_URI, "users") 7 | @JvmField val URI_AUTHENTICATED: Uri = Uri.withAppendedPath(URI, "authenticated") 8 | @JvmField val URI_FORCE_AUTHENTICATED: Uri = Uri.withAppendedPath(URI, "force_authenticated") 9 | 10 | const val ROW_USER_UUID = "USER_UUID" 11 | const val ROW_USER_SECOND_NAME = "USER_SECOND_NAME" 12 | const val ROW_USER_FIRST_NAME = "USER_FIRST_NAME" 13 | const val ROW_USER_INN = "USER_INN" 14 | const val ROW_USER_PHONE = "USER_PHONE" 15 | const val ROW_USER_PIN = "USER_PIN" 16 | const val ROW_ROLE_UUID = "ROLE_UUID" 17 | const val ROW_ROLE_TITLE = "ROLE_TITLE" 18 | const val ROW_USER_POSITION = "USER_POSITION" 19 | } 20 | -------------------------------------------------------------------------------- /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 | 14 | override fun onReceive(context: Context?, intent: Intent?) { 15 | intent?.extras?.getString(EXTRA_SCANNED_CODE)?.let { code -> 16 | if (code.isNotEmpty()) { 17 | onBarcodeReceived(code, context) 18 | } 19 | } 20 | } 21 | 22 | public abstract fun onBarcodeReceived(barcode: String, context: Context?) 23 | 24 | 25 | companion object { 26 | 27 | @JvmField 28 | public val ACTION_SCANNED = "ru.evotor.devices.ScannedCode" 29 | 30 | @JvmField 31 | public val EXTRA_SCANNED_CODE = "ScannedCode" 32 | 33 | @JvmField 34 | public val SENDER_PERMISSION = "ru.evotor.devices.SCANNER_SENDER" 35 | 36 | @JvmField 37 | public val RECEIVER_PERMISSION = "ru.evotor.devices.SCANNER_RECEIVER" 38 | 39 | @JvmField 40 | public val BARCODE_INTENT_FILTER = IntentFilter(ACTION_SCANNED) 41 | 42 | } 43 | 44 | } -------------------------------------------------------------------------------- /src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | #FFFFFF 4 | #333333 5 | -------------------------------------------------------------------------------- /src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | integration-library 3 | 4 | --------------------------------------------------------------------------------