From 1e7fe8efd2f13b40dfdd9d3ad4466b1a717e30f3 Mon Sep 17 00:00:00 2001 From: Stuart Ferguson Date: Tue, 28 Jan 2025 12:25:40 +0000 Subject: [PATCH 1/3] Refactor TransactionProcessor and Update Database Schema This commit includes significant refactoring of the TransactionProcessor project, introducing new aggregates and removing outdated ones. Key changes involve: - Updated integration tests to reflect new structures and namespaces. - Added new classes and methods for managing transactions, estates, and vouchers. - Modified project references to include necessary dependencies. - Adjusted database migrations to streamline the schema, including the removal of reporting IDs and the introduction of new identifiers. - Enhanced domain event handling capabilities with new event handlers and services. - Improved overall code organization for better maintainability and readability. --- .../EstateAggregateTests.cs | 245 ++ .../FloatActivityAggregateTests.cs | 3 +- .../FloatAggregateTests.cs | 25 +- .../ReconciliationAggregateTests.cs | 56 +- .../SettlementAggregateTests.cs | 11 +- .../TransactionAggregateTests.cs | 172 +- ...ansactionProcessor.Aggregates.Tests.csproj | 24 +- .../VoucherAggregateTests.cs | 45 +- .../EstateAggregate.cs | 223 ++ .../FloatActivityAggregate.cs | 94 + .../FloatAggregate.cs | 62 +- .../Models/Operator.cs | 6 + .../Models/SecurityUser.cs | 6 + .../ReconciliationAggregate.cs | 2 +- .../SettlementAggregate.cs | 4 +- .../TransactionAggregate.cs | 10 +- .../TransactionProcessor.Aggregates.csproj | 22 + .../VoucherAggregate.cs | 14 +- .../TransactionDomainEventHandlerTests.cs | 3 - .../VoucherDomainEventHandlerTests.cs | 11 +- .../Manager/EstateManagementManagerTests.cs | 490 ++++ .../Manager/VoucherManagementManagerTests.cs | 4 +- .../Mediator/DummyEstateDomainService.cs | 18 + .../Mediator/DummySettlementDomainService.cs | 16 +- .../Mediator/MediatorTests.cs | 11 +- .../SettlementRequestHandlerTests.cs | 2 +- .../Services/EstateDomainServiceTests.cs | 160 ++ .../Services/FloatDomainServiceTests.cs | 6 +- .../Services/SettlementDomainServiceTests.cs | 3 +- .../Services/TransactionDomainServiceTests.cs | 4 +- .../TransactionValidationServiceTests.cs | 186 +- .../Services/VoucherDomainServiceTests.cs | 8 +- ...actionProcessor.BusinessLogic.Tests.csproj | 1 + .../Common/IIntermediateEstateClient.cs | 2 + .../EventHandling/EstateDomainEventHandler.cs | 82 + .../TransactionDomainEventHandler.cs | 4 - .../VoucherDomainEventHandler.cs | 8 +- .../Manager/EstateManagementManager.cs | 239 ++ .../Manager/IEstateManagementManager.cs | 50 + .../Manager/IVoucherManagementManager.cs | 3 +- .../RequestHandlers/EstateRequestHandler.cs | 73 + .../RequestHandlers/FloatRequestHandler.cs | 1 - .../SettlementRequestHandler.cs | 3 +- .../Requests/EstateCommands.cs | 24 + .../Requests/EstateQueries.cs | 15 + .../Requests/SettlementQueries.cs | 2 +- .../Services/EstateDomainService.cs | 153 ++ ...DomainService.cs => FloatDomainService.cs} | 9 +- .../Services/IMessageTemplateReader.cs | 30 - .../Services/ISettlementDomainService.cs | 24 - .../Services/ITransactionDomainService.cs | 41 - .../Services/ITransactionValidationService.cs | 38 - .../Services/IVoucherDomainService.cs | 53 - .../Services/SettlementDomainService.cs | 13 +- .../Services/TransactionDomainService.cs | 38 +- .../Services/TransactionReceiptBuilder.cs | 23 +- .../Services/TransactionValidationService.cs | 81 +- .../Services/VoucherDomainService.cs | 50 +- .../TransactionProcessor.BusinessLogic.csproj | 9 +- .../ITransactionProcessorClient.cs | 222 ++ .../TransactionProcessorClient.cs | 1931 ++++++++++++--- .../RedeemVoucherResponse.cs | 3 + .../Contract/AddProductToContractRequest.cs | 52 + ...ansactionFeeForProductToContractRequest.cs | 52 + .../Contract/CreateContractRequest.cs | 28 + .../Requests/Estate/AssignOperatorRequest.cs | 28 + .../Requests/Estate/CreateEstateRequest.cs | 29 + .../Estate/CreateEstateUserRequest.cs | 54 + .../Merchant/AddMerchantContractRequest.cs | 12 + .../Merchant/AddMerchantDeviceRequest.cs | 19 + .../Requests/Merchant/Address.cs | 92 + .../Merchant/AssignOperatorRequest.cs | 44 + .../Requests/Merchant/Contact.cs | 45 + .../Merchant/CreateMerchantRequest.cs | 56 + .../Merchant/CreateMerchantUserRequest.cs | 54 + .../GenerateMerchantStatementRequest.cs | 21 + .../Merchant/MakeMerchantDepositRequest.cs | 44 + .../Merchant/MakeMerchantWithdrawalRequest.cs | 41 + .../Merchant/MerchantDepositSource.cs | 9 + .../Merchant/SetSettlementScheduleRequest.cs | 14 + .../Merchant/SwapMerchantDeviceRequest.cs | 17 + .../Merchant/UpdateMerchantRequest.cs | 19 + .../Operator/CreateOperatorRequest.cs | 52 + .../Operator/UpdateOperatorRequest.cs | 44 + .../Contract/AddProductToContractResponse.cs | 44 + ...nsactionFeeForProductToContractResponse.cs | 50 + .../Responses/Contract/CalculationType.cs | 18 + .../Responses/Contract/ContactResponse.cs | 50 + .../Responses/Contract/ContractProduct.cs | 66 + .../Contract/ContractProductTransactionFee.cs | 60 + .../Responses/Contract/ContractResponse.cs | 70 + .../Contract/CreateContractResponse.cs | 39 + .../Responses/Contract/FeeType.cs | 18 + .../Responses/Contract/ProductType.cs | 13 + .../Responses/Estate/CreateEstateResponse.cs | 19 + .../Estate/CreateEstateUserResponse.cs | 31 + .../Estate/EstateOperatorResponse.cs | 53 + .../Responses/Estate/EstateResponse.cs | 60 + .../Responses/Estate/SecurityUserResponse.cs | 32 + .../Responses/File/FileDetailsResponse.cs | 17 + .../Responses/File/FileLineDetailsResponse.cs | 10 + .../Responses/File/TransactionResponse.cs | 15 + .../Merchant/AddMerchantDeviceResponse.cs | 41 + .../Responses/Merchant/AddressResponse.cs | 95 + .../Merchant/AssignOperatorResponse.cs | 44 + .../Merchant/CreateMerchantResponse.cs | 35 + .../Merchant/CreateMerchantUserResponse.cs | 41 + .../GenerateMerchantStatementResponse.cs | 15 + .../Merchant/MakeMerchantDepositResponse.cs | 41 + .../MakeMerchantWithdrawalResponse.cs | 41 + .../Merchant/MerchantContractResponse.cs | 24 + .../Merchant/MerchantOperatorResponse.cs | 53 + .../Responses/Merchant/MerchantResponse.cs | 116 + .../Responses/Merchant/SettlementSchedule.cs | 10 + .../Merchant/SwapMerchantDeviceResponse.cs | 41 + .../Operator/CreateOperatorResponse.cs | 32 + .../Responses/Operator/OperatorResponse.cs | 46 + .../Settlement/SettlementFeeResponse.cs | 41 + .../Settlement/SettlementResponse.cs | 42 + ...actionProcessor.DataTransferObjects.csproj | 4 + .../EstateManagementGenericContext.cs | 581 +++++ .../Contexts/EstateManagementMySqlContext.cs | 30 + .../EstateManagementSqlServerContext.cs | 48 + .../Contexts/Extensions.cs | 468 ++++ ...ySqlIgnoreDuplicatesOnInsertInterceptor.cs | 86 + .../Entities/Calendar.cs | 39 + .../Entities/Contract.cs | 22 + .../Entities/ContractProduct.cs | 27 + .../Entities/ContractProductTransactionFee.cs | 29 + .../Entities/Estate.cs | 26 + .../Entities/EstateSecurityUser.cs | 22 + .../Entities/File.cs | 34 + .../Entities/FileImportLog.cs | 22 + .../Entities/FileImportLogFile.cs | 29 + .../Entities/FileLine.cs | 21 + .../Entities/Float.cs | 16 + .../Entities/FloatActivity.cs | 11 + .../Entities/Merchant.cs | 36 + .../Entities/MerchantAddress.cs | 37 + .../Entities/MerchantContact.cs | 27 + .../Entities/MerchantContract.cs | 9 + .../Entities/MerchantDevice.cs | 23 + .../Entities/MerchantOperator.cs | 26 + .../Entities/MerchantSecurityUser.cs | 23 + .../Entities/MerchantSettlementFee.cs | 28 + .../Entities/Operator.cs | 25 + .../Entities/Reconciliation.cs | 39 + .../Entities/ResponseCodes.cs | 12 + .../Entities/Settlement.cs | 27 + .../Entities/StatementHeader.cs | 24 + .../Entities/StatementLine.cs | 22 + .../Entities/Summary/SettlementSummary.cs | 67 + .../TransactionAdditionalRequestData.cs | 23 + .../TransactionAdditionalResponseData.cs | 20 + .../Entities/Transactions.cs | 57 + .../Entities/Voucher.cs | 50 + ...20221115193718_InitialDatabase.Designer.cs | 1065 ++++++++ .../MySql/20221115193718_InitialDatabase.cs | 752 ++++++ .../20221116082041_somenullfixes.Designer.cs | 1057 ++++++++ .../MySql/20221116082041_somenullfixes.cs | 239 ++ ...230116113800_recordproducttype.Designer.cs | 1063 ++++++++ .../MySql/20230116113800_recordproducttype.cs | 29 + ...0_task384_datamodelrefactoring.Designer.cs | 992 ++++++++ ...0630115550_task384_datamodelrefactoring.cs | 2144 +++++++++++++++++ ...ttlementProcessingStartedEvent.Designer.cs | 963 ++++++++ ..._handleSettlementProcessingStartedEvent.cs | 70 + ...hantsettlementfee_missingindex.Designer.cs | 965 ++++++++ ...2952_merchantsettlementfee_missingindex.cs | 27 + ...3_addmerchanttosettlementtable.Designer.cs | 968 ++++++++ ...0721142823_addmerchanttosettlementtable.cs | 29 + ...3_storelastsaleagainstmerchant.Designer.cs | 974 ++++++++ ...0801201633_storelastsaleagainstmerchant.cs | 40 + ...0905184421_amountintransaction.Designer.cs | 981 ++++++++ .../20230905184421_amountintransaction.cs | 39 + ...tateoperatorreportingidwithtxn.Designer.cs | 985 ++++++++ ..._recordestateoperatorreportingidwithtxn.cs | 53 + ...35806_addmerchantcontracttable.Designer.cs | 998 ++++++++ ...20231228135806_addmerchantcontracttable.cs | 34 + .../20240210074240_floattables.Designer.cs | 1062 ++++++++ .../MySql/20240210074240_floattables.cs | 70 + ...172001_fixstatementheaderindex.Designer.cs | 1061 ++++++++ .../20240313172001_fixstatementheaderindex.cs | 37 + ...20240420163033_merchantupdates.Designer.cs | 1095 +++++++++ .../MySql/20240420163033_merchantupdates.cs | 275 +++ ...ecord_operatators_at_readmodel.Designer.cs | 1112 +++++++++ ...5094256_record_operatators_at_readmodel.cs | 114 + ...ord_operatators_at_readmodel_1.Designer.cs | 1114 +++++++++ ...32550_record_operatators_at_readmodel_1.cs | 46 + ...ord_operatators_at_readmodel_2.Designer.cs | 1111 +++++++++ ...64125_record_operatators_at_readmodel_2.cs | 55 + ...er_operatoridentifier_nullable.Designer.cs | 1110 +++++++++ ...ake_voucher_operatoridentifier_nullable.cs | 46 + ..._reportingids_from_transaction.Designer.cs | 1098 +++++++++ ...37_remove_reportingids_from_transaction.cs | 1510 ++++++++++++ ...tateManagementMySqlContextModelSnapshot.cs | 1097 +++++++++ ...20221115191516_InitialDatabase.Designer.cs | 1069 ++++++++ .../20221115191516_InitialDatabase.cs | 654 +++++ .../20221116081939_somenullfixes.Designer.cs | 1061 ++++++++ .../SqlServer/20221116081939_somenullfixes.cs | 159 ++ ...230116113030_recordproducttype.Designer.cs | 1067 ++++++++ .../20230116113030_recordproducttype.cs | 29 + ...3_task384_datamodelrefactoring.Designer.cs | 1032 ++++++++ ...0630113913_task384_datamodelrefactoring.cs | 2084 ++++++++++++++++ ...ttlementProcessingStartedEvent.Designer.cs | 1001 ++++++++ ..._handleSettlementProcessingStartedEvent.cs | 68 + ...hantsettlementfee_missingindex.Designer.cs | 1003 ++++++++ ...3118_merchantsettlementfee_missingindex.cs | 27 + ...8_addmerchanttosettlementtable.Designer.cs | 1006 ++++++++ ...0721142728_addmerchanttosettlementtable.cs | 29 + ...6_storelastsaleagainstmerchant.Designer.cs | 1012 ++++++++ ...0801201426_storelastsaleagainstmerchant.cs | 40 + ...0905183930_amountintransaction.Designer.cs | 1020 ++++++++ .../20230905183930_amountintransaction.cs | 40 + ...tateoperatorreportingidwithtxn.Designer.cs | 1026 ++++++++ ..._recordestateoperatorreportingidwithtxn.cs | 51 + ...35707_addmerchantcontracttable.Designer.cs | 1039 ++++++++ ...20231228135707_addmerchantcontracttable.cs | 33 + .../20240210074115_floattables.Designer.cs | 1107 +++++++++ .../SqlServer/20240210074115_floattables.cs | 71 + ...170318_fixstatementheaderindex.Designer.cs | 1106 +++++++++ .../20240313170318_fixstatementheaderindex.cs | 39 + ...20240420162900_merchantupdates.Designer.cs | 1112 +++++++++ .../20240420162900_merchantupdates.cs | 40 + ...ecord_operatators_at_readmodel.Designer.cs | 1129 +++++++++ ...5094035_record_operatators_at_readmodel.cs | 110 + ...ord_operatators_at_readmodel_1.Designer.cs | 1131 +++++++++ ...32448_record_operatators_at_readmodel_1.cs | 46 + ...ord_operatators_at_readmodel_2.Designer.cs | 1128 +++++++++ ...63935_record_operatators_at_readmodel_2.cs | 53 + ...er_operatoridentifier_nullable.Designer.cs | 1127 +++++++++ ...ake_voucher_operatoridentifier_nullable.cs | 36 + ..._reportingids_from_transaction.Designer.cs | 1117 +++++++++ ...37_remove_reportingids_from_transaction.cs | 1497 ++++++++++++ ...ortingids_from_transaction_sp1.Designer.cs | 1114 +++++++++ ...emove_reportingids_from_transaction_sp1.cs | 28 + ...240607093059_summary_first_cut.Designer.cs | 1320 ++++++++++ .../20240607093059_summary_first_cut.cs | 142 ++ ...ManagementSqlServerContextModelSnapshot.cs | 1319 ++++++++++ .../SeedingScripts/CalendarSeeding.sql | 49 + .../SeedingScripts/ResponseCodeSeeding.sql | 19 + .../SqlServer/spBuildHistoricTransactions.sql | 46 + .../SqlServer/spBuildSettlementSummary.sql | 30 + .../SqlServer/spBuildTodaysTransactions.sql | 49 + .../TransactionProcessor.Database.csproj | 56 + .../ViewEntities/SettlementView.cs | 97 + .../MySql/Priority1/uvwSettlements.View.sql | 29 + .../Priority1/uvwSettlements.View.sql | 30 + .../EstateDomainEvents.cs | 18 + ...actionProcessor.Estate.DomainEvents.csproj | 13 + .../FloatActivityAggregate.cs | 87 - ...TransactionProcessor.FloatAggregate.csproj | 17 - .../EstateDetails.cs | 308 +++ .../SpecflowExtensions.cs | 423 +++- .../SubscriptionsHelper.cs | 18 +- ...rocessor.IntegrationTesting.Helpers.csproj | 2 +- .../TransactionProcessorSteps.cs | 483 +++- .../Common/DockerHelper.cs | 9 +- .../Common/EstateDetails.cs | 12 +- .../Common/TestingContext.cs | 8 +- .../Features/Estate.feature | 84 + .../Features/Estate.feature.cs | 381 +++ .../Features/LogonTransaction.feature.cs | 156 +- .../Features/ReconciliationFeature.feature.cs | 136 +- .../Features/RedeemVoucher.feature.cs | 96 +- .../SaleTransactionFeature.feature.cs | 438 ++-- .../Features/Settlement.feature.cs | 274 +-- .../Shared/SharedSteps.cs | 162 +- ...ansactionProcessor.IntegrationTests.csproj | 2 +- TransactionProcessor.Models/Estate.cs | 29 + TransactionProcessor.Models/Operator.cs | 23 + TransactionProcessor.Models/SecurityUser.cs | 29 + .../StateProjectionEventHandlers.cs | 4 +- ...ansactionProcessor.ProjectionEngine.csproj | 2 +- ...essor.ReconciliationAggregate.Tests.csproj | 31 - ...onProcessor.ReconciliationAggregate.csproj | 16 - ...TransactionProcessorReadModelRepository.cs | 891 +++++++ .../ModelFactory.cs | 50 + .../TransactionProcessor.Repository.csproj | 28 + ...rocessor.SettlementAggregates.Tests.csproj | 30 - ...ctionProcessor.SettlementAggregates.csproj | 17 - TransactionProcessor.Testing/TestData.cs | 161 +- .../TransactionProcessor.Testing.csproj | 1 - .../Factories/ModelFactoryTests.cs | 46 +- ...rocessor.TransactionAggregate.Tests.csproj | 30 - ...ctionProcessor.TransactionAggregate.csproj | 17 - ...ionProcessor.VoucherAggregate.Tests.csproj | 32 - ...ansactionProcessor.VoucherAggregate.csproj | 19 - TransactionProcessor.sln | 103 +- .../DomainEventHandlerRegistry.cs | 1 + .../Bootstrapper/DomainServiceRegistry.cs | 1 + .../Bootstrapper/MediatorRegistry.cs | 63 +- .../Bootstrapper/MiscRegistry.cs | 2 +- .../Bootstrapper/RepositoryRegistry.cs | 25 +- .../Controllers/ContractController.cs | 467 ++++ .../Controllers/EstateController.cs | 243 ++ .../Controllers/MerchantController.cs | 739 +++++- .../Controllers/SettlementController.cs | 111 +- .../Controllers/TransactionController.cs | 18 +- .../Controllers/VoucherController.cs | 14 +- .../Factories/IModelFactory.cs | 32 - .../Factories/ModelFactory.cs | 77 +- TransactionProcessor/appsettings.json | 11 + 302 files changed, 70142 insertions(+), 2065 deletions(-) create mode 100644 TransactionProcessor.Aggregates.Tests/EstateAggregateTests.cs rename {TransactionProcessor.FloatAggregate.Tests => TransactionProcessor.Aggregates.Tests}/FloatActivityAggregateTests.cs (97%) rename {TransactionProcessor.FloatAggregate.Tests => TransactionProcessor.Aggregates.Tests}/FloatAggregateTests.cs (82%) rename {TransactionProcessor.ReconciliationAggregate.Tests => TransactionProcessor.Aggregates.Tests}/ReconciliationAggregateTests.cs (83%) rename {TransactionProcessor.SettlementAggregates.Tests => TransactionProcessor.Aggregates.Tests}/SettlementAggregateTests.cs (98%) rename {TransactionProcessor.TransactionAggregate.Tests => TransactionProcessor.Aggregates.Tests}/TransactionAggregateTests.cs (91%) rename TransactionProcessor.FloatAggregate.Tests/TransactionProcessor.FloatAggregate.Tests.csproj => TransactionProcessor.Aggregates.Tests/TransactionProcessor.Aggregates.Tests.csproj (52%) rename {TransactionProcessor.VoucherAggregate.Tests => TransactionProcessor.Aggregates.Tests}/VoucherAggregateTests.cs (81%) create mode 100644 TransactionProcessor.Aggregates/EstateAggregate.cs create mode 100644 TransactionProcessor.Aggregates/FloatActivityAggregate.cs rename {TransactionProcessor.FloatAggregate => TransactionProcessor.Aggregates}/FloatAggregate.cs (85%) create mode 100644 TransactionProcessor.Aggregates/Models/Operator.cs create mode 100644 TransactionProcessor.Aggregates/Models/SecurityUser.cs rename {TransactionProcessor.ReconciliationAggregate => TransactionProcessor.Aggregates}/ReconciliationAggregate.cs (99%) rename {TransactionProcessor.SettlementAggregates => TransactionProcessor.Aggregates}/SettlementAggregate.cs (99%) rename {TransactionProcessor.TransactionAgrgegate => TransactionProcessor.Aggregates}/TransactionAggregate.cs (99%) create mode 100644 TransactionProcessor.Aggregates/TransactionProcessor.Aggregates.csproj rename {TransactionProcessor.VoucherAggregate => TransactionProcessor.Aggregates}/VoucherAggregate.cs (96%) create mode 100644 TransactionProcessor.BusinessLogic.Tests/Manager/EstateManagementManagerTests.cs create mode 100644 TransactionProcessor.BusinessLogic.Tests/Mediator/DummyEstateDomainService.cs create mode 100644 TransactionProcessor.BusinessLogic.Tests/Services/EstateDomainServiceTests.cs create mode 100644 TransactionProcessor.BusinessLogic/EventHandling/EstateDomainEventHandler.cs create mode 100644 TransactionProcessor.BusinessLogic/Manager/EstateManagementManager.cs create mode 100644 TransactionProcessor.BusinessLogic/Manager/IEstateManagementManager.cs create mode 100644 TransactionProcessor.BusinessLogic/RequestHandlers/EstateRequestHandler.cs create mode 100644 TransactionProcessor.BusinessLogic/Requests/EstateCommands.cs create mode 100644 TransactionProcessor.BusinessLogic/Requests/EstateQueries.cs create mode 100644 TransactionProcessor.BusinessLogic/Services/EstateDomainService.cs rename TransactionProcessor.BusinessLogic/Services/{IFloatDomainService.cs => FloatDomainService.cs} (96%) delete mode 100644 TransactionProcessor.BusinessLogic/Services/IMessageTemplateReader.cs delete mode 100644 TransactionProcessor.BusinessLogic/Services/ISettlementDomainService.cs delete mode 100644 TransactionProcessor.BusinessLogic/Services/ITransactionDomainService.cs delete mode 100644 TransactionProcessor.BusinessLogic/Services/ITransactionValidationService.cs delete mode 100644 TransactionProcessor.BusinessLogic/Services/IVoucherDomainService.cs create mode 100644 TransactionProcessor.DataTransferObjects/Requests/Contract/AddProductToContractRequest.cs create mode 100644 TransactionProcessor.DataTransferObjects/Requests/Contract/AddTransactionFeeForProductToContractRequest.cs create mode 100644 TransactionProcessor.DataTransferObjects/Requests/Contract/CreateContractRequest.cs create mode 100644 TransactionProcessor.DataTransferObjects/Requests/Estate/AssignOperatorRequest.cs create mode 100644 TransactionProcessor.DataTransferObjects/Requests/Estate/CreateEstateRequest.cs create mode 100644 TransactionProcessor.DataTransferObjects/Requests/Estate/CreateEstateUserRequest.cs create mode 100644 TransactionProcessor.DataTransferObjects/Requests/Merchant/AddMerchantContractRequest.cs create mode 100644 TransactionProcessor.DataTransferObjects/Requests/Merchant/AddMerchantDeviceRequest.cs create mode 100644 TransactionProcessor.DataTransferObjects/Requests/Merchant/Address.cs create mode 100644 TransactionProcessor.DataTransferObjects/Requests/Merchant/AssignOperatorRequest.cs create mode 100644 TransactionProcessor.DataTransferObjects/Requests/Merchant/Contact.cs create mode 100644 TransactionProcessor.DataTransferObjects/Requests/Merchant/CreateMerchantRequest.cs create mode 100644 TransactionProcessor.DataTransferObjects/Requests/Merchant/CreateMerchantUserRequest.cs create mode 100644 TransactionProcessor.DataTransferObjects/Requests/Merchant/GenerateMerchantStatementRequest.cs create mode 100644 TransactionProcessor.DataTransferObjects/Requests/Merchant/MakeMerchantDepositRequest.cs create mode 100644 TransactionProcessor.DataTransferObjects/Requests/Merchant/MakeMerchantWithdrawalRequest.cs create mode 100644 TransactionProcessor.DataTransferObjects/Requests/Merchant/MerchantDepositSource.cs create mode 100644 TransactionProcessor.DataTransferObjects/Requests/Merchant/SetSettlementScheduleRequest.cs create mode 100644 TransactionProcessor.DataTransferObjects/Requests/Merchant/SwapMerchantDeviceRequest.cs create mode 100644 TransactionProcessor.DataTransferObjects/Requests/Merchant/UpdateMerchantRequest.cs create mode 100644 TransactionProcessor.DataTransferObjects/Requests/Operator/CreateOperatorRequest.cs create mode 100644 TransactionProcessor.DataTransferObjects/Requests/Operator/UpdateOperatorRequest.cs create mode 100644 TransactionProcessor.DataTransferObjects/Responses/Contract/AddProductToContractResponse.cs create mode 100644 TransactionProcessor.DataTransferObjects/Responses/Contract/AddTransactionFeeForProductToContractResponse.cs create mode 100644 TransactionProcessor.DataTransferObjects/Responses/Contract/CalculationType.cs create mode 100644 TransactionProcessor.DataTransferObjects/Responses/Contract/ContactResponse.cs create mode 100644 TransactionProcessor.DataTransferObjects/Responses/Contract/ContractProduct.cs create mode 100644 TransactionProcessor.DataTransferObjects/Responses/Contract/ContractProductTransactionFee.cs create mode 100644 TransactionProcessor.DataTransferObjects/Responses/Contract/ContractResponse.cs create mode 100644 TransactionProcessor.DataTransferObjects/Responses/Contract/CreateContractResponse.cs create mode 100644 TransactionProcessor.DataTransferObjects/Responses/Contract/FeeType.cs create mode 100644 TransactionProcessor.DataTransferObjects/Responses/Contract/ProductType.cs create mode 100644 TransactionProcessor.DataTransferObjects/Responses/Estate/CreateEstateResponse.cs create mode 100644 TransactionProcessor.DataTransferObjects/Responses/Estate/CreateEstateUserResponse.cs create mode 100644 TransactionProcessor.DataTransferObjects/Responses/Estate/EstateOperatorResponse.cs create mode 100644 TransactionProcessor.DataTransferObjects/Responses/Estate/EstateResponse.cs create mode 100644 TransactionProcessor.DataTransferObjects/Responses/Estate/SecurityUserResponse.cs create mode 100644 TransactionProcessor.DataTransferObjects/Responses/File/FileDetailsResponse.cs create mode 100644 TransactionProcessor.DataTransferObjects/Responses/File/FileLineDetailsResponse.cs create mode 100644 TransactionProcessor.DataTransferObjects/Responses/File/TransactionResponse.cs create mode 100644 TransactionProcessor.DataTransferObjects/Responses/Merchant/AddMerchantDeviceResponse.cs create mode 100644 TransactionProcessor.DataTransferObjects/Responses/Merchant/AddressResponse.cs create mode 100644 TransactionProcessor.DataTransferObjects/Responses/Merchant/AssignOperatorResponse.cs create mode 100644 TransactionProcessor.DataTransferObjects/Responses/Merchant/CreateMerchantResponse.cs create mode 100644 TransactionProcessor.DataTransferObjects/Responses/Merchant/CreateMerchantUserResponse.cs create mode 100644 TransactionProcessor.DataTransferObjects/Responses/Merchant/GenerateMerchantStatementResponse.cs create mode 100644 TransactionProcessor.DataTransferObjects/Responses/Merchant/MakeMerchantDepositResponse.cs create mode 100644 TransactionProcessor.DataTransferObjects/Responses/Merchant/MakeMerchantWithdrawalResponse.cs create mode 100644 TransactionProcessor.DataTransferObjects/Responses/Merchant/MerchantContractResponse.cs create mode 100644 TransactionProcessor.DataTransferObjects/Responses/Merchant/MerchantOperatorResponse.cs create mode 100644 TransactionProcessor.DataTransferObjects/Responses/Merchant/MerchantResponse.cs create mode 100644 TransactionProcessor.DataTransferObjects/Responses/Merchant/SettlementSchedule.cs create mode 100644 TransactionProcessor.DataTransferObjects/Responses/Merchant/SwapMerchantDeviceResponse.cs create mode 100644 TransactionProcessor.DataTransferObjects/Responses/Operator/CreateOperatorResponse.cs create mode 100644 TransactionProcessor.DataTransferObjects/Responses/Operator/OperatorResponse.cs create mode 100644 TransactionProcessor.DataTransferObjects/Responses/Settlement/SettlementFeeResponse.cs create mode 100644 TransactionProcessor.DataTransferObjects/Responses/Settlement/SettlementResponse.cs create mode 100644 TransactionProcessor.Database/Contexts/EstateManagementGenericContext.cs create mode 100644 TransactionProcessor.Database/Contexts/EstateManagementMySqlContext.cs create mode 100644 TransactionProcessor.Database/Contexts/EstateManagementSqlServerContext.cs create mode 100644 TransactionProcessor.Database/Contexts/Extensions.cs create mode 100644 TransactionProcessor.Database/Contexts/MySqlIgnoreDuplicatesOnInsertInterceptor.cs create mode 100644 TransactionProcessor.Database/Entities/Calendar.cs create mode 100644 TransactionProcessor.Database/Entities/Contract.cs create mode 100644 TransactionProcessor.Database/Entities/ContractProduct.cs create mode 100644 TransactionProcessor.Database/Entities/ContractProductTransactionFee.cs create mode 100644 TransactionProcessor.Database/Entities/Estate.cs create mode 100644 TransactionProcessor.Database/Entities/EstateSecurityUser.cs create mode 100644 TransactionProcessor.Database/Entities/File.cs create mode 100644 TransactionProcessor.Database/Entities/FileImportLog.cs create mode 100644 TransactionProcessor.Database/Entities/FileImportLogFile.cs create mode 100644 TransactionProcessor.Database/Entities/FileLine.cs create mode 100644 TransactionProcessor.Database/Entities/Float.cs create mode 100644 TransactionProcessor.Database/Entities/FloatActivity.cs create mode 100644 TransactionProcessor.Database/Entities/Merchant.cs create mode 100644 TransactionProcessor.Database/Entities/MerchantAddress.cs create mode 100644 TransactionProcessor.Database/Entities/MerchantContact.cs create mode 100644 TransactionProcessor.Database/Entities/MerchantContract.cs create mode 100644 TransactionProcessor.Database/Entities/MerchantDevice.cs create mode 100644 TransactionProcessor.Database/Entities/MerchantOperator.cs create mode 100644 TransactionProcessor.Database/Entities/MerchantSecurityUser.cs create mode 100644 TransactionProcessor.Database/Entities/MerchantSettlementFee.cs create mode 100644 TransactionProcessor.Database/Entities/Operator.cs create mode 100644 TransactionProcessor.Database/Entities/Reconciliation.cs create mode 100644 TransactionProcessor.Database/Entities/ResponseCodes.cs create mode 100644 TransactionProcessor.Database/Entities/Settlement.cs create mode 100644 TransactionProcessor.Database/Entities/StatementHeader.cs create mode 100644 TransactionProcessor.Database/Entities/StatementLine.cs create mode 100644 TransactionProcessor.Database/Entities/Summary/SettlementSummary.cs create mode 100644 TransactionProcessor.Database/Entities/TransactionAdditionalRequestData.cs create mode 100644 TransactionProcessor.Database/Entities/TransactionAdditionalResponseData.cs create mode 100644 TransactionProcessor.Database/Entities/Transactions.cs create mode 100644 TransactionProcessor.Database/Entities/Voucher.cs create mode 100644 TransactionProcessor.Database/Migrations/MySql/20221115193718_InitialDatabase.Designer.cs create mode 100644 TransactionProcessor.Database/Migrations/MySql/20221115193718_InitialDatabase.cs create mode 100644 TransactionProcessor.Database/Migrations/MySql/20221116082041_somenullfixes.Designer.cs create mode 100644 TransactionProcessor.Database/Migrations/MySql/20221116082041_somenullfixes.cs create mode 100644 TransactionProcessor.Database/Migrations/MySql/20230116113800_recordproducttype.Designer.cs create mode 100644 TransactionProcessor.Database/Migrations/MySql/20230116113800_recordproducttype.cs create mode 100644 TransactionProcessor.Database/Migrations/MySql/20230630115550_task384_datamodelrefactoring.Designer.cs create mode 100644 TransactionProcessor.Database/Migrations/MySql/20230630115550_task384_datamodelrefactoring.cs create mode 100644 TransactionProcessor.Database/Migrations/MySql/20230717130332_handleSettlementProcessingStartedEvent.Designer.cs create mode 100644 TransactionProcessor.Database/Migrations/MySql/20230717130332_handleSettlementProcessingStartedEvent.cs create mode 100644 TransactionProcessor.Database/Migrations/MySql/20230717132952_merchantsettlementfee_missingindex.Designer.cs create mode 100644 TransactionProcessor.Database/Migrations/MySql/20230717132952_merchantsettlementfee_missingindex.cs create mode 100644 TransactionProcessor.Database/Migrations/MySql/20230721142823_addmerchanttosettlementtable.Designer.cs create mode 100644 TransactionProcessor.Database/Migrations/MySql/20230721142823_addmerchanttosettlementtable.cs create mode 100644 TransactionProcessor.Database/Migrations/MySql/20230801201633_storelastsaleagainstmerchant.Designer.cs create mode 100644 TransactionProcessor.Database/Migrations/MySql/20230801201633_storelastsaleagainstmerchant.cs create mode 100644 TransactionProcessor.Database/Migrations/MySql/20230905184421_amountintransaction.Designer.cs create mode 100644 TransactionProcessor.Database/Migrations/MySql/20230905184421_amountintransaction.cs create mode 100644 TransactionProcessor.Database/Migrations/MySql/20231115193921_recordestateoperatorreportingidwithtxn.Designer.cs create mode 100644 TransactionProcessor.Database/Migrations/MySql/20231115193921_recordestateoperatorreportingidwithtxn.cs create mode 100644 TransactionProcessor.Database/Migrations/MySql/20231228135806_addmerchantcontracttable.Designer.cs create mode 100644 TransactionProcessor.Database/Migrations/MySql/20231228135806_addmerchantcontracttable.cs create mode 100644 TransactionProcessor.Database/Migrations/MySql/20240210074240_floattables.Designer.cs create mode 100644 TransactionProcessor.Database/Migrations/MySql/20240210074240_floattables.cs create mode 100644 TransactionProcessor.Database/Migrations/MySql/20240313172001_fixstatementheaderindex.Designer.cs create mode 100644 TransactionProcessor.Database/Migrations/MySql/20240313172001_fixstatementheaderindex.cs create mode 100644 TransactionProcessor.Database/Migrations/MySql/20240420163033_merchantupdates.Designer.cs create mode 100644 TransactionProcessor.Database/Migrations/MySql/20240420163033_merchantupdates.cs create mode 100644 TransactionProcessor.Database/Migrations/MySql/20240425094256_record_operatators_at_readmodel.Designer.cs create mode 100644 TransactionProcessor.Database/Migrations/MySql/20240425094256_record_operatators_at_readmodel.cs create mode 100644 TransactionProcessor.Database/Migrations/MySql/20240425132550_record_operatators_at_readmodel_1.Designer.cs create mode 100644 TransactionProcessor.Database/Migrations/MySql/20240425132550_record_operatators_at_readmodel_1.cs create mode 100644 TransactionProcessor.Database/Migrations/MySql/20240425164125_record_operatators_at_readmodel_2.Designer.cs create mode 100644 TransactionProcessor.Database/Migrations/MySql/20240425164125_record_operatators_at_readmodel_2.cs create mode 100644 TransactionProcessor.Database/Migrations/MySql/20240501155336_make_voucher_operatoridentifier_nullable.Designer.cs create mode 100644 TransactionProcessor.Database/Migrations/MySql/20240501155336_make_voucher_operatoridentifier_nullable.cs create mode 100644 TransactionProcessor.Database/Migrations/MySql/20240606143402_20240605061637_remove_reportingids_from_transaction.Designer.cs create mode 100644 TransactionProcessor.Database/Migrations/MySql/20240606143402_20240605061637_remove_reportingids_from_transaction.cs create mode 100644 TransactionProcessor.Database/Migrations/MySql/EstateManagementMySqlContextModelSnapshot.cs create mode 100644 TransactionProcessor.Database/Migrations/SqlServer/20221115191516_InitialDatabase.Designer.cs create mode 100644 TransactionProcessor.Database/Migrations/SqlServer/20221115191516_InitialDatabase.cs create mode 100644 TransactionProcessor.Database/Migrations/SqlServer/20221116081939_somenullfixes.Designer.cs create mode 100644 TransactionProcessor.Database/Migrations/SqlServer/20221116081939_somenullfixes.cs create mode 100644 TransactionProcessor.Database/Migrations/SqlServer/20230116113030_recordproducttype.Designer.cs create mode 100644 TransactionProcessor.Database/Migrations/SqlServer/20230116113030_recordproducttype.cs create mode 100644 TransactionProcessor.Database/Migrations/SqlServer/20230630113913_task384_datamodelrefactoring.Designer.cs create mode 100644 TransactionProcessor.Database/Migrations/SqlServer/20230630113913_task384_datamodelrefactoring.cs create mode 100644 TransactionProcessor.Database/Migrations/SqlServer/20230717125919_handleSettlementProcessingStartedEvent.Designer.cs create mode 100644 TransactionProcessor.Database/Migrations/SqlServer/20230717125919_handleSettlementProcessingStartedEvent.cs create mode 100644 TransactionProcessor.Database/Migrations/SqlServer/20230717133118_merchantsettlementfee_missingindex.Designer.cs create mode 100644 TransactionProcessor.Database/Migrations/SqlServer/20230717133118_merchantsettlementfee_missingindex.cs create mode 100644 TransactionProcessor.Database/Migrations/SqlServer/20230721142728_addmerchanttosettlementtable.Designer.cs create mode 100644 TransactionProcessor.Database/Migrations/SqlServer/20230721142728_addmerchanttosettlementtable.cs create mode 100644 TransactionProcessor.Database/Migrations/SqlServer/20230801201426_storelastsaleagainstmerchant.Designer.cs create mode 100644 TransactionProcessor.Database/Migrations/SqlServer/20230801201426_storelastsaleagainstmerchant.cs create mode 100644 TransactionProcessor.Database/Migrations/SqlServer/20230905183930_amountintransaction.Designer.cs create mode 100644 TransactionProcessor.Database/Migrations/SqlServer/20230905183930_amountintransaction.cs create mode 100644 TransactionProcessor.Database/Migrations/SqlServer/20231115193804_recordestateoperatorreportingidwithtxn.Designer.cs create mode 100644 TransactionProcessor.Database/Migrations/SqlServer/20231115193804_recordestateoperatorreportingidwithtxn.cs create mode 100644 TransactionProcessor.Database/Migrations/SqlServer/20231228135707_addmerchantcontracttable.Designer.cs create mode 100644 TransactionProcessor.Database/Migrations/SqlServer/20231228135707_addmerchantcontracttable.cs create mode 100644 TransactionProcessor.Database/Migrations/SqlServer/20240210074115_floattables.Designer.cs create mode 100644 TransactionProcessor.Database/Migrations/SqlServer/20240210074115_floattables.cs create mode 100644 TransactionProcessor.Database/Migrations/SqlServer/20240313170318_fixstatementheaderindex.Designer.cs create mode 100644 TransactionProcessor.Database/Migrations/SqlServer/20240313170318_fixstatementheaderindex.cs create mode 100644 TransactionProcessor.Database/Migrations/SqlServer/20240420162900_merchantupdates.Designer.cs create mode 100644 TransactionProcessor.Database/Migrations/SqlServer/20240420162900_merchantupdates.cs create mode 100644 TransactionProcessor.Database/Migrations/SqlServer/20240425094035_record_operatators_at_readmodel.Designer.cs create mode 100644 TransactionProcessor.Database/Migrations/SqlServer/20240425094035_record_operatators_at_readmodel.cs create mode 100644 TransactionProcessor.Database/Migrations/SqlServer/20240425132448_record_operatators_at_readmodel_1.Designer.cs create mode 100644 TransactionProcessor.Database/Migrations/SqlServer/20240425132448_record_operatators_at_readmodel_1.cs create mode 100644 TransactionProcessor.Database/Migrations/SqlServer/20240425163935_record_operatators_at_readmodel_2.Designer.cs create mode 100644 TransactionProcessor.Database/Migrations/SqlServer/20240425163935_record_operatators_at_readmodel_2.cs create mode 100644 TransactionProcessor.Database/Migrations/SqlServer/20240501154042_make_voucher_operatoridentifier_nullable.Designer.cs create mode 100644 TransactionProcessor.Database/Migrations/SqlServer/20240501154042_make_voucher_operatoridentifier_nullable.cs create mode 100644 TransactionProcessor.Database/Migrations/SqlServer/20240605061637_remove_reportingids_from_transaction.Designer.cs create mode 100644 TransactionProcessor.Database/Migrations/SqlServer/20240605061637_remove_reportingids_from_transaction.cs create mode 100644 TransactionProcessor.Database/Migrations/SqlServer/20240605133603_remove_reportingids_from_transaction_sp1.Designer.cs create mode 100644 TransactionProcessor.Database/Migrations/SqlServer/20240605133603_remove_reportingids_from_transaction_sp1.cs create mode 100644 TransactionProcessor.Database/Migrations/SqlServer/20240607093059_summary_first_cut.Designer.cs create mode 100644 TransactionProcessor.Database/Migrations/SqlServer/20240607093059_summary_first_cut.cs create mode 100644 TransactionProcessor.Database/Migrations/SqlServer/EstateManagementSqlServerContextModelSnapshot.cs create mode 100644 TransactionProcessor.Database/SeedingScripts/CalendarSeeding.sql create mode 100644 TransactionProcessor.Database/SeedingScripts/ResponseCodeSeeding.sql create mode 100644 TransactionProcessor.Database/StoredProcedures/SqlServer/spBuildHistoricTransactions.sql create mode 100644 TransactionProcessor.Database/StoredProcedures/SqlServer/spBuildSettlementSummary.sql create mode 100644 TransactionProcessor.Database/StoredProcedures/SqlServer/spBuildTodaysTransactions.sql create mode 100644 TransactionProcessor.Database/TransactionProcessor.Database.csproj create mode 100644 TransactionProcessor.Database/ViewEntities/SettlementView.cs create mode 100644 TransactionProcessor.Database/Views/MySql/Priority1/uvwSettlements.View.sql create mode 100644 TransactionProcessor.Database/Views/SqlServer/Priority1/uvwSettlements.View.sql create mode 100644 TransactionProcessor.Estate.DomainEvents/EstateDomainEvents.cs create mode 100644 TransactionProcessor.Estate.DomainEvents/TransactionProcessor.Estate.DomainEvents.csproj delete mode 100644 TransactionProcessor.FloatAggregate/FloatActivityAggregate.cs delete mode 100644 TransactionProcessor.FloatAggregate/TransactionProcessor.FloatAggregate.csproj create mode 100644 TransactionProcessor.IntegrationTesting.Helpers/EstateDetails.cs create mode 100644 TransactionProcessor.IntegrationTests/Features/Estate.feature create mode 100644 TransactionProcessor.IntegrationTests/Features/Estate.feature.cs create mode 100644 TransactionProcessor.Models/Estate.cs create mode 100644 TransactionProcessor.Models/Operator.cs create mode 100644 TransactionProcessor.Models/SecurityUser.cs delete mode 100644 TransactionProcessor.ReconciliationAggregate.Tests/TransactionProcessor.ReconciliationAggregate.Tests.csproj delete mode 100644 TransactionProcessor.ReconciliationAggregate/TransactionProcessor.ReconciliationAggregate.csproj create mode 100644 TransactionProcessor.Repository/ITransactionProcessorReadModelRepository.cs create mode 100644 TransactionProcessor.Repository/ModelFactory.cs create mode 100644 TransactionProcessor.Repository/TransactionProcessor.Repository.csproj delete mode 100644 TransactionProcessor.SettlementAggregates.Tests/TransactionProcessor.SettlementAggregates.Tests.csproj delete mode 100644 TransactionProcessor.SettlementAggregates/TransactionProcessor.SettlementAggregates.csproj delete mode 100644 TransactionProcessor.TransactionAggregate.Tests/TransactionProcessor.TransactionAggregate.Tests.csproj delete mode 100644 TransactionProcessor.TransactionAgrgegate/TransactionProcessor.TransactionAggregate.csproj delete mode 100644 TransactionProcessor.VoucherAggregate.Tests/TransactionProcessor.VoucherAggregate.Tests.csproj delete mode 100644 TransactionProcessor.VoucherAggregate/TransactionProcessor.VoucherAggregate.csproj create mode 100644 TransactionProcessor/Controllers/ContractController.cs create mode 100644 TransactionProcessor/Controllers/EstateController.cs delete mode 100644 TransactionProcessor/Factories/IModelFactory.cs diff --git a/TransactionProcessor.Aggregates.Tests/EstateAggregateTests.cs b/TransactionProcessor.Aggregates.Tests/EstateAggregateTests.cs new file mode 100644 index 00000000..7584e562 --- /dev/null +++ b/TransactionProcessor.Aggregates.Tests/EstateAggregateTests.cs @@ -0,0 +1,245 @@ +using Shouldly; +using TransactionProcessor.Models; +using TransactionProcessor.Testing; + +namespace TransactionProcessor.Aggregates.Tests +{ + public class EstateAggregateTests + { + [Fact] + public void EstateAggregate_CanBeCreated_IsCreated() + { + EstateAggregate aggregate = EstateAggregate.Create(TestData.EstateId); + + aggregate.AggregateId.ShouldBe(TestData.EstateId); + } + + [Fact] + public void EstateAggregate_Create_IsCreated() + { + EstateAggregate aggregate = EstateAggregate.Create(TestData.EstateId); + aggregate.Create(TestData.EstateName); + aggregate.GenerateReference(); + + aggregate.AggregateId.ShouldBe(TestData.EstateId); + aggregate.EstateName.ShouldBe(TestData.EstateName); + aggregate.IsCreated.ShouldBeTrue(); + aggregate.EstateReference.ShouldBe(TestData.EstateReference); + } + + [Theory] + [InlineData("")] + [InlineData(null)] + public void EstateAggregate_Create_InvalidEstateName_ErrorThrown(String estateName) + { + EstateAggregate aggregate = EstateAggregate.Create(TestData.EstateId); + ArgumentNullException exception = Should.Throw(() => + { + aggregate.Create(estateName); + }); + + exception.Message.ShouldContain("Estate name must be provided when registering a new estate"); + } + + [Fact] + public void EstateAggregate_Create_EstateAlreadyCreated_NoErrorThrown() + { + EstateAggregate aggregate = EstateAggregate.Create(TestData.EstateId); + aggregate.Create(TestData.EstateName); + + Should.NotThrow(() => + { + aggregate.Create(TestData.EstateName); + }); + } + + [Fact] + public void EstateAggregate_GenerateReference_CalledTwice_NoErrorThrown() + { + EstateAggregate aggregate = EstateAggregate.Create(TestData.EstateId); + aggregate.Create(TestData.EstateName); + aggregate.GenerateReference(); + + Should.NotThrow(() => + { + aggregate.GenerateReference(); + }); + } + + [Fact] + public void EstateAggregate_GetEstate_NoOperators_EstateIsReturned() + { + EstateAggregate aggregate = EstateAggregate.Create(TestData.EstateId); + aggregate.Create(TestData.EstateName); + aggregate.GenerateReference(); + TransactionProcessor.Models.Estate model = aggregate.GetEstate(); + + model.EstateId.ShouldBe(TestData.EstateId); + model.Name.ShouldBe(TestData.EstateName); + model.Reference.ShouldBe(TestData.EstateReference); + model.Operators.ShouldBeEmpty(); + } + + [Fact] + public void EstateAggregate_GetEstate_WithAnOperator_EstateIsReturned() + { + EstateAggregate aggregate = EstateAggregate.Create(TestData.EstateId); + aggregate.Create(TestData.EstateName); + aggregate.GenerateReference(); + aggregate.AddOperator(TestData.OperatorId); + + TransactionProcessor.Models.Estate model = aggregate.GetEstate(); + + model.EstateId.ShouldBe(TestData.EstateId); + model.Name.ShouldBe(TestData.EstateName); + model.Reference.ShouldBe(TestData.EstateReference); + model.Operators.ShouldHaveSingleItem(); + + EstateOperator? @operator =model.Operators.Single(); + @operator.OperatorId.ShouldBe(TestData.OperatorId); + } + + [Fact] + public void EstateAggregate_GetEstate_NoSecurityUsers_EstateIsReturned() + { + EstateAggregate aggregate = EstateAggregate.Create(TestData.EstateId); + aggregate.Create(TestData.EstateName); + aggregate.GenerateReference(); + TransactionProcessor.Models.Estate model = aggregate.GetEstate(); + + model.EstateId.ShouldBe(TestData.EstateId); + model.Name.ShouldBe(TestData.EstateName); + model.Reference.ShouldBe(TestData.EstateReference); + model.Operators.ShouldBeEmpty(); + model.SecurityUsers.ShouldBeEmpty(); + } + + [Fact] + public void EstateAggregate_GetEstate_WithASecurityUser_EstateIsReturned() + { + EstateAggregate aggregate = EstateAggregate.Create(TestData.EstateId); + aggregate.Create(TestData.EstateName); + aggregate.GenerateReference(); + aggregate.AddSecurityUser(TestData.SecurityUserId,TestData.EstateUserEmailAddress); + + TransactionProcessor.Models.Estate model = aggregate.GetEstate(); + + model.EstateId.ShouldBe(TestData.EstateId); + model.Name.ShouldBe(TestData.EstateName); + model.Reference.ShouldBe(TestData.EstateReference); + model.SecurityUsers.ShouldHaveSingleItem(); + + SecurityUser securityUser = model.SecurityUsers.Single(); + securityUser.SecurityUserId.ShouldBe(TestData.SecurityUserId); + securityUser.EmailAddress.ShouldBe(TestData.EstateUserEmailAddress); + } + + [Fact] + public void EstateAggregate_AddOperatorToEstate_OperatorIsAdded() + { + EstateAggregate aggregate = EstateAggregate.Create(TestData.EstateId); + aggregate.Create(TestData.EstateName); + + aggregate.AddOperator(TestData.OperatorId); + + TransactionProcessor.Models.Estate estate = aggregate.GetEstate(); + estate.Operators.ShouldHaveSingleItem(); + estate.Operators.Single().OperatorId.ShouldBe(TestData.OperatorId); + estate.Operators.Single().IsDeleted.ShouldBeFalse(); + } + + [Fact] + public void EstateAggregate_AddOperatorToEstate_EstateNotCreated_ErrorThrown() + { + EstateAggregate aggregate = EstateAggregate.Create(TestData.EstateId); + + InvalidOperationException exception = Should.Throw(() => + { + aggregate.AddOperator(TestData.OperatorId); + }); + + exception.Message.ShouldContain("Estate has not been created"); + } + + [Fact] + public void EstateAggregate_AddOperatorToEstate_OperatorWithIdAlreadyAdded_ErrorThrown() + { + EstateAggregate aggregate = EstateAggregate.Create(TestData.EstateId); + aggregate.Create(TestData.EstateName); + aggregate.AddOperator(TestData.OperatorId); + + InvalidOperationException exception = Should.Throw(() => + { + aggregate.AddOperator(TestData.OperatorId); + }); + + exception.Message.ShouldContain($"Duplicate operator details are not allowed, an operator already exists on this estate with Id [{TestData.OperatorId}]"); + } + + [Fact] + public void EstateAggregate_AddSecurityUserToEstate_SecurityUserIsAdded() + { + EstateAggregate aggregate = EstateAggregate.Create(TestData.EstateId); + aggregate.Create(TestData.EstateName); + aggregate.AddSecurityUser(TestData.SecurityUserId, TestData.EstateUserEmailAddress); + + TransactionProcessor.Models.Estate estate = aggregate.GetEstate(); + estate.SecurityUsers.ShouldHaveSingleItem(); + estate.SecurityUsers.Single().EmailAddress.ShouldBe(TestData.EstateUserEmailAddress); + } + + [Fact] + public void EstateAggregate_AddSecurityUserToEstate_EstateNotCreated_ErrorThrown() + { + EstateAggregate aggregate = EstateAggregate.Create(TestData.EstateId); + + InvalidOperationException exception = Should.Throw(() => + { + aggregate.AddSecurityUser(TestData.SecurityUserId, TestData.EstateUserEmailAddress); + }); + + exception.Message.ShouldContain("Estate has not been created"); + } + + [Fact] + public void EstateAggregate_RemoveOperatorFromEstate_OperatorIsAdded() + { + EstateAggregate aggregate = EstateAggregate.Create(TestData.EstateId); + aggregate.Create(TestData.EstateName); + aggregate.AddOperator(TestData.OperatorId); + + aggregate.RemoveOperator(TestData.OperatorId); + + TransactionProcessor.Models.Estate estate = aggregate.GetEstate(); + estate.Operators.ShouldHaveSingleItem(); + estate.Operators.Single().IsDeleted.ShouldBeTrue(); + } + + [Fact] + public void EstateAggregate_RemoveOperatorFromEstate_EstateNotCreated_ErrorThrown() + { + EstateAggregate aggregate = EstateAggregate.Create(TestData.EstateId); + + InvalidOperationException exception = Should.Throw(() => + { + aggregate.RemoveOperator(TestData.OperatorId); + }); + + exception.Message.ShouldContain("Estate has not been created"); + } + + [Fact] + public void EstateAggregate_RemoveOperatorFromEstate_OperatorWithIdNotAlreadyAdded_ErrorThrown() + { + EstateAggregate aggregate = EstateAggregate.Create(TestData.EstateId); + aggregate.Create(TestData.EstateName); + + InvalidOperationException exception = Should.Throw(() => + { + aggregate.RemoveOperator(TestData.OperatorId); + }); + + exception.Message.ShouldContain($"Operator not added to this Estate with Id [{TestData.OperatorId}]"); + } + } +} diff --git a/TransactionProcessor.FloatAggregate.Tests/FloatActivityAggregateTests.cs b/TransactionProcessor.Aggregates.Tests/FloatActivityAggregateTests.cs similarity index 97% rename from TransactionProcessor.FloatAggregate.Tests/FloatActivityAggregateTests.cs rename to TransactionProcessor.Aggregates.Tests/FloatActivityAggregateTests.cs index ce88ee3e..e669b5ec 100644 --- a/TransactionProcessor.FloatAggregate.Tests/FloatActivityAggregateTests.cs +++ b/TransactionProcessor.Aggregates.Tests/FloatActivityAggregateTests.cs @@ -1,8 +1,7 @@ using Shouldly; using TransactionProcessor.Testing; -using Xunit; -namespace TransactionProcessor.FloatAggregate.Tests; +namespace TransactionProcessor.Aggregates.Tests; public class FloatActivityAggregateTests { [Fact] diff --git a/TransactionProcessor.FloatAggregate.Tests/FloatAggregateTests.cs b/TransactionProcessor.Aggregates.Tests/FloatAggregateTests.cs similarity index 82% rename from TransactionProcessor.FloatAggregate.Tests/FloatAggregateTests.cs rename to TransactionProcessor.Aggregates.Tests/FloatAggregateTests.cs index fdae018d..f3c90d3c 100644 --- a/TransactionProcessor.FloatAggregate.Tests/FloatAggregateTests.cs +++ b/TransactionProcessor.Aggregates.Tests/FloatAggregateTests.cs @@ -1,17 +1,14 @@ -namespace TransactionProcessor.FloatAggregate.Tests -{ - using Shouldly; - using Testing; - using TransactionProcessor.Float.DomainEvents; - using TransactionProcessor.Settlement.DomainEvents; - using Xunit; +using Shouldly; +using TransactionProcessor.Testing; +namespace TransactionProcessor.Aggregates.Tests +{ public class FloatAggregateTests { [Fact] public void FloatAggregate_CanBeCreated_IsCreated() { - FloatAggregate aggregate = FloatAggregate.Create(TestData.FloatAggregateId); + Aggregates.FloatAggregate aggregate = Aggregates.FloatAggregate.Create(TestData.FloatAggregateId); aggregate.AggregateId.ShouldBe(TestData.FloatAggregateId); } @@ -19,7 +16,7 @@ public void FloatAggregate_CanBeCreated_IsCreated() [Fact] public void FloatAggregate_CreateFloat_IsCreated() { - FloatAggregate aggregate = FloatAggregate.Create(TestData.FloatAggregateId); + Aggregates.FloatAggregate aggregate = Aggregates.FloatAggregate.Create(TestData.FloatAggregateId); aggregate.CreateFloat(TestData.EstateId, TestData.ContractId, TestData.ProductId, TestData.FloatCreatedDateTime); aggregate.AggregateId.ShouldBe(TestData.FloatAggregateId); @@ -32,7 +29,7 @@ public void FloatAggregate_CreateFloat_IsCreated() [Fact] public void FloatAggregate_CreateFloat_FloatAlreadyCreated_ErrorThrown() { - FloatAggregate aggregate = FloatAggregate.Create(TestData.FloatAggregateId); + Aggregates.FloatAggregate aggregate = Aggregates.FloatAggregate.Create(TestData.FloatAggregateId); aggregate.CreateFloat(TestData.EstateId, TestData.ContractId, TestData.ProductId, TestData.FloatCreatedDateTime); Should.Throw(() => { @@ -43,7 +40,7 @@ public void FloatAggregate_CreateFloat_FloatAlreadyCreated_ErrorThrown() [Fact] public void FloatAggregate_RecordCreditPurchase_CreditPurchaseIsRecorded() { - FloatAggregate aggregate = FloatAggregate.Create(TestData.FloatAggregateId); + Aggregates.FloatAggregate aggregate = Aggregates.FloatAggregate.Create(TestData.FloatAggregateId); aggregate.CreateFloat(TestData.EstateId, TestData.ContractId, TestData.ProductId, TestData.FloatCreatedDateTime); aggregate.RecordCreditPurchase(DateTime.Now, 1000, 900); @@ -56,7 +53,7 @@ public void FloatAggregate_RecordCreditPurchase_CreditPurchaseIsRecorded() [Fact] public void FloatAggregate_RecordCreditPurchase_FloatNotCreated_ErrorThrown() { - FloatAggregate aggregate = FloatAggregate.Create(TestData.FloatAggregateId); + Aggregates.FloatAggregate aggregate = Aggregates.FloatAggregate.Create(TestData.FloatAggregateId); Should.Throw(() => { aggregate.RecordCreditPurchase(DateTime.Now, 1000, 900); @@ -66,7 +63,7 @@ public void FloatAggregate_RecordCreditPurchase_FloatNotCreated_ErrorThrown() [Fact] public void FloatAggregate_RecordCreditPurchase_MultipleCreditPurchases_AllCreditPurchasesAreRecorded() { - FloatAggregate aggregate = FloatAggregate.Create(TestData.FloatAggregateId); + Aggregates.FloatAggregate aggregate = Aggregates.FloatAggregate.Create(TestData.FloatAggregateId); aggregate.CreateFloat(TestData.EstateId, TestData.ContractId, TestData.ProductId, TestData.FloatCreatedDateTime); aggregate.RecordCreditPurchase(DateTime.Now, 1000, 900); @@ -99,7 +96,7 @@ public void FloatAggregate_RecordCreditPurchase_MultipleCreditPurchases_AllCredi [Fact] public void FloatAggregate_RecordCreditPurchase_DuplicateCreditPurchase_ErrorThrown() { - FloatAggregate aggregate = FloatAggregate.Create(TestData.FloatAggregateId); + Aggregates.FloatAggregate aggregate = Aggregates.FloatAggregate.Create(TestData.FloatAggregateId); aggregate.CreateFloat(TestData.EstateId, TestData.ContractId, TestData.ProductId, TestData.FloatCreatedDateTime); DateTime purchaseDateTime = DateTime.Now; aggregate.RecordCreditPurchase(purchaseDateTime, 1000, 900); diff --git a/TransactionProcessor.ReconciliationAggregate.Tests/ReconciliationAggregateTests.cs b/TransactionProcessor.Aggregates.Tests/ReconciliationAggregateTests.cs similarity index 83% rename from TransactionProcessor.ReconciliationAggregate.Tests/ReconciliationAggregateTests.cs rename to TransactionProcessor.Aggregates.Tests/ReconciliationAggregateTests.cs index 393155be..3077ca44 100644 --- a/TransactionProcessor.ReconciliationAggregate.Tests/ReconciliationAggregateTests.cs +++ b/TransactionProcessor.Aggregates.Tests/ReconciliationAggregateTests.cs @@ -1,20 +1,14 @@ -using System; -using System.Collections.Generic; -using System.Text; +using Shouldly; +using TransactionProcessor.Testing; -namespace TransactionProcessor.ReconciliationAggregate.Tests +namespace TransactionProcessor.Aggregates.Tests { - using Shouldly; - using Testing; - using TransactionAggregate; - using Xunit; - public class ReconciliationAggregateTests { [Fact] public void ReconciliationAggregate_CanBeCreated_IsCreated() { - ReconciliationAggregate aggregate = ReconciliationAggregate.Create(TestData.TransactionId); + Aggregates.ReconciliationAggregate aggregate = Aggregates.ReconciliationAggregate.Create(TestData.TransactionId); aggregate.AggregateId.ShouldBe(TestData.TransactionId); } @@ -22,7 +16,7 @@ public void ReconciliationAggregate_CanBeCreated_IsCreated() [Fact] public void ReconciliationAggregate_StartReconciliation_ReconciliationIsStarted() { - ReconciliationAggregate reconciliationAggregate = ReconciliationAggregate.Create(TestData.TransactionId); + Aggregates.ReconciliationAggregate reconciliationAggregate = Aggregates.ReconciliationAggregate.Create(TestData.TransactionId); reconciliationAggregate.StartReconciliation(TestData.TransactionDateTime, TestData.EstateId, TestData.MerchantId); @@ -39,7 +33,7 @@ public void ReconciliationAggregate_StartReconciliation_InvalidData_ErrorThrown( Boolean validEstateId, Boolean validMerchantId) { - ReconciliationAggregate reconciliationAggregate = ReconciliationAggregate.Create(TestData.TransactionId); + Aggregates.ReconciliationAggregate reconciliationAggregate = Aggregates.ReconciliationAggregate.Create(TestData.TransactionId); DateTime transactionDateTime = validDateTime ? TestData.TransactionDateTime : DateTime.MinValue; Guid estateId = validEstateId ? TestData.EstateId : Guid.Empty; @@ -51,7 +45,7 @@ public void ReconciliationAggregate_StartReconciliation_InvalidData_ErrorThrown( [Fact] public void ReconciliationAggregate_StartReconciliation_ReconciliationAlreadyStarted_ErrorThrown() { - ReconciliationAggregate reconciliationAggregate = ReconciliationAggregate.Create(TestData.TransactionId); + Aggregates.ReconciliationAggregate reconciliationAggregate = Aggregates.ReconciliationAggregate.Create(TestData.TransactionId); reconciliationAggregate.StartReconciliation(TestData.TransactionDateTime, TestData.EstateId, TestData.MerchantId); @@ -64,7 +58,7 @@ public void ReconciliationAggregate_StartReconciliation_ReconciliationAlreadySta [Fact] public void ReconciliationAggregate_StartReconciliation_ReconciliationAlreadyCompleted_ErrorThrown() { - ReconciliationAggregate reconciliationAggregate = ReconciliationAggregate.Create(TestData.TransactionId); + Aggregates.ReconciliationAggregate reconciliationAggregate = Aggregates.ReconciliationAggregate.Create(TestData.TransactionId); reconciliationAggregate.StartReconciliation(TestData.TransactionDateTime, TestData.EstateId, TestData.MerchantId); reconciliationAggregate.RecordOverallTotals(TestData.ReconciliationTransactionCount, TestData.ReconciliationTransactionValue); @@ -81,7 +75,7 @@ public void ReconciliationAggregate_StartReconciliation_ReconciliationAlreadyCom [Fact] public void ReconciliationAggregate_RecordOverallTotals_OverallTotalsAreRecorded() { - ReconciliationAggregate reconciliationAggregate = ReconciliationAggregate.Create(TestData.TransactionId); + Aggregates.ReconciliationAggregate reconciliationAggregate = Aggregates.ReconciliationAggregate.Create(TestData.TransactionId); reconciliationAggregate.StartReconciliation(TestData.TransactionDateTime, TestData.EstateId, TestData.MerchantId); reconciliationAggregate.RecordOverallTotals(TestData.ReconciliationTransactionCount, TestData.ReconciliationTransactionValue); @@ -93,7 +87,7 @@ public void ReconciliationAggregate_RecordOverallTotals_OverallTotalsAreRecorded [Fact] public void ReconciliationAggregate_RecordOverallTotals_ReconciliationNotStarted_ErrorThrown() { - ReconciliationAggregate reconciliationAggregate = ReconciliationAggregate.Create(TestData.TransactionId); + Aggregates.ReconciliationAggregate reconciliationAggregate = Aggregates.ReconciliationAggregate.Create(TestData.TransactionId); Should.Throw(() => { @@ -105,7 +99,7 @@ public void ReconciliationAggregate_RecordOverallTotals_ReconciliationNotStarted [Fact] public void ReconciliationAggregate_RecordOverallTotals_ReconciliationAlreadyCompleted_ErrorThrown() { - ReconciliationAggregate reconciliationAggregate = ReconciliationAggregate.Create(TestData.TransactionId); + Aggregates.ReconciliationAggregate reconciliationAggregate = Aggregates.ReconciliationAggregate.Create(TestData.TransactionId); reconciliationAggregate.StartReconciliation(TestData.TransactionDateTime, TestData.EstateId, TestData.MerchantId); reconciliationAggregate.RecordOverallTotals(TestData.ReconciliationTransactionCount, TestData.ReconciliationTransactionValue); @@ -122,7 +116,7 @@ public void ReconciliationAggregate_RecordOverallTotals_ReconciliationAlreadyCom [Fact] public void ReconciliationAggregate_Authorise_ReconciliationIsAuthorised() { - ReconciliationAggregate reconciliationAggregate = ReconciliationAggregate.Create(TestData.TransactionId); + Aggregates.ReconciliationAggregate reconciliationAggregate = Aggregates.ReconciliationAggregate.Create(TestData.TransactionId); reconciliationAggregate.StartReconciliation(TestData.TransactionDateTime, TestData.EstateId, TestData.MerchantId); reconciliationAggregate.RecordOverallTotals(TestData.ReconciliationTransactionCount, TestData.ReconciliationTransactionValue); @@ -136,7 +130,7 @@ public void ReconciliationAggregate_Authorise_ReconciliationIsAuthorised() [Fact] public void ReconciliationAggregate_Authorise_ReconciliationNotStarted_ErrorThrown() { - ReconciliationAggregate reconciliationAggregate = ReconciliationAggregate.Create(TestData.TransactionId); + Aggregates.ReconciliationAggregate reconciliationAggregate = Aggregates.ReconciliationAggregate.Create(TestData.TransactionId); Should.Throw(() => { @@ -147,7 +141,7 @@ public void ReconciliationAggregate_Authorise_ReconciliationNotStarted_ErrorThro [Fact] public void ReconciliationAggregate_Authorise_ReconciliationAlreadyAuthorised_ErrorThrown() { - ReconciliationAggregate reconciliationAggregate = ReconciliationAggregate.Create(TestData.TransactionId); + Aggregates.ReconciliationAggregate reconciliationAggregate = Aggregates.ReconciliationAggregate.Create(TestData.TransactionId); reconciliationAggregate.StartReconciliation(TestData.TransactionDateTime, TestData.EstateId, TestData.MerchantId); reconciliationAggregate.RecordOverallTotals(TestData.ReconciliationTransactionCount, TestData.ReconciliationTransactionValue); @@ -162,7 +156,7 @@ public void ReconciliationAggregate_Authorise_ReconciliationAlreadyAuthorised_Er [Fact] public void ReconciliationAggregate_Authorise_ReconciliationAlreadyDeclined_ErrorThrown() { - ReconciliationAggregate reconciliationAggregate = ReconciliationAggregate.Create(TestData.TransactionId); + Aggregates.ReconciliationAggregate reconciliationAggregate = Aggregates.ReconciliationAggregate.Create(TestData.TransactionId); reconciliationAggregate.StartReconciliation(TestData.TransactionDateTime, TestData.EstateId, TestData.MerchantId); reconciliationAggregate.RecordOverallTotals(TestData.ReconciliationTransactionCount, TestData.ReconciliationTransactionValue); @@ -177,7 +171,7 @@ public void ReconciliationAggregate_Authorise_ReconciliationAlreadyDeclined_Erro [Fact] public void ReconciliationAggregate_Authorise_ReconciliationAlreadyCompleted_ErrorThrown() { - ReconciliationAggregate reconciliationAggregate = ReconciliationAggregate.Create(TestData.TransactionId); + Aggregates.ReconciliationAggregate reconciliationAggregate = Aggregates.ReconciliationAggregate.Create(TestData.TransactionId); reconciliationAggregate.StartReconciliation(TestData.TransactionDateTime, TestData.EstateId, TestData.MerchantId); reconciliationAggregate.RecordOverallTotals(TestData.ReconciliationTransactionCount, TestData.ReconciliationTransactionValue); @@ -193,7 +187,7 @@ public void ReconciliationAggregate_Authorise_ReconciliationAlreadyCompleted_Err [Fact] public void ReconciliationAggregate_Decline_ReconciliationIsDeclined() { - ReconciliationAggregate reconciliationAggregate = ReconciliationAggregate.Create(TestData.TransactionId); + Aggregates.ReconciliationAggregate reconciliationAggregate = Aggregates.ReconciliationAggregate.Create(TestData.TransactionId); reconciliationAggregate.StartReconciliation(TestData.TransactionDateTime, TestData.EstateId, TestData.MerchantId); reconciliationAggregate.RecordOverallTotals(TestData.ReconciliationTransactionCount, TestData.ReconciliationTransactionValue); @@ -207,7 +201,7 @@ public void ReconciliationAggregate_Decline_ReconciliationIsDeclined() [Fact] public void ReconciliationAggregate_Decline_ReconciliationNotStarted_ErrorThrown() { - ReconciliationAggregate reconciliationAggregate = ReconciliationAggregate.Create(TestData.TransactionId); + Aggregates.ReconciliationAggregate reconciliationAggregate = Aggregates.ReconciliationAggregate.Create(TestData.TransactionId); Should.Throw(() => { @@ -218,7 +212,7 @@ public void ReconciliationAggregate_Decline_ReconciliationNotStarted_ErrorThrown [Fact] public void ReconciliationAggregate_Decline_ReconciliationAlreadyAuthorised_ErrorThrown() { - ReconciliationAggregate reconciliationAggregate = ReconciliationAggregate.Create(TestData.TransactionId); + Aggregates.ReconciliationAggregate reconciliationAggregate = Aggregates.ReconciliationAggregate.Create(TestData.TransactionId); reconciliationAggregate.StartReconciliation(TestData.TransactionDateTime, TestData.EstateId, TestData.MerchantId); reconciliationAggregate.RecordOverallTotals(TestData.ReconciliationTransactionCount, TestData.ReconciliationTransactionValue); @@ -233,7 +227,7 @@ public void ReconciliationAggregate_Decline_ReconciliationAlreadyAuthorised_Erro [Fact] public void ReconciliationAggregate_Decline_ReconciliationAlreadyDecline_ErrorThrown() { - ReconciliationAggregate reconciliationAggregate = ReconciliationAggregate.Create(TestData.TransactionId); + Aggregates.ReconciliationAggregate reconciliationAggregate = Aggregates.ReconciliationAggregate.Create(TestData.TransactionId); reconciliationAggregate.StartReconciliation(TestData.TransactionDateTime, TestData.EstateId, TestData.MerchantId); reconciliationAggregate.RecordOverallTotals(TestData.ReconciliationTransactionCount, TestData.ReconciliationTransactionValue); @@ -248,7 +242,7 @@ public void ReconciliationAggregate_Decline_ReconciliationAlreadyDecline_ErrorTh [Fact] public void ReconciliationAggregate_Decline_ReconciliationAlreadyCompleted_ErrorThrown() { - ReconciliationAggregate reconciliationAggregate = ReconciliationAggregate.Create(TestData.TransactionId); + Aggregates.ReconciliationAggregate reconciliationAggregate = Aggregates.ReconciliationAggregate.Create(TestData.TransactionId); reconciliationAggregate.StartReconciliation(TestData.TransactionDateTime, TestData.EstateId, TestData.MerchantId); reconciliationAggregate.RecordOverallTotals(TestData.ReconciliationTransactionCount, TestData.ReconciliationTransactionValue); @@ -266,7 +260,7 @@ public void ReconciliationAggregate_Decline_ReconciliationAlreadyCompleted_Error [InlineData(false)] public void ReconciliationAggregate_CompleteReconciliation_ReconciliationIsCompleted(Boolean isAuthorised) { - ReconciliationAggregate reconciliationAggregate = ReconciliationAggregate.Create(TestData.TransactionId); + Aggregates.ReconciliationAggregate reconciliationAggregate = Aggregates.ReconciliationAggregate.Create(TestData.TransactionId); reconciliationAggregate.StartReconciliation(TestData.TransactionDateTime, TestData.EstateId, TestData.MerchantId); reconciliationAggregate.RecordOverallTotals(TestData.ReconciliationTransactionCount, TestData.ReconciliationTransactionValue); @@ -289,7 +283,7 @@ public void ReconciliationAggregate_CompleteReconciliation_ReconciliationIsCompl [Fact] public void ReconciliationAggregate_CompleteReconciliation_ReconciliationNotStarted_ErrorThrown() { - ReconciliationAggregate reconciliationAggregate = ReconciliationAggregate.Create(TestData.TransactionId); + Aggregates.ReconciliationAggregate reconciliationAggregate = Aggregates.ReconciliationAggregate.Create(TestData.TransactionId); Should.Throw(() => { @@ -300,7 +294,7 @@ public void ReconciliationAggregate_CompleteReconciliation_ReconciliationNotStar [Fact] public void ReconciliationAggregate_CompleteReconciliation_NotAuthorisedOrDeclined_ErrorThrown() { - ReconciliationAggregate reconciliationAggregate = ReconciliationAggregate.Create(TestData.TransactionId); + Aggregates.ReconciliationAggregate reconciliationAggregate = Aggregates.ReconciliationAggregate.Create(TestData.TransactionId); reconciliationAggregate.StartReconciliation(TestData.TransactionDateTime, TestData.EstateId, TestData.MerchantId); reconciliationAggregate.RecordOverallTotals(TestData.ReconciliationTransactionCount, TestData.ReconciliationTransactionValue); @@ -316,7 +310,7 @@ public void ReconciliationAggregate_CompleteReconciliation_NotAuthorisedOrDeclin [InlineData(false)] public void ReconciliationAggregate_CompleteReconciliation_ReconciliationAlreadyCompleted(Boolean isAuthorised) { - ReconciliationAggregate reconciliationAggregate = ReconciliationAggregate.Create(TestData.TransactionId); + Aggregates.ReconciliationAggregate reconciliationAggregate = Aggregates.ReconciliationAggregate.Create(TestData.TransactionId); reconciliationAggregate.StartReconciliation(TestData.TransactionDateTime, TestData.EstateId, TestData.MerchantId); reconciliationAggregate.RecordOverallTotals(TestData.ReconciliationTransactionCount, TestData.ReconciliationTransactionValue); diff --git a/TransactionProcessor.SettlementAggregates.Tests/SettlementAggregateTests.cs b/TransactionProcessor.Aggregates.Tests/SettlementAggregateTests.cs similarity index 98% rename from TransactionProcessor.SettlementAggregates.Tests/SettlementAggregateTests.cs rename to TransactionProcessor.Aggregates.Tests/SettlementAggregateTests.cs index f7a05720..a6d8a2cc 100644 --- a/TransactionProcessor.SettlementAggregates.Tests/SettlementAggregateTests.cs +++ b/TransactionProcessor.Aggregates.Tests/SettlementAggregateTests.cs @@ -1,11 +1,8 @@ -namespace TransactionProcessor.SettlementAggregates.Tests -{ - using System; - using Shouldly; - using Testing; - using TransactionAggregate; - using Xunit; +using Shouldly; +using TransactionProcessor.Testing; +namespace TransactionProcessor.Aggregates.Tests +{ public class SettlementAggregateTests { [Fact] diff --git a/TransactionProcessor.TransactionAggregate.Tests/TransactionAggregateTests.cs b/TransactionProcessor.Aggregates.Tests/TransactionAggregateTests.cs similarity index 91% rename from TransactionProcessor.TransactionAggregate.Tests/TransactionAggregateTests.cs rename to TransactionProcessor.Aggregates.Tests/TransactionAggregateTests.cs index 16090c4b..2e7091b7 100644 --- a/TransactionProcessor.TransactionAggregate.Tests/TransactionAggregateTests.cs +++ b/TransactionProcessor.Aggregates.Tests/TransactionAggregateTests.cs @@ -1,20 +1,14 @@ -using System; +using Shouldly; +using TransactionProcessor.Models; using TransactionProcessor.Testing; -using Xunit; -namespace TransactionProcessor.TransactionAggregate.Tests{ - using System.Collections.Generic; - using System.Linq; - using EstateManagement.DataTransferObjects; - using Microsoft.AspNetCore.SignalR; - using Models; - using Shouldly; - using FeeType = Models.FeeType; +namespace TransactionProcessor.Aggregates.Tests{ + using FeeType = TransactionProcessor.Models.FeeType; public class TransactionAggregateTests{ [Fact] public void TransactionAggregate_CanBeCreated_IsCreated(){ - TransactionAggregate aggregate = TransactionAggregate.Create(TestData.TransactionId); + Aggregates.TransactionAggregate aggregate = Aggregates.TransactionAggregate.Create(TestData.TransactionId); aggregate.AggregateId.ShouldBe(TestData.TransactionId); } @@ -22,7 +16,7 @@ public void TransactionAggregate_CanBeCreated_IsCreated(){ [Theory] [InlineData(TransactionType.Sale)] public void TransactionAggregate_StartTransaction_TransactionIsStarted(TransactionType transactionType){ - TransactionAggregate transactionAggregate = TransactionAggregate.Create(TestData.TransactionId); + Aggregates.TransactionAggregate transactionAggregate = Aggregates.TransactionAggregate.Create(TestData.TransactionId); transactionAggregate.StartTransaction(TestData.TransactionDateTime, TestData.TransactionNumber, transactionType, @@ -42,14 +36,14 @@ public void TransactionAggregate_StartTransaction_TransactionIsStarted(Transacti transactionAggregate.TransactionReference.ShouldBe(TestData.TransactionReference); transactionAggregate.TransactionAmount.ShouldBe(TestData.TransactionAmount); - Transaction transaction = transactionAggregate.GetTransaction(); + TransactionProcessor.Models.Transaction transaction = transactionAggregate.GetTransaction(); transaction.ShouldNotBeNull(); } [Theory] [InlineData(TransactionType.Logon)] public void TransactionAggregate_StartTransaction_NullAmount_TransactionIsStarted(TransactionType transactionType){ - TransactionAggregate transactionAggregate = TransactionAggregate.Create(TestData.TransactionId); + Aggregates.TransactionAggregate transactionAggregate = Aggregates.TransactionAggregate.Create(TestData.TransactionId); transactionAggregate.StartTransaction(TestData.TransactionDateTime, TestData.TransactionNumber, transactionType, @@ -69,7 +63,7 @@ public void TransactionAggregate_StartTransaction_NullAmount_TransactionIsStarte transactionAggregate.TransactionReference.ShouldBe(TestData.TransactionReference); transactionAggregate.TransactionAmount.ShouldBeNull(); - Transaction transaction = transactionAggregate.GetTransaction(); + TransactionProcessor.Models.Transaction transaction = transactionAggregate.GetTransaction(); transaction.ShouldNotBeNull(); } @@ -77,7 +71,7 @@ public void TransactionAggregate_StartTransaction_NullAmount_TransactionIsStarte [InlineData(TransactionType.Logon)] [InlineData(TransactionType.Sale)] public void TransactionAggregate_StartTransaction_TransactionAlreadyStarted_ErrorThrown(TransactionType transactionType){ - TransactionAggregate transactionAggregate = TransactionAggregate.Create(TestData.TransactionId); + Aggregates.TransactionAggregate transactionAggregate = Aggregates.TransactionAggregate.Create(TestData.TransactionId); transactionAggregate.StartTransaction(TestData.TransactionDateTime, TestData.TransactionNumber, transactionType, @@ -103,7 +97,7 @@ public void TransactionAggregate_StartTransaction_TransactionAlreadyStarted_Erro [InlineData(TransactionType.Logon)] [InlineData(TransactionType.Sale)] public void TransactionAggregate_StartTransaction_TransactionAlreadyCompleted_ErrorThrown(TransactionType transactionType){ - TransactionAggregate transactionAggregate = TransactionAggregate.Create(TestData.TransactionId); + Aggregates.TransactionAggregate transactionAggregate = Aggregates.TransactionAggregate.Create(TestData.TransactionId); transactionAggregate.StartTransaction(TestData.TransactionDateTime, TestData.TransactionNumber, transactionType, @@ -167,7 +161,7 @@ public void TransactionAggregate_StartTransaction_InvalidData_ErrorThrown(Boolea Guid estateId = validEstateId ? TestData.EstateId : Guid.Empty; Guid merchantId = validMerchantId ? TestData.MerchantId : Guid.Empty; - TransactionAggregate transactionAggregate = TransactionAggregate.Create(TestData.TransactionId); + Aggregates.TransactionAggregate transactionAggregate = Aggregates.TransactionAggregate.Create(TestData.TransactionId); Should.Throw(() => { transactionAggregate.StartTransaction(transactionDateTime, @@ -184,7 +178,7 @@ public void TransactionAggregate_StartTransaction_InvalidData_ErrorThrown(Boolea [Theory] [InlineData(TransactionType.Sale)] public void TransactionAggregate_AddProductDetails_ProductDetailsAdded(TransactionType transactionType){ - TransactionAggregate transactionAggregate = TransactionAggregate.Create(TestData.TransactionId); + Aggregates.TransactionAggregate transactionAggregate = Aggregates.TransactionAggregate.Create(TestData.TransactionId); transactionAggregate.StartTransaction(TestData.TransactionDateTime, TestData.TransactionNumber, transactionType, @@ -205,7 +199,7 @@ public void TransactionAggregate_AddProductDetails_ProductDetailsAdded(Transacti [InlineData(TransactionSource.OnlineSale)] [InlineData(TransactionSource.FileImport)] public void TransactionAggregate_AddTransactionSource_TransactionSourceAdded(TransactionSource transactionSource){ - TransactionAggregate transactionAggregate = TransactionAggregate.Create(TestData.TransactionId); + Aggregates.TransactionAggregate transactionAggregate = Aggregates.TransactionAggregate.Create(TestData.TransactionId); transactionAggregate.StartTransaction(TestData.TransactionDateTime, TestData.TransactionNumber, TransactionType.Sale, @@ -223,7 +217,7 @@ public void TransactionAggregate_AddTransactionSource_TransactionSourceAdded(Tra [Fact] public void TransactionAggregate_AddTransactionSource_InvalidSource_ErrorThrown(){ - TransactionAggregate transactionAggregate = TransactionAggregate.Create(TestData.TransactionId); + Aggregates.TransactionAggregate transactionAggregate = Aggregates.TransactionAggregate.Create(TestData.TransactionId); transactionAggregate.StartTransaction(TestData.TransactionDateTime, TestData.TransactionNumber, TransactionType.Sale, @@ -241,7 +235,7 @@ public void TransactionAggregate_AddTransactionSource_InvalidSource_ErrorThrown( [InlineData(TransactionSource.OnlineSale)] [InlineData(TransactionSource.FileImport)] public void TransactionAggregate_AddTransactionSource_SourceAlreadySet_NoErrorThrown(TransactionSource transactionSource){ - TransactionAggregate transactionAggregate = TransactionAggregate.Create(TestData.TransactionId); + Aggregates.TransactionAggregate transactionAggregate = Aggregates.TransactionAggregate.Create(TestData.TransactionId); transactionAggregate.StartTransaction(TestData.TransactionDateTime, TestData.TransactionNumber, TransactionType.Sale, @@ -259,7 +253,7 @@ public void TransactionAggregate_AddTransactionSource_SourceAlreadySet_NoErrorTh [Theory] [InlineData(TransactionType.Sale)] public void TransactionAggregate_AddProductDetails_InvalidContractId_ErrorThrown(TransactionType transactionType){ - TransactionAggregate transactionAggregate = TransactionAggregate.Create(TestData.TransactionId); + Aggregates.TransactionAggregate transactionAggregate = Aggregates.TransactionAggregate.Create(TestData.TransactionId); transactionAggregate.StartTransaction(TestData.TransactionDateTime, TestData.TransactionNumber, transactionType, @@ -275,7 +269,7 @@ public void TransactionAggregate_AddProductDetails_InvalidContractId_ErrorThrown [Theory] [InlineData(TransactionType.Sale)] public void TransactionAggregate_AddProductDetails_InvalidProductId_ErrorThrown(TransactionType transactionType){ - TransactionAggregate transactionAggregate = TransactionAggregate.Create(TestData.TransactionId); + Aggregates.TransactionAggregate transactionAggregate = Aggregates.TransactionAggregate.Create(TestData.TransactionId); transactionAggregate.StartTransaction(TestData.TransactionDateTime, TestData.TransactionNumber, transactionType, @@ -291,7 +285,7 @@ public void TransactionAggregate_AddProductDetails_InvalidProductId_ErrorThrown( [Theory] [InlineData(TransactionType.Sale)] public void TransactionAggregate_AddProductDetails_ProductDetailsAlreadyAdded_ErrorThrown(TransactionType transactionType){ - TransactionAggregate transactionAggregate = TransactionAggregate.Create(TestData.TransactionId); + Aggregates.TransactionAggregate transactionAggregate = Aggregates.TransactionAggregate.Create(TestData.TransactionId); transactionAggregate.StartTransaction(TestData.TransactionDateTime, TestData.TransactionNumber, transactionType, @@ -309,7 +303,7 @@ public void TransactionAggregate_AddProductDetails_ProductDetailsAlreadyAdded_Er [Theory] [InlineData(TransactionType.Sale)] public void TransactionAggregate_AddProductDetails_TransactionNotStarted_ErrorThrown(TransactionType transactionType){ - TransactionAggregate transactionAggregate = TransactionAggregate.Create(TestData.TransactionId); + Aggregates.TransactionAggregate transactionAggregate = Aggregates.TransactionAggregate.Create(TestData.TransactionId); Should.Throw(() => { transactionAggregate.AddProductDetails(TestData.ContractId, TestData.ProductId); }); } @@ -317,7 +311,7 @@ public void TransactionAggregate_AddProductDetails_TransactionNotStarted_ErrorTh [Theory] [InlineData(TransactionType.Sale)] public void TransactionAggregate_AddProductDetails_TransactionAlreadyCompleted_ErrorThrown(TransactionType transactionType){ - TransactionAggregate transactionAggregate = TransactionAggregate.Create(TestData.TransactionId); + Aggregates.TransactionAggregate transactionAggregate = Aggregates.TransactionAggregate.Create(TestData.TransactionId); transactionAggregate.StartTransaction(TestData.TransactionDateTime, TestData.TransactionNumber, transactionType, @@ -351,7 +345,7 @@ public void TransactionAggregate_AddProductDetails_TransactionAlreadyCompleted_E [Theory] [InlineData(TransactionType.Logon)] public void TransactionAggregate_AuthoriseTransactionLocally_TransactionIsAuthorised(TransactionType transactionType){ - TransactionAggregate transactionAggregate = TransactionAggregate.Create(TestData.TransactionId); + Aggregates.TransactionAggregate transactionAggregate = Aggregates.TransactionAggregate.Create(TestData.TransactionId); transactionAggregate.StartTransaction(TestData.TransactionDateTime, TestData.TransactionNumber, transactionType, @@ -372,7 +366,7 @@ public void TransactionAggregate_AuthoriseTransactionLocally_TransactionIsAuthor [Fact] public void TransactionAggregate_AuthoriseTransactionLocally_TransactionNotStarted_ErrorThrown(){ - TransactionAggregate transactionAggregate = TransactionAggregate.Create(TestData.TransactionId); + Aggregates.TransactionAggregate transactionAggregate = Aggregates.TransactionAggregate.Create(TestData.TransactionId); Should.Throw(() => { transactionAggregate.AuthoriseTransactionLocally(TestData.AuthorisationCode, @@ -384,7 +378,7 @@ public void TransactionAggregate_AuthoriseTransactionLocally_TransactionNotStart [Theory] [InlineData(TransactionType.Logon)] public void TransactionAggregate_AuthoriseTransactionLocally_TransactionAlreadyAuthorisedLocally_ErrorThrown(TransactionType transactionType){ - TransactionAggregate transactionAggregate = TransactionAggregate.Create(TestData.TransactionId); + Aggregates.TransactionAggregate transactionAggregate = Aggregates.TransactionAggregate.Create(TestData.TransactionId); transactionAggregate.StartTransaction(TestData.TransactionDateTime, TestData.TransactionNumber, transactionType, @@ -405,7 +399,7 @@ public void TransactionAggregate_AuthoriseTransactionLocally_TransactionAlreadyA [Theory] [InlineData(TransactionType.Logon)] public void TransactionAggregate_AuthoriseTransactionLocally_TransactionAlreadyAuthorised_ErrorThrown(TransactionType transactionType){ - TransactionAggregate transactionAggregate = TransactionAggregate.Create(TestData.TransactionId); + Aggregates.TransactionAggregate transactionAggregate = Aggregates.TransactionAggregate.Create(TestData.TransactionId); transactionAggregate.StartTransaction(TestData.TransactionDateTime, TestData.TransactionNumber, transactionType, @@ -426,7 +420,7 @@ public void TransactionAggregate_AuthoriseTransactionLocally_TransactionAlreadyA [Theory] [InlineData(TransactionType.Sale)] public void TransactionAggregate_AuthoriseTransactionLocally_TransactionCannotBeLocallyAuthorised_ErrorThrown(TransactionType transactionType){ - TransactionAggregate transactionAggregate = TransactionAggregate.Create(TestData.TransactionId); + Aggregates.TransactionAggregate transactionAggregate = Aggregates.TransactionAggregate.Create(TestData.TransactionId); transactionAggregate.StartTransaction(TestData.TransactionDateTime, TestData.TransactionNumber, transactionType, @@ -449,7 +443,7 @@ public void TransactionAggregate_AuthoriseTransactionLocally_TransactionCannotBe [InlineData(TransactionType.Logon)] [InlineData(TransactionType.Sale)] public void TransactionAggregate_AuthoriseTransaction_TransactionIsAuthorised(TransactionType transactionType){ - TransactionAggregate transactionAggregate = TransactionAggregate.Create(TestData.TransactionId); + Aggregates.TransactionAggregate transactionAggregate = Aggregates.TransactionAggregate.Create(TestData.TransactionId); transactionAggregate.StartTransaction(TestData.TransactionDateTime, TestData.TransactionNumber, transactionType, @@ -474,7 +468,7 @@ public void TransactionAggregate_AuthoriseTransaction_TransactionIsAuthorised(Tr [Fact] public void TransactionAggregate_AuthoriseTransaction_TransactionNotStarted_ErrorThrown(){ - TransactionAggregate transactionAggregate = TransactionAggregate.Create(TestData.TransactionId); + Aggregates.TransactionAggregate transactionAggregate = Aggregates.TransactionAggregate.Create(TestData.TransactionId); Should.Throw(() => { transactionAggregate.AuthoriseTransaction(TestData.OperatorId, TestData.OperatorAuthorisationCode, TestData.OperatorResponseCode, TestData.OperatorResponseMessage, TestData.OperatorTransactionId, TestData.ResponseCode, TestData.ResponseMessage); }); } @@ -483,7 +477,7 @@ public void TransactionAggregate_AuthoriseTransaction_TransactionNotStarted_Erro [InlineData(TransactionType.Logon)] [InlineData(TransactionType.Sale)] public void TransactionAggregate_AuthoriseTransaction_TransactionAlreadyAuthorised_ErrorThrown(TransactionType transactionType){ - TransactionAggregate transactionAggregate = TransactionAggregate.Create(TestData.TransactionId); + Aggregates.TransactionAggregate transactionAggregate = Aggregates.TransactionAggregate.Create(TestData.TransactionId); transactionAggregate.StartTransaction(TestData.TransactionDateTime, TestData.TransactionNumber, transactionType, @@ -505,7 +499,7 @@ public void TransactionAggregate_AuthoriseTransaction_TransactionAlreadyAuthoris [InlineData(TransactionType.Logon)] [InlineData(TransactionType.Sale)] public void TransactionAggregate_DeclineTransactionLocally_TransactionIsDeclined(TransactionType transactionType){ - TransactionAggregate transactionAggregate = TransactionAggregate.Create(TestData.TransactionId); + Aggregates.TransactionAggregate transactionAggregate = Aggregates.TransactionAggregate.Create(TestData.TransactionId); transactionAggregate.StartTransaction(TestData.TransactionDateTime, TestData.TransactionNumber, transactionType, @@ -531,7 +525,7 @@ public void TransactionAggregate_DeclineTransactionLocally_TransactionIsDeclined [Fact] public void TransactionAggregate_DeclineTransactionLocally_TransactionNotStarted_ErrorThrown(){ - TransactionAggregate transactionAggregate = TransactionAggregate.Create(TestData.TransactionId); + Aggregates.TransactionAggregate transactionAggregate = Aggregates.TransactionAggregate.Create(TestData.TransactionId); Should.Throw(() => { transactionAggregate.DeclineTransactionLocally(TestData.ResponseCode, TestData.ResponseMessage); }); } @@ -539,7 +533,7 @@ public void TransactionAggregate_DeclineTransactionLocally_TransactionNotStarted [Theory] [InlineData(TransactionType.Logon)] public void TransactionAggregate_DeclineTransactionLocally_TransactionAlreadyAuthorisedLocally_ErrorThrown(TransactionType transactionType){ - TransactionAggregate transactionAggregate = TransactionAggregate.Create(TestData.TransactionId); + Aggregates.TransactionAggregate transactionAggregate = Aggregates.TransactionAggregate.Create(TestData.TransactionId); transactionAggregate.StartTransaction(TestData.TransactionDateTime, TestData.TransactionNumber, transactionType, @@ -557,7 +551,7 @@ public void TransactionAggregate_DeclineTransactionLocally_TransactionAlreadyAut [InlineData(TransactionType.Logon)] [InlineData(TransactionType.Sale)] public void TransactionAggregate_DeclineTransactionLocally_TransactionAlreadyAuthorised_ErrorThrown(TransactionType transactionType){ - TransactionAggregate transactionAggregate = TransactionAggregate.Create(TestData.TransactionId); + Aggregates.TransactionAggregate transactionAggregate = Aggregates.TransactionAggregate.Create(TestData.TransactionId); transactionAggregate.StartTransaction(TestData.TransactionDateTime, TestData.TransactionNumber, transactionType, @@ -579,7 +573,7 @@ public void TransactionAggregate_DeclineTransactionLocally_TransactionAlreadyAut [InlineData(TransactionType.Logon)] [InlineData(TransactionType.Sale)] public void TransactionAggregate_DeclineTransactionLocally_TransactionAlreadyDeclinedLocally_ErrorThrown(TransactionType transactionType){ - TransactionAggregate transactionAggregate = TransactionAggregate.Create(TestData.TransactionId); + Aggregates.TransactionAggregate transactionAggregate = Aggregates.TransactionAggregate.Create(TestData.TransactionId); transactionAggregate.StartTransaction(TestData.TransactionDateTime, TestData.TransactionNumber, transactionType, @@ -601,7 +595,7 @@ public void TransactionAggregate_DeclineTransactionLocally_TransactionAlreadyDec [InlineData(TransactionType.Logon)] [InlineData(TransactionType.Sale)] public void TransactionAggregate_DeclineTransactionLocally_TransactionAlreadyDeclined_ErrorThrown(TransactionType transactionType){ - TransactionAggregate transactionAggregate = TransactionAggregate.Create(TestData.TransactionId); + Aggregates.TransactionAggregate transactionAggregate = Aggregates.TransactionAggregate.Create(TestData.TransactionId); transactionAggregate.StartTransaction(TestData.TransactionDateTime, TestData.TransactionNumber, transactionType, @@ -623,7 +617,7 @@ public void TransactionAggregate_DeclineTransactionLocally_TransactionAlreadyDec [InlineData(TransactionType.Logon)] [InlineData(TransactionType.Sale)] public void TransactionAggregate_DeclineTransaction_TransactionIsDeclined(TransactionType transactionType){ - TransactionAggregate transactionAggregate = TransactionAggregate.Create(TestData.TransactionId); + Aggregates.TransactionAggregate transactionAggregate = Aggregates.TransactionAggregate.Create(TestData.TransactionId); transactionAggregate.StartTransaction(TestData.TransactionDateTime, TestData.TransactionNumber, transactionType, @@ -649,7 +643,7 @@ public void TransactionAggregate_DeclineTransaction_TransactionIsDeclined(Transa [Fact] public void TransactionAggregate_DeclineTransaction_TransactionNotStarted_ErrorThrown(){ - TransactionAggregate transactionAggregate = TransactionAggregate.Create(TestData.TransactionId); + Aggregates.TransactionAggregate transactionAggregate = Aggregates.TransactionAggregate.Create(TestData.TransactionId); Should.Throw(() => { transactionAggregate.DeclineTransaction(TestData.OperatorId, TestData.DeclinedOperatorResponseCode, TestData.DeclinedOperatorResponseMessage, TestData.DeclinedResponseCode, TestData.DeclinedResponseMessage); }); } @@ -673,7 +667,7 @@ public void TransactionAggregate_DeclineTransaction_TransactionNotStarted_ErrorT [InlineData(TransactionType.Logon)] [InlineData(TransactionType.Sale)] public void TransactionAggregate_DeclineTransaction_TransactionAlreadyAuthorised_ErrorThrown(TransactionType transactionType){ - TransactionAggregate transactionAggregate = TransactionAggregate.Create(TestData.TransactionId); + Aggregates.TransactionAggregate transactionAggregate = Aggregates.TransactionAggregate.Create(TestData.TransactionId); transactionAggregate.StartTransaction(TestData.TransactionDateTime, TestData.TransactionNumber, transactionType, @@ -695,7 +689,7 @@ public void TransactionAggregate_DeclineTransaction_TransactionAlreadyAuthorised [InlineData(TransactionType.Logon)] [InlineData(TransactionType.Sale)] public void TransactionAggregate_DeclineTransaction_TransactionAlreadyDeclinedLocally_ErrorThrown(TransactionType transactionType){ - TransactionAggregate transactionAggregate = TransactionAggregate.Create(TestData.TransactionId); + Aggregates.TransactionAggregate transactionAggregate = Aggregates.TransactionAggregate.Create(TestData.TransactionId); transactionAggregate.StartTransaction(TestData.TransactionDateTime, TestData.TransactionNumber, transactionType, @@ -717,7 +711,7 @@ public void TransactionAggregate_DeclineTransaction_TransactionAlreadyDeclinedLo [InlineData(TransactionType.Logon)] [InlineData(TransactionType.Sale)] public void TransactionAggregate_DeclineTransaction_TransactionAlreadyDeclined_ErrorThrown(TransactionType transactionType){ - TransactionAggregate transactionAggregate = TransactionAggregate.Create(TestData.TransactionId); + Aggregates.TransactionAggregate transactionAggregate = Aggregates.TransactionAggregate.Create(TestData.TransactionId); transactionAggregate.StartTransaction(TestData.TransactionDateTime, TestData.TransactionNumber, transactionType, @@ -739,7 +733,7 @@ public void TransactionAggregate_DeclineTransaction_TransactionAlreadyDeclined_E [InlineData(TransactionType.Logon)] [InlineData(TransactionType.Sale)] public void TransactionAggregate_CompleteTransaction_TransactionIsCompleted(TransactionType transactionType){ - TransactionAggregate transactionAggregate = TransactionAggregate.Create(TestData.TransactionId); + Aggregates.TransactionAggregate transactionAggregate = Aggregates.TransactionAggregate.Create(TestData.TransactionId); transactionAggregate.StartTransaction(TestData.TransactionDateTime, TestData.TransactionNumber, transactionType, @@ -763,7 +757,7 @@ public void TransactionAggregate_CompleteTransaction_TransactionIsCompleted(Tran [Fact] public void TransactionAggregate_CompleteTransaction_TransactionNotStarted_ErrorThrown(){ - TransactionAggregate transactionAggregate = TransactionAggregate.Create(TestData.TransactionId); + Aggregates.TransactionAggregate transactionAggregate = Aggregates.TransactionAggregate.Create(TestData.TransactionId); Should.Throw(() => { transactionAggregate.CompleteTransaction(); }); } @@ -772,7 +766,7 @@ public void TransactionAggregate_CompleteTransaction_TransactionNotStarted_Error [InlineData(TransactionType.Logon)] [InlineData(TransactionType.Sale)] public void TransactionAggregate_CompleteTransaction_TransactionNotAuthorised_ErrorThrown(TransactionType transactionType){ - TransactionAggregate transactionAggregate = TransactionAggregate.Create(TestData.TransactionId); + Aggregates.TransactionAggregate transactionAggregate = Aggregates.TransactionAggregate.Create(TestData.TransactionId); transactionAggregate.StartTransaction(TestData.TransactionDateTime, TestData.TransactionNumber, transactionType, @@ -792,7 +786,7 @@ public void TransactionAggregate_CompleteTransaction_TransactionNotAuthorised_Er [InlineData(TransactionType.Logon)] [InlineData(TransactionType.Sale)] public void TransactionAggregate_CompleteTransaction_TransactionAlreadyCompleted_ErrorThrown(TransactionType transactionType){ - TransactionAggregate transactionAggregate = TransactionAggregate.Create(TestData.TransactionId); + Aggregates.TransactionAggregate transactionAggregate = Aggregates.TransactionAggregate.Create(TestData.TransactionId); transactionAggregate.StartTransaction(TestData.TransactionDateTime, TestData.TransactionNumber, transactionType, @@ -819,7 +813,7 @@ public void TransactionAggregate_CompleteTransaction_TransactionAlreadyCompleted [InlineData(TransactionType.Logon)] [InlineData(TransactionType.Sale)] public void TransactionAggregate_RecordAdditionalRequestData_RequestDataRecorded(TransactionType transactionType){ - TransactionAggregate transactionAggregate = TransactionAggregate.Create(TestData.TransactionId); + Aggregates.TransactionAggregate transactionAggregate = Aggregates.TransactionAggregate.Create(TestData.TransactionId); transactionAggregate.StartTransaction(TestData.TransactionDateTime, TestData.TransactionNumber, transactionType, @@ -840,7 +834,7 @@ public void TransactionAggregate_RecordAdditionalRequestData_RequestDataRecorded [InlineData(TransactionType.Logon)] [InlineData(TransactionType.Sale)] public void TransactionAggregate_RecordAdditionalRequestData_TransactionNotStarted_ErrorThrown(TransactionType transactionType){ - TransactionAggregate transactionAggregate = TransactionAggregate.Create(TestData.TransactionId); + Aggregates.TransactionAggregate transactionAggregate = Aggregates.TransactionAggregate.Create(TestData.TransactionId); Should.Throw(() => { transactionAggregate.RecordAdditionalRequestData(TestData.OperatorId, TestData.AdditionalTransactionMetaDataForMobileTopup()); }); } @@ -849,7 +843,7 @@ public void TransactionAggregate_RecordAdditionalRequestData_TransactionNotStart [InlineData(TransactionType.Logon)] [InlineData(TransactionType.Sale)] public void TransactionAggregate_RecordAdditionalRequestData_AdditionalRequestDataAlreadyRecorded_ErrorThrown(TransactionType transactionType){ - TransactionAggregate transactionAggregate = TransactionAggregate.Create(TestData.TransactionId); + Aggregates.TransactionAggregate transactionAggregate = Aggregates.TransactionAggregate.Create(TestData.TransactionId); transactionAggregate.StartTransaction(TestData.TransactionDateTime, TestData.TransactionNumber, transactionType, @@ -871,7 +865,7 @@ public void TransactionAggregate_RecordAdditionalRequestData_AdditionalRequestDa [InlineData(TransactionType.Logon)] [InlineData(TransactionType.Sale)] public void TransactionAggregate_RecordAdditionalRequestData_AlreadyAuthorised_ErrorThrown(TransactionType transactionType){ - TransactionAggregate transactionAggregate = TransactionAggregate.Create(TestData.TransactionId); + Aggregates.TransactionAggregate transactionAggregate = Aggregates.TransactionAggregate.Create(TestData.TransactionId); transactionAggregate.StartTransaction(TestData.TransactionDateTime, TestData.TransactionNumber, transactionType, @@ -900,7 +894,7 @@ public void TransactionAggregate_RecordAdditionalRequestData_AlreadyAuthorised_E [InlineData(TransactionType.Logon)] [InlineData(TransactionType.Sale)] public void TransactionAggregate_RecordAdditionalRequestData_AlreadyDeclined_ErrorThrown(TransactionType transactionType){ - TransactionAggregate transactionAggregate = TransactionAggregate.Create(TestData.TransactionId); + Aggregates.TransactionAggregate transactionAggregate = Aggregates.TransactionAggregate.Create(TestData.TransactionId); transactionAggregate.StartTransaction(TestData.TransactionDateTime, TestData.TransactionNumber, transactionType, @@ -929,7 +923,7 @@ public void TransactionAggregate_RecordAdditionalRequestData_AlreadyDeclined_Err [InlineData(TransactionType.Logon)] [InlineData(TransactionType.Sale)] public void TransactionAggregate_RecordAdditionalRequestData_AlreadyCompleted_ErrorThrown(TransactionType transactionType){ - TransactionAggregate transactionAggregate = TransactionAggregate.Create(TestData.TransactionId); + Aggregates.TransactionAggregate transactionAggregate = Aggregates.TransactionAggregate.Create(TestData.TransactionId); transactionAggregate.StartTransaction(TestData.TransactionDateTime, TestData.TransactionNumber, transactionType, @@ -962,7 +956,7 @@ public void TransactionAggregate_RecordAdditionalRequestData_AlreadyCompleted_Er [InlineData(TransactionType.Logon)] [InlineData(TransactionType.Sale)] public void TransactionAggregate_RecordAdditionalResponseData_ResponseDataRecorded(TransactionType transactionType){ - TransactionAggregate transactionAggregate = TransactionAggregate.Create(TestData.TransactionId); + Aggregates.TransactionAggregate transactionAggregate = Aggregates.TransactionAggregate.Create(TestData.TransactionId); transactionAggregate.StartTransaction(TestData.TransactionDateTime, TestData.TransactionNumber, transactionType, @@ -990,7 +984,7 @@ public void TransactionAggregate_RecordAdditionalResponseData_ResponseDataRecord [InlineData(TransactionType.Logon)] [InlineData(TransactionType.Sale)] public void TransactionAggregate_RecordAdditionalResponseData_TransactionNotStarted_ErrorThrown(TransactionType transactionType){ - TransactionAggregate transactionAggregate = TransactionAggregate.Create(TestData.TransactionId); + Aggregates.TransactionAggregate transactionAggregate = Aggregates.TransactionAggregate.Create(TestData.TransactionId); Should.Throw(() => { transactionAggregate.RecordAdditionalResponseData(TestData.OperatorId, TestData.AdditionalTransactionMetaDataForMobileTopup()); }); } @@ -999,7 +993,7 @@ public void TransactionAggregate_RecordAdditionalResponseData_TransactionNotStar [InlineData(TransactionType.Logon)] [InlineData(TransactionType.Sale)] public void TransactionAggregate_RecordAdditionalResponseData_AdditionalResponseDataAlreadyRecorded_ErrorThrown(TransactionType transactionType){ - TransactionAggregate transactionAggregate = TransactionAggregate.Create(TestData.TransactionId); + Aggregates.TransactionAggregate transactionAggregate = Aggregates.TransactionAggregate.Create(TestData.TransactionId); transactionAggregate.StartTransaction(TestData.TransactionDateTime, TestData.TransactionNumber, transactionType, @@ -1029,7 +1023,7 @@ public void TransactionAggregate_RecordAdditionalResponseData_AdditionalResponse [InlineData(TransactionType.Logon)] [InlineData(TransactionType.Sale)] public void TransactionAggregate_RecordAdditionalResponseData_AlreadyCompleted_ErrorThrown(TransactionType transactionType){ - TransactionAggregate transactionAggregate = TransactionAggregate.Create(TestData.TransactionId); + Aggregates.TransactionAggregate transactionAggregate = Aggregates.TransactionAggregate.Create(TestData.TransactionId); transactionAggregate.StartTransaction(TestData.TransactionDateTime, TestData.TransactionNumber, transactionType, @@ -1058,7 +1052,7 @@ public void TransactionAggregate_RecordAdditionalResponseData_AlreadyCompleted_E [Fact] public void TransactionAggregate_RequestEmailReceipt_CustomerEmailReceiptHasBeenRequested(){ - TransactionAggregate transactionAggregate = TransactionAggregate.Create(TestData.TransactionId); + Aggregates.TransactionAggregate transactionAggregate = Aggregates.TransactionAggregate.Create(TestData.TransactionId); transactionAggregate.StartTransaction(TestData.TransactionDateTime, TestData.TransactionNumber, TransactionType.Sale, @@ -1081,7 +1075,7 @@ public void TransactionAggregate_RequestEmailReceipt_CustomerEmailReceiptHasBeen [Fact] public void TransactionAggregate_RequestEmailReceipt_TransactionNotCompleted_ErrorThrown(){ - TransactionAggregate transactionAggregate = TransactionAggregate.Create(TestData.TransactionId); + Aggregates.TransactionAggregate transactionAggregate = Aggregates.TransactionAggregate.Create(TestData.TransactionId); transactionAggregate.StartTransaction(TestData.TransactionDateTime, TestData.TransactionNumber, TransactionType.Sale, @@ -1100,7 +1094,7 @@ public void TransactionAggregate_RequestEmailReceipt_TransactionNotCompleted_Err [Fact] public void TransactionAggregate_RequestEmailReceipt_EmailReceiptAlreadyRequested_ErrorThrown(){ - TransactionAggregate transactionAggregate = TransactionAggregate.Create(TestData.TransactionId); + Aggregates.TransactionAggregate transactionAggregate = Aggregates.TransactionAggregate.Create(TestData.TransactionId); transactionAggregate.StartTransaction(TestData.TransactionDateTime, TestData.TransactionNumber, TransactionType.Sale, @@ -1122,7 +1116,7 @@ public void TransactionAggregate_RequestEmailReceipt_EmailReceiptAlreadyRequeste [Fact] public void TransactionAggregate_RequestEmailReceiptResend_CustomerEmailReceiptHasBeenRequested(){ - TransactionAggregate transactionAggregate = TransactionAggregate.Create(TestData.TransactionId); + Aggregates.TransactionAggregate transactionAggregate = Aggregates.TransactionAggregate.Create(TestData.TransactionId); transactionAggregate.StartTransaction(TestData.TransactionDateTime, TestData.TransactionNumber, TransactionType.Sale, @@ -1145,7 +1139,7 @@ public void TransactionAggregate_RequestEmailReceiptResend_CustomerEmailReceiptH [Fact] public void TransactionAggregate_RequestEmailReceiptResend_ReceiptNotSent_ErrorThrown(){ - TransactionAggregate transactionAggregate = TransactionAggregate.Create(TestData.TransactionId); + Aggregates.TransactionAggregate transactionAggregate = Aggregates.TransactionAggregate.Create(TestData.TransactionId); transactionAggregate.StartTransaction(TestData.TransactionDateTime, TestData.TransactionNumber, TransactionType.Sale, @@ -1165,7 +1159,7 @@ public void TransactionAggregate_RequestEmailReceiptResend_ReceiptNotSent_ErrorT [Theory] [InlineData(TransactionType.Sale, FeeType.ServiceProvider)] public void TransactionAggregate_AddFee_FeeDetailsAdded(TransactionType transactionType, FeeType feeType){ - TransactionAggregate transactionAggregate = TransactionAggregate.Create(TestData.TransactionId); + Aggregates.TransactionAggregate transactionAggregate = Aggregates.TransactionAggregate.Create(TestData.TransactionId); transactionAggregate.StartTransaction(TestData.TransactionDateTime, TestData.TransactionNumber, transactionType, @@ -1198,7 +1192,7 @@ public void TransactionAggregate_AddFee_FeeDetailsAdded(TransactionType transact [Theory] [InlineData(TransactionType.Sale)] public void TransactionAggregate_AddFee_NullFee_ErrorThrown(TransactionType transactionType){ - TransactionAggregate transactionAggregate = TransactionAggregate.Create(TestData.TransactionId); + Aggregates.TransactionAggregate transactionAggregate = Aggregates.TransactionAggregate.Create(TestData.TransactionId); transactionAggregate.StartTransaction(TestData.TransactionDateTime, TestData.TransactionNumber, transactionType, @@ -1219,7 +1213,7 @@ public void TransactionAggregate_AddFee_NullFee_ErrorThrown(TransactionType tran [InlineData(TransactionType.Sale, FeeType.ServiceProvider)] [InlineData(TransactionType.Sale, FeeType.Merchant)] public void TransactionAggregate_AddFee_TransactionNotAuthorised_ErrorThrown(TransactionType transactionType, FeeType feeType){ - TransactionAggregate transactionAggregate = TransactionAggregate.Create(TestData.TransactionId); + Aggregates.TransactionAggregate transactionAggregate = Aggregates.TransactionAggregate.Create(TestData.TransactionId); transactionAggregate.StartTransaction(TestData.TransactionDateTime, TestData.TransactionNumber, transactionType, @@ -1251,7 +1245,7 @@ private CalculatedFee GetCalculatedFeeToAdd(FeeType feeType){ [Theory] [InlineData(TransactionType.Sale, FeeType.ServiceProvider)] public void TransactionAggregate_AddFee_TransactionNotCompleted_ErrorThrown(TransactionType transactionType, FeeType feeType){ - TransactionAggregate transactionAggregate = TransactionAggregate.Create(TestData.TransactionId); + Aggregates.TransactionAggregate transactionAggregate = Aggregates.TransactionAggregate.Create(TestData.TransactionId); transactionAggregate.StartTransaction(TestData.TransactionDateTime, TestData.TransactionNumber, transactionType, @@ -1270,7 +1264,7 @@ public void TransactionAggregate_AddFee_TransactionNotCompleted_ErrorThrown(Tran [Theory] [InlineData(TransactionType.Sale, FeeType.ServiceProvider)] public void TransactionAggregate_AddFee_FeeAlreadyAdded_NoErrorThrown(TransactionType transactionType, FeeType feeType){ - TransactionAggregate transactionAggregate = TransactionAggregate.Create(TestData.TransactionId); + Aggregates.TransactionAggregate transactionAggregate = Aggregates.TransactionAggregate.Create(TestData.TransactionId); transactionAggregate.StartTransaction(TestData.TransactionDateTime, TestData.TransactionNumber, transactionType, @@ -1292,7 +1286,7 @@ public void TransactionAggregate_AddFee_FeeAlreadyAdded_NoErrorThrown(Transactio [Theory] [InlineData(TransactionType.Sale)] public void TransactionAggregate_AddFee_UnsupportedFeeType_ErrorThrown(TransactionType transactionType){ - TransactionAggregate transactionAggregate = TransactionAggregate.Create(TestData.TransactionId); + Aggregates.TransactionAggregate transactionAggregate = Aggregates.TransactionAggregate.Create(TestData.TransactionId); transactionAggregate.StartTransaction(TestData.TransactionDateTime, TestData.TransactionNumber, transactionType, @@ -1313,7 +1307,7 @@ public void TransactionAggregate_AddFee_UnsupportedFeeType_ErrorThrown(Transacti [InlineData(FeeType.ServiceProvider)] [InlineData(FeeType.Merchant)] public void TransactionAggregate_AddFee_LogonTransaction_ErrorThrown(FeeType feeType){ - TransactionAggregate transactionAggregate = TransactionAggregate.Create(TestData.TransactionId); + Aggregates.TransactionAggregate transactionAggregate = Aggregates.TransactionAggregate.Create(TestData.TransactionId); transactionAggregate.StartTransaction(TestData.TransactionDateTime, TestData.TransactionNumber, TransactionType.Logon, @@ -1332,7 +1326,7 @@ public void TransactionAggregate_AddFee_LogonTransaction_ErrorThrown(FeeType fee [Theory] [InlineData(TransactionType.Sale, FeeType.Merchant)] public void TransactionAggregate_AddSettledFee_FeeDetailsAdded(TransactionType transactionType, FeeType feeType){ - TransactionAggregate transactionAggregate = TransactionAggregate.Create(TestData.TransactionId); + Aggregates.TransactionAggregate transactionAggregate = Aggregates.TransactionAggregate.Create(TestData.TransactionId); transactionAggregate.StartTransaction(TestData.TransactionDateTime, TestData.TransactionNumber, transactionType, @@ -1365,7 +1359,7 @@ public void TransactionAggregate_AddSettledFee_FeeDetailsAdded(TransactionType t [Theory] [InlineData(TransactionType.Sale)] public void TransactionAggregate_AddSettledFee_NullFee_ErrorThrown(TransactionType transactionType){ - TransactionAggregate transactionAggregate = TransactionAggregate.Create(TestData.TransactionId); + Aggregates.TransactionAggregate transactionAggregate = Aggregates.TransactionAggregate.Create(TestData.TransactionId); transactionAggregate.StartTransaction(TestData.TransactionDateTime, TestData.TransactionNumber, transactionType, @@ -1385,7 +1379,7 @@ public void TransactionAggregate_AddSettledFee_NullFee_ErrorThrown(TransactionTy [Theory] [InlineData(TransactionType.Sale, FeeType.Merchant)] public void TransactionAggregate_AddSettledFee_TransactionNotAuthorised_ErrorThrown(TransactionType transactionType, FeeType feeType){ - TransactionAggregate transactionAggregate = TransactionAggregate.Create(TestData.TransactionId); + Aggregates.TransactionAggregate transactionAggregate = Aggregates.TransactionAggregate.Create(TestData.TransactionId); transactionAggregate.StartTransaction(TestData.TransactionDateTime, TestData.TransactionNumber, transactionType, @@ -1405,7 +1399,7 @@ public void TransactionAggregate_AddSettledFee_TransactionNotAuthorised_ErrorThr [Theory] [InlineData(TransactionType.Sale, FeeType.Merchant)] public void TransactionAggregate_AddSettledFee_TransactionNotCompleted_ErrorThrown(TransactionType transactionType, FeeType feeType){ - TransactionAggregate transactionAggregate = TransactionAggregate.Create(TestData.TransactionId); + Aggregates.TransactionAggregate transactionAggregate = Aggregates.TransactionAggregate.Create(TestData.TransactionId); transactionAggregate.StartTransaction(TestData.TransactionDateTime, TestData.TransactionNumber, transactionType, @@ -1424,7 +1418,7 @@ public void TransactionAggregate_AddSettledFee_TransactionNotCompleted_ErrorThro [Theory] [InlineData(TransactionType.Sale, FeeType.Merchant)] public void TransactionAggregate_AddSettledFee_FeeNotAlreadyAdded_NoErrorThrown(TransactionType transactionType, FeeType feeType){ - TransactionAggregate transactionAggregate = TransactionAggregate.Create(TestData.TransactionId); + Aggregates.TransactionAggregate transactionAggregate = Aggregates.TransactionAggregate.Create(TestData.TransactionId); transactionAggregate.StartTransaction(TestData.TransactionDateTime, TestData.TransactionNumber, transactionType, @@ -1449,7 +1443,7 @@ public void TransactionAggregate_AddSettledFee_FeeNotAlreadyAdded_NoErrorThrown( [Theory] [InlineData(TransactionType.Sale)] public void TransactionAggregate_AddSettledFee_UnsupportedFeeType_ErrorThrown(TransactionType transactionType){ - TransactionAggregate transactionAggregate = TransactionAggregate.Create(TestData.TransactionId); + Aggregates.TransactionAggregate transactionAggregate = Aggregates.TransactionAggregate.Create(TestData.TransactionId); transactionAggregate.StartTransaction(TestData.TransactionDateTime, TestData.TransactionNumber, transactionType, @@ -1473,7 +1467,7 @@ public void TransactionAggregate_AddSettledFee_UnsupportedFeeType_ErrorThrown(Tr [Theory] [InlineData(FeeType.Merchant)] public void TransactionAggregate_AddSettledFee_LogonTransaction_ErrorThrown(FeeType feeType){ - TransactionAggregate transactionAggregate = TransactionAggregate.Create(TestData.TransactionId); + Aggregates.TransactionAggregate transactionAggregate = Aggregates.TransactionAggregate.Create(TestData.TransactionId); transactionAggregate.StartTransaction(TestData.TransactionDateTime, TestData.TransactionNumber, TransactionType.Logon, @@ -1492,7 +1486,7 @@ public void TransactionAggregate_AddSettledFee_LogonTransaction_ErrorThrown(FeeT [Theory] [InlineData(TransactionType.Sale, FeeType.Merchant)] public void TransactionAggregate_AddFeePendingSettlement_FeeDetailsAdded(TransactionType transactionType, FeeType feeType){ - TransactionAggregate transactionAggregate = TransactionAggregate.Create(TestData.TransactionId); + Aggregates.TransactionAggregate transactionAggregate = Aggregates.TransactionAggregate.Create(TestData.TransactionId); transactionAggregate.StartTransaction(TestData.TransactionDateTime, TestData.TransactionNumber, transactionType, @@ -1525,7 +1519,7 @@ public void TransactionAggregate_AddFeePendingSettlement_FeeDetailsAdded(Transac [Theory] [InlineData(TransactionType.Sale)] public void TransactionAggregate_AddFeePendingSettlement_NullFee_ErrorThrown(TransactionType transactionType){ - TransactionAggregate transactionAggregate = TransactionAggregate.Create(TestData.TransactionId); + Aggregates.TransactionAggregate transactionAggregate = Aggregates.TransactionAggregate.Create(TestData.TransactionId); transactionAggregate.StartTransaction(TestData.TransactionDateTime, TestData.TransactionNumber, transactionType, @@ -1546,7 +1540,7 @@ public void TransactionAggregate_AddFeePendingSettlement_NullFee_ErrorThrown(Tra [InlineData(TransactionType.Sale, FeeType.ServiceProvider)] [InlineData(TransactionType.Sale, FeeType.Merchant)] public void TransactionAggregate_AddFeePendingSettlement_TransactionNotAuthorised_ErrorThrown(TransactionType transactionType, FeeType feeType){ - TransactionAggregate transactionAggregate = TransactionAggregate.Create(TestData.TransactionId); + Aggregates.TransactionAggregate transactionAggregate = Aggregates.TransactionAggregate.Create(TestData.TransactionId); transactionAggregate.StartTransaction(TestData.TransactionDateTime, TestData.TransactionNumber, transactionType, @@ -1567,7 +1561,7 @@ public void TransactionAggregate_AddFeePendingSettlement_TransactionNotAuthorise [Theory] [InlineData(TransactionType.Sale, FeeType.ServiceProvider)] public void TransactionAggregate_AddFeePendingSettlement_TransactionNotCompleted_ErrorThrown(TransactionType transactionType, FeeType feeType){ - TransactionAggregate transactionAggregate = TransactionAggregate.Create(TestData.TransactionId); + Aggregates.TransactionAggregate transactionAggregate = Aggregates.TransactionAggregate.Create(TestData.TransactionId); transactionAggregate.StartTransaction(TestData.TransactionDateTime, TestData.TransactionNumber, transactionType, @@ -1586,7 +1580,7 @@ public void TransactionAggregate_AddFeePendingSettlement_TransactionNotCompleted [Theory] [InlineData(TransactionType.Sale, FeeType.Merchant)] public void TransactionAggregate_AddFeePendingSettlement_FeeAlreadyAdded_NoErrorThrown(TransactionType transactionType, FeeType feeType){ - TransactionAggregate transactionAggregate = TransactionAggregate.Create(TestData.TransactionId); + Aggregates.TransactionAggregate transactionAggregate = Aggregates.TransactionAggregate.Create(TestData.TransactionId); transactionAggregate.StartTransaction(TestData.TransactionDateTime, TestData.TransactionNumber, transactionType, @@ -1608,7 +1602,7 @@ public void TransactionAggregate_AddFeePendingSettlement_FeeAlreadyAdded_NoError [Theory] [InlineData(TransactionType.Sale)] public void TransactionAggregate_AddFeePendingSettlement_UnsupportedFeeType_ErrorThrown(TransactionType transactionType){ - TransactionAggregate transactionAggregate = TransactionAggregate.Create(TestData.TransactionId); + Aggregates.TransactionAggregate transactionAggregate = Aggregates.TransactionAggregate.Create(TestData.TransactionId); transactionAggregate.StartTransaction(TestData.TransactionDateTime, TestData.TransactionNumber, transactionType, @@ -1629,7 +1623,7 @@ public void TransactionAggregate_AddFeePendingSettlement_UnsupportedFeeType_Erro [InlineData(FeeType.ServiceProvider)] [InlineData(FeeType.Merchant)] public void TransactionAggregate_AddFeePendingSettlement_LogonTransaction_ErrorThrown(FeeType feeType){ - TransactionAggregate transactionAggregate = TransactionAggregate.Create(TestData.TransactionId); + Aggregates.TransactionAggregate transactionAggregate = Aggregates.TransactionAggregate.Create(TestData.TransactionId); transactionAggregate.StartTransaction(TestData.TransactionDateTime, TestData.TransactionNumber, TransactionType.Logon, @@ -1658,7 +1652,7 @@ public void TransactionAggregate_AddFeePendingSettlement_LogonTransaction_ErrorT [MemberData(nameof(TransactionAggregate_RecordCostPrice_SaleTransaction_CostPriceRecorded_Data))] public void TransactionAggregate_RecordCostPrice_SaleTransaction_CostPriceRecorded(Decimal unitCost, Decimal totalCost, Decimal? expectedUnitCost, Decimal? expectedTotalCost, Boolean expectedCostsCalculated) { - TransactionAggregate transactionAggregate = TransactionAggregate.Create(TestData.TransactionId); + Aggregates.TransactionAggregate transactionAggregate = Aggregates.TransactionAggregate.Create(TestData.TransactionId); transactionAggregate.StartTransaction(TestData.TransactionDateTime, TestData.TransactionNumber, TransactionType.Logon, @@ -1677,7 +1671,7 @@ public void TransactionAggregate_RecordCostPrice_SaleTransaction_CostPriceRecord [Fact] public void TransactionAggregate_RecordCostPrice_SaleTransaction_CostAlreadyRecorded(){ - TransactionAggregate transactionAggregate = TransactionAggregate.Create(TestData.TransactionId); + Aggregates.TransactionAggregate transactionAggregate = Aggregates.TransactionAggregate.Create(TestData.TransactionId); transactionAggregate.StartTransaction(TestData.TransactionDateTime, TestData.TransactionNumber, TransactionType.Logon, @@ -1694,7 +1688,7 @@ public void TransactionAggregate_RecordCostPrice_SaleTransaction_CostAlreadyReco [Fact] public void TransactionAggregate_RecordCostPrice_SaleTransaction_NotStarted_ErrorThrown(){ - TransactionAggregate transactionAggregate = TransactionAggregate.Create(TestData.TransactionId); + Aggregates.TransactionAggregate transactionAggregate = Aggregates.TransactionAggregate.Create(TestData.TransactionId); Should.Throw(() => { transactionAggregate.RecordCostPrice(TestData.UnitCostPrice, TestData.TotalCostPrice); }); } diff --git a/TransactionProcessor.FloatAggregate.Tests/TransactionProcessor.FloatAggregate.Tests.csproj b/TransactionProcessor.Aggregates.Tests/TransactionProcessor.Aggregates.Tests.csproj similarity index 52% rename from TransactionProcessor.FloatAggregate.Tests/TransactionProcessor.FloatAggregate.Tests.csproj rename to TransactionProcessor.Aggregates.Tests/TransactionProcessor.Aggregates.Tests.csproj index 9385ae96..7a2dc8a6 100644 --- a/TransactionProcessor.FloatAggregate.Tests/TransactionProcessor.FloatAggregate.Tests.csproj +++ b/TransactionProcessor.Aggregates.Tests/TransactionProcessor.Aggregates.Tests.csproj @@ -1,31 +1,29 @@ - + net8.0 enable enable - None + false true - + + - - - runtime; build; native; contentfiles; analyzers; buildtransitive - all - - - runtime; build; native; contentfiles; analyzers; buildtransitive - all - + + - + + + + + diff --git a/TransactionProcessor.VoucherAggregate.Tests/VoucherAggregateTests.cs b/TransactionProcessor.Aggregates.Tests/VoucherAggregateTests.cs similarity index 81% rename from TransactionProcessor.VoucherAggregate.Tests/VoucherAggregateTests.cs rename to TransactionProcessor.Aggregates.Tests/VoucherAggregateTests.cs index 6961b8bf..eeb2dc12 100644 --- a/TransactionProcessor.VoucherAggregate.Tests/VoucherAggregateTests.cs +++ b/TransactionProcessor.Aggregates.Tests/VoucherAggregateTests.cs @@ -1,15 +1,14 @@ -namespace TransactionProcessor.VoucherAggregate.Tests; - using Shouldly; -using Testing; -using Xunit; +using TransactionProcessor.Testing; + +namespace TransactionProcessor.Aggregates.Tests; - public class VoucherAggregateTests +public class VoucherAggregateTests { [Fact] public void VoucherAggregate_CanBeCreated_IsCreated() { - VoucherAggregate aggregate = VoucherAggregate.Create(TestData.VoucherId); + Aggregates.VoucherAggregate aggregate = Aggregates.VoucherAggregate.Create(TestData.VoucherId); aggregate.AggregateId.ShouldBe(TestData.VoucherId); } @@ -17,7 +16,7 @@ public void VoucherAggregate_CanBeCreated_IsCreated() [Fact] public void VoucherAggregate_Generate_VoucherIsGenerated() { - VoucherAggregate aggregate = VoucherAggregate.Create(TestData.VoucherId); + Aggregates.VoucherAggregate aggregate = Aggregates.VoucherAggregate.Create(TestData.VoucherId); aggregate.Generate(TestData.OperatorId, TestData.EstateId, TestData.TransactionId, TestData.GeneratedDateTime, TestData.Value); var voucher = aggregate.GetVoucher(); @@ -33,7 +32,7 @@ public void VoucherAggregate_Generate_VoucherIsGenerated() [Fact] public void VoucherAggregate_Generate_VoucherAlreadyGenerated_ErrorThrown() { - VoucherAggregate aggregate = VoucherAggregate.Create(TestData.VoucherId); + Aggregates.VoucherAggregate aggregate = Aggregates.VoucherAggregate.Create(TestData.VoucherId); aggregate.Generate(TestData.OperatorId, TestData.EstateId, TestData.TransactionId, TestData.GeneratedDateTime, TestData.Value); Should.Throw(() => @@ -45,7 +44,7 @@ public void VoucherAggregate_Generate_VoucherAlreadyGenerated_ErrorThrown() [Fact] public void VoucherAggregate_Generate_VoucherAlreadyIssued_ErrorThrown() { - VoucherAggregate aggregate = VoucherAggregate.Create(TestData.VoucherId); + Aggregates.VoucherAggregate aggregate = Aggregates.VoucherAggregate.Create(TestData.VoucherId); aggregate.Generate(TestData.OperatorId, TestData.EstateId, TestData.TransactionId, TestData.GeneratedDateTime, TestData.Value); aggregate.Issue(TestData.RecipientEmail, TestData.RecipientMobile, TestData.IssuedDateTime); Should.Throw(() => @@ -57,7 +56,7 @@ public void VoucherAggregate_Generate_VoucherAlreadyIssued_ErrorThrown() [Fact] public void VoucherAggregate_Generate_InvalidOperatorIdentifier_ErrorIsThrown() { - VoucherAggregate aggregate = VoucherAggregate.Create(TestData.VoucherId); + Aggregates.VoucherAggregate aggregate = Aggregates.VoucherAggregate.Create(TestData.VoucherId); Should.Throw(() => { @@ -68,7 +67,7 @@ public void VoucherAggregate_Generate_InvalidOperatorIdentifier_ErrorIsThrown() [Fact] public void VoucherAggregate_Generate_InvalidEstateId_ErrorIsThrown() { - VoucherAggregate aggregate = VoucherAggregate.Create(TestData.VoucherId); + Aggregates.VoucherAggregate aggregate = Aggregates.VoucherAggregate.Create(TestData.VoucherId); Should.Throw(() => { @@ -81,7 +80,7 @@ public void VoucherAggregate_Generate_InvalidEstateId_ErrorIsThrown() [InlineData(-1)] public void VoucherAggregate_Generate_InvalidValue_ErrorIsThrown(Decimal value) { - VoucherAggregate aggregate = VoucherAggregate.Create(TestData.VoucherId); + Aggregates.VoucherAggregate aggregate = Aggregates.VoucherAggregate.Create(TestData.VoucherId); Should.Throw(() => { @@ -92,7 +91,7 @@ public void VoucherAggregate_Generate_InvalidValue_ErrorIsThrown(Decimal value) [Fact] public void VoucherAggregate_Issue_VoucherIsIssued() { - VoucherAggregate aggregate = VoucherAggregate.Create(TestData.VoucherId); + Aggregates.VoucherAggregate aggregate = Aggregates.VoucherAggregate.Create(TestData.VoucherId); aggregate.Generate(TestData.OperatorId, TestData.EstateId, TestData.TransactionId, TestData.GeneratedDateTime, TestData.Value); aggregate.Issue(TestData.RecipientEmail, TestData.RecipientMobile, TestData.IssuedDateTime); var voucher = aggregate.GetVoucher(); @@ -102,7 +101,7 @@ public void VoucherAggregate_Issue_VoucherIsIssued() [Fact] public void VoucherAggregate_Issue_VoucherNotGenerated_ErrorThrown() { - VoucherAggregate aggregate = VoucherAggregate.Create(TestData.VoucherId); + Aggregates.VoucherAggregate aggregate = Aggregates.VoucherAggregate.Create(TestData.VoucherId); Should.Throw(() => { @@ -112,7 +111,7 @@ public void VoucherAggregate_Issue_VoucherNotGenerated_ErrorThrown() [Fact] public void VoucherAggregate_Issue_VoucherAlreadyIssued_ErrorThrown() { - VoucherAggregate aggregate = VoucherAggregate.Create(TestData.VoucherId); + Aggregates.VoucherAggregate aggregate = Aggregates.VoucherAggregate.Create(TestData.VoucherId); aggregate.Generate(TestData.OperatorId, TestData.EstateId, TestData.TransactionId, TestData.GeneratedDateTime, TestData.Value); aggregate.Issue(TestData.RecipientEmail, TestData.RecipientMobile, TestData.IssuedDateTime); @@ -129,7 +128,7 @@ public void VoucherAggregate_Issue_VoucherAlreadyIssued_ErrorThrown() [InlineData(null, "")] public void VoucherAggregate_Issue_EitherEmailOrMobileIsRequired_ErrorThrown(String recipientEmail, String recipientMobile) { - VoucherAggregate aggregate = VoucherAggregate.Create(TestData.VoucherId); + Aggregates.VoucherAggregate aggregate = Aggregates.VoucherAggregate.Create(TestData.VoucherId); aggregate.Generate(TestData.OperatorId, TestData.EstateId, TestData.TransactionId, TestData.GeneratedDateTime, TestData.Value); Should.Throw(() => { @@ -140,7 +139,7 @@ public void VoucherAggregate_Issue_EitherEmailOrMobileIsRequired_ErrorThrown(Str [Fact] public void VoucherAggregate_AddBarcode_BarcodeIsAdded() { - VoucherAggregate aggregate = VoucherAggregate.Create(TestData.VoucherId); + Aggregates.VoucherAggregate aggregate = Aggregates.VoucherAggregate.Create(TestData.VoucherId); aggregate.Generate(TestData.OperatorId, TestData.EstateId, TestData.TransactionId, TestData.GeneratedDateTime, TestData.Value); aggregate.AddBarcode(TestData.Barcode); var voucher = aggregate.GetVoucher(); @@ -152,7 +151,7 @@ public void VoucherAggregate_AddBarcode_BarcodeIsAdded() [InlineData("")] public void VoucherAggregate_AddBarcode_InvalidBarcode_ErrorThrown(String barcode) { - VoucherAggregate aggregate = VoucherAggregate.Create(TestData.VoucherId); + Aggregates.VoucherAggregate aggregate = Aggregates.VoucherAggregate.Create(TestData.VoucherId); aggregate.Generate(TestData.OperatorId, TestData.EstateId, TestData.TransactionId, TestData.GeneratedDateTime, TestData.Value); Should.Throw(() => @@ -164,7 +163,7 @@ public void VoucherAggregate_AddBarcode_InvalidBarcode_ErrorThrown(String barcod [Fact] public void VoucherAggregate_AddBarcode_VoucherNotGenerated_ErrorThrown() { - VoucherAggregate aggregate = VoucherAggregate.Create(TestData.VoucherId); + Aggregates.VoucherAggregate aggregate = Aggregates.VoucherAggregate.Create(TestData.VoucherId); Should.Throw(() => { @@ -175,7 +174,7 @@ public void VoucherAggregate_AddBarcode_VoucherNotGenerated_ErrorThrown() [Fact] public void VoucherAggregate_Redeem_VoucherIsRedeemed() { - VoucherAggregate aggregate = VoucherAggregate.Create(TestData.VoucherId); + Aggregates.VoucherAggregate aggregate = Aggregates.VoucherAggregate.Create(TestData.VoucherId); aggregate.Generate(TestData.OperatorId, TestData.EstateId, TestData.TransactionId, TestData.GeneratedDateTime, TestData.Value); aggregate.Issue(TestData.RecipientEmail, TestData.RecipientMobile, TestData.IssuedDateTime); aggregate.Redeem(TestData.RedeemedDateTime); @@ -187,7 +186,7 @@ public void VoucherAggregate_Redeem_VoucherIsRedeemed() [Fact] public void VoucherAggregate_Redeem_VoucherNotGenerated_ErrorThrown() { - VoucherAggregate aggregate = VoucherAggregate.Create(TestData.VoucherId); + Aggregates.VoucherAggregate aggregate = Aggregates.VoucherAggregate.Create(TestData.VoucherId); Should.Throw(() => { @@ -198,7 +197,7 @@ public void VoucherAggregate_Redeem_VoucherNotGenerated_ErrorThrown() [Fact] public void VoucherAggregate_Redeem_VoucherNotIssued_ErrorThrown() { - VoucherAggregate aggregate = VoucherAggregate.Create(TestData.VoucherId); + Aggregates.VoucherAggregate aggregate = Aggregates.VoucherAggregate.Create(TestData.VoucherId); aggregate.Generate(TestData.OperatorId, TestData.EstateId, TestData.TransactionId, TestData.GeneratedDateTime, TestData.Value); Should.Throw(() => { @@ -209,7 +208,7 @@ public void VoucherAggregate_Redeem_VoucherNotIssued_ErrorThrown() [Fact] public void VoucherAggregate_Redeem_VoucherAlreadyRedeemed_ErrorThrown() { - VoucherAggregate aggregate = VoucherAggregate.Create(TestData.VoucherId); + Aggregates.VoucherAggregate aggregate = Aggregates.VoucherAggregate.Create(TestData.VoucherId); aggregate.Generate(TestData.OperatorId, TestData.EstateId, TestData.TransactionId, TestData.GeneratedDateTime, TestData.Value); aggregate.Issue(TestData.RecipientEmail, TestData.RecipientMobile, TestData.IssuedDateTime); aggregate.Redeem(TestData.RedeemedDateTime); diff --git a/TransactionProcessor.Aggregates/EstateAggregate.cs b/TransactionProcessor.Aggregates/EstateAggregate.cs new file mode 100644 index 00000000..770a94dc --- /dev/null +++ b/TransactionProcessor.Aggregates/EstateAggregate.cs @@ -0,0 +1,223 @@ +using System.Diagnostics.CodeAnalysis; +using Shared.DomainDrivenDesign.EventSourcing; +using Shared.EventStore.Aggregate; +using Shared.General; +using TransactionProcessor.Aggregates.Models; +using TransactionProcessor.Estate.DomainEvents; + +namespace TransactionProcessor.Aggregates{ + public static class EstateAggregateExtensions{ + #region Methods + + public static void AddOperator(this EstateAggregate aggregate, + Guid operatorId){ + + aggregate.CheckEstateHasBeenCreated(); + aggregate.CheckOperatorHasNotAlreadyBeenCreated(operatorId); + + OperatorAddedToEstateEvent operatorAddedToEstateEvent = + new OperatorAddedToEstateEvent(aggregate.AggregateId, operatorId); + + aggregate.ApplyAndAppend(operatorAddedToEstateEvent); + } + + public static void RemoveOperator(this EstateAggregate aggregate, + Guid operatorId) + { + + aggregate.CheckEstateHasBeenCreated(); + aggregate.CheckOperatorHasBeenAdded(operatorId); + + OperatorRemovedFromEstateEvent operatorRemovedFromEstateEvent = + new OperatorRemovedFromEstateEvent(aggregate.AggregateId, operatorId); + + aggregate.ApplyAndAppend(operatorRemovedFromEstateEvent); + } + + public static void AddSecurityUser(this EstateAggregate aggregate, + Guid securityUserId, + String emailAddress){ + aggregate.CheckEstateHasBeenCreated(); + + SecurityUserAddedToEstateEvent securityUserAddedEvent = new SecurityUserAddedToEstateEvent(aggregate.AggregateId, securityUserId, emailAddress); + + aggregate.ApplyAndAppend(securityUserAddedEvent); + } + + public static void Create(this EstateAggregate aggregate, String estateName){ + Guard.ThrowIfNullOrEmpty(estateName, typeof(ArgumentNullException), "Estate name must be provided when registering a new estate"); + + // Just return if already created + if (aggregate.IsCreated) + return; + + EstateCreatedEvent estateCreatedEvent = new EstateCreatedEvent(aggregate.AggregateId, estateName); + + aggregate.ApplyAndAppend(estateCreatedEvent); + } + + public static void GenerateReference(this EstateAggregate aggregate){ + // Just return as we already have a reference allocated + if (String.IsNullOrEmpty(aggregate.EstateReference) == false) + return; + + aggregate.CheckEstateHasBeenCreated(); + + String reference = $"{aggregate.AggregateId.GetHashCode():X}"; + + EstateReferenceAllocatedEvent estateReferenceAllocatedEvent = new EstateReferenceAllocatedEvent(aggregate.AggregateId, reference); + + aggregate.ApplyAndAppend(estateReferenceAllocatedEvent); + } + + public static TransactionProcessor.Models.Estate GetEstate(this EstateAggregate aggregate){ + TransactionProcessor.Models.Estate estateModel = new TransactionProcessor.Models.Estate(); + + estateModel.EstateId = aggregate.AggregateId; + estateModel.Name = aggregate.EstateName; + estateModel.Reference = aggregate.EstateReference; + + estateModel.Operators = new List(); + if (aggregate.Operators.Any()){ + + foreach (KeyValuePair @operator in aggregate.Operators){ + estateModel.Operators.Add(new TransactionProcessor.Models.EstateOperator + { + OperatorId = @operator.Key, + IsDeleted = @operator.Value.IsDeleted, + }); + } + } + + estateModel.SecurityUsers = new List(); + if (aggregate.SecurityUsers.Any()){ + + foreach (KeyValuePair securityUser in aggregate.SecurityUsers){ + estateModel.SecurityUsers.Add(new TransactionProcessor.Models.SecurityUser + { + EmailAddress = securityUser.Value.EmailAddress, + SecurityUserId = securityUser.Key + }); + } + } + + return estateModel; + } + + public static void PlayEvent(this EstateAggregate aggregate, SecurityUserAddedToEstateEvent domainEvent){ + SecurityUser securityUser = new (domainEvent.EmailAddress); + + aggregate.SecurityUsers.Add(domainEvent.SecurityUserId,securityUser); + } + + public static void PlayEvent(this EstateAggregate aggregate, EstateCreatedEvent domainEvent){ + aggregate.EstateName = domainEvent.EstateName; + aggregate.IsCreated = true; + } + + public static void PlayEvent(this EstateAggregate aggregate, EstateReferenceAllocatedEvent domainEvent){ + aggregate.EstateReference = domainEvent.EstateReference; + } + + /// + /// Operators the added to estate event. + /// + /// The domain event. + public static void PlayEvent(this EstateAggregate aggregate, OperatorAddedToEstateEvent domainEvent){ + Operator @operator = new (); + + aggregate.Operators.Add(domainEvent.OperatorId, @operator); + } + + public static void PlayEvent(this EstateAggregate aggregate, OperatorRemovedFromEstateEvent domainEvent){ + KeyValuePair @operator = aggregate.Operators.Single(o => o.Key == domainEvent.OperatorId); + aggregate.Operators[domainEvent.OperatorId] = @operator.Value with{ + IsDeleted = true + }; + } + + private static void CheckEstateHasBeenCreated(this EstateAggregate aggregate){ + if (aggregate.IsCreated == false){ + throw new InvalidOperationException("Estate has not been created"); + } + } + + private static void CheckOperatorHasNotAlreadyBeenCreated(this EstateAggregate aggregate, + Guid operatorId){ + Boolean operatorRecord = aggregate.Operators.ContainsKey(operatorId); + + if (operatorRecord == true){ + throw new InvalidOperationException($"Duplicate operator details are not allowed, an operator already exists on this estate with Id [{operatorId}]"); + } + } + + private static void CheckOperatorHasBeenAdded(this EstateAggregate aggregate, + Guid operatorId) + { + Boolean operatorRecord = aggregate.Operators.ContainsKey(operatorId); + + if (operatorRecord == false) + { + throw new InvalidOperationException($"Operator not added to this Estate with Id [{operatorId}]"); + } + } + + #endregion + } + + public record EstateAggregate : Aggregate{ + #region Fields + + internal readonly Dictionary Operators; + + internal readonly Dictionary SecurityUsers; + + #endregion + + #region Constructors + + [ExcludeFromCodeCoverage] + public EstateAggregate(){ + // Nothing here + this.Operators = new Dictionary(); + this.SecurityUsers = new Dictionary(); + } + + private EstateAggregate(Guid aggregateId){ + Guard.ThrowIfInvalidGuid(aggregateId, "Aggregate Id cannot be an Empty Guid"); + + this.AggregateId = aggregateId; + this.Operators = new Dictionary(); + this.SecurityUsers = new Dictionary(); + } + + #endregion + + #region Properties + + public String EstateName{ get; internal set; } + + public String EstateReference{ get; internal set; } + + public Boolean IsCreated{ get; internal set; } + + #endregion + + #region Methods + + public static EstateAggregate Create(Guid aggregateId){ + return new EstateAggregate(aggregateId); + } + + public override void PlayEvent(IDomainEvent domainEvent) => EstateAggregateExtensions.PlayEvent(this, (dynamic)domainEvent); + + [ExcludeFromCodeCoverage] + protected override Object GetMetadata(){ + return new{ + EstateId = this.AggregateId + }; + } + + #endregion + } +} \ No newline at end of file diff --git a/TransactionProcessor.Aggregates/FloatActivityAggregate.cs b/TransactionProcessor.Aggregates/FloatActivityAggregate.cs new file mode 100644 index 00000000..2e4dc2ea --- /dev/null +++ b/TransactionProcessor.Aggregates/FloatActivityAggregate.cs @@ -0,0 +1,94 @@ +using System.Diagnostics.CodeAnalysis; +using System; +using Shared.DomainDrivenDesign.EventSourcing; +using Shared.EventStore.Aggregate; +using Shared.General; +using TransactionProcessor.Float.DomainEvents; + +namespace TransactionProcessor.Aggregates +{ + public static class FloatActivityAggregateExtensions + { + + public static void PlayEvent(this FloatActivityAggregate aggregate, + FloatAggregateCreditedEvent domainEvent) + { + aggregate.CreditCount++; + aggregate.Credits.Add(domainEvent.CreditId); + } + + public static void PlayEvent(this FloatActivityAggregate aggregate, + FloatAggregateDebitedEvent domainEvent) + { + aggregate.DebitCount++; + aggregate.Debits.Add(domainEvent.DebitId); + } + + public static void RecordCreditPurchase(this FloatActivityAggregate aggregate, + Guid estateId, + DateTime activityDateTime, + Decimal creditAmount, + Guid creditId) + { + + if (aggregate.Credits.Any(c => c == creditId)) + return; + + FloatAggregateCreditedEvent floatAggregateCreditedEvent = new(aggregate.AggregateId, estateId, activityDateTime, creditAmount, creditId); + aggregate.ApplyAndAppend(floatAggregateCreditedEvent); + } + + public static void RecordTransactionAgainstFloat(this FloatActivityAggregate aggregate, + Guid estateId, + DateTime activityDateTime, + Decimal transactionAmount, + Guid transactionId) + { + if (aggregate.Debits.Any(c => c == transactionId)) + return; + + FloatAggregateDebitedEvent floatAggregateCreditedEvent = new(aggregate.AggregateId, estateId, activityDateTime, transactionAmount, transactionId); + aggregate.ApplyAndAppend(floatAggregateCreditedEvent); + } + } + + public record FloatActivityAggregate : Aggregate + { + public override void PlayEvent(IDomainEvent domainEvent) => FloatActivityAggregateExtensions.PlayEvent(this, (dynamic)domainEvent); + + public Int32 CreditCount { get; internal set; } + public Int32 DebitCount { get; internal set; } + public List Credits { get; internal set; } + public List Debits { get; internal set; } + [ExcludeFromCodeCoverage] + protected override Object GetMetadata() + { + return new + { + + }; + } + + + [ExcludeFromCodeCoverage] + public FloatActivityAggregate() + { + this.Credits = new List(); + this.Debits = new List(); + } + + private FloatActivityAggregate(Guid aggregateId) + { + Guard.ThrowIfInvalidGuid(aggregateId, "Aggregate Id cannot be an Empty Guid"); + + this.AggregateId = aggregateId; + this.Credits = new List(); + this.Debits = new List(); + } + + public static FloatActivityAggregate Create(Guid aggregateId) + { + return new FloatActivityAggregate(aggregateId); + } + } +} diff --git a/TransactionProcessor.FloatAggregate/FloatAggregate.cs b/TransactionProcessor.Aggregates/FloatAggregate.cs similarity index 85% rename from TransactionProcessor.FloatAggregate/FloatAggregate.cs rename to TransactionProcessor.Aggregates/FloatAggregate.cs index 699f27b4..322deeab 100644 --- a/TransactionProcessor.FloatAggregate/FloatAggregate.cs +++ b/TransactionProcessor.Aggregates/FloatAggregate.cs @@ -1,11 +1,16 @@ -namespace TransactionProcessor.FloatAggregate +using Shared.DomainDrivenDesign.EventSourcing; +using Shared.EventStore.Aggregate; +using Shared.General; +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using TransactionProcessor.Float.DomainEvents; + +namespace TransactionProcessor.Aggregates { - using System.Diagnostics.CodeAnalysis; - using Float.DomainEvents; - using Shared.DomainDrivenDesign.EventSourcing; - using Shared.EventStore.Aggregate; - using Shared.General; - public static class FloatAggregateExtensions { public static void PlayEvent(this FloatAggregate aggregate, FloatCreatedForContractProductEvent domainEvent) @@ -23,10 +28,10 @@ public static void PlayEvent(this FloatAggregate aggregate, FloatCreditPurchased aggregate.TotalCreditPurchases += domainEvent.Amount; aggregate.TotalCostPrice += domainEvent.CostPrice; aggregate.UnitCostPrice = (aggregate.TotalCostPrice / aggregate.TotalCreditPurchases); - aggregate.Credits.Add((domainEvent.CreditPurchasedDateTime, domainEvent.Amount,domainEvent.CostPrice)); + aggregate.Credits.Add((domainEvent.CreditPurchasedDateTime, domainEvent.Amount, domainEvent.CostPrice)); } - - public static void CreateFloat(this FloatAggregate aggregate, + + public static void CreateFloat(this FloatAggregate aggregate, Guid estateId, Guid contractId, Guid productId, @@ -34,7 +39,7 @@ public static void CreateFloat(this FloatAggregate aggregate, { aggregate.ValidateFloatIsNotAlreadyCreated(); - FloatCreatedForContractProductEvent floatCreatedForContractProductEvent = new (aggregate.AggregateId, + FloatCreatedForContractProductEvent floatCreatedForContractProductEvent = new(aggregate.AggregateId, estateId, contractId, productId, createdDateTime); aggregate.ApplyAndAppend(floatCreatedForContractProductEvent); @@ -44,26 +49,30 @@ public static void RecordCreditPurchase(this FloatAggregate aggregate, DateTime { aggregate.ValidateFloatIsAlreadyCreated(); aggregate.ValidateCreditIsNotADuplicate(creditPurchasedDate, amount, costPrice); - - FloatCreditPurchasedEvent floatCreditPurchasedEvent = new (aggregate.AggregateId, aggregate.EstateId, + + FloatCreditPurchasedEvent floatCreditPurchasedEvent = new(aggregate.AggregateId, aggregate.EstateId, creditPurchasedDate, amount, costPrice); aggregate.ApplyAndAppend(floatCreditPurchasedEvent); } - + public static Decimal GetUnitCostPrice(this FloatAggregate aggregate) { return Math.Round(aggregate.UnitCostPrice, 4); } - public static void ValidateFloatIsAlreadyCreated(this FloatAggregate aggregate){ - if (aggregate.IsCreated == false){ + public static void ValidateFloatIsAlreadyCreated(this FloatAggregate aggregate) + { + if (aggregate.IsCreated == false) + { throw new InvalidOperationException($"Float Aggregate Id {aggregate.AggregateId} must be created to perform this operation"); } } - public static void ValidateFloatIsNotAlreadyCreated(this FloatAggregate aggregate){ - if (aggregate.IsCreated == true){ + public static void ValidateFloatIsNotAlreadyCreated(this FloatAggregate aggregate) + { + if (aggregate.IsCreated == true) + { throw new InvalidOperationException($"Float Aggregate Id {aggregate.AggregateId} must not be created to perform this operation"); } } @@ -86,14 +95,15 @@ public record FloatAggregate : Aggregate protected override Object GetMetadata() { return new - { - this.EstateId - }; + { + this.EstateId + }; } [ExcludeFromCodeCoverage] - public FloatAggregate(){ + public FloatAggregate() + { this.Credits = new List<(DateTime creditPurchasedDate, Decimal amount, Decimal costPrice)>(); } @@ -106,7 +116,7 @@ private FloatAggregate(Guid aggregateId) } internal List<(DateTime creditPurchasedDate, Decimal amount, Decimal costPrice)> Credits; - + public Boolean IsCreated { get; internal set; } public Guid EstateId { get; internal set; } @@ -116,10 +126,10 @@ private FloatAggregate(Guid aggregateId) public DateTime CreatedDateTime { get; internal set; } public Int32 NumberOfCreditPurchases { get; internal set; } - - + + public Decimal TotalCreditPurchases { get; internal set; } - + public Decimal TotalCostPrice { get; internal set; } public Decimal UnitCostPrice { get; internal set; } diff --git a/TransactionProcessor.Aggregates/Models/Operator.cs b/TransactionProcessor.Aggregates/Models/Operator.cs new file mode 100644 index 00000000..89cf6580 --- /dev/null +++ b/TransactionProcessor.Aggregates/Models/Operator.cs @@ -0,0 +1,6 @@ +using System; + +namespace TransactionProcessor.Aggregates.Models +{ + internal record Operator(bool IsDeleted = false); +} \ No newline at end of file diff --git a/TransactionProcessor.Aggregates/Models/SecurityUser.cs b/TransactionProcessor.Aggregates/Models/SecurityUser.cs new file mode 100644 index 00000000..98f63da7 --- /dev/null +++ b/TransactionProcessor.Aggregates/Models/SecurityUser.cs @@ -0,0 +1,6 @@ +using System; + +namespace TransactionProcessor.Aggregates.Models +{ + internal record SecurityUser(string EmailAddress); +} diff --git a/TransactionProcessor.ReconciliationAggregate/ReconciliationAggregate.cs b/TransactionProcessor.Aggregates/ReconciliationAggregate.cs similarity index 99% rename from TransactionProcessor.ReconciliationAggregate/ReconciliationAggregate.cs rename to TransactionProcessor.Aggregates/ReconciliationAggregate.cs index 16987dbd..8a48ca8a 100644 --- a/TransactionProcessor.ReconciliationAggregate/ReconciliationAggregate.cs +++ b/TransactionProcessor.Aggregates/ReconciliationAggregate.cs @@ -1,6 +1,6 @@ using System; -namespace TransactionProcessor.ReconciliationAggregate +namespace TransactionProcessor.Aggregates { using System.Diagnostics.CodeAnalysis; using Reconciliation.DomainEvents; diff --git a/TransactionProcessor.SettlementAggregates/SettlementAggregate.cs b/TransactionProcessor.Aggregates/SettlementAggregate.cs similarity index 99% rename from TransactionProcessor.SettlementAggregates/SettlementAggregate.cs rename to TransactionProcessor.Aggregates/SettlementAggregate.cs index 87e7c1b0..1216d9f6 100644 --- a/TransactionProcessor.SettlementAggregates/SettlementAggregate.cs +++ b/TransactionProcessor.Aggregates/SettlementAggregate.cs @@ -1,4 +1,6 @@ -namespace TransactionProcessor.SettlementAggregates +using TransactionProcessor.Models; + +namespace TransactionProcessor.Aggregates { using System; using System.Collections.Generic; diff --git a/TransactionProcessor.TransactionAgrgegate/TransactionAggregate.cs b/TransactionProcessor.Aggregates/TransactionAggregate.cs similarity index 99% rename from TransactionProcessor.TransactionAgrgegate/TransactionAggregate.cs rename to TransactionProcessor.Aggregates/TransactionAggregate.cs index e51f8602..f8d894c4 100644 --- a/TransactionProcessor.TransactionAgrgegate/TransactionAggregate.cs +++ b/TransactionProcessor.Aggregates/TransactionAggregate.cs @@ -1,4 +1,7 @@ -namespace TransactionProcessor.TransactionAggregate +using TransactionProcessor.Models; +using TransactionProcessor.Transaction.DomainEvents; + +namespace TransactionProcessor.Aggregates { using System; using System.Collections.Generic; @@ -9,7 +12,6 @@ using Shared.DomainDrivenDesign.EventSourcing; using Shared.EventStore.Aggregate; using Shared.General; - using Transaction.DomainEvents; public static class TransactionAggregateExtensions{ @@ -56,9 +58,9 @@ public static List GetFees(this TransactionAggregate aggregate) return aggregate.CalculatedFees; } - public static Transaction GetTransaction(this TransactionAggregate aggregate) + public static TransactionProcessor.Models.Transaction GetTransaction(this TransactionAggregate aggregate) { - return new Transaction + return new TransactionProcessor.Models.Transaction { AuthorisationCode = aggregate.AuthorisationCode, MerchantId = aggregate.MerchantId, diff --git a/TransactionProcessor.Aggregates/TransactionProcessor.Aggregates.csproj b/TransactionProcessor.Aggregates/TransactionProcessor.Aggregates.csproj new file mode 100644 index 00000000..c7073642 --- /dev/null +++ b/TransactionProcessor.Aggregates/TransactionProcessor.Aggregates.csproj @@ -0,0 +1,22 @@ + + + + net8.0 + enable + enable + + + + + + + + + + + + + + + + diff --git a/TransactionProcessor.VoucherAggregate/VoucherAggregate.cs b/TransactionProcessor.Aggregates/VoucherAggregate.cs similarity index 96% rename from TransactionProcessor.VoucherAggregate/VoucherAggregate.cs rename to TransactionProcessor.Aggregates/VoucherAggregate.cs index 9f7d1f50..f898d6e3 100644 --- a/TransactionProcessor.VoucherAggregate/VoucherAggregate.cs +++ b/TransactionProcessor.Aggregates/VoucherAggregate.cs @@ -1,11 +1,11 @@ -namespace TransactionProcessor.VoucherAggregate; - -using System.Diagnostics.CodeAnalysis; -using Models; +using System.Diagnostics.CodeAnalysis; using Shared.DomainDrivenDesign.EventSourcing; using Shared.EventStore.Aggregate; using Shared.General; -using Voucher.DomainEvents; +using TransactionProcessor.Models; +using TransactionProcessor.Voucher.DomainEvents; + +namespace TransactionProcessor.Aggregates; public static class VoucherAggregateExtensions{ public static void AddBarcode(this VoucherAggregate aggregate, String barcodeAsBase64) @@ -46,9 +46,9 @@ public static void Generate(this VoucherAggregate aggregate, aggregate.ApplyAndAppend(voucherGeneratedEvent); } - public static Voucher GetVoucher(this VoucherAggregate aggregate) + public static TransactionProcessor.Models.Voucher GetVoucher(this VoucherAggregate aggregate) { - return new Voucher + return new TransactionProcessor.Models.Voucher { EstateId = aggregate.EstateId, Value = aggregate.Value, diff --git a/TransactionProcessor.BusinessLogic.Tests/DomainEventHandlers/TransactionDomainEventHandlerTests.cs b/TransactionProcessor.BusinessLogic.Tests/DomainEventHandlers/TransactionDomainEventHandlerTests.cs index 84019183..e0d36a01 100644 --- a/TransactionProcessor.BusinessLogic.Tests/DomainEventHandlers/TransactionDomainEventHandlerTests.cs +++ b/TransactionProcessor.BusinessLogic.Tests/DomainEventHandlers/TransactionDomainEventHandlerTests.cs @@ -18,7 +18,6 @@ namespace TransactionProcessor.BusinessLogic.Tests.DomainEventHandlers using EstateManagement.DataTransferObjects.Responses.Contract; using EstateManagement.DataTransferObjects.Responses.Merchant; using EventHandling; - using FloatAggregate; using MessagingService.Client; using MessagingService.DataTransferObjects; using Microsoft.Extensions.Caching.Memory; @@ -26,7 +25,6 @@ namespace TransactionProcessor.BusinessLogic.Tests.DomainEventHandlers using Models; using Moq; using SecurityService.Client; - using SettlementAggregates; using Shared.DomainDrivenDesign.EventSourcing; using Shared.EventStore.Aggregate; using Shared.EventStore.EventStore; @@ -35,7 +33,6 @@ namespace TransactionProcessor.BusinessLogic.Tests.DomainEventHandlers using Shared.Logger; using Shouldly; using Testing; - using TransactionAggregate; using TransactionProcessor.Settlement.DomainEvents; using TransactionProcessor.Transaction.DomainEvents; using Xunit; diff --git a/TransactionProcessor.BusinessLogic.Tests/DomainEventHandlers/VoucherDomainEventHandlerTests.cs b/TransactionProcessor.BusinessLogic.Tests/DomainEventHandlers/VoucherDomainEventHandlerTests.cs index d4f7a8fb..1eb891a9 100644 --- a/TransactionProcessor.BusinessLogic.Tests/DomainEventHandlers/VoucherDomainEventHandlerTests.cs +++ b/TransactionProcessor.BusinessLogic.Tests/DomainEventHandlers/VoucherDomainEventHandlerTests.cs @@ -1,4 +1,7 @@ using SimpleResults; +using TransactionProcessor.Aggregates; +using TransactionProcessor.Database.Contexts; +using TransactionProcessor.Database.Entities; namespace TransactionProcessor.BusinessLogic.Tests.DomainEventHandlers; @@ -9,8 +12,6 @@ namespace TransactionProcessor.BusinessLogic.Tests.DomainEventHandlers; using System.Reflection; using System.Threading; using System.Threading.Tasks; -using EstateManagement.Database.Contexts; -using EstateManagement.Database.Entities; using EventHandling; using MessagingService.Client; using Microsoft.EntityFrameworkCore; @@ -23,9 +24,7 @@ namespace TransactionProcessor.BusinessLogic.Tests.DomainEventHandlers; using Shared.General; using Shared.Logger; using Testing; -using VoucherAggregate; using Xunit; -using Transaction = Models.Transaction; public enum TestDatabaseType { @@ -73,7 +72,7 @@ public async Task VoucherDomainEventHandler_VoucherIssuedEvent_WithEmailAddress_ .ReturnsAsync(Result.Success(TestData.GetVoucherAggregateWithRecipientEmail())); EstateManagementGenericContext context = await this.GetContext(Guid.NewGuid().ToString("N"), TestDatabaseType.InMemory); - context.Transactions.Add(new EstateManagement.Database.Entities.Transaction() + context.Transactions.Add(new Database.Entities.Transaction() { TransactionId = TestData.TransactionId, MerchantId = TestData.MerchantId, @@ -122,7 +121,7 @@ public async Task VoucherDomainEventHandler_VoucherIssuedEvent_WithRecipientMobi .ReturnsAsync(Result.Success(TestData.GetVoucherAggregateWithRecipientMobile())); EstateManagementGenericContext context = await this.GetContext(Guid.NewGuid().ToString("N"), TestDatabaseType.InMemory); - context.Transactions.Add(new EstateManagement.Database.Entities.Transaction() + context.Transactions.Add(new Database.Entities.Transaction() { TransactionId = TestData.TransactionId, MerchantId = TestData.MerchantId, diff --git a/TransactionProcessor.BusinessLogic.Tests/Manager/EstateManagementManagerTests.cs b/TransactionProcessor.BusinessLogic.Tests/Manager/EstateManagementManagerTests.cs new file mode 100644 index 00000000..dd0e1a86 --- /dev/null +++ b/TransactionProcessor.BusinessLogic.Tests/Manager/EstateManagementManagerTests.cs @@ -0,0 +1,490 @@ +using EstateManagement.DataTransferObjects.Responses.Merchant; +using Moq; +using Shared.DomainDrivenDesign.EventSourcing; +using Shared.EventStore.Aggregate; +using SimpleResults; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +using Shouldly; +using TransactionProcessor.Aggregates; +using TransactionProcessor.BusinessLogic.Manager; +using TransactionProcessor.ProjectionEngine.Repository; +using TransactionProcessor.Repository; +using TransactionProcessor.Testing; +using Xunit; + +namespace TransactionProcessor.BusinessLogic.Tests.Manager +{ + public class EstateManagementManagerTests + { + private readonly Mock EstateManagementRepository; + private readonly Mock> EstateAggregateRepository; + //private readonly Mock> ContractAggregateRepository; + //private readonly Mock> MerchantAggregateRepository; + //private readonly Mock> OperatorAggregateRepository; + + private readonly EstateManagementManager EstateManagementManager; + + public EstateManagementManagerTests() + { + this.EstateManagementRepository = new Mock(); + + this.EstateAggregateRepository = new Mock>(); + //this.ContractAggregateRepository = new Mock>(); + //this.MerchantAggregateRepository = new Mock>(); + //this.OperatorAggregateRepository = new Mock>(); + + this.EstateManagementManager = new EstateManagementManager(this.EstateManagementRepository.Object, this.EstateAggregateRepository.Object); //, + //this.ContractAggregateRepository.Object, + //this.MerchantAggregateRepository.Object, + //this.OperatorAggregateRepository.Object); + } + + [Fact] + public async Task EstateManagementManager_GetEstates_EstatesAreReturned() + { + this.EstateAggregateRepository.Setup(a => a.GetLatestVersion(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.Aggregates.CreatedEstateAggregate())); + this.EstateManagementRepository.Setup(e => e.GetEstate(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.EstateModel)); + + var getEstatesResult = await this.EstateManagementManager.GetEstates(TestData.EstateId, CancellationToken.None); + getEstatesResult.IsSuccess.ShouldBeTrue(); + var estateModels = getEstatesResult.Data; + estateModels.ShouldNotBeNull(); + estateModels.ShouldHaveSingleItem(); + estateModels.Single().EstateId.ShouldBe(TestData.EstateModel.EstateId); + estateModels.Single().Name.ShouldBe(TestData.EstateModel.Name); + } + + [Fact] + public async Task EstateManagementManager_GetEstates_RepoCallFails_ResultFailed() + { + this.EstateAggregateRepository.Setup(a => a.GetLatestVersion(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.Aggregates.CreatedEstateAggregate())); + this.EstateManagementRepository.Setup(e => e.GetEstate(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Failure()); + + var getEstatesResult = await this.EstateManagementManager.GetEstates(TestData.EstateId, CancellationToken.None); + getEstatesResult.IsFailed.ShouldBeTrue(); + } + + [Fact] + public async Task EstateManagementManager_GetEstate_EstateIsReturned() + { + this.EstateAggregateRepository.Setup(a => a.GetLatestVersion(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.Aggregates.EstateAggregateWithOperator())); + this.EstateManagementRepository.Setup(e => e.GetEstate(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.EstateModel)); + //this.OperatorAggregateRepository.Setup(o => o.GetLatestVersion(It.IsAny(), CancellationToken.None)).ReturnsAsync(Result.Success(TestData.Aggregates.CreatedOperatorAggregate())); + + var getEstateResult = await this.EstateManagementManager.GetEstate(TestData.EstateId, CancellationToken.None); + getEstateResult.IsSuccess.ShouldBeTrue(); + var estateModel = getEstateResult.Data; + estateModel.ShouldNotBeNull(); + estateModel.EstateId.ShouldBe(TestData.EstateModel.EstateId); + estateModel.Name.ShouldBe(TestData.EstateModel.Name); + estateModel.Operators.ShouldHaveSingleItem(); + estateModel.Operators.Single().OperatorId.ShouldBe(TestData.OperatorId); + // TODO: add back in with operator aggregate + //estateModel.Operators.Single().Name.ShouldBe(TestData.OperatorName); + estateModel.Operators.Single().IsDeleted.ShouldBeFalse(); + } + + [Fact] + public async Task EstateManagementManager_GetEstate_InvalidEstateId_ErrorIsThrown() + { + this.EstateAggregateRepository.Setup(a => a.GetLatestVersion(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.Aggregates.EmptyEstateAggregate)); + this.EstateManagementRepository.Setup(e => e.GetEstate(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.EstateModel)); + + var getEstateResult = await this.EstateManagementManager.GetEstate(TestData.EstateId, CancellationToken.None); + getEstateResult.IsFailed.ShouldBeTrue(); + } + + [Fact] + public async Task EstateManagementManager_GetEstate_GetLatestFailed_ErrorIsThrown() + { + this.EstateAggregateRepository.Setup(a => a.GetLatestVersion(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Failure()); + this.EstateManagementRepository.Setup(e => e.GetEstate(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.EstateModel)); + + var getEstateResult = await this.EstateManagementManager.GetEstate(TestData.EstateId, CancellationToken.None); + getEstateResult.IsFailed.ShouldBeTrue(); + } + /* + [Fact] + public async Task EstateManagementManager_GetMerchant_MerchantIsReturned() + { + this.MerchantAggregateRepository.Setup(m => m.GetLatestVersion(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.Aggregates.MerchantAggregateWithEverything(SettlementSchedule.Monthly))); + this.OperatorAggregateRepository.Setup(o => o.GetLatestVersion(It.IsAny(), CancellationToken.None)).ReturnsAsync(Result.Success(TestData.Aggregates.CreatedOperatorAggregate())); + + Merchant expectedModel = TestData.MerchantModelWithAddressesContactsDevicesAndOperatorsAndContracts(SettlementSchedule.Monthly); + + var getMerchantResult = await this.EstateManagementManager.GetMerchant(TestData.EstateId, TestData.MerchantId, CancellationToken.None); + getMerchantResult.IsSuccess.ShouldBeTrue(); + var merchantModel = getMerchantResult.Data; + + merchantModel.ShouldNotBeNull(); + merchantModel.MerchantReportingId.ShouldBe(expectedModel.MerchantReportingId); + merchantModel.EstateId.ShouldBe(expectedModel.EstateId); + merchantModel.EstateReportingId.ShouldBe(expectedModel.EstateReportingId); + merchantModel.NextStatementDate.ShouldBe(expectedModel.NextStatementDate); + merchantModel.MerchantId.ShouldBe(expectedModel.MerchantId); + merchantModel.MerchantName.ShouldBe(expectedModel.MerchantName); + merchantModel.SettlementSchedule.ShouldBe(expectedModel.SettlementSchedule); + + merchantModel.Addresses.ShouldHaveSingleItem(); + merchantModel.Addresses.Single().AddressId.ShouldNotBe(Guid.Empty); + merchantModel.Addresses.Single().AddressLine1.ShouldBe(expectedModel.Addresses.Single().AddressLine1); + merchantModel.Addresses.Single().AddressLine2.ShouldBe(expectedModel.Addresses.Single().AddressLine2); + merchantModel.Addresses.Single().AddressLine3.ShouldBe(expectedModel.Addresses.Single().AddressLine3); + merchantModel.Addresses.Single().AddressLine4.ShouldBe(expectedModel.Addresses.Single().AddressLine4); + merchantModel.Addresses.Single().Country.ShouldBe(expectedModel.Addresses.Single().Country); + merchantModel.Addresses.Single().PostalCode.ShouldBe(expectedModel.Addresses.Single().PostalCode); + merchantModel.Addresses.Single().Region.ShouldBe(expectedModel.Addresses.Single().Region); + merchantModel.Addresses.Single().Town.ShouldBe(expectedModel.Addresses.Single().Town); + + merchantModel.Contacts.ShouldHaveSingleItem(); + merchantModel.Contacts.Single().ContactEmailAddress.ShouldBe(expectedModel.Contacts.Single().ContactEmailAddress); + merchantModel.Contacts.Single().ContactId.ShouldNotBe(Guid.Empty); + merchantModel.Contacts.Single().ContactName.ShouldBe(expectedModel.Contacts.Single().ContactName); + merchantModel.Contacts.Single().ContactPhoneNumber.ShouldBe(expectedModel.Contacts.Single().ContactPhoneNumber); + + merchantModel.Devices.ShouldHaveSingleItem(); + merchantModel.Devices.Single().DeviceId.ShouldBe(expectedModel.Devices.Single().DeviceId); + merchantModel.Devices.Single().DeviceIdentifier.ShouldBe(expectedModel.Devices.Single().DeviceIdentifier); + + merchantModel.Operators.ShouldHaveSingleItem(); + merchantModel.Operators.Single().MerchantNumber.ShouldBe(expectedModel.Operators.Single().MerchantNumber); + merchantModel.Operators.Single().Name.ShouldBe(expectedModel.Operators.Single().Name); + merchantModel.Operators.Single().OperatorId.ShouldBe(expectedModel.Operators.Single().OperatorId); + merchantModel.Operators.Single().TerminalNumber.ShouldBe(expectedModel.Operators.Single().TerminalNumber); + + } + + [Fact] + public async Task EstateManagementManager_GetMerchant_MerchantIsReturnedWithNullAddressesAndContacts() + { + this.MerchantAggregateRepository.Setup(m => m.GetLatestVersion(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.Aggregates.MerchantAggregateWithOperator())); + this.EstateManagementRepository.Setup(m => m.GetMerchant(It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.MerchantModelWithNullAddressesAndContacts)); + this.OperatorAggregateRepository.Setup(o => o.GetLatestVersion(It.IsAny(), CancellationToken.None)).ReturnsAsync(Result.Success(TestData.Aggregates.EmptyOperatorAggregate())); + + var getMerchantResult = await this.EstateManagementManager.GetMerchant(TestData.EstateId, TestData.MerchantId, CancellationToken.None); + getMerchantResult.IsSuccess.ShouldBeTrue(); + var merchantModel = getMerchantResult.Data; + + merchantModel.ShouldNotBeNull(); + merchantModel.MerchantId.ShouldBe(TestData.MerchantId); + merchantModel.MerchantName.ShouldBe(TestData.MerchantName); + merchantModel.Addresses.ShouldBeNull(); + merchantModel.Contacts.ShouldBeNull(); + } + + [Fact] + public async Task EstateManagementManager_GetMerchant_WithAddress_MerchantIsReturnedWithNullContacts() + { + this.MerchantAggregateRepository.Setup(m => m.GetLatestVersion(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.Aggregates.MerchantAggregateWithAddress())); + + var getMerchantResult = await this.EstateManagementManager.GetMerchant(TestData.EstateId, TestData.MerchantId, CancellationToken.None); + getMerchantResult.IsSuccess.ShouldBeTrue(); + var merchantModel = getMerchantResult.Data; + + merchantModel.ShouldNotBeNull(); + merchantModel.MerchantId.ShouldBe(TestData.MerchantId); + merchantModel.MerchantName.ShouldBe(TestData.MerchantName); + merchantModel.Addresses.ShouldHaveSingleItem(); + merchantModel.Contacts.ShouldBeNull(); + } + + [Fact] + public async Task EstateManagementManager_GetMerchant_WithContact_MerchantIsReturnedWithNullAddresses() + { + this.MerchantAggregateRepository.Setup(m => m.GetLatestVersion(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.Aggregates.MerchantAggregateWithContact())); + + var getMerchantResult = await this.EstateManagementManager.GetMerchant(TestData.EstateId, TestData.MerchantId, CancellationToken.None); + getMerchantResult.IsSuccess.ShouldBeTrue(); + var merchantModel = getMerchantResult.Data; + + merchantModel.ShouldNotBeNull(); + merchantModel.MerchantId.ShouldBe(TestData.MerchantId); + merchantModel.MerchantName.ShouldBe(TestData.MerchantName); + merchantModel.Addresses.ShouldBeNull(); + merchantModel.Contacts.ShouldHaveSingleItem(); + } + + [Fact] + public async Task EstateManagementManager_GetMerchant_MerchantNotCreated_ErrorThrown() + { + this.MerchantAggregateRepository.Setup(m => m.GetLatestVersion(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.Aggregates.EmptyMerchantAggregate())); + + var result = await this.EstateManagementManager.GetMerchant(TestData.EstateId, TestData.MerchantId, CancellationToken.None); + result.IsFailed.ShouldBeTrue(); + } + + [Fact] + public async Task EstateManagementManager_GetMerchant_GetLatestFails_ErrorThrown() + { + this.MerchantAggregateRepository.Setup(m => m.GetLatestVersion(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Failure()); + + var result = await this.EstateManagementManager.GetMerchant(TestData.EstateId, TestData.MerchantId, CancellationToken.None); + result.IsFailed.ShouldBeTrue(); + } + + [Fact] + public async Task EstateManagementManager_GetMerchants_MerchantListIsReturned() + { + this.EstateManagementRepository.Setup(e => e.GetMerchants(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(new List + { + TestData + .MerchantModelWithAddressesContactsDevicesAndOperatorsAndContracts() + })); + + Result> getMerchantsResult = await this.EstateManagementManager.GetMerchants(TestData.EstateId, CancellationToken.None); + getMerchantsResult.IsSuccess.ShouldBeTrue(); + var merchantList = getMerchantsResult.Data; + + merchantList.ShouldNotBeNull(); + merchantList.ShouldNotBeEmpty(); + merchantList.ShouldHaveSingleItem(); + } + + [Fact] + public async Task EstateManagementManager_GetMerchants_NullMerchants_ExceptionThrown() + { + List merchants = null; + this.EstateManagementRepository.Setup(e => e.GetMerchants(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(merchants)); + + Result> getMerchantsResult = await this.EstateManagementManager.GetMerchants(TestData.EstateId, CancellationToken.None); + getMerchantsResult.IsFailed.ShouldBeTrue(); + } + + [Fact] + public async Task EstateManagementManager_GetMerchants_EmptyMerchants_ExceptionThrown() + { + List merchants = new List(); + this.EstateManagementRepository.Setup(e => e.GetMerchants(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(merchants)); + + Result> getMerchantsResult = await this.EstateManagementManager.GetMerchants(TestData.EstateId, CancellationToken.None); + getMerchantsResult.IsFailed.ShouldBeTrue(); + } + + [Fact] + public async Task EstateManagementManager_GetMerchants_RepoCallFails_ExceptionThrown() + { + List merchants = new List(); + this.EstateManagementRepository.Setup(e => e.GetMerchants(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Failure()); + + Result> getMerchantsResult = await this.EstateManagementManager.GetMerchants(TestData.EstateId, CancellationToken.None); + getMerchantsResult.IsFailed.ShouldBeTrue(); + } + + [Fact] + public async Task EstateManagementManager_GetContract_ContractIsReturned() + { + this.ContractAggregateRepository.Setup(c => c.GetLatestVersion(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.Aggregates.CreatedContractAggregateWithAProductAndTransactionFee(CalculationType.Fixed, FeeType.Merchant))); + + Result getContractResult = await this.EstateManagementManager.GetContract(TestData.EstateId, TestData.ContractId, CancellationToken.None); + getContractResult.IsSuccess.ShouldBeTrue(); + var contractModel = getContractResult.Data; + + contractModel.ShouldNotBeNull(); + contractModel.ContractId.ShouldBe(TestData.ContractId); + contractModel.Description.ShouldBe(TestData.ContractDescription); + contractModel.OperatorId.ShouldBe(TestData.OperatorId); + contractModel.Products.ShouldNotBeNull(); + contractModel.Products.First().ContractProductId.ShouldBe(TestData.ContractProductId); + contractModel.Products.First().TransactionFees.ShouldNotBeNull(); + contractModel.Products.First().TransactionFees.First().TransactionFeeId.ShouldBe(TestData.TransactionFeeId); + } + + [Fact] + public async Task EstateManagementManager_GetContract_ContractNotCreated_ErrorIsThrown() + { + this.ContractAggregateRepository.Setup(c => c.GetLatestVersion(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.Aggregates.EmptyContractAggregate())); + + Result getContractResult = await this.EstateManagementManager.GetContract(TestData.EstateId, TestData.ContractId, CancellationToken.None); + getContractResult.IsFailed.ShouldBeTrue(); + } + + [Fact] + public async Task EstateManagementManager_GetContract_GetLatestFails_ErrorIsThrown() + { + this.ContractAggregateRepository.Setup(c => c.GetLatestVersion(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Failure()); + + Result getContractResult = await this.EstateManagementManager.GetContract(TestData.EstateId, TestData.ContractId, CancellationToken.None); + getContractResult.IsFailed.ShouldBeTrue(); + } + + [Fact] + public async Task EstateManagementManager_GetContracts_ContractAreReturned() + { + this.EstateManagementRepository.Setup(e => e.GetContracts(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(new List() { TestData.ContractModelWithProductsAndTransactionFees })); + + var getContractsResult = await this.EstateManagementManager.GetContracts(TestData.EstateId, CancellationToken.None); + getContractsResult.IsSuccess.ShouldBeTrue(); + var contractModelList = getContractsResult.Data; + contractModelList.ShouldNotBeNull(); + contractModelList.ShouldNotBeEmpty(); + } + + [Fact] + public async Task EstateManagementManager_GetContracts_RepoCallFails_ContractAreReturned() + { + this.EstateManagementRepository.Setup(e => e.GetContracts(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Failure()); + + var getContractsResult = await this.EstateManagementManager.GetContracts(TestData.EstateId, CancellationToken.None); + getContractsResult.IsFailed.ShouldBeTrue(); + } + + [Fact] + public async Task EstateManagementManager_GetTransactionFeesForProduct_TransactionFeesAreReturned() + { + this.ContractAggregateRepository.Setup(c => c.GetLatestVersion(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.Aggregates.CreatedContractAggregateWithAProductAndTransactionFee(CalculationType.Fixed, FeeType.Merchant))); + + var getTransactionFeesForProductResult = await this.EstateManagementManager.GetTransactionFeesForProduct(TestData.EstateId, TestData.MerchantId, TestData.ContractId, TestData.ContractProductId, CancellationToken.None); + getTransactionFeesForProductResult.IsSuccess.ShouldBeTrue(); + var transactionFees = getTransactionFeesForProductResult.Data; + transactionFees.ShouldNotBeNull(); + transactionFees.ShouldHaveSingleItem(); + transactionFees.First().TransactionFeeId.ShouldBe(TestData.TransactionFeeId); + } + + [Fact] + public async Task EstateManagementManager_GetTransactionFeesForProduct_ContractNotFound_ErrorThrown() + { + this.ContractAggregateRepository.Setup(c => c.GetLatestVersion(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.Aggregates.EmptyContractAggregate())); + + var result = await this.EstateManagementManager.GetTransactionFeesForProduct(TestData.EstateId, TestData.MerchantId, TestData.ContractId, TestData.ContractProductId, CancellationToken.None); + result.IsFailed.ShouldBeTrue(); + } + + [Fact] + public async Task EstateManagementManager_GetTransactionFeesForProduct_ProductNotFound_ErrorThrown() + { + this.ContractAggregateRepository.Setup(c => c.GetLatestVersion(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.Aggregates.CreatedContractAggregate())); + + var result = await this.EstateManagementManager.GetTransactionFeesForProduct(TestData.EstateId, TestData.MerchantId, TestData.ContractId, TestData.ContractProductId, CancellationToken.None); + result.IsFailed.ShouldBeTrue(); + } + + [Fact] + public async Task EstateManagementManager_GetTransactionFeesForProduct_GetLatestFails_ErrorThrown() + { + this.ContractAggregateRepository.Setup(c => c.GetLatestVersion(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Failure()); + + var result = await this.EstateManagementManager.GetTransactionFeesForProduct(TestData.EstateId, TestData.MerchantId, TestData.ContractId, TestData.ContractProductId, CancellationToken.None); + result.IsFailed.ShouldBeTrue(); + } + + [Fact] + public async Task EstateManagementManager_GetMerchantContracts_MerchantContractsReturned() + { + this.EstateManagementRepository.Setup(e => e.GetMerchantContracts(It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.MerchantContracts)); + + var getMerchantContractsResult = await this.EstateManagementManager.GetMerchantContracts(TestData.EstateId, TestData.MerchantId, CancellationToken.None); + getMerchantContractsResult.IsSuccess.ShouldBeTrue(); + var merchantContracts = getMerchantContractsResult.Data; + merchantContracts.ShouldNotBeNull(); + merchantContracts.ShouldHaveSingleItem(); + merchantContracts.Single().ContractId.ShouldBe(TestData.ContractId); + } + + [Fact] + public async Task EstateManagementManager_GetMerchantContracts_EmptyListReturned_ResultFailed() + { + this.EstateManagementRepository.Setup(e => e.GetMerchantContracts(It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.MerchantContractsEmptyList)); + + var getMerchantContractsResult = await this.EstateManagementManager.GetMerchantContracts(TestData.EstateId, TestData.MerchantId, CancellationToken.None); + getMerchantContractsResult.IsFailed.ShouldBeTrue(); + } + + [Fact] + public async Task EstateManagementManager_GetMerchantContracts_RepoCallFailed_ResultFailed() + { + this.EstateManagementRepository.Setup(e => e.GetMerchantContracts(It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(Result.Failure()); + + var getMerchantContractsResult = await this.EstateManagementManager.GetMerchantContracts(TestData.EstateId, TestData.MerchantId, CancellationToken.None); + getMerchantContractsResult.IsFailed.ShouldBeTrue(); + } + + [Fact] + public async Task EstateManagementManager_GetFileDetails_FileDetailsAreReturned() + { + this.EstateManagementRepository.Setup(e => e.GetFileDetails(It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.FileModel)); + + var getFileDetailsResult = await this.EstateManagementManager.GetFileDetails(TestData.EstateId, TestData.FileId, CancellationToken.None); + getFileDetailsResult.IsSuccess.ShouldBeTrue(); + var fileDetails = getFileDetailsResult.Data; + fileDetails.ShouldNotBeNull(); + } + + [Fact] + public async Task EstateManagementManager_GetFileDetails_RepoCallFailed_FileDetailsAreReturned() + { + this.EstateManagementRepository.Setup(e => e.GetFileDetails(It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(Result.Failure()); + + var getFileDetailsResult = await this.EstateManagementManager.GetFileDetails(TestData.EstateId, TestData.FileId, CancellationToken.None); + getFileDetailsResult.IsFailed.ShouldBeTrue(); + } + + [Fact] + public async Task EstateManagementManager_GetOperator_OperatorDetailsAreReturned() + { + this.OperatorAggregateRepository.Setup(e => e.GetLatestVersion(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.Aggregates.CreatedOperatorAggregate())); + + var getOperatorResult = await this.EstateManagementManager.GetOperator(TestData.EstateId, TestData.OperatorId, CancellationToken.None); + getOperatorResult.IsSuccess.ShouldBeTrue(); + var operatorDetails = getOperatorResult.Data; + operatorDetails.ShouldNotBeNull(); + } + + [Fact] + public async Task EstateManagementManager_GetOperator_OperatorNotCreated_ExceptionThrown() + { + this.OperatorAggregateRepository.Setup(e => e.GetLatestVersion(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.Aggregates.EmptyOperatorAggregate())); + + var getOperatorResult = await this.EstateManagementManager.GetOperator(TestData.EstateId, TestData.OperatorId, CancellationToken.None); + getOperatorResult.IsFailed.ShouldBeTrue(); + } + + [Fact] + public async Task EstateManagementManager_GetOperator_GetLatestFails_ExceptionThrown() + { + this.OperatorAggregateRepository.Setup(e => e.GetLatestVersion(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Failure()); + + var getOperatorResult = await this.EstateManagementManager.GetOperator(TestData.EstateId, TestData.OperatorId, CancellationToken.None); + getOperatorResult.IsFailed.ShouldBeTrue(); + } + + [Fact] + public async Task EstateManagementManager_GetOperators_OperatorDetailsAreReturned() + { + this.EstateManagementRepository.Setup(e => e.GetOperators(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(new List{ + TestData.OperatorModel + })); + + var getOperatorsResult = await this.EstateManagementManager.GetOperators(TestData.EstateId, CancellationToken.None); + getOperatorsResult.IsSuccess.ShouldBeTrue(); + var operators = getOperatorsResult.Data; + operators.ShouldNotBeNull(); + operators.ShouldHaveSingleItem(); + operators.Single().OperatorId.ShouldBe(TestData.OperatorId); + } + + [Fact] + public async Task EstateManagementManager_GetOperators_EmptyList_ExceptionThrown() + { + this.EstateManagementRepository.Setup(e => e.GetOperators(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(new List())); + + var getOperatorsResult = await this.EstateManagementManager.GetOperators(TestData.EstateId, CancellationToken.None); + getOperatorsResult.IsSuccess.ShouldBeTrue(); + } + + [Fact] + public async Task EstateManagementManager_GetOperators_RepoCallFails_ExceptionThrown() + { + this.EstateManagementRepository.Setup(e => e.GetOperators(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Failure()); + + var getOperatorsResult = await this.EstateManagementManager.GetOperators(TestData.EstateId, CancellationToken.None); + getOperatorsResult.IsFailed.ShouldBeTrue(); + } + */ + } +} diff --git a/TransactionProcessor.BusinessLogic.Tests/Manager/VoucherManagementManagerTests.cs b/TransactionProcessor.BusinessLogic.Tests/Manager/VoucherManagementManagerTests.cs index c2f26c76..a434d94d 100644 --- a/TransactionProcessor.BusinessLogic.Tests/Manager/VoucherManagementManagerTests.cs +++ b/TransactionProcessor.BusinessLogic.Tests/Manager/VoucherManagementManagerTests.cs @@ -8,20 +8,18 @@ using System.Threading; using System.Threading.Tasks; using SimpleResults; +using TransactionProcessor.Aggregates; using TransactionProcessor.BusinessLogic.Manager; using TransactionProcessor.BusinessLogic.Tests.DomainEventHandlers; using Xunit; namespace TransactionProcessor.BusinessLogic.Tests.Manager { - using EstateManagement.Database.Contexts; - using EstateManagement.Database.Entities; using Microsoft.EntityFrameworkCore.Diagnostics; using ProjectionEngine.Database.Database; using ProjectionEngine.Database.Database.Entities; using Shared.EntityFramework; using Testing; - using VoucherAggregate; public class VoucherManagementManagerTests { diff --git a/TransactionProcessor.BusinessLogic.Tests/Mediator/DummyEstateDomainService.cs b/TransactionProcessor.BusinessLogic.Tests/Mediator/DummyEstateDomainService.cs new file mode 100644 index 00000000..bf3aaad6 --- /dev/null +++ b/TransactionProcessor.BusinessLogic.Tests/Mediator/DummyEstateDomainService.cs @@ -0,0 +1,18 @@ +using System.Threading; +using System.Threading.Tasks; +using SimpleResults; +using TransactionProcessor.BusinessLogic.Requests; +using TransactionProcessor.BusinessLogic.Services; + +namespace TransactionProcessor.BusinessLogic.Tests.Mediator; + +public class DummyEstateDomainService : IEstateDomainService +{ + public async Task CreateEstate(EstateCommands.CreateEstateCommand command, CancellationToken cancellationToken) => Result.Success(); + + public async Task AddOperatorToEstate(EstateCommands.AddOperatorToEstateCommand command, CancellationToken cancellationToken) => Result.Success(); + + public async Task CreateEstateUser(EstateCommands.CreateEstateUserCommand command, CancellationToken cancellationToken) => Result.Success(); + + public async Task RemoveOperatorFromEstate(EstateCommands.RemoveOperatorFromEstateCommand command, CancellationToken cancellationToken) => Result.Success(); +} \ No newline at end of file diff --git a/TransactionProcessor.BusinessLogic.Tests/Mediator/DummySettlementDomainService.cs b/TransactionProcessor.BusinessLogic.Tests/Mediator/DummySettlementDomainService.cs index e6426da6..a43f598a 100644 --- a/TransactionProcessor.BusinessLogic.Tests/Mediator/DummySettlementDomainService.cs +++ b/TransactionProcessor.BusinessLogic.Tests/Mediator/DummySettlementDomainService.cs @@ -1,4 +1,5 @@ -using SimpleResults; +using System.Collections.Generic; +using SimpleResults; using TransactionProcessor.BusinessLogic.Requests; namespace TransactionProcessor.BusinessLogic.Tests.Mediator; @@ -8,6 +9,7 @@ namespace TransactionProcessor.BusinessLogic.Tests.Mediator; using System.Threading.Tasks; using BusinessLogic.Services; using Models; +using TransactionProcessor.BusinessLogic.Manager; public class DummySettlementDomainService : ISettlementDomainService { @@ -23,4 +25,16 @@ public async Task AddMerchantFeePendingSettlement( public async Task AddSettledFeeToSettlement(SettlementCommands.AddSettledFeeToSettlementCommand command, CancellationToken cancellationToken) => Result.Success(); +} + +public class DummyEstateManagementManager : IEstateManagementManager { + public async Task> GetEstate(Guid estateId, + CancellationToken cancellationToken) { + return Result.Success(new Estate()); + } + + public async Task>> GetEstates(Guid estateId, + CancellationToken cancellationToken) { + return Result.Success(new List()); + } } \ No newline at end of file diff --git a/TransactionProcessor.BusinessLogic.Tests/Mediator/MediatorTests.cs b/TransactionProcessor.BusinessLogic.Tests/Mediator/MediatorTests.cs index f958372c..257c85b6 100644 --- a/TransactionProcessor.BusinessLogic.Tests/Mediator/MediatorTests.cs +++ b/TransactionProcessor.BusinessLogic.Tests/Mediator/MediatorTests.cs @@ -10,6 +10,7 @@ using System.Text; using System.Threading.Tasks; using Shared.EventStore.EventStore; +using TransactionProcessor.BusinessLogic.Manager; using TransactionProcessor.ProjectionEngine.Repository; using Xunit; @@ -45,7 +46,11 @@ public MediatorTests() //this.Requests.Add(TestData.GetVoucherByVoucherCodeQuery); //this.Requests.Add(TestData.GetVoucherByTransactionIdQuery); - + this.Requests.Add(TestData.Commands.CreateEstateCommand); + this.Requests.Add(TestData.Commands.CreateEstateUserCommand); + this.Requests.Add(TestData.Commands.AddOperatorToEstateCommand); + this.Requests.Add(TestData.Queries.GetEstateQuery); + this.Requests.Add(TestData.Queries.GetEstatesQuery); } [Fact] @@ -113,7 +118,9 @@ private void AddTestRegistrations(ServiceRegistry services, s.AddSingleton(); s.AddSingleton, DummyMerchantBalanceStateRepository>(); s.AddSingleton(); - s.AddSingleton(); + s.AddSingleton(); + s.AddSingleton(); + s.AddSingleton(); }); } } diff --git a/TransactionProcessor.BusinessLogic.Tests/RequestHandler/SettlementRequestHandlerTests.cs b/TransactionProcessor.BusinessLogic.Tests/RequestHandler/SettlementRequestHandlerTests.cs index 5f9b7d07..7038a453 100644 --- a/TransactionProcessor.BusinessLogic.Tests/RequestHandler/SettlementRequestHandlerTests.cs +++ b/TransactionProcessor.BusinessLogic.Tests/RequestHandler/SettlementRequestHandlerTests.cs @@ -5,10 +5,10 @@ using Shared.EventStore.Aggregate; using Shouldly; using SimpleResults; +using TransactionProcessor.Aggregates; using TransactionProcessor.BusinessLogic.RequestHandlers; using TransactionProcessor.BusinessLogic.Requests; using TransactionProcessor.BusinessLogic.Services; -using TransactionProcessor.SettlementAggregates; using TransactionProcessor.Testing; using Xunit; diff --git a/TransactionProcessor.BusinessLogic.Tests/Services/EstateDomainServiceTests.cs b/TransactionProcessor.BusinessLogic.Tests/Services/EstateDomainServiceTests.cs new file mode 100644 index 00000000..c889711f --- /dev/null +++ b/TransactionProcessor.BusinessLogic.Tests/Services/EstateDomainServiceTests.cs @@ -0,0 +1,160 @@ +using System; +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; +using Moq; +using SecurityService.Client; +using SecurityService.DataTransferObjects; +using SecurityService.DataTransferObjects.Responses; +using Shared.DomainDrivenDesign.EventSourcing; +using Shared.EventStore.Aggregate; +using Shouldly; +using SimpleResults; +using TransactionProcessor.Aggregates; +using TransactionProcessor.BusinessLogic.Services; +using TransactionProcessor.Testing; +using Xunit; + +namespace TransactionProcessor.BusinessLogic.Tests.Services +{ + public class EstateDomainServiceTests { + private EstateDomainService DomainService; + private Mock> EstateAggregateRepository; + private Mock SecurityServiceClient; + public EstateDomainServiceTests() { + this.EstateAggregateRepository = new Mock>(); + this.SecurityServiceClient = new Mock(); + this.DomainService = new EstateDomainService(this.EstateAggregateRepository.Object, this.SecurityServiceClient.Object); + } + + [Fact] + public async Task EstateDomainService_CreateEstate_EstateIsCreated() { + + this.EstateAggregateRepository.Setup(m => m.GetLatestVersion(It.IsAny(), It.IsAny())) + .ReturnsAsync(SimpleResults.Result.Success(new EstateAggregate())); + this.EstateAggregateRepository + .Setup(m => m.SaveChanges(It.IsAny(), It.IsAny())) + .ReturnsAsync(SimpleResults.Result.Success()); + + Result result = await this.DomainService.CreateEstate(TestData.Commands.CreateEstateCommand, CancellationToken.None); + result.IsSuccess.ShouldBeTrue(); + } + + + [Fact] + public async Task EstateDomainService_AddOperatorEstate_OperatorIsAdded() + { + this.EstateAggregateRepository.Setup(m => m.GetLatestVersion(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.Aggregates.CreatedEstateAggregate())); + this.EstateAggregateRepository.Setup(m => m.SaveChanges(It.IsAny(), It.IsAny())).ReturnsAsync(SimpleResults.Result.Success()); + + Result result = await this.DomainService.AddOperatorToEstate(TestData.Commands.AddOperatorToEstateCommand, CancellationToken.None); + result.IsSuccess.ShouldBeTrue(); + } + + [Fact] + public async Task EstateDomainService_RemoveOperatorFromEstate_OperatorIsRemoved() + { + this.EstateAggregateRepository.Setup(m => m.GetLatestVersion(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.Aggregates.EstateAggregateWithOperator())); + this.EstateAggregateRepository.Setup(m => m.SaveChanges(It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success); + Result result = await this.DomainService.RemoveOperatorFromEstate(TestData.Commands.RemoveOperatorFromEstateCommand, CancellationToken.None); + result.IsSuccess.ShouldBeTrue(); + } + + [Fact] + public async Task EstateDomainService_CreateEstateUser_EstateUserIsCreated() { + this.EstateAggregateRepository + .Setup(m => m.GetLatestVersion(It.IsAny(), It.IsAny())) + .ReturnsAsync(Result.Success(TestData.Aggregates.CreatedEstateAggregate())); + this.EstateAggregateRepository + .Setup(m => m.SaveChanges(It.IsAny(), It.IsAny())) + .ReturnsAsync(SimpleResults.Result.Success()); + + this.SecurityServiceClient + .Setup(s => s.CreateUser(It.IsAny(), It.IsAny())) + .ReturnsAsync(Result.Success); + this.SecurityServiceClient + .Setup(s => s.GetUsers(It.IsAny(), It.IsAny())) + .ReturnsAsync(Result.Success(new List() { + new UserDetails { + UserId = Guid.Parse("FA077CE3-B915-4048-88E3-9B500699317F") + } + })); + + Result result = await this.DomainService.CreateEstateUser(TestData.Commands.CreateEstateUserCommand, CancellationToken.None); + result.IsSuccess.ShouldBeTrue(); + } + + [Fact] + public async Task EstateDomainService_CreateEstateUser_UserCreateFailed_ResultIsFailed() + { + this.EstateAggregateRepository + .Setup(m => m.GetLatestVersion(It.IsAny(), It.IsAny())) + .ReturnsAsync(Result.Success(TestData.Aggregates.CreatedEstateAggregate())); + this.EstateAggregateRepository + .Setup(m => m.SaveChanges(It.IsAny(), It.IsAny())) + .ReturnsAsync(SimpleResults.Result.Success()); + + this.SecurityServiceClient + .Setup(s => s.CreateUser(It.IsAny(), It.IsAny())) + .ReturnsAsync(Result.Failure); + this.SecurityServiceClient + .Setup(s => s.GetUsers(It.IsAny(), It.IsAny())) + .ReturnsAsync(Result.Success(new List() { + new UserDetails { + UserId = Guid.Parse("FA077CE3-B915-4048-88E3-9B500699317F") + } + })); + + Result result = await this.DomainService.CreateEstateUser(TestData.Commands.CreateEstateUserCommand, CancellationToken.None); + result.IsFailed.ShouldBeTrue(); + } + + [Fact] + public async Task EstateDomainService_CreateEstateUser_GetUsersFailed_ResultIsFailed() + { + this.EstateAggregateRepository + .Setup(m => m.GetLatestVersion(It.IsAny(), It.IsAny())) + .ReturnsAsync(Result.Success(TestData.Aggregates.CreatedEstateAggregate())); + this.EstateAggregateRepository + .Setup(m => m.SaveChanges(It.IsAny(), It.IsAny())) + .ReturnsAsync(SimpleResults.Result.Success()); + + this.SecurityServiceClient + .Setup(s => s.CreateUser(It.IsAny(), It.IsAny())) + .ReturnsAsync(Result.Success); + this.SecurityServiceClient + .Setup(s => s.GetUsers(It.IsAny(), It.IsAny())) + .ReturnsAsync(Result.Failure()); + + Result result = await this.DomainService.CreateEstateUser(TestData.Commands.CreateEstateUserCommand, CancellationToken.None); + result.IsFailed.ShouldBeTrue(); + } + + [Fact] + public async Task EstateDomainService_CreateEstateUser_NullUserReturned_ResultIsFailed() + { + this.EstateAggregateRepository + .Setup(m => m.GetLatestVersion(It.IsAny(), It.IsAny())) + .ReturnsAsync(Result.Success(TestData.Aggregates.CreatedEstateAggregate())); + this.EstateAggregateRepository + .Setup(m => m.SaveChanges(It.IsAny(), It.IsAny())) + .ReturnsAsync(SimpleResults.Result.Success()); + + this.SecurityServiceClient + .Setup(s => s.CreateUser(It.IsAny(), It.IsAny())) + .ReturnsAsync(Result.Success); + this.SecurityServiceClient + .Setup(s => s.GetUsers(It.IsAny(), It.IsAny())) + .ReturnsAsync(Result.Success(new List() { + null + })); + + Result result = await this.DomainService.CreateEstateUser(TestData.Commands.CreateEstateUserCommand, CancellationToken.None); + result.IsFailed.ShouldBeTrue(); + } + + // TODO: EstateDomainServiceTests - CreateEstateUser - failed creating user test + // TODO: EstateDomainServiceTests - Estate Not Created tests missing + // TODO: EstateDomainServiceTests - Save Changes failed + } +} diff --git a/TransactionProcessor.BusinessLogic.Tests/Services/FloatDomainServiceTests.cs b/TransactionProcessor.BusinessLogic.Tests/Services/FloatDomainServiceTests.cs index 7e135f28..c1048d89 100644 --- a/TransactionProcessor.BusinessLogic.Tests/Services/FloatDomainServiceTests.cs +++ b/TransactionProcessor.BusinessLogic.Tests/Services/FloatDomainServiceTests.cs @@ -12,7 +12,6 @@ namespace TransactionProcessor.BusinessLogic.Tests.Services using EstateManagement.Client; using EstateManagement.DataTransferObjects.Responses; using EstateManagement.DataTransferObjects.Responses.Contract; - using FloatAggregate; using Microsoft.Extensions.Configuration; using Models; using Moq; @@ -23,6 +22,7 @@ namespace TransactionProcessor.BusinessLogic.Tests.Services using Shared.Logger; using Shouldly; using Testing; + using TransactionProcessor.Aggregates; using TransactionProcessor.BusinessLogic.Common; using TransactionProcessor.BusinessLogic.Services; using Xunit; @@ -33,7 +33,7 @@ public class FloatDomainServiceTests private readonly Mock SecurityServiceClient; private readonly Mock> FloatAggregateRepository; private readonly Mock> FloatActivityAggregateRepository; - private readonly Mock> TransactionAggregateRepository; + private readonly Mock> TransactionAggregateRepository; private readonly FloatDomainService FloatDomainService; @@ -48,7 +48,7 @@ public FloatDomainServiceTests(){ this.SecurityServiceClient = new Mock(); this.FloatAggregateRepository = new Mock>(); this.FloatActivityAggregateRepository = new Mock>(); - this.TransactionAggregateRepository = new Mock>(); + this.TransactionAggregateRepository = new Mock>(); this.FloatDomainService = new FloatDomainService(this.FloatAggregateRepository.Object, this.FloatActivityAggregateRepository.Object, this.TransactionAggregateRepository.Object, diff --git a/TransactionProcessor.BusinessLogic.Tests/Services/SettlementDomainServiceTests.cs b/TransactionProcessor.BusinessLogic.Tests/Services/SettlementDomainServiceTests.cs index 74e11f98..231fa086 100644 --- a/TransactionProcessor.BusinessLogic.Tests/Services/SettlementDomainServiceTests.cs +++ b/TransactionProcessor.BusinessLogic.Tests/Services/SettlementDomainServiceTests.cs @@ -1,4 +1,5 @@ using SimpleResults; +using TransactionProcessor.Aggregates; using TransactionProcessor.BusinessLogic.Requests; namespace TransactionProcessor.BusinessLogic.Tests.Services @@ -13,14 +14,12 @@ namespace TransactionProcessor.BusinessLogic.Tests.Services using Models; using Moq; using SecurityService.Client; - using SettlementAggregates; using Shared.DomainDrivenDesign.EventSourcing; using Shared.EventStore.Aggregate; using Shared.General; using Shared.Logger; using Shouldly; using Testing; - using TransactionAggregate; using TransactionProcessor.BusinessLogic.Common; using Xunit; diff --git a/TransactionProcessor.BusinessLogic.Tests/Services/TransactionDomainServiceTests.cs b/TransactionProcessor.BusinessLogic.Tests/Services/TransactionDomainServiceTests.cs index 9c15b8a1..dce5e461 100644 --- a/TransactionProcessor.BusinessLogic.Tests/Services/TransactionDomainServiceTests.cs +++ b/TransactionProcessor.BusinessLogic.Tests/Services/TransactionDomainServiceTests.cs @@ -2,6 +2,7 @@ using MessagingService.DataTransferObjects; using Microsoft.Extensions.Caching.Memory; using SimpleResults; +using TransactionProcessor.Aggregates; using TransactionProcessor.BusinessLogic.Common; using TransactionProcessor.BusinessLogic.Manager; using TransactionProcessor.BusinessLogic.Requests; @@ -17,12 +18,10 @@ namespace TransactionProcessor.BusinessLogic.Tests.Services{ using EstateManagement.DataTransferObjects.Requests; using EstateManagement.DataTransferObjects.Requests.Merchant; using EstateManagement.DataTransferObjects.Responses.Merchant; - using FloatAggregate; using MessagingService.Client; using Microsoft.Extensions.Configuration; using Models; using Moq; - using ReconciliationAggregate; using SecurityService.Client; using Shared.DomainDrivenDesign.EventSourcing; using Shared.EventStore.Aggregate; @@ -30,7 +29,6 @@ namespace TransactionProcessor.BusinessLogic.Tests.Services{ using Shared.Logger; using Shouldly; using Testing; - using TransactionAggregate; using Xunit; using static Microsoft.EntityFrameworkCore.DbLoggerCategory.Database; diff --git a/TransactionProcessor.BusinessLogic.Tests/Services/TransactionValidationServiceTests.cs b/TransactionProcessor.BusinessLogic.Tests/Services/TransactionValidationServiceTests.cs index 7cd544b0..f4aa319d 100644 --- a/TransactionProcessor.BusinessLogic.Tests/Services/TransactionValidationServiceTests.cs +++ b/TransactionProcessor.BusinessLogic.Tests/Services/TransactionValidationServiceTests.cs @@ -1,4 +1,7 @@ -using SimpleResults; +using Shared.DomainDrivenDesign.EventSourcing; +using Shared.EventStore.Aggregate; +using SimpleResults; +using TransactionProcessor.Aggregates; namespace TransactionProcessor.BusinessLogic.Tests.Services; @@ -31,6 +34,7 @@ public class TransactionValidationServiceTests { private readonly Mock> StateRepository; private readonly Mock EstateClient; private readonly Mock EventStoreContext; + private readonly Mock> EstateAggregateRepository; public TransactionValidationServiceTests() { IConfigurationRoot configurationRoot = new ConfigurationBuilder().AddInMemoryCollection(TestData.DefaultAppSettings).Build(); ConfigurationReader.Initialise(configurationRoot); @@ -41,19 +45,21 @@ public TransactionValidationServiceTests() { this.SecurityServiceClient = new Mock(); this.StateRepository = new Mock>(); this.EventStoreContext = new Mock(); + this.EstateAggregateRepository = new Mock>(); this.SecurityServiceClient.Setup(s => s.GetToken(It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.TokenResponse())); this.TransactionValidationService = new TransactionValidationService(this.EstateClient.Object, this.SecurityServiceClient.Object, this.StateRepository.Object, - this.EventStoreContext.Object); + this.EventStoreContext.Object, + this.EstateAggregateRepository.Object); } [Fact] public async Task ValidateLogonTransactionX_ValidationSuccessful_CorrectResponseReturned() { - this.EstateClient.Setup(e => e.GetEstate(It.IsAny(), It.IsAny(), It.IsAny())) - .ReturnsAsync(Result.Success(TestData.GetEstateResponseWithOperator1)); + this.EstateAggregateRepository.Setup(e => e.GetLatestVersion(It.IsAny(), It.IsAny())) + .ReturnsAsync(Result.Success(TestData.Aggregates.EstateAggregateWithOperator())); this.EstateClient.Setup(e => e.GetMerchant(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())) .ReturnsAsync(Result.Success(TestData.GetMerchantResponseWithOperator1)); @@ -66,7 +72,7 @@ public async Task ValidateLogonTransactionX_ValidationSuccessful_CorrectResponse [Fact] public async Task ValidateLogonTransactionX_InvalidEstate_CorrectResponseReturned() { - this.EstateClient.Setup(e => e.GetEstate(It.IsAny(), It.IsAny(), It.IsAny())) + this.EstateAggregateRepository.Setup(e => e.GetLatestVersion(It.IsAny(), It.IsAny())) .ReturnsAsync(Result.NotFound("Estate not found")); Result result = await this.TransactionValidationService.ValidateLogonTransaction(TestData.EstateId, TestData.MerchantId, @@ -79,8 +85,8 @@ public async Task ValidateLogonTransactionX_InvalidEstate_CorrectResponseReturne [Fact] public async Task ValidateLogonTransactionX_FailureWhileGettingEstate_CorrectResponseReturned() { - this.EstateClient.Setup(e => e.GetEstate(It.IsAny(), It.IsAny(), It.IsAny())) - .ReturnsAsync(Result.Failure("Failure Message")); + this.EstateAggregateRepository.Setup(e => e.GetLatestVersion(It.IsAny(), It.IsAny())) + .ReturnsAsync(Result.Failure("Failed")); Result result = await this.TransactionValidationService.ValidateLogonTransaction(TestData.EstateId, TestData.MerchantId, TestData.DeviceIdentifier, CancellationToken.None); @@ -92,8 +98,8 @@ public async Task ValidateLogonTransactionX_FailureWhileGettingEstate_CorrectRes [Fact] public async Task ValidateLogonTransactionX_InvalidMerchant_CorrectResponseReturned() { - this.EstateClient.Setup(e => e.GetEstate(It.IsAny(), It.IsAny(), It.IsAny())) - .ReturnsAsync(Result.Success(TestData.GetEstateResponseWithOperator1)); + this.EstateAggregateRepository.Setup(e => e.GetLatestVersion(It.IsAny(), It.IsAny())) + .ReturnsAsync(Result.Success(TestData.Aggregates.EstateAggregateWithOperator())); this.EstateClient.Setup(e => e.GetMerchant(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())) .ReturnsAsync(Result.NotFound("Merchant Not Found")); @@ -107,8 +113,8 @@ public async Task ValidateLogonTransactionX_InvalidMerchant_CorrectResponseRetur [Fact] public async Task ValidateLogonTransactionX_FailureWhileGettingMerchant_CorrectResponseReturned() { - this.EstateClient.Setup(e => e.GetEstate(It.IsAny(), It.IsAny(), It.IsAny())) - .ReturnsAsync(Result.Success(TestData.GetEstateResponseWithOperator1)); + this.EstateAggregateRepository.Setup(e => e.GetLatestVersion(It.IsAny(), It.IsAny())) + .ReturnsAsync(Result.Success(TestData.Aggregates.EstateAggregateWithOperator())); this.EstateClient.Setup(e => e.GetMerchant(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())) .ReturnsAsync(Result.Failure("Merchant Not Found")); @@ -122,8 +128,8 @@ public async Task ValidateLogonTransactionX_FailureWhileGettingMerchant_CorrectR [Fact] public async Task ValidateLogonTransactionX_InvalidDeviceId_CorrectResponseReturned() { - this.EstateClient.Setup(e => e.GetEstate(It.IsAny(), It.IsAny(), It.IsAny())) - .ReturnsAsync(Result.Success(TestData.GetEstateResponseWithOperator1)); + this.EstateAggregateRepository.Setup(e => e.GetLatestVersion(It.IsAny(), It.IsAny())) + .ReturnsAsync(Result.Success(TestData.Aggregates.EstateAggregateWithOperator())); this.EstateClient.Setup(e => e.GetMerchant(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())) .ReturnsAsync(Result.Success(TestData.GetMerchantResponseWithOperator1)); @@ -137,8 +143,8 @@ public async Task ValidateLogonTransactionX_InvalidDeviceId_CorrectResponseRetur [Fact] public async Task ValidateLogonTransactionX_MerchantHasNoDevices_CorrectResponseReturned() { - this.EstateClient.Setup(e => e.GetEstate(It.IsAny(), It.IsAny(), It.IsAny())) - .ReturnsAsync(Result.Success(TestData.GetEstateResponseWithOperator1)); + this.EstateAggregateRepository.Setup(e => e.GetLatestVersion(It.IsAny(), It.IsAny())) + .ReturnsAsync(Result.Success(TestData.Aggregates.EstateAggregateWithOperator())); this.EstateClient.Setup(e => e.GetMerchant(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())) .ReturnsAsync(Result.Success(TestData.GetMerchantResponseWithNoDevices)); @@ -152,8 +158,8 @@ public async Task ValidateLogonTransactionX_MerchantHasNoDevices_CorrectResponse [Fact] public async Task ValidateLogonTransactionX_MerchantHasNullDevices_CorrectResponseReturned() { - this.EstateClient.Setup(e => e.GetEstate(It.IsAny(), It.IsAny(), It.IsAny())) - .ReturnsAsync(Result.Success(TestData.GetEstateResponseWithOperator1)); + this.EstateAggregateRepository.Setup(e => e.GetLatestVersion(It.IsAny(), It.IsAny())) + .ReturnsAsync(Result.Success(TestData.Aggregates.EstateAggregateWithOperator())); this.EstateClient.Setup(e => e.GetMerchant(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())) .ReturnsAsync(Result.Success(TestData.GetMerchantResponseWithNullDevices)); @@ -167,8 +173,8 @@ public async Task ValidateLogonTransactionX_MerchantHasNullDevices_CorrectRespon [Fact] public async Task ValidateReconciliationTransactionX_ValidationSuccessful_CorrectResponseReturned() { - this.EstateClient.Setup(e => e.GetEstate(It.IsAny(), It.IsAny(), It.IsAny())) - .ReturnsAsync(Result.Success(TestData.GetEstateResponseWithOperator1)); + this.EstateAggregateRepository.Setup(e => e.GetLatestVersion(It.IsAny(), It.IsAny())) + .ReturnsAsync(Result.Success(TestData.Aggregates.EstateAggregateWithOperator())); this.EstateClient.Setup(e => e.GetMerchant(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())) .ReturnsAsync(Result.Success(TestData.GetMerchantResponseWithOperator1)); @@ -182,8 +188,8 @@ public async Task ValidateReconciliationTransactionX_ValidationSuccessful_Correc [Fact] public async Task ValidateReconciliationTransactionX_InvalidEstate_CorrectResponseReturned() { - this.EstateClient.Setup(e => e.GetEstate(It.IsAny(), It.IsAny(), It.IsAny())) - .ReturnsAsync(Result.NotFound("Estate not found")); + this.EstateAggregateRepository.Setup(e => e.GetLatestVersion(It.IsAny(), It.IsAny())) + .ReturnsAsync(Result.NotFound("Estate Not Found")); Result result = await this.TransactionValidationService.ValidateReconciliationTransaction(TestData.EstateId, TestData.MerchantId, TestData.DeviceIdentifier, CancellationToken.None); @@ -195,8 +201,8 @@ public async Task ValidateReconciliationTransactionX_InvalidEstate_CorrectRespon [Fact] public async Task ValidateReconciliationTransactionX_FailureWhileGettingEstate_CorrectResponseReturned() { - this.EstateClient.Setup(e => e.GetEstate(It.IsAny(), It.IsAny(), It.IsAny())) - .ReturnsAsync(Result.Failure("Failure Message")); + this.EstateAggregateRepository.Setup(e => e.GetLatestVersion(It.IsAny(), It.IsAny())) + .ReturnsAsync(Result.Failure("Failed")); Result result = await this.TransactionValidationService.ValidateReconciliationTransaction(TestData.EstateId, TestData.MerchantId, TestData.DeviceIdentifier, CancellationToken.None); @@ -208,8 +214,8 @@ public async Task ValidateReconciliationTransactionX_FailureWhileGettingEstate_C [Fact] public async Task ValidateReconciliationTransactionX_InvalidMerchant_CorrectResponseReturned() { - this.EstateClient.Setup(e => e.GetEstate(It.IsAny(), It.IsAny(), It.IsAny())) - .ReturnsAsync(Result.Success(TestData.GetEstateResponseWithOperator1)); + this.EstateAggregateRepository.Setup(e => e.GetLatestVersion(It.IsAny(), It.IsAny())) + .ReturnsAsync(Result.Success(TestData.Aggregates.EstateAggregateWithOperator())); this.EstateClient.Setup(e => e.GetMerchant(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())) .ReturnsAsync(Result.NotFound("Merchant Not Found")); @@ -223,8 +229,8 @@ public async Task ValidateReconciliationTransactionX_InvalidMerchant_CorrectResp [Fact] public async Task ValidateReconciliationTransactionX_FailureWhileGettingMerchant_CorrectResponseReturned() { - this.EstateClient.Setup(e => e.GetEstate(It.IsAny(), It.IsAny(), It.IsAny())) - .ReturnsAsync(Result.Success(TestData.GetEstateResponseWithOperator1)); + this.EstateAggregateRepository.Setup(e => e.GetLatestVersion(It.IsAny(), It.IsAny())) + .ReturnsAsync(Result.Success(TestData.Aggregates.EstateAggregateWithOperator())); this.EstateClient.Setup(e => e.GetMerchant(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())) .ReturnsAsync(Result.Failure("Merchant Not Found")); @@ -238,8 +244,8 @@ public async Task ValidateReconciliationTransactionX_FailureWhileGettingMerchant [Fact] public async Task ValidateReconciliationTransactionX_InvalidDeviceId_CorrectResponseReturned() { - this.EstateClient.Setup(e => e.GetEstate(It.IsAny(), It.IsAny(), It.IsAny())) - .ReturnsAsync(Result.Success(TestData.GetEstateResponseWithOperator1)); + this.EstateAggregateRepository.Setup(e => e.GetLatestVersion(It.IsAny(), It.IsAny())) + .ReturnsAsync(Result.Success(TestData.Aggregates.EstateAggregateWithOperator())); this.EstateClient.Setup(e => e.GetMerchant(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())) .ReturnsAsync(Result.Success(TestData.GetMerchantResponseWithOperator1)); @@ -253,8 +259,8 @@ public async Task ValidateReconciliationTransactionX_InvalidDeviceId_CorrectResp [Fact] public async Task ValidateReconciliationTransactionX_MerchantHasNoDevices_CorrectResponseReturned() { - this.EstateClient.Setup(e => e.GetEstate(It.IsAny(), It.IsAny(), It.IsAny())) - .ReturnsAsync(Result.Success(TestData.GetEstateResponseWithOperator1)); + this.EstateAggregateRepository.Setup(e => e.GetLatestVersion(It.IsAny(), It.IsAny())) + .ReturnsAsync(Result.Success(TestData.Aggregates.EstateAggregateWithOperator())); this.EstateClient.Setup(e => e.GetMerchant(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())) .ReturnsAsync(Result.Success(TestData.GetMerchantResponseWithNoDevices)); @@ -268,8 +274,8 @@ public async Task ValidateReconciliationTransactionX_MerchantHasNoDevices_Correc [Fact] public async Task ValidateReconciliationTransactionX_MerchantHasNullDevices_CorrectResponseReturned() { - this.EstateClient.Setup(e => e.GetEstate(It.IsAny(), It.IsAny(), It.IsAny())) - .ReturnsAsync(Result.Success(TestData.GetEstateResponseWithOperator1)); + this.EstateAggregateRepository.Setup(e => e.GetLatestVersion(It.IsAny(), It.IsAny())) + .ReturnsAsync(Result.Success(TestData.Aggregates.EstateAggregateWithOperator())); this.EstateClient.Setup(e => e.GetMerchant(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())) .ReturnsAsync(Result.Success(TestData.GetMerchantResponseWithNullDevices)); @@ -285,8 +291,8 @@ public async Task TransactionValidationService_ValidateSaleTransaction_DeviceNot { this.SecurityServiceClient.Setup(s => s.GetToken(It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.TokenResponse())); - this.EstateClient.Setup(e => e.GetEstate(It.IsAny(), It.IsAny(), It.IsAny())) - .ReturnsAsync(TestData.GetEstateResponseWithOperator1); + this.EstateAggregateRepository.Setup(e => e.GetLatestVersion(It.IsAny(), It.IsAny())) + .ReturnsAsync(Result.Success(TestData.Aggregates.EstateAggregateWithOperator())); this.EstateClient.Setup(e => e.GetMerchant(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())) .ReturnsAsync(TestData.GetMerchantResponseWithOperator1); @@ -308,8 +314,8 @@ public async Task TransactionValidationService_ValidateSaleTransaction_EstateFou { this.SecurityServiceClient.Setup(s => s.GetToken(It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.TokenResponse())); - this.EstateClient.Setup(e => e.GetEstate(It.IsAny(), It.IsAny(), It.IsAny())) - .ReturnsAsync(TestData.GetEstateResponseWithEmptyOperators); + this.EstateAggregateRepository.Setup(e => e.GetLatestVersion(It.IsAny(), It.IsAny())) + .ReturnsAsync(Result.Success(TestData.Aggregates.CreatedEstateAggregate())); this.EstateClient.Setup(e => e.GetMerchant(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())) .ReturnsAsync(TestData.GetEmptyMerchantResponse); @@ -331,8 +337,8 @@ public async Task TransactionValidationService_ValidateSaleTransaction_EstateFou { this.SecurityServiceClient.Setup(s => s.GetToken(It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.TokenResponse())); - this.EstateClient.Setup(e => e.GetEstate(It.IsAny(), It.IsAny(), It.IsAny())) - .ReturnsAsync(TestData.GetEstateResponseWithOperator1Deleted); + this.EstateAggregateRepository.Setup(e => e.GetLatestVersion(It.IsAny(), It.IsAny())) + .ReturnsAsync(Result.Success(TestData.Aggregates.EstateAggregateWithOperatorDeleted())); this.EstateClient.Setup(e => e.GetMerchant(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())) .ReturnsAsync(TestData.GetEmptyMerchantResponse); @@ -354,8 +360,8 @@ public async Task TransactionValidationService_ValidateSaleTransaction_EstateFou { this.SecurityServiceClient.Setup(s => s.GetToken(It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.TokenResponse())); - this.EstateClient.Setup(e => e.GetEstate(It.IsAny(), It.IsAny(), It.IsAny())) - .ReturnsAsync(TestData.GetEstateResponseWithNullOperators); + this.EstateAggregateRepository.Setup(e => e.GetLatestVersion(It.IsAny(), It.IsAny())) + .ReturnsAsync(Result.Success(TestData.Aggregates.CreatedEstateAggregate())); this.EstateClient.Setup(e => e.GetMerchant(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())) .ReturnsAsync(TestData.GetEmptyMerchantResponse); @@ -377,8 +383,8 @@ public async Task TransactionValidationService_ValidateSaleTransaction_EstateFou { this.SecurityServiceClient.Setup(s => s.GetToken(It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.TokenResponse())); - this.EstateClient.Setup(e => e.GetEstate(It.IsAny(), It.IsAny(), It.IsAny())) - .ReturnsAsync(TestData.GetEstateResponseWithOperator1); + this.EstateAggregateRepository.Setup(e => e.GetLatestVersion(It.IsAny(), It.IsAny())) + .ReturnsAsync(Result.Success(TestData.Aggregates.EstateAggregateWithOperator())); this.EstateClient.Setup(e => e.GetMerchant(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())) .ReturnsAsync(TestData.GetEmptyMerchantResponse); @@ -400,8 +406,8 @@ public async Task TransactionValidationService_ValidateSaleTransaction_EstateNot { this.SecurityServiceClient.Setup(s => s.GetToken(It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.TokenResponse())); - this.EstateClient.Setup(e => e.GetEstate(It.IsAny(), It.IsAny(), It.IsAny())) - .ReturnsAsync(Result.NotFound()); + this.EstateAggregateRepository.Setup(e => e.GetLatestVersion(It.IsAny(), It.IsAny())) + .ReturnsAsync(Result.NotFound("Estate Not Found")); var result = await this.TransactionValidationService.ValidateSaleTransaction(TestData.EstateId, TestData.MerchantId, @@ -421,8 +427,8 @@ public async Task TransactionValidationService_ValidateSaleTransaction_GetEstate { this.SecurityServiceClient.Setup(s => s.GetToken(It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.TokenResponse())); - this.EstateClient.Setup(e => e.GetEstate(It.IsAny(), It.IsAny(), It.IsAny())) - .ReturnsAsync(Result.Failure()); + this.EstateAggregateRepository.Setup(e => e.GetLatestVersion(It.IsAny(), It.IsAny())) + .ReturnsAsync(Result.Failure("Failed")); var result = await this.TransactionValidationService.ValidateSaleTransaction(TestData.EstateId, TestData.MerchantId, @@ -442,8 +448,8 @@ public async Task TransactionValidationService_ValidateSaleTransaction_InvalidCo { this.SecurityServiceClient.Setup(s => s.GetToken(It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.TokenResponse())); - this.EstateClient.Setup(e => e.GetEstate(It.IsAny(), It.IsAny(), It.IsAny())) - .ReturnsAsync(TestData.GetEstateResponseWithOperator1); + this.EstateAggregateRepository.Setup(e => e.GetLatestVersion(It.IsAny(), It.IsAny())) + .ReturnsAsync(Result.Success(TestData.Aggregates.EstateAggregateWithOperator())); this.EstateClient.Setup(e => e.GetMerchant(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())) .ReturnsAsync(TestData.GetMerchantResponseWithOperator1); @@ -468,8 +474,8 @@ public async Task TransactionValidationService_ValidateSaleTransaction_InvalidPr { this.SecurityServiceClient.Setup(s => s.GetToken(It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.TokenResponse())); - this.EstateClient.Setup(e => e.GetEstate(It.IsAny(), It.IsAny(), It.IsAny())) - .ReturnsAsync(TestData.GetEstateResponseWithOperator1); + this.EstateAggregateRepository.Setup(e => e.GetLatestVersion(It.IsAny(), It.IsAny())) + .ReturnsAsync(Result.Success(TestData.Aggregates.EstateAggregateWithOperator())); this.EstateClient.Setup(e => e.GetMerchant(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())) .ReturnsAsync(TestData.GetMerchantResponseWithOperator1); this.EstateClient.Setup(e => e.GetMerchantContracts(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())) @@ -498,8 +504,8 @@ public async Task TransactionValidationService_ValidateSaleTransaction_InvalidTr { this.SecurityServiceClient.Setup(s => s.GetToken(It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.TokenResponse())); - this.EstateClient.Setup(e => e.GetEstate(It.IsAny(), It.IsAny(), It.IsAny())) - .ReturnsAsync(TestData.GetEstateResponseWithOperator1); + this.EstateAggregateRepository.Setup(e => e.GetLatestVersion(It.IsAny(), It.IsAny())) + .ReturnsAsync(Result.Success(TestData.Aggregates.EstateAggregateWithOperator())); this.EstateClient.Setup(e => e.GetMerchant(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())) .ReturnsAsync(TestData.GetMerchantResponseWithOperator1); this.EstateClient.Setup(e => e.GetMerchantContracts(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())) @@ -523,8 +529,8 @@ public async Task TransactionValidationService_ValidateSaleTransaction_MerchantD { this.SecurityServiceClient.Setup(s => s.GetToken(It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.TokenResponse())); - this.EstateClient.Setup(e => e.GetEstate(It.IsAny(), It.IsAny(), It.IsAny())) - .ReturnsAsync(TestData.GetEstateResponseWithOperator1); + this.EstateAggregateRepository.Setup(e => e.GetLatestVersion(It.IsAny(), It.IsAny())) + .ReturnsAsync(Result.Success(TestData.Aggregates.EstateAggregateWithOperator())); this.EstateClient.Setup(e => e.GetMerchant(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())) .ReturnsAsync(TestData.GetMerchantResponseWithNoDevices); @@ -546,8 +552,8 @@ public async Task TransactionValidationService_ValidateSaleTransaction_MerchantD { this.SecurityServiceClient.Setup(s => s.GetToken(It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.TokenResponse())); - this.EstateClient.Setup(e => e.GetEstate(It.IsAny(), It.IsAny(), It.IsAny())) - .ReturnsAsync(TestData.GetEstateResponseWithOperator1); + this.EstateAggregateRepository.Setup(e => e.GetLatestVersion(It.IsAny(), It.IsAny())) + .ReturnsAsync(Result.Success(TestData.Aggregates.EstateAggregateWithOperator())); this.EstateClient.Setup(e => e.GetMerchant(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())) .ReturnsAsync(TestData.GetMerchantResponseWithNullDevices); @@ -569,8 +575,8 @@ public async Task TransactionValidationService_ValidateSaleTransaction_MerchantD { this.SecurityServiceClient.Setup(s => s.GetToken(It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.TokenResponse())); - this.EstateClient.Setup(e => e.GetEstate(It.IsAny(), It.IsAny(), It.IsAny())) - .ReturnsAsync(TestData.GetEstateResponseWithOperator1); + this.EstateAggregateRepository.Setup(e => e.GetLatestVersion(It.IsAny(), It.IsAny())) + .ReturnsAsync(Result.Success(TestData.Aggregates.EstateAggregateWithOperator())); this.EstateClient.Setup(e => e.GetMerchant(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())) .ReturnsAsync(TestData.GetMerchantResponseWithOperator1); this.EstateClient.Setup(e => e.GetMerchantContracts(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())) @@ -597,8 +603,8 @@ public async Task TransactionValidationService_ValidateSaleTransaction_MerchantH { this.SecurityServiceClient.Setup(s => s.GetToken(It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.TokenResponse())); - this.EstateClient.Setup(e => e.GetEstate(It.IsAny(), It.IsAny(), It.IsAny())) - .ReturnsAsync(TestData.GetEstateResponseWithOperator1); + this.EstateAggregateRepository.Setup(e => e.GetLatestVersion(It.IsAny(), It.IsAny())) + .ReturnsAsync(Result.Success(TestData.Aggregates.EstateAggregateWithOperator())); this.EstateClient.SetupSequence(e => e.GetMerchant(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())) .ReturnsAsync(TestData.GetMerchantResponseWithOperator1) .ReturnsAsync(TestData.GetMerchantResponseWithOperator1AndEmptyContracts); @@ -626,8 +632,8 @@ public async Task TransactionValidationService_ValidateSaleTransaction_MerchantH { this.SecurityServiceClient.Setup(s => s.GetToken(It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.TokenResponse())); - this.EstateClient.Setup(e => e.GetEstate(It.IsAny(), It.IsAny(), It.IsAny())) - .ReturnsAsync(TestData.GetEstateResponseWithOperator1); + this.EstateAggregateRepository.Setup(e => e.GetLatestVersion(It.IsAny(), It.IsAny())) + .ReturnsAsync(Result.Success(TestData.Aggregates.EstateAggregateWithOperator())); this.EstateClient.SetupSequence(e => e.GetMerchant(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())) .ReturnsAsync(TestData.GetMerchantResponseWithOperator1) .ReturnsAsync(TestData.GetMerchantResponseWithOperator1AndNullContracts); @@ -653,8 +659,8 @@ public async Task TransactionValidationService_ValidateSaleTransaction_MerchantN { this.SecurityServiceClient.Setup(s => s.GetToken(It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.TokenResponse())); - this.EstateClient.Setup(e => e.GetEstate(It.IsAny(), It.IsAny(), It.IsAny())) - .ReturnsAsync(TestData.GetEstateResponseWithOperator1); + this.EstateAggregateRepository.Setup(e => e.GetLatestVersion(It.IsAny(), It.IsAny())) + .ReturnsAsync(Result.Success(TestData.Aggregates.EstateAggregateWithOperator())); this.EstateClient.Setup(e => e.GetMerchant(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())) .ReturnsAsync(TestData.GetMerchantResponseWithOperator1); this.EstateClient.Setup(e => e.GetMerchantContracts(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())) @@ -680,8 +686,8 @@ public async Task TransactionValidationService_ValidateSaleTransaction_MerchantN { this.SecurityServiceClient.Setup(s => s.GetToken(It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.TokenResponse())); - this.EstateClient.Setup(e => e.GetEstate(It.IsAny(), It.IsAny(), It.IsAny())) - .ReturnsAsync(TestData.GetEstateResponseWithOperator1); + this.EstateAggregateRepository.Setup(e => e.GetLatestVersion(It.IsAny(), It.IsAny())) + .ReturnsAsync(Result.Success(TestData.Aggregates.EstateAggregateWithOperator())); this.EstateClient.Setup(e => e.GetMerchant(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())) .ReturnsAsync(Result.NotFound()); @@ -703,8 +709,8 @@ public async Task TransactionValidationService_ValidateSaleTransaction_FailedGet { this.SecurityServiceClient.Setup(s => s.GetToken(It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.TokenResponse())); - this.EstateClient.Setup(e => e.GetEstate(It.IsAny(), It.IsAny(), It.IsAny())) - .ReturnsAsync(TestData.GetEstateResponseWithOperator1); + this.EstateAggregateRepository.Setup(e => e.GetLatestVersion(It.IsAny(), It.IsAny())) + .ReturnsAsync(Result.Success(TestData.Aggregates.EstateAggregateWithOperator())); this.EstateClient.Setup(e => e.GetMerchant(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())) .ReturnsAsync(Result.Failure()); @@ -726,13 +732,11 @@ public async Task TransactionValidationService_ValidateSaleTransaction_MerchantN { this.SecurityServiceClient.Setup(s => s.GetToken(It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.TokenResponse())); - this.EstateClient.Setup(e => e.GetEstate(It.IsAny(), It.IsAny(), It.IsAny())) - .ReturnsAsync(TestData.GetEstateResponseWithOperator1); + this.EstateAggregateRepository.Setup(e => e.GetLatestVersion(It.IsAny(), It.IsAny())) + .ReturnsAsync(Result.Success(TestData.Aggregates.EstateAggregateWithOperator())); this.EstateClient.SetupSequence(e => e.GetMerchant(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(TestData.GetMerchantResponseWithOperator1) .ReturnsAsync(Result.NotFound()); - //this.EstateClient.Setup(e => e.GetMerchantContracts(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())) - // .ThrowsAsync(new Exception("Exception", new KeyNotFoundException("Invalid Merchant"))); - + this.EventStoreContext.Setup(e => e.GetPartitionStateFromProjection(It.IsAny(), It.IsAny(), It.IsAny())) .ReturnsAsync(JsonConvert.SerializeObject(TestData.MerchantBalanceProjectionState)); @@ -754,12 +758,10 @@ public async Task TransactionValidationService_ValidateSaleTransaction_FailedGet { this.SecurityServiceClient.Setup(s => s.GetToken(It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.TokenResponse())); - this.EstateClient.Setup(e => e.GetEstate(It.IsAny(), It.IsAny(), It.IsAny())) - .ReturnsAsync(TestData.GetEstateResponseWithOperator1); + this.EstateAggregateRepository.Setup(e => e.GetLatestVersion(It.IsAny(), It.IsAny())) + .ReturnsAsync(Result.Success(TestData.Aggregates.EstateAggregateWithOperator())); this.EstateClient.SetupSequence(e => e.GetMerchant(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(TestData.GetMerchantResponseWithOperator1) .ReturnsAsync(Result.Failure()); - //this.EstateClient.Setup(e => e.GetMerchantContracts(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())) - // .ThrowsAsync(new Exception("Exception", new KeyNotFoundException("Invalid Merchant"))); this.EventStoreContext.Setup(e => e.GetPartitionStateFromProjection(It.IsAny(), It.IsAny(), It.IsAny())) .ReturnsAsync(JsonConvert.SerializeObject(TestData.MerchantBalanceProjectionState)); @@ -782,8 +784,8 @@ public async Task TransactionValidationService_ValidateSaleTransaction_MerchantO { this.SecurityServiceClient.Setup(s => s.GetToken(It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.TokenResponse())); - this.EstateClient.Setup(e => e.GetEstate(It.IsAny(), It.IsAny(), It.IsAny())) - .ReturnsAsync(TestData.GetEstateResponseWithOperator1); + this.EstateAggregateRepository.Setup(e => e.GetLatestVersion(It.IsAny(), It.IsAny())) + .ReturnsAsync(Result.Success(TestData.Aggregates.EstateAggregateWithOperator())); this.EstateClient.Setup(e => e.GetMerchant(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())) .ReturnsAsync(TestData.GetMerchantResponseWithEmptyOperators); @@ -805,8 +807,8 @@ public async Task TransactionValidationService_ValidateSaleTransaction_MerchantO { this.SecurityServiceClient.Setup(s => s.GetToken(It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.TokenResponse())); - this.EstateClient.Setup(e => e.GetEstate(It.IsAny(), It.IsAny(), It.IsAny())) - .ReturnsAsync(TestData.GetEstateResponseWithOperator1); + this.EstateAggregateRepository.Setup(e => e.GetLatestVersion(It.IsAny(), It.IsAny())) + .ReturnsAsync(Result.Success(TestData.Aggregates.EstateAggregateWithOperator())); this.EstateClient.Setup(e => e.GetMerchant(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())) .ReturnsAsync(TestData.GetMerchantResponseWithNullOperators); @@ -828,8 +830,8 @@ public async Task TransactionValidationService_ValidateSaleTransaction_MerchantO { this.SecurityServiceClient.Setup(s => s.GetToken(It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.TokenResponse())); - this.EstateClient.Setup(e => e.GetEstate(It.IsAny(), It.IsAny(), It.IsAny())) - .ReturnsAsync(TestData.GetEstateResponseWithOperator1); + this.EstateAggregateRepository.Setup(e => e.GetLatestVersion(It.IsAny(), It.IsAny())) + .ReturnsAsync(Result.Success(TestData.Aggregates.EstateAggregateWithOperator())); this.EstateClient.Setup(e => e.GetMerchant(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())) .ReturnsAsync(TestData.GetMerchantResponseWithOperator1Deleted); @@ -851,8 +853,8 @@ public async Task TransactionValidationService_ValidateSaleTransaction_OperatorN { this.SecurityServiceClient.Setup(s => s.GetToken(It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.TokenResponse())); - this.EstateClient.Setup(e => e.GetEstate(It.IsAny(), It.IsAny(), It.IsAny())) - .ReturnsAsync(TestData.GetEstateResponseWithOperator1); + this.EstateAggregateRepository.Setup(e => e.GetLatestVersion(It.IsAny(), It.IsAny())) + .ReturnsAsync(Result.Success(TestData.Aggregates.EstateAggregateWithOperator())); this.EstateClient.Setup(e => e.GetMerchant(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())) .ReturnsAsync(TestData.GetMerchantResponseWithOperator2); @@ -874,8 +876,8 @@ public async Task TransactionValidationService_ValidateSaleTransaction_ProductId { this.SecurityServiceClient.Setup(s => s.GetToken(It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.TokenResponse())); - this.EstateClient.Setup(e => e.GetEstate(It.IsAny(), It.IsAny(), It.IsAny())) - .ReturnsAsync(TestData.GetEstateResponseWithOperator1); + this.EstateAggregateRepository.Setup(e => e.GetLatestVersion(It.IsAny(), It.IsAny())) + .ReturnsAsync(Result.Success(TestData.Aggregates.EstateAggregateWithOperator())); this.EstateClient.Setup(e => e.GetMerchant(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())) .ReturnsAsync(TestData.GetMerchantResponseWithOperator1); this.EstateClient.Setup(e => e.GetMerchantContracts(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())) @@ -902,8 +904,8 @@ public async Task TransactionValidationService_ValidateSaleTransaction_Successfu { this.SecurityServiceClient.Setup(s => s.GetToken(It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.TokenResponse())); - this.EstateClient.Setup(e => e.GetEstate(It.IsAny(), It.IsAny(), It.IsAny())) - .ReturnsAsync(TestData.GetEstateResponseWithOperator1); + this.EstateAggregateRepository.Setup(e => e.GetLatestVersion(It.IsAny(), It.IsAny())) + .ReturnsAsync(Result.Success(TestData.Aggregates.EstateAggregateWithOperator())); this.EstateClient.Setup(e => e.GetMerchant(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())) .ReturnsAsync(TestData.GetMerchantResponseWithOperator1); this.EstateClient.Setup(e => e.GetMerchantContracts(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())) @@ -929,8 +931,8 @@ public async Task TransactionValidationService_ValidateSaleTransaction_FailedGet { this.SecurityServiceClient.Setup(s => s.GetToken(It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(Result.Success(TestData.TokenResponse())); - this.EstateClient.Setup(e => e.GetEstate(It.IsAny(), It.IsAny(), It.IsAny())) - .ReturnsAsync(TestData.GetEstateResponseWithOperator1); + this.EstateAggregateRepository.Setup(e => e.GetLatestVersion(It.IsAny(), It.IsAny())) + .ReturnsAsync(Result.Success(TestData.Aggregates.EstateAggregateWithOperator())); this.EstateClient.SetupSequence(e => e.GetMerchant(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(TestData.GetMerchantResponseWithOperator1) .ReturnsAsync(Result.Success(TestData.GetMerchantResponseWithOperator1)); diff --git a/TransactionProcessor.BusinessLogic.Tests/Services/VoucherDomainServiceTests.cs b/TransactionProcessor.BusinessLogic.Tests/Services/VoucherDomainServiceTests.cs index 9b901867..bf8c7237 100644 --- a/TransactionProcessor.BusinessLogic.Tests/Services/VoucherDomainServiceTests.cs +++ b/TransactionProcessor.BusinessLogic.Tests/Services/VoucherDomainServiceTests.cs @@ -1,5 +1,7 @@ using SimpleResults; +using TransactionProcessor.Aggregates; using TransactionProcessor.BusinessLogic.Common; +using TransactionProcessor.Database.Contexts; namespace TransactionProcessor.BusinessLogic.Tests.Services { @@ -10,7 +12,6 @@ namespace TransactionProcessor.BusinessLogic.Tests.Services using BusinessLogic.Services; using DomainEventHandlers; using EstateManagement.Client; - using EstateManagement.Database.Contexts; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Diagnostics; using Microsoft.Extensions.Configuration; @@ -24,7 +25,6 @@ namespace TransactionProcessor.BusinessLogic.Tests.Services using Shared.Logger; using Shouldly; using Testing; - using VoucherAggregate; using Xunit; public class VoucherDomainServiceTests @@ -238,7 +238,7 @@ public async Task VoucherDomainService_RedeemVoucher_InvalidEstate_ErrorThrown() .ReturnsAsync(Result.Failure()); EstateManagementGenericContext context = await this.GetContext(Guid.NewGuid().ToString("N")); - context.Vouchers.Add(new EstateManagement.Database.Entities.Voucher { + context.Vouchers.Add(new TransactionProcessor.Database.Entities.Voucher { VoucherCode = TestData.VoucherCode, OperatorIdentifier = TestData.OperatorIdentifier }); @@ -277,7 +277,7 @@ public async Task VoucherDomainService_RedeemVoucher_VoucherRedeemed() { .ReturnsAsync(TestData.GetEstateResponseWithOperator1); EstateManagementGenericContext context = await this.GetContext(Guid.NewGuid().ToString("N")); - context.Vouchers.Add(new EstateManagement.Database.Entities.Voucher { + context.Vouchers.Add(new TransactionProcessor.Database.Entities.Voucher { VoucherCode = TestData.VoucherCode, OperatorIdentifier = TestData.OperatorIdentifier }); diff --git a/TransactionProcessor.BusinessLogic.Tests/TransactionProcessor.BusinessLogic.Tests.csproj b/TransactionProcessor.BusinessLogic.Tests/TransactionProcessor.BusinessLogic.Tests.csproj index 0e8710e2..5493ba1e 100644 --- a/TransactionProcessor.BusinessLogic.Tests/TransactionProcessor.BusinessLogic.Tests.csproj +++ b/TransactionProcessor.BusinessLogic.Tests/TransactionProcessor.BusinessLogic.Tests.csproj @@ -28,6 +28,7 @@ + diff --git a/TransactionProcessor.BusinessLogic/Common/IIntermediateEstateClient.cs b/TransactionProcessor.BusinessLogic/Common/IIntermediateEstateClient.cs index 374adc78..a9e69f19 100644 --- a/TransactionProcessor.BusinessLogic/Common/IIntermediateEstateClient.cs +++ b/TransactionProcessor.BusinessLogic/Common/IIntermediateEstateClient.cs @@ -9,7 +9,9 @@ using EstateManagement.DataTransferObjects.Responses.Contract; using EstateManagement.DataTransferObjects.Responses.Estate; using EstateManagement.DataTransferObjects.Responses.Merchant; +using Shared.EventStore.Aggregate; using SimpleResults; +using TransactionProcessor.Aggregates; namespace TransactionProcessor.BusinessLogic.Common { diff --git a/TransactionProcessor.BusinessLogic/EventHandling/EstateDomainEventHandler.cs b/TransactionProcessor.BusinessLogic/EventHandling/EstateDomainEventHandler.cs new file mode 100644 index 00000000..e245b9fe --- /dev/null +++ b/TransactionProcessor.BusinessLogic/EventHandling/EstateDomainEventHandler.cs @@ -0,0 +1,82 @@ +using System.Threading; +using System.Threading.Tasks; +using Shared.DomainDrivenDesign.EventSourcing; +using Shared.EventStore.EventHandling; +using SimpleResults; +using TransactionProcessor.Estate.DomainEvents; +using TransactionProcessor.Repository; + +namespace TransactionProcessor.BusinessLogic.EventHandling; + +public class EstateDomainEventHandler : IDomainEventHandler +{ + #region Fields + + /// + /// The estate reporting repository + /// + private readonly ITransactionProcessorReadModelRepository EstateReportingRepository; + + #endregion + + #region Constructors + + /// + /// Initializes a new instance of the class. + /// + /// The estate reporting repository. + public EstateDomainEventHandler(ITransactionProcessorReadModelRepository estateReportingRepository) + { + this.EstateReportingRepository = estateReportingRepository; + } + + #endregion + + #region Methods + + /// + /// Handles the specified domain event. + /// + /// The domain event. + /// The cancellation token. + public async Task Handle(IDomainEvent domainEvent, + CancellationToken cancellationToken) + { + return await this.HandleSpecificDomainEvent((dynamic)domainEvent, cancellationToken); + } + + /// + /// Handles the specific domain event. + /// + /// The domain event. + /// The cancellation token. + private async Task HandleSpecificDomainEvent(EstateCreatedEvent domainEvent, + CancellationToken cancellationToken) + { + Result createResult = await this.EstateReportingRepository.CreateReadModel(domainEvent, cancellationToken); + if (createResult.IsFailed) + return createResult; + + return await this.EstateReportingRepository.AddEstate(domainEvent, cancellationToken); + } + + /// + /// Handles the specific domain event. + /// + /// The domain event. + /// The cancellation token. + private async Task HandleSpecificDomainEvent(SecurityUserAddedToEstateEvent domainEvent, + CancellationToken cancellationToken) + { + return await this.EstateReportingRepository.AddEstateSecurityUser(domainEvent, cancellationToken); + } + + private async Task HandleSpecificDomainEvent(EstateReferenceAllocatedEvent domainEvent, + CancellationToken cancellationToken) + { + return await this.EstateReportingRepository.UpdateEstate(domainEvent, cancellationToken); + } + + #endregion +} + diff --git a/TransactionProcessor.BusinessLogic/EventHandling/TransactionDomainEventHandler.cs b/TransactionProcessor.BusinessLogic/EventHandling/TransactionDomainEventHandler.cs index 09d6532e..b6637565 100644 --- a/TransactionProcessor.BusinessLogic/EventHandling/TransactionDomainEventHandler.cs +++ b/TransactionProcessor.BusinessLogic/EventHandling/TransactionDomainEventHandler.cs @@ -15,11 +15,9 @@ namespace TransactionProcessor.BusinessLogic.EventHandling using System.Threading.Tasks; using Common; using EstateManagement.Client; - using EstateManagement.Database.Entities; using EstateManagement.DataTransferObjects; using EstateManagement.DataTransferObjects.Responses; using EstateManagement.DataTransferObjects.Responses.Estate; - using FloatAggregate; using Manager; using MessagingService.Client; using MessagingService.DataTransferObjects; @@ -29,14 +27,12 @@ namespace TransactionProcessor.BusinessLogic.EventHandling using SecurityService.DataTransferObjects.Responses; using Services; using Settlement.DomainEvents; - using SettlementAggregates; using Shared.DomainDrivenDesign.EventSourcing; using Shared.EventStore.Aggregate; using Shared.EventStore.EventHandling; using Shared.General; using Shared.Logger; using Transaction.DomainEvents; - using TransactionAggregate; using static TransactionProcessor.BusinessLogic.Requests.SettlementCommands; using static TransactionProcessor.BusinessLogic.Requests.TransactionCommands; using CalculationType = Models.CalculationType; diff --git a/TransactionProcessor.BusinessLogic/EventHandling/VoucherDomainEventHandler.cs b/TransactionProcessor.BusinessLogic/EventHandling/VoucherDomainEventHandler.cs index dd01c5ca..a163dbc7 100644 --- a/TransactionProcessor.BusinessLogic/EventHandling/VoucherDomainEventHandler.cs +++ b/TransactionProcessor.BusinessLogic/EventHandling/VoucherDomainEventHandler.cs @@ -1,5 +1,8 @@ using Shared.Results; using SimpleResults; +using TransactionProcessor.Aggregates; +using TransactionProcessor.Database.Contexts; +using TransactionProcessor.Database.Entities; namespace TransactionProcessor.BusinessLogic.EventHandling; @@ -11,8 +14,6 @@ namespace TransactionProcessor.BusinessLogic.EventHandling; using System.Threading; using System.Threading.Tasks; using Common; -using EstateManagement.Database.Contexts; -using EstateManagement.Database.Entities; using MessagingService.Client; using MessagingService.DataTransferObjects; using Microsoft.EntityFrameworkCore; @@ -24,7 +25,6 @@ namespace TransactionProcessor.BusinessLogic.EventHandling; using Shared.General; using Shared.Logger; using Voucher.DomainEvents; -using VoucherAggregate; public class VoucherDomainEventHandler : IDomainEventHandler { @@ -143,7 +143,7 @@ private async Task GetVoucherOperator(Models.Voucher voucherModel, EstateManagementGenericContext context = await this.DbContextFactory.GetContext(voucherModel.EstateId, ConnectionStringIdentifier, cancellationToken); - Transaction transaction = await context.Transactions.SingleOrDefaultAsync(t => t.TransactionId == voucherModel.TransactionId, cancellationToken); + Database.Entities.Transaction transaction = await context.Transactions.SingleOrDefaultAsync(t => t.TransactionId == voucherModel.TransactionId, cancellationToken); Contract contract = await context.Contracts.SingleOrDefaultAsync(c => c.ContractId == transaction.ContractId, cancellationToken); return contract.Description; diff --git a/TransactionProcessor.BusinessLogic/Manager/EstateManagementManager.cs b/TransactionProcessor.BusinessLogic/Manager/EstateManagementManager.cs new file mode 100644 index 00000000..e40702b3 --- /dev/null +++ b/TransactionProcessor.BusinessLogic/Manager/EstateManagementManager.cs @@ -0,0 +1,239 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; +using Shared.DomainDrivenDesign.EventSourcing; +using Shared.EventStore.Aggregate; +using Shared.Results; +using SimpleResults; +using TransactionProcessor.Aggregates; +using TransactionProcessor.Models; +using TransactionProcessor.ProjectionEngine.Repository; +using TransactionProcessor.Repository; + +namespace TransactionProcessor.BusinessLogic.Manager +{ + /// + /// + /// + /// + public class EstateManagementManager : IEstateManagementManager + { + #region Fields + + private readonly ITransactionProcessorReadModelRepository EstateManagementRepository; + + private readonly IAggregateRepository EstateAggregateRepository; + + //private readonly IAggregateRepository ContractAggregateRepository; + + //private readonly IAggregateRepository MerchantAggregateRepository; + + //private readonly IAggregateRepository OperatorAggregateRepository; + + //private readonly IModelFactory ModelFactory; + + #endregion + + #region Constructors + + public EstateManagementManager(ITransactionProcessorReadModelRepository estateManagementRepository, + IAggregateRepository estateAggregateRepository) + //IAggregateRepository contractAggregateRepository, + //IAggregateRepository merchantAggregateRepository, + //IModelFactory modelFactory, + //IAggregateRepository operatorAggregateRepository) + { + this.EstateManagementRepository = estateManagementRepository; + this.EstateAggregateRepository = estateAggregateRepository; + //this.ContractAggregateRepository = contractAggregateRepository; + //this.MerchantAggregateRepository = merchantAggregateRepository; + //this.OperatorAggregateRepository = operatorAggregateRepository; + //this.ModelFactory = modelFactory; + } + + #endregion + + #region Methods + + //public async Task>> GetContracts(Guid estateId, + // CancellationToken cancellationToken) + //{ + // Result> getContractsResult = await this.EstateManagementRepository.GetContracts(estateId, cancellationToken); + + // if (getContractsResult.IsFailed) + // return ResultHelpers.CreateFailure(getContractsResult); + + // return Result.Success(getContractsResult.Data); + //} + + //public async Task> GetContract(Guid estateId, + // Guid contractId, + // CancellationToken cancellationToken){ + // Result getContractResult = await this.ContractAggregateRepository.GetLatestVersion(contractId, cancellationToken); + // if (getContractResult.IsFailed) + // return ResultHelpers.CreateFailure(getContractResult); + + // ContractAggregate contractAggregate = getContractResult.Data; + + // if (contractAggregate.IsCreated == false){ + // return Result.NotFound($"No contract found with Id [{estateId}]"); + // } + // Contract contractModel = contractAggregate.GetContract(); + + // return Result.Success(contractModel); + //} + + public async Task> GetEstate(Guid estateId, + CancellationToken cancellationToken){ + + Result getEstateResult = await this.EstateAggregateRepository.GetLatestVersion(estateId, cancellationToken); + if (getEstateResult.IsFailed) + return ResultHelpers.CreateFailure(getEstateResult); + + EstateAggregate estateAggregate = getEstateResult.Data; + if (estateAggregate.IsCreated == false){ + return Result.NotFound($"No estate found with Id [{estateId}]"); + } + + Models.Estate estateModel = estateAggregate.GetEstate(); + + //if (estateModel.Operators != null){ + // foreach (Operator @operator in estateModel.Operators){ + // OperatorAggregate operatorAggregate = await this.OperatorAggregateRepository.GetLatestVersion(@operator.OperatorId, cancellationToken); + // @operator.Name = operatorAggregate.Name; + // } + //} + + return Result.Success(estateModel); + } + + public async Task>> GetEstates(Guid estateId, + CancellationToken cancellationToken){ + Result getEstateResult= await this.EstateManagementRepository.GetEstate(estateId, cancellationToken); + if (getEstateResult.IsFailed) + return Result.NotFound($"No estate found with Id [{estateId}]"); + + return Result.Success(new List(){ + getEstateResult.Data + }); + } + + //public async Task> GetMerchant(Guid estateId, + // Guid merchantId, + // CancellationToken cancellationToken) + //{ + // Result getMerchantResult= await this.MerchantAggregateRepository.GetLatestVersion(merchantId, cancellationToken); + // if (getMerchantResult.IsFailed) + // return ResultHelpers.CreateFailure(getMerchantResult); + + // MerchantAggregate merchantAggregate = getMerchantResult.Data; + // if (merchantAggregate.IsCreated == false) + // { + // return Result.NotFound($"No merchant found with Id [{merchantId}]"); + // } + + // Merchant merchantModel = merchantAggregate.GetMerchant(); + + // if (merchantModel.Operators != null){ + // foreach (Models.Merchant.Operator @operator in merchantModel.Operators){ + // OperatorAggregate operatorAggregate = await this.OperatorAggregateRepository.GetLatestVersion(@operator.OperatorId, cancellationToken); + // @operator.Name = operatorAggregate.Name; + // } + // } + + // return Result.Success(merchantModel); + //} + + //public async Task>> GetMerchantContracts(Guid estateId, + // Guid merchantId, + // CancellationToken cancellationToken) + //{ + // Result> getMerchantContractsResult = await this.EstateManagementRepository.GetMerchantContracts(estateId, merchantId, cancellationToken); + // if (getMerchantContractsResult.IsFailed) + // return ResultHelpers.CreateFailure(getMerchantContractsResult); + + // var contractModels = getMerchantContractsResult.Data; + // if (contractModels.Any() == false) + // return Result.NotFound($"No contracts for Estate {estateId} and Merchant {merchantId}"); + + // return Result.Success(contractModels); + //} + + //public async Task>> GetMerchants(Guid estateId, + // CancellationToken cancellationToken) + //{ + // var getMerchantsResult= await this.EstateManagementRepository.GetMerchants(estateId, cancellationToken); + // if (getMerchantsResult.IsFailed) + // return ResultHelpers.CreateFailure(getMerchantsResult); + // var merchants = getMerchantsResult.Data; + // if (merchants == null || merchants.Any() == false) + // { + // return Result.NotFound($"No Merchants found for estate Id {estateId}"); + // } + + // return Result.Success(merchants); + //} + + //public async Task>> GetTransactionFeesForProduct(Guid estateId, + // Guid merchantId, + // Guid contractId, + // Guid productId, + // CancellationToken cancellationToken) + //{ + // // TODO: this will need updated to handle merchant specific fees when that is available + + // Result getContractResult = await this.ContractAggregateRepository.GetLatestVersion(contractId, cancellationToken); + // if (getContractResult.IsFailed) + // return ResultHelpers.CreateFailure(getContractResult); + // ContractAggregate contract = getContractResult.Data; + // if (contract.IsCreated == false){ + // return Result.NotFound($"No contract found with Id [{contractId}]"); + // } + + // List products = contract.GetProducts(); + + // Product product = products.SingleOrDefault(p => p.ContractProductId == productId); + + // if (product == null){ + // return Result.NotFound($"No product found with Id [{productId}] on contract Id [{contractId}]"); + // } + + // return Result.Success(product.TransactionFees); + + //} + + //public async Task> GetFileDetails(Guid estateId, Guid fileId, CancellationToken cancellationToken){ + // var getFileDetailsResult= await this.EstateManagementRepository.GetFileDetails(estateId, fileId, cancellationToken); + // if (getFileDetailsResult.IsFailed) + // return ResultHelpers.CreateFailure(getFileDetailsResult); + + // return Result.Success(getFileDetailsResult.Data); + //} + + //public async Task> GetOperator(Guid estateId, Guid operatorId, CancellationToken cancellationToken){ + // var getOperatorResult = await this.OperatorAggregateRepository.GetLatestVersion(operatorId, cancellationToken); + // if (getOperatorResult.IsFailed) + // return ResultHelpers.CreateFailure(getOperatorResult); + // var operatorAggregate = getOperatorResult.Data; + // if (operatorAggregate.IsCreated == false){ + // return Result.NotFound($"No operator found with Id [{operatorId}]"); + // } + + // Models.Operator.Operator @operator = operatorAggregate.GetOperator(); + + // return Result.Success(@operator); + //} + + //public async Task>> GetOperators(Guid estateId, CancellationToken cancellationToken){ + // Result> getOperatorsResult = await this.EstateManagementRepository.GetOperators(estateId, cancellationToken); + // if (getOperatorsResult.IsFailed) + // return ResultHelpers.CreateFailure(getOperatorsResult); + + // return Result.Success(getOperatorsResult.Data); + //} + + #endregion + } +} \ No newline at end of file diff --git a/TransactionProcessor.BusinessLogic/Manager/IEstateManagementManager.cs b/TransactionProcessor.BusinessLogic/Manager/IEstateManagementManager.cs new file mode 100644 index 00000000..507ff45b --- /dev/null +++ b/TransactionProcessor.BusinessLogic/Manager/IEstateManagementManager.cs @@ -0,0 +1,50 @@ +using System; +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; +using SimpleResults; + +namespace TransactionProcessor.BusinessLogic.Manager +{ + public interface IEstateManagementManager + { + #region Methods + + //Task>> GetMerchantContracts(Guid estateId, + // Guid merchantId, + // CancellationToken cancellationToken); + + //Task>> GetContracts(Guid estateId, + // CancellationToken cancellationToken); + + //Task> GetContract(Guid estateId, + // Guid contractId, + // CancellationToken cancellationToken); + + Task> GetEstate(Guid estateId, + CancellationToken cancellationToken); + + Task>> GetEstates(Guid estateId, + CancellationToken cancellationToken); + + //Task> GetMerchant(Guid estateId, Guid merchantId, + // CancellationToken cancellationToken); + + //Task>> GetMerchants(Guid estateId, CancellationToken cancellationToken); + + //Task>> GetTransactionFeesForProduct(Guid estateId, + // Guid merchantId, + // Guid contractId, + // Guid productId, + // CancellationToken cancellationToken); + + //Task> GetFileDetails(Guid estateId, Guid fileId, CancellationToken cancellationToken); + + //Task> GetOperator(Guid estateId,Guid operatorId, + // CancellationToken cancellationToken); + + //Task>> GetOperators(Guid estateId, CancellationToken cancellationToken); + + #endregion + } +} \ No newline at end of file diff --git a/TransactionProcessor.BusinessLogic/Manager/IVoucherManagementManager.cs b/TransactionProcessor.BusinessLogic/Manager/IVoucherManagementManager.cs index 7e766ae6..d82264d0 100644 --- a/TransactionProcessor.BusinessLogic/Manager/IVoucherManagementManager.cs +++ b/TransactionProcessor.BusinessLogic/Manager/IVoucherManagementManager.cs @@ -5,14 +5,13 @@ using System.Threading; using System.Threading.Tasks; using SimpleResults; +using TransactionProcessor.Aggregates; namespace TransactionProcessor.BusinessLogic.Manager { - using EstateManagement.Database.Contexts; using Microsoft.EntityFrameworkCore; using ProjectionEngine.Database.Database; using ProjectionEngine.Database.Database.Entities; - using VoucherAggregate; using Voucher = Models.Voucher; public interface IVoucherManagementManager diff --git a/TransactionProcessor.BusinessLogic/RequestHandlers/EstateRequestHandler.cs b/TransactionProcessor.BusinessLogic/RequestHandlers/EstateRequestHandler.cs new file mode 100644 index 00000000..ce1c0a71 --- /dev/null +++ b/TransactionProcessor.BusinessLogic/RequestHandlers/EstateRequestHandler.cs @@ -0,0 +1,73 @@ +using MediatR; +using SimpleResults; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +using TransactionProcessor.BusinessLogic.Manager; +using TransactionProcessor.BusinessLogic.Requests; +using TransactionProcessor.BusinessLogic.Services; + +namespace TransactionProcessor.BusinessLogic.RequestHandlers +{ + public class EstateRequestHandler : IRequestHandler, + IRequestHandler, + IRequestHandler, + IRequestHandler, + IRequestHandler>, + IRequestHandler>> + { + #region Fields + + private readonly IEstateDomainService EstateDomainService; + + private readonly IEstateManagementManager EstateManagementManager; + + #endregion + + #region Constructors + + public EstateRequestHandler(IEstateDomainService estateDomainService, IEstateManagementManager manager) { + this.EstateDomainService = estateDomainService; + this.EstateManagementManager = manager; + } + + #endregion + + #region Methods + + public async Task Handle(EstateCommands.CreateEstateCommand command, CancellationToken cancellationToken) + { + return await this.EstateDomainService.CreateEstate(command, cancellationToken); + } + + public async Task Handle(EstateCommands.CreateEstateUserCommand command, CancellationToken cancellationToken) + { + return await this.EstateDomainService.CreateEstateUser(command, cancellationToken); + } + + public async Task Handle(EstateCommands.AddOperatorToEstateCommand command, + CancellationToken cancellationToken) + { + return await this.EstateDomainService.AddOperatorToEstate(command, cancellationToken); + } + + public async Task Handle(EstateCommands.RemoveOperatorFromEstateCommand command, CancellationToken cancellationToken) + { + return await this.EstateDomainService.RemoveOperatorFromEstate(command, cancellationToken); + } + + public async Task> Handle(EstateQueries.GetEstateQuery query, CancellationToken cancellationToken) + { + return await this.EstateManagementManager.GetEstate(query.EstateId, cancellationToken); + } + + public async Task>> Handle(EstateQueries.GetEstatesQuery query, CancellationToken cancellationToken) + { + return await this.EstateManagementManager.GetEstates(query.EstateId, cancellationToken); + } + #endregion + } +} diff --git a/TransactionProcessor.BusinessLogic/RequestHandlers/FloatRequestHandler.cs b/TransactionProcessor.BusinessLogic/RequestHandlers/FloatRequestHandler.cs index 34a2f4ab..c1415038 100644 --- a/TransactionProcessor.BusinessLogic/RequestHandlers/FloatRequestHandler.cs +++ b/TransactionProcessor.BusinessLogic/RequestHandlers/FloatRequestHandler.cs @@ -6,7 +6,6 @@ namespace TransactionProcessor.BusinessLogic.RequestHandlers { using System.Threading; - using EstateManagement.Database.Entities; using MediatR; using Models; using Requests; diff --git a/TransactionProcessor.BusinessLogic/RequestHandlers/SettlementRequestHandler.cs b/TransactionProcessor.BusinessLogic/RequestHandlers/SettlementRequestHandler.cs index 10fdc8ac..9e47f7d5 100644 --- a/TransactionProcessor.BusinessLogic/RequestHandlers/SettlementRequestHandler.cs +++ b/TransactionProcessor.BusinessLogic/RequestHandlers/SettlementRequestHandler.cs @@ -4,13 +4,12 @@ using System.Text; using System.Threading.Tasks; using SimpleResults; +using TransactionProcessor.Aggregates; using TransactionProcessor.BusinessLogic.Common; -using TransactionProcessor.SettlementAggregates; namespace TransactionProcessor.BusinessLogic.RequestHandlers { using System.Threading; - using EstateManagement.Database.Entities; using MediatR; using Models; using Requests; diff --git a/TransactionProcessor.BusinessLogic/Requests/EstateCommands.cs b/TransactionProcessor.BusinessLogic/Requests/EstateCommands.cs new file mode 100644 index 00000000..9fe21add --- /dev/null +++ b/TransactionProcessor.BusinessLogic/Requests/EstateCommands.cs @@ -0,0 +1,24 @@ +using EstateManagement.DataTransferObjects.Requests.Estate; +using MediatR; +using SimpleResults; +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace TransactionProcessor.BusinessLogic.Requests +{ + [ExcludeFromCodeCoverage] + public class EstateCommands + { + public record CreateEstateCommand(CreateEstateRequest RequestDto) : IRequest; + + public record CreateEstateUserCommand(Guid EstateId, CreateEstateUserRequest RequestDto) : IRequest; + + public record AddOperatorToEstateCommand(Guid EstateId, AssignOperatorRequest RequestDto) : IRequest; + + public record RemoveOperatorFromEstateCommand(Guid EstateId, Guid OperatorId) : IRequest; + } +} diff --git a/TransactionProcessor.BusinessLogic/Requests/EstateQueries.cs b/TransactionProcessor.BusinessLogic/Requests/EstateQueries.cs new file mode 100644 index 00000000..38fa5252 --- /dev/null +++ b/TransactionProcessor.BusinessLogic/Requests/EstateQueries.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using MediatR; +using SimpleResults; + +namespace TransactionProcessor.BusinessLogic.Requests +{ + [ExcludeFromCodeCoverage] + public class EstateQueries + { + public record GetEstateQuery(Guid EstateId) : IRequest>; + public record GetEstatesQuery(Guid EstateId) : IRequest>>; + } +} diff --git a/TransactionProcessor.BusinessLogic/Requests/SettlementQueries.cs b/TransactionProcessor.BusinessLogic/Requests/SettlementQueries.cs index ecfa8ecb..ebf0ce90 100644 --- a/TransactionProcessor.BusinessLogic/Requests/SettlementQueries.cs +++ b/TransactionProcessor.BusinessLogic/Requests/SettlementQueries.cs @@ -2,7 +2,7 @@ using System.Diagnostics.CodeAnalysis; using MediatR; using SimpleResults; -using TransactionProcessor.SettlementAggregates; +using TransactionProcessor.Aggregates; namespace TransactionProcessor.BusinessLogic.Requests; [ExcludeFromCodeCoverage] diff --git a/TransactionProcessor.BusinessLogic/Services/EstateDomainService.cs b/TransactionProcessor.BusinessLogic/Services/EstateDomainService.cs new file mode 100644 index 00000000..3e9146ac --- /dev/null +++ b/TransactionProcessor.BusinessLogic/Services/EstateDomainService.cs @@ -0,0 +1,153 @@ +using SecurityService.Client; +using SecurityService.DataTransferObjects; +using Shared.DomainDrivenDesign.EventSourcing; +using Shared.EventStore.Aggregate; +using Shared.Exceptions; +using Shared.Results; +using SimpleResults; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +using TransactionProcessor.Aggregates; +using TransactionProcessor.BusinessLogic.Requests; + +namespace TransactionProcessor.BusinessLogic.Services +{ + public interface IEstateDomainService + { + #region Methods + + Task CreateEstate(EstateCommands.CreateEstateCommand command, CancellationToken cancellationToken); + + Task AddOperatorToEstate(EstateCommands.AddOperatorToEstateCommand command, CancellationToken cancellationToken); + + Task CreateEstateUser(EstateCommands.CreateEstateUserCommand command, CancellationToken cancellationToken); + + Task RemoveOperatorFromEstate(EstateCommands.RemoveOperatorFromEstateCommand command, CancellationToken cancellationToken); + + #endregion + } + + public class EstateDomainService : IEstateDomainService + { + #region Fields + + private readonly IAggregateRepository EstateAggregateRepository; + + private readonly ISecurityServiceClient SecurityServiceClient; + + #endregion + + #region Constructors + + public EstateDomainService(IAggregateRepository estateAggregateRepository, + ISecurityServiceClient securityServiceClient) + { + this.EstateAggregateRepository = estateAggregateRepository; + this.SecurityServiceClient = securityServiceClient; + } + + #endregion + + #region Methods + + private async Task ApplyUpdates(Action action, Guid estateId, CancellationToken cancellationToken, Boolean isNotFoundError = true) + { + try + { + Result getLatestVersionResult = await this.EstateAggregateRepository.GetLatestVersion(estateId, cancellationToken); + Result estateAggregateResult = + DomainServiceHelper.HandleGetAggregateResult(getLatestVersionResult, estateId, isNotFoundError); + if (estateAggregateResult.IsFailed) + return ResultHelpers.CreateFailure(estateAggregateResult); + + EstateAggregate estateAggregate = estateAggregateResult.Data; + + action(estateAggregate); + + Result saveResult = await this.EstateAggregateRepository.SaveChanges(estateAggregate, cancellationToken); + if (saveResult.IsFailed) + return ResultHelpers.CreateFailure(saveResult); + + return Result.Success(); + } + catch (Exception ex) + { + return Result.Failure(ex.GetExceptionMessages()); + } + } + + + public async Task CreateEstate(EstateCommands.CreateEstateCommand command, CancellationToken cancellationToken) + { + Result result = await ApplyUpdates((estateAggregate) => { + estateAggregate.Create(command.RequestDto.EstateName); + estateAggregate.GenerateReference(); + }, command.RequestDto.EstateId, cancellationToken, false); + + return result; + } + + public async Task AddOperatorToEstate(EstateCommands.AddOperatorToEstateCommand command, CancellationToken cancellationToken) + { + Result result = await ApplyUpdates((estateAggregate) => { + estateAggregate.AddOperator(command.RequestDto.OperatorId); + }, command.EstateId, cancellationToken); + + return result; + } + + public async Task CreateEstateUser(EstateCommands.CreateEstateUserCommand command, CancellationToken cancellationToken) + { + CreateUserRequest createUserRequest = new CreateUserRequest + { + EmailAddress = command.RequestDto.EmailAddress, + FamilyName = command.RequestDto.FamilyName, + GivenName = command.RequestDto.GivenName, + MiddleName = command.RequestDto.MiddleName, + Password = command.RequestDto.Password, + PhoneNumber = "123456", // Is this really needed :| + Roles = new List(), + Claims = new Dictionary() + }; + + // Check if role has been overridden + String estateRoleName = Environment.GetEnvironmentVariable("EstateRoleName"); + createUserRequest.Roles.Add(String.IsNullOrEmpty(estateRoleName) ? "Estate" : estateRoleName); + createUserRequest.Claims.Add("estateId", command.EstateId.ToString()); + + Result createUserResult = await this.SecurityServiceClient.CreateUser(createUserRequest, cancellationToken); + if (createUserResult.IsFailed) + return ResultHelpers.CreateFailure(createUserResult); + + var userDetailsResult = await this.SecurityServiceClient.GetUsers(createUserRequest.EmailAddress, cancellationToken); + if (userDetailsResult.IsFailed) + return ResultHelpers.CreateFailure(userDetailsResult); + + var user = userDetailsResult.Data.SingleOrDefault(); + if (user == null) + return Result.Failure($"Unable to get user details for username {createUserRequest.EmailAddress}"); + + Result result = await ApplyUpdates((estateAggregate) => { + // Add the user to the aggregate + estateAggregate.AddSecurityUser(user.UserId, command.RequestDto.EmailAddress); + }, command.EstateId, cancellationToken); + + return result; + } + + public async Task RemoveOperatorFromEstate(EstateCommands.RemoveOperatorFromEstateCommand command, CancellationToken cancellationToken) + { + Result result = await ApplyUpdates((estateAggregate) => { + estateAggregate.RemoveOperator(command.OperatorId); + }, command.EstateId, cancellationToken); + + return result; + } + + #endregion + } +} diff --git a/TransactionProcessor.BusinessLogic/Services/IFloatDomainService.cs b/TransactionProcessor.BusinessLogic/Services/FloatDomainService.cs similarity index 96% rename from TransactionProcessor.BusinessLogic/Services/IFloatDomainService.cs rename to TransactionProcessor.BusinessLogic/Services/FloatDomainService.cs index 04d60d19..983a3046 100644 --- a/TransactionProcessor.BusinessLogic/Services/IFloatDomainService.cs +++ b/TransactionProcessor.BusinessLogic/Services/FloatDomainService.cs @@ -16,11 +16,9 @@ namespace TransactionProcessor.BusinessLogic.Services using System.Threading; using Common; using EstateManagement.Client; - using EstateManagement.Database.Entities; using EstateManagement.DataTransferObjects.Responses; using EstateManagement.DataTransferObjects.Responses.Contract; using EstateManagement.DataTransferObjects.Responses.Estate; - using FloatAggregate; using Models; using SecurityService.Client; using SecurityService.DataTransferObjects.Responses; @@ -29,6 +27,7 @@ namespace TransactionProcessor.BusinessLogic.Services using Shared.Exceptions; using Shared.General; using Shared.Logger; + using TransactionProcessor.Aggregates; public interface IFloatDomainService { Task CreateFloatForContractProduct(FloatCommands.CreateFloatForContractProductCommand command, @@ -46,14 +45,14 @@ Task RecordTransaction(FloatActivityCommands.RecordTransactionCommand co public class FloatDomainService : IFloatDomainService{ private readonly IAggregateRepository FloatAggregateRepository; private readonly IAggregateRepository FloatActivityAggregateRepository; - private readonly IAggregateRepository TransactionAggregateRepository; + private readonly IAggregateRepository TransactionAggregateRepository; private readonly IIntermediateEstateClient EstateClient; private readonly ISecurityServiceClient SecurityServiceClient; public FloatDomainService(IAggregateRepository floatAggregateRepository, IAggregateRepository floatActivityAggregateRepository, - IAggregateRepository transactionAggregateRepository, + IAggregateRepository transactionAggregateRepository, IIntermediateEstateClient estateClient, ISecurityServiceClient securityServiceClient) { @@ -200,7 +199,7 @@ public async Task RecordCreditPurchase(FloatActivityCommands.RecordCredi public async Task RecordTransaction(FloatActivityCommands.RecordTransactionCommand command, CancellationToken cancellationToken) { - Result getTransactionResult = await this.TransactionAggregateRepository.GetLatestVersion(command.TransactionId, cancellationToken); + Result getTransactionResult = await this.TransactionAggregateRepository.GetLatestVersion(command.TransactionId, cancellationToken); if (getTransactionResult.IsFailed) return ResultHelpers.CreateFailure(getTransactionResult); diff --git a/TransactionProcessor.BusinessLogic/Services/IMessageTemplateReader.cs b/TransactionProcessor.BusinessLogic/Services/IMessageTemplateReader.cs deleted file mode 100644 index a903ae10..00000000 --- a/TransactionProcessor.BusinessLogic/Services/IMessageTemplateReader.cs +++ /dev/null @@ -1,30 +0,0 @@ -namespace TransactionProcessor.BusinessLogic.Services -{ - using System; - using System.Threading; - using System.Threading.Tasks; - using EstateManagement.DataTransferObjects.Responses; - using Models; - - /// - /// - /// - public interface ITransactionReceiptBuilder - { - #region Methods - - /// - /// Gets the email receipt message. - /// - /// The transaction. - /// The merchant. - /// The cancellation token. - /// - Task GetEmailReceiptMessage(Transaction transaction, - EstateManagement.DataTransferObjects.Responses.Merchant.MerchantResponse merchant, - String operatorName, - CancellationToken cancellationToken); - - #endregion - } -} \ No newline at end of file diff --git a/TransactionProcessor.BusinessLogic/Services/ISettlementDomainService.cs b/TransactionProcessor.BusinessLogic/Services/ISettlementDomainService.cs deleted file mode 100644 index 8b6a80ee..00000000 --- a/TransactionProcessor.BusinessLogic/Services/ISettlementDomainService.cs +++ /dev/null @@ -1,24 +0,0 @@ -using SimpleResults; -using TransactionProcessor.BusinessLogic.Requests; - -namespace TransactionProcessor.BusinessLogic.Services -{ - using System; - using System.Threading; - using System.Threading.Tasks; - using Models; - - /// - /// - /// - public interface ISettlementDomainService - { - Task> ProcessSettlement(SettlementCommands.ProcessSettlementCommand command, CancellationToken cancellationToken); - - Task AddMerchantFeePendingSettlement(SettlementCommands.AddMerchantFeePendingSettlementCommand command, - CancellationToken cancellationToken); - - Task AddSettledFeeToSettlement(SettlementCommands.AddSettledFeeToSettlementCommand command, - CancellationToken cancellationToken); - } -} \ No newline at end of file diff --git a/TransactionProcessor.BusinessLogic/Services/ITransactionDomainService.cs b/TransactionProcessor.BusinessLogic/Services/ITransactionDomainService.cs deleted file mode 100644 index ad90f496..00000000 --- a/TransactionProcessor.BusinessLogic/Services/ITransactionDomainService.cs +++ /dev/null @@ -1,41 +0,0 @@ -using SimpleResults; -using TransactionProcessor.BusinessLogic.Requests; - -namespace TransactionProcessor.BusinessLogic.Services -{ - using System; - using System.Collections.Generic; - using System.Threading; - using System.Threading.Tasks; - using Models; - - public interface ITransactionDomainService - { - #region Methods - - Task> ProcessLogonTransaction(TransactionCommands.ProcessLogonTransactionCommand command, - CancellationToken cancellationToken); - - Task> ProcessSaleTransaction(TransactionCommands.ProcessSaleTransactionCommand command, - CancellationToken cancellationToken); - - Task> ProcessReconciliationTransaction(TransactionCommands.ProcessReconciliationCommand command, - CancellationToken cancellationToken); - - Task ResendTransactionReceipt(TransactionCommands.ResendTransactionReceiptCommand command, - CancellationToken cancellationToken); - - Task CalculateFeesForTransaction(TransactionCommands.CalculateFeesForTransactionCommand command, - CancellationToken cancellationToken); - - #endregion - - Task AddSettledMerchantFee(TransactionCommands.AddSettledMerchantFeeCommand command, - CancellationToken cancellationToken); - - Task SendCustomerEmailReceipt(TransactionCommands.SendCustomerEmailReceiptCommand command, - CancellationToken cancellationToken); - Task ResendCustomerEmailReceipt(TransactionCommands.ResendCustomerEmailReceiptCommand command, - CancellationToken cancellationToken); - } -} \ No newline at end of file diff --git a/TransactionProcessor.BusinessLogic/Services/ITransactionValidationService.cs b/TransactionProcessor.BusinessLogic/Services/ITransactionValidationService.cs deleted file mode 100644 index 9e03fd40..00000000 --- a/TransactionProcessor.BusinessLogic/Services/ITransactionValidationService.cs +++ /dev/null @@ -1,38 +0,0 @@ -using System.Diagnostics.CodeAnalysis; -using SimpleResults; - -namespace TransactionProcessor.BusinessLogic.Services; - -using System; -using System.Threading; -using System.Threading.Tasks; - -public interface ITransactionValidationService{ - #region Methods - - Task> ValidateLogonTransaction(Guid estateId, - Guid merchantId, - String deviceIdentifier, - CancellationToken cancellationToken); - Task> ValidateReconciliationTransaction(Guid estateId, - Guid merchantId, - String deviceIdentifier, - CancellationToken cancellationToken); - - Task> ValidateSaleTransaction(Guid estateId, - Guid merchantId, - Guid contractId, - Guid productId, - String deviceIdentifier, - Guid operatorId, - Decimal? transactionAmount, - CancellationToken cancellationToken); - - #endregion -} - -[ExcludeFromCodeCoverage] -public record TransactionValidationResult(TransactionResponseCode ResponseCode, String ResponseMessage); - -[ExcludeFromCodeCoverage] -public record TransactionValidationResult(TransactionValidationResult validationResult, T additionalData = default); \ No newline at end of file diff --git a/TransactionProcessor.BusinessLogic/Services/IVoucherDomainService.cs b/TransactionProcessor.BusinessLogic/Services/IVoucherDomainService.cs deleted file mode 100644 index b6a64f45..00000000 --- a/TransactionProcessor.BusinessLogic/Services/IVoucherDomainService.cs +++ /dev/null @@ -1,53 +0,0 @@ -using System; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -using SimpleResults; - -namespace TransactionProcessor.BusinessLogic.Services -{ - using Models; - - public interface IVoucherDomainService - { - #region Methods - - /// - /// Issues the voucher. - /// - /// The voucher identifier. - /// The operator identifier. - /// The estate identifier. - /// The transaction identifier. - /// The issued date time. - /// The value. - /// The recipient email. - /// The recipient mobile. - /// The cancellation token. - /// - Task> IssueVoucher(Guid voucherId, - Guid operatorId, - Guid estateId, - Guid transactionId, - DateTime issuedDateTime, - Decimal value, - String recipientEmail, - String recipientMobile, - CancellationToken cancellationToken); - - /// - /// Redeems the voucher. - /// - /// The estate identifier. - /// The voucher code. - /// The redeemed date time. - /// The cancellation token. - /// - Task> RedeemVoucher(Guid estateId, - String voucherCode, - DateTime redeemedDateTime, - CancellationToken cancellationToken); - - #endregion - } -} diff --git a/TransactionProcessor.BusinessLogic/Services/SettlementDomainService.cs b/TransactionProcessor.BusinessLogic/Services/SettlementDomainService.cs index 45bddaee..b0aadb2f 100644 --- a/TransactionProcessor.BusinessLogic/Services/SettlementDomainService.cs +++ b/TransactionProcessor.BusinessLogic/Services/SettlementDomainService.cs @@ -1,5 +1,6 @@ using Shared.Results; using SimpleResults; +using TransactionProcessor.Aggregates; using TransactionProcessor.BusinessLogic.Requests; namespace TransactionProcessor.BusinessLogic.Services @@ -17,14 +18,22 @@ namespace TransactionProcessor.BusinessLogic.Services using Models; using SecurityService.Client; using SecurityService.DataTransferObjects.Responses; - using SettlementAggregates; using Shared.DomainDrivenDesign.EventSourcing; using Shared.EventStore.Aggregate; using Shared.Exceptions; using Shared.General; using Shared.Logger; - using TransactionAggregate; + public interface ISettlementDomainService + { + Task> ProcessSettlement(SettlementCommands.ProcessSettlementCommand command, CancellationToken cancellationToken); + + Task AddMerchantFeePendingSettlement(SettlementCommands.AddMerchantFeePendingSettlementCommand command, + CancellationToken cancellationToken); + + Task AddSettledFeeToSettlement(SettlementCommands.AddSettledFeeToSettlementCommand command, + CancellationToken cancellationToken); + } public class SettlementDomainService : ISettlementDomainService { private readonly IAggregateRepository TransactionAggregateRepository; diff --git a/TransactionProcessor.BusinessLogic/Services/TransactionDomainService.cs b/TransactionProcessor.BusinessLogic/Services/TransactionDomainService.cs index 9f34e97d..959c22fc 100644 --- a/TransactionProcessor.BusinessLogic/Services/TransactionDomainService.cs +++ b/TransactionProcessor.BusinessLogic/Services/TransactionDomainService.cs @@ -4,6 +4,7 @@ using Shared.Exceptions; using Shared.Results; using SimpleResults; +using TransactionProcessor.Aggregates; namespace TransactionProcessor.BusinessLogic.Services{ using System; @@ -18,27 +19,50 @@ namespace TransactionProcessor.BusinessLogic.Services{ using EstateManagement.DataTransferObjects.Requests.Merchant; using EstateManagement.DataTransferObjects.Responses; using EstateManagement.DataTransferObjects.Responses.Estate; - using FloatAggregate; using MessagingService.Client; using MessagingService.DataTransferObjects; using Microsoft.Extensions.Caching.Memory; using Models; using OperatorInterfaces; - using ReconciliationAggregate; using SecurityService.Client; using SecurityService.DataTransferObjects.Responses; using Shared.DomainDrivenDesign.EventSourcing; using Shared.EventStore.Aggregate; using Shared.General; using Shared.Logger; - using TransactionAggregate; using TransactionProcessor.BusinessLogic.Manager; using TransactionProcessor.BusinessLogic.Requests; - /// - /// - /// - /// + public interface ITransactionDomainService + { + #region Methods + + Task> ProcessLogonTransaction(TransactionCommands.ProcessLogonTransactionCommand command, + CancellationToken cancellationToken); + + Task> ProcessSaleTransaction(TransactionCommands.ProcessSaleTransactionCommand command, + CancellationToken cancellationToken); + + Task> ProcessReconciliationTransaction(TransactionCommands.ProcessReconciliationCommand command, + CancellationToken cancellationToken); + + Task ResendTransactionReceipt(TransactionCommands.ResendTransactionReceiptCommand command, + CancellationToken cancellationToken); + + Task CalculateFeesForTransaction(TransactionCommands.CalculateFeesForTransactionCommand command, + CancellationToken cancellationToken); + + #endregion + + Task AddSettledMerchantFee(TransactionCommands.AddSettledMerchantFeeCommand command, + CancellationToken cancellationToken); + + Task SendCustomerEmailReceipt(TransactionCommands.SendCustomerEmailReceiptCommand command, + CancellationToken cancellationToken); + Task ResendCustomerEmailReceipt(TransactionCommands.ResendCustomerEmailReceiptCommand command, + CancellationToken cancellationToken); + } + public class TransactionDomainService : ITransactionDomainService{ #region Fields diff --git a/TransactionProcessor.BusinessLogic/Services/TransactionReceiptBuilder.cs b/TransactionProcessor.BusinessLogic/Services/TransactionReceiptBuilder.cs index 09192b67..acdadcef 100644 --- a/TransactionProcessor.BusinessLogic/Services/TransactionReceiptBuilder.cs +++ b/TransactionProcessor.BusinessLogic/Services/TransactionReceiptBuilder.cs @@ -8,10 +8,25 @@ using EstateManagement.DataTransferObjects.Responses; using Models; - /// - /// - /// - /// + public interface ITransactionReceiptBuilder + { + #region Methods + + /// + /// Gets the email receipt message. + /// + /// The transaction. + /// The merchant. + /// The cancellation token. + /// + Task GetEmailReceiptMessage(Transaction transaction, + EstateManagement.DataTransferObjects.Responses.Merchant.MerchantResponse merchant, + String operatorName, + CancellationToken cancellationToken); + + #endregion + } + public class TransactionReceiptBuilder : ITransactionReceiptBuilder { #region Fields diff --git a/TransactionProcessor.BusinessLogic/Services/TransactionValidationService.cs b/TransactionProcessor.BusinessLogic/Services/TransactionValidationService.cs index 1c5da9a8..c4e568b5 100644 --- a/TransactionProcessor.BusinessLogic/Services/TransactionValidationService.cs +++ b/TransactionProcessor.BusinessLogic/Services/TransactionValidationService.cs @@ -1,7 +1,11 @@ using System.Runtime.CompilerServices; using EstateManagement.DataTransferObjects.Responses.Merchant; +using Shared.DomainDrivenDesign.EventSourcing; +using Shared.EventStore.Aggregate; using Shared.Results; using SimpleResults; +using TransactionProcessor.Aggregates; +using TransactionProcessor.Models; namespace TransactionProcessor.BusinessLogic.Services; @@ -13,7 +17,6 @@ namespace TransactionProcessor.BusinessLogic.Services; using System.Threading.Tasks; using Common; using EstateManagement.Client; -using EstateManagement.Database.Entities; using EstateManagement.DataTransferObjects.Responses; using EstateManagement.DataTransferObjects.Responses.Estate; using EventStore.Client; @@ -27,6 +30,31 @@ namespace TransactionProcessor.BusinessLogic.Services; using Shared.General; using Shared.Logger; +public interface ITransactionValidationService +{ + #region Methods + + Task> ValidateLogonTransaction(Guid estateId, + Guid merchantId, + String deviceIdentifier, + CancellationToken cancellationToken); + Task> ValidateReconciliationTransaction(Guid estateId, + Guid merchantId, + String deviceIdentifier, + CancellationToken cancellationToken); + + Task> ValidateSaleTransaction(Guid estateId, + Guid merchantId, + Guid contractId, + Guid productId, + String deviceIdentifier, + Guid operatorId, + Decimal? transactionAmount, + CancellationToken cancellationToken); + + #endregion +} + public class TransactionValidationService : ITransactionValidationService{ #region Fields @@ -38,6 +66,7 @@ public class TransactionValidationService : ITransactionValidationService{ private readonly ProjectionEngine.Repository.IProjectionStateRepository MerchantBalanceStateRepository; private readonly IEventStoreContext EventStoreContext; + private readonly IAggregateRepository EstateAggregateRepository; /// @@ -52,12 +81,14 @@ public class TransactionValidationService : ITransactionValidationService{ public TransactionValidationService(IIntermediateEstateClient estateClient, ISecurityServiceClient securityServiceClient, ProjectionEngine.Repository.IProjectionStateRepository merchantBalanceStateRepository, - IEventStoreContext eventStoreContext) + IEventStoreContext eventStoreContext, + IAggregateRepository estateAggregateRepository) { this.EstateClient = estateClient; this.SecurityServiceClient = securityServiceClient; this.MerchantBalanceStateRepository = merchantBalanceStateRepository; this.EventStoreContext = eventStoreContext; + this.EstateAggregateRepository = estateAggregateRepository; } #region Methods @@ -76,7 +107,7 @@ public async Task> ValidateLogonTransaction( String deviceIdentifier, CancellationToken cancellationToken) { // Validate Estate - Result> estateValidationResult = await ValidateEstate(estateId, cancellationToken); + Result> estateValidationResult = await ValidateEstate(estateId, cancellationToken); if (estateValidationResult.IsFailed) return CreateFailedResult(estateValidationResult.Data.validationResult); // Validate Merchant @@ -99,10 +130,10 @@ public async Task> ValidateReconciliationTra CancellationToken cancellationToken) { // Validate Estate - Result> estateValidationResult = await ValidateEstate(estateId, cancellationToken); + Result> estateValidationResult = await ValidateEstate(estateId, cancellationToken); if (estateValidationResult.IsFailed) return CreateFailedResult(estateValidationResult.Data.validationResult); - EstateResponse estate = estateValidationResult.Data.additionalData; + EstateAggregate estate = estateValidationResult.Data.additionalData; // Validate Merchant Result> merchantValidationResult = await ValidateMerchant(estateId, estateValidationResult.Data.additionalData.EstateName, merchantId, cancellationToken); @@ -117,13 +148,6 @@ public async Task> ValidateReconciliationTra // Validate the merchant device return Result.Success(new TransactionValidationResult(TransactionResponseCode.Success, "SUCCESS")); } - - private async Task> GetEstate(Guid estateId, - CancellationToken cancellationToken){ - this.TokenResponse = await Helpers.GetToken(this.TokenResponse, this.SecurityServiceClient, cancellationToken); - - return await this.EstateClient.GetEstate(this.TokenResponse.AccessToken, estateId, cancellationToken); - } private async Task> GetMerchant(Guid estateId, Guid merchantId, @@ -157,10 +181,10 @@ public async Task> ValidateSaleTransaction(G CancellationToken cancellationToken) { // Validate Estate - Result> estateValidationResult = await ValidateEstate(estateId, cancellationToken); + Result> estateValidationResult = await ValidateEstate(estateId, cancellationToken); if (estateValidationResult.IsFailed) return CreateFailedResult(estateValidationResult.Data.validationResult); - EstateResponse estate = estateValidationResult.Data.additionalData; + EstateAggregate estate = estateValidationResult.Data.additionalData; // Validate Operator for Estate Result estateOperatorValidationResult = ValidateEstateOperator(estate, operatorId); @@ -192,28 +216,29 @@ public async Task> ValidateSaleTransaction(G return Result.Success(new TransactionValidationResult(TransactionResponseCode.Success, "SUCCESS")); } - private async Task>> ValidateEstate(Guid estateId, CancellationToken cancellationToken) + private async Task>> ValidateEstate(Guid estateId, CancellationToken cancellationToken) { - Result getEstateResult = await this.GetEstate(estateId, cancellationToken); + Result getEstateResult = await this.EstateAggregateRepository.GetLatestVersion(estateId, cancellationToken); if (getEstateResult.IsFailed) { - TransactionValidationResult transactionValidationResult = getEstateResult.Status switch { + TransactionValidationResult transactionValidationResult = getEstateResult.Status switch + { ResultStatus.NotFound => new TransactionValidationResult(TransactionResponseCode.InvalidEstateId, $"Estate Id [{estateId}] is not a valid estate"), _ => new TransactionValidationResult(TransactionResponseCode.UnknownFailure, $"An error occurred while getting Estate Id [{estateId}] Message: [{getEstateResult.Message}]") }; - - return CreateFailedResult(new TransactionValidationResult(transactionValidationResult)); + return CreateFailedResult(new TransactionValidationResult(transactionValidationResult)); } - return Result.Success(new TransactionValidationResult(new TransactionValidationResult(TransactionResponseCode.Success, "SUCCESS"), getEstateResult.Data)); + return Result.Success(new TransactionValidationResult(new TransactionValidationResult(TransactionResponseCode.Success, "SUCCESS"), getEstateResult.Data)); } - private Result ValidateEstateOperator(EstateResponse estate, Guid operatorId) - { - if (estate.Operators == null || !estate.Operators.Any()) + private Result ValidateEstateOperator(EstateAggregate estate, Guid operatorId) { + List estateOperators = estate.GetEstate().Operators; + + if (estateOperators == null || estateOperators.Any() == false) { return CreateFailedResult(new TransactionValidationResult(TransactionResponseCode.NoEstateOperators, $"Estate {estate.EstateName} has no operators defined")); } - EstateOperatorResponse estateOperatorRecord = estate.Operators.SingleOrDefault(o => o.OperatorId == operatorId); + EstateOperator estateOperatorRecord = estateOperators.SingleOrDefault(o => o.OperatorId == operatorId); Result result = estateOperatorRecord switch { null => CreateFailedResult(new TransactionValidationResult(TransactionResponseCode.OperatorNotValidForEstate, $"Operator {operatorId} not configured for Estate [{estate.EstateName}]")), @@ -351,4 +376,10 @@ private async Task> ValidateTransactionAmoun return Result.Success(new TransactionValidationResult(TransactionResponseCode.Success, "SUCCESS")); } -} \ No newline at end of file +} + +[ExcludeFromCodeCoverage] +public record TransactionValidationResult(TransactionResponseCode ResponseCode, String ResponseMessage); + +[ExcludeFromCodeCoverage] +public record TransactionValidationResult(TransactionValidationResult validationResult, T additionalData = default); \ No newline at end of file diff --git a/TransactionProcessor.BusinessLogic/Services/VoucherDomainService.cs b/TransactionProcessor.BusinessLogic/Services/VoucherDomainService.cs index 71a40cf1..e538f906 100644 --- a/TransactionProcessor.BusinessLogic/Services/VoucherDomainService.cs +++ b/TransactionProcessor.BusinessLogic/Services/VoucherDomainService.cs @@ -1,4 +1,6 @@ using Shared.Results; +using TransactionProcessor.Aggregates; +using TransactionProcessor.Database.Contexts; namespace TransactionProcessor.BusinessLogic.Services; @@ -9,8 +11,6 @@ namespace TransactionProcessor.BusinessLogic.Services; using System.Threading.Tasks; using Common; using EstateManagement.Client; -using EstateManagement.Database.Contexts; -using EstateManagement.Database.Entities; using EstateManagement.DataTransferObjects.Responses; using EstateManagement.DataTransferObjects.Responses.Estate; using Google.Protobuf.WellKnownTypes; @@ -25,7 +25,49 @@ namespace TransactionProcessor.BusinessLogic.Services; using Shared.General; using Shared.Logger; using SimpleResults; -using VoucherAggregate; + +public interface IVoucherDomainService +{ + #region Methods + + /// + /// Issues the voucher. + /// + /// The voucher identifier. + /// The operator identifier. + /// The estate identifier. + /// The transaction identifier. + /// The issued date time. + /// The value. + /// The recipient email. + /// The recipient mobile. + /// The cancellation token. + /// + Task> IssueVoucher(Guid voucherId, + Guid operatorId, + Guid estateId, + Guid transactionId, + DateTime issuedDateTime, + Decimal value, + String recipientEmail, + String recipientMobile, + CancellationToken cancellationToken); + + /// + /// Redeems the voucher. + /// + /// The estate identifier. + /// The voucher code. + /// The redeemed date time. + /// The cancellation token. + /// + Task> RedeemVoucher(Guid estateId, + String voucherCode, + DateTime redeemedDateTime, + CancellationToken cancellationToken); + + #endregion +} public class VoucherDomainService : IVoucherDomainService { @@ -155,7 +197,7 @@ public async Task> RedeemVoucher(Guid estateId, // Find the voucher based on the voucher code EstateManagementGenericContext context = await this.DbContextFactory.GetContext(estateId, VoucherDomainService.ConnectionStringIdentifier, cancellationToken); - EstateManagement.Database.Entities.Voucher voucher = await context.Vouchers.SingleOrDefaultAsync(v => v.VoucherCode == voucherCode, cancellationToken); + TransactionProcessor.Database.Entities.Voucher voucher = await context.Vouchers.SingleOrDefaultAsync(v => v.VoucherCode == voucherCode, cancellationToken); if (voucher == null) { diff --git a/TransactionProcessor.BusinessLogic/TransactionProcessor.BusinessLogic.csproj b/TransactionProcessor.BusinessLogic/TransactionProcessor.BusinessLogic.csproj index 908cff20..6eb524e4 100644 --- a/TransactionProcessor.BusinessLogic/TransactionProcessor.BusinessLogic.csproj +++ b/TransactionProcessor.BusinessLogic/TransactionProcessor.BusinessLogic.csproj @@ -7,7 +7,7 @@ - + @@ -24,14 +24,11 @@ + - - - - - + diff --git a/TransactionProcessor.Client/ITransactionProcessorClient.cs b/TransactionProcessor.Client/ITransactionProcessorClient.cs index 479023f5..9e4de499 100644 --- a/TransactionProcessor.Client/ITransactionProcessorClient.cs +++ b/TransactionProcessor.Client/ITransactionProcessorClient.cs @@ -1,4 +1,13 @@ using SimpleResults; +using TransactionProcessor.DataTransferObjects.Requests.Contract; +using TransactionProcessor.DataTransferObjects.Requests.Estate; +using TransactionProcessor.DataTransferObjects.Requests.Merchant; +using TransactionProcessor.DataTransferObjects.Requests.Operator; +using TransactionProcessor.DataTransferObjects.Responses.Contract; +using TransactionProcessor.DataTransferObjects.Responses.Estate; +using TransactionProcessor.DataTransferObjects.Responses.Merchant; +using TransactionProcessor.DataTransferObjects.Responses.Operator; +using AssignOperatorRequest = TransactionProcessor.DataTransferObjects.Requests.Estate.AssignOperatorRequest; namespace TransactionProcessor.Client { @@ -70,6 +79,219 @@ Task RecordFloatCreditPurchase(String accessToken, RecordFloatCreditPurchaseRequest recordFloatCreditPurchaseRequest, CancellationToken cancellationToken); + Task> GetEstate(String accessToken, + Guid estateId, + CancellationToken cancellationToken); + + Task>> GetEstates(String accessToken, + Guid estateId, + CancellationToken cancellationToken); + + Task CreateEstate(String accessToken, + CreateEstateRequest createEstateRequest, + CancellationToken cancellationToken); + + Task CreateEstateUser(String accessToken, + Guid estateId, + CreateEstateUserRequest createEstateUserRequest, + CancellationToken cancellationToken); + + Task CreateMerchant(String accessToken, + Guid estateId, + CreateMerchantRequest createMerchantRequest, + CancellationToken cancellationToken); + + Task> GetMerchant(String accessToken, + Guid estateId, + Guid merchantId, + CancellationToken cancellationToken); + + Task AssignOperatorToMerchant(String accessToken, + Guid estateId, + Guid merchantId, + DataTransferObjects.Requests.Merchant.AssignOperatorRequest assignOperatorRequest, + CancellationToken cancellationToken); + + Task CreateOperator(String accessToken, + Guid estateId, + CreateOperatorRequest createOperatorRequest, + CancellationToken cancellationToken); + + Task>> GetOperators(String accessToken, + Guid estateId, + CancellationToken cancellationToken); + + Task AssignOperatorToEstate(String accessToken, + Guid estateId, + AssignOperatorRequest assignOperatorRequest, + CancellationToken cancellationToken); + + Task CreateContract(String accessToken, + Guid estateId, + CreateContractRequest createContractRequest, + CancellationToken cancellationToken); + + Task>> GetContracts(String accessToken, + Guid estateId, + CancellationToken cancellationToken); + + Task AddProductToContract(String accessToken, + Guid estateId, + Guid contractId, + AddProductToContractRequest addProductToContractRequest, + CancellationToken cancellationToken); + + Task> GetContract(String accessToken, + Guid estateId, + Guid contractId, + CancellationToken cancellationToken); + + Task AddTransactionFeeForProductToContract(String accessToken, + Guid estateId, + Guid contractId, + Guid productId, + AddTransactionFeeForProductToContractRequest + addTransactionFeeForProductToContractRequest, + CancellationToken cancellationToken); + + Task>> GetTransactionFeesForProduct(String accessToken, + Guid estateId, + Guid merchantId, + Guid contractId, + Guid productId, + CancellationToken cancellationToken); + + Task AddDeviceToMerchant(String accessToken, + Guid estateId, + Guid merchantId, + AddMerchantDeviceRequest request, + CancellationToken cancellationToken); + + Task AddContractToMerchant(String accessToken, + Guid estateId, + Guid merchantId, + AddMerchantContractRequest request, + CancellationToken cancellationToken); + + Task MakeMerchantDeposit(String accessToken, + Guid estateId, + Guid merchantId, + MakeMerchantDepositRequest makeMerchantDepositRequest, + CancellationToken cancellationToken); + + Task CreateMerchantUser(String accessToken, + Guid estateId, + Guid merchantId, + CreateMerchantUserRequest createMerchantUserRequest, + CancellationToken cancellationToken); + + Task RemoveOperatorFromEstate(String accessToken, + Guid estateId, + Guid operatorId, + CancellationToken cancellationToken); + + Task> GetOperator(String accessToken, + Guid estateId, + Guid operatorId, + CancellationToken cancellationToken); + + Task UpdateOperator(String accessToken, + Guid estateId, + Guid operatorId, + UpdateOperatorRequest updateOperatorRequest, + CancellationToken cancellationToken); + + Task UpdateMerchantContact(String accessToken, + Guid estateId, + Guid merchantId, + Guid contactId, + Contact updatedContactRequest, + CancellationToken cancellationToken); + + Task UpdateMerchantAddress(String accessToken, + Guid estateId, + Guid merchantId, + Guid addressId, + Address updatedAddressRequest, + CancellationToken cancellationToken); + + Task UpdateMerchant(String accessToken, + Guid estateId, + Guid merchantId, + UpdateMerchantRequest request, + CancellationToken cancellationToken); + + Task SetMerchantSettlementSchedule(String accessToken, + Guid estateId, + Guid merchantId, + SetSettlementScheduleRequest setSettlementScheduleRequest, + CancellationToken cancellationToken); + + Task SwapDeviceForMerchant(String accessToken, + Guid estateId, + Guid merchantId, + String deviceIdentifier, + SwapMerchantDeviceRequest request, + CancellationToken cancellationToken); + + Task MakeMerchantWithdrawal(String accessToken, + Guid estateId, + Guid merchantId, + MakeMerchantWithdrawalRequest makeMerchantWithdrawalRequest, + CancellationToken cancellationToken); + + Task> GetSettlement(String accessToken, + Guid estateId, + Guid? merchantId, + Guid settlementId, + CancellationToken cancellationToken); + + Task>> GetSettlements(String accessToken, + Guid estateId, + Guid? merchantId, + String startDate, + String endDate, + CancellationToken cancellationToken); + + Task>> GetMerchants(String accessToken, + Guid estateId, + CancellationToken cancellationToken); + + Task>> GetMerchantContracts(String accessToken, + Guid estateId, + Guid merchantId, + CancellationToken cancellationToken); + + Task DisableTransactionFeeForProduct(String accessToken, + Guid estateId, + Guid contractId, + Guid productId, + Guid transactionFeeId, + CancellationToken cancellationToken); + + Task RemoveContractFromMerchant(String accessToken, + Guid estateId, + Guid merchantId, + Guid contractId, + CancellationToken cancellationToken); + + Task RemoveOperatorFromMerchant(String accessToken, + Guid estateId, + Guid merchantId, + Guid operatorId, + CancellationToken cancellationToken); + + Task AddMerchantContact(String accessToken, + Guid estateId, + Guid merchantId, + Contact newContactRequest, + CancellationToken cancellationToken); + + Task AddMerchantAddress(String accessToken, + Guid estateId, + Guid merchantId, + Address newAddressRequest, + CancellationToken cancellationToken); #endregion } } \ No newline at end of file diff --git a/TransactionProcessor.Client/TransactionProcessorClient.cs b/TransactionProcessor.Client/TransactionProcessorClient.cs index 4e79ecf6..fb8e10ef 100644 --- a/TransactionProcessor.Client/TransactionProcessorClient.cs +++ b/TransactionProcessor.Client/TransactionProcessorClient.cs @@ -1,415 +1,1718 @@ using SimpleResults; +using TransactionProcessor.DataTransferObjects.Requests.Contract; +using TransactionProcessor.DataTransferObjects.Requests.Estate; +using TransactionProcessor.DataTransferObjects.Requests.Merchant; +using TransactionProcessor.DataTransferObjects.Requests.Operator; +using TransactionProcessor.DataTransferObjects.Responses.Contract; +using TransactionProcessor.DataTransferObjects.Responses.Estate; +using TransactionProcessor.DataTransferObjects.Responses.Merchant; +using TransactionProcessor.DataTransferObjects.Responses.Operator; +using AssignOperatorRequest = TransactionProcessor.DataTransferObjects.Requests.Merchant.AssignOperatorRequest; + +namespace TransactionProcessor.Client; + +using System; +using System.Collections.Generic; +using System.Net.Http; +using System.Net.Http.Headers; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +using ClientProxyBase; +using DataTransferObjects; +using Newtonsoft.Json; +using Shared.Results; + +public class TransactionProcessorClient : ClientProxyBase, ITransactionProcessorClient { + #region Fields + + //private readonly String BaseAddress; + + private readonly Func BaseAddressResolver; + + #endregion + + #region Constructors + + public TransactionProcessorClient(Func baseAddressResolver, + HttpClient httpClient) : base(httpClient) { + this.BaseAddressResolver = baseAddressResolver; + + // Add the API version header + this.HttpClient.DefaultRequestHeaders.Add("api-version", "1.0"); + } + + #endregion -namespace TransactionProcessor.Client{ - using System; - using System.Collections.Generic; - using System.Net.Http; - using System.Net.Http.Headers; - using System.Text; - using System.Threading; - using System.Threading.Tasks; - using ClientProxyBase; - using DataTransferObjects; - using Newtonsoft.Json; - using Shared.Results; + public async Task> GetEstate(String accessToken, + Guid estateId, + CancellationToken cancellationToken) { + EstateResponse response = null; - public class TransactionProcessorClient : ClientProxyBase, ITransactionProcessorClient{ - #region Fields + String requestUri = this.BuildRequestUrl($"/api/estates/{estateId}"); - private readonly String BaseAddress; + try { + // Add the access token to the client headers + this.HttpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken); - #endregion + // Make the Http Call here + HttpResponseMessage httpResponse = await this.HttpClient.GetAsync(requestUri, cancellationToken); - #region Constructors + // Process the response + Result result = await this.HandleResponseX(httpResponse, cancellationToken); - public TransactionProcessorClient(Func baseAddressResolver, - HttpClient httpClient) : base(httpClient){ - this.BaseAddress = baseAddressResolver("TransactionProcessorApi"); + if (result.IsFailed) + return ResultHelpers.CreateFailure(result); - // Add the API version header - this.HttpClient.DefaultRequestHeaders.Add("api-version", "1.0"); + // call was successful so now deserialise the body to the response object + ResponseData responseData = this.HandleResponseContent(result.Data); + + return Result.Success(responseData.Data); } + catch (Exception ex) { + // An exception has occurred, add some additional information to the message + Exception exception = new($"Error getting estate Id {estateId}.", ex); - #endregion + throw exception; + } - public async Task CreateFloatForContractProduct(String accessToken, Guid estateId, CreateFloatForContractProductRequest createFloatForContractProductRequest, CancellationToken cancellationToken){ - String requestUri = $"{this.BaseAddress}/api/estates/{estateId}/floats"; + return response; + } + + public async Task CreateEstate(String accessToken, + CreateEstateRequest createEstateRequest, + CancellationToken cancellationToken) { + CreateEstateResponse response = null; - try - { - String requestSerialised = JsonConvert.SerializeObject(createFloatForContractProductRequest); + String requestUri = this.BuildRequestUrl("/api/estates/"); - StringContent httpContent = new StringContent(requestSerialised, Encoding.UTF8, "application/json"); + try { + String requestSerialised = JsonConvert.SerializeObject(createEstateRequest); - // Add the access token to the client headers - this.HttpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken); + StringContent httpContent = new(requestSerialised, Encoding.UTF8, "application/json"); - // Make the Http Call here - HttpResponseMessage httpResponse = await this.HttpClient.PostAsync(requestUri, httpContent, cancellationToken); + // Add the access token to the client headers + this.HttpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken); - // Process the response - Result result = await this.HandleResponseX(httpResponse, cancellationToken); + // Make the Http Call here + HttpResponseMessage httpResponse = await this.HttpClient.PostAsync(requestUri, httpContent, cancellationToken); - if (result.IsFailed) - return ResultHelpers.CreateFailure(result); + // Process the response + Result result = await this.HandleResponseX(httpResponse, cancellationToken); - return Result.Success(); - } - catch (Exception ex) - { - // An exception has occurred, add some additional information to the message - Exception exception = new Exception("Error creating contract product float.", ex); + if (result.IsFailed) + return ResultHelpers.CreateFailure(result); - throw exception; - } + return Result.Success(); } + catch (Exception ex) { + // An exception has occurred, add some additional information to the message + Exception exception = new($"Error creating new estate {createEstateRequest.EstateName}.", ex); - public async Task> GetMerchantBalance(String accessToken, - Guid estateId, - Guid merchantId, - CancellationToken cancellationToken, - Boolean liveBalance = true){ - String requestUri = $"{this.BaseAddress}/api/estates/{estateId}/merchants/{merchantId}/balance"; - - if (liveBalance){ - requestUri = $"{this.BaseAddress}/api/estates/{estateId}/merchants/{merchantId}/livebalance"; - } - - try - { - // Add the access token to the client headers - this.HttpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken); - - // Make the Http Call here - HttpResponseMessage httpResponse = await this.HttpClient.GetAsync(requestUri, cancellationToken); - - // Process the response - Result result = await this.HandleResponseX(httpResponse, cancellationToken); - - if (result.IsFailed) - return ResultHelpers.CreateFailure(result); - - ResponseData responseData = HandleResponseContent(result.Data); - - return Result.Success(responseData.Data); - } - catch (Exception ex) - { - // An exception has occurred, add some additional information to the message - Exception exception = new Exception("Error getting merchant balance.", ex); - - throw exception; - } - } - - public async Task>> GetMerchantBalanceHistory(String accessToken, - Guid estateId, - Guid merchantId, - DateTime startDate, - DateTime endDate, - CancellationToken cancellationToken){ - String requestUri = $"{this.BaseAddress}/api/estates/{estateId}/merchants/{merchantId}/balancehistory?startDate={startDate:yyyy-MM-dd}&endDate={endDate:yyyy-MM-dd}"; - - try - { - // Add the access token to the client headers - this.HttpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken); - - // Make the Http Call here - HttpResponseMessage httpResponse = await this.HttpClient.GetAsync(requestUri, cancellationToken); - - // Process the response - Result result = await this.HandleResponseX(httpResponse, cancellationToken); - - if (result.IsFailed) - return ResultHelpers.CreateFailure(result); - - ResponseData> responseData = HandleResponseContent>(result.Data); - - return Result.Success(responseData.Data); - } - catch (Exception ex) - { - // An exception has occurred, add some additional information to the message - Exception exception = new Exception("Error getting merchant balance history.", ex); - - throw exception; - } - } - - public async Task> GetSettlementByDate(String accessToken, - DateTime settlementDate, + throw exception; + } + } + + public async Task>> GetEstates(String accessToken, + Guid estateId, + CancellationToken cancellationToken) { + List response = null; + + String requestUri = this.BuildRequestUrl($"/api/estates/{estateId}/all"); + + try { + // Add the access token to the client headers + this.HttpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken); + + // Make the Http Call here + HttpResponseMessage httpResponse = await this.HttpClient.GetAsync(requestUri, cancellationToken); + + // Process the response + Result result = await this.HandleResponseX(httpResponse, cancellationToken); + + if (result.IsFailed) + return ResultHelpers.CreateFailure(result); + + ResponseData> responseData = this.HandleResponseContent>(result.Data); + + return Result.Success(responseData.Data); + } + catch (Exception ex) { + // An exception has occurred, add some additional information to the message + Exception exception = new($"Error getting all estates for estate Id {estateId}.", ex); + + throw exception; + } + + return response; + } + + public async Task CreateFloatForContractProduct(String accessToken, + Guid estateId, + CreateFloatForContractProductRequest createFloatForContractProductRequest, + CancellationToken cancellationToken) { + String requestUri = this.BuildRequestUrl($"/api/estates/{estateId}/floats"); + + try { + String requestSerialised = JsonConvert.SerializeObject(createFloatForContractProductRequest); + + StringContent httpContent = new(requestSerialised, Encoding.UTF8, "application/json"); + + // Add the access token to the client headers + this.HttpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken); + + // Make the Http Call here + HttpResponseMessage httpResponse = await this.HttpClient.PostAsync(requestUri, httpContent, cancellationToken); + + // Process the response + Result result = await this.HandleResponseX(httpResponse, cancellationToken); + + if (result.IsFailed) + return ResultHelpers.CreateFailure(result); + + return Result.Success(); + } + catch (Exception ex) { + // An exception has occurred, add some additional information to the message + Exception exception = new("Error creating contract product float.", ex); + + throw exception; + } + } + + public async Task> GetMerchantBalance(String accessToken, Guid estateId, Guid merchantId, - CancellationToken cancellationToken){ - String requestUri = $"{this.BaseAddress}/api/settlements/{settlementDate.Date:yyyy-MM-dd}/estates/{estateId}/merchants/{merchantId}/pending"; - try { - // Add the access token to the client headers - this.HttpClient.DefaultRequestHeaders.Authorization = - new AuthenticationHeaderValue("Bearer", accessToken); + CancellationToken cancellationToken, + Boolean liveBalance = true) { + String requestUri = this.BuildRequestUrl($"/api/estates/{estateId}/merchants/{merchantId}/balance"); + + if (liveBalance) requestUri = this.BuildRequestUrl($"/api/estates/{estateId}/merchants/{merchantId}/livebalance"); - // Make the Http Call here - HttpResponseMessage httpResponse = await this.HttpClient.GetAsync(requestUri, cancellationToken); + try { + // Add the access token to the client headers + this.HttpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken); - // Process the response - Result result = await this.HandleResponseX(httpResponse, cancellationToken); + // Make the Http Call here + HttpResponseMessage httpResponse = await this.HttpClient.GetAsync(requestUri, cancellationToken); - if (result.IsFailed) - return ResultHelpers.CreateFailure(result); + // Process the response + Result result = await this.HandleResponseX(httpResponse, cancellationToken); - ResponseData responseData = HandleResponseContent(result.Data); - - return Result.Success(responseData.Data); - } - catch (Exception ex) { - // An exception has occurred, add some additional information to the message - Exception exception = new Exception("Error getting settlement.", ex); + if (result.IsFailed) + return ResultHelpers.CreateFailure(result); - throw exception; - } + ResponseData responseData = this.HandleResponseContent(result.Data); + + return Result.Success(responseData.Data); } + catch (Exception ex) { + // An exception has occurred, add some additional information to the message + Exception exception = new("Error getting merchant balance.", ex); - public async Task> GetVoucherByCode(String accessToken, - Guid estateId, - String voucherCode, - CancellationToken cancellationToken){ - GetVoucherResponse response = null; + throw exception; + } + } + + public async Task>> GetMerchantBalanceHistory(String accessToken, + Guid estateId, + Guid merchantId, + DateTime startDate, + DateTime endDate, + CancellationToken cancellationToken) { + String requestUri = this.BuildRequestUrl($"/api/estates/{estateId}/merchants/{merchantId}/balancehistory?startDate={startDate:yyyy-MM-dd}&endDate={endDate:yyyy-MM-dd}"); + + try { + // Add the access token to the client headers + this.HttpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken); + + // Make the Http Call here + HttpResponseMessage httpResponse = await this.HttpClient.GetAsync(requestUri, cancellationToken); + + // Process the response + Result result = await this.HandleResponseX(httpResponse, cancellationToken); + + if (result.IsFailed) + return ResultHelpers.CreateFailure(result); + + ResponseData> responseData = this.HandleResponseContent>(result.Data); + + return Result.Success(responseData.Data); + } + catch (Exception ex) { + // An exception has occurred, add some additional information to the message + Exception exception = new("Error getting merchant balance history.", ex); + + throw exception; + } + } + + public async Task> GetSettlementByDate(String accessToken, + DateTime settlementDate, + Guid estateId, + Guid merchantId, + CancellationToken cancellationToken) { + String requestUri = this.BuildRequestUrl($"/api/settlements/{settlementDate.Date:yyyy-MM-dd}/estates/{estateId}/merchants/{merchantId}/pending"); + try { + // Add the access token to the client headers + this.HttpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken); + + // Make the Http Call here + HttpResponseMessage httpResponse = await this.HttpClient.GetAsync(requestUri, cancellationToken); + + // Process the response + Result result = await this.HandleResponseX(httpResponse, cancellationToken); + + if (result.IsFailed) + return ResultHelpers.CreateFailure(result); + + ResponseData responseData = this.HandleResponseContent(result.Data); + + return Result.Success(responseData.Data); + } + catch (Exception ex) { + // An exception has occurred, add some additional information to the message + Exception exception = new("Error getting settlement.", ex); + + throw exception; + } + } + + public async Task> GetVoucherByCode(String accessToken, + Guid estateId, + String voucherCode, + CancellationToken cancellationToken) { + GetVoucherResponse response = null; - String requestUri = $"{this.BaseAddress}/api/vouchers?estateId={estateId}&voucherCode={voucherCode}"; + String requestUri = this.BuildRequestUrl($"/api/vouchers?estateId={estateId}&voucherCode={voucherCode}"); - try - { - // Add the access token to the client headers - this.HttpClient.DefaultRequestHeaders.Authorization = - new AuthenticationHeaderValue("Bearer", accessToken); + try { + // Add the access token to the client headers + this.HttpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken); - // Make the Http Call here - HttpResponseMessage httpResponse = await this.HttpClient.GetAsync(requestUri, cancellationToken); + // Make the Http Call here + HttpResponseMessage httpResponse = await this.HttpClient.GetAsync(requestUri, cancellationToken); - // Process the response - Result result = await this.HandleResponseX(httpResponse, cancellationToken); + // Process the response + Result result = await this.HandleResponseX(httpResponse, cancellationToken); - if (result.IsFailed) - return ResultHelpers.CreateFailure(result); + if (result.IsFailed) + return ResultHelpers.CreateFailure(result); - ResponseData responseData = HandleResponseContent(result.Data); - - return Result.Success(responseData.Data); - } - catch (Exception ex) - { - // An exception has occurred, add some additional information to the message - Exception exception = new Exception("Error getting voucher by code.", ex); ; + ResponseData responseData = this.HandleResponseContent(result.Data); - throw exception; - } + return Result.Success(responseData.Data); } + catch (Exception ex) { + // An exception has occurred, add some additional information to the message + Exception exception = new("Error getting voucher by code.", ex); + ; - public async Task> GetVoucherByTransactionId(String accessToken, - Guid estateId, - Guid transactionId, - CancellationToken cancellationToken){ - GetVoucherResponse response = null; + throw exception; + } + } + + public async Task> GetVoucherByTransactionId(String accessToken, + Guid estateId, + Guid transactionId, + CancellationToken cancellationToken) { + GetVoucherResponse response = null; + + String requestUri = this.BuildRequestUrl($"/api/vouchers?estateId={estateId}&transactionId={transactionId}"); + + try { + // Add the access token to the client headers + this.HttpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken); + + // Make the Http Call here + HttpResponseMessage httpResponse = await this.HttpClient.GetAsync(requestUri, cancellationToken); + + // Process the response + Result result = await this.HandleResponseX(httpResponse, cancellationToken); + + if (result.IsFailed) + return ResultHelpers.CreateFailure(result); + + ResponseData responseData = this.HandleResponseContent(result.Data); + + return Result.Success(responseData.Data); + } + catch (Exception ex) { + // An exception has occurred, add some additional information to the message + Exception exception = new("Error getting voucher by transaction Id.", ex); + ; + + throw exception; + } + } + + public async Task> PerformTransaction(String accessToken, + SerialisedMessage transactionRequest, + CancellationToken cancellationToken) { + String requestUri = this.BuildRequestUrl($"/api/transactions"); + try { + String requestSerialised = JsonConvert.SerializeObject(transactionRequest); + + StringContent httpContent = new(requestSerialised, Encoding.UTF8, "application/json"); + + // Add the access token to the client headers + this.HttpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken); + + // Make the Http Call here + HttpResponseMessage httpResponse = await this.HttpClient.PostAsync(requestUri, httpContent, cancellationToken); + + // Process the response + Result result = await this.HandleResponseX(httpResponse, cancellationToken); + + if (result.IsFailed) + return ResultHelpers.CreateFailure(result); + + ResponseData responseData = this.HandleResponseContent(result.Data); + + return Result.Success(responseData.Data); + } + catch (Exception ex) { + // An exception has occurred, add some additional information to the message + Exception exception = new("Error posting transaction.", ex); + + throw exception; + } + } + + public async Task ProcessSettlement(String accessToken, + DateTime settlementDate, + Guid estateId, + Guid merchantId, + CancellationToken cancellationToken) { + String requestUri = this.BuildRequestUrl($"/api/settlements/{settlementDate.Date:yyyy-MM-dd}/estates/{estateId}/merchants/{merchantId}"); + + try { + StringContent httpContent = new(String.Empty, Encoding.UTF8, "application/json"); + + // Add the access token to the client headers + this.HttpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken); + + // Make the Http Call here + HttpResponseMessage httpResponse = await this.HttpClient.PostAsync(requestUri, httpContent, cancellationToken); + + // Process the response + Result result = await this.HandleResponseX(httpResponse, cancellationToken); + + if (result.IsFailed) + return ResultHelpers.CreateFailure(result); - String requestUri = $"{this.BaseAddress}/api/vouchers?estateId={estateId}&transactionId={transactionId}"; + return Result.Success(); + } + catch (Exception ex) { + // An exception has occurred, add some additional information to the message + Exception exception = new("Error processing settlement.", ex); + + throw exception; + } + } + + private String BuildRequestUrl(String route) { + String baseAddress = this.BaseAddressResolver("TransactionProcessorApi"); + + return $"{baseAddress}{route}"; + } + + public async Task RecordFloatCreditPurchase(String accessToken, + Guid estateId, + RecordFloatCreditPurchaseRequest recordFloatCreditPurchaseRequest, + CancellationToken cancellationToken) { + String requestUri = this.BuildRequestUrl($"/api/estates/{estateId}/floats"); + + try { + String requestSerialised = JsonConvert.SerializeObject(recordFloatCreditPurchaseRequest); + + StringContent httpContent = new(requestSerialised, Encoding.UTF8, "application/json"); + + // Add the access token to the client headers + this.HttpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken); + + // Make the Http Call here + HttpResponseMessage httpResponse = await this.HttpClient.PutAsync(requestUri, httpContent, cancellationToken); + + // Process the response + Result result = await this.HandleResponseX(httpResponse, cancellationToken); + + if (result.IsFailed) + return ResultHelpers.CreateFailure(result); + + return Result.Success(); + } + catch (Exception ex) { + // An exception has occurred, add some additional information to the message + Exception exception = new("Error crediting contract product float.", ex); - try - { - // Add the access token to the client headers - this.HttpClient.DefaultRequestHeaders.Authorization = - new AuthenticationHeaderValue("Bearer", accessToken); + throw exception; + } + } + + public async Task> RedeemVoucher(String accessToken, + RedeemVoucherRequest redeemVoucherRequest, + CancellationToken cancellationToken) { + RedeemVoucherResponse response = null; + + String requestUri = this.BuildRequestUrl($"/api/vouchers"); - // Make the Http Call here - HttpResponseMessage httpResponse = await this.HttpClient.GetAsync(requestUri, cancellationToken); + try { + String requestSerialised = JsonConvert.SerializeObject(redeemVoucherRequest); - // Process the response - Result result = await this.HandleResponseX(httpResponse, cancellationToken); + StringContent httpContent = new(requestSerialised, Encoding.UTF8, "application/json"); - if (result.IsFailed) - return ResultHelpers.CreateFailure(result); + // Add the access token to the client headers + this.HttpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken); - ResponseData responseData = HandleResponseContent(result.Data); + // Make the Http Call here + HttpResponseMessage httpResponse = await this.HttpClient.PutAsync(requestUri, httpContent, cancellationToken); - return Result.Success(responseData.Data); - } - catch (Exception ex) - { - // An exception has occurred, add some additional information to the message - Exception exception = new Exception("Error getting voucher by transaction Id.", ex); ; + // Process the response + Result result = await this.HandleResponseX(httpResponse, cancellationToken); - throw exception; - } + if (result.IsFailed) + return ResultHelpers.CreateFailure(result); + + ResponseData responseData = this.HandleResponseContent(result.Data); + + return Result.Success(responseData.Data); } + catch (Exception ex) { + // An exception has occurred, add some additional information to the message + Exception exception = new("Error redeeming voucher.", ex); - public async Task> PerformTransaction(String accessToken, - SerialisedMessage transactionRequest, - CancellationToken cancellationToken){ - String requestUri = $"{this.BaseAddress}/api/transactions"; - try - { - String requestSerialised = JsonConvert.SerializeObject(transactionRequest); + throw exception; + } + } - StringContent httpContent = new StringContent(requestSerialised, Encoding.UTF8, "application/json"); + public async Task ResendEmailReceipt(String accessToken, + Guid estateId, + Guid transactionId, + CancellationToken cancellationToken) { + String requestUri = this.BuildRequestUrl($"/api/{estateId}/transactions/{transactionId}/resendreceipt"); - // Add the access token to the client headers - this.HttpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken); + try { + StringContent httpContent = new(String.Empty, Encoding.UTF8, "application/json"); - // Make the Http Call here - HttpResponseMessage httpResponse = await this.HttpClient.PostAsync(requestUri, httpContent, cancellationToken); + // Add the access token to the client headers + this.HttpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken); - // Process the response - Result result = await this.HandleResponseX(httpResponse, cancellationToken); + // Make the Http Call here + HttpResponseMessage httpResponse = await this.HttpClient.PostAsync(requestUri, httpContent, cancellationToken); - if (result.IsFailed) - return ResultHelpers.CreateFailure(result); + // Process the response + Result result = await this.HandleResponseX(httpResponse, cancellationToken); - ResponseData responseData = HandleResponseContent(result.Data); + if (result.IsFailed) + return ResultHelpers.CreateFailure(result); - return Result.Success(responseData.Data); - } - catch (Exception ex) - { - // An exception has occurred, add some additional information to the message - Exception exception = new Exception("Error posting transaction.", ex); + return Result.Success(); + } + catch (Exception ex) { + // An exception has occurred, add some additional information to the message + Exception exception = new("Error requesting receipt resend.", ex); - throw exception; - } + throw exception; } + } - public async Task ProcessSettlement(String accessToken, - DateTime settlementDate, + public async Task AddContractToMerchant(String accessToken, Guid estateId, Guid merchantId, - CancellationToken cancellationToken){ - String requestUri = $"{this.BaseAddress}/api/settlements/{settlementDate.Date:yyyy-MM-dd}/estates/{estateId}/merchants/{merchantId}"; + AddMerchantContractRequest addMerchantContractRequest, + CancellationToken cancellationToken) { + String requestUri = this.BuildRequestUrl($"/api/estates/{estateId}/merchants/{merchantId}/contracts"); + + try { + String requestSerialised = JsonConvert.SerializeObject(addMerchantContractRequest); + + StringContent httpContent = new(requestSerialised, Encoding.UTF8, "application/json"); + + // Add the access token to the client headers + this.HttpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken); + + // Make the Http Call here + HttpResponseMessage httpResponse = await this.HttpClient.PatchAsync(requestUri, httpContent, cancellationToken); + + // Process the response + Result result = await this.HandleResponseX(httpResponse, cancellationToken); + + if (result.IsFailed) + return ResultHelpers.CreateFailure(result); - try - { - StringContent httpContent = new StringContent(String.Empty, Encoding.UTF8, "application/json"); + return Result.Success(); + } + catch (Exception ex) { + // An exception has occurred, add some additional information to the message + Exception exception = new($"Error adding contract {addMerchantContractRequest.ContractId} to merchant Id {merchantId} in estate {estateId}.", ex); + + throw exception; + } + } - // Add the access token to the client headers - this.HttpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken); + public async Task AddDeviceToMerchant(String accessToken, + Guid estateId, + Guid merchantId, + AddMerchantDeviceRequest addMerchantDeviceRequest, + CancellationToken cancellationToken) { + String requestUri = this.BuildRequestUrl($"/api/estates/{estateId}/merchants/{merchantId}/devices"); - // Make the Http Call here - HttpResponseMessage httpResponse = await this.HttpClient.PostAsync(requestUri, httpContent, cancellationToken); + try { + String requestSerialised = JsonConvert.SerializeObject(addMerchantDeviceRequest); - // Process the response - Result result = await this.HandleResponseX(httpResponse, cancellationToken); + StringContent httpContent = new(requestSerialised, Encoding.UTF8, "application/json"); - if (result.IsFailed) - return ResultHelpers.CreateFailure(result); + // Add the access token to the client headers + this.HttpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken); - return Result.Success(); - } - catch(Exception ex){ - // An exception has occurred, add some additional information to the message - Exception exception = new Exception("Error processing settlement.", ex); + // Make the Http Call here + HttpResponseMessage httpResponse = await this.HttpClient.PatchAsync(requestUri, httpContent, cancellationToken); + + // Process the response + Result result = await this.HandleResponseX(httpResponse, cancellationToken); + + if (result.IsFailed) + return ResultHelpers.CreateFailure(result); + + return Result.Success(); + } + catch (Exception ex) { + // An exception has occurred, add some additional information to the message + Exception exception = new($"Error adding device to merchant Id {merchantId} in estate {estateId}.", ex); - throw exception; - } + throw exception; } + } + + public async Task AddMerchantAddress(String accessToken, + Guid estateId, + Guid merchantId, + Address newAddressRequest, + CancellationToken cancellationToken) { + String requestUri = this.BuildRequestUrl($"/api/estates/{estateId}/merchants/{merchantId}/addresses"); - public async Task RecordFloatCreditPurchase(String accessToken, Guid estateId, RecordFloatCreditPurchaseRequest recordFloatCreditPurchaseRequest, CancellationToken cancellationToken){ - String requestUri = $"{this.BaseAddress}/api/estates/{estateId}/floats"; + try { + String requestSerialised = JsonConvert.SerializeObject(newAddressRequest); - try - { - String requestSerialised = JsonConvert.SerializeObject(recordFloatCreditPurchaseRequest); + StringContent httpContent = new(requestSerialised, Encoding.UTF8, "application/json"); - StringContent httpContent = new StringContent(requestSerialised, Encoding.UTF8, "application/json"); - - // Add the access token to the client headers - this.HttpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken); + // Add the access token to the client headers + this.HttpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken); - // Make the Http Call here - HttpResponseMessage httpResponse = await this.HttpClient.PutAsync(requestUri, httpContent, cancellationToken); + // Make the Http Call here + HttpResponseMessage httpResponse = await this.HttpClient.PatchAsync(requestUri, httpContent, cancellationToken); - // Process the response - Result result = await this.HandleResponseX(httpResponse, cancellationToken); + // Process the response + Result result = await this.HandleResponseX(httpResponse, cancellationToken); - if (result.IsFailed) - return ResultHelpers.CreateFailure(result); + if (result.IsFailed) + return ResultHelpers.CreateFailure(result); - return Result.Success(); - } - catch (Exception ex) - { - // An exception has occurred, add some additional information to the message - Exception exception = new Exception("Error crediting contract product float.", ex); + return Result.Success(); + } + catch (Exception ex) { + // An exception has occurred, add some additional information to the message + Exception exception = new($"Error adding address for merchant {merchantId} for estate {estateId}.", ex); - throw exception; - } + throw exception; } + } + + public async Task AddMerchantContact(String accessToken, + Guid estateId, + Guid merchantId, + Contact newContactRequest, + CancellationToken cancellationToken) { + String requestUri = this.BuildRequestUrl($"/api/estates/{estateId}/merchants/{merchantId}/contacts"); + + try { + String requestSerialised = JsonConvert.SerializeObject(newContactRequest); + + StringContent httpContent = new(requestSerialised, Encoding.UTF8, "application/json"); + + // Add the access token to the client headers + this.HttpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken); - public async Task> RedeemVoucher(String accessToken, - RedeemVoucherRequest redeemVoucherRequest, - CancellationToken cancellationToken){ - RedeemVoucherResponse response = null; + // Make the Http Call here + HttpResponseMessage httpResponse = await this.HttpClient.PatchAsync(requestUri, httpContent, cancellationToken); - String requestUri = $"{this.BaseAddress}/api/vouchers"; + // Process the response + Result result = await this.HandleResponseX(httpResponse, cancellationToken); - try - { - String requestSerialised = JsonConvert.SerializeObject(redeemVoucherRequest); + if (result.IsFailed) + return ResultHelpers.CreateFailure(result); - StringContent httpContent = new StringContent(requestSerialised, Encoding.UTF8, "application/json"); + return Result.Success(); + } + catch (Exception ex) { + // An exception has occurred, add some additional information to the message + Exception exception = new($"Error adding contact for merchant {merchantId} for estate {estateId}.", ex); + + throw exception; + } + } - // Add the access token to the client headers - this.HttpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken); + public async Task AddProductToContract(String accessToken, + Guid estateId, + Guid contractId, + AddProductToContractRequest addProductToContractRequest, + CancellationToken cancellationToken) { + String requestUri = this.BuildRequestUrl($"/api/estates/{estateId}/contracts/{contractId}/products"); - // Make the Http Call here - HttpResponseMessage httpResponse = await this.HttpClient.PutAsync(requestUri, httpContent, cancellationToken); + try { + String requestSerialised = JsonConvert.SerializeObject(addProductToContractRequest); - // Process the response - Result result = await this.HandleResponseX(httpResponse, cancellationToken); + StringContent httpContent = new(requestSerialised, Encoding.UTF8, "application/json"); - if (result.IsFailed) - return ResultHelpers.CreateFailure(result); + // Add the access token to the client headers + this.HttpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken); - ResponseData responseData = HandleResponseContent(result.Data); + // Make the Http Call here + HttpResponseMessage httpResponse = await this.HttpClient.PatchAsync(requestUri, httpContent, cancellationToken); - return Result.Success(responseData.Data); - } - catch (Exception ex) - { - // An exception has occurred, add some additional information to the message - Exception exception = new Exception("Error redeeming voucher.", ex); + // Process the response + Result result = await this.HandleResponseX(httpResponse, cancellationToken); - throw exception; - } + if (result.IsFailed) + return ResultHelpers.CreateFailure(result); + + return Result.Success(); } + catch (Exception ex) { + // An exception has occurred, add some additional information to the message + Exception exception = new($"Error adding product [{addProductToContractRequest.ProductName}] to contract [{contractId}] for estate {estateId}.", ex); - public async Task ResendEmailReceipt(String accessToken, - Guid estateId, - Guid transactionId, - CancellationToken cancellationToken){ - String requestUri = $"{this.BaseAddress}/api/{estateId}/transactions/{transactionId}/resendreceipt"; + throw exception; + } + } + + public async Task AddTransactionFeeForProductToContract(String accessToken, + Guid estateId, + Guid contractId, + Guid productId, + AddTransactionFeeForProductToContractRequest addTransactionFeeForProductToContractRequest, + CancellationToken cancellationToken) { + String requestUri = this.BuildRequestUrl($"/api/estates/{estateId}/contracts/{contractId}/products/{productId}/transactionFees"); + + try { + String requestSerialised = JsonConvert.SerializeObject(addTransactionFeeForProductToContractRequest); + + StringContent httpContent = new(requestSerialised, Encoding.UTF8, "application/json"); + + // Add the access token to the client headers + this.HttpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken); + + // Make the Http Call here + HttpResponseMessage httpResponse = await this.HttpClient.PatchAsync(requestUri, httpContent, cancellationToken); + + // Process the response + Result result = await this.HandleResponseX(httpResponse, cancellationToken); + + if (result.IsFailed) + return ResultHelpers.CreateFailure(result); + + return Result.Success(); + } + catch (Exception ex) { + // An exception has occurred, add some additional information to the message + Exception exception = new($"Error adding transaction fee [{addTransactionFeeForProductToContractRequest.Description}] for product [{productId}] to contract [{contractId}] for estate {estateId}.", ex); + + throw exception; + } + } + + public async Task AssignOperatorToMerchant(String accessToken, + Guid estateId, + Guid merchantId, + AssignOperatorRequest assignOperatorRequest, + CancellationToken cancellationToken) { + String requestUri = this.BuildRequestUrl($"/api/estates/{estateId}/merchants/{merchantId}/operators"); + + try { + String requestSerialised = JsonConvert.SerializeObject(assignOperatorRequest); + + StringContent httpContent = new(requestSerialised, Encoding.UTF8, "application/json"); + + // Add the access token to the client headers + this.HttpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken); + + // Make the Http Call here + HttpResponseMessage httpResponse = await this.HttpClient.PatchAsync(requestUri, httpContent, cancellationToken); + + // Process the response + Result result = await this.HandleResponseX(httpResponse, cancellationToken); + + if (result.IsFailed) + return ResultHelpers.CreateFailure(result); + + return Result.Success(); + } + catch (Exception ex) { + // An exception has occurred, add some additional information to the message + Exception exception = new($"Error assigning operator Id {assignOperatorRequest.OperatorId} to merchant Id {merchantId} for estate {estateId}.", ex); + + throw exception; + } + } + + public async Task RemoveOperatorFromMerchant(String accessToken, + Guid estateId, + Guid merchantId, + Guid operatorId, + CancellationToken cancellationToken) { + String requestUri = this.BuildRequestUrl($"/api/estates/{estateId}/merchants/{merchantId}/operators/{operatorId}"); + + try { + // Add the access token to the client headers + this.HttpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken); + + // Make the Http Call here + HttpResponseMessage httpResponse = await this.HttpClient.DeleteAsync(requestUri, cancellationToken); + + // Process the response + Result result = await this.HandleResponseX(httpResponse, cancellationToken); + + if (result.IsFailed) + return ResultHelpers.CreateFailure(result); + + return Result.Success(); + } + catch (Exception ex) { + // An exception has occurred, add some additional information to the message + Exception exception = new($"Error removing operator Id {operatorId} from merchant Id {merchantId} for estate {estateId}.", ex); + + throw exception; + } + } + + public async Task RemoveOperatorFromEstate(String accessToken, + Guid estateId, + Guid operatorId, + CancellationToken cancellationToken) { + String requestUri = this.BuildRequestUrl($"/api/estates/{estateId}/operators/{operatorId}"); + + try { + // Add the access token to the client headers + this.HttpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken); + + // Make the Http Call here + HttpResponseMessage httpResponse = await this.HttpClient.DeleteAsync(requestUri, cancellationToken); + + // Process the response + Result result = await this.HandleResponseX(httpResponse, cancellationToken); + + if (result.IsFailed) + return ResultHelpers.CreateFailure(result); + + return Result.Success(); + } + catch (Exception ex) { + // An exception has occurred, add some additional information to the message + Exception exception = new($"Error removing operator Id {operatorId} from estate {estateId}.", ex); + + throw exception; + } + } + + public async Task RemoveContractFromMerchant(String accessToken, + Guid estateId, + Guid merchantId, + Guid contractId, + CancellationToken cancellationToken) { + String requestUri = this.BuildRequestUrl($"/api/estates/{estateId}/merchants/{merchantId}/contracts/{contractId}"); + + try { + // Add the access token to the client headers + this.HttpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken); + + // Make the Http Call here + HttpResponseMessage httpResponse = await this.HttpClient.DeleteAsync(requestUri, cancellationToken); + + // Process the response + Result result = await this.HandleResponseX(httpResponse, cancellationToken); + + if (result.IsFailed) + return ResultHelpers.CreateFailure(result); + + return Result.Success(); + } + catch (Exception ex) { + // An exception has occurred, add some additional information to the message + Exception exception = new($"Error removing contract Id {contractId} from merchant Id {merchantId} for estate {estateId}.", ex); + + throw exception; + } + } + + public async Task CreateContract(String accessToken, + Guid estateId, + CreateContractRequest createContractRequest, + CancellationToken cancellationToken) { + CreateContractResponse response = null; + + String requestUri = this.BuildRequestUrl($"/api/estates/{estateId}/contracts/"); + + try { + String requestSerialised = JsonConvert.SerializeObject(createContractRequest); + + StringContent httpContent = new(requestSerialised, Encoding.UTF8, "application/json"); + + // Add the access token to the client headers + this.HttpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken); + + // Make the Http Call here + HttpResponseMessage httpResponse = await this.HttpClient.PostAsync(requestUri, httpContent, cancellationToken); + + // Process the response + Result result = await this.HandleResponseX(httpResponse, cancellationToken); + + if (result.IsFailed) + return ResultHelpers.CreateFailure(result); + + return Result.Success(); + } + catch (Exception ex) { + // An exception has occurred, add some additional information to the message + Exception exception = new($"Error creating contract [{createContractRequest.Description}] for estate {estateId}.", ex); + + throw exception; + } + } + + public async Task CreateOperator(String accessToken, + Guid estateId, + CreateOperatorRequest createOperatorRequest, + CancellationToken cancellationToken) { + CreateOperatorResponse response = null; + + String requestUri = this.BuildRequestUrl($"/api/estates/{estateId}/operators"); + + try { + String requestSerialised = JsonConvert.SerializeObject(createOperatorRequest); + + StringContent httpContent = new(requestSerialised, Encoding.UTF8, "application/json"); + + // Add the access token to the client headers + this.HttpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken); - try { - StringContent httpContent = new StringContent(String.Empty, Encoding.UTF8, "application/json"); + // Make the Http Call here + HttpResponseMessage httpResponse = await this.HttpClient.PostAsync(requestUri, httpContent, cancellationToken); - // Add the access token to the client headers - this.HttpClient.DefaultRequestHeaders.Authorization = - new AuthenticationHeaderValue("Bearer", accessToken); + // Process the response + Result result = await this.HandleResponseX(httpResponse, cancellationToken); - // Make the Http Call here - HttpResponseMessage httpResponse = - await this.HttpClient.PostAsync(requestUri, httpContent, cancellationToken); + if (result.IsFailed) + return ResultHelpers.CreateFailure(result); - // Process the response - Result result = await this.HandleResponseX(httpResponse, cancellationToken); + return Result.Success(); + } + catch (Exception ex) { + // An exception has occurred, add some additional information to the message + Exception exception = new($"Error creating new operator {createOperatorRequest.Name}.", ex); + + throw exception; + } + } + + public async Task CreateEstateUser(String accessToken, + Guid estateId, + CreateEstateUserRequest createEstateUserRequest, + CancellationToken cancellationToken) { + String requestUri = this.BuildRequestUrl($"/api/estates/{estateId}/users"); + + try { + String requestSerialised = JsonConvert.SerializeObject(createEstateUserRequest); + + StringContent httpContent = new(requestSerialised, Encoding.UTF8, "application/json"); + + // Add the access token to the client headers + this.HttpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken); + + // Make the Http Call here + HttpResponseMessage httpResponse = await this.HttpClient.PatchAsync(requestUri, httpContent, cancellationToken); + + // Process the response + Result result = await this.HandleResponseX(httpResponse, cancellationToken); + + if (result.IsFailed) + return ResultHelpers.CreateFailure(result); + + return Result.Success(); + ; + } + catch (Exception ex) { + // An exception has occurred, add some additional information to the message + Exception exception = new($"Error creating new estate user Estate Id {estateId} Email Address {createEstateUserRequest.EmailAddress}.", ex); + + throw exception; + } + } - if (result.IsFailed) - return ResultHelpers.CreateFailure(result); + public async Task CreateMerchant(String accessToken, + Guid estateId, + CreateMerchantRequest createMerchantRequest, + CancellationToken cancellationToken) { + CreateMerchantResponse response = null; - return Result.Success(); - } - catch (Exception ex) { - // An exception has occurred, add some additional information to the message - Exception exception = new Exception("Error requesting receipt resend.", ex); + String requestUri = this.BuildRequestUrl($"/api/estates/{estateId}/merchants"); - throw exception; - } + try { + String requestSerialised = JsonConvert.SerializeObject(createMerchantRequest); + + StringContent httpContent = new(requestSerialised, Encoding.UTF8, "application/json"); + + // Add the access token to the client headers + this.HttpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken); + + // Make the Http Call here + HttpResponseMessage httpResponse = await this.HttpClient.PostAsync(requestUri, httpContent, cancellationToken); + + // Process the response + Result result = await this.HandleResponseX(httpResponse, cancellationToken); + + if (result.IsFailed) + return ResultHelpers.CreateFailure(result); + + return Result.Success(); + } + catch (Exception ex) { + // An exception has occurred, add some additional information to the message + Exception exception = new($"Error creating new merchant {createMerchantRequest.Name} for estate {estateId}.", ex); + + throw exception; } } + + public async Task CreateMerchantUser(String accessToken, + Guid estateId, + Guid merchantId, + CreateMerchantUserRequest createMerchantUserRequest, + CancellationToken cancellationToken) { + String requestUri = this.BuildRequestUrl($"/api/estates/{estateId}/merchants/{merchantId}/users"); + + try { + String requestSerialised = JsonConvert.SerializeObject(createMerchantUserRequest); + + StringContent httpContent = new(requestSerialised, Encoding.UTF8, "application/json"); + + // Add the access token to the client headers + this.HttpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken); + + // Make the Http Call here + HttpResponseMessage httpResponse = await this.HttpClient.PatchAsync(requestUri, httpContent, cancellationToken); + + // Process the response + Result result = await this.HandleResponseX(httpResponse, cancellationToken); + + if (result.IsFailed) + return ResultHelpers.CreateFailure(result); + + return Result.Success(); + } + catch (Exception ex) { + // An exception has occurred, add some additional information to the message + Exception exception = new($"Error creating new merchant user Merchant Id {estateId} Email Address {createMerchantUserRequest.EmailAddress}.", ex); + + throw exception; + } + } + + public async Task AssignOperatorToEstate(String accessToken, + Guid estateId, + DataTransferObjects.Requests.Estate.AssignOperatorRequest assignOperatorRequest, + CancellationToken cancellationToken) { + String requestUri = this.BuildRequestUrl($"/api/estates/{estateId}/operators"); + + try { + String requestSerialised = JsonConvert.SerializeObject(assignOperatorRequest); + + StringContent httpContent = new(requestSerialised, Encoding.UTF8, "application/json"); + + // Add the access token to the client headers + this.HttpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken); + + // Make the Http Call here + HttpResponseMessage httpResponse = await this.HttpClient.PatchAsync(requestUri, httpContent, cancellationToken); + + // Process the response + Result result = await this.HandleResponseX(httpResponse, cancellationToken); + + if (result.IsFailed) + return ResultHelpers.CreateFailure(result); + + return Result.Success(); + } + catch (Exception ex) { + // An exception has occurred, add some additional information to the message + Exception exception = new($"Error adding new operator {assignOperatorRequest.OperatorId} to estate {estateId}.", ex); + + throw exception; + } + } + + public async Task DisableTransactionFeeForProduct(String accessToken, + Guid estateId, + Guid contractId, + Guid productId, + Guid transactionFeeId, + CancellationToken cancellationToken) { + String requestUri = this.BuildRequestUrl($"/api/estates/{estateId}/contracts/{contractId}/products/{productId}/transactionFees/{transactionFeeId}"); + + try { + // Add the access token to the client headers + this.HttpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken); + + // Make the Http Call here + HttpResponseMessage httpResponse = await this.HttpClient.DeleteAsync(requestUri, cancellationToken); + + // Process the response + Result result = await this.HandleResponseX(httpResponse, cancellationToken); + + if (result.IsFailed) + return ResultHelpers.CreateFailure(result); + + return Result.Success(); + } + catch (Exception ex) { + // An exception has occurred, add some additional information to the message + Exception exception = new($"Error disabling transaction fee Id [{transactionFeeId}] for product [{productId}] on contract [{contractId}] for estate {estateId}.", ex); + + throw exception; + } + } + + public async Task> GetContract(String accessToken, + Guid estateId, + Guid contractId, + CancellationToken cancellationToken) { + ContractResponse response = null; + + String requestUri = this.BuildRequestUrl($"/api/estates/{estateId}/contracts/{contractId}"); + + try { + // Add the access token to the client headers + this.HttpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken); + + // Make the Http Call here + HttpResponseMessage httpResponse = await this.HttpClient.GetAsync(requestUri, cancellationToken); + + // Process the response + Result result = await this.HandleResponseX(httpResponse, cancellationToken); + + if (result.IsFailed) + return ResultHelpers.CreateFailure(result); + + // call was successful so now deserialise the body to the response object + ResponseData responseData = this.HandleResponseContent(result.Data); + + return Result.Success(responseData.Data); + } + catch (Exception ex) { + // An exception has occurred, add some additional information to the message + Exception exception = new($"Error getting contract {contractId} for estate {estateId}.", ex); + + throw exception; + } + + return response; + } + + public async Task>> GetContracts(String accessToken, + Guid estateId, + CancellationToken cancellationToken) { + List response = null; + + String requestUri = this.BuildRequestUrl($"/api/estates/{estateId}/contracts"); + + try { + // Add the access token to the client headers + this.HttpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken); + + // Make the Http Call here + HttpResponseMessage httpResponse = await this.HttpClient.GetAsync(requestUri, cancellationToken); + + // Process the response + Result result = await this.HandleResponseX(httpResponse, cancellationToken); + + if (result.IsFailed) + return ResultHelpers.CreateFailure(result); + + ResponseData> responseData = this.HandleResponseContent>(result.Data); + + return Result.Success(responseData.Data); + } + catch (Exception ex) { + // An exception has occurred, add some additional information to the message + Exception exception = new($"Error getting contracts for estate {estateId}.", ex); + + throw exception; + } + + return response; + } + + public async Task> GetMerchant(String accessToken, + Guid estateId, + Guid merchantId, + CancellationToken cancellationToken) { + MerchantResponse response = null; + + String requestUri = this.BuildRequestUrl($"/api/estates/{estateId}/merchants/{merchantId}"); + + try { + // Add the access token to the client headers + this.HttpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken); + + // Make the Http Call here + HttpResponseMessage httpResponse = await this.HttpClient.GetAsync(requestUri, cancellationToken); + + // Process the response + Result result = await this.HandleResponseX(httpResponse, cancellationToken); + + if (result.IsFailed) + return ResultHelpers.CreateFailure(result); + + ResponseData responseData = this.HandleResponseContent(result.Data); + + return Result.Success(responseData.Data); + } + catch (Exception ex) { + // An exception has occurred, add some additional information to the message + Exception exception = new($"Error getting merchant Id {merchantId} in estate {estateId}.", ex); + + throw exception; + } + + return response; + } + + public async Task>> GetMerchantContracts(String accessToken, + Guid estateId, + Guid merchantId, + CancellationToken cancellationToken) { + List response = null; + + String requestUri = this.BuildRequestUrl($"/api/estates/{estateId}/merchants/{merchantId}/contracts"); + + try { + // Add the access token to the client headers + this.HttpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken); + + // Make the Http Call here + HttpResponseMessage httpResponse = await this.HttpClient.GetAsync(requestUri, cancellationToken); + + // Process the response + Result result = await this.HandleResponseX(httpResponse, cancellationToken); + + if (result.IsFailed) + return ResultHelpers.CreateFailure(result); + + ResponseData> responseData = this.HandleResponseContent>(result.Data); + + return Result.Success(responseData.Data); + } + catch (Exception ex) { + // An exception has occurred, add some additional information to the message + Exception exception = new($"Error getting merchant contracts for merchant Id {merchantId} in estate {estateId}.", ex); + + throw exception; + } + + return response; + } + + public async Task>> GetMerchants(String accessToken, + Guid estateId, + CancellationToken cancellationToken) { + List response = null; + + String requestUri = this.BuildRequestUrl($"/api/estates/{estateId}/merchants"); + + try { + // Add the access token to the client headers + this.HttpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken); + + // Make the Http Call here + HttpResponseMessage httpResponse = await this.HttpClient.GetAsync(requestUri, cancellationToken); + + // Process the response + Result result = await this.HandleResponseX(httpResponse, cancellationToken); + + if (result.IsFailed) + return ResultHelpers.CreateFailure(result); + + ResponseData> responseData = this.HandleResponseContent>(result.Data); + + return Result.Success(responseData.Data); + } + catch (Exception ex) { + // An exception has occurred, add some additional information to the message + Exception exception = new($"Error getting merchant list for estate {estateId}.", ex); + + throw exception; + } + + return response; + } + + public async Task> GetSettlement(String accessToken, + Guid estateId, + Guid? merchantId, + Guid settlementId, + CancellationToken cancellationToken) { + SettlementResponse response = null; + + String requestUri = this.BuildRequestUrl($"/api/estates/{estateId}/settlements/{settlementId}?merchantId={merchantId}"); + + try { + // Add the access token to the client headers + this.HttpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken); + + // Make the Http Call here + HttpResponseMessage httpResponse = await this.HttpClient.GetAsync(requestUri, cancellationToken); + + // Process the response + Result result = await this.HandleResponseX(httpResponse, cancellationToken); + + if (result.IsFailed) + return ResultHelpers.CreateFailure(result); + + ResponseData responseData = this.HandleResponseContent(result.Data); + + return Result.Success(responseData.Data); + } + catch (Exception ex) { + // An exception has occurred, add some additional information to the message + Exception exception = new($"Error getting settlement id {settlementId} for estate [{estateId}]"); + + throw exception; + } + + return response; + } + + public async Task>> GetSettlements(String accessToken, + Guid estateId, + Guid? merchantId, + String startDate, + String endDate, + CancellationToken cancellationToken) { + List response = null; + + String requestUri = this.BuildRequestUrl($"/api/estates/{estateId}/settlements/?merchantId={merchantId}&start_date={startDate}&end_date={endDate}"); + + try { + // Add the access token to the client headers + this.HttpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken); + + // Make the Http Call here + HttpResponseMessage httpResponse = await this.HttpClient.GetAsync(requestUri, cancellationToken); + + // Process the response + Result result = await this.HandleResponseX(httpResponse, cancellationToken); + + if (result.IsFailed) + return ResultHelpers.CreateFailure(result); + + ResponseData> responseData = this.HandleResponseContent>(result.Data); + + return Result.Success(responseData.Data); + } + catch (Exception ex) { + // An exception has occurred, add some additional information to the message + Exception exception = new($"Error getting settlements for estate [{estateId}]"); + + throw exception; + } + + return response; + } + + public async Task>> GetTransactionFeesForProduct(String accessToken, + Guid estateId, + Guid merchantId, + Guid contractId, + Guid productId, + CancellationToken cancellationToken) { + List response = null; + + String requestUri = this.BuildRequestUrl($"/api/estates/{estateId}/merchants/{merchantId}/contracts/{contractId}/products/{productId}/transactionFees"); + + try { + // Add the access token to the client headers + this.HttpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken); + + // Make the Http Call here + HttpResponseMessage httpResponse = await this.HttpClient.GetAsync(requestUri, cancellationToken); + + // Process the response + Result result = await this.HandleResponseX(httpResponse, cancellationToken); + + if (result.IsFailed) + return ResultHelpers.CreateFailure(result); + + // call was successful so now deserialise the body to the response object + ResponseData> responseData = this.HandleResponseContent>(result.Data); + + return Result.Success(responseData.Data); + } + catch (Exception ex) { + // An exception has occurred, add some additional information to the message + Exception exception = new($"Error transaction fees for product {productId} on contract {contractId} for merchant Id {merchantId} in estate {estateId}.", ex); + + throw exception; + } + + return response; + } + + public async Task MakeMerchantDeposit(String accessToken, + Guid estateId, + Guid merchantId, + MakeMerchantDepositRequest makeMerchantDepositRequest, + CancellationToken cancellationToken) { + String requestUri = this.BuildRequestUrl($"/api/estates/{estateId}/merchants/{merchantId}/deposits"); + + try { + String requestSerialised = JsonConvert.SerializeObject(makeMerchantDepositRequest); + + StringContent httpContent = new(requestSerialised, Encoding.UTF8, "application/json"); + + // Add the access token to the client headers + this.HttpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken); + + // Make the Http Call here + HttpResponseMessage httpResponse = await this.HttpClient.PostAsync(requestUri, httpContent, cancellationToken); + + // Process the response + Result result = await this.HandleResponseX(httpResponse, cancellationToken); + + if (result.IsFailed) + return ResultHelpers.CreateFailure(result); + + return Result.Success(); + } + catch (Exception ex) { + // An exception has occurred, add some additional information to the message + Exception exception = new($"Error making merchant deposit for merchant {merchantId} for estate {estateId}.", ex); + + throw exception; + } + } + + public async Task MakeMerchantWithdrawal(String accessToken, + Guid estateId, + Guid merchantId, + MakeMerchantWithdrawalRequest makeMerchantWithdrawalRequest, + CancellationToken cancellationToken) { + MakeMerchantWithdrawalResponse response = null; + + String requestUri = this.BuildRequestUrl($"/api/estates/{estateId}/merchants/{merchantId}/withdrawals"); + + try { + String requestSerialised = JsonConvert.SerializeObject(makeMerchantWithdrawalRequest); + + StringContent httpContent = new(requestSerialised, Encoding.UTF8, "application/json"); + + // Add the access token to the client headers + this.HttpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken); + + // Make the Http Call here + HttpResponseMessage httpResponse = await this.HttpClient.PostAsync(requestUri, httpContent, cancellationToken); + + // Process the response + Result result = await this.HandleResponseX(httpResponse, cancellationToken); + + if (result.IsFailed) + return ResultHelpers.CreateFailure(result); + + return Result.Success(); + } + catch (Exception ex) { + // An exception has occurred, add some additional information to the message + Exception exception = new($"Error making merchant withdrawal for merchant {merchantId} for estate {estateId}.", ex); + + throw exception; + } + } + + public async Task SetMerchantSettlementSchedule(String accessToken, + Guid estateId, + Guid merchantId, + SetSettlementScheduleRequest setSettlementScheduleRequest, + CancellationToken cancellationToken) { + MakeMerchantDepositResponse response = null; + + String requestUri = this.BuildRequestUrl($"/api/estates/{estateId}/merchants/{merchantId}"); + + try { + String requestSerialised = JsonConvert.SerializeObject(setSettlementScheduleRequest); + + StringContent httpContent = new(requestSerialised, Encoding.UTF8, "application/json"); + + // Make the Http Call here + HttpRequestMessage requestMessage = new(HttpMethod.Patch, requestUri); + requestMessage.Headers.Authorization = new AuthenticationHeaderValue("Bearer", accessToken); + requestMessage.Content = httpContent; + + HttpResponseMessage httpResponse = await this.HttpClient.SendAsync(requestMessage, cancellationToken); + + // Process the response + Result result = await this.HandleResponseX(httpResponse, cancellationToken); + + if (result.IsFailed) + return ResultHelpers.CreateFailure(result); + + return Result.Success(); + } + catch (Exception ex) { + // An exception has occurred, add some additional information to the message + Exception exception = new($"Error setting settlement interval for merchant {merchantId} for estate {estateId}.", ex); + + throw exception; + } + } + + public async Task SwapDeviceForMerchant(String accessToken, + Guid estateId, + Guid merchantId, + String deviceIdentifier, + SwapMerchantDeviceRequest swapMerchantDeviceRequest, + CancellationToken cancellationToken) { + String requestUri = this.BuildRequestUrl($"/api/estates/{estateId}/merchants/{merchantId}/devices/{deviceIdentifier}"); + + try { + String requestSerialised = JsonConvert.SerializeObject(swapMerchantDeviceRequest); + + StringContent httpContent = new(requestSerialised, Encoding.UTF8, "application/json"); + + // Add the access token to the client headers + this.HttpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken); + + // Make the Http Call here + HttpResponseMessage httpResponse = await this.HttpClient.PatchAsync(requestUri, httpContent, cancellationToken); + + // Process the response + Result result = await this.HandleResponseX(httpResponse, cancellationToken); + + if (result.IsFailed) + return ResultHelpers.CreateFailure(result); + + return Result.Success(); + } + catch (Exception ex) { + // An exception has occurred, add some additional information to the message + Exception exception = new($"Error swapping device for merchant Id {merchantId} in estate {estateId}.", ex); + + throw exception; + } + } + + public async Task UpdateMerchant(String accessToken, + Guid estateId, + Guid merchantId, + UpdateMerchantRequest updateMerchantRequest, + CancellationToken cancellationToken) { + String requestUri = this.BuildRequestUrl($"/api/estates/{estateId}/merchants/{merchantId}"); + + try { + String requestSerialised = JsonConvert.SerializeObject(updateMerchantRequest); + + StringContent httpContent = new(requestSerialised, Encoding.UTF8, "application/json"); + + // Add the access token to the client headers + this.HttpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken); + + // Make the Http Call here + HttpResponseMessage httpResponse = await this.HttpClient.PatchAsync(requestUri, httpContent, cancellationToken); + + // Process the response + Result result = await this.HandleResponseX(httpResponse, cancellationToken); + + if (result.IsFailed) + return ResultHelpers.CreateFailure(result); + + return Result.Success(); + } + catch (Exception ex) { + // An exception has occurred, add some additional information to the message + Exception exception = new($"Error updating merchant {merchantId} for estate {estateId}.", ex); + + throw exception; + } + } + + public async Task UpdateMerchantAddress(String accessToken, + Guid estateId, + Guid merchantId, + Guid addressId, + Address updatedAddressRequest, + CancellationToken cancellationToken) { + String requestUri = this.BuildRequestUrl($"/api/estates/{estateId}/merchants/{merchantId}/addresses/{addressId}"); + + try { + String requestSerialised = JsonConvert.SerializeObject(updatedAddressRequest); + + StringContent httpContent = new(requestSerialised, Encoding.UTF8, "application/json"); + + // Add the access token to the client headers + this.HttpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken); + + // Make the Http Call here + HttpResponseMessage httpResponse = await this.HttpClient.PatchAsync(requestUri, httpContent, cancellationToken); + + // Process the response + Result result = await this.HandleResponseX(httpResponse, cancellationToken); + + if (result.IsFailed) + return ResultHelpers.CreateFailure(result); + + return Result.Success(); + } + catch (Exception ex) { + // An exception has occurred, add some additional information to the message + Exception exception = new($"Error updating address {addressId} for merchant {merchantId} for estate {estateId}.", ex); + + throw exception; + } + } + + public async Task UpdateMerchantContact(String accessToken, + Guid estateId, + Guid merchantId, + Guid contactId, + Contact updatedContactRequest, + CancellationToken cancellationToken) { + String requestUri = this.BuildRequestUrl($"/api/estates/{estateId}/merchants/{merchantId}/contacts/{contactId}"); + + try { + String requestSerialised = JsonConvert.SerializeObject(updatedContactRequest); + + StringContent httpContent = new(requestSerialised, Encoding.UTF8, "application/json"); + + // Add the access token to the client headers + this.HttpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken); + + // Make the Http Call here + HttpResponseMessage httpResponse = await this.HttpClient.PatchAsync(requestUri, httpContent, cancellationToken); + + // Process the response + Result result = await this.HandleResponseX(httpResponse, cancellationToken); + + if (result.IsFailed) + return ResultHelpers.CreateFailure(result); + + return Result.Success(); + } + catch (Exception ex) { + // An exception has occurred, add some additional information to the message + Exception exception = new($"Error updating contact {contactId} for merchant {merchantId} for estate {estateId}.", ex); + + throw exception; + } + } + + public async Task UpdateOperator(String accessToken, + Guid estateId, + Guid operatorId, + UpdateOperatorRequest updateOperatorRequest, + CancellationToken cancellationToken) { + String requestUri = this.BuildRequestUrl($"/api/estates/{estateId}/operators/{operatorId}"); + + try { + String requestSerialised = JsonConvert.SerializeObject(updateOperatorRequest); + + StringContent httpContent = new(requestSerialised, Encoding.UTF8, "application/json"); + + // Add the access token to the client headers + this.HttpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken); + + // Make the Http Call here + HttpResponseMessage httpResponse = await this.HttpClient.PostAsync(requestUri, httpContent, cancellationToken); + + // Process the response + Result result = await this.HandleResponseX(httpResponse, cancellationToken); + + if (result.IsFailed) + return ResultHelpers.CreateFailure(result); + + return Result.Success(); + } + catch (Exception ex) { + // An exception has occurred, add some additional information to the message + Exception exception = new($"Error updating operator id {operatorId}.", ex); + + throw exception; + } + } + + public async Task> GetOperator(String accessToken, + Guid estateId, + Guid operatorId, + CancellationToken cancellationToken) { + OperatorResponse response = null; + + String requestUri = this.BuildRequestUrl($"/api/estates/{estateId}/operators/{operatorId}"); + + try { + // Add the access token to the client headers + this.HttpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken); + + // Make the Http Call here + HttpResponseMessage httpResponse = await this.HttpClient.GetAsync(requestUri, cancellationToken); + + // Process the response + Result result = await this.HandleResponseX(httpResponse, cancellationToken); + + if (result.IsFailed) + return ResultHelpers.CreateFailure(result); + + ResponseData responseData = this.HandleResponseContent(result.Data); + + return Result.Success(responseData.Data); + } + catch (Exception ex) { + // An exception has occurred, add some additional information to the message + Exception exception = new($"Error getting operator id {operatorId} for estate Id {estateId}.", ex); + + throw exception; + } + + return response; + } + + public async Task>> GetOperators(String accessToken, + Guid estateId, + CancellationToken cancellationToken) { + List response = null; + + String requestUri = this.BuildRequestUrl($"/api/estates/{estateId}/operators"); + + try { + // Add the access token to the client headers + this.HttpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken); + + // Make the Http Call here + HttpResponseMessage httpResponse = await this.HttpClient.GetAsync(requestUri, cancellationToken); + + // Process the response + Result result = await this.HandleResponseX(httpResponse, cancellationToken); + + if (result.IsFailed) + return ResultHelpers.CreateFailure(result); + + ResponseData> responseData = this.HandleResponseContent>(result.Data); + + return Result.Success(responseData.Data); + } + catch (Exception ex) { + // An exception has occurred, add some additional information to the message + Exception exception = new($"Error getting all operators for estate Id {estateId}.", ex); + + throw exception; + } + + return response; + } } \ No newline at end of file diff --git a/TransactionProcessor.DataTransferObjects/RedeemVoucherResponse.cs b/TransactionProcessor.DataTransferObjects/RedeemVoucherResponse.cs index d3f0db99..f7e961de 100644 --- a/TransactionProcessor.DataTransferObjects/RedeemVoucherResponse.cs +++ b/TransactionProcessor.DataTransferObjects/RedeemVoucherResponse.cs @@ -1,6 +1,9 @@ namespace TransactionProcessor.DataTransferObjects { using System; + using System.Collections.Generic; + using System.ComponentModel.DataAnnotations; + using System.Diagnostics.CodeAnalysis; using Newtonsoft.Json; public class RedeemVoucherResponse diff --git a/TransactionProcessor.DataTransferObjects/Requests/Contract/AddProductToContractRequest.cs b/TransactionProcessor.DataTransferObjects/Requests/Contract/AddProductToContractRequest.cs new file mode 100644 index 00000000..ab5207e4 --- /dev/null +++ b/TransactionProcessor.DataTransferObjects/Requests/Contract/AddProductToContractRequest.cs @@ -0,0 +1,52 @@ +using System; +using Newtonsoft.Json; +using TransactionProcessor.DataTransferObjects.Responses.Contract; + +namespace TransactionProcessor.DataTransferObjects.Requests.Contract +{ + /// + /// + /// + public class AddProductToContractRequest + { + #region Properties + + /// + /// Gets or sets the display text. + /// + /// + /// The display text. + /// + [JsonProperty("display_text")] + public String DisplayText { get; set; } + + /// + /// Gets or sets the name of the product. + /// + /// + /// The name of the product. + /// + [JsonProperty("product_name")] + public String ProductName { get; set; } + + /// + /// Gets or sets the value. + /// + /// + /// The value. + /// + [JsonProperty("value")] + public Decimal? Value { get; set; } + + /// + /// Gets or sets the type of the product. + /// + /// + /// The type of the product. + /// + [JsonProperty("product_type")] + public ProductType ProductType { get; set; } + + #endregion + } +} \ No newline at end of file diff --git a/TransactionProcessor.DataTransferObjects/Requests/Contract/AddTransactionFeeForProductToContractRequest.cs b/TransactionProcessor.DataTransferObjects/Requests/Contract/AddTransactionFeeForProductToContractRequest.cs new file mode 100644 index 00000000..af915423 --- /dev/null +++ b/TransactionProcessor.DataTransferObjects/Requests/Contract/AddTransactionFeeForProductToContractRequest.cs @@ -0,0 +1,52 @@ +using System; +using Newtonsoft.Json; +using TransactionProcessor.DataTransferObjects.Responses.Contract; + +namespace TransactionProcessor.DataTransferObjects.Requests.Contract +{ + /// + /// + /// + public class AddTransactionFeeForProductToContractRequest + { + #region Properties + + /// + /// Gets or sets the type of the calculation. + /// + /// + /// The type of the calculation. + /// + [JsonProperty("calculation_type")] + public CalculationType CalculationType { get; set; } + + /// + /// Gets or sets the description. + /// + /// + /// The description. + /// + [JsonProperty("description")] + public String Description { get; set; } + + /// + /// Gets or sets the type of the fee. + /// + /// + /// The type of the fee. + /// + [JsonProperty("fee_type")] + public FeeType FeeType { get; set; } + + /// + /// Gets or sets the value. + /// + /// + /// The value. + /// + [JsonProperty("value")] + public Decimal Value { get; set; } + + #endregion + } +} \ No newline at end of file diff --git a/TransactionProcessor.DataTransferObjects/Requests/Contract/CreateContractRequest.cs b/TransactionProcessor.DataTransferObjects/Requests/Contract/CreateContractRequest.cs new file mode 100644 index 00000000..5bd1ce1a --- /dev/null +++ b/TransactionProcessor.DataTransferObjects/Requests/Contract/CreateContractRequest.cs @@ -0,0 +1,28 @@ +using System; +using System.Diagnostics.CodeAnalysis; +using Newtonsoft.Json; + +namespace TransactionProcessor.DataTransferObjects.Requests.Contract +{ + [ExcludeFromCodeCoverage] + public class CreateContractRequest + { + /// + /// Gets or sets the operator identifier. + /// + /// + /// The operator identifier. + /// + [JsonProperty("operator_id")] + public Guid OperatorId { get; set; } + + /// + /// Gets or sets the description. + /// + /// + /// The description. + /// + [JsonProperty("description")] + public String Description { get; set; } + } +} diff --git a/TransactionProcessor.DataTransferObjects/Requests/Estate/AssignOperatorRequest.cs b/TransactionProcessor.DataTransferObjects/Requests/Estate/AssignOperatorRequest.cs new file mode 100644 index 00000000..1757f063 --- /dev/null +++ b/TransactionProcessor.DataTransferObjects/Requests/Estate/AssignOperatorRequest.cs @@ -0,0 +1,28 @@ +using System; +using System.ComponentModel.DataAnnotations; +using System.Diagnostics.CodeAnalysis; +using Newtonsoft.Json; + +namespace TransactionProcessor.DataTransferObjects.Requests.Estate +{ + /// + /// + /// + [ExcludeFromCodeCoverage] + public class AssignOperatorRequest + { + #region Properties + + /// + /// Gets or sets the name. + /// + /// + /// The name. + /// + [Required] + [JsonProperty("operator_id")] + public Guid OperatorId { get; set; } + + #endregion + } +} \ No newline at end of file diff --git a/TransactionProcessor.DataTransferObjects/Requests/Estate/CreateEstateRequest.cs b/TransactionProcessor.DataTransferObjects/Requests/Estate/CreateEstateRequest.cs new file mode 100644 index 00000000..422e0a1a --- /dev/null +++ b/TransactionProcessor.DataTransferObjects/Requests/Estate/CreateEstateRequest.cs @@ -0,0 +1,29 @@ +using System; +using System.ComponentModel.DataAnnotations; +using Newtonsoft.Json; + +namespace TransactionProcessor.DataTransferObjects.Requests.Estate +{ + public class CreateEstateRequest + { + /// + /// Gets or sets the estate identifier. + /// + /// + /// The estate identifier. + /// + [Required] + [JsonProperty("estate_id")] + public Guid EstateId { get; set; } + + /// + /// Gets or sets the name of the estate. + /// + /// + /// The name of the estate. + /// + [Required] + [JsonProperty("estate_name")] + public String EstateName { get; set; } + } +} \ No newline at end of file diff --git a/TransactionProcessor.DataTransferObjects/Requests/Estate/CreateEstateUserRequest.cs b/TransactionProcessor.DataTransferObjects/Requests/Estate/CreateEstateUserRequest.cs new file mode 100644 index 00000000..b1826d83 --- /dev/null +++ b/TransactionProcessor.DataTransferObjects/Requests/Estate/CreateEstateUserRequest.cs @@ -0,0 +1,54 @@ +using System; +using System.ComponentModel.DataAnnotations; +using System.Diagnostics.CodeAnalysis; +using Newtonsoft.Json; + +namespace TransactionProcessor.DataTransferObjects.Requests.Estate +{ + [ExcludeFromCodeCoverage] + public class CreateEstateUserRequest + { + [Required] + [JsonProperty("email_address")] + public String EmailAddress { get; set; } + + /// + /// Gets or sets the password. + /// + /// + /// The password. + /// + [Required] + [JsonProperty("password")] + public String Password { get; set; } + + /// + /// Gets or sets the name of the given. + /// + /// + /// The name of the given. + /// + [Required] + [JsonProperty("given_name")] + public String GivenName { get; set; } + + /// + /// Gets or sets the name of the middle. + /// + /// + /// The name of the middle. + /// + [JsonProperty("middle_name")] + public String MiddleName { get; set; } + + /// + /// Gets or sets the name of the family. + /// + /// + /// The name of the family. + /// + [Required] + [JsonProperty("family_name")] + public String FamilyName { get; set; } + } +} diff --git a/TransactionProcessor.DataTransferObjects/Requests/Merchant/AddMerchantContractRequest.cs b/TransactionProcessor.DataTransferObjects/Requests/Merchant/AddMerchantContractRequest.cs new file mode 100644 index 00000000..f5bb45df --- /dev/null +++ b/TransactionProcessor.DataTransferObjects/Requests/Merchant/AddMerchantContractRequest.cs @@ -0,0 +1,12 @@ +using System; +using System.Diagnostics.CodeAnalysis; +using Newtonsoft.Json; + +namespace TransactionProcessor.DataTransferObjects.Requests.Merchant{ + [ExcludeFromCodeCoverage] + public class AddMerchantContractRequest + { + [JsonProperty("contract_id")] + public Guid ContractId { get; set; } + } +} \ No newline at end of file diff --git a/TransactionProcessor.DataTransferObjects/Requests/Merchant/AddMerchantDeviceRequest.cs b/TransactionProcessor.DataTransferObjects/Requests/Merchant/AddMerchantDeviceRequest.cs new file mode 100644 index 00000000..043d242d --- /dev/null +++ b/TransactionProcessor.DataTransferObjects/Requests/Merchant/AddMerchantDeviceRequest.cs @@ -0,0 +1,19 @@ +using System; +using System.Diagnostics.CodeAnalysis; +using Newtonsoft.Json; + +namespace TransactionProcessor.DataTransferObjects.Requests.Merchant +{ + [ExcludeFromCodeCoverage] + public class AddMerchantDeviceRequest + { + /// + /// Gets or sets the device identifier. + /// + /// + /// The device identifier. + /// + [JsonProperty("device_identifier")] + public String DeviceIdentifier { get; set; } + } +} diff --git a/TransactionProcessor.DataTransferObjects/Requests/Merchant/Address.cs b/TransactionProcessor.DataTransferObjects/Requests/Merchant/Address.cs new file mode 100644 index 00000000..b2a23ced --- /dev/null +++ b/TransactionProcessor.DataTransferObjects/Requests/Merchant/Address.cs @@ -0,0 +1,92 @@ +using System; +using System.ComponentModel.DataAnnotations; +using Newtonsoft.Json; + +namespace TransactionProcessor.DataTransferObjects.Requests.Merchant +{ + /// + /// + /// + public class Address + { + #region Properties + + /// + /// Gets or sets the address line1. + /// + /// + /// The address line1. + /// + [JsonProperty("address_line_1")] + [Required] + public String AddressLine1 { get; set; } + + /// + /// Gets or sets the address line2. + /// + /// + /// The address line2. + /// + [JsonProperty("address_line_2")] + public String AddressLine2 { get; set; } + + /// + /// Gets or sets the address line3. + /// + /// + /// The address line3. + /// + [JsonProperty("address_line_3")] + public String AddressLine3 { get; set; } + + /// + /// Gets or sets the address line4. + /// + /// + /// The address line4. + /// + [JsonProperty("address_line_4")] + public String AddressLine4 { get; set; } + + /// + /// Gets or sets the country. + /// + /// + /// The country. + /// + [JsonProperty("country")] + [Required] + public String Country { get; set; } + + /// + /// Gets or sets the postal code. + /// + /// + /// The postal code. + /// + [JsonProperty("postal_code")] + public String PostalCode { get; set; } + + /// + /// Gets or sets the region. + /// + /// + /// The region. + /// + [JsonProperty("region")] + [Required] + public String Region { get; set; } + + /// + /// Gets or sets the town. + /// + /// + /// The town. + /// + [JsonProperty("town")] + [Required] + public String Town { get; set; } + + #endregion + } +} \ No newline at end of file diff --git a/TransactionProcessor.DataTransferObjects/Requests/Merchant/AssignOperatorRequest.cs b/TransactionProcessor.DataTransferObjects/Requests/Merchant/AssignOperatorRequest.cs new file mode 100644 index 00000000..d2c44d0b --- /dev/null +++ b/TransactionProcessor.DataTransferObjects/Requests/Merchant/AssignOperatorRequest.cs @@ -0,0 +1,44 @@ +using System; +using System.Diagnostics.CodeAnalysis; +using Newtonsoft.Json; + +namespace TransactionProcessor.DataTransferObjects.Requests.Merchant +{ + /// + /// + /// + [ExcludeFromCodeCoverage] + public class AssignOperatorRequest + { + #region Properties + + /// + /// Gets or sets the merchant number. + /// + /// + /// The merchant number. + /// + [JsonProperty("merchant_number")] + public String MerchantNumber { get; set; } + + /// + /// Gets or sets the operator identifier. + /// + /// + /// The operator identifier. + /// + [JsonProperty("operator_id")] + public Guid OperatorId { get; set; } + + /// + /// Gets or sets the terminal number. + /// + /// + /// The terminal number. + /// + [JsonProperty("terminal_number")] + public String TerminalNumber { get; set; } + + #endregion + } +} \ No newline at end of file diff --git a/TransactionProcessor.DataTransferObjects/Requests/Merchant/Contact.cs b/TransactionProcessor.DataTransferObjects/Requests/Merchant/Contact.cs new file mode 100644 index 00000000..bb4342cb --- /dev/null +++ b/TransactionProcessor.DataTransferObjects/Requests/Merchant/Contact.cs @@ -0,0 +1,45 @@ +using System; +using System.ComponentModel.DataAnnotations; +using Newtonsoft.Json; + +namespace TransactionProcessor.DataTransferObjects.Requests.Merchant +{ + /// + /// + /// + public class Contact + { + #region Properties + + /// + /// Gets or sets the name of the contact. + /// + /// + /// The name of the contact. + /// + [JsonProperty("contact_name")] + [Required] + public String ContactName { get; set; } + + /// + /// Gets or sets the email address. + /// + /// + /// The email address. + /// + [JsonProperty("email_address")] + [Required] + public String EmailAddress { get; set; } + + /// + /// Gets or sets the phone number. + /// + /// + /// The phone number. + /// + [JsonProperty("phone_number")] + public String PhoneNumber { get; set; } + + #endregion + } +} \ No newline at end of file diff --git a/TransactionProcessor.DataTransferObjects/Requests/Merchant/CreateMerchantRequest.cs b/TransactionProcessor.DataTransferObjects/Requests/Merchant/CreateMerchantRequest.cs new file mode 100644 index 00000000..ace015d4 --- /dev/null +++ b/TransactionProcessor.DataTransferObjects/Requests/Merchant/CreateMerchantRequest.cs @@ -0,0 +1,56 @@ +using System; +using System.ComponentModel.DataAnnotations; +using Newtonsoft.Json; +using TransactionProcessor.DataTransferObjects.Responses.Merchant; + +namespace TransactionProcessor.DataTransferObjects.Requests.Merchant +{ + /// + /// + /// + public class CreateMerchantRequest + { + #region Properties + + /// + /// Gets or sets the address. + /// + /// + /// The address. + /// + [JsonProperty("address")] + [Required] + public Address Address { get; set; } + + /// + /// Gets or sets the contact. + /// + /// + /// The contact. + /// + [JsonProperty("contact")] + [Required] + public Contact Contact { get; set; } + + /// + /// Gets or sets the name. + /// + /// + /// The name. + /// + [Required] + [JsonProperty("name")] + public String Name { get; set; } + + [JsonProperty("settlement_schedule")] + public SettlementSchedule SettlementSchedule { get; set; } + + [JsonProperty("merchant_id")] + public Guid? MerchantId { get; set; } + + [JsonProperty("created_date_time")] + public DateTime? CreatedDateTime { get; set; } + + #endregion + } +} \ No newline at end of file diff --git a/TransactionProcessor.DataTransferObjects/Requests/Merchant/CreateMerchantUserRequest.cs b/TransactionProcessor.DataTransferObjects/Requests/Merchant/CreateMerchantUserRequest.cs new file mode 100644 index 00000000..70b6482c --- /dev/null +++ b/TransactionProcessor.DataTransferObjects/Requests/Merchant/CreateMerchantUserRequest.cs @@ -0,0 +1,54 @@ +using System; +using System.ComponentModel.DataAnnotations; +using System.Diagnostics.CodeAnalysis; +using Newtonsoft.Json; + +namespace TransactionProcessor.DataTransferObjects.Requests.Merchant +{ + [ExcludeFromCodeCoverage] + public class CreateMerchantUserRequest + { + [Required] + [JsonProperty("email_address")] + public String EmailAddress { get; set; } + + /// + /// Gets or sets the password. + /// + /// + /// The password. + /// + [Required] + [JsonProperty("password")] + public String Password { get; set; } + + /// + /// Gets or sets the name of the given. + /// + /// + /// The name of the given. + /// + [Required] + [JsonProperty("given_name")] + public String GivenName { get; set; } + + /// + /// Gets or sets the name of the middle. + /// + /// + /// The name of the middle. + /// + [JsonProperty("middle_name")] + public String MiddleName { get; set; } + + /// + /// Gets or sets the name of the family. + /// + /// + /// The name of the family. + /// + [Required] + [JsonProperty("family_name")] + public String FamilyName { get; set; } + } +} diff --git a/TransactionProcessor.DataTransferObjects/Requests/Merchant/GenerateMerchantStatementRequest.cs b/TransactionProcessor.DataTransferObjects/Requests/Merchant/GenerateMerchantStatementRequest.cs new file mode 100644 index 00000000..07202598 --- /dev/null +++ b/TransactionProcessor.DataTransferObjects/Requests/Merchant/GenerateMerchantStatementRequest.cs @@ -0,0 +1,21 @@ +using System; +using Newtonsoft.Json; + +namespace TransactionProcessor.DataTransferObjects.Requests.Merchant +{ + public class GenerateMerchantStatementRequest + { + #region Properties + + /// + /// Gets or sets the statement date. + /// + /// + /// The statement date. + /// + [JsonProperty("merchant_statement_date")] + public DateTime MerchantStatementDate { get; set; } + + #endregion + } +} \ No newline at end of file diff --git a/TransactionProcessor.DataTransferObjects/Requests/Merchant/MakeMerchantDepositRequest.cs b/TransactionProcessor.DataTransferObjects/Requests/Merchant/MakeMerchantDepositRequest.cs new file mode 100644 index 00000000..22e4af42 --- /dev/null +++ b/TransactionProcessor.DataTransferObjects/Requests/Merchant/MakeMerchantDepositRequest.cs @@ -0,0 +1,44 @@ +using System; +using System.Diagnostics.CodeAnalysis; +using Newtonsoft.Json; + +namespace TransactionProcessor.DataTransferObjects.Requests.Merchant +{ + /// + /// + /// + [ExcludeFromCodeCoverage] + public class MakeMerchantDepositRequest + { + #region Properties + + /// + /// Gets or sets the amount. + /// + /// + /// The amount. + /// + [JsonProperty("amount")] + public Decimal Amount { get; set; } + + /// + /// Gets or sets the deposit date time. + /// + /// + /// The deposit date time. + /// + [JsonProperty("deposit_date_time")] + public DateTime DepositDateTime { get; set; } + + /// + /// Gets or sets the reference. + /// + /// + /// The reference. + /// + [JsonProperty("reference")] + public String Reference { get; set; } + + #endregion + } +} \ No newline at end of file diff --git a/TransactionProcessor.DataTransferObjects/Requests/Merchant/MakeMerchantWithdrawalRequest.cs b/TransactionProcessor.DataTransferObjects/Requests/Merchant/MakeMerchantWithdrawalRequest.cs new file mode 100644 index 00000000..7893bc28 --- /dev/null +++ b/TransactionProcessor.DataTransferObjects/Requests/Merchant/MakeMerchantWithdrawalRequest.cs @@ -0,0 +1,41 @@ +using System; +using System.Diagnostics.CodeAnalysis; +using Newtonsoft.Json; + +namespace TransactionProcessor.DataTransferObjects.Requests.Merchant +{ + [ExcludeFromCodeCoverage] + public class MakeMerchantWithdrawalRequest + { + #region Properties + + /// + /// Gets or sets the amount. + /// + /// + /// The amount. + /// + [JsonProperty("amount")] + public Decimal Amount { get; set; } + + /// + /// Gets or sets the withdrawal date time. + /// + /// + /// The withdrawal date time. + /// + [JsonProperty("withdrawal_date_time")] + public DateTime WithdrawalDateTime { get; set; } + + /// + /// Gets or sets the reference. + /// + /// + /// The reference. + /// + [JsonProperty("reference")] + public String Reference { get; set; } + + #endregion + } +} \ No newline at end of file diff --git a/TransactionProcessor.DataTransferObjects/Requests/Merchant/MerchantDepositSource.cs b/TransactionProcessor.DataTransferObjects/Requests/Merchant/MerchantDepositSource.cs new file mode 100644 index 00000000..ef3d1476 --- /dev/null +++ b/TransactionProcessor.DataTransferObjects/Requests/Merchant/MerchantDepositSource.cs @@ -0,0 +1,9 @@ +namespace TransactionProcessor.DataTransferObjects.Requests.Merchant +{ + public enum MerchantDepositSource + { + NotSet, + Manual, + Automatic + } +} \ No newline at end of file diff --git a/TransactionProcessor.DataTransferObjects/Requests/Merchant/SetSettlementScheduleRequest.cs b/TransactionProcessor.DataTransferObjects/Requests/Merchant/SetSettlementScheduleRequest.cs new file mode 100644 index 00000000..62f1665a --- /dev/null +++ b/TransactionProcessor.DataTransferObjects/Requests/Merchant/SetSettlementScheduleRequest.cs @@ -0,0 +1,14 @@ +using System.Diagnostics.CodeAnalysis; +using Newtonsoft.Json; +using TransactionProcessor.DataTransferObjects.Responses.Merchant; + +namespace TransactionProcessor.DataTransferObjects.Requests.Merchant +{ + [ExcludeFromCodeCoverage] + public class SetSettlementScheduleRequest + { + [JsonProperty("settlment_schedule")] + public SettlementSchedule SettlementSchedule { get; set; } + + } +} diff --git a/TransactionProcessor.DataTransferObjects/Requests/Merchant/SwapMerchantDeviceRequest.cs b/TransactionProcessor.DataTransferObjects/Requests/Merchant/SwapMerchantDeviceRequest.cs new file mode 100644 index 00000000..d4a42bc9 --- /dev/null +++ b/TransactionProcessor.DataTransferObjects/Requests/Merchant/SwapMerchantDeviceRequest.cs @@ -0,0 +1,17 @@ +using System; +using Newtonsoft.Json; + +namespace TransactionProcessor.DataTransferObjects.Requests.Merchant +{ + public class SwapMerchantDeviceRequest + { + /// + /// Gets or sets the device identifier. + /// + /// + /// The device identifier. + /// + [JsonProperty("new_device_identifier")] + public String NewDeviceIdentifier { get; set; } + } +} \ No newline at end of file diff --git a/TransactionProcessor.DataTransferObjects/Requests/Merchant/UpdateMerchantRequest.cs b/TransactionProcessor.DataTransferObjects/Requests/Merchant/UpdateMerchantRequest.cs new file mode 100644 index 00000000..2939ee3e --- /dev/null +++ b/TransactionProcessor.DataTransferObjects/Requests/Merchant/UpdateMerchantRequest.cs @@ -0,0 +1,19 @@ +using System; +using Newtonsoft.Json; +using TransactionProcessor.DataTransferObjects.Responses.Merchant; + +namespace TransactionProcessor.DataTransferObjects.Requests.Merchant +{ + public class UpdateMerchantRequest + { + #region Properties + + [JsonProperty("name")] + public String Name { get; set; } + + [JsonProperty("settlement_schedule")] + public SettlementSchedule SettlementSchedule { get; set; } + + #endregion + } +} \ No newline at end of file diff --git a/TransactionProcessor.DataTransferObjects/Requests/Operator/CreateOperatorRequest.cs b/TransactionProcessor.DataTransferObjects/Requests/Operator/CreateOperatorRequest.cs new file mode 100644 index 00000000..57ab8776 --- /dev/null +++ b/TransactionProcessor.DataTransferObjects/Requests/Operator/CreateOperatorRequest.cs @@ -0,0 +1,52 @@ +using System; +using System.ComponentModel.DataAnnotations; +using System.Diagnostics.CodeAnalysis; +using Newtonsoft.Json; + +namespace TransactionProcessor.DataTransferObjects.Requests.Operator +{ + /// + /// + /// + [ExcludeFromCodeCoverage] + public class CreateOperatorRequest + { + #region Properties + + /// + /// Gets or sets the name. + /// + /// + /// The name. + /// + [Required] + [JsonProperty("name")] + public String Name { get; set; } + + [Required] + [JsonProperty("operator_id")] + public Guid OperatorId { get; set; } + + /// + /// Gets or sets a value indicating whether [require custom merchant number]. + /// + /// + /// true if [require custom merchant number]; otherwise, false. + /// + [Required] + [JsonProperty("require_custom_merchant_number")] + public Boolean? RequireCustomMerchantNumber { get; set; } + + /// + /// Gets or sets a value indicating whether [require custom terminal number]. + /// + /// + /// true if [require custom terminal number]; otherwise, false. + /// + [Required] + [JsonProperty("require_custom_terminal_number")] + public Boolean? RequireCustomTerminalNumber { get; set; } + + #endregion + } +} \ No newline at end of file diff --git a/TransactionProcessor.DataTransferObjects/Requests/Operator/UpdateOperatorRequest.cs b/TransactionProcessor.DataTransferObjects/Requests/Operator/UpdateOperatorRequest.cs new file mode 100644 index 00000000..9ced77a1 --- /dev/null +++ b/TransactionProcessor.DataTransferObjects/Requests/Operator/UpdateOperatorRequest.cs @@ -0,0 +1,44 @@ +using System; +using System.ComponentModel.DataAnnotations; +using System.Diagnostics.CodeAnalysis; +using Newtonsoft.Json; + +namespace TransactionProcessor.DataTransferObjects.Requests.Operator{ + [ExcludeFromCodeCoverage] + public class UpdateOperatorRequest + { + #region Properties + + /// + /// Gets or sets the name. + /// + /// + /// The name. + /// + [Required] + [JsonProperty("name")] + public String Name { get; set; } + + /// + /// Gets or sets a value indicating whether [require custom merchant number]. + /// + /// + /// true if [require custom merchant number]; otherwise, false. + /// + [Required] + [JsonProperty("require_custom_merchant_number")] + public Boolean? RequireCustomMerchantNumber { get; set; } + + /// + /// Gets or sets a value indicating whether [require custom terminal number]. + /// + /// + /// true if [require custom terminal number]; otherwise, false. + /// + [Required] + [JsonProperty("require_custom_terminal_number")] + public Boolean? RequireCustomTerminalNumber { get; set; } + + #endregion + } +} \ No newline at end of file diff --git a/TransactionProcessor.DataTransferObjects/Responses/Contract/AddProductToContractResponse.cs b/TransactionProcessor.DataTransferObjects/Responses/Contract/AddProductToContractResponse.cs new file mode 100644 index 00000000..5d2b56c4 --- /dev/null +++ b/TransactionProcessor.DataTransferObjects/Responses/Contract/AddProductToContractResponse.cs @@ -0,0 +1,44 @@ +using System; +using System.Diagnostics.CodeAnalysis; +using Newtonsoft.Json; + +namespace TransactionProcessor.DataTransferObjects.Responses.Contract +{ + /// + /// + /// + [ExcludeFromCodeCoverage] + public class AddProductToContractResponse + { + #region Properties + + /// + /// Gets or sets the contract identifier. + /// + /// + /// The contract identifier. + /// + [JsonProperty("contract_id")] + public Guid ContractId { get; set; } + + /// + /// Gets or sets the estate identifier. + /// + /// + /// The estate identifier. + /// + [JsonProperty("estate_id")] + public Guid EstateId { get; set; } + + /// + /// Gets or sets the product identifier. + /// + /// + /// The product identifier. + /// + [JsonProperty("product_id")] + public Guid ProductId { get; set; } + + #endregion + } +} \ No newline at end of file diff --git a/TransactionProcessor.DataTransferObjects/Responses/Contract/AddTransactionFeeForProductToContractResponse.cs b/TransactionProcessor.DataTransferObjects/Responses/Contract/AddTransactionFeeForProductToContractResponse.cs new file mode 100644 index 00000000..d8b5c76d --- /dev/null +++ b/TransactionProcessor.DataTransferObjects/Responses/Contract/AddTransactionFeeForProductToContractResponse.cs @@ -0,0 +1,50 @@ +using System; +using System.Diagnostics.CodeAnalysis; +using Newtonsoft.Json; + +namespace TransactionProcessor.DataTransferObjects.Responses.Contract +{ + [ExcludeFromCodeCoverage] + public class AddTransactionFeeForProductToContractResponse + { + #region Properties + + /// + /// Gets or sets the contract identifier. + /// + /// + /// The contract identifier. + /// + [JsonProperty("contract_id")] + public Guid ContractId { get; set; } + + /// + /// Gets or sets the estate identifier. + /// + /// + /// The estate identifier. + /// + [JsonProperty("estate_id")] + public Guid EstateId { get; set; } + + /// + /// Gets or sets the product identifier. + /// + /// + /// The product identifier. + /// + [JsonProperty("product_id")] + public Guid ProductId { get; set; } + + /// + /// Gets or sets the transaction fee identifier. + /// + /// + /// The transaction fee identifier. + /// + [JsonProperty("transaction_fee_id")] + public Guid TransactionFeeId { get; set; } + + #endregion + } +} \ No newline at end of file diff --git a/TransactionProcessor.DataTransferObjects/Responses/Contract/CalculationType.cs b/TransactionProcessor.DataTransferObjects/Responses/Contract/CalculationType.cs new file mode 100644 index 00000000..5ed95303 --- /dev/null +++ b/TransactionProcessor.DataTransferObjects/Responses/Contract/CalculationType.cs @@ -0,0 +1,18 @@ +namespace TransactionProcessor.DataTransferObjects.Responses.Contract +{ + /// + /// + /// + public enum CalculationType + { + /// + /// The fixed + /// + Fixed, + + /// + /// The percentage + /// + Percentage + } +} \ No newline at end of file diff --git a/TransactionProcessor.DataTransferObjects/Responses/Contract/ContactResponse.cs b/TransactionProcessor.DataTransferObjects/Responses/Contract/ContactResponse.cs new file mode 100644 index 00000000..1a237a6b --- /dev/null +++ b/TransactionProcessor.DataTransferObjects/Responses/Contract/ContactResponse.cs @@ -0,0 +1,50 @@ +using System; +using System.Diagnostics.CodeAnalysis; +using Newtonsoft.Json; + +namespace TransactionProcessor.DataTransferObjects.Responses.Contract +{ + [ExcludeFromCodeCoverage] + public class ContactResponse + { + #region Properties + + /// + /// Gets the contact email address. + /// + /// + /// The contact email address. + /// + [JsonProperty("contact_email_address")] + public String ContactEmailAddress { get; set; } + + /// + /// Gets the contact identifier. + /// + /// + /// The contact identifier. + /// + [JsonProperty("contact_id")] + public Guid ContactId { get; set; } + + /// + /// Gets the name of the contact. + /// + /// + /// The name of the contact. + /// + [JsonProperty("contact_name")] + public String ContactName { get; set; } + + /// + /// Gets the contact phone number. + /// + /// + /// The contact phone number. + /// + [JsonProperty("contact_phone_number")] + public String ContactPhoneNumber { get; set; } + + #endregion + } +} \ No newline at end of file diff --git a/TransactionProcessor.DataTransferObjects/Responses/Contract/ContractProduct.cs b/TransactionProcessor.DataTransferObjects/Responses/Contract/ContractProduct.cs new file mode 100644 index 00000000..403628df --- /dev/null +++ b/TransactionProcessor.DataTransferObjects/Responses/Contract/ContractProduct.cs @@ -0,0 +1,66 @@ +using System; +using System.Collections.Generic; +using Newtonsoft.Json; + +namespace TransactionProcessor.DataTransferObjects.Responses.Contract +{ + public class ContractProduct + { + /// + /// Gets or sets the display text. + /// + /// + /// The display text. + /// + [JsonProperty("display_text")] + public String DisplayText { get; set; } + + /// + /// Gets or sets the name. + /// + /// + /// The name. + /// + [JsonProperty("name")] + public String Name { get; set; } + + /// + /// Gets or sets the product identifier. + /// + /// + /// The product identifier. + /// + [JsonProperty("product_id")] + public Guid ProductId { get; set; } + + [JsonProperty("product_reporting_id")] + public Int32 ProductReportingId { get; set; } + + /// + /// Gets or sets the transaction fees. + /// + /// + /// The transaction fees. + /// + [JsonProperty("transaction_fees")] + public List TransactionFees { get; set; } + + /// + /// Gets or sets the value. + /// + /// + /// The value. + /// + [JsonProperty("value")] + public Decimal? Value { get; set; } + + /// + /// Gets or sets the type of the product. + /// + /// + /// The type of the product. + /// + [JsonProperty("product_type")] + public ProductType ProductType { get; set; } + } +} \ No newline at end of file diff --git a/TransactionProcessor.DataTransferObjects/Responses/Contract/ContractProductTransactionFee.cs b/TransactionProcessor.DataTransferObjects/Responses/Contract/ContractProductTransactionFee.cs new file mode 100644 index 00000000..fa517baf --- /dev/null +++ b/TransactionProcessor.DataTransferObjects/Responses/Contract/ContractProductTransactionFee.cs @@ -0,0 +1,60 @@ +using System; +using Newtonsoft.Json; + +namespace TransactionProcessor.DataTransferObjects.Responses.Contract +{ + public class ContractProductTransactionFee + { + #region Properties + + /// + /// Gets or sets the type of the calculation. + /// + /// + /// The type of the calculation. + /// + [JsonProperty("calculation_type")] + public CalculationType CalculationType { get; set; } + + /// + /// Gets or sets the type of the fee. + /// + /// + /// The type of the fee. + /// + [JsonProperty("fee_type")] + public FeeType FeeType { get; set; } + + /// + /// Gets or sets the description. + /// + /// + /// The description. + /// + [JsonProperty("description")] + public String Description { get; set; } + + /// + /// Gets or sets the transaction fee identifier. + /// + /// + /// The transaction fee identifier. + /// + [JsonProperty("transaction_fee_id")] + public Guid TransactionFeeId { get; set; } + + [JsonProperty("transaction_fee_reporting_id")] + public Int32 TransactionFeeReportingId { get; set; } + + /// + /// Gets or sets the value. + /// + /// + /// The value. + /// + [JsonProperty("value")] + public Decimal Value { get; set; } + + #endregion + } +} \ No newline at end of file diff --git a/TransactionProcessor.DataTransferObjects/Responses/Contract/ContractResponse.cs b/TransactionProcessor.DataTransferObjects/Responses/Contract/ContractResponse.cs new file mode 100644 index 00000000..faf78922 --- /dev/null +++ b/TransactionProcessor.DataTransferObjects/Responses/Contract/ContractResponse.cs @@ -0,0 +1,70 @@ +using System; +using System.Collections.Generic; +using Newtonsoft.Json; + +namespace TransactionProcessor.DataTransferObjects.Responses.Contract +{ + public class ContractResponse + { + /// + /// Gets or sets the contract identifier. + /// + /// + /// The contract identifier. + /// + [JsonProperty("contract_id")] + public Guid ContractId { get; set; } + + [JsonProperty("contract_reporting_id")] + public Int32 ContractReportingId { get; set; } + + /// + /// Gets or sets the description. + /// + /// + /// The description. + /// + [JsonProperty("description")] + public String Description { get; set; } + + /// + /// Gets or sets the estate identifier. + /// + /// + /// The estate identifier. + /// + [JsonProperty("estate_id")] + public Guid EstateId { get; set; } + + [JsonProperty("estate_reporting_id")] + public Int32 EstateReportingId { get; set; } + + /// + /// Gets or sets the operator identifier. + /// + /// + /// The operator identifier. + /// + [JsonProperty("operator_id")] + public Guid OperatorId { get; set; } + + /// + /// Gets or sets the name of the operator. + /// + /// + /// The name of the operator. + /// + [JsonProperty("operator_name")] + public String OperatorName { get; set; } + + /// + /// Gets or sets the products. + /// + /// + /// The products. + /// + [JsonProperty("products")] + public List Products { get; set; } + + } +} diff --git a/TransactionProcessor.DataTransferObjects/Responses/Contract/CreateContractResponse.cs b/TransactionProcessor.DataTransferObjects/Responses/Contract/CreateContractResponse.cs new file mode 100644 index 00000000..baa7fce9 --- /dev/null +++ b/TransactionProcessor.DataTransferObjects/Responses/Contract/CreateContractResponse.cs @@ -0,0 +1,39 @@ +using System; +using Newtonsoft.Json; + +namespace TransactionProcessor.DataTransferObjects.Responses.Contract +{ + public class CreateContractResponse + { + #region Properties + + /// + /// Gets or sets the contract identifier. + /// + /// + /// The contract identifier. + /// + [JsonProperty("contract_id")] + public Guid ContractId { get; set; } + + /// + /// Gets or sets the estate identifier. + /// + /// + /// The estate identifier. + /// + [JsonProperty("estate_id")] + public Guid EstateId { get; set; } + + /// + /// Gets or sets the operator identifier. + /// + /// + /// The operator identifier. + /// + [JsonProperty("operator_id")] + public Guid OperatorId { get; set; } + + #endregion + } +} \ No newline at end of file diff --git a/TransactionProcessor.DataTransferObjects/Responses/Contract/FeeType.cs b/TransactionProcessor.DataTransferObjects/Responses/Contract/FeeType.cs new file mode 100644 index 00000000..3ec0e665 --- /dev/null +++ b/TransactionProcessor.DataTransferObjects/Responses/Contract/FeeType.cs @@ -0,0 +1,18 @@ +namespace TransactionProcessor.DataTransferObjects.Responses.Contract +{ + /// + /// + /// + public enum FeeType + { + /// + /// The merchant + /// + Merchant, + + /// + /// The service provider + /// + ServiceProvider + } +} \ No newline at end of file diff --git a/TransactionProcessor.DataTransferObjects/Responses/Contract/ProductType.cs b/TransactionProcessor.DataTransferObjects/Responses/Contract/ProductType.cs new file mode 100644 index 00000000..92f2c131 --- /dev/null +++ b/TransactionProcessor.DataTransferObjects/Responses/Contract/ProductType.cs @@ -0,0 +1,13 @@ +namespace TransactionProcessor.DataTransferObjects.Responses.Contract +{ + public enum ProductType + { + NotSet = 0, + + MobileTopup, + + Voucher, + + BillPayment + } +} \ No newline at end of file diff --git a/TransactionProcessor.DataTransferObjects/Responses/Estate/CreateEstateResponse.cs b/TransactionProcessor.DataTransferObjects/Responses/Estate/CreateEstateResponse.cs new file mode 100644 index 00000000..322348d4 --- /dev/null +++ b/TransactionProcessor.DataTransferObjects/Responses/Estate/CreateEstateResponse.cs @@ -0,0 +1,19 @@ +using System; +using System.Diagnostics.CodeAnalysis; +using Newtonsoft.Json; + +namespace TransactionProcessor.DataTransferObjects.Responses.Estate +{ + [ExcludeFromCodeCoverage] + public class CreateEstateResponse + { + /// + /// Gets or sets the name of the estate. + /// + /// + /// The name of the estate. + /// + [JsonProperty("estate_id")] + public Guid EstateId { get; set; } + } +} \ No newline at end of file diff --git a/TransactionProcessor.DataTransferObjects/Responses/Estate/CreateEstateUserResponse.cs b/TransactionProcessor.DataTransferObjects/Responses/Estate/CreateEstateUserResponse.cs new file mode 100644 index 00000000..74355e0e --- /dev/null +++ b/TransactionProcessor.DataTransferObjects/Responses/Estate/CreateEstateUserResponse.cs @@ -0,0 +1,31 @@ +using System; +using System.Diagnostics.CodeAnalysis; +using Newtonsoft.Json; + +namespace TransactionProcessor.DataTransferObjects.Responses.Estate +{ + /// + /// + /// + [ExcludeFromCodeCoverage] + public class CreateEstateUserResponse + { + /// + /// Gets or sets the name of the estate. + /// + /// + /// The name of the estate. + /// + [JsonProperty("estate_id")] + public Guid EstateId { get; set; } + + /// + /// Gets or sets the user identifier. + /// + /// + /// The user identifier. + /// + [JsonProperty("user_id")] + public Guid UserId { get; set; } + } +} \ No newline at end of file diff --git a/TransactionProcessor.DataTransferObjects/Responses/Estate/EstateOperatorResponse.cs b/TransactionProcessor.DataTransferObjects/Responses/Estate/EstateOperatorResponse.cs new file mode 100644 index 00000000..6979af45 --- /dev/null +++ b/TransactionProcessor.DataTransferObjects/Responses/Estate/EstateOperatorResponse.cs @@ -0,0 +1,53 @@ +using System; +using System.Diagnostics.CodeAnalysis; +using Newtonsoft.Json; + +namespace TransactionProcessor.DataTransferObjects.Responses.Estate +{ + [ExcludeFromCodeCoverage] + public class EstateOperatorResponse + { + #region Properties + + /// + /// Gets the name. + /// + /// + /// The name. + /// + [JsonProperty("name")] + public String Name { get; set; } + + /// + /// Gets the operator identifier. + /// + /// + /// The operator identifier. + /// + [JsonProperty("operator_id")] + public Guid OperatorId { get; set; } + + /// + /// Gets a value indicating whether [require custom merchant number]. + /// + /// + /// true if [require custom merchant number]; otherwise, false. + /// + [JsonProperty("require_custom_merchant_number")] + public Boolean RequireCustomMerchantNumber { get; set; } + + /// + /// Gets a value indicating whether [require customterminal number]. + /// + /// + /// true if [require customterminal number]; otherwise, false. + /// + [JsonProperty("require_custom_terminal_number")] + public Boolean RequireCustomTerminalNumber { get; set; } + + [JsonProperty("is_deleted")] + public Boolean IsDeleted { get; set; } + + #endregion + } +} \ No newline at end of file diff --git a/TransactionProcessor.DataTransferObjects/Responses/Estate/EstateResponse.cs b/TransactionProcessor.DataTransferObjects/Responses/Estate/EstateResponse.cs new file mode 100644 index 00000000..1d1687cf --- /dev/null +++ b/TransactionProcessor.DataTransferObjects/Responses/Estate/EstateResponse.cs @@ -0,0 +1,60 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using Newtonsoft.Json; + +namespace TransactionProcessor.DataTransferObjects.Responses.Estate +{ + /// + /// + /// + [ExcludeFromCodeCoverage] + public class EstateResponse + { + #region Properties + + /// + /// Gets or sets the estate identifier. + /// + /// + /// The estate identifier. + /// + [JsonProperty("estate_id")] + public Guid EstateId { get; set; } + + [JsonProperty("estate_reporting_id")] + public Int32 EstateReportingId { get; set; } + + /// + /// Gets or sets the name of the estate. + /// + /// + /// The name of the estate. + /// + [JsonProperty("estate_name")] + public String EstateName { get; set; } + + [JsonProperty("estate_reference")] + public String EstateReference { get; set; } + + /// + /// Gets or sets the operators. + /// + /// + /// The operators. + /// + [JsonProperty("operators")] + public List Operators { get; set; } + + /// + /// Gets or sets the security users. + /// + /// + /// The security users. + /// + [JsonProperty("security_users")] + public List SecurityUsers { get; set; } + + #endregion + } +} \ No newline at end of file diff --git a/TransactionProcessor.DataTransferObjects/Responses/Estate/SecurityUserResponse.cs b/TransactionProcessor.DataTransferObjects/Responses/Estate/SecurityUserResponse.cs new file mode 100644 index 00000000..bfee711a --- /dev/null +++ b/TransactionProcessor.DataTransferObjects/Responses/Estate/SecurityUserResponse.cs @@ -0,0 +1,32 @@ +using System; +using System.Diagnostics.CodeAnalysis; +using Newtonsoft.Json; + +namespace TransactionProcessor.DataTransferObjects.Responses.Estate +{ + [ExcludeFromCodeCoverage] + public class SecurityUserResponse + { + #region Properties + + /// + /// Gets or sets the email address. + /// + /// + /// The email address. + /// + [JsonProperty("email_address")] + public String EmailAddress { get; set; } + + /// + /// Gets or sets the security user identifier. + /// + /// + /// The security user identifier. + /// + [JsonProperty("security_user_id")] + public Guid SecurityUserId { get; set; } + + #endregion + } +} \ No newline at end of file diff --git a/TransactionProcessor.DataTransferObjects/Responses/File/FileDetailsResponse.cs b/TransactionProcessor.DataTransferObjects/Responses/File/FileDetailsResponse.cs new file mode 100644 index 00000000..6fdd4fea --- /dev/null +++ b/TransactionProcessor.DataTransferObjects/Responses/File/FileDetailsResponse.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using TransactionProcessor.DataTransferObjects.Responses.Merchant; + +namespace TransactionProcessor.DataTransferObjects.Responses.File{ + public class FileDetailsResponse{ + public Guid FileId{ get; set; } + + public DateTime FileReceivedDate{ get; set; } + + public DateTime FileReceivedDateTime{ get; set; } + + public List FileLineDetails{ get; set; } + + public MerchantResponse Merchant{ get; set; } + } +} \ No newline at end of file diff --git a/TransactionProcessor.DataTransferObjects/Responses/File/FileLineDetailsResponse.cs b/TransactionProcessor.DataTransferObjects/Responses/File/FileLineDetailsResponse.cs new file mode 100644 index 00000000..25483774 --- /dev/null +++ b/TransactionProcessor.DataTransferObjects/Responses/File/FileLineDetailsResponse.cs @@ -0,0 +1,10 @@ +using System; + +namespace TransactionProcessor.DataTransferObjects.Responses.File{ + public class FileLineDetailsResponse{ + public String FileLineData{ get; set; } + public Int32 FileLineNumber { get; set; } + public String Status{ get; set; } + public TransactionResponse Transaction{ get; set; } + } +} \ No newline at end of file diff --git a/TransactionProcessor.DataTransferObjects/Responses/File/TransactionResponse.cs b/TransactionProcessor.DataTransferObjects/Responses/File/TransactionResponse.cs new file mode 100644 index 00000000..b9649035 --- /dev/null +++ b/TransactionProcessor.DataTransferObjects/Responses/File/TransactionResponse.cs @@ -0,0 +1,15 @@ +using System; + +namespace TransactionProcessor.DataTransferObjects.Responses.File +{ + public class TransactionResponse + { + public Guid TransactionId { get; set; } + public String AuthCode { get; set; } + public Boolean IsAuthorised { get; set; } + public Boolean IsCompleted { get; set; } + public String ResponseCode { get; set; } + public String ResponseMessage { get; set; } + public String TransactionNumber { get; set; } + } +} diff --git a/TransactionProcessor.DataTransferObjects/Responses/Merchant/AddMerchantDeviceResponse.cs b/TransactionProcessor.DataTransferObjects/Responses/Merchant/AddMerchantDeviceResponse.cs new file mode 100644 index 00000000..8991e8e6 --- /dev/null +++ b/TransactionProcessor.DataTransferObjects/Responses/Merchant/AddMerchantDeviceResponse.cs @@ -0,0 +1,41 @@ +using System; +using System.Diagnostics.CodeAnalysis; +using Newtonsoft.Json; + +namespace TransactionProcessor.DataTransferObjects.Responses.Merchant +{ + [ExcludeFromCodeCoverage] + public class AddMerchantDeviceResponse + { + #region Properties + + /// + /// Gets or sets the estate identifier. + /// + /// + /// The estate identifier. + /// + [JsonProperty("estate_id")] + public Guid EstateId { get; set; } + + /// + /// Gets or sets the merchant identifier. + /// + /// + /// The merchant identifier. + /// + [JsonProperty("merchant_id")] + public Guid MerchantId { get; set; } + + /// + /// Gets or sets the device identifier. + /// + /// + /// The device identifier. + /// + [JsonProperty("device_id")] + public Guid DeviceId { get; set; } + + #endregion + } +} diff --git a/TransactionProcessor.DataTransferObjects/Responses/Merchant/AddressResponse.cs b/TransactionProcessor.DataTransferObjects/Responses/Merchant/AddressResponse.cs new file mode 100644 index 00000000..7a1cc17a --- /dev/null +++ b/TransactionProcessor.DataTransferObjects/Responses/Merchant/AddressResponse.cs @@ -0,0 +1,95 @@ +using System; +using System.Diagnostics.CodeAnalysis; +using Newtonsoft.Json; + +namespace TransactionProcessor.DataTransferObjects.Responses.Merchant +{ + [ExcludeFromCodeCoverage] + public class AddressResponse + { + #region Properties + + /// + /// Gets or sets the address identifier. + /// + /// + /// The address identifier. + /// + [JsonProperty("address_id")] + public Guid AddressId { get; set; } + + /// + /// Gets the address line1. + /// + /// + /// The address line1. + /// + [JsonProperty("address_line_1")] + public String AddressLine1 { get; set; } + + /// + /// Gets the address line2. + /// + /// + /// The address line2. + /// + [JsonProperty("address_line_2")] + public String AddressLine2 { get; set; } + + /// + /// Gets the address line3. + /// + /// + /// The address line3. + /// + [JsonProperty("address_line_3")] + public String AddressLine3 { get; set; } + + /// + /// Gets the address line4. + /// + /// + /// The address line4. + /// + [JsonProperty("address_line_4")] + public String AddressLine4 { get; set; } + + /// + /// Gets the country. + /// + /// + /// The country. + /// + [JsonProperty("country")] + public String Country { get; set; } + + /// + /// Gets the postal code. + /// + /// + /// The postal code. + /// + [JsonProperty("postal_code")] + public String PostalCode { get; set; } + + /// + /// Gets the region. + /// + /// + /// The region. + /// + [JsonProperty("region")] + public String Region { get; set; } + + /// + /// Gets the town. + /// + /// + /// The town. + /// + [JsonProperty("town")] + public String Town { get; set; } + + #endregion + } +} \ No newline at end of file diff --git a/TransactionProcessor.DataTransferObjects/Responses/Merchant/AssignOperatorResponse.cs b/TransactionProcessor.DataTransferObjects/Responses/Merchant/AssignOperatorResponse.cs new file mode 100644 index 00000000..4b2dc4e6 --- /dev/null +++ b/TransactionProcessor.DataTransferObjects/Responses/Merchant/AssignOperatorResponse.cs @@ -0,0 +1,44 @@ +using System; +using System.Diagnostics.CodeAnalysis; +using Newtonsoft.Json; + +namespace TransactionProcessor.DataTransferObjects.Responses.Merchant +{ + /// + /// + /// + [ExcludeFromCodeCoverage] + public class AssignOperatorResponse + { + #region Properties + + /// + /// Gets or sets the estate identifier. + /// + /// + /// The estate identifier. + /// + [JsonProperty("estate_id")] + public Guid EstateId { get; set; } + + /// + /// Gets or sets the merchant identifier. + /// + /// + /// The merchant identifier. + /// + [JsonProperty("merchant_id")] + public Guid MerchantId { get; set; } + + /// + /// Gets or sets the operator identifier. + /// + /// + /// The operator identifier. + /// + [JsonProperty("operator_id")] + public Guid OperatorId { get; set; } + + #endregion + } +} \ No newline at end of file diff --git a/TransactionProcessor.DataTransferObjects/Responses/Merchant/CreateMerchantResponse.cs b/TransactionProcessor.DataTransferObjects/Responses/Merchant/CreateMerchantResponse.cs new file mode 100644 index 00000000..1df62a1e --- /dev/null +++ b/TransactionProcessor.DataTransferObjects/Responses/Merchant/CreateMerchantResponse.cs @@ -0,0 +1,35 @@ +using System; +using System.Diagnostics.CodeAnalysis; +using Newtonsoft.Json; + +namespace TransactionProcessor.DataTransferObjects.Responses.Merchant +{ + /// + /// + /// + [ExcludeFromCodeCoverage] + public class CreateMerchantResponse + { + #region Properties + + /// + /// Gets or sets the estate identifier. + /// + /// + /// The estate identifier. + /// + [JsonProperty("estate_id")] + public Guid EstateId { get; set; } + + /// + /// Gets or sets the merchant identifier. + /// + /// + /// The merchant identifier. + /// + [JsonProperty("merchant_id")] + public Guid MerchantId { get; set; } + + #endregion + } +} \ No newline at end of file diff --git a/TransactionProcessor.DataTransferObjects/Responses/Merchant/CreateMerchantUserResponse.cs b/TransactionProcessor.DataTransferObjects/Responses/Merchant/CreateMerchantUserResponse.cs new file mode 100644 index 00000000..dc63caae --- /dev/null +++ b/TransactionProcessor.DataTransferObjects/Responses/Merchant/CreateMerchantUserResponse.cs @@ -0,0 +1,41 @@ +using System; +using System.Diagnostics.CodeAnalysis; +using Newtonsoft.Json; + +namespace TransactionProcessor.DataTransferObjects.Responses.Merchant +{ + [ExcludeFromCodeCoverage] + public class CreateMerchantUserResponse + { + #region Properties + + /// + /// Gets or sets the name of the estate. + /// + /// + /// The name of the estate. + /// + [JsonProperty("estate_id")] + public Guid EstateId { get; set; } + + /// + /// Gets or sets the merchant identifier. + /// + /// + /// The merchant identifier. + /// + [JsonProperty("merchant_id")] + public Guid MerchantId { get; set; } + + /// + /// Gets or sets the user identifier. + /// + /// + /// The user identifier. + /// + [JsonProperty("user_id")] + public Guid UserId { get; set; } + + #endregion + } +} \ No newline at end of file diff --git a/TransactionProcessor.DataTransferObjects/Responses/Merchant/GenerateMerchantStatementResponse.cs b/TransactionProcessor.DataTransferObjects/Responses/Merchant/GenerateMerchantStatementResponse.cs new file mode 100644 index 00000000..48bb62bc --- /dev/null +++ b/TransactionProcessor.DataTransferObjects/Responses/Merchant/GenerateMerchantStatementResponse.cs @@ -0,0 +1,15 @@ +using System; +using Newtonsoft.Json; + +namespace TransactionProcessor.DataTransferObjects.Responses.Merchant +{ + public class GenerateMerchantStatementResponse + { + [JsonProperty("merchant_statement_id")] + public Guid MerchantStatementId { get; set; } + [JsonProperty("merchant_id")] + public Guid MerchantId { get; set; } + [JsonProperty("estate_id")] + public Guid EstateId { get; set; } + } +} \ No newline at end of file diff --git a/TransactionProcessor.DataTransferObjects/Responses/Merchant/MakeMerchantDepositResponse.cs b/TransactionProcessor.DataTransferObjects/Responses/Merchant/MakeMerchantDepositResponse.cs new file mode 100644 index 00000000..efd29295 --- /dev/null +++ b/TransactionProcessor.DataTransferObjects/Responses/Merchant/MakeMerchantDepositResponse.cs @@ -0,0 +1,41 @@ +using System; +using System.Diagnostics.CodeAnalysis; +using Newtonsoft.Json; + +namespace TransactionProcessor.DataTransferObjects.Responses.Merchant +{ + [ExcludeFromCodeCoverage] + public class MakeMerchantDepositResponse + { + #region Properties + + /// + /// Gets or sets the estate identifier. + /// + /// + /// The estate identifier. + /// + [JsonProperty("estate_id")] + public Guid EstateId { get; set; } + + /// + /// Gets or sets the merchant identifier. + /// + /// + /// The merchant identifier. + /// + [JsonProperty("merchant_id")] + public Guid MerchantId { get; set; } + + /// + /// Gets or sets the device identifier. + /// + /// + /// The device identifier. + /// + [JsonProperty("deposit_id")] + public Guid DepositId { get; set; } + + #endregion + } +} diff --git a/TransactionProcessor.DataTransferObjects/Responses/Merchant/MakeMerchantWithdrawalResponse.cs b/TransactionProcessor.DataTransferObjects/Responses/Merchant/MakeMerchantWithdrawalResponse.cs new file mode 100644 index 00000000..e566dd2a --- /dev/null +++ b/TransactionProcessor.DataTransferObjects/Responses/Merchant/MakeMerchantWithdrawalResponse.cs @@ -0,0 +1,41 @@ +using System; +using System.Diagnostics.CodeAnalysis; +using Newtonsoft.Json; + +namespace TransactionProcessor.DataTransferObjects.Responses.Merchant +{ + [ExcludeFromCodeCoverage] + public class MakeMerchantWithdrawalResponse + { + #region Properties + + /// + /// Gets or sets the estate identifier. + /// + /// + /// The estate identifier. + /// + [JsonProperty("estate_id")] + public Guid EstateId { get; set; } + + /// + /// Gets or sets the merchant identifier. + /// + /// + /// The merchant identifier. + /// + [JsonProperty("merchant_id")] + public Guid MerchantId { get; set; } + + /// + /// Gets or sets the withdrawal identifier. + /// + /// + /// The withdrawal identifier. + /// + [JsonProperty("withdrawal_id")] + public Guid WithdrawalId { get; set; } + + #endregion + } +} \ No newline at end of file diff --git a/TransactionProcessor.DataTransferObjects/Responses/Merchant/MerchantContractResponse.cs b/TransactionProcessor.DataTransferObjects/Responses/Merchant/MerchantContractResponse.cs new file mode 100644 index 00000000..a131e64f --- /dev/null +++ b/TransactionProcessor.DataTransferObjects/Responses/Merchant/MerchantContractResponse.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using Newtonsoft.Json; + +namespace TransactionProcessor.DataTransferObjects.Responses.Merchant{ + [ExcludeFromCodeCoverage] + public class MerchantContractResponse + { + [JsonProperty("contract_id")] + public Guid ContractId { get; set; } + + [JsonProperty("is_deleted")] + public Boolean IsDeleted { get; set; } + + [JsonProperty("contract_products")] + public List ContractProducts { get; set; } + + public MerchantContractResponse() + { + this.ContractProducts = new List(); + } + } +} \ No newline at end of file diff --git a/TransactionProcessor.DataTransferObjects/Responses/Merchant/MerchantOperatorResponse.cs b/TransactionProcessor.DataTransferObjects/Responses/Merchant/MerchantOperatorResponse.cs new file mode 100644 index 00000000..addd06d9 --- /dev/null +++ b/TransactionProcessor.DataTransferObjects/Responses/Merchant/MerchantOperatorResponse.cs @@ -0,0 +1,53 @@ +using System; +using System.Diagnostics.CodeAnalysis; +using Newtonsoft.Json; + +namespace TransactionProcessor.DataTransferObjects.Responses.Merchant +{ + [ExcludeFromCodeCoverage] + public class MerchantOperatorResponse + { + #region Properties + + /// + /// Gets the name. + /// + /// + /// The name. + /// + [JsonProperty("name")] + public String Name { get; set; } + + /// + /// Gets the operator identifier. + /// + /// + /// The operator identifier. + /// + [JsonProperty("operator_id")] + public Guid OperatorId { get; set; } + + /// + /// Gets or sets the merchant number. + /// + /// + /// The merchant number. + /// + [JsonProperty("merchant_number")] + public String MerchantNumber { get; set; } + + /// + /// Gets or sets the terminal number. + /// + /// + /// The terminal number. + /// + [JsonProperty("terminal_number")] + public String TerminalNumber { get; set; } + + [JsonProperty("is_deleted")] + public Boolean IsDeleted { get; set; } + + #endregion + } +} \ No newline at end of file diff --git a/TransactionProcessor.DataTransferObjects/Responses/Merchant/MerchantResponse.cs b/TransactionProcessor.DataTransferObjects/Responses/Merchant/MerchantResponse.cs new file mode 100644 index 00000000..29d9ae6e --- /dev/null +++ b/TransactionProcessor.DataTransferObjects/Responses/Merchant/MerchantResponse.cs @@ -0,0 +1,116 @@ +using System; +using System.Collections.Generic; +using Newtonsoft.Json; +using TransactionProcessor.DataTransferObjects.Responses.Contract; + +namespace TransactionProcessor.DataTransferObjects.Responses.Merchant +{ + /// + /// + /// + public class MerchantResponse + { + #region Properties + + /// + /// Gets or sets the addresses. + /// + /// + /// The addresses. + /// + [JsonProperty("addresses")] + public List Addresses { get; set; } + + /// + /// Gets or sets the contacts. + /// + /// + /// The contacts. + /// + [JsonProperty("contacts")] + public List Contacts { get; set; } + + /// + /// Gets or sets the devices. + /// + /// + /// The devices. + /// + [JsonProperty("devices")] + public Dictionary Devices { get; set; } + + /// + /// Gets or sets the estate identifier. + /// + /// + /// The estate identifier. + /// + [JsonProperty("estate_id")] + public Guid EstateId { get; set; } + + [JsonProperty("estate_reporting_id")] + public Int32 EstateReportingId { get; set; } + + /// + /// Gets or sets the merchant identifier. + /// + /// + /// The merchant identifier. + /// + [JsonProperty("merchant_id")] + public Guid MerchantId { get; set; } + + [JsonProperty("merchant_reporting_id")] + public Int32 MerchantReportingId { get; set; } + + /// + /// Gets or sets the name of the merchant. + /// + /// + /// The name of the merchant. + /// + [JsonProperty("merchant_name")] + public String MerchantName { get; set; } + + /// + /// Gets or sets the merchant reference. + /// + /// + /// The merchant reference. + /// + [JsonProperty("merchant_reference")] + public String MerchantReference { get; set; } + + /// + /// Gets or sets the next statement date. + /// + /// + /// The next statement date. + /// + [JsonProperty("next_statement_date")] + public DateTime NextStatementDate { get; set; } + + /// + /// Gets or sets the operators. + /// + /// + /// The operators. + /// + [JsonProperty("operators")] + public List Operators { get; set; } + + /// + /// Gets or sets the settlement schedule. + /// + /// + /// The settlement schedule. + /// + [JsonProperty("settlement_schedule")] + public SettlementSchedule SettlementSchedule { get; set; } + + [JsonProperty("contracts")] + public List Contracts { get; set; } + + #endregion + } +} \ No newline at end of file diff --git a/TransactionProcessor.DataTransferObjects/Responses/Merchant/SettlementSchedule.cs b/TransactionProcessor.DataTransferObjects/Responses/Merchant/SettlementSchedule.cs new file mode 100644 index 00000000..bd875a58 --- /dev/null +++ b/TransactionProcessor.DataTransferObjects/Responses/Merchant/SettlementSchedule.cs @@ -0,0 +1,10 @@ +namespace TransactionProcessor.DataTransferObjects.Responses.Merchant +{ + public enum SettlementSchedule + { + NotSet, + Immediate, + Weekly, + Monthly + } +} \ No newline at end of file diff --git a/TransactionProcessor.DataTransferObjects/Responses/Merchant/SwapMerchantDeviceResponse.cs b/TransactionProcessor.DataTransferObjects/Responses/Merchant/SwapMerchantDeviceResponse.cs new file mode 100644 index 00000000..04a9e491 --- /dev/null +++ b/TransactionProcessor.DataTransferObjects/Responses/Merchant/SwapMerchantDeviceResponse.cs @@ -0,0 +1,41 @@ +using System; +using System.Diagnostics.CodeAnalysis; +using Newtonsoft.Json; + +namespace TransactionProcessor.DataTransferObjects.Responses.Merchant +{ + [ExcludeFromCodeCoverage] + public class SwapMerchantDeviceResponse + { + #region Properties + + /// + /// Gets or sets the estate identifier. + /// + /// + /// The estate identifier. + /// + [JsonProperty("estate_id")] + public Guid EstateId { get; set; } + + /// + /// Gets or sets the merchant identifier. + /// + /// + /// The merchant identifier. + /// + [JsonProperty("merchant_id")] + public Guid MerchantId { get; set; } + + /// + /// Gets or sets the device identifier. + /// + /// + /// The device identifier. + /// + [JsonProperty("device_id")] + public Guid DeviceId { get; set; } + + #endregion + } +} \ No newline at end of file diff --git a/TransactionProcessor.DataTransferObjects/Responses/Operator/CreateOperatorResponse.cs b/TransactionProcessor.DataTransferObjects/Responses/Operator/CreateOperatorResponse.cs new file mode 100644 index 00000000..9ab08661 --- /dev/null +++ b/TransactionProcessor.DataTransferObjects/Responses/Operator/CreateOperatorResponse.cs @@ -0,0 +1,32 @@ +using System; +using System.Diagnostics.CodeAnalysis; +using Newtonsoft.Json; + +namespace TransactionProcessor.DataTransferObjects.Responses.Operator +{ + [ExcludeFromCodeCoverage] + public class CreateOperatorResponse + { + #region Properties + + /// + /// Gets or sets the estate identifier. + /// + /// + /// The estate identifier. + /// + [JsonProperty("estate_id")] + public Guid EstateId { get; set; } + + /// + /// Gets or sets the estate identifier. + /// + /// + /// The estate identifier. + /// + [JsonProperty("operator_id")] + public Guid OperatorId { get; set; } + + #endregion + } +} \ No newline at end of file diff --git a/TransactionProcessor.DataTransferObjects/Responses/Operator/OperatorResponse.cs b/TransactionProcessor.DataTransferObjects/Responses/Operator/OperatorResponse.cs new file mode 100644 index 00000000..573df9e3 --- /dev/null +++ b/TransactionProcessor.DataTransferObjects/Responses/Operator/OperatorResponse.cs @@ -0,0 +1,46 @@ +using System; +using Newtonsoft.Json; + +namespace TransactionProcessor.DataTransferObjects.Responses.Operator +{ + public class OperatorResponse + { + /// + /// Gets the name. + /// + /// + /// The name. + /// + [JsonProperty("name")] + public String Name { get; set; } + + /// + /// Gets the operator identifier. + /// + /// + /// The operator identifier. + /// + [JsonProperty("operator_id")] + public Guid OperatorId { get; set; } + + /// + /// Gets a value indicating whether [require custom merchant number]. + /// + /// + /// true if [require custom merchant number]; otherwise, false. + /// + [JsonProperty("require_custom_merchant_number")] + public Boolean RequireCustomMerchantNumber { get; set; } + + /// + /// Gets a value indicating whether [require customterminal number]. + /// + /// + /// true if [require customterminal number]; otherwise, false. + /// + [JsonProperty("require_custom_terminal_number")] + public Boolean RequireCustomTerminalNumber { get; set; } + + + } +} diff --git a/TransactionProcessor.DataTransferObjects/Responses/Settlement/SettlementFeeResponse.cs b/TransactionProcessor.DataTransferObjects/Responses/Settlement/SettlementFeeResponse.cs new file mode 100644 index 00000000..5bfaacee --- /dev/null +++ b/TransactionProcessor.DataTransferObjects/Responses/Settlement/SettlementFeeResponse.cs @@ -0,0 +1,41 @@ +using System; +using System.Diagnostics.CodeAnalysis; +using Newtonsoft.Json; + +namespace TransactionProcessor.DataTransferObjects.Responses.Settlement +{ + [ExcludeFromCodeCoverage] + public class SettlementFeeResponse + { + #region Properties + + [JsonProperty("calculated_value")] + public Decimal CalculatedValue { get; set; } + + [JsonProperty("fee_description")] + public String FeeDescription { get; set; } + + [JsonProperty("is_settled")] + public Boolean IsSettled { get; set; } + + [JsonProperty("merchant_id")] + public Guid MerchantId { get; set; } + + [JsonProperty("merchant_name")] + public String MerchantName { get; set; } + + [JsonProperty("settlement_date")] + public DateTime SettlementDate { get; set; } + + [JsonProperty("settlement_id")] + public Guid SettlementId { get; set; } + + [JsonProperty("transaction_id")] + public Guid TransactionId { get; set; } + + [JsonProperty("operator_identifier")] + public String OperatorIdentifier { get; set; } + + #endregion + } +} \ No newline at end of file diff --git a/TransactionProcessor.DataTransferObjects/Responses/Settlement/SettlementResponse.cs b/TransactionProcessor.DataTransferObjects/Responses/Settlement/SettlementResponse.cs new file mode 100644 index 00000000..8c7ec957 --- /dev/null +++ b/TransactionProcessor.DataTransferObjects/Responses/Settlement/SettlementResponse.cs @@ -0,0 +1,42 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using Newtonsoft.Json; + +namespace TransactionProcessor.DataTransferObjects.Responses.Settlement +{ + [ExcludeFromCodeCoverage] + public class SettlementResponse + { + #region Constructors + + public SettlementResponse() + { + this.SettlementFees = new List(); + } + + #endregion + + #region Properties + + [JsonProperty("is_completed")] + public Boolean IsCompleted { get; set; } + + [JsonProperty("number_of_fees_settled")] + public Int32 NumberOfFeesSettled { get; set; } + + [JsonProperty("settlement_date")] + public DateTime SettlementDate { get; set; } + + [JsonProperty("settlement_fees")] + public List SettlementFees { get; set; } + + [JsonProperty("settlement_id")] + public Guid SettlementId { get; set; } + + [JsonProperty("value_of_fees_settled")] + public Decimal ValueOfFeesSettled { get; set; } + + #endregion + } +} \ No newline at end of file diff --git a/TransactionProcessor.DataTransferObjects/TransactionProcessor.DataTransferObjects.csproj b/TransactionProcessor.DataTransferObjects/TransactionProcessor.DataTransferObjects.csproj index 476ab059..44da5063 100644 --- a/TransactionProcessor.DataTransferObjects/TransactionProcessor.DataTransferObjects.csproj +++ b/TransactionProcessor.DataTransferObjects/TransactionProcessor.DataTransferObjects.csproj @@ -14,4 +14,8 @@ + + + + diff --git a/TransactionProcessor.Database/Contexts/EstateManagementGenericContext.cs b/TransactionProcessor.Database/Contexts/EstateManagementGenericContext.cs new file mode 100644 index 00000000..3a6c9af6 --- /dev/null +++ b/TransactionProcessor.Database/Contexts/EstateManagementGenericContext.cs @@ -0,0 +1,581 @@ +using System.Reflection; +using EntityFramework.Exceptions.Common; +using Microsoft.EntityFrameworkCore; +using Shared.DomainDrivenDesign.EventSourcing; +using Shared.Exceptions; +using Shared.Logger; +using SimpleResults; +using TransactionProcessor.Database.Entities; +using TransactionProcessor.Database.Entities.Summary; +using TransactionProcessor.Database.ViewEntities; +using File = TransactionProcessor.Database.Entities.File; + +namespace TransactionProcessor.Database.Contexts; + +public abstract class EstateManagementGenericContext : DbContext +{ + #region Fields + + protected readonly String ConnectionString; + + protected readonly String DatabaseEngine; + + protected static List TablesToIgnoreDuplicates = new List(); + + #endregion + + #region Constructors + + protected EstateManagementGenericContext(String databaseEngine, + String connectionString) + { + this.DatabaseEngine = databaseEngine; + this.ConnectionString = connectionString; + } + + public EstateManagementGenericContext(DbContextOptions dbContextOptions) : base(dbContextOptions) + { + } + + #endregion + + #region Properties + + public DbSet Calendar { get; set; } + + public DbSet ContractProducts { get; set; } + + public DbSet ContractProductTransactionFees { get; set; } + + public DbSet Contracts { get; set; } + + public DbSet Operators { get; set; } + + public DbSet Estates { get; set; } + + public DbSet EstateSecurityUsers { get; set; } + + public virtual DbSet FileImportLogFiles { get; set; } + + public virtual DbSet FileImportLogs { get; set; } + + public virtual DbSet FileLines { get; set; } + + public virtual DbSet Files { get; set; } + public DbSet Floats { get; set; } + public DbSet FloatActivity { get; set; } + + public DbSet MerchantAddresses { get; set; } + + public DbSet MerchantContacts { get; set; } + + public DbSet MerchantDevices { get; set; } + + public DbSet MerchantOperators { get; set; } + + public DbSet Merchants { get; set; } + + public DbSet MerchantSecurityUsers { get; set; } + + public DbSet MerchantSettlementFees { get; set; } + + public DbSet Reconciliations { get; set; } + + public DbSet ResponseCodes { get; set; } + + public DbSet Settlements { get; set; } + + public virtual DbSet SettlementsView { get; set; } + + public DbSet StatementHeaders { get; set; } + + public DbSet StatementLines { get; set; } + + public DbSet Transactions { get; set; } + + public DbSet TransactionsAdditionalRequestData { get; set; } + + public DbSet TransactionsAdditionalResponseData { get; set; } + + public DbSet Vouchers { get; set; } + + public DbSet MerchantContracts { get; set; } + + public DbSet SettlementSummary { get; set; } + public DbSet TodayTransactions { get; set; } + public DbSet TransactionHistory { get; set; } + + #endregion + + #region Methods + + private async Task CreateStoredProcedures(CancellationToken cancellationToken) + { + String executingAssemblyLocation = Assembly.GetExecutingAssembly().Location; + String executingAssemblyFolder = Path.GetDirectoryName(executingAssemblyLocation); + + String scriptsFolder = $@"{executingAssemblyFolder}/StoredProcedures/{this.DatabaseEngine}"; + + String[] directories = Directory.GetDirectories(scriptsFolder); + if (directories.Length == 0) + { + var list = new List { scriptsFolder }; + directories = list.ToArray(); + } + directories = directories.OrderBy(d => d).ToArray(); + + foreach (String directiory in directories) + { + String[] sqlFiles = Directory.GetFiles(directiory, "*.sql"); + foreach (String sqlFile in sqlFiles.OrderBy(x => x)) + { + Logger.LogInformation($"About to create Stored Procedure [{sqlFile}]"); + String sql = System.IO.File.ReadAllText(sqlFile); + + // Check here is we need to replace a Database Name + if (sql.Contains("{DatabaseName}")) + { + sql = sql.Replace("{DatabaseName}", this.Database.GetDbConnection().Database); + } + + // Create the new view using the original sql from file + await this.Database.ExecuteSqlRawAsync(sql, cancellationToken); + + Logger.LogInformation($"Created Stored Procedure [{sqlFile}] successfully."); + } + } + } + + private async Task CreateViews(CancellationToken cancellationToken) + { + String executingAssemblyLocation = Assembly.GetExecutingAssembly().Location; + String executingAssemblyFolder = Path.GetDirectoryName(executingAssemblyLocation); + + String scriptsFolder = $@"{executingAssemblyFolder}/Views/{this.DatabaseEngine}"; + + String[] directiories = Directory.GetDirectories(scriptsFolder); + directiories = directiories.OrderBy(d => d).ToArray(); + + foreach (String directiory in directiories) + { + String[] sqlFiles = Directory.GetFiles(directiory, "*View.sql"); + foreach (String sqlFile in sqlFiles.OrderBy(x => x)) + { + Logger.LogInformation($"About to create View [{sqlFile}]"); + String sql = System.IO.File.ReadAllText(sqlFile); + + // Check here is we need to replace a Database Name + if (sql.Contains("{DatabaseName}")) + { + sql = sql.Replace("{DatabaseName}", this.Database.GetDbConnection().Database); + } + + // Create the new view using the original sql from file + await this.Database.ExecuteSqlRawAsync(sql, cancellationToken); + + Logger.LogInformation($"Created View [{sqlFile}] successfully."); + } + } + } + + private async Task SeedStandingData(CancellationToken cancellationToken) + { + String executingAssemblyLocation = Assembly.GetExecutingAssembly().Location; + String executingAssemblyFolder = Path.GetDirectoryName(executingAssemblyLocation); + + String scriptsFolder = $@"{executingAssemblyFolder}/SeedingScripts"; ///{this.DatabaseEngine}"; + + String[] sqlFiles = Directory.GetFiles(scriptsFolder, "*.sql"); + foreach (String sqlFile in sqlFiles.OrderBy(x => x)) + { + Logger.LogDebug($"About to create View [{sqlFile}]"); + String sql = System.IO.File.ReadAllText(sqlFile); + + // Check here is we need to replace a Database Name + if (sql.Contains("{DatabaseName}")) + { + sql = sql.Replace("{DatabaseName}", this.Database.GetDbConnection().Database); + } + + // Create the new view using the original sql from file + await this.Database.ExecuteSqlRawAsync(sql, cancellationToken); + + Logger.LogInformation($"Run Seeding Script [{sqlFile}] successfully."); + } + } + + public static Boolean IsDuplicateInsertsIgnored(String tableName) => + EstateManagementGenericContext.TablesToIgnoreDuplicates.Contains(tableName.Trim(), StringComparer.InvariantCultureIgnoreCase); + + public virtual async Task MigrateAsync(CancellationToken cancellationToken) + { + if (this.Database.IsSqlServer() || this.Database.IsMySql()) + { + await this.Database.MigrateAsync(cancellationToken); + await this.SetIgnoreDuplicates(cancellationToken); + await this.CreateViews(cancellationToken); + await this.SeedStandingData(cancellationToken); + } + + if (this.Database.IsSqlServer()) + { + await this.CreateStoredProcedures(cancellationToken); + } + } + + protected override void OnModelCreating(ModelBuilder modelBuilder) + { + modelBuilder.SetupResponseCodes() + .SetupEstate() + .SetupEstateSecurityUser() + .SetupMerchant() + .SetupMerchantAddress() + .SetupMerchantContact() + .SetupMerchantDevice() + .SetupMerchantDevice() + .SetupMerchantOperator() + .SetupMerchantSecurityUser() + .SetupContract() + .SetupContractProduct() + .SetupContractProductTransactionFee() + .SetupTransaction() + .SetupTransactionAdditionalResponseData() + .SetupTransactionAdditionalRequestData() + .SetupSettlement() + .SetupMerchantSettlementFee() + .SetupFile() + .SetupFileImportLog() + .SetupFileImportLogFile() + .SetupFileLine() + .SetupStatementHeader() + .SetupStatementLine() + .SetupReconciliation() + .SetupVoucher() + .SetupMerchantContract() + .SetupFloat() + .SetupFloatActivity() + .SetupOperator() + .SetupSettlementSummary() + .SetupTransactionHistory() + .SetupTodaysTransactions(); + + modelBuilder.SetupViewEntities(); + + base.OnModelCreating(modelBuilder); + } + + protected virtual async Task SetIgnoreDuplicates(CancellationToken cancellationToken) + { + EstateManagementGenericContext.TablesToIgnoreDuplicates = new List { + nameof(this.ResponseCodes) + }; + } + + public new async Task SaveChangesAsync(CancellationToken cancellationToken) { + try { + await base.SaveChangesAsync(cancellationToken); + return Result.Success(); + } + catch (Exception ex) { + return Result.Failure(ex.GetExceptionMessages()); + } + } + + public virtual async Task SaveChangesWithDuplicateHandling(CancellationToken cancellationToken) + { + try + { + await base.SaveChangesAsync(cancellationToken); + return Result.Success(); + } + catch (UniqueConstraintException uex) + { + // Swallow the error + Logger.LogWarning(BuildUniqueConstraintExceptionLogMessage(uex)); + return Result.Success(); + } + } + + private static String BuildUniqueConstraintExceptionLogMessage(UniqueConstraintException uex) { + String constraintName = "N/A"; + if (String.IsNullOrEmpty(uex.ConstraintName) == false) { + constraintName = uex.ConstraintName; + } + String constraintProperties = "N/A"; + if (uex.ConstraintProperties != null) { + constraintProperties = String.Join(",", uex.ConstraintProperties); + } + return $"Unique Constraint Exception. Message [{uex.Message}] Inner Exception [{uex.InnerException.Message}]"; + + } + + + #endregion +} + +public static class EstateManagementGenericContextExtensions { + public static async Task> LoadEstate(this EstateManagementGenericContext context, IDomainEvent domainEvent, CancellationToken cancellationToken) + { + Guid estateId = DomainEventHelper.GetEstateId(domainEvent); + Estate estate = await context.Estates.SingleOrDefaultAsync(e => e.EstateId == estateId, cancellationToken); + return estate switch + { + null => Result.NotFound($"Estate not found with Id {estateId}"), + _ => Result.Success(estate) + }; + } + + public static async Task> LoadOperator(this EstateManagementGenericContext context, Guid operatorId, CancellationToken cancellationToken) + { + Operator @operator = await context.Operators.SingleOrDefaultAsync(e => e.OperatorId == operatorId, cancellationToken); + + return @operator switch + { + null => Result.NotFound($"Operator not found with Id {operatorId}"), + _ => Result.Success(@operator) + }; + } + + public static async Task> LoadOperator(this EstateManagementGenericContext context, IDomainEvent domainEvent, CancellationToken cancellationToken) + { + Guid operatorId = DomainEventHelper.GetOperatorId(domainEvent); + Result loadOperatorResult = await context.LoadOperator(operatorId, cancellationToken); + + return loadOperatorResult; + } + + public static async Task> LoadMerchantDevice(this EstateManagementGenericContext context, IDomainEvent domainEvent, CancellationToken cancellationToken) + { + Guid merchantId = DomainEventHelper.GetMerchantId(domainEvent); + Guid deviceId = DomainEventHelper.GetDeviceId(domainEvent); + MerchantDevice device = await context.MerchantDevices.SingleOrDefaultAsync(d => d.DeviceId == deviceId && + d.MerchantId == merchantId, cancellationToken); + + return device switch + { + null => Result.NotFound($"Device Id {deviceId} not found for Merchant {merchantId}"), + _ => Result.Success(device) + }; + } + + public static async Task> LoadFile(this EstateManagementGenericContext context, IDomainEvent domainEvent, CancellationToken cancellationToken) + { + Guid fileId = DomainEventHelper.GetFileId(domainEvent); + File file = await context.Files.SingleOrDefaultAsync(e => e.FileId == fileId, cancellationToken: cancellationToken); + + return file switch + { + null => Result.NotFound($"File not found with Id {fileId}"), + _ => Result.Success(file) + }; + } + + public static async Task> LoadMerchant(this EstateManagementGenericContext context, IDomainEvent domainEvent, CancellationToken cancellationToken) + { + Guid merchantId = DomainEventHelper.GetMerchantId(domainEvent); + Merchant merchant = await context.Merchants.SingleOrDefaultAsync(e => e.MerchantId == merchantId, cancellationToken: cancellationToken); + return merchant switch + { + null => Result.NotFound($"Merchant not found with Id {merchantId}"), + _ => Result.Success(merchant) + }; + } + + public static async Task> LoadMerchantAddress(this EstateManagementGenericContext context, IDomainEvent domainEvent, CancellationToken cancellationToken) + { + Guid merchantId = DomainEventHelper.GetMerchantId(domainEvent); + Guid addressId = DomainEventHelper.GetAddressId(domainEvent); + + MerchantAddress merchantAddress = await context.MerchantAddresses.SingleOrDefaultAsync(e => e.MerchantId == merchantId && + e.AddressId == addressId, cancellationToken: cancellationToken); + + return merchantAddress switch + { + null => Result.NotFound($"Merchant Address {addressId} not found with merchant Id {merchantId}"), + _ => Result.Success(merchantAddress) + }; + } + + public static async Task> LoadMerchantContact(this EstateManagementGenericContext context, IDomainEvent domainEvent, CancellationToken cancellationToken) + { + Guid merchantId = DomainEventHelper.GetMerchantId(domainEvent); + + Guid contactId = DomainEventHelper.GetContactId(domainEvent); + MerchantContact merchantContact = await context.MerchantContacts.SingleOrDefaultAsync(e => e.MerchantId == merchantId && + e.ContactId == contactId, cancellationToken: cancellationToken); + return merchantContact switch + { + null => Result.NotFound($"Merchant Contact {contactId} not found with merchant Id {merchantId}"), + _ => Result.Success(merchantContact) + }; + } + + public static async Task> LoadReconcilation(this EstateManagementGenericContext context, IDomainEvent domainEvent, CancellationToken cancellationToken) + { + Guid transactionId = DomainEventHelper.GetTransactionId(domainEvent); + Reconciliation reconciliation = + await context.Reconciliations.SingleOrDefaultAsync(t => t.TransactionId == transactionId, cancellationToken: cancellationToken); + return reconciliation switch + { + null => Result.NotFound($"Reconciliation not found with Id {transactionId}"), + _ => Result.Success(reconciliation) + }; + } + + public static async Task> LoadSettlement(this EstateManagementGenericContext context, IDomainEvent domainEvent, CancellationToken cancellationToken) + { + Guid settlementId = DomainEventHelper.GetSettlementId(domainEvent); + Settlement settlement = await context.Settlements.SingleOrDefaultAsync(e => e.SettlementId == settlementId, cancellationToken: cancellationToken); + + return settlement switch + { + null => Result.NotFound($"Settlement not found with Id {settlementId}"), + _ => Result.Success(settlement) + }; + } + + public static async Task> LoadStatementHeader(this EstateManagementGenericContext context, IDomainEvent domainEvent, CancellationToken cancellationToken) + { + Guid statementHeaderId = DomainEventHelper.GetStatementHeaderId(domainEvent); + StatementHeader statementHeader = await context.StatementHeaders.SingleOrDefaultAsync(e => e.StatementId == statementHeaderId, cancellationToken: cancellationToken); + + return statementHeader switch + { + null => Result.NotFound($"Statement Header not found with Id {statementHeaderId}"), + _ => Result.Success(statementHeader) + }; + } + + public static async Task> LoadTransaction(this EstateManagementGenericContext context, IDomainEvent domainEvent, CancellationToken cancellationToken) + { + Guid transactionId = DomainEventHelper.GetTransactionId(domainEvent); + Transaction transaction = await context.Transactions.SingleOrDefaultAsync(e => e.TransactionId == transactionId, cancellationToken: cancellationToken); + + return transaction switch + { + null => Result.NotFound($"Transaction not found with Id {transactionId}"), + _ => Result.Success(transaction) + }; + } + + public static async Task> LoadVoucher(this EstateManagementGenericContext context, IDomainEvent domainEvent, CancellationToken cancellationToken) + { + Guid voucherId = DomainEventHelper.GetVoucherId(domainEvent); + Voucher voucher = await context.Vouchers.SingleOrDefaultAsync(v => v.VoucherId == voucherId, cancellationToken); + + return voucher switch + { + null => Result.NotFound($"Voucher not found with Id {voucherId}"), + _ => Result.Success(voucher) + }; + } + + public static async Task> LoadContract(this EstateManagementGenericContext context, IDomainEvent domainEvent, CancellationToken cancellationToken) + { + Guid contractId = DomainEventHelper.GetContractId(domainEvent); + Entities.Contract contract = await context.Contracts.SingleOrDefaultAsync(e => e.ContractId == contractId, cancellationToken: cancellationToken); + + return contract switch + { + null => Result.NotFound($"Contract not found with Id {contractId}"), + _ => Result.Success(contract) + }; + } + + public static async Task> LoadContractProductTransactionFee(this EstateManagementGenericContext context, IDomainEvent domainEvent, CancellationToken cancellationToken) + { + Guid contractProductTransactionFeeId = DomainEventHelper.GetContractProductTransactionFeeId(domainEvent); + ContractProductTransactionFee contractProductTransactionFee = await context.ContractProductTransactionFees.SingleOrDefaultAsync(e => e.ContractProductTransactionFeeId == contractProductTransactionFeeId, cancellationToken: cancellationToken); + + return contractProductTransactionFee switch + { + null => Result.NotFound($"Contract Product Transaction Fee not found with Id {contractProductTransactionFeeId}"), + _ => Result.Success(contractProductTransactionFee) + }; + } +} + +public static class DomainEventHelper +{ + #region Methods + + public static Guid GetContractId(IDomainEvent domainEvent) => DomainEventHelper.GetProperty(domainEvent, "ContractId"); + + public static Guid GetContractProductId(IDomainEvent domainEvent) => DomainEventHelper.GetProperty(domainEvent, "ProductId"); + + public static Guid GetContractProductTransactionFeeId(IDomainEvent domainEvent) => DomainEventHelper.GetProperty(domainEvent, "FeeId"); + + public static Guid GetEstateId(IDomainEvent domainEvent) => DomainEventHelper.GetProperty(domainEvent, "EstateId"); + public static Guid GetOperatorId(IDomainEvent domainEvent) => DomainEventHelper.GetProperty(domainEvent, "OperatorId"); + + public static Guid GetFileId(IDomainEvent domainEvent) => DomainEventHelper.GetProperty(domainEvent, "FileId"); + + public static Guid GetFileImportLogId(IDomainEvent domainEvent) => DomainEventHelper.GetProperty(domainEvent, "FileImportLogId"); + public static Guid GetDeviceId(IDomainEvent domainEvent) => DomainEventHelper.GetProperty(domainEvent, "DeviceId"); + public static Guid GetMerchantId(IDomainEvent domainEvent) => DomainEventHelper.GetProperty(domainEvent, "MerchantId"); + public static Guid GetAddressId(IDomainEvent domainEvent) => DomainEventHelper.GetProperty(domainEvent, "AddressId"); + + public static Guid GetContactId(IDomainEvent domainEvent) => DomainEventHelper.GetProperty(domainEvent, "ContactId"); + + public static T GetProperty(IDomainEvent domainEvent, String propertyName) + { + try + { + var f = domainEvent.GetType() + .GetProperties() + .SingleOrDefault(p => p.Name == propertyName); + + if (f != null) + { + return (T)f.GetValue(domainEvent); + } + } + catch + { + // ignored + } + + return default(T); + } + + public static T GetPropertyIgnoreCase(IDomainEvent domainEvent, String propertyName) + { + try + { + var f = domainEvent.GetType() + .GetProperties() + .SingleOrDefault(p => String.Compare(p.Name, propertyName, StringComparison.CurrentCultureIgnoreCase) == 0); + + if (f != null) + { + return (T)f.GetValue(domainEvent); + } + } + catch + { + // ignored + } + + return default(T); + } + + public static Guid GetSettlementId(IDomainEvent domainEvent) => DomainEventHelper.GetProperty(domainEvent, "SettlementId"); + + public static Guid GetStatementHeaderId(IDomainEvent domainEvent) => DomainEventHelper.GetProperty(domainEvent, "MerchantStatementId"); + + public static Guid GetTransactionId(IDomainEvent domainEvent) => DomainEventHelper.GetProperty(domainEvent, "TransactionId"); + + public static Guid GetVoucherId(IDomainEvent domainEvent) => DomainEventHelper.GetProperty(domainEvent, "VoucherId"); + + public static Boolean HasProperty(IDomainEvent domainEvent, + String propertyName) + { + PropertyInfo propertyInfo = domainEvent.GetType() + .GetProperties() + .SingleOrDefault(p => p.Name == propertyName); + + return propertyInfo != null; + } + + #endregion +} \ No newline at end of file diff --git a/TransactionProcessor.Database/Contexts/EstateManagementMySqlContext.cs b/TransactionProcessor.Database/Contexts/EstateManagementMySqlContext.cs new file mode 100644 index 00000000..e3b7d21b --- /dev/null +++ b/TransactionProcessor.Database/Contexts/EstateManagementMySqlContext.cs @@ -0,0 +1,30 @@ +using EntityFramework.Exceptions.MySQL.Pomelo; +using Microsoft.EntityFrameworkCore; +using Shared.General; + +namespace TransactionProcessor.Database.Contexts; + +public class EstateManagementMySqlContext : EstateManagementGenericContext +{ + public EstateManagementMySqlContext() : base("MySql", ConfigurationReader.GetConnectionString("EstateReportingReadModel")) + { + } + + public EstateManagementMySqlContext(String connectionString) : base("MySql", connectionString) + { + } + + public EstateManagementMySqlContext(DbContextOptions dbContextOptions) : base(dbContextOptions) + { + } + + protected override void OnConfiguring(DbContextOptionsBuilder options) + { + if (!string.IsNullOrWhiteSpace(this.ConnectionString)) + { + options.UseMySql(this.ConnectionString, ServerVersion.Parse("8.0.27")).AddInterceptors(new MySqlIgnoreDuplicatesOnInsertInterceptor()); + } + + options.UseExceptionProcessor(); + } +} \ No newline at end of file diff --git a/TransactionProcessor.Database/Contexts/EstateManagementSqlServerContext.cs b/TransactionProcessor.Database/Contexts/EstateManagementSqlServerContext.cs new file mode 100644 index 00000000..744461a2 --- /dev/null +++ b/TransactionProcessor.Database/Contexts/EstateManagementSqlServerContext.cs @@ -0,0 +1,48 @@ +using EntityFramework.Exceptions.SqlServer; +using Microsoft.EntityFrameworkCore; +using Shared.General; + +namespace TransactionProcessor.Database.Contexts; + +public class EstateManagementSqlServerContext : EstateManagementGenericContext +{ + public EstateManagementSqlServerContext() : base("SqlServer", ConfigurationReader.GetConnectionString("EstateReportingReadModel")) + { + } + + public EstateManagementSqlServerContext(String connectionString) : base("SqlServer", connectionString) + { + } + + public EstateManagementSqlServerContext(DbContextOptions dbContextOptions) : base(dbContextOptions) + { + } + + protected override void OnConfiguring(DbContextOptionsBuilder options) + { + if (!string.IsNullOrWhiteSpace(this.ConnectionString)) + { + options.UseSqlServer(this.ConnectionString); + } + + options.UseExceptionProcessor(); + } + + protected override async Task SetIgnoreDuplicates(CancellationToken cancellationToken) + { + base.SetIgnoreDuplicates(cancellationToken); + + var tableList = EstateManagementGenericContext.TablesToIgnoreDuplicates.Select(x => $"ALTER TABLE [{x}] REBUILD WITH (IGNORE_DUP_KEY = ON)").ToList(); + + String sql = string.Join(";", tableList); + + await this.Database.ExecuteSqlRawAsync(sql, cancellationToken); + + //var tableList2 = new List(); + //tableList2.AddRange(EstateManagementGenericContext.TablesToIgnoreDuplicates.Select(x => $"DECLARE @TableName NVARCHAR(128);\r\nDECLARE @IndexScript NVARCHAR(MAX) = '';\r\nSET @TableName = '{x}';\r\n\r\nSELECT @IndexScript = @IndexScript + 'ALTER INDEX ' + QUOTENAME(i.name) + ' ON ' + QUOTENAME(OBJECT_SCHEMA_NAME(i.object_id)) + '.' + QUOTENAME(OBJECT_NAME(i.object_id)) + ' SET ( IGNORE_DUP_KEY = ON );'\r\nFROM sys.indexes AS i\r\nWHERE i.object_id = OBJECT_ID(@TableName) AND i.index_id > 0 and is_primary_key = 0 and is_unique = 1;\r\n\r\nEXEC sp_executesql @IndexScript;").ToList()); + + //foreach (String sql2 in tableList2){ + // await this.Database.ExecuteSqlRawAsync(sql2, cancellationToken); + //} + } +} \ No newline at end of file diff --git a/TransactionProcessor.Database/Contexts/Extensions.cs b/TransactionProcessor.Database/Contexts/Extensions.cs new file mode 100644 index 00000000..33f6981d --- /dev/null +++ b/TransactionProcessor.Database/Contexts/Extensions.cs @@ -0,0 +1,468 @@ +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Metadata.Builders; +using TransactionProcessor.Database.Entities; +using TransactionProcessor.Database.Entities.Summary; +using TransactionProcessor.Database.ViewEntities; +using File = TransactionProcessor.Database.Entities.File; + +namespace TransactionProcessor.Database.Contexts; + +public static class Extensions{ + #region Methods + + /// + /// Decimals the precision. + /// + /// The property builder. + /// The precision. + /// The scale. + /// + public static PropertyBuilder DecimalPrecision(this PropertyBuilder propertyBuilder, + Int32 precision, + Int32 scale){ + return propertyBuilder.HasColumnType($"decimal({precision},{scale})"); + } + + public static PropertyBuilder IsDateOnly(this PropertyBuilder propertyBuilder){ + return propertyBuilder.HasColumnType("date"); + } + + public static ModelBuilder SetupContract(this ModelBuilder modelBuilder){ + modelBuilder.Entity().HasKey(c => new { + c.EstateId, + c.OperatorId, + c.ContractId + }); + + return modelBuilder; + } + + public static ModelBuilder SetupContractProduct(this ModelBuilder modelBuilder){ + modelBuilder.Entity().HasKey(c => new { + c.ContractProductReportingId, + }); + + modelBuilder.Entity().HasIndex(c => new { + c.ContractProductId, + c.ContractId + }).IsUnique(true); + + return modelBuilder; + } + + public static ModelBuilder SetupContractProductTransactionFee(this ModelBuilder modelBuilder){ + modelBuilder.Entity().HasKey(c => new { + c.ContractProductTransactionFeeReportingId, + }); + + modelBuilder.Entity().HasIndex(c => new { + c.ContractProductTransactionFeeId, + c.ContractProductId + }).IsUnique(true); + + modelBuilder.Entity().Property(p => p.Value).DecimalPrecision(18, 4); + + return modelBuilder; + } + + public static ModelBuilder SetupEstate(this ModelBuilder modelBuilder){ + modelBuilder.Entity().HasKey(t => new{ + t.EstateReportingId + }); + + modelBuilder.Entity().HasIndex(t => new{ + t.EstateId + }).IsUnique(); + + return modelBuilder; + } + + public static ModelBuilder SetupOperator(this ModelBuilder modelBuilder) + { + modelBuilder.Entity().HasKey(t => new { + t.OperatorReportingId + }); + + modelBuilder.Entity().HasIndex(t => new { + t.OperatorId + }).IsUnique(); + + return modelBuilder; + } + + public static ModelBuilder SetupTransactionHistory(this ModelBuilder modelBuilder) + { + modelBuilder.Entity().HasNoKey(); + modelBuilder.Entity().HasIndex(s => new + { + s.TransactionDate + }).IsClustered(true); + + modelBuilder.Entity(s => { s.Property(p => p.TransactionDate).IsDateOnly(); }); + + modelBuilder.Entity().HasIndex(s => new + { + s.TransactionId + }).IsUnique(true); + + return modelBuilder; + } + + public static ModelBuilder SetupTodaysTransactions(this ModelBuilder modelBuilder) + { + modelBuilder.Entity().HasNoKey(); + modelBuilder.Entity().HasIndex(s => new + { + s.TransactionDate + }).IsClustered(true); + + modelBuilder.Entity(s => { s.Property(p => p.TransactionDate).IsDateOnly(); }); + + modelBuilder.Entity().HasIndex(s => new + { + s.TransactionId + }).IsUnique(true); + + return modelBuilder; + } + + public static ModelBuilder SetupSettlementSummary(this ModelBuilder modelBuilder) + { + modelBuilder.Entity().HasNoKey(); + modelBuilder.Entity().HasIndex(s => new + { + s.SettlementDate + }).IsClustered(true); + + modelBuilder.Entity(s => { s.Property(p => p.SettlementDate).IsDateOnly(); }); + + modelBuilder.Entity().HasIndex(s => new + { + s.SettlementDate, + s.MerchantReportingId, + s.OperatorReportingId, + s.ContractProductReportingId, + s.IsCompleted, + s.IsSettled + }).IsUnique(true); + + return modelBuilder; + } + + public static ModelBuilder SetupEstateSecurityUser(this ModelBuilder modelBuilder){ + modelBuilder.Entity().HasKey(t => new{ + t.SecurityUserId, + t.EstateId + }); + return modelBuilder; + } + + public static ModelBuilder SetupMerchant(this ModelBuilder modelBuilder){ + modelBuilder.Entity().HasKey(t => new { + t.MerchantReportingId + }); + + modelBuilder.Entity().HasIndex(t => new { + t.EstateId, + t.MerchantId + }).IsUnique(); + + modelBuilder.Entity(e => { e.Property(p => p.LastSaleDate).IsDateOnly(); }); + + return modelBuilder; + } + + public static ModelBuilder SetupMerchantAddress(this ModelBuilder modelBuilder){ + modelBuilder.Entity().HasKey(t => new { + t.MerchantId, + t.AddressId + }); + return modelBuilder; + } + + public static ModelBuilder SetupMerchantContact(this ModelBuilder modelBuilder) + { + modelBuilder.Entity().HasKey(t => new { + t.MerchantId, + t.ContactId + }); + return modelBuilder; + } + + public static ModelBuilder SetupMerchantDevice(this ModelBuilder modelBuilder) + { + modelBuilder.Entity().HasKey(t => new { + t.MerchantId, + t.DeviceId + }); + return modelBuilder; + } + + public static ModelBuilder SetupMerchantSecurityUser(this ModelBuilder modelBuilder) + { + modelBuilder.Entity().HasKey(t => new { + t.MerchantId, + t.SecurityUserId + }); + return modelBuilder; + } + + public static ModelBuilder SetupMerchantOperator(this ModelBuilder modelBuilder) + { + modelBuilder.Entity().HasKey(t => new { + t.MerchantId, + t.OperatorId + }); + return modelBuilder; + } + + public static ModelBuilder SetupResponseCodes(this ModelBuilder modelBuilder){ + modelBuilder.Entity().HasKey(r => new{ + r.ResponseCode + }); + return modelBuilder; + } + + public static ModelBuilder SetupSettlement(this ModelBuilder modelBuilder){ + modelBuilder.Entity().HasKey(s => new { + s.SettlementReportingId + }).IsClustered(false); + + modelBuilder.Entity().HasIndex(s => new { + s.EstateId, + s.SettlementId + }).IsClustered(false).IsUnique(true); + + modelBuilder.Entity().HasIndex(s => new { + s.SettlementDate, + }).IsClustered(true); + + modelBuilder.Entity(e => { e.Property(p => p.SettlementDate).IsDateOnly(); }); + + return modelBuilder; + } + + public static ModelBuilder SetupMerchantSettlementFee(this ModelBuilder modelBuilder){ + + + modelBuilder.Entity().HasKey(s => new{ + s.SettlementId, + s.TransactionId, + s.ContractProductTransactionFeeId + }); + + return modelBuilder; + } + + public static ModelBuilder SetupTransaction(this ModelBuilder modelBuilder){ + modelBuilder.Entity().HasKey(t => new { + t.TransactionReportingId, + }).IsClustered(false); + + modelBuilder.Entity().HasIndex(t => new { + t.TransactionId + }).IsClustered(false).IsUnique(true); + + modelBuilder.Entity().HasIndex(t => new + { + t.TransactionDate + }).IsClustered(true); + + modelBuilder.Entity(e => { e.Property(p => p.TransactionDate).IsDateOnly(); }); + + return modelBuilder; + } + + public static ModelBuilder SetupTransactionAdditionalRequestData(this ModelBuilder modelBuilder) + { + modelBuilder.Entity().HasKey(t => new { + t.TransactionId + }); + + + return modelBuilder; + } + + public static ModelBuilder SetupTransactionAdditionalResponseData(this ModelBuilder modelBuilder) + { + modelBuilder.Entity().HasKey(t => new { + t.TransactionId + }); + + + return modelBuilder; + } + + public static ModelBuilder SetupVoucher(this ModelBuilder modelBuilder){ + modelBuilder.Entity().HasKey(t => new{ + t.VoucherId + }); + + modelBuilder.Entity().HasIndex(t => new { + t.VoucherCode + }); + + modelBuilder.Entity().HasIndex(t => new { + t.TransactionId + }); + + modelBuilder.Entity(e => { e.Property(p => p.IssuedDate).IsDateOnly(); }); + modelBuilder.Entity(e => { e.Property(p => p.GenerateDate).IsDateOnly(); }); + modelBuilder.Entity(e => { e.Property(p => p.ExpiryDate).IsDateOnly(); }); + + return modelBuilder; + } + + public static ModelBuilder SetupReconciliation(this ModelBuilder modelBuilder) + { + modelBuilder.Entity().HasKey(t => new { + t.TransactionReportingId, + }).IsClustered(false); + + modelBuilder.Entity().HasIndex(t => new { + t.TransactionId, + t.MerchantId, + }).IsClustered(false).IsUnique(true); + + modelBuilder.Entity().HasIndex(t => new { + t.TransactionDate + }).IsClustered(true); + + modelBuilder.Entity(e => { e.Property(p => p.TransactionDate).IsDateOnly(); }); + + return modelBuilder; + } + + public static ModelBuilder SetupStatementHeader(this ModelBuilder modelBuilder){ + modelBuilder.Entity().HasKey(s => new { + s.MerchantId, + s.StatementId + }).IsClustered(false); + + modelBuilder.Entity().HasIndex(s => new { + s.StatementGeneratedDate, + }).IsClustered(); + + modelBuilder.Entity(e => { e.Property(p => p.StatementGeneratedDate).IsDateOnly(); }); + modelBuilder.Entity(e => { e.Property(p => p.StatementCreatedDate).IsDateOnly(); }); + + return modelBuilder; + } + + public static ModelBuilder SetupStatementLine(this ModelBuilder modelBuilder) + { + modelBuilder.Entity().HasKey(t => new { + t.StatementId, + t.TransactionId, + t.ActivityDateTime, + t.ActivityType + }); + + modelBuilder.Entity(e => { e.Property(p => p.ActivityDate).IsDateOnly(); }); + + + return modelBuilder; + } + + public static ModelBuilder SetupViewEntities(this ModelBuilder modelBuilder){ + modelBuilder.Entity().HasNoKey().ToView("uvwSettlements"); + + return modelBuilder; + } + + public static ModelBuilder SetupFileImportLog(this ModelBuilder modelBuilder){ + modelBuilder.Entity().HasKey(f => new{ + f.EstateId, + f.FileImportLogReportingId + }); + + modelBuilder.Entity().HasIndex(f => new { + f.EstateId, + f.FileImportLogId + }).IsUnique(); + + modelBuilder.Entity(e => { e.Property(p => p.ImportLogDate).IsDateOnly(); }); + + return modelBuilder; + } + + public static ModelBuilder SetupFileImportLogFile(this ModelBuilder modelBuilder){ + modelBuilder.Entity().HasKey(f => new { + f.FileImportLogId, + f.FileId, + }); + + modelBuilder.Entity(e => { e.Property(p => p.FileUploadedDate).IsDateOnly(); }); + + return modelBuilder; + } + + public static ModelBuilder SetupFile(this ModelBuilder modelBuilder){ + modelBuilder.Entity().HasKey(f => new { + f.FileReportingId + }); + + modelBuilder.Entity().HasIndex(f => new { + f.FileId + }).IsUnique(); + + modelBuilder.Entity(e => { e.Property(p => p.FileReceivedDate).IsDateOnly(); }); + + return modelBuilder; + } + + public static ModelBuilder SetupFileLine(this ModelBuilder modelBuilder) + { + modelBuilder.Entity().HasKey(f => new { + f.FileId, + f.LineNumber + }).IsClustered(); + + //modelBuilder.Entity().HasIndex(f => new { + // f.TransactionId + //}).IsUnique(true); + + return modelBuilder; + } + + public static ModelBuilder SetupMerchantContract(this ModelBuilder modelBuilder){ + modelBuilder.Entity().HasKey(mc => new{ + mc.MerchantId, + mc.ContractId + }); + + return modelBuilder; + } + + public static ModelBuilder SetupFloat(this ModelBuilder modelBuilder) + { + modelBuilder.Entity().HasKey(t => new { + t.FloatId + }).IsClustered(false); + + modelBuilder.Entity().HasIndex(t => new { + t.CreatedDate + }).IsClustered(true); + + modelBuilder.Entity(e => { e.Property(p => p.CreatedDate).IsDateOnly(); }); + + return modelBuilder; + } + + public static ModelBuilder SetupFloatActivity(this ModelBuilder modelBuilder) + { + modelBuilder.Entity().HasKey(t => new { + t.EventId + }).IsClustered(false); + + modelBuilder.Entity().HasIndex(t => new { + t.ActivityDate + }).IsClustered(true); + + modelBuilder.Entity(e => { e.Property(p => p.ActivityDate).IsDateOnly(); }); + + return modelBuilder; + } + + #endregion +} \ No newline at end of file diff --git a/TransactionProcessor.Database/Contexts/MySqlIgnoreDuplicatesOnInsertInterceptor.cs b/TransactionProcessor.Database/Contexts/MySqlIgnoreDuplicatesOnInsertInterceptor.cs new file mode 100644 index 00000000..b2dedbd3 --- /dev/null +++ b/TransactionProcessor.Database/Contexts/MySqlIgnoreDuplicatesOnInsertInterceptor.cs @@ -0,0 +1,86 @@ +using System.Data.Common; +using Microsoft.EntityFrameworkCore.Diagnostics; + +namespace TransactionProcessor.Database.Contexts +{ + public class MySqlIgnoreDuplicatesOnInsertInterceptor : DbCommandInterceptor + { + public override ValueTask> NonQueryExecutingAsync(DbCommand command, + CommandEventData eventData, + InterceptionResult result, + CancellationToken cancellationToken = new CancellationToken()) + { + command.CommandText = this.SetIgnoreDuplicates(command.CommandText); + return new ValueTask>(result); + } + + public override ValueTask> ScalarExecutingAsync(DbCommand command, + CommandEventData eventData, + InterceptionResult result, + CancellationToken cancellationToken = new CancellationToken()) + { + command.CommandText = this.SetIgnoreDuplicates(command.CommandText); + return new ValueTask>(result); + } + + public override ValueTask> ReaderExecutingAsync(DbCommand command, + CommandEventData eventData, + InterceptionResult result, + CancellationToken cancellationToken = new CancellationToken()) + { + command.CommandText = this.SetIgnoreDuplicates(command.CommandText); + + return new ValueTask>(result); + } + + public override InterceptionResult ScalarExecuting(DbCommand command, + CommandEventData eventData, + InterceptionResult result) + { + command.CommandText = this.SetIgnoreDuplicates(command.CommandText); + return result; + } + + public override InterceptionResult NonQueryExecuting(DbCommand command, + CommandEventData eventData, + InterceptionResult result) + { + command.CommandText = this.SetIgnoreDuplicates(command.CommandText); + return result; + } + + public override InterceptionResult ReaderExecuting(DbCommand command, + CommandEventData eventData, + InterceptionResult result) + { + command.CommandText = this.SetIgnoreDuplicates(command.CommandText); + return result; + } + + private String SetIgnoreDuplicates(String commandText) + { + if (this.IsCommandInsert(commandText)) + { + if (EstateManagementGenericContext.IsDuplicateInsertsIgnored(this.GetTableName(commandText))) + { + // Swap the insert to ignore duplicates + return commandText.Replace("INSERT INTO", "INSERT IGNORE INTO"); + } + } + + return commandText; + } + + private Boolean IsCommandInsert(String commandText) => commandText.Contains("INSERT INTO", StringComparison.InvariantCultureIgnoreCase); + + private String GetTableName(String commandText) + { + // Extract table and check if we are ignoring duplicates + Int32 tablenameEnd = commandText.IndexOf("("); + Int32 tablenameStart = 11; + String tableName = commandText.Substring(tablenameStart, tablenameEnd - tablenameStart); + tableName = tableName.Replace("`", ""); + return tableName; + } + } +} \ No newline at end of file diff --git a/TransactionProcessor.Database/Entities/Calendar.cs b/TransactionProcessor.Database/Entities/Calendar.cs new file mode 100644 index 00000000..b6fe07dc --- /dev/null +++ b/TransactionProcessor.Database/Entities/Calendar.cs @@ -0,0 +1,39 @@ +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + +namespace TransactionProcessor.Database.Entities +{ + /// + /// + /// + [Table("calendar")] + public class Calendar + { + #region Properties + + [Key] + public DateTime Date { get; set; } + + public String DayOfWeek { get; set; } + + public Int32 DayOfWeekNumber { get; set; } + + public String DayOfWeekShort { get; set; } + + public String MonthNameLong { get; set; } + + public String MonthNameShort { get; set; } + + public Int32 MonthNumber { get; set; } + + public Int32? WeekNumber { get; set; } + + public String WeekNumberString { get; set; } + + public Int32 Year { get; set; } + + public String YearWeekNumber { get; set; } + + #endregion + } +} \ No newline at end of file diff --git a/TransactionProcessor.Database/Entities/Contract.cs b/TransactionProcessor.Database/Entities/Contract.cs new file mode 100644 index 00000000..bc3833cf --- /dev/null +++ b/TransactionProcessor.Database/Entities/Contract.cs @@ -0,0 +1,22 @@ +using System.ComponentModel.DataAnnotations.Schema; + +namespace TransactionProcessor.Database.Entities +{ + [Table("contract")] + public class Contract + { + #region Properties + + public Guid ContractId { get; set; } + + [DatabaseGenerated(DatabaseGeneratedOption.Identity)] + public Int32 ContractReportingId { get; set; } + + public Guid EstateId { get; set; } + + public Guid OperatorId { get; set; } + + public String Description { get; set; } + #endregion + } +} \ No newline at end of file diff --git a/TransactionProcessor.Database/Entities/ContractProduct.cs b/TransactionProcessor.Database/Entities/ContractProduct.cs new file mode 100644 index 00000000..0ff70966 --- /dev/null +++ b/TransactionProcessor.Database/Entities/ContractProduct.cs @@ -0,0 +1,27 @@ +using System.ComponentModel.DataAnnotations.Schema; + +namespace TransactionProcessor.Database.Entities +{ + [Table("contractproduct")] + public class ContractProduct + { + #region Properties + + public Guid ContractId { get; set; } + + public String DisplayText { get; set; } + + public Guid ContractProductId { get; set; } + + [DatabaseGenerated(DatabaseGeneratedOption.Identity)] + public Int32 ContractProductReportingId { get; set; } + + public String ProductName { get; set; } + + public Decimal? Value { get; set; } + + public Int32 ProductType { get; set; } + + #endregion + } +} \ No newline at end of file diff --git a/TransactionProcessor.Database/Entities/ContractProductTransactionFee.cs b/TransactionProcessor.Database/Entities/ContractProductTransactionFee.cs new file mode 100644 index 00000000..537b5102 --- /dev/null +++ b/TransactionProcessor.Database/Entities/ContractProductTransactionFee.cs @@ -0,0 +1,29 @@ +using System.ComponentModel.DataAnnotations.Schema; + +namespace TransactionProcessor.Database.Entities +{ + [Table("contractproducttransactionfee")] + public class ContractProductTransactionFee + { + #region Properties + + public Guid ContractProductId { get; set; } + + public Int32 CalculationType { get; set; } + + public Int32 FeeType { get; set; } + + public Boolean IsEnabled { get; set; } + + public Guid ContractProductTransactionFeeId { get; set; } + + [DatabaseGenerated(DatabaseGeneratedOption.Identity)] + public Int32 ContractProductTransactionFeeReportingId { get; set; } + + public String Description { get; set; } + + public Decimal Value { get; set; } + + #endregion + } +} \ No newline at end of file diff --git a/TransactionProcessor.Database/Entities/Estate.cs b/TransactionProcessor.Database/Entities/Estate.cs new file mode 100644 index 00000000..1f742606 --- /dev/null +++ b/TransactionProcessor.Database/Entities/Estate.cs @@ -0,0 +1,26 @@ +using System.ComponentModel.DataAnnotations.Schema; + +namespace TransactionProcessor.Database.Entities +{ + /// + /// + /// + [Table("estate")] + public class Estate + { + #region Properties + + public DateTime CreatedDateTime { get; set; } + + public Guid EstateId { get; set; } + + [DatabaseGenerated(DatabaseGeneratedOption.Identity)] + public Int32 EstateReportingId { get; set; } + + public String Name { get; set; } + + public String? Reference { get; set; } + + #endregion + } +} \ No newline at end of file diff --git a/TransactionProcessor.Database/Entities/EstateSecurityUser.cs b/TransactionProcessor.Database/Entities/EstateSecurityUser.cs new file mode 100644 index 00000000..96a4f979 --- /dev/null +++ b/TransactionProcessor.Database/Entities/EstateSecurityUser.cs @@ -0,0 +1,22 @@ +using System.ComponentModel.DataAnnotations.Schema; + +namespace TransactionProcessor.Database.Entities +{ + /// + /// + /// + [Table("estatesecurityuser")] + public class EstateSecurityUser + { + #region Properties + public DateTime CreatedDateTime { get; set; } + + public String EmailAddress { get; set; } + + public Guid EstateId { get; set; } + + public Guid SecurityUserId { get; set; } + + #endregion + } +} \ No newline at end of file diff --git a/TransactionProcessor.Database/Entities/File.cs b/TransactionProcessor.Database/Entities/File.cs new file mode 100644 index 00000000..b262581a --- /dev/null +++ b/TransactionProcessor.Database/Entities/File.cs @@ -0,0 +1,34 @@ +using System.ComponentModel.DataAnnotations.Schema; + +namespace TransactionProcessor.Database.Entities +{ + /// + /// + /// + [Table("file")] + public class File + { + public Guid EstateId { get; set; } + + public Guid FileId { get; set; } + + [DatabaseGenerated(DatabaseGeneratedOption.Identity)] + public Int32 FileReportingId{ get; set; } + + public Guid FileImportLogId { get; set; } + + public string FileLocation { get; set; } + + public Guid FileProfileId { get; set; } + + public DateTime FileReceivedDateTime { get; set; } + + public DateTime FileReceivedDate { get; set; } + + public Guid MerchantId { get; set; } + + public Guid UserId { get; set; } + + public Boolean IsCompleted { get; set; } + } +} \ No newline at end of file diff --git a/TransactionProcessor.Database/Entities/FileImportLog.cs b/TransactionProcessor.Database/Entities/FileImportLog.cs new file mode 100644 index 00000000..6358f0c6 --- /dev/null +++ b/TransactionProcessor.Database/Entities/FileImportLog.cs @@ -0,0 +1,22 @@ +using System.ComponentModel.DataAnnotations.Schema; + +namespace TransactionProcessor.Database.Entities +{ + /// + /// + /// + [Table("fileimportlog")] + public class FileImportLog + { + public Guid EstateId { get; set; } + + [DatabaseGenerated(DatabaseGeneratedOption.Identity)] + public Int32 FileImportLogReportingId { get; set; } + + public Guid FileImportLogId { get; set; } + + public DateTime ImportLogDateTime { get; set; } + + public DateTime ImportLogDate { get; set; } + } +} diff --git a/TransactionProcessor.Database/Entities/FileImportLogFile.cs b/TransactionProcessor.Database/Entities/FileImportLogFile.cs new file mode 100644 index 00000000..b01b1fde --- /dev/null +++ b/TransactionProcessor.Database/Entities/FileImportLogFile.cs @@ -0,0 +1,29 @@ +using System.ComponentModel.DataAnnotations.Schema; + +namespace TransactionProcessor.Database.Entities +{ + /// + /// + /// + [Table("fileimportlogfile")] + public class FileImportLogFile + { + public Guid FileId { get; set; } + + public Guid FileImportLogId { get; set; } + + public string FilePath { get; set; } + + public Guid FileProfileId { get; set; } + + public DateTime FileUploadedDateTime { get; set; } + + public DateTime FileUploadedDate { get; set; } + + public Guid MerchantId { get; set; } + + public string OriginalFileName { get; set; } + + public Guid UserId { get; set; } + } +} \ No newline at end of file diff --git a/TransactionProcessor.Database/Entities/FileLine.cs b/TransactionProcessor.Database/Entities/FileLine.cs new file mode 100644 index 00000000..46b34232 --- /dev/null +++ b/TransactionProcessor.Database/Entities/FileLine.cs @@ -0,0 +1,21 @@ +using System.ComponentModel.DataAnnotations.Schema; + +namespace TransactionProcessor.Database.Entities +{ + /// + /// + /// + [Table("fileline")] + public class FileLine + { + public string FileLineData { get; set; } + + public int LineNumber { get; set; } + + public string Status { get; set; } // Success/Failed/Ignored (maybe first char?) + + public Guid TransactionId { get; set; } + + public Guid FileId { get; set; } + } +} \ No newline at end of file diff --git a/TransactionProcessor.Database/Entities/Float.cs b/TransactionProcessor.Database/Entities/Float.cs new file mode 100644 index 00000000..10f205dc --- /dev/null +++ b/TransactionProcessor.Database/Entities/Float.cs @@ -0,0 +1,16 @@ +namespace TransactionProcessor.Database.Entities +{ + public class Float + { + public Guid FloatId { get; set; } + + public Guid EstateId { get; set; } + + public Guid ContractId { get; set; } + + public Guid ProductId { get; set; } + + public DateTime CreatedDateTime { get; set; } + public DateTime CreatedDate { get; set; } + } +} diff --git a/TransactionProcessor.Database/Entities/FloatActivity.cs b/TransactionProcessor.Database/Entities/FloatActivity.cs new file mode 100644 index 00000000..269e5cd4 --- /dev/null +++ b/TransactionProcessor.Database/Entities/FloatActivity.cs @@ -0,0 +1,11 @@ +namespace TransactionProcessor.Database.Entities; + +public class FloatActivity{ + public Guid FloatId { get; set; } + public Guid EventId { get; set; } + public DateTime ActivityDate { get; set; } + public DateTime ActivityDateTime { get; set; } + public String CreditOrDebit { get; set; } + public Decimal Amount { get; set; } + public Decimal CostPrice { get; set; } +} \ No newline at end of file diff --git a/TransactionProcessor.Database/Entities/Merchant.cs b/TransactionProcessor.Database/Entities/Merchant.cs new file mode 100644 index 00000000..cc9d0525 --- /dev/null +++ b/TransactionProcessor.Database/Entities/Merchant.cs @@ -0,0 +1,36 @@ +using System.ComponentModel.DataAnnotations.Schema; + +namespace TransactionProcessor.Database.Entities +{ + /// + /// + /// + [Table("merchant")] + public class Merchant + { + #region Properties + + public DateTime CreatedDateTime { get; set; } + + public Guid EstateId { get; set; } + + public Guid MerchantId { get; set; } + + [DatabaseGenerated(DatabaseGeneratedOption.Identity)] + public Int32 MerchantReportingId { get; set; } + + public String Name { get; set; } + + public Int32 SettlementSchedule { get; set; } + + public String? Reference { get; set; } + + public DateTime LastStatementGenerated { get; set; } + + public DateTime LastSaleDate { get; set; } + + public DateTime LastSaleDateTime { get; set; } + + #endregion + } +} \ No newline at end of file diff --git a/TransactionProcessor.Database/Entities/MerchantAddress.cs b/TransactionProcessor.Database/Entities/MerchantAddress.cs new file mode 100644 index 00000000..dfbd9a34 --- /dev/null +++ b/TransactionProcessor.Database/Entities/MerchantAddress.cs @@ -0,0 +1,37 @@ +using System.ComponentModel.DataAnnotations.Schema; + +namespace TransactionProcessor.Database.Entities +{ + /// + /// + /// + [Table("merchantaddress")] + public class MerchantAddress + { + #region Properties + + public Guid AddressId { get; set; } + + public String AddressLine1 { get; set; } + + public String? AddressLine2 { get; set; } + + public String? AddressLine3 { get; set; } + + public String? AddressLine4 { get; set; } + + public String? Country { get; set; } + + public DateTime CreatedDateTime { get; set; } + + public Guid MerchantId { get; set; } + + public String? PostalCode { get; set; } + + public String? Region { get; set; } + + public String? Town { get; set; } + + #endregion + } +} \ No newline at end of file diff --git a/TransactionProcessor.Database/Entities/MerchantContact.cs b/TransactionProcessor.Database/Entities/MerchantContact.cs new file mode 100644 index 00000000..dfb5bebc --- /dev/null +++ b/TransactionProcessor.Database/Entities/MerchantContact.cs @@ -0,0 +1,27 @@ +using System.ComponentModel.DataAnnotations.Schema; + +namespace TransactionProcessor.Database.Entities +{ + /// + /// + /// + [Table("merchantcontact")] + public class MerchantContact + { + #region Properties + + public Guid ContactId { get; set; } + + public DateTime CreatedDateTime { get; set; } + + public String? EmailAddress { get; set; } + + public Guid MerchantId { get; set; } + + public String Name { get; set; } + + public String? PhoneNumber { get; set; } + + #endregion + } +} \ No newline at end of file diff --git a/TransactionProcessor.Database/Entities/MerchantContract.cs b/TransactionProcessor.Database/Entities/MerchantContract.cs new file mode 100644 index 00000000..124a4214 --- /dev/null +++ b/TransactionProcessor.Database/Entities/MerchantContract.cs @@ -0,0 +1,9 @@ +namespace TransactionProcessor.Database.Entities +{ + public class MerchantContract + { + public Guid MerchantId { get; set; } + public Guid ContractId { get; set; } + public Boolean IsDeleted{ get; set; } + } +} diff --git a/TransactionProcessor.Database/Entities/MerchantDevice.cs b/TransactionProcessor.Database/Entities/MerchantDevice.cs new file mode 100644 index 00000000..c8f46bca --- /dev/null +++ b/TransactionProcessor.Database/Entities/MerchantDevice.cs @@ -0,0 +1,23 @@ +using System.ComponentModel.DataAnnotations.Schema; + +namespace TransactionProcessor.Database.Entities +{ + /// + /// + /// + [Table("merchantdevice")] + public class MerchantDevice + { + #region Properties + + public DateTime CreatedDateTime { get; set; } + + public Guid DeviceId { get; set; } + + public String DeviceIdentifier { get; set; } + + public Guid MerchantId { get; set; } + + #endregion + } +} \ No newline at end of file diff --git a/TransactionProcessor.Database/Entities/MerchantOperator.cs b/TransactionProcessor.Database/Entities/MerchantOperator.cs new file mode 100644 index 00000000..25dd2190 --- /dev/null +++ b/TransactionProcessor.Database/Entities/MerchantOperator.cs @@ -0,0 +1,26 @@ +using System.ComponentModel.DataAnnotations.Schema; + +namespace TransactionProcessor.Database.Entities +{ + /// + /// + /// + [Table("merchantoperator")] + public class MerchantOperator + { + #region Properties + public Guid MerchantId { get; set; } + + public String? MerchantNumber { get; set; } + + public String Name { get; set; } + + public Guid OperatorId { get; set; } + + public String? TerminalNumber { get; set; } + + public Boolean IsDeleted { get; set; } + + #endregion + } +} \ No newline at end of file diff --git a/TransactionProcessor.Database/Entities/MerchantSecurityUser.cs b/TransactionProcessor.Database/Entities/MerchantSecurityUser.cs new file mode 100644 index 00000000..331d967b --- /dev/null +++ b/TransactionProcessor.Database/Entities/MerchantSecurityUser.cs @@ -0,0 +1,23 @@ +using System.ComponentModel.DataAnnotations.Schema; + +namespace TransactionProcessor.Database.Entities +{ + /// + /// + /// + [Table("merchantsecurityuser")] + public class MerchantSecurityUser + { + #region Properties + + public DateTime CreatedDateTime { get; set; } + + public String EmailAddress { get; set; } + + public Guid MerchantId { get; set; } + + public Guid SecurityUserId { get; set; } + + #endregion + } +} \ No newline at end of file diff --git a/TransactionProcessor.Database/Entities/MerchantSettlementFee.cs b/TransactionProcessor.Database/Entities/MerchantSettlementFee.cs new file mode 100644 index 00000000..3a792e40 --- /dev/null +++ b/TransactionProcessor.Database/Entities/MerchantSettlementFee.cs @@ -0,0 +1,28 @@ +using System.ComponentModel.DataAnnotations.Schema; + +namespace TransactionProcessor.Database.Entities +{ + [Table("merchantsettlementfee")] + public class MerchantSettlementFee + { + #region Properties + + public Decimal CalculatedValue { get; set; } + + public DateTime FeeCalculatedDateTime { get; set; } + + public Guid ContractProductTransactionFeeId { get; set; } + + public Decimal FeeValue { get; set; } + + public Boolean IsSettled { get; set; } + + public Guid MerchantId { get; set; } + + public Guid SettlementId { get; set; } + + public Guid TransactionId { get; set; } + + #endregion + } +} \ No newline at end of file diff --git a/TransactionProcessor.Database/Entities/Operator.cs b/TransactionProcessor.Database/Entities/Operator.cs new file mode 100644 index 00000000..85def636 --- /dev/null +++ b/TransactionProcessor.Database/Entities/Operator.cs @@ -0,0 +1,25 @@ +using System.ComponentModel.DataAnnotations.Schema; + +namespace TransactionProcessor.Database.Entities +{ + [Table("operator")] + public class Operator + { + #region Properties + + [DatabaseGenerated(DatabaseGeneratedOption.Identity)] + public Int32 OperatorReportingId { get; set; } + + public Guid EstateId { get; set; } + + public String Name { get; set; } + + public Guid OperatorId { get; set; } + + public Boolean RequireCustomMerchantNumber { get; set; } + + public Boolean RequireCustomTerminalNumber { get; set; } + + #endregion + } +} \ No newline at end of file diff --git a/TransactionProcessor.Database/Entities/Reconciliation.cs b/TransactionProcessor.Database/Entities/Reconciliation.cs new file mode 100644 index 00000000..f379cdd8 --- /dev/null +++ b/TransactionProcessor.Database/Entities/Reconciliation.cs @@ -0,0 +1,39 @@ +using System.ComponentModel.DataAnnotations.Schema; + +namespace TransactionProcessor.Database.Entities +{ + [Table("reconciliation")] + public class Reconciliation + { + #region Properties + + public String? DeviceIdentifier { get; set; } + + public Boolean IsAuthorised { get; set; } + + public Boolean IsCompleted { get; set; } + + public Guid MerchantId { get; set; } + + public String? ResponseCode { get; set; } + + public String? ResponseMessage { get; set; } + + public Int32 TransactionCount { get; set; } + + public DateTime TransactionDate { get; set; } + + public DateTime TransactionDateTime { get; set; } + + public Guid TransactionId { get; set; } + + [DatabaseGenerated(DatabaseGeneratedOption.Identity)] + public Int32 TransactionReportingId { get; set; } + + public TimeSpan TransactionTime { get; set; } + + public Decimal TransactionValue { get; set; } + + #endregion + } +} \ No newline at end of file diff --git a/TransactionProcessor.Database/Entities/ResponseCodes.cs b/TransactionProcessor.Database/Entities/ResponseCodes.cs new file mode 100644 index 00000000..657c27a4 --- /dev/null +++ b/TransactionProcessor.Database/Entities/ResponseCodes.cs @@ -0,0 +1,12 @@ +using System.ComponentModel.DataAnnotations.Schema; + +namespace TransactionProcessor.Database.Entities +{ + [Table("responsecodes")] + public class ResponseCodes + { + public Int32 ResponseCode { get; set; } + + public String Description { get; set; } + } +} diff --git a/TransactionProcessor.Database/Entities/Settlement.cs b/TransactionProcessor.Database/Entities/Settlement.cs new file mode 100644 index 00000000..1c30e1dd --- /dev/null +++ b/TransactionProcessor.Database/Entities/Settlement.cs @@ -0,0 +1,27 @@ +using System.ComponentModel.DataAnnotations.Schema; + +namespace TransactionProcessor.Database.Entities +{ + [Table("settlement")] + public class Settlement + { + #region Properties + + public Guid EstateId { get; set; } + public Guid MerchantId { get; set; } + + public Boolean ProcessingStarted { get; set; } + public DateTime ProcessingStartedDateTIme { get; set; } + + public Boolean IsCompleted { get; set; } + + public DateTime SettlementDate { get; set; } + + public Guid SettlementId { get; set; } + + [DatabaseGenerated(DatabaseGeneratedOption.Identity)] + public Int32 SettlementReportingId { get; set; } + + #endregion + } +} \ No newline at end of file diff --git a/TransactionProcessor.Database/Entities/StatementHeader.cs b/TransactionProcessor.Database/Entities/StatementHeader.cs new file mode 100644 index 00000000..471ea228 --- /dev/null +++ b/TransactionProcessor.Database/Entities/StatementHeader.cs @@ -0,0 +1,24 @@ +using System.ComponentModel.DataAnnotations.Schema; + +namespace TransactionProcessor.Database.Entities +{ + [Table("statementheader")] + public class StatementHeader + { + public Guid StatementId { get; set; } + + [DatabaseGenerated(DatabaseGeneratedOption.Identity)] + public Int32 StatementReportingId { get; set; } + + public Guid MerchantId { get; set; } + + public DateTime StatementCreatedDate { get; set; } + + public DateTime StatementGeneratedDate { get; set; } + + public DateTime StatementCreatedDateTime { get; set; } + + public DateTime StatementGeneratedDateTime { get; set; } + } +} + diff --git a/TransactionProcessor.Database/Entities/StatementLine.cs b/TransactionProcessor.Database/Entities/StatementLine.cs new file mode 100644 index 00000000..980e4a36 --- /dev/null +++ b/TransactionProcessor.Database/Entities/StatementLine.cs @@ -0,0 +1,22 @@ +using System.ComponentModel.DataAnnotations.Schema; + +namespace TransactionProcessor.Database.Entities; + +[Table("statementline")] +public class StatementLine +{ + public Guid StatementId { get; set; } + + public DateTime ActivityDateTime { get; set; } + + public DateTime ActivityDate { get; set; } + + public Int32 ActivityType { get; set; } + + public String? ActivityDescription { get; set; } + + public Decimal InAmount { get; set; } + public Decimal OutAmount { get; set; } + + public Guid TransactionId { get; set; } +} \ No newline at end of file diff --git a/TransactionProcessor.Database/Entities/Summary/SettlementSummary.cs b/TransactionProcessor.Database/Entities/Summary/SettlementSummary.cs new file mode 100644 index 00000000..c1e1ebde --- /dev/null +++ b/TransactionProcessor.Database/Entities/Summary/SettlementSummary.cs @@ -0,0 +1,67 @@ +namespace TransactionProcessor.Database.Entities.Summary +{ + public class SettlementSummary + { + public bool IsCompleted { get; set; } + public bool IsSettled { get; set; } + public DateTime SettlementDate { get; set; } + public int MerchantReportingId { get; set; } + public int OperatorReportingId { get; set; } + public int ContractProductReportingId { get; set; } + public decimal? SalesValue { get; set; } + public decimal? FeeValue { get; set; } + public int? SalesCount { get; set; } + public int? FeeCount { get; set; } + } + + public class TodayTransaction + { + public int MerchantReportingId { get; set; } + public int ContractProductReportingId { get; set; } + public int ContractReportingId { get; set; } + public int OperatorReportingId { get; set; } + public Guid TransactionId { get; set; } + public string AuthorisationCode { get; set; } + public string DeviceIdentifier { get; set; } + public bool IsAuthorised { get; set; } + public bool IsCompleted { get; set; } + public string ResponseCode { get; set; } + public string ResponseMessage { get; set; } + public DateTime TransactionDate { get; set; } + public DateTime TransactionDateTime { get; set; } + public string TransactionNumber { get; set; } + public string TransactionReference { get; set; } + public TimeSpan TransactionTime { get; set; } + public int TransactionSource { get; set; } + public string TransactionType { get; set; } + public int TransactionReportingId { get; set; } + public decimal TransactionAmount { get; set; } + public int? Hour { get; set; } + } + + public class TransactionHistory + { + public int MerchantReportingId { get; set; } + public int ContractProductReportingId { get; set; } + public int ContractReportingId { get; set; } + public int OperatorReportingId { get; set; } + public Guid TransactionId { get; set; } + public string AuthorisationCode { get; set; } + public string DeviceIdentifier { get; set; } + public bool IsAuthorised { get; set; } + public bool IsCompleted { get; set; } + public string ResponseCode { get; set; } + public string ResponseMessage { get; set; } + public DateTime TransactionDate { get; set; } + public DateTime TransactionDateTime { get; set; } + public string TransactionNumber { get; set; } + public string TransactionReference { get; set; } + public TimeSpan TransactionTime { get; set; } + public int TransactionSource { get; set; } + public string TransactionType { get; set; } + public int TransactionReportingId { get; set; } + public decimal TransactionAmount { get; set; } + public int? Hour { get; set; } + } + +} diff --git a/TransactionProcessor.Database/Entities/TransactionAdditionalRequestData.cs b/TransactionProcessor.Database/Entities/TransactionAdditionalRequestData.cs new file mode 100644 index 00000000..3046e6eb --- /dev/null +++ b/TransactionProcessor.Database/Entities/TransactionAdditionalRequestData.cs @@ -0,0 +1,23 @@ +using System.ComponentModel.DataAnnotations.Schema; + +namespace TransactionProcessor.Database.Entities +{ + /// + /// + /// + [Table("transactionadditionalrequestdata")] + public class TransactionAdditionalRequestData + { + #region Properties + + public String? Amount { get; set; } + + + public String? CustomerAccountNumber { get; set; } + + [DatabaseGenerated(DatabaseGeneratedOption.None)] + public Guid TransactionId { get; set; } + + #endregion + } +} \ No newline at end of file diff --git a/TransactionProcessor.Database/Entities/TransactionAdditionalResponseData.cs b/TransactionProcessor.Database/Entities/TransactionAdditionalResponseData.cs new file mode 100644 index 00000000..abffa6be --- /dev/null +++ b/TransactionProcessor.Database/Entities/TransactionAdditionalResponseData.cs @@ -0,0 +1,20 @@ +using System.ComponentModel.DataAnnotations.Schema; + +namespace TransactionProcessor.Database.Entities +{ + /// + /// + /// + [Table("transactionadditionalresponsedata")] + public class TransactionAdditionalResponseData + { + #region Properties + [DatabaseGenerated(DatabaseGeneratedOption.None)] + public Int32 TransactionReportingId { get; set; } + + [DatabaseGenerated(DatabaseGeneratedOption.None)] + public Guid TransactionId { get; set; } + + #endregion + } +} \ No newline at end of file diff --git a/TransactionProcessor.Database/Entities/Transactions.cs b/TransactionProcessor.Database/Entities/Transactions.cs new file mode 100644 index 00000000..258974aa --- /dev/null +++ b/TransactionProcessor.Database/Entities/Transactions.cs @@ -0,0 +1,57 @@ +using System.ComponentModel.DataAnnotations.Schema; + +namespace TransactionProcessor.Database.Entities +{ + /// + /// + /// + [Table("transaction")] + public class Transaction + { + #region Properties + + public String? AuthorisationCode { get; set; } + + //public Int32 ContractReportingId { get; set; } + public Guid ContractId { get; set; } + + public String? DeviceIdentifier { get; set; } + + public Boolean IsAuthorised { get; set; } + + public Boolean IsCompleted { get; set; } + + public Guid MerchantId { get; set; } + + public Guid OperatorId { get; set; } + + public Guid ContractProductId { get; set; } + + public String? ResponseCode { get; set; } + + public String? ResponseMessage { get; set; } + + public DateTime TransactionDate { get; set; } + + public DateTime TransactionDateTime { get; set; } + + public Guid TransactionId { get; set; } + + [DatabaseGenerated(DatabaseGeneratedOption.Identity)] + public Int32 TransactionReportingId { get; set; } + + public String? TransactionNumber { get; set; } + + public String? TransactionReference { get; set; } + + public TimeSpan TransactionTime { get; set; } + + public String? TransactionType { get; set; } + + public Int32 TransactionSource { get; set; } + + public Decimal TransactionAmount { get; set; } + + #endregion + } +} \ No newline at end of file diff --git a/TransactionProcessor.Database/Entities/Voucher.cs b/TransactionProcessor.Database/Entities/Voucher.cs new file mode 100644 index 00000000..917a5d64 --- /dev/null +++ b/TransactionProcessor.Database/Entities/Voucher.cs @@ -0,0 +1,50 @@ +using System.ComponentModel.DataAnnotations.Schema; + +namespace TransactionProcessor.Database.Entities +{ + /// + /// + /// + [Table("voucher")] + public class Voucher + { + #region Properties + + public DateTime ExpiryDate { get; set; } + public DateTime ExpiryDateTime { get; set; } + + public Boolean IsGenerated { get; set; } + + public Boolean IsIssued { get; set; } + + public Boolean IsRedeemed { get; set; } + + public String? OperatorIdentifier { get; set; } + + public String? RecipientEmail { get; set; } + + public String? RecipientMobile { get; set; } + + public Decimal Value { get; set; } + + public String VoucherCode { get; set; } + + public Guid VoucherId { get; set; } + + public Guid TransactionId { get; set; } + + public DateTime GenerateDateTime { get; set; } + + public DateTime IssuedDateTime { get; set; } + + public DateTime RedeemedDateTime { get; set; } + + public DateTime GenerateDate { get; set; } + + public DateTime IssuedDate { get; set; } + + public DateTime RedeemedDate { get; set; } + + #endregion + } +} \ No newline at end of file diff --git a/TransactionProcessor.Database/Migrations/MySql/20221115193718_InitialDatabase.Designer.cs b/TransactionProcessor.Database/Migrations/MySql/20221115193718_InitialDatabase.Designer.cs new file mode 100644 index 00000000..9f623bc5 --- /dev/null +++ b/TransactionProcessor.Database/Migrations/MySql/20221115193718_InitialDatabase.Designer.cs @@ -0,0 +1,1065 @@ +// + +#nullable disable + +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using TransactionProcessor.Database.Contexts; + +namespace TransactionProcessor.Database.Migrations.MySql +{ + [DbContext(typeof(EstateManagementMySqlContext))] + [Migration("20221115193718_InitialDatabase")] + partial class InitialDatabase + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "6.0.5") + .HasAnnotation("Relational:MaxIdentifierLength", 64); + + modelBuilder.Entity("EstateManagement.Database.Entities.Calendar", b => + { + b.Property("Date") + .HasColumnType("datetime(6)"); + + b.Property("DayOfWeek") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("DayOfWeekNumber") + .HasColumnType("int"); + + b.Property("DayOfWeekShort") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("MonthNameLong") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("MonthNameShort") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("MonthNumber") + .HasColumnType("int"); + + b.Property("WeekNumber") + .HasColumnType("int"); + + b.Property("WeekNumberString") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("Year") + .HasColumnType("int"); + + b.Property("YearWeekNumber") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("Date"); + + b.ToTable("calendar"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Contract", b => + { + b.Property("EstateId") + .HasColumnType("char(36)"); + + b.Property("OperatorId") + .HasColumnType("char(36)"); + + b.Property("ContractId") + .HasColumnType("char(36)"); + + b.Property("Description") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("EstateId", "OperatorId", "ContractId"); + + b.ToTable("contract"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.ContractProduct", b => + { + b.Property("EstateId") + .HasColumnType("char(36)"); + + b.Property("ContractId") + .HasColumnType("char(36)"); + + b.Property("ProductId") + .HasColumnType("char(36)"); + + b.Property("DisplayText") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ProductName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("Value") + .HasColumnType("decimal(65,30)"); + + b.HasKey("EstateId", "ContractId", "ProductId"); + + b.ToTable("contractproduct"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.ContractProductTransactionFee", b => + { + b.Property("EstateId") + .HasColumnType("char(36)"); + + b.Property("ContractId") + .HasColumnType("char(36)"); + + b.Property("ProductId") + .HasColumnType("char(36)"); + + b.Property("TransactionFeeId") + .HasColumnType("char(36)"); + + b.Property("CalculationType") + .HasColumnType("int"); + + b.Property("Description") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("FeeType") + .HasColumnType("int"); + + b.Property("IsEnabled") + .HasColumnType("tinyint(1)"); + + b.Property("Value") + .HasColumnType("decimal(18,4)"); + + b.HasKey("EstateId", "ContractId", "ProductId", "TransactionFeeId"); + + b.ToTable("contractproducttransactionfee"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Estate", b => + { + b.Property("EstateId") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("Reference") + .HasColumnType("longtext"); + + b.HasKey("EstateId"); + + b.ToTable("estate"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.EstateOperator", b => + { + b.Property("EstateId") + .HasColumnType("char(36)"); + + b.Property("OperatorId") + .HasColumnType("char(36)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("RequireCustomMerchantNumber") + .HasColumnType("tinyint(1)"); + + b.Property("RequireCustomTerminalNumber") + .HasColumnType("tinyint(1)"); + + b.HasKey("EstateId", "OperatorId"); + + b.ToTable("estateoperator"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.EstateSecurityUser", b => + { + b.Property("SecurityUserId") + .HasColumnType("char(36)"); + + b.Property("EstateId") + .HasColumnType("char(36)"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("EmailAddress") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("SecurityUserId", "EstateId"); + + b.ToTable("estatesecurityuser"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.File", b => + { + b.Property("EstateId") + .HasColumnType("char(36)"); + + b.Property("FileImportLogId") + .HasColumnType("char(36)"); + + b.Property("FileId") + .HasColumnType("char(36)"); + + b.Property("FileLocation") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("FileProfileId") + .HasColumnType("char(36)"); + + b.Property("FileReceivedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("IsCompleted") + .HasColumnType("tinyint(1)"); + + b.Property("MerchantId") + .HasColumnType("char(36)"); + + b.Property("UserId") + .HasColumnType("char(36)"); + + b.HasKey("EstateId", "FileImportLogId", "FileId"); + + b.ToTable("file"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.FileImportLog", b => + { + b.Property("EstateId") + .HasColumnType("char(36)"); + + b.Property("FileImportLogId") + .HasColumnType("char(36)"); + + b.Property("ImportLogDateTime") + .HasColumnType("datetime(6)"); + + b.HasKey("EstateId", "FileImportLogId"); + + b.ToTable("fileimportlog"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.FileImportLogFile", b => + { + b.Property("EstateId") + .HasColumnType("char(36)"); + + b.Property("FileImportLogId") + .HasColumnType("char(36)"); + + b.Property("FileId") + .HasColumnType("char(36)"); + + b.Property("FilePath") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("FileProfileId") + .HasColumnType("char(36)"); + + b.Property("FileUploadedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("MerchantId") + .HasColumnType("char(36)"); + + b.Property("OriginalFileName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("UserId") + .HasColumnType("char(36)"); + + b.HasKey("EstateId", "FileImportLogId", "FileId"); + + b.ToTable("fileimportlogfile"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.FileLine", b => + { + b.Property("EstateId") + .HasColumnType("char(36)"); + + b.Property("FileId") + .HasColumnType("char(36)"); + + b.Property("LineNumber") + .HasColumnType("int"); + + b.Property("FileLineData") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("Status") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("TransactionId") + .HasColumnType("char(36)"); + + b.HasKey("EstateId", "FileId", "LineNumber"); + + b.ToTable("fileline"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Merchant", b => + { + b.Property("EstateId") + .HasColumnType("char(36)"); + + b.Property("MerchantId") + .HasColumnType("char(36)"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("LastStatementGenerated") + .HasColumnType("datetime(6)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("Reference") + .HasColumnType("longtext"); + + b.Property("SettlementSchedule") + .HasColumnType("int"); + + b.HasKey("EstateId", "MerchantId"); + + b.ToTable("merchant"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantAddress", b => + { + b.Property("EstateId") + .HasColumnType("char(36)"); + + b.Property("MerchantId") + .HasColumnType("char(36)"); + + b.Property("AddressId") + .HasColumnType("char(36)"); + + b.Property("AddressLine1") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("AddressLine2") + .HasColumnType("longtext"); + + b.Property("AddressLine3") + .HasColumnType("longtext"); + + b.Property("AddressLine4") + .HasColumnType("longtext"); + + b.Property("Country") + .HasColumnType("longtext"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("PostalCode") + .HasColumnType("longtext"); + + b.Property("Region") + .HasColumnType("longtext"); + + b.Property("Town") + .HasColumnType("longtext"); + + b.HasKey("EstateId", "MerchantId", "AddressId"); + + b.ToTable("merchantaddress"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantContact", b => + { + b.Property("EstateId") + .HasColumnType("char(36)"); + + b.Property("MerchantId") + .HasColumnType("char(36)"); + + b.Property("ContactId") + .HasColumnType("char(36)"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("EmailAddress") + .HasColumnType("longtext"); + + b.Property("Name") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("PhoneNumber") + .HasColumnType("longtext"); + + b.HasKey("EstateId", "MerchantId", "ContactId"); + + b.ToTable("merchantcontact"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantDevice", b => + { + b.Property("EstateId") + .HasColumnType("char(36)"); + + b.Property("MerchantId") + .HasColumnType("char(36)"); + + b.Property("DeviceId") + .HasColumnType("char(36)"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("DeviceIdentifier") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("EstateId", "MerchantId", "DeviceId"); + + b.ToTable("merchantdevice"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantOperator", b => + { + b.Property("EstateId") + .HasColumnType("char(36)"); + + b.Property("MerchantId") + .HasColumnType("char(36)"); + + b.Property("OperatorId") + .HasColumnType("char(36)"); + + b.Property("MerchantNumber") + .HasColumnType("longtext"); + + b.Property("Name") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("TerminalNumber") + .HasColumnType("longtext"); + + b.HasKey("EstateId", "MerchantId", "OperatorId"); + + b.ToTable("merchantoperator"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantSecurityUser", b => + { + b.Property("EstateId") + .HasColumnType("char(36)"); + + b.Property("MerchantId") + .HasColumnType("char(36)"); + + b.Property("SecurityUserId") + .HasColumnType("char(36)"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("EmailAddress") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("EstateId", "MerchantId", "SecurityUserId"); + + b.ToTable("merchantsecurityuser"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantSettlementFee", b => + { + b.Property("EstateId") + .HasColumnType("char(36)"); + + b.Property("SettlementId") + .HasColumnType("char(36)"); + + b.Property("TransactionId") + .HasColumnType("char(36)"); + + b.Property("FeeId") + .HasColumnType("char(36)"); + + b.Property("CalculatedValue") + .HasColumnType("decimal(65,30)"); + + b.Property("FeeCalculatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("FeeValue") + .HasColumnType("decimal(65,30)"); + + b.Property("IsSettled") + .HasColumnType("tinyint(1)"); + + b.Property("MerchantId") + .HasColumnType("char(36)"); + + b.HasKey("EstateId", "SettlementId", "TransactionId", "FeeId"); + + b.ToTable("merchantsettlementfee"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Reconciliation", b => + { + b.Property("TransactionId") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("DeviceIdentifier") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("EstateId") + .HasColumnType("char(36)"); + + b.Property("IsAuthorised") + .HasColumnType("tinyint(1)"); + + b.Property("IsCompleted") + .HasColumnType("tinyint(1)"); + + b.Property("MerchantId") + .HasColumnType("char(36)"); + + b.Property("ResponseCode") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ResponseMessage") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("TransactionCount") + .HasColumnType("int"); + + b.Property("TransactionDate") + .HasColumnType("datetime(6)"); + + b.Property("TransactionDateTime") + .HasColumnType("datetime(6)"); + + b.Property("TransactionTime") + .HasColumnType("time(6)"); + + b.Property("TransactionValue") + .HasColumnType("decimal(65,30)"); + + b.HasKey("TransactionId"); + + b.ToTable("reconciliation"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.ResponseCodes", b => + { + b.Property("ResponseCode") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("Description") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("ResponseCode"); + + b.ToTable("responsecodes"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Settlement", b => + { + b.Property("EstateId") + .HasColumnType("char(36)"); + + b.Property("SettlementId") + .HasColumnType("char(36)"); + + b.Property("IsCompleted") + .HasColumnType("tinyint(1)"); + + b.Property("SettlementDate") + .HasColumnType("datetime(6)"); + + b.HasKey("EstateId", "SettlementId"); + + b.ToTable("settlement"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.StatementHeader", b => + { + b.Property("StatementId") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("EstateId") + .HasColumnType("char(36)"); + + b.Property("MerchantId") + .HasColumnType("char(36)"); + + b.Property("StatementCreatedDate") + .HasColumnType("datetime(6)"); + + b.Property("StatementGeneratedDate") + .HasColumnType("datetime(6)"); + + b.HasKey("StatementId"); + + b.ToTable("statementheader"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.StatementLine", b => + { + b.Property("StatementId") + .HasColumnType("char(36)"); + + b.Property("TransactionId") + .HasColumnType("char(36)"); + + b.Property("ActivityDateTime") + .HasColumnType("datetime(6)"); + + b.Property("ActivityType") + .HasColumnType("int"); + + b.Property("ActivityDescription") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("EstateId") + .HasColumnType("char(36)"); + + b.Property("InAmount") + .HasColumnType("decimal(65,30)"); + + b.Property("MerchantId") + .HasColumnType("char(36)"); + + b.Property("OutAmount") + .HasColumnType("decimal(65,30)"); + + b.HasKey("StatementId", "TransactionId", "ActivityDateTime", "ActivityType"); + + b.ToTable("statementline"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Transaction", b => + { + b.Property("EstateId") + .HasColumnType("char(36)"); + + b.Property("MerchantId") + .HasColumnType("char(36)"); + + b.Property("TransactionId") + .HasColumnType("char(36)"); + + b.Property("AuthorisationCode") + .HasColumnType("longtext"); + + b.Property("ContractId") + .HasColumnType("char(36)"); + + b.Property("DeviceIdentifier") + .HasColumnType("longtext"); + + b.Property("IsAuthorised") + .HasColumnType("tinyint(1)"); + + b.Property("IsCompleted") + .HasColumnType("tinyint(1)"); + + b.Property("OperatorIdentifier") + .HasColumnType("longtext"); + + b.Property("ProductId") + .HasColumnType("char(36)"); + + b.Property("ResponseCode") + .HasColumnType("longtext"); + + b.Property("ResponseMessage") + .HasColumnType("longtext"); + + b.Property("TransactionDate") + .HasColumnType("datetime(6)"); + + b.Property("TransactionDateTime") + .HasColumnType("datetime(6)"); + + b.Property("TransactionNumber") + .HasColumnType("longtext"); + + b.Property("TransactionReference") + .HasColumnType("longtext"); + + b.Property("TransactionSource") + .HasColumnType("int"); + + b.Property("TransactionTime") + .HasColumnType("time(6)"); + + b.Property("TransactionType") + .HasColumnType("longtext"); + + b.HasKey("EstateId", "MerchantId", "TransactionId"); + + b.ToTable("transaction"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.TransactionAdditionalRequestData", b => + { + b.Property("EstateId") + .HasColumnType("char(36)"); + + b.Property("MerchantId") + .HasColumnType("char(36)"); + + b.Property("TransactionId") + .HasColumnType("char(36)"); + + b.Property("Amount") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("CustomerAccountNumber") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("EstateId", "MerchantId", "TransactionId"); + + b.ToTable("transactionadditionalrequestdata"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.TransactionAdditionalResponseData", b => + { + b.Property("TransactionId") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("EstateId") + .HasColumnType("char(36)"); + + b.Property("MerchantId") + .HasColumnType("char(36)"); + + b.HasKey("TransactionId"); + + b.ToTable("transactionadditionalresponsedata"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.TransactionFee", b => + { + b.Property("TransactionId") + .HasColumnType("char(36)"); + + b.Property("FeeId") + .HasColumnType("char(36)"); + + b.Property("CalculatedValue") + .HasColumnType("decimal(65,30)"); + + b.Property("CalculationType") + .HasColumnType("int"); + + b.Property("EventId") + .HasColumnType("char(36)"); + + b.Property("FeeType") + .HasColumnType("int"); + + b.Property("FeeValue") + .HasColumnType("decimal(65,30)"); + + b.HasKey("TransactionId", "FeeId"); + + b.ToTable("transactionfee"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Voucher", b => + { + b.Property("VoucherId") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("EstateId") + .HasColumnType("char(36)"); + + b.Property("ExpiryDate") + .HasColumnType("datetime(6)"); + + b.Property("GenerateDateTime") + .HasColumnType("datetime(6)"); + + b.Property("IsGenerated") + .HasColumnType("tinyint(1)"); + + b.Property("IsIssued") + .HasColumnType("tinyint(1)"); + + b.Property("IsRedeemed") + .HasColumnType("tinyint(1)"); + + b.Property("IssuedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("OperatorIdentifier") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("RecipientEmail") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("RecipientMobile") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("RedeemedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("TransactionId") + .HasColumnType("char(36)"); + + b.Property("Value") + .HasColumnType("decimal(65,30)"); + + b.Property("VoucherCode") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("VoucherId"); + + b.ToTable("voucher"); + }); + + modelBuilder.Entity("EstateManagement.Database.ViewEntities.FileImportLogView", b => + { + b.Property("FileCount") + .HasColumnType("int"); + + b.Property("FileImportLogId") + .HasColumnType("char(36)"); + + b.Property("ImportLogDate") + .HasColumnType("datetime(6)"); + + b.Property("ImportLogDateTime") + .HasColumnType("datetime(6)"); + + b.Property("ImportLogTime") + .HasColumnType("time(6)"); + + b.Property("MerchantId") + .HasColumnType("char(36)"); + + b.ToTable("uvwFileImportLogView"); + + b.ToView("uvwFileImportLog"); + }); + + modelBuilder.Entity("EstateManagement.Database.ViewEntities.FileView", b => + { + b.Property("EmailAddress") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("FailedCount") + .HasColumnType("int"); + + b.Property("FileId") + .HasColumnType("char(36)"); + + b.Property("FileReceivedDate") + .HasColumnType("datetime(6)"); + + b.Property("FileReceivedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("FileReceivedTime") + .HasColumnType("time(6)"); + + b.Property("IsCompleted") + .HasColumnType("tinyint(1)"); + + b.Property("LineCount") + .HasColumnType("int"); + + b.Property("MerchantId") + .HasColumnType("char(36)"); + + b.Property("MerchantName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("PendingCount") + .HasColumnType("int"); + + b.Property("SuccessCount") + .HasColumnType("int"); + + b.Property("UserId") + .HasColumnType("char(36)"); + + b.ToTable("uvwFileView"); + + b.ToView("uvwFile"); + }); + + modelBuilder.Entity("EstateManagement.Database.ViewEntities.SettlementView", b => + { + b.Property("Amount") + .HasColumnType("decimal(65,30)"); + + b.Property("CalculatedValue") + .HasColumnType("decimal(65,30)"); + + b.Property("DayOfWeek") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("EstateId") + .HasColumnType("char(36)"); + + b.Property("FeeDescription") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("IsCompleted") + .HasColumnType("tinyint(1)"); + + b.Property("IsSettled") + .HasColumnType("tinyint(1)"); + + b.Property("MerchantId") + .HasColumnType("char(36)"); + + b.Property("MerchantName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("Month") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("MonthNumber") + .HasColumnType("int"); + + b.Property("OperatorIdentifier") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("SettlementDate") + .HasColumnType("datetime(6)"); + + b.Property("SettlementId") + .HasColumnType("char(36)"); + + b.Property("TransactionId") + .HasColumnType("char(36)"); + + b.Property("WeekNumber") + .HasColumnType("int"); + + b.Property("YearNumber") + .HasColumnType("int"); + + b.ToView("uvwSettlements"); + }); + + modelBuilder.Entity("EstateManagement.Database.ViewEntities.TransactionsView", b => + { + b.Property("Amount") + .HasColumnType("decimal(65,30)"); + + b.Property("DayOfWeek") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("EstateId") + .HasColumnType("char(36)"); + + b.Property("IsAuthorised") + .HasColumnType("tinyint(1)"); + + b.Property("IsCompleted") + .HasColumnType("tinyint(1)"); + + b.Property("MerchantId") + .HasColumnType("char(36)"); + + b.Property("Month") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("MonthNumber") + .HasColumnType("int"); + + b.Property("OperatorIdentifier") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ResponseCode") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("TransactionDate") + .HasColumnType("datetime(6)"); + + b.Property("TransactionDateTime") + .HasColumnType("datetime(6)"); + + b.Property("TransactionId") + .HasColumnType("char(36)"); + + b.Property("TransactionType") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("WeekNumber") + .HasColumnType("int"); + + b.Property("YearNumber") + .HasColumnType("int"); + + b.ToTable("uvwTransactionsView"); + + b.ToView("uvwTransactions"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/TransactionProcessor.Database/Migrations/MySql/20221115193718_InitialDatabase.cs b/TransactionProcessor.Database/Migrations/MySql/20221115193718_InitialDatabase.cs new file mode 100644 index 00000000..8aab124a --- /dev/null +++ b/TransactionProcessor.Database/Migrations/MySql/20221115193718_InitialDatabase.cs @@ -0,0 +1,752 @@ +#nullable disable + +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; + +namespace TransactionProcessor.Database.Migrations.MySql +{ + public partial class InitialDatabase : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterDatabase() + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "calendar", + columns: table => new + { + Date = table.Column(type: "datetime(6)", nullable: false), + DayOfWeek = table.Column(type: "longtext", nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + DayOfWeekNumber = table.Column(type: "int", nullable: false), + DayOfWeekShort = table.Column(type: "longtext", nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + MonthNameLong = table.Column(type: "longtext", nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + MonthNameShort = table.Column(type: "longtext", nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + MonthNumber = table.Column(type: "int", nullable: false), + WeekNumber = table.Column(type: "int", nullable: true), + WeekNumberString = table.Column(type: "longtext", nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + Year = table.Column(type: "int", nullable: false), + YearWeekNumber = table.Column(type: "longtext", nullable: false) + .Annotation("MySql:CharSet", "utf8mb4") + }, + constraints: table => + { + table.PrimaryKey("PK_calendar", x => x.Date); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "contract", + columns: table => new + { + ContractId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + EstateId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + OperatorId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + Description = table.Column(type: "longtext", nullable: false) + .Annotation("MySql:CharSet", "utf8mb4") + }, + constraints: table => + { + table.PrimaryKey("PK_contract", x => new { x.EstateId, x.OperatorId, x.ContractId }); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "contractproduct", + columns: table => new + { + ContractId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + EstateId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + ProductId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + DisplayText = table.Column(type: "longtext", nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + ProductName = table.Column(type: "longtext", nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + Value = table.Column(type: "decimal(65,30)", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_contractproduct", x => new { x.EstateId, x.ContractId, x.ProductId }); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "contractproducttransactionfee", + columns: table => new + { + ContractId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + EstateId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + ProductId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + TransactionFeeId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + CalculationType = table.Column(type: "int", nullable: false), + FeeType = table.Column(type: "int", nullable: false), + IsEnabled = table.Column(type: "tinyint(1)", nullable: false), + Description = table.Column(type: "longtext", nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + Value = table.Column(type: "decimal(18,4)", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_contractproducttransactionfee", x => new { x.EstateId, x.ContractId, x.ProductId, x.TransactionFeeId }); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "estate", + columns: table => new + { + EstateId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + CreatedDateTime = table.Column(type: "datetime(6)", nullable: false), + Name = table.Column(type: "longtext", nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + Reference = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4") + }, + constraints: table => + { + table.PrimaryKey("PK_estate", x => x.EstateId); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "estateoperator", + columns: table => new + { + EstateId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + OperatorId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + Name = table.Column(type: "longtext", nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + RequireCustomMerchantNumber = table.Column(type: "tinyint(1)", nullable: false), + RequireCustomTerminalNumber = table.Column(type: "tinyint(1)", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_estateoperator", x => new { x.EstateId, x.OperatorId }); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "estatesecurityuser", + columns: table => new + { + EstateId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + SecurityUserId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + CreatedDateTime = table.Column(type: "datetime(6)", nullable: false), + EmailAddress = table.Column(type: "longtext", nullable: false) + .Annotation("MySql:CharSet", "utf8mb4") + }, + constraints: table => + { + table.PrimaryKey("PK_estatesecurityuser", x => new { x.SecurityUserId, x.EstateId }); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "file", + columns: table => new + { + EstateId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + FileId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + FileImportLogId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + FileLocation = table.Column(type: "longtext", nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + FileProfileId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + FileReceivedDateTime = table.Column(type: "datetime(6)", nullable: false), + MerchantId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + UserId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + IsCompleted = table.Column(type: "tinyint(1)", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_file", x => new { x.EstateId, x.FileImportLogId, x.FileId }); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "fileimportlog", + columns: table => new + { + EstateId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + FileImportLogId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + ImportLogDateTime = table.Column(type: "datetime(6)", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_fileimportlog", x => new { x.EstateId, x.FileImportLogId }); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "fileimportlogfile", + columns: table => new + { + EstateId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + FileId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + FileImportLogId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + FilePath = table.Column(type: "longtext", nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + FileProfileId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + FileUploadedDateTime = table.Column(type: "datetime(6)", nullable: false), + MerchantId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + OriginalFileName = table.Column(type: "longtext", nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + UserId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci") + }, + constraints: table => + { + table.PrimaryKey("PK_fileimportlogfile", x => new { x.EstateId, x.FileImportLogId, x.FileId }); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "fileline", + columns: table => new + { + EstateId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + FileId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + LineNumber = table.Column(type: "int", nullable: false), + FileLineData = table.Column(type: "longtext", nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + Status = table.Column(type: "longtext", nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + TransactionId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci") + }, + constraints: table => + { + table.PrimaryKey("PK_fileline", x => new { x.EstateId, x.FileId, x.LineNumber }); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "merchant", + columns: table => new + { + EstateId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + MerchantId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + CreatedDateTime = table.Column(type: "datetime(6)", nullable: false), + Name = table.Column(type: "longtext", nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + SettlementSchedule = table.Column(type: "int", nullable: false), + Reference = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + LastStatementGenerated = table.Column(type: "datetime(6)", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_merchant", x => new { x.EstateId, x.MerchantId }); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "merchantaddress", + columns: table => new + { + AddressId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + EstateId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + MerchantId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + AddressLine1 = table.Column(type: "longtext", nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + AddressLine2 = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + AddressLine3 = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + AddressLine4 = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + Country = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + CreatedDateTime = table.Column(type: "datetime(6)", nullable: false), + PostalCode = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + Region = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + Town = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4") + }, + constraints: table => + { + table.PrimaryKey("PK_merchantaddress", x => new { x.EstateId, x.MerchantId, x.AddressId }); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "merchantcontact", + columns: table => new + { + ContactId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + EstateId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + MerchantId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + CreatedDateTime = table.Column(type: "datetime(6)", nullable: false), + EmailAddress = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + Name = table.Column(type: "longtext", nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + PhoneNumber = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4") + }, + constraints: table => + { + table.PrimaryKey("PK_merchantcontact", x => new { x.EstateId, x.MerchantId, x.ContactId }); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "merchantdevice", + columns: table => new + { + DeviceId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + EstateId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + MerchantId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + CreatedDateTime = table.Column(type: "datetime(6)", nullable: false), + DeviceIdentifier = table.Column(type: "longtext", nullable: false) + .Annotation("MySql:CharSet", "utf8mb4") + }, + constraints: table => + { + table.PrimaryKey("PK_merchantdevice", x => new { x.EstateId, x.MerchantId, x.DeviceId }); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "merchantoperator", + columns: table => new + { + EstateId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + MerchantId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + OperatorId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + MerchantNumber = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + Name = table.Column(type: "longtext", nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + TerminalNumber = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4") + }, + constraints: table => + { + table.PrimaryKey("PK_merchantoperator", x => new { x.EstateId, x.MerchantId, x.OperatorId }); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "merchantsecurityuser", + columns: table => new + { + EstateId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + MerchantId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + SecurityUserId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + CreatedDateTime = table.Column(type: "datetime(6)", nullable: false), + EmailAddress = table.Column(type: "longtext", nullable: false) + .Annotation("MySql:CharSet", "utf8mb4") + }, + constraints: table => + { + table.PrimaryKey("PK_merchantsecurityuser", x => new { x.EstateId, x.MerchantId, x.SecurityUserId }); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "merchantsettlementfee", + columns: table => new + { + EstateId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + FeeId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + SettlementId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + TransactionId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + CalculatedValue = table.Column(type: "decimal(65,30)", nullable: false), + FeeCalculatedDateTime = table.Column(type: "datetime(6)", nullable: false), + FeeValue = table.Column(type: "decimal(65,30)", nullable: false), + IsSettled = table.Column(type: "tinyint(1)", nullable: false), + MerchantId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci") + }, + constraints: table => + { + table.PrimaryKey("PK_merchantsettlementfee", x => new { x.EstateId, x.SettlementId, x.TransactionId, x.FeeId }); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "reconciliation", + columns: table => new + { + TransactionId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + DeviceIdentifier = table.Column(type: "longtext", nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + EstateId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + IsAuthorised = table.Column(type: "tinyint(1)", nullable: false), + IsCompleted = table.Column(type: "tinyint(1)", nullable: false), + MerchantId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + ResponseCode = table.Column(type: "longtext", nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + ResponseMessage = table.Column(type: "longtext", nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + TransactionCount = table.Column(type: "int", nullable: false), + TransactionDate = table.Column(type: "datetime(6)", nullable: false), + TransactionDateTime = table.Column(type: "datetime(6)", nullable: false), + TransactionTime = table.Column(type: "time(6)", nullable: false), + TransactionValue = table.Column(type: "decimal(65,30)", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_reconciliation", x => x.TransactionId); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "responsecodes", + columns: table => new + { + ResponseCode = table.Column(type: "int", nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + Description = table.Column(type: "longtext", nullable: false) + .Annotation("MySql:CharSet", "utf8mb4") + }, + constraints: table => + { + table.PrimaryKey("PK_responsecodes", x => x.ResponseCode); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "settlement", + columns: table => new + { + EstateId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + SettlementId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + IsCompleted = table.Column(type: "tinyint(1)", nullable: false), + SettlementDate = table.Column(type: "datetime(6)", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_settlement", x => new { x.EstateId, x.SettlementId }); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "statementheader", + columns: table => new + { + StatementId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + EstateId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + MerchantId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + StatementCreatedDate = table.Column(type: "datetime(6)", nullable: false), + StatementGeneratedDate = table.Column(type: "datetime(6)", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_statementheader", x => x.StatementId); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "statementline", + columns: table => new + { + StatementId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + ActivityDateTime = table.Column(type: "datetime(6)", nullable: false), + ActivityType = table.Column(type: "int", nullable: false), + TransactionId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + EstateId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + MerchantId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + ActivityDescription = table.Column(type: "longtext", nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + InAmount = table.Column(type: "decimal(65,30)", nullable: false), + OutAmount = table.Column(type: "decimal(65,30)", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_statementline", x => new { x.StatementId, x.TransactionId, x.ActivityDateTime, x.ActivityType }); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "transaction", + columns: table => new + { + EstateId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + MerchantId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + TransactionId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + AuthorisationCode = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + ContractId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + DeviceIdentifier = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + IsAuthorised = table.Column(type: "tinyint(1)", nullable: false), + IsCompleted = table.Column(type: "tinyint(1)", nullable: false), + OperatorIdentifier = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + ProductId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + ResponseCode = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + ResponseMessage = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + TransactionDate = table.Column(type: "datetime(6)", nullable: false), + TransactionDateTime = table.Column(type: "datetime(6)", nullable: false), + TransactionNumber = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + TransactionReference = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + TransactionTime = table.Column(type: "time(6)", nullable: false), + TransactionType = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + TransactionSource = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_transaction", x => new { x.EstateId, x.MerchantId, x.TransactionId }); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "transactionadditionalrequestdata", + columns: table => new + { + EstateId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + MerchantId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + TransactionId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + Amount = table.Column(type: "longtext", nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + CustomerAccountNumber = table.Column(type: "longtext", nullable: false) + .Annotation("MySql:CharSet", "utf8mb4") + }, + constraints: table => + { + table.PrimaryKey("PK_transactionadditionalrequestdata", x => new { x.EstateId, x.MerchantId, x.TransactionId }); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "transactionadditionalresponsedata", + columns: table => new + { + TransactionId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + EstateId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + MerchantId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci") + }, + constraints: table => + { + table.PrimaryKey("PK_transactionadditionalresponsedata", x => x.TransactionId); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "transactionfee", + columns: table => new + { + FeeId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + TransactionId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + CalculatedValue = table.Column(type: "decimal(65,30)", nullable: false), + CalculationType = table.Column(type: "int", nullable: false), + EventId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + FeeType = table.Column(type: "int", nullable: false), + FeeValue = table.Column(type: "decimal(65,30)", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_transactionfee", x => new { x.TransactionId, x.FeeId }); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "uvwFileImportLogView", + columns: table => new + { + FileImportLogId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + ImportLogDateTime = table.Column(type: "datetime(6)", nullable: false), + ImportLogDate = table.Column(type: "datetime(6)", nullable: false), + ImportLogTime = table.Column(type: "time(6)", nullable: false), + FileCount = table.Column(type: "int", nullable: false), + MerchantId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci") + }, + constraints: table => + { + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "uvwFileView", + columns: table => new + { + FileId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + FileReceivedDateTime = table.Column(type: "datetime(6)", nullable: false), + FileReceivedDate = table.Column(type: "datetime(6)", nullable: false), + FileReceivedTime = table.Column(type: "time(6)", nullable: false), + IsCompleted = table.Column(type: "tinyint(1)", nullable: false), + MerchantId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + MerchantName = table.Column(type: "longtext", nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + UserId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + EmailAddress = table.Column(type: "longtext", nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + LineCount = table.Column(type: "int", nullable: false), + PendingCount = table.Column(type: "int", nullable: false), + FailedCount = table.Column(type: "int", nullable: false), + SuccessCount = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "uvwTransactionsView", + columns: table => new + { + TransactionId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + TransactionDateTime = table.Column(type: "datetime(6)", nullable: false), + TransactionDate = table.Column(type: "datetime(6)", nullable: false), + DayOfWeek = table.Column(type: "longtext", nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + WeekNumber = table.Column(type: "int", nullable: false), + Month = table.Column(type: "longtext", nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + MonthNumber = table.Column(type: "int", nullable: false), + YearNumber = table.Column(type: "int", nullable: false), + EstateId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + MerchantId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + IsAuthorised = table.Column(type: "tinyint(1)", nullable: false), + IsCompleted = table.Column(type: "tinyint(1)", nullable: false), + TransactionType = table.Column(type: "longtext", nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + ResponseCode = table.Column(type: "longtext", nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + Amount = table.Column(type: "decimal(65,30)", nullable: false), + OperatorIdentifier = table.Column(type: "longtext", nullable: false) + .Annotation("MySql:CharSet", "utf8mb4") + }, + constraints: table => + { + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "voucher", + columns: table => new + { + VoucherId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + EstateId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + ExpiryDate = table.Column(type: "datetime(6)", nullable: false), + IsGenerated = table.Column(type: "tinyint(1)", nullable: false), + IsIssued = table.Column(type: "tinyint(1)", nullable: false), + IsRedeemed = table.Column(type: "tinyint(1)", nullable: false), + OperatorIdentifier = table.Column(type: "longtext", nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + RecipientEmail = table.Column(type: "longtext", nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + RecipientMobile = table.Column(type: "longtext", nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + Value = table.Column(type: "decimal(65,30)", nullable: false), + VoucherCode = table.Column(type: "longtext", nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + TransactionId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + GenerateDateTime = table.Column(type: "datetime(6)", nullable: false), + IssuedDateTime = table.Column(type: "datetime(6)", nullable: false), + RedeemedDateTime = table.Column(type: "datetime(6)", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_voucher", x => x.VoucherId); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "calendar"); + + migrationBuilder.DropTable( + name: "contract"); + + migrationBuilder.DropTable( + name: "contractproduct"); + + migrationBuilder.DropTable( + name: "contractproducttransactionfee"); + + migrationBuilder.DropTable( + name: "estate"); + + migrationBuilder.DropTable( + name: "estateoperator"); + + migrationBuilder.DropTable( + name: "estatesecurityuser"); + + migrationBuilder.DropTable( + name: "file"); + + migrationBuilder.DropTable( + name: "fileimportlog"); + + migrationBuilder.DropTable( + name: "fileimportlogfile"); + + migrationBuilder.DropTable( + name: "fileline"); + + migrationBuilder.DropTable( + name: "merchant"); + + migrationBuilder.DropTable( + name: "merchantaddress"); + + migrationBuilder.DropTable( + name: "merchantcontact"); + + migrationBuilder.DropTable( + name: "merchantdevice"); + + migrationBuilder.DropTable( + name: "merchantoperator"); + + migrationBuilder.DropTable( + name: "merchantsecurityuser"); + + migrationBuilder.DropTable( + name: "merchantsettlementfee"); + + migrationBuilder.DropTable( + name: "reconciliation"); + + migrationBuilder.DropTable( + name: "responsecodes"); + + migrationBuilder.DropTable( + name: "settlement"); + + migrationBuilder.DropTable( + name: "statementheader"); + + migrationBuilder.DropTable( + name: "statementline"); + + migrationBuilder.DropTable( + name: "transaction"); + + migrationBuilder.DropTable( + name: "transactionadditionalrequestdata"); + + migrationBuilder.DropTable( + name: "transactionadditionalresponsedata"); + + migrationBuilder.DropTable( + name: "transactionfee"); + + migrationBuilder.DropTable( + name: "uvwFileImportLogView"); + + migrationBuilder.DropTable( + name: "uvwFileView"); + + migrationBuilder.DropTable( + name: "uvwTransactionsView"); + + migrationBuilder.DropTable( + name: "voucher"); + } + } +} diff --git a/TransactionProcessor.Database/Migrations/MySql/20221116082041_somenullfixes.Designer.cs b/TransactionProcessor.Database/Migrations/MySql/20221116082041_somenullfixes.Designer.cs new file mode 100644 index 00000000..c8df65fc --- /dev/null +++ b/TransactionProcessor.Database/Migrations/MySql/20221116082041_somenullfixes.Designer.cs @@ -0,0 +1,1057 @@ +// + +#nullable disable + +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using TransactionProcessor.Database.Contexts; + +namespace TransactionProcessor.Database.Migrations.MySql +{ + [DbContext(typeof(EstateManagementMySqlContext))] + [Migration("20221116082041_somenullfixes")] + partial class somenullfixes + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "6.0.5") + .HasAnnotation("Relational:MaxIdentifierLength", 64); + + modelBuilder.Entity("EstateManagement.Database.Entities.Calendar", b => + { + b.Property("Date") + .HasColumnType("datetime(6)"); + + b.Property("DayOfWeek") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("DayOfWeekNumber") + .HasColumnType("int"); + + b.Property("DayOfWeekShort") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("MonthNameLong") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("MonthNameShort") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("MonthNumber") + .HasColumnType("int"); + + b.Property("WeekNumber") + .HasColumnType("int"); + + b.Property("WeekNumberString") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("Year") + .HasColumnType("int"); + + b.Property("YearWeekNumber") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("Date"); + + b.ToTable("calendar"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Contract", b => + { + b.Property("EstateId") + .HasColumnType("char(36)"); + + b.Property("OperatorId") + .HasColumnType("char(36)"); + + b.Property("ContractId") + .HasColumnType("char(36)"); + + b.Property("Description") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("EstateId", "OperatorId", "ContractId"); + + b.ToTable("contract"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.ContractProduct", b => + { + b.Property("EstateId") + .HasColumnType("char(36)"); + + b.Property("ContractId") + .HasColumnType("char(36)"); + + b.Property("ProductId") + .HasColumnType("char(36)"); + + b.Property("DisplayText") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ProductName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("Value") + .HasColumnType("decimal(65,30)"); + + b.HasKey("EstateId", "ContractId", "ProductId"); + + b.ToTable("contractproduct"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.ContractProductTransactionFee", b => + { + b.Property("EstateId") + .HasColumnType("char(36)"); + + b.Property("ContractId") + .HasColumnType("char(36)"); + + b.Property("ProductId") + .HasColumnType("char(36)"); + + b.Property("TransactionFeeId") + .HasColumnType("char(36)"); + + b.Property("CalculationType") + .HasColumnType("int"); + + b.Property("Description") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("FeeType") + .HasColumnType("int"); + + b.Property("IsEnabled") + .HasColumnType("tinyint(1)"); + + b.Property("Value") + .HasColumnType("decimal(18,4)"); + + b.HasKey("EstateId", "ContractId", "ProductId", "TransactionFeeId"); + + b.ToTable("contractproducttransactionfee"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Estate", b => + { + b.Property("EstateId") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("Reference") + .HasColumnType("longtext"); + + b.HasKey("EstateId"); + + b.ToTable("estate"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.EstateOperator", b => + { + b.Property("EstateId") + .HasColumnType("char(36)"); + + b.Property("OperatorId") + .HasColumnType("char(36)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("RequireCustomMerchantNumber") + .HasColumnType("tinyint(1)"); + + b.Property("RequireCustomTerminalNumber") + .HasColumnType("tinyint(1)"); + + b.HasKey("EstateId", "OperatorId"); + + b.ToTable("estateoperator"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.EstateSecurityUser", b => + { + b.Property("SecurityUserId") + .HasColumnType("char(36)"); + + b.Property("EstateId") + .HasColumnType("char(36)"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("EmailAddress") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("SecurityUserId", "EstateId"); + + b.ToTable("estatesecurityuser"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.File", b => + { + b.Property("EstateId") + .HasColumnType("char(36)"); + + b.Property("FileImportLogId") + .HasColumnType("char(36)"); + + b.Property("FileId") + .HasColumnType("char(36)"); + + b.Property("FileLocation") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("FileProfileId") + .HasColumnType("char(36)"); + + b.Property("FileReceivedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("IsCompleted") + .HasColumnType("tinyint(1)"); + + b.Property("MerchantId") + .HasColumnType("char(36)"); + + b.Property("UserId") + .HasColumnType("char(36)"); + + b.HasKey("EstateId", "FileImportLogId", "FileId"); + + b.ToTable("file"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.FileImportLog", b => + { + b.Property("EstateId") + .HasColumnType("char(36)"); + + b.Property("FileImportLogId") + .HasColumnType("char(36)"); + + b.Property("ImportLogDateTime") + .HasColumnType("datetime(6)"); + + b.HasKey("EstateId", "FileImportLogId"); + + b.ToTable("fileimportlog"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.FileImportLogFile", b => + { + b.Property("EstateId") + .HasColumnType("char(36)"); + + b.Property("FileImportLogId") + .HasColumnType("char(36)"); + + b.Property("FileId") + .HasColumnType("char(36)"); + + b.Property("FilePath") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("FileProfileId") + .HasColumnType("char(36)"); + + b.Property("FileUploadedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("MerchantId") + .HasColumnType("char(36)"); + + b.Property("OriginalFileName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("UserId") + .HasColumnType("char(36)"); + + b.HasKey("EstateId", "FileImportLogId", "FileId"); + + b.ToTable("fileimportlogfile"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.FileLine", b => + { + b.Property("EstateId") + .HasColumnType("char(36)"); + + b.Property("FileId") + .HasColumnType("char(36)"); + + b.Property("LineNumber") + .HasColumnType("int"); + + b.Property("FileLineData") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("Status") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("TransactionId") + .HasColumnType("char(36)"); + + b.HasKey("EstateId", "FileId", "LineNumber"); + + b.ToTable("fileline"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Merchant", b => + { + b.Property("EstateId") + .HasColumnType("char(36)"); + + b.Property("MerchantId") + .HasColumnType("char(36)"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("LastStatementGenerated") + .HasColumnType("datetime(6)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("Reference") + .HasColumnType("longtext"); + + b.Property("SettlementSchedule") + .HasColumnType("int"); + + b.HasKey("EstateId", "MerchantId"); + + b.ToTable("merchant"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantAddress", b => + { + b.Property("EstateId") + .HasColumnType("char(36)"); + + b.Property("MerchantId") + .HasColumnType("char(36)"); + + b.Property("AddressId") + .HasColumnType("char(36)"); + + b.Property("AddressLine1") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("AddressLine2") + .HasColumnType("longtext"); + + b.Property("AddressLine3") + .HasColumnType("longtext"); + + b.Property("AddressLine4") + .HasColumnType("longtext"); + + b.Property("Country") + .HasColumnType("longtext"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("PostalCode") + .HasColumnType("longtext"); + + b.Property("Region") + .HasColumnType("longtext"); + + b.Property("Town") + .HasColumnType("longtext"); + + b.HasKey("EstateId", "MerchantId", "AddressId"); + + b.ToTable("merchantaddress"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantContact", b => + { + b.Property("EstateId") + .HasColumnType("char(36)"); + + b.Property("MerchantId") + .HasColumnType("char(36)"); + + b.Property("ContactId") + .HasColumnType("char(36)"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("EmailAddress") + .HasColumnType("longtext"); + + b.Property("Name") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("PhoneNumber") + .HasColumnType("longtext"); + + b.HasKey("EstateId", "MerchantId", "ContactId"); + + b.ToTable("merchantcontact"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantDevice", b => + { + b.Property("EstateId") + .HasColumnType("char(36)"); + + b.Property("MerchantId") + .HasColumnType("char(36)"); + + b.Property("DeviceId") + .HasColumnType("char(36)"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("DeviceIdentifier") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("EstateId", "MerchantId", "DeviceId"); + + b.ToTable("merchantdevice"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantOperator", b => + { + b.Property("EstateId") + .HasColumnType("char(36)"); + + b.Property("MerchantId") + .HasColumnType("char(36)"); + + b.Property("OperatorId") + .HasColumnType("char(36)"); + + b.Property("MerchantNumber") + .HasColumnType("longtext"); + + b.Property("Name") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("TerminalNumber") + .HasColumnType("longtext"); + + b.HasKey("EstateId", "MerchantId", "OperatorId"); + + b.ToTable("merchantoperator"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantSecurityUser", b => + { + b.Property("EstateId") + .HasColumnType("char(36)"); + + b.Property("MerchantId") + .HasColumnType("char(36)"); + + b.Property("SecurityUserId") + .HasColumnType("char(36)"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("EmailAddress") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("EstateId", "MerchantId", "SecurityUserId"); + + b.ToTable("merchantsecurityuser"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantSettlementFee", b => + { + b.Property("EstateId") + .HasColumnType("char(36)"); + + b.Property("SettlementId") + .HasColumnType("char(36)"); + + b.Property("TransactionId") + .HasColumnType("char(36)"); + + b.Property("FeeId") + .HasColumnType("char(36)"); + + b.Property("CalculatedValue") + .HasColumnType("decimal(65,30)"); + + b.Property("FeeCalculatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("FeeValue") + .HasColumnType("decimal(65,30)"); + + b.Property("IsSettled") + .HasColumnType("tinyint(1)"); + + b.Property("MerchantId") + .HasColumnType("char(36)"); + + b.HasKey("EstateId", "SettlementId", "TransactionId", "FeeId"); + + b.ToTable("merchantsettlementfee"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Reconciliation", b => + { + b.Property("TransactionId") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("DeviceIdentifier") + .HasColumnType("longtext"); + + b.Property("EstateId") + .HasColumnType("char(36)"); + + b.Property("IsAuthorised") + .HasColumnType("tinyint(1)"); + + b.Property("IsCompleted") + .HasColumnType("tinyint(1)"); + + b.Property("MerchantId") + .HasColumnType("char(36)"); + + b.Property("ResponseCode") + .HasColumnType("longtext"); + + b.Property("ResponseMessage") + .HasColumnType("longtext"); + + b.Property("TransactionCount") + .HasColumnType("int"); + + b.Property("TransactionDate") + .HasColumnType("datetime(6)"); + + b.Property("TransactionDateTime") + .HasColumnType("datetime(6)"); + + b.Property("TransactionTime") + .HasColumnType("time(6)"); + + b.Property("TransactionValue") + .HasColumnType("decimal(65,30)"); + + b.HasKey("TransactionId"); + + b.ToTable("reconciliation"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.ResponseCodes", b => + { + b.Property("ResponseCode") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("Description") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("ResponseCode"); + + b.ToTable("responsecodes"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Settlement", b => + { + b.Property("EstateId") + .HasColumnType("char(36)"); + + b.Property("SettlementId") + .HasColumnType("char(36)"); + + b.Property("IsCompleted") + .HasColumnType("tinyint(1)"); + + b.Property("SettlementDate") + .HasColumnType("datetime(6)"); + + b.HasKey("EstateId", "SettlementId"); + + b.ToTable("settlement"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.StatementHeader", b => + { + b.Property("StatementId") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("EstateId") + .HasColumnType("char(36)"); + + b.Property("MerchantId") + .HasColumnType("char(36)"); + + b.Property("StatementCreatedDate") + .HasColumnType("datetime(6)"); + + b.Property("StatementGeneratedDate") + .HasColumnType("datetime(6)"); + + b.HasKey("StatementId"); + + b.ToTable("statementheader"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.StatementLine", b => + { + b.Property("StatementId") + .HasColumnType("char(36)"); + + b.Property("TransactionId") + .HasColumnType("char(36)"); + + b.Property("ActivityDateTime") + .HasColumnType("datetime(6)"); + + b.Property("ActivityType") + .HasColumnType("int"); + + b.Property("ActivityDescription") + .HasColumnType("longtext"); + + b.Property("EstateId") + .HasColumnType("char(36)"); + + b.Property("InAmount") + .HasColumnType("decimal(65,30)"); + + b.Property("MerchantId") + .HasColumnType("char(36)"); + + b.Property("OutAmount") + .HasColumnType("decimal(65,30)"); + + b.HasKey("StatementId", "TransactionId", "ActivityDateTime", "ActivityType"); + + b.ToTable("statementline"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Transaction", b => + { + b.Property("EstateId") + .HasColumnType("char(36)"); + + b.Property("MerchantId") + .HasColumnType("char(36)"); + + b.Property("TransactionId") + .HasColumnType("char(36)"); + + b.Property("AuthorisationCode") + .HasColumnType("longtext"); + + b.Property("ContractId") + .HasColumnType("char(36)"); + + b.Property("DeviceIdentifier") + .HasColumnType("longtext"); + + b.Property("IsAuthorised") + .HasColumnType("tinyint(1)"); + + b.Property("IsCompleted") + .HasColumnType("tinyint(1)"); + + b.Property("OperatorIdentifier") + .HasColumnType("longtext"); + + b.Property("ProductId") + .HasColumnType("char(36)"); + + b.Property("ResponseCode") + .HasColumnType("longtext"); + + b.Property("ResponseMessage") + .HasColumnType("longtext"); + + b.Property("TransactionDate") + .HasColumnType("datetime(6)"); + + b.Property("TransactionDateTime") + .HasColumnType("datetime(6)"); + + b.Property("TransactionNumber") + .HasColumnType("longtext"); + + b.Property("TransactionReference") + .HasColumnType("longtext"); + + b.Property("TransactionSource") + .HasColumnType("int"); + + b.Property("TransactionTime") + .HasColumnType("time(6)"); + + b.Property("TransactionType") + .HasColumnType("longtext"); + + b.HasKey("EstateId", "MerchantId", "TransactionId"); + + b.ToTable("transaction"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.TransactionAdditionalRequestData", b => + { + b.Property("EstateId") + .HasColumnType("char(36)"); + + b.Property("MerchantId") + .HasColumnType("char(36)"); + + b.Property("TransactionId") + .HasColumnType("char(36)"); + + b.Property("Amount") + .HasColumnType("longtext"); + + b.Property("CustomerAccountNumber") + .HasColumnType("longtext"); + + b.HasKey("EstateId", "MerchantId", "TransactionId"); + + b.ToTable("transactionadditionalrequestdata"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.TransactionAdditionalResponseData", b => + { + b.Property("TransactionId") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("EstateId") + .HasColumnType("char(36)"); + + b.Property("MerchantId") + .HasColumnType("char(36)"); + + b.HasKey("TransactionId"); + + b.ToTable("transactionadditionalresponsedata"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.TransactionFee", b => + { + b.Property("TransactionId") + .HasColumnType("char(36)"); + + b.Property("FeeId") + .HasColumnType("char(36)"); + + b.Property("CalculatedValue") + .HasColumnType("decimal(65,30)"); + + b.Property("CalculationType") + .HasColumnType("int"); + + b.Property("EventId") + .HasColumnType("char(36)"); + + b.Property("FeeType") + .HasColumnType("int"); + + b.Property("FeeValue") + .HasColumnType("decimal(65,30)"); + + b.HasKey("TransactionId", "FeeId"); + + b.ToTable("transactionfee"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Voucher", b => + { + b.Property("VoucherId") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("EstateId") + .HasColumnType("char(36)"); + + b.Property("ExpiryDate") + .HasColumnType("datetime(6)"); + + b.Property("GenerateDateTime") + .HasColumnType("datetime(6)"); + + b.Property("IsGenerated") + .HasColumnType("tinyint(1)"); + + b.Property("IsIssued") + .HasColumnType("tinyint(1)"); + + b.Property("IsRedeemed") + .HasColumnType("tinyint(1)"); + + b.Property("IssuedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("OperatorIdentifier") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("RecipientEmail") + .HasColumnType("longtext"); + + b.Property("RecipientMobile") + .HasColumnType("longtext"); + + b.Property("RedeemedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("TransactionId") + .HasColumnType("char(36)"); + + b.Property("Value") + .HasColumnType("decimal(65,30)"); + + b.Property("VoucherCode") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("VoucherId"); + + b.ToTable("voucher"); + }); + + modelBuilder.Entity("EstateManagement.Database.ViewEntities.FileImportLogView", b => + { + b.Property("FileCount") + .HasColumnType("int"); + + b.Property("FileImportLogId") + .HasColumnType("char(36)"); + + b.Property("ImportLogDate") + .HasColumnType("datetime(6)"); + + b.Property("ImportLogDateTime") + .HasColumnType("datetime(6)"); + + b.Property("ImportLogTime") + .HasColumnType("time(6)"); + + b.Property("MerchantId") + .HasColumnType("char(36)"); + + b.ToTable("uvwFileImportLogView"); + + b.ToView("uvwFileImportLog"); + }); + + modelBuilder.Entity("EstateManagement.Database.ViewEntities.FileView", b => + { + b.Property("EmailAddress") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("FailedCount") + .HasColumnType("int"); + + b.Property("FileId") + .HasColumnType("char(36)"); + + b.Property("FileReceivedDate") + .HasColumnType("datetime(6)"); + + b.Property("FileReceivedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("FileReceivedTime") + .HasColumnType("time(6)"); + + b.Property("IsCompleted") + .HasColumnType("tinyint(1)"); + + b.Property("LineCount") + .HasColumnType("int"); + + b.Property("MerchantId") + .HasColumnType("char(36)"); + + b.Property("MerchantName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("PendingCount") + .HasColumnType("int"); + + b.Property("SuccessCount") + .HasColumnType("int"); + + b.Property("UserId") + .HasColumnType("char(36)"); + + b.ToTable("uvwFileView"); + + b.ToView("uvwFile"); + }); + + modelBuilder.Entity("EstateManagement.Database.ViewEntities.SettlementView", b => + { + b.Property("Amount") + .HasColumnType("decimal(65,30)"); + + b.Property("CalculatedValue") + .HasColumnType("decimal(65,30)"); + + b.Property("DayOfWeek") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("EstateId") + .HasColumnType("char(36)"); + + b.Property("FeeDescription") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("IsCompleted") + .HasColumnType("tinyint(1)"); + + b.Property("IsSettled") + .HasColumnType("tinyint(1)"); + + b.Property("MerchantId") + .HasColumnType("char(36)"); + + b.Property("MerchantName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("Month") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("MonthNumber") + .HasColumnType("int"); + + b.Property("OperatorIdentifier") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("SettlementDate") + .HasColumnType("datetime(6)"); + + b.Property("SettlementId") + .HasColumnType("char(36)"); + + b.Property("TransactionId") + .HasColumnType("char(36)"); + + b.Property("WeekNumber") + .HasColumnType("int"); + + b.Property("YearNumber") + .HasColumnType("int"); + + b.ToView("uvwSettlements"); + }); + + modelBuilder.Entity("EstateManagement.Database.ViewEntities.TransactionsView", b => + { + b.Property("Amount") + .HasColumnType("decimal(65,30)"); + + b.Property("DayOfWeek") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("EstateId") + .HasColumnType("char(36)"); + + b.Property("IsAuthorised") + .HasColumnType("tinyint(1)"); + + b.Property("IsCompleted") + .HasColumnType("tinyint(1)"); + + b.Property("MerchantId") + .HasColumnType("char(36)"); + + b.Property("Month") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("MonthNumber") + .HasColumnType("int"); + + b.Property("OperatorIdentifier") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ResponseCode") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("TransactionDate") + .HasColumnType("datetime(6)"); + + b.Property("TransactionDateTime") + .HasColumnType("datetime(6)"); + + b.Property("TransactionId") + .HasColumnType("char(36)"); + + b.Property("TransactionType") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("WeekNumber") + .HasColumnType("int"); + + b.Property("YearNumber") + .HasColumnType("int"); + + b.ToTable("uvwTransactionsView"); + + b.ToView("uvwTransactions"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/TransactionProcessor.Database/Migrations/MySql/20221116082041_somenullfixes.cs b/TransactionProcessor.Database/Migrations/MySql/20221116082041_somenullfixes.cs new file mode 100644 index 00000000..f758efad --- /dev/null +++ b/TransactionProcessor.Database/Migrations/MySql/20221116082041_somenullfixes.cs @@ -0,0 +1,239 @@ +#nullable disable + +using Microsoft.EntityFrameworkCore.Migrations; + +namespace TransactionProcessor.Database.Migrations.MySql +{ + public partial class somenullfixes : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterColumn( + name: "RecipientMobile", + table: "voucher", + type: "longtext", + nullable: true, + oldClrType: typeof(string), + oldType: "longtext") + .Annotation("MySql:CharSet", "utf8mb4") + .OldAnnotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.AlterColumn( + name: "RecipientEmail", + table: "voucher", + type: "longtext", + nullable: true, + oldClrType: typeof(string), + oldType: "longtext") + .Annotation("MySql:CharSet", "utf8mb4") + .OldAnnotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.AlterColumn( + name: "CustomerAccountNumber", + table: "transactionadditionalrequestdata", + type: "longtext", + nullable: true, + oldClrType: typeof(string), + oldType: "longtext") + .Annotation("MySql:CharSet", "utf8mb4") + .OldAnnotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.AlterColumn( + name: "Amount", + table: "transactionadditionalrequestdata", + type: "longtext", + nullable: true, + oldClrType: typeof(string), + oldType: "longtext") + .Annotation("MySql:CharSet", "utf8mb4") + .OldAnnotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.AlterColumn( + name: "ActivityDescription", + table: "statementline", + type: "longtext", + nullable: true, + oldClrType: typeof(string), + oldType: "longtext") + .Annotation("MySql:CharSet", "utf8mb4") + .OldAnnotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.AlterColumn( + name: "ResponseMessage", + table: "reconciliation", + type: "longtext", + nullable: true, + oldClrType: typeof(string), + oldType: "longtext") + .Annotation("MySql:CharSet", "utf8mb4") + .OldAnnotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.AlterColumn( + name: "ResponseCode", + table: "reconciliation", + type: "longtext", + nullable: true, + oldClrType: typeof(string), + oldType: "longtext") + .Annotation("MySql:CharSet", "utf8mb4") + .OldAnnotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.AlterColumn( + name: "DeviceIdentifier", + table: "reconciliation", + type: "longtext", + nullable: true, + oldClrType: typeof(string), + oldType: "longtext") + .Annotation("MySql:CharSet", "utf8mb4") + .OldAnnotation("MySql:CharSet", "utf8mb4"); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.UpdateData( + table: "voucher", + keyColumn: "RecipientMobile", + keyValue: null, + column: "RecipientMobile", + value: ""); + + migrationBuilder.AlterColumn( + name: "RecipientMobile", + table: "voucher", + type: "longtext", + nullable: false, + oldClrType: typeof(string), + oldType: "longtext", + oldNullable: true) + .Annotation("MySql:CharSet", "utf8mb4") + .OldAnnotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.UpdateData( + table: "voucher", + keyColumn: "RecipientEmail", + keyValue: null, + column: "RecipientEmail", + value: ""); + + migrationBuilder.AlterColumn( + name: "RecipientEmail", + table: "voucher", + type: "longtext", + nullable: false, + oldClrType: typeof(string), + oldType: "longtext", + oldNullable: true) + .Annotation("MySql:CharSet", "utf8mb4") + .OldAnnotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.UpdateData( + table: "transactionadditionalrequestdata", + keyColumn: "CustomerAccountNumber", + keyValue: null, + column: "CustomerAccountNumber", + value: ""); + + migrationBuilder.AlterColumn( + name: "CustomerAccountNumber", + table: "transactionadditionalrequestdata", + type: "longtext", + nullable: false, + oldClrType: typeof(string), + oldType: "longtext", + oldNullable: true) + .Annotation("MySql:CharSet", "utf8mb4") + .OldAnnotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.UpdateData( + table: "transactionadditionalrequestdata", + keyColumn: "Amount", + keyValue: null, + column: "Amount", + value: ""); + + migrationBuilder.AlterColumn( + name: "Amount", + table: "transactionadditionalrequestdata", + type: "longtext", + nullable: false, + oldClrType: typeof(string), + oldType: "longtext", + oldNullable: true) + .Annotation("MySql:CharSet", "utf8mb4") + .OldAnnotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.UpdateData( + table: "statementline", + keyColumn: "ActivityDescription", + keyValue: null, + column: "ActivityDescription", + value: ""); + + migrationBuilder.AlterColumn( + name: "ActivityDescription", + table: "statementline", + type: "longtext", + nullable: false, + oldClrType: typeof(string), + oldType: "longtext", + oldNullable: true) + .Annotation("MySql:CharSet", "utf8mb4") + .OldAnnotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.UpdateData( + table: "reconciliation", + keyColumn: "ResponseMessage", + keyValue: null, + column: "ResponseMessage", + value: ""); + + migrationBuilder.AlterColumn( + name: "ResponseMessage", + table: "reconciliation", + type: "longtext", + nullable: false, + oldClrType: typeof(string), + oldType: "longtext", + oldNullable: true) + .Annotation("MySql:CharSet", "utf8mb4") + .OldAnnotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.UpdateData( + table: "reconciliation", + keyColumn: "ResponseCode", + keyValue: null, + column: "ResponseCode", + value: ""); + + migrationBuilder.AlterColumn( + name: "ResponseCode", + table: "reconciliation", + type: "longtext", + nullable: false, + oldClrType: typeof(string), + oldType: "longtext", + oldNullable: true) + .Annotation("MySql:CharSet", "utf8mb4") + .OldAnnotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.UpdateData( + table: "reconciliation", + keyColumn: "DeviceIdentifier", + keyValue: null, + column: "DeviceIdentifier", + value: ""); + + migrationBuilder.AlterColumn( + name: "DeviceIdentifier", + table: "reconciliation", + type: "longtext", + nullable: false, + oldClrType: typeof(string), + oldType: "longtext", + oldNullable: true) + .Annotation("MySql:CharSet", "utf8mb4") + .OldAnnotation("MySql:CharSet", "utf8mb4"); + } + } +} diff --git a/TransactionProcessor.Database/Migrations/MySql/20230116113800_recordproducttype.Designer.cs b/TransactionProcessor.Database/Migrations/MySql/20230116113800_recordproducttype.Designer.cs new file mode 100644 index 00000000..8d396a35 --- /dev/null +++ b/TransactionProcessor.Database/Migrations/MySql/20230116113800_recordproducttype.Designer.cs @@ -0,0 +1,1063 @@ +// + +#nullable disable + +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using TransactionProcessor.Database.Contexts; + +namespace TransactionProcessor.Database.Migrations.MySql +{ + [DbContext(typeof(EstateManagementMySqlContext))] + [Migration("20230116113800_recordproducttype")] + partial class recordproducttype + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "7.0.0") + .HasAnnotation("Relational:MaxIdentifierLength", 64); + + modelBuilder.Entity("EstateManagement.Database.Entities.Calendar", b => + { + b.Property("Date") + .HasColumnType("datetime(6)"); + + b.Property("DayOfWeek") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("DayOfWeekNumber") + .HasColumnType("int"); + + b.Property("DayOfWeekShort") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("MonthNameLong") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("MonthNameShort") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("MonthNumber") + .HasColumnType("int"); + + b.Property("WeekNumber") + .HasColumnType("int"); + + b.Property("WeekNumberString") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("Year") + .HasColumnType("int"); + + b.Property("YearWeekNumber") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("Date"); + + b.ToTable("calendar"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Contract", b => + { + b.Property("EstateId") + .HasColumnType("char(36)"); + + b.Property("OperatorId") + .HasColumnType("char(36)"); + + b.Property("ContractId") + .HasColumnType("char(36)"); + + b.Property("Description") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("EstateId", "OperatorId", "ContractId"); + + b.ToTable("contract"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.ContractProduct", b => + { + b.Property("EstateId") + .HasColumnType("char(36)"); + + b.Property("ContractId") + .HasColumnType("char(36)"); + + b.Property("ProductId") + .HasColumnType("char(36)"); + + b.Property("DisplayText") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ProductName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ProductType") + .HasColumnType("int"); + + b.Property("Value") + .HasColumnType("decimal(65,30)"); + + b.HasKey("EstateId", "ContractId", "ProductId"); + + b.ToTable("contractproduct"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.ContractProductTransactionFee", b => + { + b.Property("EstateId") + .HasColumnType("char(36)"); + + b.Property("ContractId") + .HasColumnType("char(36)"); + + b.Property("ProductId") + .HasColumnType("char(36)"); + + b.Property("TransactionFeeId") + .HasColumnType("char(36)"); + + b.Property("CalculationType") + .HasColumnType("int"); + + b.Property("Description") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("FeeType") + .HasColumnType("int"); + + b.Property("IsEnabled") + .HasColumnType("tinyint(1)"); + + b.Property("Value") + .HasColumnType("decimal(18,4)"); + + b.HasKey("EstateId", "ContractId", "ProductId", "TransactionFeeId"); + + b.ToTable("contractproducttransactionfee"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Estate", b => + { + b.Property("EstateId") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("Reference") + .HasColumnType("longtext"); + + b.HasKey("EstateId"); + + b.ToTable("estate"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.EstateOperator", b => + { + b.Property("EstateId") + .HasColumnType("char(36)"); + + b.Property("OperatorId") + .HasColumnType("char(36)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("RequireCustomMerchantNumber") + .HasColumnType("tinyint(1)"); + + b.Property("RequireCustomTerminalNumber") + .HasColumnType("tinyint(1)"); + + b.HasKey("EstateId", "OperatorId"); + + b.ToTable("estateoperator"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.EstateSecurityUser", b => + { + b.Property("SecurityUserId") + .HasColumnType("char(36)"); + + b.Property("EstateId") + .HasColumnType("char(36)"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("EmailAddress") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("SecurityUserId", "EstateId"); + + b.ToTable("estatesecurityuser"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.File", b => + { + b.Property("EstateId") + .HasColumnType("char(36)"); + + b.Property("FileImportLogId") + .HasColumnType("char(36)"); + + b.Property("FileId") + .HasColumnType("char(36)"); + + b.Property("FileLocation") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("FileProfileId") + .HasColumnType("char(36)"); + + b.Property("FileReceivedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("IsCompleted") + .HasColumnType("tinyint(1)"); + + b.Property("MerchantId") + .HasColumnType("char(36)"); + + b.Property("UserId") + .HasColumnType("char(36)"); + + b.HasKey("EstateId", "FileImportLogId", "FileId"); + + b.ToTable("file"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.FileImportLog", b => + { + b.Property("EstateId") + .HasColumnType("char(36)"); + + b.Property("FileImportLogId") + .HasColumnType("char(36)"); + + b.Property("ImportLogDateTime") + .HasColumnType("datetime(6)"); + + b.HasKey("EstateId", "FileImportLogId"); + + b.ToTable("fileimportlog"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.FileImportLogFile", b => + { + b.Property("EstateId") + .HasColumnType("char(36)"); + + b.Property("FileImportLogId") + .HasColumnType("char(36)"); + + b.Property("FileId") + .HasColumnType("char(36)"); + + b.Property("FilePath") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("FileProfileId") + .HasColumnType("char(36)"); + + b.Property("FileUploadedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("MerchantId") + .HasColumnType("char(36)"); + + b.Property("OriginalFileName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("UserId") + .HasColumnType("char(36)"); + + b.HasKey("EstateId", "FileImportLogId", "FileId"); + + b.ToTable("fileimportlogfile"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.FileLine", b => + { + b.Property("EstateId") + .HasColumnType("char(36)"); + + b.Property("FileId") + .HasColumnType("char(36)"); + + b.Property("LineNumber") + .HasColumnType("int"); + + b.Property("FileLineData") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("Status") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("TransactionId") + .HasColumnType("char(36)"); + + b.HasKey("EstateId", "FileId", "LineNumber"); + + b.ToTable("fileline"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Merchant", b => + { + b.Property("EstateId") + .HasColumnType("char(36)"); + + b.Property("MerchantId") + .HasColumnType("char(36)"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("LastStatementGenerated") + .HasColumnType("datetime(6)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("Reference") + .HasColumnType("longtext"); + + b.Property("SettlementSchedule") + .HasColumnType("int"); + + b.HasKey("EstateId", "MerchantId"); + + b.ToTable("merchant"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantAddress", b => + { + b.Property("EstateId") + .HasColumnType("char(36)"); + + b.Property("MerchantId") + .HasColumnType("char(36)"); + + b.Property("AddressId") + .HasColumnType("char(36)"); + + b.Property("AddressLine1") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("AddressLine2") + .HasColumnType("longtext"); + + b.Property("AddressLine3") + .HasColumnType("longtext"); + + b.Property("AddressLine4") + .HasColumnType("longtext"); + + b.Property("Country") + .HasColumnType("longtext"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("PostalCode") + .HasColumnType("longtext"); + + b.Property("Region") + .HasColumnType("longtext"); + + b.Property("Town") + .HasColumnType("longtext"); + + b.HasKey("EstateId", "MerchantId", "AddressId"); + + b.ToTable("merchantaddress"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantContact", b => + { + b.Property("EstateId") + .HasColumnType("char(36)"); + + b.Property("MerchantId") + .HasColumnType("char(36)"); + + b.Property("ContactId") + .HasColumnType("char(36)"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("EmailAddress") + .HasColumnType("longtext"); + + b.Property("Name") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("PhoneNumber") + .HasColumnType("longtext"); + + b.HasKey("EstateId", "MerchantId", "ContactId"); + + b.ToTable("merchantcontact"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantDevice", b => + { + b.Property("EstateId") + .HasColumnType("char(36)"); + + b.Property("MerchantId") + .HasColumnType("char(36)"); + + b.Property("DeviceId") + .HasColumnType("char(36)"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("DeviceIdentifier") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("EstateId", "MerchantId", "DeviceId"); + + b.ToTable("merchantdevice"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantOperator", b => + { + b.Property("EstateId") + .HasColumnType("char(36)"); + + b.Property("MerchantId") + .HasColumnType("char(36)"); + + b.Property("OperatorId") + .HasColumnType("char(36)"); + + b.Property("MerchantNumber") + .HasColumnType("longtext"); + + b.Property("Name") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("TerminalNumber") + .HasColumnType("longtext"); + + b.HasKey("EstateId", "MerchantId", "OperatorId"); + + b.ToTable("merchantoperator"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantSecurityUser", b => + { + b.Property("EstateId") + .HasColumnType("char(36)"); + + b.Property("MerchantId") + .HasColumnType("char(36)"); + + b.Property("SecurityUserId") + .HasColumnType("char(36)"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("EmailAddress") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("EstateId", "MerchantId", "SecurityUserId"); + + b.ToTable("merchantsecurityuser"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantSettlementFee", b => + { + b.Property("EstateId") + .HasColumnType("char(36)"); + + b.Property("SettlementId") + .HasColumnType("char(36)"); + + b.Property("TransactionId") + .HasColumnType("char(36)"); + + b.Property("FeeId") + .HasColumnType("char(36)"); + + b.Property("CalculatedValue") + .HasColumnType("decimal(65,30)"); + + b.Property("FeeCalculatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("FeeValue") + .HasColumnType("decimal(65,30)"); + + b.Property("IsSettled") + .HasColumnType("tinyint(1)"); + + b.Property("MerchantId") + .HasColumnType("char(36)"); + + b.HasKey("EstateId", "SettlementId", "TransactionId", "FeeId"); + + b.ToTable("merchantsettlementfee"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Reconciliation", b => + { + b.Property("TransactionId") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("DeviceIdentifier") + .HasColumnType("longtext"); + + b.Property("EstateId") + .HasColumnType("char(36)"); + + b.Property("IsAuthorised") + .HasColumnType("tinyint(1)"); + + b.Property("IsCompleted") + .HasColumnType("tinyint(1)"); + + b.Property("MerchantId") + .HasColumnType("char(36)"); + + b.Property("ResponseCode") + .HasColumnType("longtext"); + + b.Property("ResponseMessage") + .HasColumnType("longtext"); + + b.Property("TransactionCount") + .HasColumnType("int"); + + b.Property("TransactionDate") + .HasColumnType("datetime(6)"); + + b.Property("TransactionDateTime") + .HasColumnType("datetime(6)"); + + b.Property("TransactionTime") + .HasColumnType("time(6)"); + + b.Property("TransactionValue") + .HasColumnType("decimal(65,30)"); + + b.HasKey("TransactionId"); + + b.ToTable("reconciliation"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.ResponseCodes", b => + { + b.Property("ResponseCode") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("Description") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("ResponseCode"); + + b.ToTable("responsecodes"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Settlement", b => + { + b.Property("EstateId") + .HasColumnType("char(36)"); + + b.Property("SettlementId") + .HasColumnType("char(36)"); + + b.Property("IsCompleted") + .HasColumnType("tinyint(1)"); + + b.Property("SettlementDate") + .HasColumnType("datetime(6)"); + + b.HasKey("EstateId", "SettlementId"); + + b.ToTable("settlement"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.StatementHeader", b => + { + b.Property("StatementId") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("EstateId") + .HasColumnType("char(36)"); + + b.Property("MerchantId") + .HasColumnType("char(36)"); + + b.Property("StatementCreatedDate") + .HasColumnType("datetime(6)"); + + b.Property("StatementGeneratedDate") + .HasColumnType("datetime(6)"); + + b.HasKey("StatementId"); + + b.ToTable("statementheader"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.StatementLine", b => + { + b.Property("StatementId") + .HasColumnType("char(36)"); + + b.Property("TransactionId") + .HasColumnType("char(36)"); + + b.Property("ActivityDateTime") + .HasColumnType("datetime(6)"); + + b.Property("ActivityType") + .HasColumnType("int"); + + b.Property("ActivityDescription") + .HasColumnType("longtext"); + + b.Property("EstateId") + .HasColumnType("char(36)"); + + b.Property("InAmount") + .HasColumnType("decimal(65,30)"); + + b.Property("MerchantId") + .HasColumnType("char(36)"); + + b.Property("OutAmount") + .HasColumnType("decimal(65,30)"); + + b.HasKey("StatementId", "TransactionId", "ActivityDateTime", "ActivityType"); + + b.ToTable("statementline"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Transaction", b => + { + b.Property("EstateId") + .HasColumnType("char(36)"); + + b.Property("MerchantId") + .HasColumnType("char(36)"); + + b.Property("TransactionId") + .HasColumnType("char(36)"); + + b.Property("AuthorisationCode") + .HasColumnType("longtext"); + + b.Property("ContractId") + .HasColumnType("char(36)"); + + b.Property("DeviceIdentifier") + .HasColumnType("longtext"); + + b.Property("IsAuthorised") + .HasColumnType("tinyint(1)"); + + b.Property("IsCompleted") + .HasColumnType("tinyint(1)"); + + b.Property("OperatorIdentifier") + .HasColumnType("longtext"); + + b.Property("ProductId") + .HasColumnType("char(36)"); + + b.Property("ResponseCode") + .HasColumnType("longtext"); + + b.Property("ResponseMessage") + .HasColumnType("longtext"); + + b.Property("TransactionDate") + .HasColumnType("datetime(6)"); + + b.Property("TransactionDateTime") + .HasColumnType("datetime(6)"); + + b.Property("TransactionNumber") + .HasColumnType("longtext"); + + b.Property("TransactionReference") + .HasColumnType("longtext"); + + b.Property("TransactionSource") + .HasColumnType("int"); + + b.Property("TransactionTime") + .HasColumnType("time(6)"); + + b.Property("TransactionType") + .HasColumnType("longtext"); + + b.HasKey("EstateId", "MerchantId", "TransactionId"); + + b.ToTable("transaction"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.TransactionAdditionalRequestData", b => + { + b.Property("EstateId") + .HasColumnType("char(36)"); + + b.Property("MerchantId") + .HasColumnType("char(36)"); + + b.Property("TransactionId") + .HasColumnType("char(36)"); + + b.Property("Amount") + .HasColumnType("longtext"); + + b.Property("CustomerAccountNumber") + .HasColumnType("longtext"); + + b.HasKey("EstateId", "MerchantId", "TransactionId"); + + b.ToTable("transactionadditionalrequestdata"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.TransactionAdditionalResponseData", b => + { + b.Property("TransactionId") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("EstateId") + .HasColumnType("char(36)"); + + b.Property("MerchantId") + .HasColumnType("char(36)"); + + b.HasKey("TransactionId"); + + b.ToTable("transactionadditionalresponsedata"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.TransactionFee", b => + { + b.Property("TransactionId") + .HasColumnType("char(36)"); + + b.Property("FeeId") + .HasColumnType("char(36)"); + + b.Property("CalculatedValue") + .HasColumnType("decimal(65,30)"); + + b.Property("CalculationType") + .HasColumnType("int"); + + b.Property("EventId") + .HasColumnType("char(36)"); + + b.Property("FeeType") + .HasColumnType("int"); + + b.Property("FeeValue") + .HasColumnType("decimal(65,30)"); + + b.HasKey("TransactionId", "FeeId"); + + b.ToTable("transactionfee"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Voucher", b => + { + b.Property("VoucherId") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("EstateId") + .HasColumnType("char(36)"); + + b.Property("ExpiryDate") + .HasColumnType("datetime(6)"); + + b.Property("GenerateDateTime") + .HasColumnType("datetime(6)"); + + b.Property("IsGenerated") + .HasColumnType("tinyint(1)"); + + b.Property("IsIssued") + .HasColumnType("tinyint(1)"); + + b.Property("IsRedeemed") + .HasColumnType("tinyint(1)"); + + b.Property("IssuedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("OperatorIdentifier") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("RecipientEmail") + .HasColumnType("longtext"); + + b.Property("RecipientMobile") + .HasColumnType("longtext"); + + b.Property("RedeemedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("TransactionId") + .HasColumnType("char(36)"); + + b.Property("Value") + .HasColumnType("decimal(65,30)"); + + b.Property("VoucherCode") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("VoucherId"); + + b.ToTable("voucher"); + }); + + modelBuilder.Entity("EstateManagement.Database.ViewEntities.FileImportLogView", b => + { + b.Property("FileCount") + .HasColumnType("int"); + + b.Property("FileImportLogId") + .HasColumnType("char(36)"); + + b.Property("ImportLogDate") + .HasColumnType("datetime(6)"); + + b.Property("ImportLogDateTime") + .HasColumnType("datetime(6)"); + + b.Property("ImportLogTime") + .HasColumnType("time(6)"); + + b.Property("MerchantId") + .HasColumnType("char(36)"); + + b.ToTable("uvwFileImportLogView"); + + b.ToView("uvwFileImportLog", (string)null); + }); + + modelBuilder.Entity("EstateManagement.Database.ViewEntities.FileView", b => + { + b.Property("EmailAddress") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("FailedCount") + .HasColumnType("int"); + + b.Property("FileId") + .HasColumnType("char(36)"); + + b.Property("FileReceivedDate") + .HasColumnType("datetime(6)"); + + b.Property("FileReceivedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("FileReceivedTime") + .HasColumnType("time(6)"); + + b.Property("IsCompleted") + .HasColumnType("tinyint(1)"); + + b.Property("LineCount") + .HasColumnType("int"); + + b.Property("MerchantId") + .HasColumnType("char(36)"); + + b.Property("MerchantName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("PendingCount") + .HasColumnType("int"); + + b.Property("SuccessCount") + .HasColumnType("int"); + + b.Property("UserId") + .HasColumnType("char(36)"); + + b.ToTable("uvwFileView"); + + b.ToView("uvwFile", (string)null); + }); + + modelBuilder.Entity("EstateManagement.Database.ViewEntities.SettlementView", b => + { + b.Property("Amount") + .HasColumnType("decimal(65,30)"); + + b.Property("CalculatedValue") + .HasColumnType("decimal(65,30)"); + + b.Property("DayOfWeek") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("EstateId") + .HasColumnType("char(36)"); + + b.Property("FeeDescription") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("IsCompleted") + .HasColumnType("tinyint(1)"); + + b.Property("IsSettled") + .HasColumnType("tinyint(1)"); + + b.Property("MerchantId") + .HasColumnType("char(36)"); + + b.Property("MerchantName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("Month") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("MonthNumber") + .HasColumnType("int"); + + b.Property("OperatorIdentifier") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("SettlementDate") + .HasColumnType("datetime(6)"); + + b.Property("SettlementId") + .HasColumnType("char(36)"); + + b.Property("TransactionId") + .HasColumnType("char(36)"); + + b.Property("WeekNumber") + .HasColumnType("int"); + + b.Property("YearNumber") + .HasColumnType("int"); + + b.ToTable((string)null); + + b.ToView("uvwSettlements", (string)null); + }); + + modelBuilder.Entity("EstateManagement.Database.ViewEntities.TransactionsView", b => + { + b.Property("Amount") + .HasColumnType("decimal(65,30)"); + + b.Property("DayOfWeek") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("EstateId") + .HasColumnType("char(36)"); + + b.Property("IsAuthorised") + .HasColumnType("tinyint(1)"); + + b.Property("IsCompleted") + .HasColumnType("tinyint(1)"); + + b.Property("MerchantId") + .HasColumnType("char(36)"); + + b.Property("Month") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("MonthNumber") + .HasColumnType("int"); + + b.Property("OperatorIdentifier") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ResponseCode") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("TransactionDate") + .HasColumnType("datetime(6)"); + + b.Property("TransactionDateTime") + .HasColumnType("datetime(6)"); + + b.Property("TransactionId") + .HasColumnType("char(36)"); + + b.Property("TransactionType") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("WeekNumber") + .HasColumnType("int"); + + b.Property("YearNumber") + .HasColumnType("int"); + + b.ToTable("uvwTransactionsView"); + + b.ToView("uvwTransactions", (string)null); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/TransactionProcessor.Database/Migrations/MySql/20230116113800_recordproducttype.cs b/TransactionProcessor.Database/Migrations/MySql/20230116113800_recordproducttype.cs new file mode 100644 index 00000000..dc02bbf4 --- /dev/null +++ b/TransactionProcessor.Database/Migrations/MySql/20230116113800_recordproducttype.cs @@ -0,0 +1,29 @@ +#nullable disable + +using Microsoft.EntityFrameworkCore.Migrations; + +namespace TransactionProcessor.Database.Migrations.MySql +{ + /// + public partial class recordproducttype : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "ProductType", + table: "contractproduct", + type: "int", + nullable: false, + defaultValue: 0); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "ProductType", + table: "contractproduct"); + } + } +} diff --git a/TransactionProcessor.Database/Migrations/MySql/20230630115550_task384_datamodelrefactoring.Designer.cs b/TransactionProcessor.Database/Migrations/MySql/20230630115550_task384_datamodelrefactoring.Designer.cs new file mode 100644 index 00000000..415b1977 --- /dev/null +++ b/TransactionProcessor.Database/Migrations/MySql/20230630115550_task384_datamodelrefactoring.Designer.cs @@ -0,0 +1,992 @@ +// + +#nullable disable + +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using TransactionProcessor.Database.Contexts; + +namespace TransactionProcessor.Database.Migrations.MySql +{ + [DbContext(typeof(EstateManagementMySqlContext))] + [Migration("20230630115550_task384_datamodelrefactoring")] + partial class task384_datamodelrefactoring + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "7.0.7") + .HasAnnotation("Relational:MaxIdentifierLength", 64); + + modelBuilder.Entity("EstateManagement.Database.Entities.Calendar", b => + { + b.Property("Date") + .HasColumnType("datetime(6)"); + + b.Property("DayOfWeek") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("DayOfWeekNumber") + .HasColumnType("int"); + + b.Property("DayOfWeekShort") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("MonthNameLong") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("MonthNameShort") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("MonthNumber") + .HasColumnType("int"); + + b.Property("WeekNumber") + .HasColumnType("int"); + + b.Property("WeekNumberString") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("Year") + .HasColumnType("int"); + + b.Property("YearWeekNumber") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("Date"); + + b.ToTable("calendar"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Contract", b => + { + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("OperatorId") + .HasColumnType("char(36)"); + + b.Property("ContractId") + .HasColumnType("char(36)"); + + b.Property("ContractReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("Description") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("EstateReportingId", "OperatorId", "ContractId"); + + b.ToTable("contract"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.ContractProduct", b => + { + b.Property("ContractReportingId") + .HasColumnType("int"); + + b.Property("ProductId") + .HasColumnType("char(36)"); + + b.Property("ContractProductReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("DisplayText") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ProductName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ProductType") + .HasColumnType("int"); + + b.Property("Value") + .HasColumnType("decimal(65,30)"); + + b.HasKey("ContractReportingId", "ProductId"); + + b.ToTable("contractproduct"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.ContractProductTransactionFee", b => + { + b.Property("ContractProductReportingId") + .HasColumnType("int"); + + b.Property("TransactionFeeId") + .HasColumnType("char(36)"); + + b.Property("CalculationType") + .HasColumnType("int"); + + b.Property("Description") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("FeeType") + .HasColumnType("int"); + + b.Property("IsEnabled") + .HasColumnType("tinyint(1)"); + + b.Property("TransactionFeeReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("Value") + .HasColumnType("decimal(18,4)"); + + b.HasKey("ContractProductReportingId", "TransactionFeeId"); + + b.ToTable("contractproducttransactionfee"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Estate", b => + { + b.Property("EstateReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("EstateId") + .HasColumnType("char(36)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("Reference") + .HasColumnType("longtext"); + + b.HasKey("EstateReportingId"); + + b.HasIndex("EstateId") + .IsUnique(); + + b.ToTable("estate"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.EstateOperator", b => + { + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("OperatorId") + .HasColumnType("char(36)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("RequireCustomMerchantNumber") + .HasColumnType("tinyint(1)"); + + b.Property("RequireCustomTerminalNumber") + .HasColumnType("tinyint(1)"); + + b.HasKey("EstateReportingId", "OperatorId"); + + b.ToTable("estateoperator"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.EstateSecurityUser", b => + { + b.Property("SecurityUserId") + .HasColumnType("char(36)"); + + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("EmailAddress") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("SecurityUserId", "EstateReportingId"); + + b.ToTable("estatesecurityuser"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.File", b => + { + b.Property("FileReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("FileId") + .HasColumnType("char(36)"); + + b.Property("FileImportLogReportingId") + .HasColumnType("int"); + + b.Property("FileLocation") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("FileProfileId") + .HasColumnType("char(36)"); + + b.Property("FileReceivedDate") + .HasColumnType("date"); + + b.Property("FileReceivedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("IsCompleted") + .HasColumnType("tinyint(1)"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("UserId") + .HasColumnType("char(36)"); + + b.HasKey("FileReportingId"); + + b.HasIndex("FileId") + .IsUnique(); + + b.ToTable("file"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.FileImportLog", b => + { + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("FileImportLogReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("FileImportLogId") + .HasColumnType("char(36)"); + + b.Property("ImportLogDate") + .HasColumnType("date"); + + b.Property("ImportLogDateTime") + .HasColumnType("datetime(6)"); + + b.HasKey("EstateReportingId", "FileImportLogReportingId"); + + b.HasIndex("EstateReportingId", "FileImportLogId") + .IsUnique(); + + b.ToTable("fileimportlog"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.FileImportLogFile", b => + { + b.Property("FileImportLogReportingId") + .HasColumnType("int"); + + b.Property("FileReportingId") + .HasColumnType("int"); + + b.Property("FilePath") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("FileProfileId") + .HasColumnType("char(36)"); + + b.Property("FileUploadedDate") + .HasColumnType("date"); + + b.Property("FileUploadedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("OriginalFileName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("UserId") + .HasColumnType("char(36)"); + + b.HasKey("FileImportLogReportingId", "FileReportingId"); + + b.ToTable("fileimportlogfile"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.FileLine", b => + { + b.Property("FileReportingId") + .HasColumnType("int"); + + b.Property("LineNumber") + .HasColumnType("int"); + + b.Property("FileLineData") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("Status") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.HasKey("FileReportingId", "LineNumber") + .HasAnnotation("SqlServer:Clustered", true); + + b.HasIndex("TransactionReportingId"); + + b.ToTable("fileline"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Merchant", b => + { + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("MerchantReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("LastStatementGenerated") + .HasColumnType("datetime(6)"); + + b.Property("MerchantId") + .HasColumnType("char(36)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("Reference") + .HasColumnType("longtext"); + + b.Property("SettlementSchedule") + .HasColumnType("int"); + + b.HasKey("EstateReportingId", "MerchantReportingId"); + + b.HasIndex("EstateReportingId", "MerchantId") + .IsUnique(); + + b.ToTable("merchant"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantAddress", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("AddressId") + .HasColumnType("char(36)"); + + b.Property("AddressLine1") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("AddressLine2") + .HasColumnType("longtext"); + + b.Property("AddressLine3") + .HasColumnType("longtext"); + + b.Property("AddressLine4") + .HasColumnType("longtext"); + + b.Property("Country") + .HasColumnType("longtext"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("PostalCode") + .HasColumnType("longtext"); + + b.Property("Region") + .HasColumnType("longtext"); + + b.Property("Town") + .HasColumnType("longtext"); + + b.HasKey("MerchantReportingId", "AddressId"); + + b.ToTable("merchantaddress"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantContact", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("ContactId") + .HasColumnType("char(36)"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("EmailAddress") + .HasColumnType("longtext"); + + b.Property("Name") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("PhoneNumber") + .HasColumnType("longtext"); + + b.HasKey("MerchantReportingId", "ContactId"); + + b.ToTable("merchantcontact"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantDevice", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("DeviceId") + .HasColumnType("char(36)"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("DeviceIdentifier") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("MerchantReportingId", "DeviceId"); + + b.ToTable("merchantdevice"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantOperator", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("OperatorId") + .HasColumnType("char(36)"); + + b.Property("MerchantNumber") + .HasColumnType("longtext"); + + b.Property("Name") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("TerminalNumber") + .HasColumnType("longtext"); + + b.HasKey("MerchantReportingId", "OperatorId"); + + b.ToTable("merchantoperator"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantSecurityUser", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("SecurityUserId") + .HasColumnType("char(36)"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("EmailAddress") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("MerchantReportingId", "SecurityUserId"); + + b.ToTable("merchantsecurityuser"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantSettlementFee", b => + { + b.Property("SettlementReportingId") + .HasColumnType("int"); + + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.Property("TransactionFeeReportingId") + .HasColumnType("int"); + + b.Property("CalculatedValue") + .HasColumnType("decimal(65,30)"); + + b.Property("FeeCalculatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("FeeValue") + .HasColumnType("decimal(65,30)"); + + b.Property("IsSettled") + .HasColumnType("tinyint(1)"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.HasKey("SettlementReportingId", "TransactionReportingId", "TransactionFeeReportingId"); + + b.ToTable("merchantsettlementfee"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Reconciliation", b => + { + b.Property("TransactionReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("DeviceIdentifier") + .HasColumnType("longtext"); + + b.Property("IsAuthorised") + .HasColumnType("tinyint(1)"); + + b.Property("IsCompleted") + .HasColumnType("tinyint(1)"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("ResponseCode") + .HasColumnType("longtext"); + + b.Property("ResponseMessage") + .HasColumnType("longtext"); + + b.Property("TransactionCount") + .HasColumnType("int"); + + b.Property("TransactionDate") + .HasColumnType("date"); + + b.Property("TransactionDateTime") + .HasColumnType("datetime(6)"); + + b.Property("TransactionId") + .HasColumnType("char(36)"); + + b.Property("TransactionTime") + .HasColumnType("time(6)"); + + b.Property("TransactionValue") + .HasColumnType("decimal(65,30)"); + + b.HasKey("TransactionReportingId") + .HasAnnotation("SqlServer:Clustered", false); + + b.HasIndex("TransactionDate", "MerchantReportingId") + .HasAnnotation("SqlServer:Clustered", true); + + b.HasIndex("TransactionId", "MerchantReportingId") + .IsUnique() + .HasAnnotation("SqlServer:Clustered", false); + + b.ToTable("reconciliation"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.ResponseCodes", b => + { + b.Property("ResponseCode") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("Description") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("ResponseCode"); + + b.ToTable("responsecodes"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Settlement", b => + { + b.Property("SettlementReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("IsCompleted") + .HasColumnType("tinyint(1)"); + + b.Property("SettlementDate") + .HasColumnType("date"); + + b.Property("SettlementId") + .HasColumnType("char(36)"); + + b.HasKey("SettlementReportingId") + .HasAnnotation("SqlServer:Clustered", false); + + b.HasIndex("EstateReportingId", "SettlementId") + .IsUnique() + .HasAnnotation("SqlServer:Clustered", false); + + b.HasIndex("SettlementDate", "EstateReportingId") + .HasAnnotation("SqlServer:Clustered", true); + + b.ToTable("settlement"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.StatementHeader", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("StatementId") + .HasColumnType("char(36)"); + + b.Property("StatementCreatedDate") + .HasColumnType("date"); + + b.Property("StatementCreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("StatementGeneratedDate") + .HasColumnType("date"); + + b.Property("StatementGeneratedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("StatementReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.HasKey("MerchantReportingId", "StatementId") + .HasAnnotation("SqlServer:Clustered", false); + + b.HasIndex("MerchantReportingId", "StatementGeneratedDate") + .IsUnique() + .HasAnnotation("SqlServer:Clustered", true); + + b.ToTable("statementheader"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.StatementLine", b => + { + b.Property("StatementReportingId") + .HasColumnType("int"); + + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.Property("ActivityDateTime") + .HasColumnType("datetime(6)"); + + b.Property("ActivityType") + .HasColumnType("int"); + + b.Property("ActivityDate") + .HasColumnType("date"); + + b.Property("ActivityDescription") + .HasColumnType("longtext"); + + b.Property("InAmount") + .HasColumnType("decimal(65,30)"); + + b.Property("OutAmount") + .HasColumnType("decimal(65,30)"); + + b.HasKey("StatementReportingId", "TransactionReportingId", "ActivityDateTime", "ActivityType"); + + b.ToTable("statementline"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Transaction", b => + { + b.Property("TransactionReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("AuthorisationCode") + .HasColumnType("longtext"); + + b.Property("ContractProductReportingId") + .HasColumnType("int"); + + b.Property("ContractReportingId") + .HasColumnType("int"); + + b.Property("DeviceIdentifier") + .HasColumnType("longtext"); + + b.Property("IsAuthorised") + .HasColumnType("tinyint(1)"); + + b.Property("IsCompleted") + .HasColumnType("tinyint(1)"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("OperatorIdentifier") + .HasColumnType("longtext"); + + b.Property("ResponseCode") + .HasColumnType("longtext"); + + b.Property("ResponseMessage") + .HasColumnType("longtext"); + + b.Property("TransactionDate") + .HasColumnType("date"); + + b.Property("TransactionDateTime") + .HasColumnType("datetime(6)"); + + b.Property("TransactionId") + .HasColumnType("char(36)"); + + b.Property("TransactionNumber") + .HasColumnType("longtext"); + + b.Property("TransactionReference") + .HasColumnType("longtext"); + + b.Property("TransactionSource") + .HasColumnType("int"); + + b.Property("TransactionTime") + .HasColumnType("time(6)"); + + b.Property("TransactionType") + .HasColumnType("longtext"); + + b.HasKey("TransactionReportingId") + .HasAnnotation("SqlServer:Clustered", false); + + b.HasIndex("TransactionDate", "MerchantReportingId") + .HasAnnotation("SqlServer:Clustered", true); + + b.HasIndex("TransactionId", "MerchantReportingId") + .IsUnique() + .HasAnnotation("SqlServer:Clustered", false); + + b.ToTable("transaction"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.TransactionAdditionalRequestData", b => + { + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.Property("Amount") + .HasColumnType("longtext"); + + b.Property("CustomerAccountNumber") + .HasColumnType("longtext"); + + b.HasKey("TransactionReportingId"); + + b.ToTable("transactionadditionalrequestdata"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.TransactionAdditionalResponseData", b => + { + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.HasKey("TransactionReportingId"); + + b.ToTable("transactionadditionalresponsedata"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.TransactionFee", b => + { + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.Property("TransactionFeeReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("CalculatedValue") + .HasColumnType("decimal(65,30)"); + + b.Property("CalculationType") + .HasColumnType("int"); + + b.Property("EventId") + .HasColumnType("char(36)"); + + b.Property("FeeId") + .HasColumnType("char(36)"); + + b.Property("FeeType") + .HasColumnType("int"); + + b.Property("FeeValue") + .HasColumnType("decimal(65,30)"); + + b.HasKey("TransactionReportingId", "TransactionFeeReportingId"); + + b.HasIndex("FeeId") + .IsUnique(); + + b.ToTable("transactionfee"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Voucher", b => + { + b.Property("VoucherId") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("ExpiryDate") + .HasColumnType("date"); + + b.Property("ExpiryDateTime") + .HasColumnType("datetime(6)"); + + b.Property("GenerateDate") + .HasColumnType("date"); + + b.Property("GenerateDateTime") + .HasColumnType("datetime(6)"); + + b.Property("IsGenerated") + .HasColumnType("tinyint(1)"); + + b.Property("IsIssued") + .HasColumnType("tinyint(1)"); + + b.Property("IsRedeemed") + .HasColumnType("tinyint(1)"); + + b.Property("IssuedDate") + .HasColumnType("date"); + + b.Property("IssuedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("OperatorIdentifier") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("RecipientEmail") + .HasColumnType("longtext"); + + b.Property("RecipientMobile") + .HasColumnType("longtext"); + + b.Property("RedeemedDate") + .HasColumnType("datetime(6)"); + + b.Property("RedeemedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.Property("Value") + .HasColumnType("decimal(65,30)"); + + b.Property("VoucherCode") + .IsRequired() + .HasColumnType("varchar(255)"); + + b.HasKey("VoucherId"); + + b.HasIndex("TransactionReportingId"); + + b.HasIndex("VoucherCode"); + + b.ToTable("voucher"); + }); + + modelBuilder.Entity("EstateManagement.Database.ViewEntities.SettlementView", b => + { + b.Property("Amount") + .HasColumnType("decimal(65,30)"); + + b.Property("CalculatedValue") + .HasColumnType("decimal(65,30)"); + + b.Property("DayOfWeek") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("EstateId") + .HasColumnType("char(36)"); + + b.Property("FeeDescription") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("IsCompleted") + .HasColumnType("tinyint(1)"); + + b.Property("IsSettled") + .HasColumnType("tinyint(1)"); + + b.Property("MerchantId") + .HasColumnType("char(36)"); + + b.Property("MerchantName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("Month") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("MonthNumber") + .HasColumnType("int"); + + b.Property("OperatorIdentifier") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("SettlementDate") + .HasColumnType("datetime(6)"); + + b.Property("SettlementId") + .HasColumnType("char(36)"); + + b.Property("TransactionId") + .HasColumnType("char(36)"); + + b.Property("WeekNumber") + .HasColumnType("int"); + + b.Property("YearNumber") + .HasColumnType("int"); + + b.ToTable((string)null); + + b.ToView("uvwSettlements", (string)null); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/TransactionProcessor.Database/Migrations/MySql/20230630115550_task384_datamodelrefactoring.cs b/TransactionProcessor.Database/Migrations/MySql/20230630115550_task384_datamodelrefactoring.cs new file mode 100644 index 00000000..0f06f6a0 --- /dev/null +++ b/TransactionProcessor.Database/Migrations/MySql/20230630115550_task384_datamodelrefactoring.cs @@ -0,0 +1,2144 @@ +#nullable disable + +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; + +namespace TransactionProcessor.Database.Migrations.MySql +{ + /// + public partial class task384_datamodelrefactoring : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "uvwFileImportLogView"); + + migrationBuilder.DropTable( + name: "uvwFileView"); + + migrationBuilder.DropTable( + name: "uvwTransactionsView"); + + migrationBuilder.DropPrimaryKey( + name: "PK_transactionfee", + table: "transactionfee"); + + migrationBuilder.DropPrimaryKey( + name: "PK_transactionadditionalresponsedata", + table: "transactionadditionalresponsedata"); + + migrationBuilder.DropPrimaryKey( + name: "PK_transactionadditionalrequestdata", + table: "transactionadditionalrequestdata"); + + migrationBuilder.DropPrimaryKey( + name: "PK_transaction", + table: "transaction"); + + migrationBuilder.DropPrimaryKey( + name: "PK_statementline", + table: "statementline"); + + migrationBuilder.DropPrimaryKey( + name: "PK_statementheader", + table: "statementheader"); + + migrationBuilder.DropPrimaryKey( + name: "PK_settlement", + table: "settlement"); + + migrationBuilder.DropPrimaryKey( + name: "PK_reconciliation", + table: "reconciliation"); + + migrationBuilder.DropPrimaryKey( + name: "PK_merchantsettlementfee", + table: "merchantsettlementfee"); + + migrationBuilder.DropPrimaryKey( + name: "PK_merchantsecurityuser", + table: "merchantsecurityuser"); + + migrationBuilder.DropPrimaryKey( + name: "PK_merchantoperator", + table: "merchantoperator"); + + migrationBuilder.DropPrimaryKey( + name: "PK_merchantdevice", + table: "merchantdevice"); + + migrationBuilder.DropPrimaryKey( + name: "PK_merchantcontact", + table: "merchantcontact"); + + migrationBuilder.DropPrimaryKey( + name: "PK_merchantaddress", + table: "merchantaddress"); + + migrationBuilder.DropPrimaryKey( + name: "PK_merchant", + table: "merchant"); + + migrationBuilder.DropPrimaryKey( + name: "PK_fileline", + table: "fileline"); + + migrationBuilder.DropPrimaryKey( + name: "PK_fileimportlogfile", + table: "fileimportlogfile"); + + migrationBuilder.DropPrimaryKey( + name: "PK_fileimportlog", + table: "fileimportlog"); + + migrationBuilder.DropPrimaryKey( + name: "PK_file", + table: "file"); + + migrationBuilder.DropPrimaryKey( + name: "PK_estatesecurityuser", + table: "estatesecurityuser"); + + migrationBuilder.DropPrimaryKey( + name: "PK_estateoperator", + table: "estateoperator"); + + migrationBuilder.DropPrimaryKey( + name: "PK_estate", + table: "estate"); + + migrationBuilder.DropPrimaryKey( + name: "PK_contractproducttransactionfee", + table: "contractproducttransactionfee"); + + migrationBuilder.DropPrimaryKey( + name: "PK_contractproduct", + table: "contractproduct"); + + migrationBuilder.DropPrimaryKey( + name: "PK_contract", + table: "contract"); + + migrationBuilder.DropColumn( + name: "EstateId", + table: "voucher"); + + migrationBuilder.DropColumn( + name: "TransactionId", + table: "voucher"); + + migrationBuilder.DropColumn( + name: "TransactionId", + table: "transactionfee"); + + migrationBuilder.AddColumn( + name: "TransactionReportingId", + table: "transactionadditionalresponsedata", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "TransactionReportingId", + table: "transactionadditionalrequestdata", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.DropColumn( + name: "TransactionId", + table: "transactionadditionalresponsedata"); + + migrationBuilder.DropColumn( + name: "EstateId", + table: "transactionadditionalresponsedata"); + + migrationBuilder.DropColumn( + name: "MerchantId", + table: "transactionadditionalresponsedata"); + + migrationBuilder.DropColumn( + name: "EstateId", + table: "transactionadditionalrequestdata"); + + migrationBuilder.DropColumn( + name: "MerchantId", + table: "transactionadditionalrequestdata"); + + migrationBuilder.DropColumn( + name: "TransactionId", + table: "transactionadditionalrequestdata"); + + migrationBuilder.DropColumn( + name: "EstateId", + table: "transaction"); + + migrationBuilder.DropColumn( + name: "MerchantId", + table: "transaction"); + + migrationBuilder.DropColumn( + name: "ContractId", + table: "transaction"); + + migrationBuilder.DropColumn( + name: "ProductId", + table: "transaction"); + + migrationBuilder.DropColumn( + name: "StatementId", + table: "statementline"); + + migrationBuilder.DropColumn( + name: "TransactionId", + table: "statementline"); + + migrationBuilder.DropColumn( + name: "EstateId", + table: "statementline"); + + migrationBuilder.DropColumn( + name: "MerchantId", + table: "statementline"); + + migrationBuilder.DropColumn( + name: "EstateId", + table: "statementheader"); + + migrationBuilder.DropColumn( + name: "MerchantId", + table: "statementheader"); + + migrationBuilder.DropColumn( + name: "EstateId", + table: "settlement"); + + migrationBuilder.DropColumn( + name: "EstateId", + table: "reconciliation"); + + migrationBuilder.DropColumn( + name: "MerchantId", + table: "reconciliation"); + + migrationBuilder.DropColumn( + name: "EstateId", + table: "merchantsettlementfee"); + + migrationBuilder.DropColumn( + name: "SettlementId", + table: "merchantsettlementfee"); + + migrationBuilder.DropColumn( + name: "TransactionId", + table: "merchantsettlementfee"); + + migrationBuilder.DropColumn( + name: "FeeId", + table: "merchantsettlementfee"); + + migrationBuilder.DropColumn( + name: "MerchantId", + table: "merchantsettlementfee"); + + migrationBuilder.DropColumn( + name: "EstateId", + table: "merchantsecurityuser"); + + migrationBuilder.DropColumn( + name: "MerchantId", + table: "merchantsecurityuser"); + + migrationBuilder.DropColumn( + name: "EstateId", + table: "merchantoperator"); + + migrationBuilder.DropColumn( + name: "MerchantId", + table: "merchantoperator"); + + migrationBuilder.DropColumn( + name: "EstateId", + table: "merchantdevice"); + + migrationBuilder.DropColumn( + name: "MerchantId", + table: "merchantdevice"); + + migrationBuilder.DropColumn( + name: "EstateId", + table: "merchantcontact"); + + migrationBuilder.DropColumn( + name: "MerchantId", + table: "merchantcontact"); + + migrationBuilder.DropColumn( + name: "EstateId", + table: "merchantaddress"); + + migrationBuilder.DropColumn( + name: "MerchantId", + table: "merchantaddress"); + + migrationBuilder.DropColumn( + name: "EstateId", + table: "merchant"); + + migrationBuilder.DropColumn( + name: "EstateId", + table: "fileline"); + + migrationBuilder.DropColumn( + name: "FileId", + table: "fileline"); + + migrationBuilder.DropColumn( + name: "TransactionId", + table: "fileline"); + + migrationBuilder.DropColumn( + name: "EstateId", + table: "fileimportlogfile"); + + migrationBuilder.DropColumn( + name: "FileImportLogId", + table: "fileimportlogfile"); + + migrationBuilder.DropColumn( + name: "FileId", + table: "fileimportlogfile"); + + migrationBuilder.DropColumn( + name: "MerchantId", + table: "fileimportlogfile"); + + migrationBuilder.DropColumn( + name: "EstateId", + table: "fileimportlog"); + + migrationBuilder.DropColumn( + name: "EstateId", + table: "file"); + + migrationBuilder.DropColumn( + name: "FileImportLogId", + table: "file"); + + migrationBuilder.DropColumn( + name: "MerchantId", + table: "file"); + + migrationBuilder.DropColumn( + name: "EstateId", + table: "estatesecurityuser"); + + migrationBuilder.DropColumn( + name: "EstateId", + table: "estateoperator"); + + migrationBuilder.DropColumn( + name: "EstateId", + table: "contractproducttransactionfee"); + + migrationBuilder.DropColumn( + name: "ContractId", + table: "contractproducttransactionfee"); + + migrationBuilder.DropColumn( + name: "ProductId", + table: "contractproducttransactionfee"); + + migrationBuilder.DropColumn( + name: "EstateId", + table: "contractproduct"); + + migrationBuilder.DropColumn( + name: "ContractId", + table: "contractproduct"); + + migrationBuilder.DropColumn( + name: "EstateId", + table: "contract"); + + migrationBuilder.AlterColumn( + name: "VoucherCode", + table: "voucher", + type: "varchar(255)", + nullable: false, + oldClrType: typeof(string), + oldType: "longtext") + .Annotation("MySql:CharSet", "utf8mb4") + .OldAnnotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.AlterColumn( + name: "ExpiryDate", + table: "voucher", + type: "date", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "datetime(6)"); + + migrationBuilder.AddColumn( + name: "ExpiryDateTime", + table: "voucher", + type: "datetime(6)", + nullable: false, + defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified)); + + migrationBuilder.AddColumn( + name: "GenerateDate", + table: "voucher", + type: "date", + nullable: false, + defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified)); + + migrationBuilder.AddColumn( + name: "IssuedDate", + table: "voucher", + type: "date", + nullable: false, + defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified)); + + migrationBuilder.AddColumn( + name: "RedeemedDate", + table: "voucher", + type: "datetime(6)", + nullable: false, + defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified)); + + migrationBuilder.AddColumn( + name: "TransactionReportingId", + table: "voucher", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "TransactionReportingId", + table: "transactionfee", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "TransactionFeeReportingId", + table: "transactionfee", + type: "int", + nullable: false, + defaultValue: 0) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn); + + migrationBuilder.AlterColumn( + name: "TransactionDate", + table: "transaction", + type: "date", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "datetime(6)"); + + migrationBuilder.AddColumn( + name: "TransactionReportingId", + table: "transaction", + type: "int", + nullable: false, + defaultValue: 0) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn); + + migrationBuilder.AddColumn( + name: "ContractProductReportingId", + table: "transaction", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "ContractReportingId", + table: "transaction", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "MerchantReportingId", + table: "transaction", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "StatementReportingId", + table: "statementline", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "TransactionReportingId", + table: "statementline", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "ActivityDate", + table: "statementline", + type: "date", + nullable: false, + defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified)); + + migrationBuilder.AlterColumn( + name: "StatementGeneratedDate", + table: "statementheader", + type: "date", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "datetime(6)"); + + migrationBuilder.AlterColumn( + name: "StatementCreatedDate", + table: "statementheader", + type: "date", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "datetime(6)"); + + migrationBuilder.AddColumn( + name: "MerchantReportingId", + table: "statementheader", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "StatementCreatedDateTime", + table: "statementheader", + type: "datetime(6)", + nullable: false, + defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified)); + + migrationBuilder.AddColumn( + name: "StatementGeneratedDateTime", + table: "statementheader", + type: "datetime(6)", + nullable: false, + defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified)); + + migrationBuilder.AddColumn( + name: "StatementReportingId", + table: "statementheader", + type: "int", + nullable: false, + defaultValue: 0) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn); + + migrationBuilder.AlterColumn( + name: "SettlementDate", + table: "settlement", + type: "date", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "datetime(6)"); + + migrationBuilder.AddColumn( + name: "SettlementReportingId", + table: "settlement", + type: "int", + nullable: false, + defaultValue: 0) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn); + + migrationBuilder.AddColumn( + name: "EstateReportingId", + table: "settlement", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AlterColumn( + name: "TransactionDate", + table: "reconciliation", + type: "date", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "datetime(6)"); + + migrationBuilder.AddColumn( + name: "TransactionReportingId", + table: "reconciliation", + type: "int", + nullable: false, + defaultValue: 0) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn); + + migrationBuilder.AddColumn( + name: "MerchantReportingId", + table: "reconciliation", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "SettlementReportingId", + table: "merchantsettlementfee", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "TransactionReportingId", + table: "merchantsettlementfee", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "TransactionFeeReportingId", + table: "merchantsettlementfee", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "MerchantReportingId", + table: "merchantsettlementfee", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "MerchantReportingId", + table: "merchantsecurityuser", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "MerchantReportingId", + table: "merchantoperator", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "MerchantReportingId", + table: "merchantdevice", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "MerchantReportingId", + table: "merchantcontact", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "MerchantReportingId", + table: "merchantaddress", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "EstateReportingId", + table: "merchant", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "MerchantReportingId", + table: "merchant", + type: "int", + nullable: false, + defaultValue: 0) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn); + + migrationBuilder.AddColumn( + name: "FileReportingId", + table: "fileline", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "TransactionReportingId", + table: "fileline", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "FileImportLogReportingId", + table: "fileimportlogfile", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "FileReportingId", + table: "fileimportlogfile", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "FileUploadedDate", + table: "fileimportlogfile", + type: "date", + nullable: false, + defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified)); + + migrationBuilder.AddColumn( + name: "MerchantReportingId", + table: "fileimportlogfile", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "EstateReportingId", + table: "fileimportlog", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "FileImportLogReportingId", + table: "fileimportlog", + type: "int", + nullable: false, + defaultValue: 0) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn); + + migrationBuilder.AddColumn( + name: "ImportLogDate", + table: "fileimportlog", + type: "date", + nullable: false, + defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified)); + + migrationBuilder.AddColumn( + name: "FileReportingId", + table: "file", + type: "int", + nullable: false, + defaultValue: 0) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn); + + migrationBuilder.AddColumn( + name: "EstateReportingId", + table: "file", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "FileImportLogReportingId", + table: "file", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "FileReceivedDate", + table: "file", + type: "date", + nullable: false, + defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified)); + + migrationBuilder.AddColumn( + name: "MerchantReportingId", + table: "file", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "EstateReportingId", + table: "estatesecurityuser", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "EstateReportingId", + table: "estateoperator", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "EstateReportingId", + table: "estate", + type: "int", + nullable: false, + defaultValue: 0) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn); + + migrationBuilder.AddColumn( + name: "ContractProductReportingId", + table: "contractproducttransactionfee", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "TransactionFeeReportingId", + table: "contractproducttransactionfee", + type: "int", + nullable: false, + defaultValue: 0) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn); + + migrationBuilder.AddColumn( + name: "ContractReportingId", + table: "contractproduct", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "ContractProductReportingId", + table: "contractproduct", + type: "int", + nullable: false, + defaultValue: 0) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn); + + migrationBuilder.AddColumn( + name: "EstateReportingId", + table: "contract", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "ContractReportingId", + table: "contract", + type: "int", + nullable: false, + defaultValue: 0) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn); + + migrationBuilder.AddPrimaryKey( + name: "PK_transactionfee", + table: "transactionfee", + columns: new[] { "TransactionReportingId", "TransactionFeeReportingId" }); + + migrationBuilder.AddPrimaryKey( + name: "PK_transactionadditionalresponsedata", + table: "transactionadditionalresponsedata", + column: "TransactionReportingId"); + + migrationBuilder.AddPrimaryKey( + name: "PK_transactionadditionalrequestdata", + table: "transactionadditionalrequestdata", + column: "TransactionReportingId"); + + migrationBuilder.AddPrimaryKey( + name: "PK_transaction", + table: "transaction", + column: "TransactionReportingId"); + + migrationBuilder.AddPrimaryKey( + name: "PK_statementline", + table: "statementline", + columns: new[] { "StatementReportingId", "TransactionReportingId", "ActivityDateTime", "ActivityType" }); + + migrationBuilder.AddPrimaryKey( + name: "PK_statementheader", + table: "statementheader", + columns: new[] { "MerchantReportingId", "StatementId" }); + + migrationBuilder.AddPrimaryKey( + name: "PK_settlement", + table: "settlement", + column: "SettlementReportingId"); + + migrationBuilder.AddPrimaryKey( + name: "PK_reconciliation", + table: "reconciliation", + column: "TransactionReportingId"); + + migrationBuilder.AddPrimaryKey( + name: "PK_merchantsettlementfee", + table: "merchantsettlementfee", + columns: new[] { "SettlementReportingId", "TransactionReportingId", "TransactionFeeReportingId" }); + + migrationBuilder.AddPrimaryKey( + name: "PK_merchantsecurityuser", + table: "merchantsecurityuser", + columns: new[] { "MerchantReportingId", "SecurityUserId" }); + + migrationBuilder.AddPrimaryKey( + name: "PK_merchantoperator", + table: "merchantoperator", + columns: new[] { "MerchantReportingId", "OperatorId" }); + + migrationBuilder.AddPrimaryKey( + name: "PK_merchantdevice", + table: "merchantdevice", + columns: new[] { "MerchantReportingId", "DeviceId" }); + + migrationBuilder.AddPrimaryKey( + name: "PK_merchantcontact", + table: "merchantcontact", + columns: new[] { "MerchantReportingId", "ContactId" }); + + migrationBuilder.AddPrimaryKey( + name: "PK_merchantaddress", + table: "merchantaddress", + columns: new[] { "MerchantReportingId", "AddressId" }); + + migrationBuilder.AddPrimaryKey( + name: "PK_merchant", + table: "merchant", + columns: new[] { "EstateReportingId", "MerchantReportingId" }); + + migrationBuilder.AddPrimaryKey( + name: "PK_fileline", + table: "fileline", + columns: new[] { "FileReportingId", "LineNumber" }); + + migrationBuilder.AddPrimaryKey( + name: "PK_fileimportlogfile", + table: "fileimportlogfile", + columns: new[] { "FileImportLogReportingId", "FileReportingId" }); + + migrationBuilder.AddPrimaryKey( + name: "PK_fileimportlog", + table: "fileimportlog", + columns: new[] { "EstateReportingId", "FileImportLogReportingId" }); + + migrationBuilder.AddPrimaryKey( + name: "PK_file", + table: "file", + column: "FileReportingId"); + + migrationBuilder.AddPrimaryKey( + name: "PK_estatesecurityuser", + table: "estatesecurityuser", + columns: new[] { "SecurityUserId", "EstateReportingId" }); + + migrationBuilder.AddPrimaryKey( + name: "PK_estateoperator", + table: "estateoperator", + columns: new[] { "EstateReportingId", "OperatorId" }); + + migrationBuilder.AddPrimaryKey( + name: "PK_estate", + table: "estate", + column: "EstateReportingId"); + + migrationBuilder.AddPrimaryKey( + name: "PK_contractproducttransactionfee", + table: "contractproducttransactionfee", + columns: new[] { "ContractProductReportingId", "TransactionFeeId" }); + + migrationBuilder.AddPrimaryKey( + name: "PK_contractproduct", + table: "contractproduct", + columns: new[] { "ContractReportingId", "ProductId" }); + + migrationBuilder.AddPrimaryKey( + name: "PK_contract", + table: "contract", + columns: new[] { "EstateReportingId", "OperatorId", "ContractId" }); + + migrationBuilder.CreateIndex( + name: "IX_voucher_TransactionReportingId", + table: "voucher", + column: "TransactionReportingId"); + + migrationBuilder.CreateIndex( + name: "IX_voucher_VoucherCode", + table: "voucher", + column: "VoucherCode"); + + migrationBuilder.CreateIndex( + name: "IX_transactionfee_FeeId", + table: "transactionfee", + column: "FeeId", + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_transaction_TransactionDate_MerchantReportingId", + table: "transaction", + columns: new[] { "TransactionDate", "MerchantReportingId" }); + + migrationBuilder.CreateIndex( + name: "IX_transaction_TransactionId_MerchantReportingId", + table: "transaction", + columns: new[] { "TransactionId", "MerchantReportingId" }, + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_statementheader_MerchantReportingId_StatementGeneratedDate", + table: "statementheader", + columns: new[] { "MerchantReportingId", "StatementGeneratedDate" }, + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_settlement_EstateReportingId_SettlementId", + table: "settlement", + columns: new[] { "EstateReportingId", "SettlementId" }, + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_settlement_SettlementDate_EstateReportingId", + table: "settlement", + columns: new[] { "SettlementDate", "EstateReportingId" }); + + migrationBuilder.CreateIndex( + name: "IX_reconciliation_TransactionDate_MerchantReportingId", + table: "reconciliation", + columns: new[] { "TransactionDate", "MerchantReportingId" }); + + migrationBuilder.CreateIndex( + name: "IX_reconciliation_TransactionId_MerchantReportingId", + table: "reconciliation", + columns: new[] { "TransactionId", "MerchantReportingId" }, + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_merchant_EstateReportingId_MerchantId", + table: "merchant", + columns: new[] { "EstateReportingId", "MerchantId" }, + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_fileline_TransactionReportingId", + table: "fileline", + column: "TransactionReportingId"); + + migrationBuilder.CreateIndex( + name: "IX_fileimportlog_EstateReportingId_FileImportLogId", + table: "fileimportlog", + columns: new[] { "EstateReportingId", "FileImportLogId" }, + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_file_FileId", + table: "file", + column: "FileId", + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_estate_EstateId", + table: "estate", + column: "EstateId", + unique: true); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropIndex( + name: "IX_voucher_TransactionReportingId", + table: "voucher"); + + migrationBuilder.DropIndex( + name: "IX_voucher_VoucherCode", + table: "voucher"); + + migrationBuilder.DropPrimaryKey( + name: "PK_transactionfee", + table: "transactionfee"); + + migrationBuilder.DropIndex( + name: "IX_transactionfee_FeeId", + table: "transactionfee"); + + migrationBuilder.DropPrimaryKey( + name: "PK_transactionadditionalresponsedata", + table: "transactionadditionalresponsedata"); + + migrationBuilder.DropPrimaryKey( + name: "PK_transactionadditionalrequestdata", + table: "transactionadditionalrequestdata"); + + migrationBuilder.DropPrimaryKey( + name: "PK_transaction", + table: "transaction"); + + migrationBuilder.DropIndex( + name: "IX_transaction_TransactionDate_MerchantReportingId", + table: "transaction"); + + migrationBuilder.DropIndex( + name: "IX_transaction_TransactionId_MerchantReportingId", + table: "transaction"); + + migrationBuilder.DropPrimaryKey( + name: "PK_statementline", + table: "statementline"); + + migrationBuilder.DropPrimaryKey( + name: "PK_statementheader", + table: "statementheader"); + + migrationBuilder.DropIndex( + name: "IX_statementheader_MerchantReportingId_StatementGeneratedDate", + table: "statementheader"); + + migrationBuilder.DropPrimaryKey( + name: "PK_settlement", + table: "settlement"); + + migrationBuilder.DropIndex( + name: "IX_settlement_EstateReportingId_SettlementId", + table: "settlement"); + + migrationBuilder.DropIndex( + name: "IX_settlement_SettlementDate_EstateReportingId", + table: "settlement"); + + migrationBuilder.DropPrimaryKey( + name: "PK_reconciliation", + table: "reconciliation"); + + migrationBuilder.DropIndex( + name: "IX_reconciliation_TransactionDate_MerchantReportingId", + table: "reconciliation"); + + migrationBuilder.DropIndex( + name: "IX_reconciliation_TransactionId_MerchantReportingId", + table: "reconciliation"); + + migrationBuilder.DropPrimaryKey( + name: "PK_merchantsettlementfee", + table: "merchantsettlementfee"); + + migrationBuilder.DropPrimaryKey( + name: "PK_merchantsecurityuser", + table: "merchantsecurityuser"); + + migrationBuilder.DropPrimaryKey( + name: "PK_merchantoperator", + table: "merchantoperator"); + + migrationBuilder.DropPrimaryKey( + name: "PK_merchantdevice", + table: "merchantdevice"); + + migrationBuilder.DropPrimaryKey( + name: "PK_merchantcontact", + table: "merchantcontact"); + + migrationBuilder.DropPrimaryKey( + name: "PK_merchantaddress", + table: "merchantaddress"); + + migrationBuilder.DropPrimaryKey( + name: "PK_merchant", + table: "merchant"); + + migrationBuilder.DropIndex( + name: "IX_merchant_EstateReportingId_MerchantId", + table: "merchant"); + + migrationBuilder.DropPrimaryKey( + name: "PK_fileline", + table: "fileline"); + + migrationBuilder.DropIndex( + name: "IX_fileline_TransactionReportingId", + table: "fileline"); + + migrationBuilder.DropPrimaryKey( + name: "PK_fileimportlogfile", + table: "fileimportlogfile"); + + migrationBuilder.DropPrimaryKey( + name: "PK_fileimportlog", + table: "fileimportlog"); + + migrationBuilder.DropIndex( + name: "IX_fileimportlog_EstateReportingId_FileImportLogId", + table: "fileimportlog"); + + migrationBuilder.DropPrimaryKey( + name: "PK_file", + table: "file"); + + migrationBuilder.DropIndex( + name: "IX_file_FileId", + table: "file"); + + migrationBuilder.DropPrimaryKey( + name: "PK_estatesecurityuser", + table: "estatesecurityuser"); + + migrationBuilder.DropPrimaryKey( + name: "PK_estateoperator", + table: "estateoperator"); + + migrationBuilder.DropPrimaryKey( + name: "PK_estate", + table: "estate"); + + migrationBuilder.DropIndex( + name: "IX_estate_EstateId", + table: "estate"); + + migrationBuilder.DropPrimaryKey( + name: "PK_contractproducttransactionfee", + table: "contractproducttransactionfee"); + + migrationBuilder.DropPrimaryKey( + name: "PK_contractproduct", + table: "contractproduct"); + + migrationBuilder.DropPrimaryKey( + name: "PK_contract", + table: "contract"); + + migrationBuilder.DropColumn( + name: "ExpiryDateTime", + table: "voucher"); + + migrationBuilder.DropColumn( + name: "GenerateDate", + table: "voucher"); + + migrationBuilder.DropColumn( + name: "IssuedDate", + table: "voucher"); + + migrationBuilder.DropColumn( + name: "RedeemedDate", + table: "voucher"); + + migrationBuilder.DropColumn( + name: "TransactionReportingId", + table: "voucher"); + + migrationBuilder.DropColumn( + name: "TransactionReportingId", + table: "transactionfee"); + + migrationBuilder.DropColumn( + name: "TransactionFeeReportingId", + table: "transactionfee"); + + migrationBuilder.DropColumn( + name: "TransactionReportingId", + table: "transactionadditionalresponsedata"); + + migrationBuilder.DropColumn( + name: "TransactionReportingId", + table: "transactionadditionalrequestdata"); + + migrationBuilder.DropColumn( + name: "TransactionReportingId", + table: "transaction"); + + migrationBuilder.DropColumn( + name: "ContractProductReportingId", + table: "transaction"); + + migrationBuilder.DropColumn( + name: "ContractReportingId", + table: "transaction"); + + migrationBuilder.DropColumn( + name: "MerchantReportingId", + table: "transaction"); + + migrationBuilder.DropColumn( + name: "StatementReportingId", + table: "statementline"); + + migrationBuilder.DropColumn( + name: "TransactionReportingId", + table: "statementline"); + + migrationBuilder.DropColumn( + name: "ActivityDate", + table: "statementline"); + + migrationBuilder.DropColumn( + name: "MerchantReportingId", + table: "statementheader"); + + migrationBuilder.DropColumn( + name: "StatementCreatedDateTime", + table: "statementheader"); + + migrationBuilder.DropColumn( + name: "StatementGeneratedDateTime", + table: "statementheader"); + + migrationBuilder.DropColumn( + name: "StatementReportingId", + table: "statementheader"); + + migrationBuilder.DropColumn( + name: "SettlementReportingId", + table: "settlement"); + + migrationBuilder.DropColumn( + name: "EstateReportingId", + table: "settlement"); + + migrationBuilder.DropColumn( + name: "TransactionReportingId", + table: "reconciliation"); + + migrationBuilder.DropColumn( + name: "MerchantReportingId", + table: "reconciliation"); + + migrationBuilder.DropColumn( + name: "SettlementReportingId", + table: "merchantsettlementfee"); + + migrationBuilder.DropColumn( + name: "TransactionReportingId", + table: "merchantsettlementfee"); + + migrationBuilder.DropColumn( + name: "TransactionFeeReportingId", + table: "merchantsettlementfee"); + + migrationBuilder.DropColumn( + name: "MerchantReportingId", + table: "merchantsettlementfee"); + + migrationBuilder.DropColumn( + name: "MerchantReportingId", + table: "merchantsecurityuser"); + + migrationBuilder.DropColumn( + name: "MerchantReportingId", + table: "merchantoperator"); + + migrationBuilder.DropColumn( + name: "MerchantReportingId", + table: "merchantdevice"); + + migrationBuilder.DropColumn( + name: "MerchantReportingId", + table: "merchantcontact"); + + migrationBuilder.DropColumn( + name: "MerchantReportingId", + table: "merchantaddress"); + + migrationBuilder.DropColumn( + name: "EstateReportingId", + table: "merchant"); + + migrationBuilder.DropColumn( + name: "MerchantReportingId", + table: "merchant"); + + migrationBuilder.DropColumn( + name: "FileReportingId", + table: "fileline"); + + migrationBuilder.DropColumn( + name: "TransactionReportingId", + table: "fileline"); + + migrationBuilder.DropColumn( + name: "FileImportLogReportingId", + table: "fileimportlogfile"); + + migrationBuilder.DropColumn( + name: "FileReportingId", + table: "fileimportlogfile"); + + migrationBuilder.DropColumn( + name: "FileUploadedDate", + table: "fileimportlogfile"); + + migrationBuilder.DropColumn( + name: "MerchantReportingId", + table: "fileimportlogfile"); + + migrationBuilder.DropColumn( + name: "EstateReportingId", + table: "fileimportlog"); + + migrationBuilder.DropColumn( + name: "FileImportLogReportingId", + table: "fileimportlog"); + + migrationBuilder.DropColumn( + name: "ImportLogDate", + table: "fileimportlog"); + + migrationBuilder.DropColumn( + name: "FileReportingId", + table: "file"); + + migrationBuilder.DropColumn( + name: "EstateReportingId", + table: "file"); + + migrationBuilder.DropColumn( + name: "FileImportLogReportingId", + table: "file"); + + migrationBuilder.DropColumn( + name: "FileReceivedDate", + table: "file"); + + migrationBuilder.DropColumn( + name: "MerchantReportingId", + table: "file"); + + migrationBuilder.DropColumn( + name: "EstateReportingId", + table: "estatesecurityuser"); + + migrationBuilder.DropColumn( + name: "EstateReportingId", + table: "estateoperator"); + + migrationBuilder.DropColumn( + name: "EstateReportingId", + table: "estate"); + + migrationBuilder.DropColumn( + name: "ContractProductReportingId", + table: "contractproducttransactionfee"); + + migrationBuilder.DropColumn( + name: "TransactionFeeReportingId", + table: "contractproducttransactionfee"); + + migrationBuilder.DropColumn( + name: "ContractReportingId", + table: "contractproduct"); + + migrationBuilder.DropColumn( + name: "ContractProductReportingId", + table: "contractproduct"); + + migrationBuilder.DropColumn( + name: "EstateReportingId", + table: "contract"); + + migrationBuilder.DropColumn( + name: "ContractReportingId", + table: "contract"); + + migrationBuilder.AlterColumn( + name: "VoucherCode", + table: "voucher", + type: "longtext", + nullable: false, + oldClrType: typeof(string), + oldType: "varchar(255)") + .Annotation("MySql:CharSet", "utf8mb4") + .OldAnnotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.AlterColumn( + name: "ExpiryDate", + table: "voucher", + type: "datetime(6)", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "date"); + + migrationBuilder.AddColumn( + name: "EstateId", + table: "voucher", + type: "char(36)", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), + collation: "ascii_general_ci"); + + migrationBuilder.AddColumn( + name: "TransactionId", + table: "voucher", + type: "char(36)", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), + collation: "ascii_general_ci"); + + migrationBuilder.AddColumn( + name: "TransactionId", + table: "transactionfee", + type: "char(36)", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), + collation: "ascii_general_ci"); + + migrationBuilder.AddColumn( + name: "TransactionId", + table: "transactionadditionalresponsedata", + type: "char(36)", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), + collation: "ascii_general_ci"); + + migrationBuilder.AddColumn( + name: "EstateId", + table: "transactionadditionalresponsedata", + type: "char(36)", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), + collation: "ascii_general_ci"); + + migrationBuilder.AddColumn( + name: "MerchantId", + table: "transactionadditionalresponsedata", + type: "char(36)", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), + collation: "ascii_general_ci"); + + migrationBuilder.AddColumn( + name: "EstateId", + table: "transactionadditionalrequestdata", + type: "char(36)", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), + collation: "ascii_general_ci"); + + migrationBuilder.AddColumn( + name: "MerchantId", + table: "transactionadditionalrequestdata", + type: "char(36)", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), + collation: "ascii_general_ci"); + + migrationBuilder.AddColumn( + name: "TransactionId", + table: "transactionadditionalrequestdata", + type: "char(36)", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), + collation: "ascii_general_ci"); + + migrationBuilder.AlterColumn( + name: "TransactionDate", + table: "transaction", + type: "datetime(6)", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "date"); + + migrationBuilder.AddColumn( + name: "EstateId", + table: "transaction", + type: "char(36)", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), + collation: "ascii_general_ci"); + + migrationBuilder.AddColumn( + name: "MerchantId", + table: "transaction", + type: "char(36)", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), + collation: "ascii_general_ci"); + + migrationBuilder.AddColumn( + name: "ContractId", + table: "transaction", + type: "char(36)", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), + collation: "ascii_general_ci"); + + migrationBuilder.AddColumn( + name: "ProductId", + table: "transaction", + type: "char(36)", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), + collation: "ascii_general_ci"); + + migrationBuilder.AddColumn( + name: "StatementId", + table: "statementline", + type: "char(36)", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), + collation: "ascii_general_ci"); + + migrationBuilder.AddColumn( + name: "TransactionId", + table: "statementline", + type: "char(36)", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), + collation: "ascii_general_ci"); + + migrationBuilder.AddColumn( + name: "EstateId", + table: "statementline", + type: "char(36)", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), + collation: "ascii_general_ci"); + + migrationBuilder.AddColumn( + name: "MerchantId", + table: "statementline", + type: "char(36)", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), + collation: "ascii_general_ci"); + + migrationBuilder.AlterColumn( + name: "StatementGeneratedDate", + table: "statementheader", + type: "datetime(6)", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "date"); + + migrationBuilder.AlterColumn( + name: "StatementCreatedDate", + table: "statementheader", + type: "datetime(6)", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "date"); + + migrationBuilder.AddColumn( + name: "EstateId", + table: "statementheader", + type: "char(36)", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), + collation: "ascii_general_ci"); + + migrationBuilder.AddColumn( + name: "MerchantId", + table: "statementheader", + type: "char(36)", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), + collation: "ascii_general_ci"); + + migrationBuilder.AlterColumn( + name: "SettlementDate", + table: "settlement", + type: "datetime(6)", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "date"); + + migrationBuilder.AddColumn( + name: "EstateId", + table: "settlement", + type: "char(36)", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), + collation: "ascii_general_ci"); + + migrationBuilder.AlterColumn( + name: "TransactionDate", + table: "reconciliation", + type: "datetime(6)", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "date"); + + migrationBuilder.AddColumn( + name: "EstateId", + table: "reconciliation", + type: "char(36)", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), + collation: "ascii_general_ci"); + + migrationBuilder.AddColumn( + name: "MerchantId", + table: "reconciliation", + type: "char(36)", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), + collation: "ascii_general_ci"); + + migrationBuilder.AddColumn( + name: "EstateId", + table: "merchantsettlementfee", + type: "char(36)", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), + collation: "ascii_general_ci"); + + migrationBuilder.AddColumn( + name: "SettlementId", + table: "merchantsettlementfee", + type: "char(36)", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), + collation: "ascii_general_ci"); + + migrationBuilder.AddColumn( + name: "TransactionId", + table: "merchantsettlementfee", + type: "char(36)", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), + collation: "ascii_general_ci"); + + migrationBuilder.AddColumn( + name: "FeeId", + table: "merchantsettlementfee", + type: "char(36)", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), + collation: "ascii_general_ci"); + + migrationBuilder.AddColumn( + name: "MerchantId", + table: "merchantsettlementfee", + type: "char(36)", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), + collation: "ascii_general_ci"); + + migrationBuilder.AddColumn( + name: "EstateId", + table: "merchantsecurityuser", + type: "char(36)", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), + collation: "ascii_general_ci"); + + migrationBuilder.AddColumn( + name: "MerchantId", + table: "merchantsecurityuser", + type: "char(36)", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), + collation: "ascii_general_ci"); + + migrationBuilder.AddColumn( + name: "EstateId", + table: "merchantoperator", + type: "char(36)", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), + collation: "ascii_general_ci"); + + migrationBuilder.AddColumn( + name: "MerchantId", + table: "merchantoperator", + type: "char(36)", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), + collation: "ascii_general_ci"); + + migrationBuilder.AddColumn( + name: "EstateId", + table: "merchantdevice", + type: "char(36)", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), + collation: "ascii_general_ci"); + + migrationBuilder.AddColumn( + name: "MerchantId", + table: "merchantdevice", + type: "char(36)", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), + collation: "ascii_general_ci"); + + migrationBuilder.AddColumn( + name: "EstateId", + table: "merchantcontact", + type: "char(36)", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), + collation: "ascii_general_ci"); + + migrationBuilder.AddColumn( + name: "MerchantId", + table: "merchantcontact", + type: "char(36)", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), + collation: "ascii_general_ci"); + + migrationBuilder.AddColumn( + name: "EstateId", + table: "merchantaddress", + type: "char(36)", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), + collation: "ascii_general_ci"); + + migrationBuilder.AddColumn( + name: "MerchantId", + table: "merchantaddress", + type: "char(36)", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), + collation: "ascii_general_ci"); + + migrationBuilder.AddColumn( + name: "EstateId", + table: "merchant", + type: "char(36)", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), + collation: "ascii_general_ci"); + + migrationBuilder.AddColumn( + name: "EstateId", + table: "fileline", + type: "char(36)", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), + collation: "ascii_general_ci"); + + migrationBuilder.AddColumn( + name: "FileId", + table: "fileline", + type: "char(36)", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), + collation: "ascii_general_ci"); + + migrationBuilder.AddColumn( + name: "TransactionId", + table: "fileline", + type: "char(36)", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), + collation: "ascii_general_ci"); + + migrationBuilder.AddColumn( + name: "EstateId", + table: "fileimportlogfile", + type: "char(36)", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), + collation: "ascii_general_ci"); + + migrationBuilder.AddColumn( + name: "FileImportLogId", + table: "fileimportlogfile", + type: "char(36)", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), + collation: "ascii_general_ci"); + + migrationBuilder.AddColumn( + name: "FileId", + table: "fileimportlogfile", + type: "char(36)", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), + collation: "ascii_general_ci"); + + migrationBuilder.AddColumn( + name: "MerchantId", + table: "fileimportlogfile", + type: "char(36)", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), + collation: "ascii_general_ci"); + + migrationBuilder.AddColumn( + name: "EstateId", + table: "fileimportlog", + type: "char(36)", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), + collation: "ascii_general_ci"); + + migrationBuilder.AddColumn( + name: "EstateId", + table: "file", + type: "char(36)", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), + collation: "ascii_general_ci"); + + migrationBuilder.AddColumn( + name: "FileImportLogId", + table: "file", + type: "char(36)", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), + collation: "ascii_general_ci"); + + migrationBuilder.AddColumn( + name: "MerchantId", + table: "file", + type: "char(36)", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), + collation: "ascii_general_ci"); + + migrationBuilder.AddColumn( + name: "EstateId", + table: "estatesecurityuser", + type: "char(36)", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), + collation: "ascii_general_ci"); + + migrationBuilder.AddColumn( + name: "EstateId", + table: "estateoperator", + type: "char(36)", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), + collation: "ascii_general_ci"); + + migrationBuilder.AddColumn( + name: "EstateId", + table: "contractproducttransactionfee", + type: "char(36)", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), + collation: "ascii_general_ci"); + + migrationBuilder.AddColumn( + name: "ContractId", + table: "contractproducttransactionfee", + type: "char(36)", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), + collation: "ascii_general_ci"); + + migrationBuilder.AddColumn( + name: "ProductId", + table: "contractproducttransactionfee", + type: "char(36)", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), + collation: "ascii_general_ci"); + + migrationBuilder.AddColumn( + name: "EstateId", + table: "contractproduct", + type: "char(36)", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), + collation: "ascii_general_ci"); + + migrationBuilder.AddColumn( + name: "ContractId", + table: "contractproduct", + type: "char(36)", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), + collation: "ascii_general_ci"); + + migrationBuilder.AddColumn( + name: "EstateId", + table: "contract", + type: "char(36)", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), + collation: "ascii_general_ci"); + + migrationBuilder.AddPrimaryKey( + name: "PK_transactionfee", + table: "transactionfee", + columns: new[] { "TransactionId", "FeeId" }); + + migrationBuilder.AddPrimaryKey( + name: "PK_transactionadditionalresponsedata", + table: "transactionadditionalresponsedata", + column: "TransactionId"); + + migrationBuilder.AddPrimaryKey( + name: "PK_transactionadditionalrequestdata", + table: "transactionadditionalrequestdata", + columns: new[] { "EstateId", "MerchantId", "TransactionId" }); + + migrationBuilder.AddPrimaryKey( + name: "PK_transaction", + table: "transaction", + columns: new[] { "EstateId", "MerchantId", "TransactionId" }); + + migrationBuilder.AddPrimaryKey( + name: "PK_statementline", + table: "statementline", + columns: new[] { "StatementId", "TransactionId", "ActivityDateTime", "ActivityType" }); + + migrationBuilder.AddPrimaryKey( + name: "PK_statementheader", + table: "statementheader", + column: "StatementId"); + + migrationBuilder.AddPrimaryKey( + name: "PK_settlement", + table: "settlement", + columns: new[] { "EstateId", "SettlementId" }); + + migrationBuilder.AddPrimaryKey( + name: "PK_reconciliation", + table: "reconciliation", + column: "TransactionId"); + + migrationBuilder.AddPrimaryKey( + name: "PK_merchantsettlementfee", + table: "merchantsettlementfee", + columns: new[] { "EstateId", "SettlementId", "TransactionId", "FeeId" }); + + migrationBuilder.AddPrimaryKey( + name: "PK_merchantsecurityuser", + table: "merchantsecurityuser", + columns: new[] { "EstateId", "MerchantId", "SecurityUserId" }); + + migrationBuilder.AddPrimaryKey( + name: "PK_merchantoperator", + table: "merchantoperator", + columns: new[] { "EstateId", "MerchantId", "OperatorId" }); + + migrationBuilder.AddPrimaryKey( + name: "PK_merchantdevice", + table: "merchantdevice", + columns: new[] { "EstateId", "MerchantId", "DeviceId" }); + + migrationBuilder.AddPrimaryKey( + name: "PK_merchantcontact", + table: "merchantcontact", + columns: new[] { "EstateId", "MerchantId", "ContactId" }); + + migrationBuilder.AddPrimaryKey( + name: "PK_merchantaddress", + table: "merchantaddress", + columns: new[] { "EstateId", "MerchantId", "AddressId" }); + + migrationBuilder.AddPrimaryKey( + name: "PK_merchant", + table: "merchant", + columns: new[] { "EstateId", "MerchantId" }); + + migrationBuilder.AddPrimaryKey( + name: "PK_fileline", + table: "fileline", + columns: new[] { "EstateId", "FileId", "LineNumber" }); + + migrationBuilder.AddPrimaryKey( + name: "PK_fileimportlogfile", + table: "fileimportlogfile", + columns: new[] { "EstateId", "FileImportLogId", "FileId" }); + + migrationBuilder.AddPrimaryKey( + name: "PK_fileimportlog", + table: "fileimportlog", + columns: new[] { "EstateId", "FileImportLogId" }); + + migrationBuilder.AddPrimaryKey( + name: "PK_file", + table: "file", + columns: new[] { "EstateId", "FileImportLogId", "FileId" }); + + migrationBuilder.AddPrimaryKey( + name: "PK_estatesecurityuser", + table: "estatesecurityuser", + columns: new[] { "SecurityUserId", "EstateId" }); + + migrationBuilder.AddPrimaryKey( + name: "PK_estateoperator", + table: "estateoperator", + columns: new[] { "EstateId", "OperatorId" }); + + migrationBuilder.AddPrimaryKey( + name: "PK_estate", + table: "estate", + column: "EstateId"); + + migrationBuilder.AddPrimaryKey( + name: "PK_contractproducttransactionfee", + table: "contractproducttransactionfee", + columns: new[] { "EstateId", "ContractId", "ProductId", "TransactionFeeId" }); + + migrationBuilder.AddPrimaryKey( + name: "PK_contractproduct", + table: "contractproduct", + columns: new[] { "EstateId", "ContractId", "ProductId" }); + + migrationBuilder.AddPrimaryKey( + name: "PK_contract", + table: "contract", + columns: new[] { "EstateId", "OperatorId", "ContractId" }); + + migrationBuilder.CreateTable( + name: "uvwFileImportLogView", + columns: table => new + { + FileCount = table.Column(type: "int", nullable: false), + FileImportLogId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + ImportLogDate = table.Column(type: "datetime(6)", nullable: false), + ImportLogDateTime = table.Column(type: "datetime(6)", nullable: false), + ImportLogTime = table.Column(type: "time(6)", nullable: false), + MerchantId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci") + }, + constraints: table => + { + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "uvwFileView", + columns: table => new + { + EmailAddress = table.Column(type: "longtext", nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + FailedCount = table.Column(type: "int", nullable: false), + FileId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + FileReceivedDate = table.Column(type: "datetime(6)", nullable: false), + FileReceivedDateTime = table.Column(type: "datetime(6)", nullable: false), + FileReceivedTime = table.Column(type: "time(6)", nullable: false), + IsCompleted = table.Column(type: "tinyint(1)", nullable: false), + LineCount = table.Column(type: "int", nullable: false), + MerchantId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + MerchantName = table.Column(type: "longtext", nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + PendingCount = table.Column(type: "int", nullable: false), + SuccessCount = table.Column(type: "int", nullable: false), + UserId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci") + }, + constraints: table => + { + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "uvwTransactionsView", + columns: table => new + { + Amount = table.Column(type: "decimal(65,30)", nullable: false), + DayOfWeek = table.Column(type: "longtext", nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + EstateId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + IsAuthorised = table.Column(type: "tinyint(1)", nullable: false), + IsCompleted = table.Column(type: "tinyint(1)", nullable: false), + MerchantId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + Month = table.Column(type: "longtext", nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + MonthNumber = table.Column(type: "int", nullable: false), + OperatorIdentifier = table.Column(type: "longtext", nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + ResponseCode = table.Column(type: "longtext", nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + TransactionDate = table.Column(type: "datetime(6)", nullable: false), + TransactionDateTime = table.Column(type: "datetime(6)", nullable: false), + TransactionId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + TransactionType = table.Column(type: "longtext", nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + WeekNumber = table.Column(type: "int", nullable: false), + YearNumber = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + }) + .Annotation("MySql:CharSet", "utf8mb4"); + } + } +} diff --git a/TransactionProcessor.Database/Migrations/MySql/20230717130332_handleSettlementProcessingStartedEvent.Designer.cs b/TransactionProcessor.Database/Migrations/MySql/20230717130332_handleSettlementProcessingStartedEvent.Designer.cs new file mode 100644 index 00000000..00f672d6 --- /dev/null +++ b/TransactionProcessor.Database/Migrations/MySql/20230717130332_handleSettlementProcessingStartedEvent.Designer.cs @@ -0,0 +1,963 @@ +// + +#nullable disable + +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using TransactionProcessor.Database.Contexts; + +namespace TransactionProcessor.Database.Migrations.MySql +{ + [DbContext(typeof(EstateManagementMySqlContext))] + [Migration("20230717130332_handleSettlementProcessingStartedEvent")] + partial class handleSettlementProcessingStartedEvent + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "7.0.7") + .HasAnnotation("Relational:MaxIdentifierLength", 64); + + modelBuilder.Entity("EstateManagement.Database.Entities.Calendar", b => + { + b.Property("Date") + .HasColumnType("datetime(6)"); + + b.Property("DayOfWeek") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("DayOfWeekNumber") + .HasColumnType("int"); + + b.Property("DayOfWeekShort") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("MonthNameLong") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("MonthNameShort") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("MonthNumber") + .HasColumnType("int"); + + b.Property("WeekNumber") + .HasColumnType("int"); + + b.Property("WeekNumberString") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("Year") + .HasColumnType("int"); + + b.Property("YearWeekNumber") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("Date"); + + b.ToTable("calendar"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Contract", b => + { + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("OperatorId") + .HasColumnType("char(36)"); + + b.Property("ContractId") + .HasColumnType("char(36)"); + + b.Property("ContractReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("Description") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("EstateReportingId", "OperatorId", "ContractId"); + + b.ToTable("contract"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.ContractProduct", b => + { + b.Property("ContractReportingId") + .HasColumnType("int"); + + b.Property("ProductId") + .HasColumnType("char(36)"); + + b.Property("ContractProductReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("DisplayText") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ProductName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ProductType") + .HasColumnType("int"); + + b.Property("Value") + .HasColumnType("decimal(65,30)"); + + b.HasKey("ContractReportingId", "ProductId"); + + b.ToTable("contractproduct"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.ContractProductTransactionFee", b => + { + b.Property("ContractProductReportingId") + .HasColumnType("int"); + + b.Property("TransactionFeeId") + .HasColumnType("char(36)"); + + b.Property("CalculationType") + .HasColumnType("int"); + + b.Property("Description") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("FeeType") + .HasColumnType("int"); + + b.Property("IsEnabled") + .HasColumnType("tinyint(1)"); + + b.Property("TransactionFeeReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("Value") + .HasColumnType("decimal(18,4)"); + + b.HasKey("ContractProductReportingId", "TransactionFeeId"); + + b.ToTable("contractproducttransactionfee"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Estate", b => + { + b.Property("EstateReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("EstateId") + .HasColumnType("char(36)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("Reference") + .HasColumnType("longtext"); + + b.HasKey("EstateReportingId"); + + b.HasIndex("EstateId") + .IsUnique(); + + b.ToTable("estate"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.EstateOperator", b => + { + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("OperatorId") + .HasColumnType("char(36)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("RequireCustomMerchantNumber") + .HasColumnType("tinyint(1)"); + + b.Property("RequireCustomTerminalNumber") + .HasColumnType("tinyint(1)"); + + b.HasKey("EstateReportingId", "OperatorId"); + + b.ToTable("estateoperator"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.EstateSecurityUser", b => + { + b.Property("SecurityUserId") + .HasColumnType("char(36)"); + + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("EmailAddress") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("SecurityUserId", "EstateReportingId"); + + b.ToTable("estatesecurityuser"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.File", b => + { + b.Property("FileReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("FileId") + .HasColumnType("char(36)"); + + b.Property("FileImportLogReportingId") + .HasColumnType("int"); + + b.Property("FileLocation") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("FileProfileId") + .HasColumnType("char(36)"); + + b.Property("FileReceivedDate") + .HasColumnType("date"); + + b.Property("FileReceivedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("IsCompleted") + .HasColumnType("tinyint(1)"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("UserId") + .HasColumnType("char(36)"); + + b.HasKey("FileReportingId"); + + b.HasIndex("FileId") + .IsUnique(); + + b.ToTable("file"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.FileImportLog", b => + { + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("FileImportLogReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("FileImportLogId") + .HasColumnType("char(36)"); + + b.Property("ImportLogDate") + .HasColumnType("date"); + + b.Property("ImportLogDateTime") + .HasColumnType("datetime(6)"); + + b.HasKey("EstateReportingId", "FileImportLogReportingId"); + + b.HasIndex("EstateReportingId", "FileImportLogId") + .IsUnique(); + + b.ToTable("fileimportlog"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.FileImportLogFile", b => + { + b.Property("FileImportLogReportingId") + .HasColumnType("int"); + + b.Property("FileReportingId") + .HasColumnType("int"); + + b.Property("FilePath") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("FileProfileId") + .HasColumnType("char(36)"); + + b.Property("FileUploadedDate") + .HasColumnType("date"); + + b.Property("FileUploadedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("OriginalFileName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("UserId") + .HasColumnType("char(36)"); + + b.HasKey("FileImportLogReportingId", "FileReportingId"); + + b.ToTable("fileimportlogfile"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.FileLine", b => + { + b.Property("FileReportingId") + .HasColumnType("int"); + + b.Property("LineNumber") + .HasColumnType("int"); + + b.Property("FileLineData") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("Status") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.HasKey("FileReportingId", "LineNumber") + .HasAnnotation("SqlServer:Clustered", true); + + b.HasIndex("TransactionReportingId"); + + b.ToTable("fileline"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Merchant", b => + { + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("MerchantReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("LastStatementGenerated") + .HasColumnType("datetime(6)"); + + b.Property("MerchantId") + .HasColumnType("char(36)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("Reference") + .HasColumnType("longtext"); + + b.Property("SettlementSchedule") + .HasColumnType("int"); + + b.HasKey("EstateReportingId", "MerchantReportingId"); + + b.HasIndex("EstateReportingId", "MerchantId") + .IsUnique(); + + b.ToTable("merchant"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantAddress", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("AddressId") + .HasColumnType("char(36)"); + + b.Property("AddressLine1") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("AddressLine2") + .HasColumnType("longtext"); + + b.Property("AddressLine3") + .HasColumnType("longtext"); + + b.Property("AddressLine4") + .HasColumnType("longtext"); + + b.Property("Country") + .HasColumnType("longtext"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("PostalCode") + .HasColumnType("longtext"); + + b.Property("Region") + .HasColumnType("longtext"); + + b.Property("Town") + .HasColumnType("longtext"); + + b.HasKey("MerchantReportingId", "AddressId"); + + b.ToTable("merchantaddress"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantContact", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("ContactId") + .HasColumnType("char(36)"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("EmailAddress") + .HasColumnType("longtext"); + + b.Property("Name") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("PhoneNumber") + .HasColumnType("longtext"); + + b.HasKey("MerchantReportingId", "ContactId"); + + b.ToTable("merchantcontact"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantDevice", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("DeviceId") + .HasColumnType("char(36)"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("DeviceIdentifier") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("MerchantReportingId", "DeviceId"); + + b.ToTable("merchantdevice"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantOperator", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("OperatorId") + .HasColumnType("char(36)"); + + b.Property("MerchantNumber") + .HasColumnType("longtext"); + + b.Property("Name") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("TerminalNumber") + .HasColumnType("longtext"); + + b.HasKey("MerchantReportingId", "OperatorId"); + + b.ToTable("merchantoperator"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantSecurityUser", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("SecurityUserId") + .HasColumnType("char(36)"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("EmailAddress") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("MerchantReportingId", "SecurityUserId"); + + b.ToTable("merchantsecurityuser"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantSettlementFee", b => + { + b.Property("SettlementReportingId") + .HasColumnType("int"); + + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.Property("TransactionFeeReportingId") + .HasColumnType("int"); + + b.Property("CalculatedValue") + .HasColumnType("decimal(65,30)"); + + b.Property("FeeCalculatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("FeeValue") + .HasColumnType("decimal(65,30)"); + + b.Property("IsSettled") + .HasColumnType("tinyint(1)"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.HasKey("SettlementReportingId", "TransactionReportingId", "TransactionFeeReportingId"); + + b.ToTable("merchantsettlementfee"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Reconciliation", b => + { + b.Property("TransactionReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("DeviceIdentifier") + .HasColumnType("longtext"); + + b.Property("IsAuthorised") + .HasColumnType("tinyint(1)"); + + b.Property("IsCompleted") + .HasColumnType("tinyint(1)"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("ResponseCode") + .HasColumnType("longtext"); + + b.Property("ResponseMessage") + .HasColumnType("longtext"); + + b.Property("TransactionCount") + .HasColumnType("int"); + + b.Property("TransactionDate") + .HasColumnType("date"); + + b.Property("TransactionDateTime") + .HasColumnType("datetime(6)"); + + b.Property("TransactionId") + .HasColumnType("char(36)"); + + b.Property("TransactionTime") + .HasColumnType("time(6)"); + + b.Property("TransactionValue") + .HasColumnType("decimal(65,30)"); + + b.HasKey("TransactionReportingId") + .HasAnnotation("SqlServer:Clustered", false); + + b.HasIndex("TransactionDate", "MerchantReportingId") + .HasAnnotation("SqlServer:Clustered", true); + + b.HasIndex("TransactionId", "MerchantReportingId") + .IsUnique() + .HasAnnotation("SqlServer:Clustered", false); + + b.ToTable("reconciliation"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.ResponseCodes", b => + { + b.Property("ResponseCode") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("Description") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("ResponseCode"); + + b.ToTable("responsecodes"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Settlement", b => + { + b.Property("SettlementReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("IsCompleted") + .HasColumnType("tinyint(1)"); + + b.Property("ProcessingStarted") + .HasColumnType("tinyint(1)"); + + b.Property("ProcessingStartedDateTIme") + .HasColumnType("datetime(6)"); + + b.Property("SettlementDate") + .HasColumnType("date"); + + b.Property("SettlementId") + .HasColumnType("char(36)"); + + b.HasKey("SettlementReportingId") + .HasAnnotation("SqlServer:Clustered", false); + + b.HasIndex("EstateReportingId", "SettlementId") + .IsUnique() + .HasAnnotation("SqlServer:Clustered", false); + + b.HasIndex("SettlementDate", "EstateReportingId") + .HasAnnotation("SqlServer:Clustered", true); + + b.ToTable("settlement"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.StatementHeader", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("StatementId") + .HasColumnType("char(36)"); + + b.Property("StatementCreatedDate") + .HasColumnType("date"); + + b.Property("StatementCreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("StatementGeneratedDate") + .HasColumnType("date"); + + b.Property("StatementGeneratedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("StatementReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.HasKey("MerchantReportingId", "StatementId") + .HasAnnotation("SqlServer:Clustered", false); + + b.HasIndex("MerchantReportingId", "StatementGeneratedDate") + .IsUnique() + .HasAnnotation("SqlServer:Clustered", true); + + b.ToTable("statementheader"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.StatementLine", b => + { + b.Property("StatementReportingId") + .HasColumnType("int"); + + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.Property("ActivityDateTime") + .HasColumnType("datetime(6)"); + + b.Property("ActivityType") + .HasColumnType("int"); + + b.Property("ActivityDate") + .HasColumnType("date"); + + b.Property("ActivityDescription") + .HasColumnType("longtext"); + + b.Property("InAmount") + .HasColumnType("decimal(65,30)"); + + b.Property("OutAmount") + .HasColumnType("decimal(65,30)"); + + b.HasKey("StatementReportingId", "TransactionReportingId", "ActivityDateTime", "ActivityType"); + + b.ToTable("statementline"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Transaction", b => + { + b.Property("TransactionReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("AuthorisationCode") + .HasColumnType("longtext"); + + b.Property("ContractProductReportingId") + .HasColumnType("int"); + + b.Property("ContractReportingId") + .HasColumnType("int"); + + b.Property("DeviceIdentifier") + .HasColumnType("longtext"); + + b.Property("IsAuthorised") + .HasColumnType("tinyint(1)"); + + b.Property("IsCompleted") + .HasColumnType("tinyint(1)"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("OperatorIdentifier") + .HasColumnType("longtext"); + + b.Property("ResponseCode") + .HasColumnType("longtext"); + + b.Property("ResponseMessage") + .HasColumnType("longtext"); + + b.Property("TransactionDate") + .HasColumnType("date"); + + b.Property("TransactionDateTime") + .HasColumnType("datetime(6)"); + + b.Property("TransactionId") + .HasColumnType("char(36)"); + + b.Property("TransactionNumber") + .HasColumnType("longtext"); + + b.Property("TransactionReference") + .HasColumnType("longtext"); + + b.Property("TransactionSource") + .HasColumnType("int"); + + b.Property("TransactionTime") + .HasColumnType("time(6)"); + + b.Property("TransactionType") + .HasColumnType("longtext"); + + b.HasKey("TransactionReportingId") + .HasAnnotation("SqlServer:Clustered", false); + + b.HasIndex("TransactionDate", "MerchantReportingId") + .HasAnnotation("SqlServer:Clustered", true); + + b.HasIndex("TransactionId", "MerchantReportingId") + .IsUnique() + .HasAnnotation("SqlServer:Clustered", false); + + b.ToTable("transaction"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.TransactionAdditionalRequestData", b => + { + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.Property("Amount") + .HasColumnType("longtext"); + + b.Property("CustomerAccountNumber") + .HasColumnType("longtext"); + + b.HasKey("TransactionReportingId"); + + b.ToTable("transactionadditionalrequestdata"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.TransactionAdditionalResponseData", b => + { + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.HasKey("TransactionReportingId"); + + b.ToTable("transactionadditionalresponsedata"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Voucher", b => + { + b.Property("VoucherId") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("ExpiryDate") + .HasColumnType("date"); + + b.Property("ExpiryDateTime") + .HasColumnType("datetime(6)"); + + b.Property("GenerateDate") + .HasColumnType("date"); + + b.Property("GenerateDateTime") + .HasColumnType("datetime(6)"); + + b.Property("IsGenerated") + .HasColumnType("tinyint(1)"); + + b.Property("IsIssued") + .HasColumnType("tinyint(1)"); + + b.Property("IsRedeemed") + .HasColumnType("tinyint(1)"); + + b.Property("IssuedDate") + .HasColumnType("date"); + + b.Property("IssuedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("OperatorIdentifier") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("RecipientEmail") + .HasColumnType("longtext"); + + b.Property("RecipientMobile") + .HasColumnType("longtext"); + + b.Property("RedeemedDate") + .HasColumnType("datetime(6)"); + + b.Property("RedeemedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.Property("Value") + .HasColumnType("decimal(65,30)"); + + b.Property("VoucherCode") + .IsRequired() + .HasColumnType("varchar(255)"); + + b.HasKey("VoucherId"); + + b.HasIndex("TransactionReportingId"); + + b.HasIndex("VoucherCode"); + + b.ToTable("voucher"); + }); + + modelBuilder.Entity("EstateManagement.Database.ViewEntities.SettlementView", b => + { + b.Property("Amount") + .HasColumnType("decimal(65,30)"); + + b.Property("CalculatedValue") + .HasColumnType("decimal(65,30)"); + + b.Property("DayOfWeek") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("EstateId") + .HasColumnType("char(36)"); + + b.Property("FeeDescription") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("IsCompleted") + .HasColumnType("tinyint(1)"); + + b.Property("IsSettled") + .HasColumnType("tinyint(1)"); + + b.Property("MerchantId") + .HasColumnType("char(36)"); + + b.Property("MerchantName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("Month") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("MonthNumber") + .HasColumnType("int"); + + b.Property("OperatorIdentifier") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("SettlementDate") + .HasColumnType("datetime(6)"); + + b.Property("SettlementId") + .HasColumnType("char(36)"); + + b.Property("TransactionId") + .HasColumnType("char(36)"); + + b.Property("WeekNumber") + .HasColumnType("int"); + + b.Property("YearNumber") + .HasColumnType("int"); + + b.ToTable((string)null); + + b.ToView("uvwSettlements", (string)null); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/TransactionProcessor.Database/Migrations/MySql/20230717130332_handleSettlementProcessingStartedEvent.cs b/TransactionProcessor.Database/Migrations/MySql/20230717130332_handleSettlementProcessingStartedEvent.cs new file mode 100644 index 00000000..abf9b7bf --- /dev/null +++ b/TransactionProcessor.Database/Migrations/MySql/20230717130332_handleSettlementProcessingStartedEvent.cs @@ -0,0 +1,70 @@ +#nullable disable + +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; + +namespace TransactionProcessor.Database.Migrations.MySql +{ + /// + public partial class handleSettlementProcessingStartedEvent : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "transactionfee"); + + migrationBuilder.AddColumn( + name: "ProcessingStarted", + table: "settlement", + type: "tinyint(1)", + nullable: false, + defaultValue: false); + + migrationBuilder.AddColumn( + name: "ProcessingStartedDateTIme", + table: "settlement", + type: "datetime(6)", + nullable: false, + defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified)); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "ProcessingStarted", + table: "settlement"); + + migrationBuilder.DropColumn( + name: "ProcessingStartedDateTIme", + table: "settlement"); + + migrationBuilder.CreateTable( + name: "transactionfee", + columns: table => new + { + TransactionReportingId = table.Column(type: "int", nullable: false), + TransactionFeeReportingId = table.Column(type: "int", nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + CalculatedValue = table.Column(type: "decimal(65,30)", nullable: false), + CalculationType = table.Column(type: "int", nullable: false), + EventId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + FeeId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + FeeType = table.Column(type: "int", nullable: false), + FeeValue = table.Column(type: "decimal(65,30)", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_transactionfee", x => new { x.TransactionReportingId, x.TransactionFeeReportingId }); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateIndex( + name: "IX_transactionfee_FeeId", + table: "transactionfee", + column: "FeeId", + unique: true); + } + } +} diff --git a/TransactionProcessor.Database/Migrations/MySql/20230717132952_merchantsettlementfee_missingindex.Designer.cs b/TransactionProcessor.Database/Migrations/MySql/20230717132952_merchantsettlementfee_missingindex.Designer.cs new file mode 100644 index 00000000..4c14dcf4 --- /dev/null +++ b/TransactionProcessor.Database/Migrations/MySql/20230717132952_merchantsettlementfee_missingindex.Designer.cs @@ -0,0 +1,965 @@ +// + +#nullable disable + +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using TransactionProcessor.Database.Contexts; + +namespace TransactionProcessor.Database.Migrations.MySql +{ + [DbContext(typeof(EstateManagementMySqlContext))] + [Migration("20230717132952_merchantsettlementfee_missingindex")] + partial class merchantsettlementfee_missingindex + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "7.0.7") + .HasAnnotation("Relational:MaxIdentifierLength", 64); + + modelBuilder.Entity("EstateManagement.Database.Entities.Calendar", b => + { + b.Property("Date") + .HasColumnType("datetime(6)"); + + b.Property("DayOfWeek") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("DayOfWeekNumber") + .HasColumnType("int"); + + b.Property("DayOfWeekShort") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("MonthNameLong") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("MonthNameShort") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("MonthNumber") + .HasColumnType("int"); + + b.Property("WeekNumber") + .HasColumnType("int"); + + b.Property("WeekNumberString") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("Year") + .HasColumnType("int"); + + b.Property("YearWeekNumber") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("Date"); + + b.ToTable("calendar"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Contract", b => + { + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("OperatorId") + .HasColumnType("char(36)"); + + b.Property("ContractId") + .HasColumnType("char(36)"); + + b.Property("ContractReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("Description") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("EstateReportingId", "OperatorId", "ContractId"); + + b.ToTable("contract"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.ContractProduct", b => + { + b.Property("ContractReportingId") + .HasColumnType("int"); + + b.Property("ProductId") + .HasColumnType("char(36)"); + + b.Property("ContractProductReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("DisplayText") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ProductName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ProductType") + .HasColumnType("int"); + + b.Property("Value") + .HasColumnType("decimal(65,30)"); + + b.HasKey("ContractReportingId", "ProductId"); + + b.ToTable("contractproduct"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.ContractProductTransactionFee", b => + { + b.Property("ContractProductReportingId") + .HasColumnType("int"); + + b.Property("TransactionFeeId") + .HasColumnType("char(36)"); + + b.Property("CalculationType") + .HasColumnType("int"); + + b.Property("Description") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("FeeType") + .HasColumnType("int"); + + b.Property("IsEnabled") + .HasColumnType("tinyint(1)"); + + b.Property("TransactionFeeReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("Value") + .HasColumnType("decimal(18,4)"); + + b.HasKey("ContractProductReportingId", "TransactionFeeId"); + + b.ToTable("contractproducttransactionfee"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Estate", b => + { + b.Property("EstateReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("EstateId") + .HasColumnType("char(36)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("Reference") + .HasColumnType("longtext"); + + b.HasKey("EstateReportingId"); + + b.HasIndex("EstateId") + .IsUnique(); + + b.ToTable("estate"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.EstateOperator", b => + { + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("OperatorId") + .HasColumnType("char(36)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("RequireCustomMerchantNumber") + .HasColumnType("tinyint(1)"); + + b.Property("RequireCustomTerminalNumber") + .HasColumnType("tinyint(1)"); + + b.HasKey("EstateReportingId", "OperatorId"); + + b.ToTable("estateoperator"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.EstateSecurityUser", b => + { + b.Property("SecurityUserId") + .HasColumnType("char(36)"); + + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("EmailAddress") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("SecurityUserId", "EstateReportingId"); + + b.ToTable("estatesecurityuser"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.File", b => + { + b.Property("FileReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("FileId") + .HasColumnType("char(36)"); + + b.Property("FileImportLogReportingId") + .HasColumnType("int"); + + b.Property("FileLocation") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("FileProfileId") + .HasColumnType("char(36)"); + + b.Property("FileReceivedDate") + .HasColumnType("date"); + + b.Property("FileReceivedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("IsCompleted") + .HasColumnType("tinyint(1)"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("UserId") + .HasColumnType("char(36)"); + + b.HasKey("FileReportingId"); + + b.HasIndex("FileId") + .IsUnique(); + + b.ToTable("file"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.FileImportLog", b => + { + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("FileImportLogReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("FileImportLogId") + .HasColumnType("char(36)"); + + b.Property("ImportLogDate") + .HasColumnType("date"); + + b.Property("ImportLogDateTime") + .HasColumnType("datetime(6)"); + + b.HasKey("EstateReportingId", "FileImportLogReportingId"); + + b.HasIndex("EstateReportingId", "FileImportLogId") + .IsUnique(); + + b.ToTable("fileimportlog"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.FileImportLogFile", b => + { + b.Property("FileImportLogReportingId") + .HasColumnType("int"); + + b.Property("FileReportingId") + .HasColumnType("int"); + + b.Property("FilePath") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("FileProfileId") + .HasColumnType("char(36)"); + + b.Property("FileUploadedDate") + .HasColumnType("date"); + + b.Property("FileUploadedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("OriginalFileName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("UserId") + .HasColumnType("char(36)"); + + b.HasKey("FileImportLogReportingId", "FileReportingId"); + + b.ToTable("fileimportlogfile"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.FileLine", b => + { + b.Property("FileReportingId") + .HasColumnType("int"); + + b.Property("LineNumber") + .HasColumnType("int"); + + b.Property("FileLineData") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("Status") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.HasKey("FileReportingId", "LineNumber") + .HasAnnotation("SqlServer:Clustered", true); + + b.HasIndex("TransactionReportingId"); + + b.ToTable("fileline"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Merchant", b => + { + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("MerchantReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("LastStatementGenerated") + .HasColumnType("datetime(6)"); + + b.Property("MerchantId") + .HasColumnType("char(36)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("Reference") + .HasColumnType("longtext"); + + b.Property("SettlementSchedule") + .HasColumnType("int"); + + b.HasKey("EstateReportingId", "MerchantReportingId"); + + b.HasIndex("EstateReportingId", "MerchantId") + .IsUnique(); + + b.ToTable("merchant"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantAddress", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("AddressId") + .HasColumnType("char(36)"); + + b.Property("AddressLine1") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("AddressLine2") + .HasColumnType("longtext"); + + b.Property("AddressLine3") + .HasColumnType("longtext"); + + b.Property("AddressLine4") + .HasColumnType("longtext"); + + b.Property("Country") + .HasColumnType("longtext"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("PostalCode") + .HasColumnType("longtext"); + + b.Property("Region") + .HasColumnType("longtext"); + + b.Property("Town") + .HasColumnType("longtext"); + + b.HasKey("MerchantReportingId", "AddressId"); + + b.ToTable("merchantaddress"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantContact", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("ContactId") + .HasColumnType("char(36)"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("EmailAddress") + .HasColumnType("longtext"); + + b.Property("Name") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("PhoneNumber") + .HasColumnType("longtext"); + + b.HasKey("MerchantReportingId", "ContactId"); + + b.ToTable("merchantcontact"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantDevice", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("DeviceId") + .HasColumnType("char(36)"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("DeviceIdentifier") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("MerchantReportingId", "DeviceId"); + + b.ToTable("merchantdevice"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantOperator", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("OperatorId") + .HasColumnType("char(36)"); + + b.Property("MerchantNumber") + .HasColumnType("longtext"); + + b.Property("Name") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("TerminalNumber") + .HasColumnType("longtext"); + + b.HasKey("MerchantReportingId", "OperatorId"); + + b.ToTable("merchantoperator"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantSecurityUser", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("SecurityUserId") + .HasColumnType("char(36)"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("EmailAddress") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("MerchantReportingId", "SecurityUserId"); + + b.ToTable("merchantsecurityuser"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantSettlementFee", b => + { + b.Property("SettlementReportingId") + .HasColumnType("int"); + + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.Property("TransactionFeeReportingId") + .HasColumnType("int"); + + b.Property("CalculatedValue") + .HasColumnType("decimal(65,30)"); + + b.Property("FeeCalculatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("FeeValue") + .HasColumnType("decimal(65,30)"); + + b.Property("IsSettled") + .HasColumnType("tinyint(1)"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.HasKey("SettlementReportingId", "TransactionReportingId", "TransactionFeeReportingId"); + + b.HasIndex("TransactionReportingId"); + + b.ToTable("merchantsettlementfee"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Reconciliation", b => + { + b.Property("TransactionReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("DeviceIdentifier") + .HasColumnType("longtext"); + + b.Property("IsAuthorised") + .HasColumnType("tinyint(1)"); + + b.Property("IsCompleted") + .HasColumnType("tinyint(1)"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("ResponseCode") + .HasColumnType("longtext"); + + b.Property("ResponseMessage") + .HasColumnType("longtext"); + + b.Property("TransactionCount") + .HasColumnType("int"); + + b.Property("TransactionDate") + .HasColumnType("date"); + + b.Property("TransactionDateTime") + .HasColumnType("datetime(6)"); + + b.Property("TransactionId") + .HasColumnType("char(36)"); + + b.Property("TransactionTime") + .HasColumnType("time(6)"); + + b.Property("TransactionValue") + .HasColumnType("decimal(65,30)"); + + b.HasKey("TransactionReportingId") + .HasAnnotation("SqlServer:Clustered", false); + + b.HasIndex("TransactionDate", "MerchantReportingId") + .HasAnnotation("SqlServer:Clustered", true); + + b.HasIndex("TransactionId", "MerchantReportingId") + .IsUnique() + .HasAnnotation("SqlServer:Clustered", false); + + b.ToTable("reconciliation"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.ResponseCodes", b => + { + b.Property("ResponseCode") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("Description") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("ResponseCode"); + + b.ToTable("responsecodes"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Settlement", b => + { + b.Property("SettlementReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("IsCompleted") + .HasColumnType("tinyint(1)"); + + b.Property("ProcessingStarted") + .HasColumnType("tinyint(1)"); + + b.Property("ProcessingStartedDateTIme") + .HasColumnType("datetime(6)"); + + b.Property("SettlementDate") + .HasColumnType("date"); + + b.Property("SettlementId") + .HasColumnType("char(36)"); + + b.HasKey("SettlementReportingId") + .HasAnnotation("SqlServer:Clustered", false); + + b.HasIndex("EstateReportingId", "SettlementId") + .IsUnique() + .HasAnnotation("SqlServer:Clustered", false); + + b.HasIndex("SettlementDate", "EstateReportingId") + .HasAnnotation("SqlServer:Clustered", true); + + b.ToTable("settlement"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.StatementHeader", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("StatementId") + .HasColumnType("char(36)"); + + b.Property("StatementCreatedDate") + .HasColumnType("date"); + + b.Property("StatementCreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("StatementGeneratedDate") + .HasColumnType("date"); + + b.Property("StatementGeneratedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("StatementReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.HasKey("MerchantReportingId", "StatementId") + .HasAnnotation("SqlServer:Clustered", false); + + b.HasIndex("MerchantReportingId", "StatementGeneratedDate") + .IsUnique() + .HasAnnotation("SqlServer:Clustered", true); + + b.ToTable("statementheader"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.StatementLine", b => + { + b.Property("StatementReportingId") + .HasColumnType("int"); + + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.Property("ActivityDateTime") + .HasColumnType("datetime(6)"); + + b.Property("ActivityType") + .HasColumnType("int"); + + b.Property("ActivityDate") + .HasColumnType("date"); + + b.Property("ActivityDescription") + .HasColumnType("longtext"); + + b.Property("InAmount") + .HasColumnType("decimal(65,30)"); + + b.Property("OutAmount") + .HasColumnType("decimal(65,30)"); + + b.HasKey("StatementReportingId", "TransactionReportingId", "ActivityDateTime", "ActivityType"); + + b.ToTable("statementline"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Transaction", b => + { + b.Property("TransactionReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("AuthorisationCode") + .HasColumnType("longtext"); + + b.Property("ContractProductReportingId") + .HasColumnType("int"); + + b.Property("ContractReportingId") + .HasColumnType("int"); + + b.Property("DeviceIdentifier") + .HasColumnType("longtext"); + + b.Property("IsAuthorised") + .HasColumnType("tinyint(1)"); + + b.Property("IsCompleted") + .HasColumnType("tinyint(1)"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("OperatorIdentifier") + .HasColumnType("longtext"); + + b.Property("ResponseCode") + .HasColumnType("longtext"); + + b.Property("ResponseMessage") + .HasColumnType("longtext"); + + b.Property("TransactionDate") + .HasColumnType("date"); + + b.Property("TransactionDateTime") + .HasColumnType("datetime(6)"); + + b.Property("TransactionId") + .HasColumnType("char(36)"); + + b.Property("TransactionNumber") + .HasColumnType("longtext"); + + b.Property("TransactionReference") + .HasColumnType("longtext"); + + b.Property("TransactionSource") + .HasColumnType("int"); + + b.Property("TransactionTime") + .HasColumnType("time(6)"); + + b.Property("TransactionType") + .HasColumnType("longtext"); + + b.HasKey("TransactionReportingId") + .HasAnnotation("SqlServer:Clustered", false); + + b.HasIndex("TransactionDate", "MerchantReportingId") + .HasAnnotation("SqlServer:Clustered", true); + + b.HasIndex("TransactionId", "MerchantReportingId") + .IsUnique() + .HasAnnotation("SqlServer:Clustered", false); + + b.ToTable("transaction"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.TransactionAdditionalRequestData", b => + { + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.Property("Amount") + .HasColumnType("longtext"); + + b.Property("CustomerAccountNumber") + .HasColumnType("longtext"); + + b.HasKey("TransactionReportingId"); + + b.ToTable("transactionadditionalrequestdata"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.TransactionAdditionalResponseData", b => + { + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.HasKey("TransactionReportingId"); + + b.ToTable("transactionadditionalresponsedata"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Voucher", b => + { + b.Property("VoucherId") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("ExpiryDate") + .HasColumnType("date"); + + b.Property("ExpiryDateTime") + .HasColumnType("datetime(6)"); + + b.Property("GenerateDate") + .HasColumnType("date"); + + b.Property("GenerateDateTime") + .HasColumnType("datetime(6)"); + + b.Property("IsGenerated") + .HasColumnType("tinyint(1)"); + + b.Property("IsIssued") + .HasColumnType("tinyint(1)"); + + b.Property("IsRedeemed") + .HasColumnType("tinyint(1)"); + + b.Property("IssuedDate") + .HasColumnType("date"); + + b.Property("IssuedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("OperatorIdentifier") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("RecipientEmail") + .HasColumnType("longtext"); + + b.Property("RecipientMobile") + .HasColumnType("longtext"); + + b.Property("RedeemedDate") + .HasColumnType("datetime(6)"); + + b.Property("RedeemedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.Property("Value") + .HasColumnType("decimal(65,30)"); + + b.Property("VoucherCode") + .IsRequired() + .HasColumnType("varchar(255)"); + + b.HasKey("VoucherId"); + + b.HasIndex("TransactionReportingId"); + + b.HasIndex("VoucherCode"); + + b.ToTable("voucher"); + }); + + modelBuilder.Entity("EstateManagement.Database.ViewEntities.SettlementView", b => + { + b.Property("Amount") + .HasColumnType("decimal(65,30)"); + + b.Property("CalculatedValue") + .HasColumnType("decimal(65,30)"); + + b.Property("DayOfWeek") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("EstateId") + .HasColumnType("char(36)"); + + b.Property("FeeDescription") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("IsCompleted") + .HasColumnType("tinyint(1)"); + + b.Property("IsSettled") + .HasColumnType("tinyint(1)"); + + b.Property("MerchantId") + .HasColumnType("char(36)"); + + b.Property("MerchantName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("Month") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("MonthNumber") + .HasColumnType("int"); + + b.Property("OperatorIdentifier") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("SettlementDate") + .HasColumnType("datetime(6)"); + + b.Property("SettlementId") + .HasColumnType("char(36)"); + + b.Property("TransactionId") + .HasColumnType("char(36)"); + + b.Property("WeekNumber") + .HasColumnType("int"); + + b.Property("YearNumber") + .HasColumnType("int"); + + b.ToTable((string)null); + + b.ToView("uvwSettlements", (string)null); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/TransactionProcessor.Database/Migrations/MySql/20230717132952_merchantsettlementfee_missingindex.cs b/TransactionProcessor.Database/Migrations/MySql/20230717132952_merchantsettlementfee_missingindex.cs new file mode 100644 index 00000000..914d8d62 --- /dev/null +++ b/TransactionProcessor.Database/Migrations/MySql/20230717132952_merchantsettlementfee_missingindex.cs @@ -0,0 +1,27 @@ +#nullable disable + +using Microsoft.EntityFrameworkCore.Migrations; + +namespace TransactionProcessor.Database.Migrations.MySql +{ + /// + public partial class merchantsettlementfee_missingindex : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateIndex( + name: "IX_merchantsettlementfee_TransactionReportingId", + table: "merchantsettlementfee", + column: "TransactionReportingId"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropIndex( + name: "IX_merchantsettlementfee_TransactionReportingId", + table: "merchantsettlementfee"); + } + } +} diff --git a/TransactionProcessor.Database/Migrations/MySql/20230721142823_addmerchanttosettlementtable.Designer.cs b/TransactionProcessor.Database/Migrations/MySql/20230721142823_addmerchanttosettlementtable.Designer.cs new file mode 100644 index 00000000..3ad631fe --- /dev/null +++ b/TransactionProcessor.Database/Migrations/MySql/20230721142823_addmerchanttosettlementtable.Designer.cs @@ -0,0 +1,968 @@ +// + +#nullable disable + +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using TransactionProcessor.Database.Contexts; + +namespace TransactionProcessor.Database.Migrations.MySql +{ + [DbContext(typeof(EstateManagementMySqlContext))] + [Migration("20230721142823_addmerchanttosettlementtable")] + partial class addmerchanttosettlementtable + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "7.0.7") + .HasAnnotation("Relational:MaxIdentifierLength", 64); + + modelBuilder.Entity("EstateManagement.Database.Entities.Calendar", b => + { + b.Property("Date") + .HasColumnType("datetime(6)"); + + b.Property("DayOfWeek") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("DayOfWeekNumber") + .HasColumnType("int"); + + b.Property("DayOfWeekShort") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("MonthNameLong") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("MonthNameShort") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("MonthNumber") + .HasColumnType("int"); + + b.Property("WeekNumber") + .HasColumnType("int"); + + b.Property("WeekNumberString") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("Year") + .HasColumnType("int"); + + b.Property("YearWeekNumber") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("Date"); + + b.ToTable("calendar"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Contract", b => + { + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("OperatorId") + .HasColumnType("char(36)"); + + b.Property("ContractId") + .HasColumnType("char(36)"); + + b.Property("ContractReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("Description") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("EstateReportingId", "OperatorId", "ContractId"); + + b.ToTable("contract"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.ContractProduct", b => + { + b.Property("ContractReportingId") + .HasColumnType("int"); + + b.Property("ProductId") + .HasColumnType("char(36)"); + + b.Property("ContractProductReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("DisplayText") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ProductName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ProductType") + .HasColumnType("int"); + + b.Property("Value") + .HasColumnType("decimal(65,30)"); + + b.HasKey("ContractReportingId", "ProductId"); + + b.ToTable("contractproduct"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.ContractProductTransactionFee", b => + { + b.Property("ContractProductReportingId") + .HasColumnType("int"); + + b.Property("TransactionFeeId") + .HasColumnType("char(36)"); + + b.Property("CalculationType") + .HasColumnType("int"); + + b.Property("Description") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("FeeType") + .HasColumnType("int"); + + b.Property("IsEnabled") + .HasColumnType("tinyint(1)"); + + b.Property("TransactionFeeReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("Value") + .HasColumnType("decimal(18,4)"); + + b.HasKey("ContractProductReportingId", "TransactionFeeId"); + + b.ToTable("contractproducttransactionfee"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Estate", b => + { + b.Property("EstateReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("EstateId") + .HasColumnType("char(36)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("Reference") + .HasColumnType("longtext"); + + b.HasKey("EstateReportingId"); + + b.HasIndex("EstateId") + .IsUnique(); + + b.ToTable("estate"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.EstateOperator", b => + { + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("OperatorId") + .HasColumnType("char(36)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("RequireCustomMerchantNumber") + .HasColumnType("tinyint(1)"); + + b.Property("RequireCustomTerminalNumber") + .HasColumnType("tinyint(1)"); + + b.HasKey("EstateReportingId", "OperatorId"); + + b.ToTable("estateoperator"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.EstateSecurityUser", b => + { + b.Property("SecurityUserId") + .HasColumnType("char(36)"); + + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("EmailAddress") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("SecurityUserId", "EstateReportingId"); + + b.ToTable("estatesecurityuser"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.File", b => + { + b.Property("FileReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("FileId") + .HasColumnType("char(36)"); + + b.Property("FileImportLogReportingId") + .HasColumnType("int"); + + b.Property("FileLocation") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("FileProfileId") + .HasColumnType("char(36)"); + + b.Property("FileReceivedDate") + .HasColumnType("date"); + + b.Property("FileReceivedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("IsCompleted") + .HasColumnType("tinyint(1)"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("UserId") + .HasColumnType("char(36)"); + + b.HasKey("FileReportingId"); + + b.HasIndex("FileId") + .IsUnique(); + + b.ToTable("file"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.FileImportLog", b => + { + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("FileImportLogReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("FileImportLogId") + .HasColumnType("char(36)"); + + b.Property("ImportLogDate") + .HasColumnType("date"); + + b.Property("ImportLogDateTime") + .HasColumnType("datetime(6)"); + + b.HasKey("EstateReportingId", "FileImportLogReportingId"); + + b.HasIndex("EstateReportingId", "FileImportLogId") + .IsUnique(); + + b.ToTable("fileimportlog"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.FileImportLogFile", b => + { + b.Property("FileImportLogReportingId") + .HasColumnType("int"); + + b.Property("FileReportingId") + .HasColumnType("int"); + + b.Property("FilePath") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("FileProfileId") + .HasColumnType("char(36)"); + + b.Property("FileUploadedDate") + .HasColumnType("date"); + + b.Property("FileUploadedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("OriginalFileName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("UserId") + .HasColumnType("char(36)"); + + b.HasKey("FileImportLogReportingId", "FileReportingId"); + + b.ToTable("fileimportlogfile"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.FileLine", b => + { + b.Property("FileReportingId") + .HasColumnType("int"); + + b.Property("LineNumber") + .HasColumnType("int"); + + b.Property("FileLineData") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("Status") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.HasKey("FileReportingId", "LineNumber") + .HasAnnotation("SqlServer:Clustered", true); + + b.HasIndex("TransactionReportingId"); + + b.ToTable("fileline"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Merchant", b => + { + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("MerchantReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("LastStatementGenerated") + .HasColumnType("datetime(6)"); + + b.Property("MerchantId") + .HasColumnType("char(36)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("Reference") + .HasColumnType("longtext"); + + b.Property("SettlementSchedule") + .HasColumnType("int"); + + b.HasKey("EstateReportingId", "MerchantReportingId"); + + b.HasIndex("EstateReportingId", "MerchantId") + .IsUnique(); + + b.ToTable("merchant"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantAddress", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("AddressId") + .HasColumnType("char(36)"); + + b.Property("AddressLine1") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("AddressLine2") + .HasColumnType("longtext"); + + b.Property("AddressLine3") + .HasColumnType("longtext"); + + b.Property("AddressLine4") + .HasColumnType("longtext"); + + b.Property("Country") + .HasColumnType("longtext"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("PostalCode") + .HasColumnType("longtext"); + + b.Property("Region") + .HasColumnType("longtext"); + + b.Property("Town") + .HasColumnType("longtext"); + + b.HasKey("MerchantReportingId", "AddressId"); + + b.ToTable("merchantaddress"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantContact", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("ContactId") + .HasColumnType("char(36)"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("EmailAddress") + .HasColumnType("longtext"); + + b.Property("Name") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("PhoneNumber") + .HasColumnType("longtext"); + + b.HasKey("MerchantReportingId", "ContactId"); + + b.ToTable("merchantcontact"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantDevice", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("DeviceId") + .HasColumnType("char(36)"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("DeviceIdentifier") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("MerchantReportingId", "DeviceId"); + + b.ToTable("merchantdevice"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantOperator", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("OperatorId") + .HasColumnType("char(36)"); + + b.Property("MerchantNumber") + .HasColumnType("longtext"); + + b.Property("Name") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("TerminalNumber") + .HasColumnType("longtext"); + + b.HasKey("MerchantReportingId", "OperatorId"); + + b.ToTable("merchantoperator"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantSecurityUser", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("SecurityUserId") + .HasColumnType("char(36)"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("EmailAddress") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("MerchantReportingId", "SecurityUserId"); + + b.ToTable("merchantsecurityuser"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantSettlementFee", b => + { + b.Property("SettlementReportingId") + .HasColumnType("int"); + + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.Property("TransactionFeeReportingId") + .HasColumnType("int"); + + b.Property("CalculatedValue") + .HasColumnType("decimal(65,30)"); + + b.Property("FeeCalculatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("FeeValue") + .HasColumnType("decimal(65,30)"); + + b.Property("IsSettled") + .HasColumnType("tinyint(1)"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.HasKey("SettlementReportingId", "TransactionReportingId", "TransactionFeeReportingId"); + + b.HasIndex("TransactionReportingId"); + + b.ToTable("merchantsettlementfee"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Reconciliation", b => + { + b.Property("TransactionReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("DeviceIdentifier") + .HasColumnType("longtext"); + + b.Property("IsAuthorised") + .HasColumnType("tinyint(1)"); + + b.Property("IsCompleted") + .HasColumnType("tinyint(1)"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("ResponseCode") + .HasColumnType("longtext"); + + b.Property("ResponseMessage") + .HasColumnType("longtext"); + + b.Property("TransactionCount") + .HasColumnType("int"); + + b.Property("TransactionDate") + .HasColumnType("date"); + + b.Property("TransactionDateTime") + .HasColumnType("datetime(6)"); + + b.Property("TransactionId") + .HasColumnType("char(36)"); + + b.Property("TransactionTime") + .HasColumnType("time(6)"); + + b.Property("TransactionValue") + .HasColumnType("decimal(65,30)"); + + b.HasKey("TransactionReportingId") + .HasAnnotation("SqlServer:Clustered", false); + + b.HasIndex("TransactionDate", "MerchantReportingId") + .HasAnnotation("SqlServer:Clustered", true); + + b.HasIndex("TransactionId", "MerchantReportingId") + .IsUnique() + .HasAnnotation("SqlServer:Clustered", false); + + b.ToTable("reconciliation"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.ResponseCodes", b => + { + b.Property("ResponseCode") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("Description") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("ResponseCode"); + + b.ToTable("responsecodes"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Settlement", b => + { + b.Property("SettlementReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("IsCompleted") + .HasColumnType("tinyint(1)"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("ProcessingStarted") + .HasColumnType("tinyint(1)"); + + b.Property("ProcessingStartedDateTIme") + .HasColumnType("datetime(6)"); + + b.Property("SettlementDate") + .HasColumnType("date"); + + b.Property("SettlementId") + .HasColumnType("char(36)"); + + b.HasKey("SettlementReportingId") + .HasAnnotation("SqlServer:Clustered", false); + + b.HasIndex("EstateReportingId", "SettlementId") + .IsUnique() + .HasAnnotation("SqlServer:Clustered", false); + + b.HasIndex("SettlementDate", "EstateReportingId") + .HasAnnotation("SqlServer:Clustered", true); + + b.ToTable("settlement"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.StatementHeader", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("StatementId") + .HasColumnType("char(36)"); + + b.Property("StatementCreatedDate") + .HasColumnType("date"); + + b.Property("StatementCreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("StatementGeneratedDate") + .HasColumnType("date"); + + b.Property("StatementGeneratedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("StatementReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.HasKey("MerchantReportingId", "StatementId") + .HasAnnotation("SqlServer:Clustered", false); + + b.HasIndex("MerchantReportingId", "StatementGeneratedDate") + .IsUnique() + .HasAnnotation("SqlServer:Clustered", true); + + b.ToTable("statementheader"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.StatementLine", b => + { + b.Property("StatementReportingId") + .HasColumnType("int"); + + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.Property("ActivityDateTime") + .HasColumnType("datetime(6)"); + + b.Property("ActivityType") + .HasColumnType("int"); + + b.Property("ActivityDate") + .HasColumnType("date"); + + b.Property("ActivityDescription") + .HasColumnType("longtext"); + + b.Property("InAmount") + .HasColumnType("decimal(65,30)"); + + b.Property("OutAmount") + .HasColumnType("decimal(65,30)"); + + b.HasKey("StatementReportingId", "TransactionReportingId", "ActivityDateTime", "ActivityType"); + + b.ToTable("statementline"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Transaction", b => + { + b.Property("TransactionReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("AuthorisationCode") + .HasColumnType("longtext"); + + b.Property("ContractProductReportingId") + .HasColumnType("int"); + + b.Property("ContractReportingId") + .HasColumnType("int"); + + b.Property("DeviceIdentifier") + .HasColumnType("longtext"); + + b.Property("IsAuthorised") + .HasColumnType("tinyint(1)"); + + b.Property("IsCompleted") + .HasColumnType("tinyint(1)"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("OperatorIdentifier") + .HasColumnType("longtext"); + + b.Property("ResponseCode") + .HasColumnType("longtext"); + + b.Property("ResponseMessage") + .HasColumnType("longtext"); + + b.Property("TransactionDate") + .HasColumnType("date"); + + b.Property("TransactionDateTime") + .HasColumnType("datetime(6)"); + + b.Property("TransactionId") + .HasColumnType("char(36)"); + + b.Property("TransactionNumber") + .HasColumnType("longtext"); + + b.Property("TransactionReference") + .HasColumnType("longtext"); + + b.Property("TransactionSource") + .HasColumnType("int"); + + b.Property("TransactionTime") + .HasColumnType("time(6)"); + + b.Property("TransactionType") + .HasColumnType("longtext"); + + b.HasKey("TransactionReportingId") + .HasAnnotation("SqlServer:Clustered", false); + + b.HasIndex("TransactionDate", "MerchantReportingId") + .HasAnnotation("SqlServer:Clustered", true); + + b.HasIndex("TransactionId", "MerchantReportingId") + .IsUnique() + .HasAnnotation("SqlServer:Clustered", false); + + b.ToTable("transaction"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.TransactionAdditionalRequestData", b => + { + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.Property("Amount") + .HasColumnType("longtext"); + + b.Property("CustomerAccountNumber") + .HasColumnType("longtext"); + + b.HasKey("TransactionReportingId"); + + b.ToTable("transactionadditionalrequestdata"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.TransactionAdditionalResponseData", b => + { + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.HasKey("TransactionReportingId"); + + b.ToTable("transactionadditionalresponsedata"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Voucher", b => + { + b.Property("VoucherId") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("ExpiryDate") + .HasColumnType("date"); + + b.Property("ExpiryDateTime") + .HasColumnType("datetime(6)"); + + b.Property("GenerateDate") + .HasColumnType("date"); + + b.Property("GenerateDateTime") + .HasColumnType("datetime(6)"); + + b.Property("IsGenerated") + .HasColumnType("tinyint(1)"); + + b.Property("IsIssued") + .HasColumnType("tinyint(1)"); + + b.Property("IsRedeemed") + .HasColumnType("tinyint(1)"); + + b.Property("IssuedDate") + .HasColumnType("date"); + + b.Property("IssuedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("OperatorIdentifier") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("RecipientEmail") + .HasColumnType("longtext"); + + b.Property("RecipientMobile") + .HasColumnType("longtext"); + + b.Property("RedeemedDate") + .HasColumnType("datetime(6)"); + + b.Property("RedeemedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.Property("Value") + .HasColumnType("decimal(65,30)"); + + b.Property("VoucherCode") + .IsRequired() + .HasColumnType("varchar(255)"); + + b.HasKey("VoucherId"); + + b.HasIndex("TransactionReportingId"); + + b.HasIndex("VoucherCode"); + + b.ToTable("voucher"); + }); + + modelBuilder.Entity("EstateManagement.Database.ViewEntities.SettlementView", b => + { + b.Property("Amount") + .HasColumnType("decimal(65,30)"); + + b.Property("CalculatedValue") + .HasColumnType("decimal(65,30)"); + + b.Property("DayOfWeek") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("EstateId") + .HasColumnType("char(36)"); + + b.Property("FeeDescription") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("IsCompleted") + .HasColumnType("tinyint(1)"); + + b.Property("IsSettled") + .HasColumnType("tinyint(1)"); + + b.Property("MerchantId") + .HasColumnType("char(36)"); + + b.Property("MerchantName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("Month") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("MonthNumber") + .HasColumnType("int"); + + b.Property("OperatorIdentifier") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("SettlementDate") + .HasColumnType("datetime(6)"); + + b.Property("SettlementId") + .HasColumnType("char(36)"); + + b.Property("TransactionId") + .HasColumnType("char(36)"); + + b.Property("WeekNumber") + .HasColumnType("int"); + + b.Property("YearNumber") + .HasColumnType("int"); + + b.ToTable((string)null); + + b.ToView("uvwSettlements", (string)null); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/TransactionProcessor.Database/Migrations/MySql/20230721142823_addmerchanttosettlementtable.cs b/TransactionProcessor.Database/Migrations/MySql/20230721142823_addmerchanttosettlementtable.cs new file mode 100644 index 00000000..1bb97bbf --- /dev/null +++ b/TransactionProcessor.Database/Migrations/MySql/20230721142823_addmerchanttosettlementtable.cs @@ -0,0 +1,29 @@ +#nullable disable + +using Microsoft.EntityFrameworkCore.Migrations; + +namespace TransactionProcessor.Database.Migrations.MySql +{ + /// + public partial class addmerchanttosettlementtable : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "MerchantReportingId", + table: "settlement", + type: "int", + nullable: false, + defaultValue: 0); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "MerchantReportingId", + table: "settlement"); + } + } +} diff --git a/TransactionProcessor.Database/Migrations/MySql/20230801201633_storelastsaleagainstmerchant.Designer.cs b/TransactionProcessor.Database/Migrations/MySql/20230801201633_storelastsaleagainstmerchant.Designer.cs new file mode 100644 index 00000000..a24d8ff9 --- /dev/null +++ b/TransactionProcessor.Database/Migrations/MySql/20230801201633_storelastsaleagainstmerchant.Designer.cs @@ -0,0 +1,974 @@ +// + +#nullable disable + +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using TransactionProcessor.Database.Contexts; + +namespace TransactionProcessor.Database.Migrations.MySql +{ + [DbContext(typeof(EstateManagementMySqlContext))] + [Migration("20230801201633_storelastsaleagainstmerchant")] + partial class storelastsaleagainstmerchant + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "7.0.7") + .HasAnnotation("Relational:MaxIdentifierLength", 64); + + modelBuilder.Entity("EstateManagement.Database.Entities.Calendar", b => + { + b.Property("Date") + .HasColumnType("datetime(6)"); + + b.Property("DayOfWeek") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("DayOfWeekNumber") + .HasColumnType("int"); + + b.Property("DayOfWeekShort") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("MonthNameLong") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("MonthNameShort") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("MonthNumber") + .HasColumnType("int"); + + b.Property("WeekNumber") + .HasColumnType("int"); + + b.Property("WeekNumberString") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("Year") + .HasColumnType("int"); + + b.Property("YearWeekNumber") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("Date"); + + b.ToTable("calendar"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Contract", b => + { + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("OperatorId") + .HasColumnType("char(36)"); + + b.Property("ContractId") + .HasColumnType("char(36)"); + + b.Property("ContractReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("Description") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("EstateReportingId", "OperatorId", "ContractId"); + + b.ToTable("contract"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.ContractProduct", b => + { + b.Property("ContractReportingId") + .HasColumnType("int"); + + b.Property("ProductId") + .HasColumnType("char(36)"); + + b.Property("ContractProductReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("DisplayText") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ProductName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ProductType") + .HasColumnType("int"); + + b.Property("Value") + .HasColumnType("decimal(65,30)"); + + b.HasKey("ContractReportingId", "ProductId"); + + b.ToTable("contractproduct"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.ContractProductTransactionFee", b => + { + b.Property("ContractProductReportingId") + .HasColumnType("int"); + + b.Property("TransactionFeeId") + .HasColumnType("char(36)"); + + b.Property("CalculationType") + .HasColumnType("int"); + + b.Property("Description") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("FeeType") + .HasColumnType("int"); + + b.Property("IsEnabled") + .HasColumnType("tinyint(1)"); + + b.Property("TransactionFeeReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("Value") + .HasColumnType("decimal(18,4)"); + + b.HasKey("ContractProductReportingId", "TransactionFeeId"); + + b.ToTable("contractproducttransactionfee"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Estate", b => + { + b.Property("EstateReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("EstateId") + .HasColumnType("char(36)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("Reference") + .HasColumnType("longtext"); + + b.HasKey("EstateReportingId"); + + b.HasIndex("EstateId") + .IsUnique(); + + b.ToTable("estate"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.EstateOperator", b => + { + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("OperatorId") + .HasColumnType("char(36)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("RequireCustomMerchantNumber") + .HasColumnType("tinyint(1)"); + + b.Property("RequireCustomTerminalNumber") + .HasColumnType("tinyint(1)"); + + b.HasKey("EstateReportingId", "OperatorId"); + + b.ToTable("estateoperator"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.EstateSecurityUser", b => + { + b.Property("SecurityUserId") + .HasColumnType("char(36)"); + + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("EmailAddress") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("SecurityUserId", "EstateReportingId"); + + b.ToTable("estatesecurityuser"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.File", b => + { + b.Property("FileReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("FileId") + .HasColumnType("char(36)"); + + b.Property("FileImportLogReportingId") + .HasColumnType("int"); + + b.Property("FileLocation") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("FileProfileId") + .HasColumnType("char(36)"); + + b.Property("FileReceivedDate") + .HasColumnType("date"); + + b.Property("FileReceivedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("IsCompleted") + .HasColumnType("tinyint(1)"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("UserId") + .HasColumnType("char(36)"); + + b.HasKey("FileReportingId"); + + b.HasIndex("FileId") + .IsUnique(); + + b.ToTable("file"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.FileImportLog", b => + { + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("FileImportLogReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("FileImportLogId") + .HasColumnType("char(36)"); + + b.Property("ImportLogDate") + .HasColumnType("date"); + + b.Property("ImportLogDateTime") + .HasColumnType("datetime(6)"); + + b.HasKey("EstateReportingId", "FileImportLogReportingId"); + + b.HasIndex("EstateReportingId", "FileImportLogId") + .IsUnique(); + + b.ToTable("fileimportlog"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.FileImportLogFile", b => + { + b.Property("FileImportLogReportingId") + .HasColumnType("int"); + + b.Property("FileReportingId") + .HasColumnType("int"); + + b.Property("FilePath") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("FileProfileId") + .HasColumnType("char(36)"); + + b.Property("FileUploadedDate") + .HasColumnType("date"); + + b.Property("FileUploadedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("OriginalFileName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("UserId") + .HasColumnType("char(36)"); + + b.HasKey("FileImportLogReportingId", "FileReportingId"); + + b.ToTable("fileimportlogfile"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.FileLine", b => + { + b.Property("FileReportingId") + .HasColumnType("int"); + + b.Property("LineNumber") + .HasColumnType("int"); + + b.Property("FileLineData") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("Status") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.HasKey("FileReportingId", "LineNumber") + .HasAnnotation("SqlServer:Clustered", true); + + b.HasIndex("TransactionReportingId"); + + b.ToTable("fileline"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Merchant", b => + { + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("MerchantReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("LastSaleDate") + .HasColumnType("date"); + + b.Property("LastSaleDateTime") + .HasColumnType("datetime(6)"); + + b.Property("LastStatementGenerated") + .HasColumnType("datetime(6)"); + + b.Property("MerchantId") + .HasColumnType("char(36)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("Reference") + .HasColumnType("longtext"); + + b.Property("SettlementSchedule") + .HasColumnType("int"); + + b.HasKey("EstateReportingId", "MerchantReportingId"); + + b.HasIndex("EstateReportingId", "MerchantId") + .IsUnique(); + + b.ToTable("merchant"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantAddress", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("AddressId") + .HasColumnType("char(36)"); + + b.Property("AddressLine1") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("AddressLine2") + .HasColumnType("longtext"); + + b.Property("AddressLine3") + .HasColumnType("longtext"); + + b.Property("AddressLine4") + .HasColumnType("longtext"); + + b.Property("Country") + .HasColumnType("longtext"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("PostalCode") + .HasColumnType("longtext"); + + b.Property("Region") + .HasColumnType("longtext"); + + b.Property("Town") + .HasColumnType("longtext"); + + b.HasKey("MerchantReportingId", "AddressId"); + + b.ToTable("merchantaddress"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantContact", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("ContactId") + .HasColumnType("char(36)"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("EmailAddress") + .HasColumnType("longtext"); + + b.Property("Name") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("PhoneNumber") + .HasColumnType("longtext"); + + b.HasKey("MerchantReportingId", "ContactId"); + + b.ToTable("merchantcontact"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantDevice", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("DeviceId") + .HasColumnType("char(36)"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("DeviceIdentifier") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("MerchantReportingId", "DeviceId"); + + b.ToTable("merchantdevice"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantOperator", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("OperatorId") + .HasColumnType("char(36)"); + + b.Property("MerchantNumber") + .HasColumnType("longtext"); + + b.Property("Name") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("TerminalNumber") + .HasColumnType("longtext"); + + b.HasKey("MerchantReportingId", "OperatorId"); + + b.ToTable("merchantoperator"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantSecurityUser", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("SecurityUserId") + .HasColumnType("char(36)"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("EmailAddress") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("MerchantReportingId", "SecurityUserId"); + + b.ToTable("merchantsecurityuser"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantSettlementFee", b => + { + b.Property("SettlementReportingId") + .HasColumnType("int"); + + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.Property("TransactionFeeReportingId") + .HasColumnType("int"); + + b.Property("CalculatedValue") + .HasColumnType("decimal(65,30)"); + + b.Property("FeeCalculatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("FeeValue") + .HasColumnType("decimal(65,30)"); + + b.Property("IsSettled") + .HasColumnType("tinyint(1)"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.HasKey("SettlementReportingId", "TransactionReportingId", "TransactionFeeReportingId"); + + b.HasIndex("TransactionReportingId"); + + b.ToTable("merchantsettlementfee"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Reconciliation", b => + { + b.Property("TransactionReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("DeviceIdentifier") + .HasColumnType("longtext"); + + b.Property("IsAuthorised") + .HasColumnType("tinyint(1)"); + + b.Property("IsCompleted") + .HasColumnType("tinyint(1)"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("ResponseCode") + .HasColumnType("longtext"); + + b.Property("ResponseMessage") + .HasColumnType("longtext"); + + b.Property("TransactionCount") + .HasColumnType("int"); + + b.Property("TransactionDate") + .HasColumnType("date"); + + b.Property("TransactionDateTime") + .HasColumnType("datetime(6)"); + + b.Property("TransactionId") + .HasColumnType("char(36)"); + + b.Property("TransactionTime") + .HasColumnType("time(6)"); + + b.Property("TransactionValue") + .HasColumnType("decimal(65,30)"); + + b.HasKey("TransactionReportingId") + .HasAnnotation("SqlServer:Clustered", false); + + b.HasIndex("TransactionDate", "MerchantReportingId") + .HasAnnotation("SqlServer:Clustered", true); + + b.HasIndex("TransactionId", "MerchantReportingId") + .IsUnique() + .HasAnnotation("SqlServer:Clustered", false); + + b.ToTable("reconciliation"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.ResponseCodes", b => + { + b.Property("ResponseCode") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("Description") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("ResponseCode"); + + b.ToTable("responsecodes"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Settlement", b => + { + b.Property("SettlementReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("IsCompleted") + .HasColumnType("tinyint(1)"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("ProcessingStarted") + .HasColumnType("tinyint(1)"); + + b.Property("ProcessingStartedDateTIme") + .HasColumnType("datetime(6)"); + + b.Property("SettlementDate") + .HasColumnType("date"); + + b.Property("SettlementId") + .HasColumnType("char(36)"); + + b.HasKey("SettlementReportingId") + .HasAnnotation("SqlServer:Clustered", false); + + b.HasIndex("EstateReportingId", "SettlementId") + .IsUnique() + .HasAnnotation("SqlServer:Clustered", false); + + b.HasIndex("SettlementDate", "EstateReportingId") + .HasAnnotation("SqlServer:Clustered", true); + + b.ToTable("settlement"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.StatementHeader", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("StatementId") + .HasColumnType("char(36)"); + + b.Property("StatementCreatedDate") + .HasColumnType("date"); + + b.Property("StatementCreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("StatementGeneratedDate") + .HasColumnType("date"); + + b.Property("StatementGeneratedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("StatementReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.HasKey("MerchantReportingId", "StatementId") + .HasAnnotation("SqlServer:Clustered", false); + + b.HasIndex("MerchantReportingId", "StatementGeneratedDate") + .IsUnique() + .HasAnnotation("SqlServer:Clustered", true); + + b.ToTable("statementheader"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.StatementLine", b => + { + b.Property("StatementReportingId") + .HasColumnType("int"); + + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.Property("ActivityDateTime") + .HasColumnType("datetime(6)"); + + b.Property("ActivityType") + .HasColumnType("int"); + + b.Property("ActivityDate") + .HasColumnType("date"); + + b.Property("ActivityDescription") + .HasColumnType("longtext"); + + b.Property("InAmount") + .HasColumnType("decimal(65,30)"); + + b.Property("OutAmount") + .HasColumnType("decimal(65,30)"); + + b.HasKey("StatementReportingId", "TransactionReportingId", "ActivityDateTime", "ActivityType"); + + b.ToTable("statementline"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Transaction", b => + { + b.Property("TransactionReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("AuthorisationCode") + .HasColumnType("longtext"); + + b.Property("ContractProductReportingId") + .HasColumnType("int"); + + b.Property("ContractReportingId") + .HasColumnType("int"); + + b.Property("DeviceIdentifier") + .HasColumnType("longtext"); + + b.Property("IsAuthorised") + .HasColumnType("tinyint(1)"); + + b.Property("IsCompleted") + .HasColumnType("tinyint(1)"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("OperatorIdentifier") + .HasColumnType("longtext"); + + b.Property("ResponseCode") + .HasColumnType("longtext"); + + b.Property("ResponseMessage") + .HasColumnType("longtext"); + + b.Property("TransactionDate") + .HasColumnType("date"); + + b.Property("TransactionDateTime") + .HasColumnType("datetime(6)"); + + b.Property("TransactionId") + .HasColumnType("char(36)"); + + b.Property("TransactionNumber") + .HasColumnType("longtext"); + + b.Property("TransactionReference") + .HasColumnType("longtext"); + + b.Property("TransactionSource") + .HasColumnType("int"); + + b.Property("TransactionTime") + .HasColumnType("time(6)"); + + b.Property("TransactionType") + .HasColumnType("longtext"); + + b.HasKey("TransactionReportingId") + .HasAnnotation("SqlServer:Clustered", false); + + b.HasIndex("TransactionDate", "MerchantReportingId") + .HasAnnotation("SqlServer:Clustered", true); + + b.HasIndex("TransactionId", "MerchantReportingId") + .IsUnique() + .HasAnnotation("SqlServer:Clustered", false); + + b.ToTable("transaction"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.TransactionAdditionalRequestData", b => + { + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.Property("Amount") + .HasColumnType("longtext"); + + b.Property("CustomerAccountNumber") + .HasColumnType("longtext"); + + b.HasKey("TransactionReportingId"); + + b.ToTable("transactionadditionalrequestdata"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.TransactionAdditionalResponseData", b => + { + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.HasKey("TransactionReportingId"); + + b.ToTable("transactionadditionalresponsedata"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Voucher", b => + { + b.Property("VoucherId") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("ExpiryDate") + .HasColumnType("date"); + + b.Property("ExpiryDateTime") + .HasColumnType("datetime(6)"); + + b.Property("GenerateDate") + .HasColumnType("date"); + + b.Property("GenerateDateTime") + .HasColumnType("datetime(6)"); + + b.Property("IsGenerated") + .HasColumnType("tinyint(1)"); + + b.Property("IsIssued") + .HasColumnType("tinyint(1)"); + + b.Property("IsRedeemed") + .HasColumnType("tinyint(1)"); + + b.Property("IssuedDate") + .HasColumnType("date"); + + b.Property("IssuedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("OperatorIdentifier") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("RecipientEmail") + .HasColumnType("longtext"); + + b.Property("RecipientMobile") + .HasColumnType("longtext"); + + b.Property("RedeemedDate") + .HasColumnType("datetime(6)"); + + b.Property("RedeemedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.Property("Value") + .HasColumnType("decimal(65,30)"); + + b.Property("VoucherCode") + .IsRequired() + .HasColumnType("varchar(255)"); + + b.HasKey("VoucherId"); + + b.HasIndex("TransactionReportingId"); + + b.HasIndex("VoucherCode"); + + b.ToTable("voucher"); + }); + + modelBuilder.Entity("EstateManagement.Database.ViewEntities.SettlementView", b => + { + b.Property("Amount") + .HasColumnType("decimal(65,30)"); + + b.Property("CalculatedValue") + .HasColumnType("decimal(65,30)"); + + b.Property("DayOfWeek") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("EstateId") + .HasColumnType("char(36)"); + + b.Property("FeeDescription") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("IsCompleted") + .HasColumnType("tinyint(1)"); + + b.Property("IsSettled") + .HasColumnType("tinyint(1)"); + + b.Property("MerchantId") + .HasColumnType("char(36)"); + + b.Property("MerchantName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("Month") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("MonthNumber") + .HasColumnType("int"); + + b.Property("OperatorIdentifier") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("SettlementDate") + .HasColumnType("datetime(6)"); + + b.Property("SettlementId") + .HasColumnType("char(36)"); + + b.Property("TransactionId") + .HasColumnType("char(36)"); + + b.Property("WeekNumber") + .HasColumnType("int"); + + b.Property("YearNumber") + .HasColumnType("int"); + + b.ToTable((string)null); + + b.ToView("uvwSettlements", (string)null); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/TransactionProcessor.Database/Migrations/MySql/20230801201633_storelastsaleagainstmerchant.cs b/TransactionProcessor.Database/Migrations/MySql/20230801201633_storelastsaleagainstmerchant.cs new file mode 100644 index 00000000..718a1769 --- /dev/null +++ b/TransactionProcessor.Database/Migrations/MySql/20230801201633_storelastsaleagainstmerchant.cs @@ -0,0 +1,40 @@ +#nullable disable + +using Microsoft.EntityFrameworkCore.Migrations; + +namespace TransactionProcessor.Database.Migrations.MySql +{ + /// + public partial class storelastsaleagainstmerchant : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "LastSaleDate", + table: "merchant", + type: "date", + nullable: false, + defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified)); + + migrationBuilder.AddColumn( + name: "LastSaleDateTime", + table: "merchant", + type: "datetime(6)", + nullable: false, + defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified)); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "LastSaleDate", + table: "merchant"); + + migrationBuilder.DropColumn( + name: "LastSaleDateTime", + table: "merchant"); + } + } +} diff --git a/TransactionProcessor.Database/Migrations/MySql/20230905184421_amountintransaction.Designer.cs b/TransactionProcessor.Database/Migrations/MySql/20230905184421_amountintransaction.Designer.cs new file mode 100644 index 00000000..4eb7cb5d --- /dev/null +++ b/TransactionProcessor.Database/Migrations/MySql/20230905184421_amountintransaction.Designer.cs @@ -0,0 +1,981 @@ +// + +#nullable disable + +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using TransactionProcessor.Database.Contexts; + +namespace TransactionProcessor.Database.Migrations.MySql +{ + [DbContext(typeof(EstateManagementMySqlContext))] + [Migration("20230905184421_amountintransaction")] + partial class amountintransaction + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "7.0.7") + .HasAnnotation("Relational:MaxIdentifierLength", 64); + + modelBuilder.Entity("EstateManagement.Database.Entities.Calendar", b => + { + b.Property("Date") + .HasColumnType("datetime(6)"); + + b.Property("DayOfWeek") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("DayOfWeekNumber") + .HasColumnType("int"); + + b.Property("DayOfWeekShort") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("MonthNameLong") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("MonthNameShort") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("MonthNumber") + .HasColumnType("int"); + + b.Property("WeekNumber") + .HasColumnType("int"); + + b.Property("WeekNumberString") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("Year") + .HasColumnType("int"); + + b.Property("YearWeekNumber") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("Date"); + + b.ToTable("calendar"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Contract", b => + { + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("OperatorId") + .HasColumnType("char(36)"); + + b.Property("ContractId") + .HasColumnType("char(36)"); + + b.Property("ContractReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("Description") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("EstateReportingId", "OperatorId", "ContractId"); + + b.ToTable("contract"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.ContractProduct", b => + { + b.Property("ContractReportingId") + .HasColumnType("int"); + + b.Property("ProductId") + .HasColumnType("char(36)"); + + b.Property("ContractProductReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("DisplayText") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ProductName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ProductType") + .HasColumnType("int"); + + b.Property("Value") + .HasColumnType("decimal(65,30)"); + + b.HasKey("ContractReportingId", "ProductId"); + + b.ToTable("contractproduct"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.ContractProductTransactionFee", b => + { + b.Property("ContractProductReportingId") + .HasColumnType("int"); + + b.Property("TransactionFeeId") + .HasColumnType("char(36)"); + + b.Property("CalculationType") + .HasColumnType("int"); + + b.Property("Description") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("FeeType") + .HasColumnType("int"); + + b.Property("IsEnabled") + .HasColumnType("tinyint(1)"); + + b.Property("TransactionFeeReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("Value") + .HasColumnType("decimal(18,4)"); + + b.HasKey("ContractProductReportingId", "TransactionFeeId"); + + b.ToTable("contractproducttransactionfee"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Estate", b => + { + b.Property("EstateReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("EstateId") + .HasColumnType("char(36)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("Reference") + .HasColumnType("longtext"); + + b.HasKey("EstateReportingId"); + + b.HasIndex("EstateId") + .IsUnique(); + + b.ToTable("estate"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.EstateOperator", b => + { + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("OperatorId") + .HasColumnType("char(36)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("RequireCustomMerchantNumber") + .HasColumnType("tinyint(1)"); + + b.Property("RequireCustomTerminalNumber") + .HasColumnType("tinyint(1)"); + + b.HasKey("EstateReportingId", "OperatorId"); + + b.ToTable("estateoperator"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.EstateSecurityUser", b => + { + b.Property("SecurityUserId") + .HasColumnType("char(36)"); + + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("EmailAddress") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("SecurityUserId", "EstateReportingId"); + + b.ToTable("estatesecurityuser"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.File", b => + { + b.Property("FileReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("FileId") + .HasColumnType("char(36)"); + + b.Property("FileImportLogReportingId") + .HasColumnType("int"); + + b.Property("FileLocation") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("FileProfileId") + .HasColumnType("char(36)"); + + b.Property("FileReceivedDate") + .HasColumnType("date"); + + b.Property("FileReceivedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("IsCompleted") + .HasColumnType("tinyint(1)"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("UserId") + .HasColumnType("char(36)"); + + b.HasKey("FileReportingId"); + + b.HasIndex("FileId") + .IsUnique(); + + b.ToTable("file"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.FileImportLog", b => + { + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("FileImportLogReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("FileImportLogId") + .HasColumnType("char(36)"); + + b.Property("ImportLogDate") + .HasColumnType("date"); + + b.Property("ImportLogDateTime") + .HasColumnType("datetime(6)"); + + b.HasKey("EstateReportingId", "FileImportLogReportingId"); + + b.HasIndex("EstateReportingId", "FileImportLogId") + .IsUnique(); + + b.ToTable("fileimportlog"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.FileImportLogFile", b => + { + b.Property("FileImportLogReportingId") + .HasColumnType("int"); + + b.Property("FileReportingId") + .HasColumnType("int"); + + b.Property("FilePath") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("FileProfileId") + .HasColumnType("char(36)"); + + b.Property("FileUploadedDate") + .HasColumnType("date"); + + b.Property("FileUploadedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("OriginalFileName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("UserId") + .HasColumnType("char(36)"); + + b.HasKey("FileImportLogReportingId", "FileReportingId"); + + b.ToTable("fileimportlogfile"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.FileLine", b => + { + b.Property("FileReportingId") + .HasColumnType("int"); + + b.Property("LineNumber") + .HasColumnType("int"); + + b.Property("FileLineData") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("Status") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.HasKey("FileReportingId", "LineNumber") + .HasAnnotation("SqlServer:Clustered", true); + + b.HasIndex("TransactionReportingId"); + + b.ToTable("fileline"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Merchant", b => + { + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("MerchantReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("LastSaleDate") + .HasColumnType("date"); + + b.Property("LastSaleDateTime") + .HasColumnType("datetime(6)"); + + b.Property("LastStatementGenerated") + .HasColumnType("datetime(6)"); + + b.Property("MerchantId") + .HasColumnType("char(36)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("Reference") + .HasColumnType("longtext"); + + b.Property("SettlementSchedule") + .HasColumnType("int"); + + b.HasKey("EstateReportingId", "MerchantReportingId"); + + b.HasIndex("EstateReportingId", "MerchantId") + .IsUnique(); + + b.ToTable("merchant"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantAddress", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("AddressId") + .HasColumnType("char(36)"); + + b.Property("AddressLine1") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("AddressLine2") + .HasColumnType("longtext"); + + b.Property("AddressLine3") + .HasColumnType("longtext"); + + b.Property("AddressLine4") + .HasColumnType("longtext"); + + b.Property("Country") + .HasColumnType("longtext"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("PostalCode") + .HasColumnType("longtext"); + + b.Property("Region") + .HasColumnType("longtext"); + + b.Property("Town") + .HasColumnType("longtext"); + + b.HasKey("MerchantReportingId", "AddressId"); + + b.ToTable("merchantaddress"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantContact", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("ContactId") + .HasColumnType("char(36)"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("EmailAddress") + .HasColumnType("longtext"); + + b.Property("Name") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("PhoneNumber") + .HasColumnType("longtext"); + + b.HasKey("MerchantReportingId", "ContactId"); + + b.ToTable("merchantcontact"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantDevice", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("DeviceId") + .HasColumnType("char(36)"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("DeviceIdentifier") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("MerchantReportingId", "DeviceId"); + + b.ToTable("merchantdevice"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantOperator", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("OperatorId") + .HasColumnType("char(36)"); + + b.Property("MerchantNumber") + .HasColumnType("longtext"); + + b.Property("Name") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("TerminalNumber") + .HasColumnType("longtext"); + + b.HasKey("MerchantReportingId", "OperatorId"); + + b.ToTable("merchantoperator"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantSecurityUser", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("SecurityUserId") + .HasColumnType("char(36)"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("EmailAddress") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("MerchantReportingId", "SecurityUserId"); + + b.ToTable("merchantsecurityuser"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantSettlementFee", b => + { + b.Property("SettlementReportingId") + .HasColumnType("int"); + + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.Property("TransactionFeeReportingId") + .HasColumnType("int"); + + b.Property("CalculatedValue") + .HasColumnType("decimal(65,30)"); + + b.Property("FeeCalculatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("FeeValue") + .HasColumnType("decimal(65,30)"); + + b.Property("IsSettled") + .HasColumnType("tinyint(1)"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.HasKey("SettlementReportingId", "TransactionReportingId", "TransactionFeeReportingId"); + + b.HasIndex("TransactionReportingId"); + + b.ToTable("merchantsettlementfee"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Reconciliation", b => + { + b.Property("TransactionReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("DeviceIdentifier") + .HasColumnType("longtext"); + + b.Property("IsAuthorised") + .HasColumnType("tinyint(1)"); + + b.Property("IsCompleted") + .HasColumnType("tinyint(1)"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("ResponseCode") + .HasColumnType("longtext"); + + b.Property("ResponseMessage") + .HasColumnType("longtext"); + + b.Property("TransactionCount") + .HasColumnType("int"); + + b.Property("TransactionDate") + .HasColumnType("date"); + + b.Property("TransactionDateTime") + .HasColumnType("datetime(6)"); + + b.Property("TransactionId") + .HasColumnType("char(36)"); + + b.Property("TransactionTime") + .HasColumnType("time(6)"); + + b.Property("TransactionValue") + .HasColumnType("decimal(65,30)"); + + b.HasKey("TransactionReportingId") + .HasAnnotation("SqlServer:Clustered", false); + + b.HasIndex("TransactionDate", "MerchantReportingId") + .HasAnnotation("SqlServer:Clustered", true); + + b.HasIndex("TransactionId", "MerchantReportingId") + .IsUnique() + .HasAnnotation("SqlServer:Clustered", false); + + b.ToTable("reconciliation"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.ResponseCodes", b => + { + b.Property("ResponseCode") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("Description") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("ResponseCode"); + + b.ToTable("responsecodes"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Settlement", b => + { + b.Property("SettlementReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("IsCompleted") + .HasColumnType("tinyint(1)"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("ProcessingStarted") + .HasColumnType("tinyint(1)"); + + b.Property("ProcessingStartedDateTIme") + .HasColumnType("datetime(6)"); + + b.Property("SettlementDate") + .HasColumnType("date"); + + b.Property("SettlementId") + .HasColumnType("char(36)"); + + b.HasKey("SettlementReportingId") + .HasAnnotation("SqlServer:Clustered", false); + + b.HasIndex("EstateReportingId", "SettlementId") + .IsUnique() + .HasAnnotation("SqlServer:Clustered", false); + + b.HasIndex("SettlementDate", "EstateReportingId") + .HasAnnotation("SqlServer:Clustered", true); + + b.ToTable("settlement"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.StatementHeader", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("StatementId") + .HasColumnType("char(36)"); + + b.Property("StatementCreatedDate") + .HasColumnType("date"); + + b.Property("StatementCreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("StatementGeneratedDate") + .HasColumnType("date"); + + b.Property("StatementGeneratedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("StatementReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.HasKey("MerchantReportingId", "StatementId") + .HasAnnotation("SqlServer:Clustered", false); + + b.HasIndex("MerchantReportingId", "StatementGeneratedDate") + .IsUnique() + .HasAnnotation("SqlServer:Clustered", true); + + b.ToTable("statementheader"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.StatementLine", b => + { + b.Property("StatementReportingId") + .HasColumnType("int"); + + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.Property("ActivityDateTime") + .HasColumnType("datetime(6)"); + + b.Property("ActivityType") + .HasColumnType("int"); + + b.Property("ActivityDate") + .HasColumnType("date"); + + b.Property("ActivityDescription") + .HasColumnType("longtext"); + + b.Property("InAmount") + .HasColumnType("decimal(65,30)"); + + b.Property("OutAmount") + .HasColumnType("decimal(65,30)"); + + b.HasKey("StatementReportingId", "TransactionReportingId", "ActivityDateTime", "ActivityType"); + + b.ToTable("statementline"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Transaction", b => + { + b.Property("TransactionReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("AuthorisationCode") + .HasColumnType("longtext"); + + b.Property("ContractProductReportingId") + .HasColumnType("int"); + + b.Property("ContractReportingId") + .HasColumnType("int"); + + b.Property("DeviceIdentifier") + .HasColumnType("longtext"); + + b.Property("IsAuthorised") + .HasColumnType("tinyint(1)"); + + b.Property("IsCompleted") + .HasColumnType("tinyint(1)"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("OperatorIdentifier") + .HasColumnType("longtext"); + + b.Property("ResponseCode") + .HasColumnType("longtext"); + + b.Property("ResponseMessage") + .HasColumnType("longtext"); + + b.Property("TransactionAmount") + .HasColumnType("decimal(65,30)"); + + b.Property("TransactionDate") + .HasColumnType("date"); + + b.Property("TransactionDateTime") + .HasColumnType("datetime(6)"); + + b.Property("TransactionId") + .HasColumnType("char(36)"); + + b.Property("TransactionNumber") + .HasColumnType("longtext"); + + b.Property("TransactionReference") + .HasColumnType("longtext"); + + b.Property("TransactionSource") + .HasColumnType("int"); + + b.Property("TransactionTime") + .HasColumnType("time(6)"); + + b.Property("TransactionType") + .HasColumnType("longtext"); + + b.HasKey("TransactionReportingId") + .HasAnnotation("SqlServer:Clustered", false); + + b.HasIndex("TransactionId") + .IsUnique() + .HasAnnotation("SqlServer:Clustered", false); + + b.HasIndex("TransactionDate", "MerchantReportingId") + .HasAnnotation("SqlServer:Clustered", true); + + b.HasIndex("TransactionId", "MerchantReportingId") + .IsUnique() + .HasAnnotation("SqlServer:Clustered", false); + + b.ToTable("transaction"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.TransactionAdditionalRequestData", b => + { + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.Property("Amount") + .HasColumnType("longtext"); + + b.Property("CustomerAccountNumber") + .HasColumnType("longtext"); + + b.HasKey("TransactionReportingId"); + + b.ToTable("transactionadditionalrequestdata"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.TransactionAdditionalResponseData", b => + { + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.HasKey("TransactionReportingId"); + + b.ToTable("transactionadditionalresponsedata"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Voucher", b => + { + b.Property("VoucherId") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("ExpiryDate") + .HasColumnType("date"); + + b.Property("ExpiryDateTime") + .HasColumnType("datetime(6)"); + + b.Property("GenerateDate") + .HasColumnType("date"); + + b.Property("GenerateDateTime") + .HasColumnType("datetime(6)"); + + b.Property("IsGenerated") + .HasColumnType("tinyint(1)"); + + b.Property("IsIssued") + .HasColumnType("tinyint(1)"); + + b.Property("IsRedeemed") + .HasColumnType("tinyint(1)"); + + b.Property("IssuedDate") + .HasColumnType("date"); + + b.Property("IssuedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("OperatorIdentifier") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("RecipientEmail") + .HasColumnType("longtext"); + + b.Property("RecipientMobile") + .HasColumnType("longtext"); + + b.Property("RedeemedDate") + .HasColumnType("datetime(6)"); + + b.Property("RedeemedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.Property("Value") + .HasColumnType("decimal(65,30)"); + + b.Property("VoucherCode") + .IsRequired() + .HasColumnType("varchar(255)"); + + b.HasKey("VoucherId"); + + b.HasIndex("TransactionReportingId"); + + b.HasIndex("VoucherCode"); + + b.ToTable("voucher"); + }); + + modelBuilder.Entity("EstateManagement.Database.ViewEntities.SettlementView", b => + { + b.Property("Amount") + .HasColumnType("decimal(65,30)"); + + b.Property("CalculatedValue") + .HasColumnType("decimal(65,30)"); + + b.Property("DayOfWeek") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("EstateId") + .HasColumnType("char(36)"); + + b.Property("FeeDescription") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("IsCompleted") + .HasColumnType("tinyint(1)"); + + b.Property("IsSettled") + .HasColumnType("tinyint(1)"); + + b.Property("MerchantId") + .HasColumnType("char(36)"); + + b.Property("MerchantName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("Month") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("MonthNumber") + .HasColumnType("int"); + + b.Property("OperatorIdentifier") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("SettlementDate") + .HasColumnType("datetime(6)"); + + b.Property("SettlementId") + .HasColumnType("char(36)"); + + b.Property("TransactionId") + .HasColumnType("char(36)"); + + b.Property("WeekNumber") + .HasColumnType("int"); + + b.Property("YearNumber") + .HasColumnType("int"); + + b.ToTable((string)null); + + b.ToView("uvwSettlements", (string)null); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/TransactionProcessor.Database/Migrations/MySql/20230905184421_amountintransaction.cs b/TransactionProcessor.Database/Migrations/MySql/20230905184421_amountintransaction.cs new file mode 100644 index 00000000..8e6667ab --- /dev/null +++ b/TransactionProcessor.Database/Migrations/MySql/20230905184421_amountintransaction.cs @@ -0,0 +1,39 @@ +#nullable disable + +using Microsoft.EntityFrameworkCore.Migrations; + +namespace TransactionProcessor.Database.Migrations.MySql +{ + /// + public partial class amountintransaction : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "TransactionAmount", + table: "transaction", + type: "decimal(65,30)", + nullable: false, + defaultValue: 0m); + + migrationBuilder.CreateIndex( + name: "IX_transaction_TransactionId", + table: "transaction", + column: "TransactionId", + unique: true); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropIndex( + name: "IX_transaction_TransactionId", + table: "transaction"); + + migrationBuilder.DropColumn( + name: "TransactionAmount", + table: "transaction"); + } + } +} diff --git a/TransactionProcessor.Database/Migrations/MySql/20231115193921_recordestateoperatorreportingidwithtxn.Designer.cs b/TransactionProcessor.Database/Migrations/MySql/20231115193921_recordestateoperatorreportingidwithtxn.Designer.cs new file mode 100644 index 00000000..bece80be --- /dev/null +++ b/TransactionProcessor.Database/Migrations/MySql/20231115193921_recordestateoperatorreportingidwithtxn.Designer.cs @@ -0,0 +1,985 @@ +// + +#nullable disable + +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using TransactionProcessor.Database.Contexts; + +namespace TransactionProcessor.Database.Migrations.MySql +{ + [DbContext(typeof(EstateManagementMySqlContext))] + [Migration("20231115193921_recordestateoperatorreportingidwithtxn")] + partial class recordestateoperatorreportingidwithtxn + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "7.0.7") + .HasAnnotation("Relational:MaxIdentifierLength", 64); + + modelBuilder.Entity("EstateManagement.Database.Entities.Calendar", b => + { + b.Property("Date") + .HasColumnType("datetime(6)"); + + b.Property("DayOfWeek") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("DayOfWeekNumber") + .HasColumnType("int"); + + b.Property("DayOfWeekShort") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("MonthNameLong") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("MonthNameShort") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("MonthNumber") + .HasColumnType("int"); + + b.Property("WeekNumber") + .HasColumnType("int"); + + b.Property("WeekNumberString") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("Year") + .HasColumnType("int"); + + b.Property("YearWeekNumber") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("Date"); + + b.ToTable("calendar"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Contract", b => + { + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("OperatorId") + .HasColumnType("char(36)"); + + b.Property("ContractId") + .HasColumnType("char(36)"); + + b.Property("ContractReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("Description") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("EstateReportingId", "OperatorId", "ContractId"); + + b.ToTable("contract"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.ContractProduct", b => + { + b.Property("ContractReportingId") + .HasColumnType("int"); + + b.Property("ProductId") + .HasColumnType("char(36)"); + + b.Property("ContractProductReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("DisplayText") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ProductName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ProductType") + .HasColumnType("int"); + + b.Property("Value") + .HasColumnType("decimal(65,30)"); + + b.HasKey("ContractReportingId", "ProductId"); + + b.ToTable("contractproduct"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.ContractProductTransactionFee", b => + { + b.Property("ContractProductReportingId") + .HasColumnType("int"); + + b.Property("TransactionFeeId") + .HasColumnType("char(36)"); + + b.Property("CalculationType") + .HasColumnType("int"); + + b.Property("Description") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("FeeType") + .HasColumnType("int"); + + b.Property("IsEnabled") + .HasColumnType("tinyint(1)"); + + b.Property("TransactionFeeReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("Value") + .HasColumnType("decimal(18,4)"); + + b.HasKey("ContractProductReportingId", "TransactionFeeId"); + + b.ToTable("contractproducttransactionfee"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Estate", b => + { + b.Property("EstateReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("EstateId") + .HasColumnType("char(36)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("Reference") + .HasColumnType("longtext"); + + b.HasKey("EstateReportingId"); + + b.HasIndex("EstateId") + .IsUnique(); + + b.ToTable("estate"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.EstateOperator", b => + { + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("OperatorId") + .HasColumnType("char(36)"); + + b.Property("EstateOperatorReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("Name") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("RequireCustomMerchantNumber") + .HasColumnType("tinyint(1)"); + + b.Property("RequireCustomTerminalNumber") + .HasColumnType("tinyint(1)"); + + b.HasKey("EstateReportingId", "OperatorId"); + + b.ToTable("estateoperator"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.EstateSecurityUser", b => + { + b.Property("SecurityUserId") + .HasColumnType("char(36)"); + + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("EmailAddress") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("SecurityUserId", "EstateReportingId"); + + b.ToTable("estatesecurityuser"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.File", b => + { + b.Property("FileReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("FileId") + .HasColumnType("char(36)"); + + b.Property("FileImportLogReportingId") + .HasColumnType("int"); + + b.Property("FileLocation") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("FileProfileId") + .HasColumnType("char(36)"); + + b.Property("FileReceivedDate") + .HasColumnType("date"); + + b.Property("FileReceivedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("IsCompleted") + .HasColumnType("tinyint(1)"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("UserId") + .HasColumnType("char(36)"); + + b.HasKey("FileReportingId"); + + b.HasIndex("FileId") + .IsUnique(); + + b.ToTable("file"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.FileImportLog", b => + { + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("FileImportLogReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("FileImportLogId") + .HasColumnType("char(36)"); + + b.Property("ImportLogDate") + .HasColumnType("date"); + + b.Property("ImportLogDateTime") + .HasColumnType("datetime(6)"); + + b.HasKey("EstateReportingId", "FileImportLogReportingId"); + + b.HasIndex("EstateReportingId", "FileImportLogId") + .IsUnique(); + + b.ToTable("fileimportlog"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.FileImportLogFile", b => + { + b.Property("FileImportLogReportingId") + .HasColumnType("int"); + + b.Property("FileReportingId") + .HasColumnType("int"); + + b.Property("FilePath") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("FileProfileId") + .HasColumnType("char(36)"); + + b.Property("FileUploadedDate") + .HasColumnType("date"); + + b.Property("FileUploadedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("OriginalFileName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("UserId") + .HasColumnType("char(36)"); + + b.HasKey("FileImportLogReportingId", "FileReportingId"); + + b.ToTable("fileimportlogfile"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.FileLine", b => + { + b.Property("FileReportingId") + .HasColumnType("int"); + + b.Property("LineNumber") + .HasColumnType("int"); + + b.Property("FileLineData") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("Status") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.HasKey("FileReportingId", "LineNumber") + .HasAnnotation("SqlServer:Clustered", true); + + b.HasIndex("TransactionReportingId"); + + b.ToTable("fileline"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Merchant", b => + { + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("MerchantReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("LastSaleDate") + .HasColumnType("date"); + + b.Property("LastSaleDateTime") + .HasColumnType("datetime(6)"); + + b.Property("LastStatementGenerated") + .HasColumnType("datetime(6)"); + + b.Property("MerchantId") + .HasColumnType("char(36)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("Reference") + .HasColumnType("longtext"); + + b.Property("SettlementSchedule") + .HasColumnType("int"); + + b.HasKey("EstateReportingId", "MerchantReportingId"); + + b.HasIndex("EstateReportingId", "MerchantId") + .IsUnique(); + + b.ToTable("merchant"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantAddress", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("AddressId") + .HasColumnType("char(36)"); + + b.Property("AddressLine1") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("AddressLine2") + .HasColumnType("longtext"); + + b.Property("AddressLine3") + .HasColumnType("longtext"); + + b.Property("AddressLine4") + .HasColumnType("longtext"); + + b.Property("Country") + .HasColumnType("longtext"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("PostalCode") + .HasColumnType("longtext"); + + b.Property("Region") + .HasColumnType("longtext"); + + b.Property("Town") + .HasColumnType("longtext"); + + b.HasKey("MerchantReportingId", "AddressId"); + + b.ToTable("merchantaddress"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantContact", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("ContactId") + .HasColumnType("char(36)"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("EmailAddress") + .HasColumnType("longtext"); + + b.Property("Name") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("PhoneNumber") + .HasColumnType("longtext"); + + b.HasKey("MerchantReportingId", "ContactId"); + + b.ToTable("merchantcontact"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantDevice", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("DeviceId") + .HasColumnType("char(36)"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("DeviceIdentifier") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("MerchantReportingId", "DeviceId"); + + b.ToTable("merchantdevice"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantOperator", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("OperatorId") + .HasColumnType("char(36)"); + + b.Property("MerchantNumber") + .HasColumnType("longtext"); + + b.Property("Name") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("TerminalNumber") + .HasColumnType("longtext"); + + b.HasKey("MerchantReportingId", "OperatorId"); + + b.ToTable("merchantoperator"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantSecurityUser", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("SecurityUserId") + .HasColumnType("char(36)"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("EmailAddress") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("MerchantReportingId", "SecurityUserId"); + + b.ToTable("merchantsecurityuser"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantSettlementFee", b => + { + b.Property("SettlementReportingId") + .HasColumnType("int"); + + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.Property("TransactionFeeReportingId") + .HasColumnType("int"); + + b.Property("CalculatedValue") + .HasColumnType("decimal(65,30)"); + + b.Property("FeeCalculatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("FeeValue") + .HasColumnType("decimal(65,30)"); + + b.Property("IsSettled") + .HasColumnType("tinyint(1)"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.HasKey("SettlementReportingId", "TransactionReportingId", "TransactionFeeReportingId"); + + b.HasIndex("TransactionReportingId"); + + b.ToTable("merchantsettlementfee"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Reconciliation", b => + { + b.Property("TransactionReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("DeviceIdentifier") + .HasColumnType("longtext"); + + b.Property("IsAuthorised") + .HasColumnType("tinyint(1)"); + + b.Property("IsCompleted") + .HasColumnType("tinyint(1)"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("ResponseCode") + .HasColumnType("longtext"); + + b.Property("ResponseMessage") + .HasColumnType("longtext"); + + b.Property("TransactionCount") + .HasColumnType("int"); + + b.Property("TransactionDate") + .HasColumnType("date"); + + b.Property("TransactionDateTime") + .HasColumnType("datetime(6)"); + + b.Property("TransactionId") + .HasColumnType("char(36)"); + + b.Property("TransactionTime") + .HasColumnType("time(6)"); + + b.Property("TransactionValue") + .HasColumnType("decimal(65,30)"); + + b.HasKey("TransactionReportingId") + .HasAnnotation("SqlServer:Clustered", false); + + b.HasIndex("TransactionDate", "MerchantReportingId") + .HasAnnotation("SqlServer:Clustered", true); + + b.HasIndex("TransactionId", "MerchantReportingId") + .IsUnique() + .HasAnnotation("SqlServer:Clustered", false); + + b.ToTable("reconciliation"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.ResponseCodes", b => + { + b.Property("ResponseCode") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("Description") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("ResponseCode"); + + b.ToTable("responsecodes"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Settlement", b => + { + b.Property("SettlementReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("IsCompleted") + .HasColumnType("tinyint(1)"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("ProcessingStarted") + .HasColumnType("tinyint(1)"); + + b.Property("ProcessingStartedDateTIme") + .HasColumnType("datetime(6)"); + + b.Property("SettlementDate") + .HasColumnType("date"); + + b.Property("SettlementId") + .HasColumnType("char(36)"); + + b.HasKey("SettlementReportingId") + .HasAnnotation("SqlServer:Clustered", false); + + b.HasIndex("EstateReportingId", "SettlementId") + .IsUnique() + .HasAnnotation("SqlServer:Clustered", false); + + b.HasIndex("SettlementDate", "EstateReportingId") + .HasAnnotation("SqlServer:Clustered", true); + + b.ToTable("settlement"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.StatementHeader", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("StatementId") + .HasColumnType("char(36)"); + + b.Property("StatementCreatedDate") + .HasColumnType("date"); + + b.Property("StatementCreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("StatementGeneratedDate") + .HasColumnType("date"); + + b.Property("StatementGeneratedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("StatementReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.HasKey("MerchantReportingId", "StatementId") + .HasAnnotation("SqlServer:Clustered", false); + + b.HasIndex("MerchantReportingId", "StatementGeneratedDate") + .IsUnique() + .HasAnnotation("SqlServer:Clustered", true); + + b.ToTable("statementheader"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.StatementLine", b => + { + b.Property("StatementReportingId") + .HasColumnType("int"); + + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.Property("ActivityDateTime") + .HasColumnType("datetime(6)"); + + b.Property("ActivityType") + .HasColumnType("int"); + + b.Property("ActivityDate") + .HasColumnType("date"); + + b.Property("ActivityDescription") + .HasColumnType("longtext"); + + b.Property("InAmount") + .HasColumnType("decimal(65,30)"); + + b.Property("OutAmount") + .HasColumnType("decimal(65,30)"); + + b.HasKey("StatementReportingId", "TransactionReportingId", "ActivityDateTime", "ActivityType"); + + b.ToTable("statementline"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Transaction", b => + { + b.Property("TransactionReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("AuthorisationCode") + .HasColumnType("longtext"); + + b.Property("ContractProductReportingId") + .HasColumnType("int"); + + b.Property("ContractReportingId") + .HasColumnType("int"); + + b.Property("DeviceIdentifier") + .HasColumnType("longtext"); + + b.Property("EstateOperatorReportingId") + .HasColumnType("int"); + + b.Property("IsAuthorised") + .HasColumnType("tinyint(1)"); + + b.Property("IsCompleted") + .HasColumnType("tinyint(1)"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("ResponseCode") + .HasColumnType("longtext"); + + b.Property("ResponseMessage") + .HasColumnType("longtext"); + + b.Property("TransactionAmount") + .HasColumnType("decimal(65,30)"); + + b.Property("TransactionDate") + .HasColumnType("date"); + + b.Property("TransactionDateTime") + .HasColumnType("datetime(6)"); + + b.Property("TransactionId") + .HasColumnType("char(36)"); + + b.Property("TransactionNumber") + .HasColumnType("longtext"); + + b.Property("TransactionReference") + .HasColumnType("longtext"); + + b.Property("TransactionSource") + .HasColumnType("int"); + + b.Property("TransactionTime") + .HasColumnType("time(6)"); + + b.Property("TransactionType") + .HasColumnType("longtext"); + + b.HasKey("TransactionReportingId") + .HasAnnotation("SqlServer:Clustered", false); + + b.HasIndex("TransactionId") + .IsUnique() + .HasAnnotation("SqlServer:Clustered", false); + + b.HasIndex("TransactionDate", "MerchantReportingId") + .HasAnnotation("SqlServer:Clustered", true); + + b.HasIndex("TransactionId", "MerchantReportingId") + .IsUnique() + .HasAnnotation("SqlServer:Clustered", false); + + b.ToTable("transaction"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.TransactionAdditionalRequestData", b => + { + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.Property("Amount") + .HasColumnType("longtext"); + + b.Property("CustomerAccountNumber") + .HasColumnType("longtext"); + + b.HasKey("TransactionReportingId"); + + b.ToTable("transactionadditionalrequestdata"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.TransactionAdditionalResponseData", b => + { + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.HasKey("TransactionReportingId"); + + b.ToTable("transactionadditionalresponsedata"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Voucher", b => + { + b.Property("VoucherId") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("ExpiryDate") + .HasColumnType("date"); + + b.Property("ExpiryDateTime") + .HasColumnType("datetime(6)"); + + b.Property("GenerateDate") + .HasColumnType("date"); + + b.Property("GenerateDateTime") + .HasColumnType("datetime(6)"); + + b.Property("IsGenerated") + .HasColumnType("tinyint(1)"); + + b.Property("IsIssued") + .HasColumnType("tinyint(1)"); + + b.Property("IsRedeemed") + .HasColumnType("tinyint(1)"); + + b.Property("IssuedDate") + .HasColumnType("date"); + + b.Property("IssuedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("OperatorIdentifier") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("RecipientEmail") + .HasColumnType("longtext"); + + b.Property("RecipientMobile") + .HasColumnType("longtext"); + + b.Property("RedeemedDate") + .HasColumnType("datetime(6)"); + + b.Property("RedeemedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.Property("Value") + .HasColumnType("decimal(65,30)"); + + b.Property("VoucherCode") + .IsRequired() + .HasColumnType("varchar(255)"); + + b.HasKey("VoucherId"); + + b.HasIndex("TransactionReportingId"); + + b.HasIndex("VoucherCode"); + + b.ToTable("voucher"); + }); + + modelBuilder.Entity("EstateManagement.Database.ViewEntities.SettlementView", b => + { + b.Property("Amount") + .HasColumnType("decimal(65,30)"); + + b.Property("CalculatedValue") + .HasColumnType("decimal(65,30)"); + + b.Property("DayOfWeek") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("EstateId") + .HasColumnType("char(36)"); + + b.Property("FeeDescription") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("IsCompleted") + .HasColumnType("tinyint(1)"); + + b.Property("IsSettled") + .HasColumnType("tinyint(1)"); + + b.Property("MerchantId") + .HasColumnType("char(36)"); + + b.Property("MerchantName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("Month") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("MonthNumber") + .HasColumnType("int"); + + b.Property("OperatorIdentifier") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("SettlementDate") + .HasColumnType("datetime(6)"); + + b.Property("SettlementId") + .HasColumnType("char(36)"); + + b.Property("TransactionId") + .HasColumnType("char(36)"); + + b.Property("WeekNumber") + .HasColumnType("int"); + + b.Property("YearNumber") + .HasColumnType("int"); + + b.ToTable((string)null); + + b.ToView("uvwSettlements", (string)null); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/TransactionProcessor.Database/Migrations/MySql/20231115193921_recordestateoperatorreportingidwithtxn.cs b/TransactionProcessor.Database/Migrations/MySql/20231115193921_recordestateoperatorreportingidwithtxn.cs new file mode 100644 index 00000000..898e1c73 --- /dev/null +++ b/TransactionProcessor.Database/Migrations/MySql/20231115193921_recordestateoperatorreportingidwithtxn.cs @@ -0,0 +1,53 @@ +#nullable disable + +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; + +namespace TransactionProcessor.Database.Migrations.MySql +{ + /// + public partial class recordestateoperatorreportingidwithtxn : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "OperatorIdentifier", + table: "transaction"); + + migrationBuilder.AddColumn( + name: "EstateOperatorReportingId", + table: "transaction", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "EstateOperatorReportingId", + table: "estateoperator", + type: "int", + nullable: false, + defaultValue: 0) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "EstateOperatorReportingId", + table: "transaction"); + + migrationBuilder.DropColumn( + name: "EstateOperatorReportingId", + table: "estateoperator"); + + migrationBuilder.AddColumn( + name: "OperatorIdentifier", + table: "transaction", + type: "longtext", + nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"); + } + } +} diff --git a/TransactionProcessor.Database/Migrations/MySql/20231228135806_addmerchantcontracttable.Designer.cs b/TransactionProcessor.Database/Migrations/MySql/20231228135806_addmerchantcontracttable.Designer.cs new file mode 100644 index 00000000..d638f866 --- /dev/null +++ b/TransactionProcessor.Database/Migrations/MySql/20231228135806_addmerchantcontracttable.Designer.cs @@ -0,0 +1,998 @@ +// + +#nullable disable + +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using TransactionProcessor.Database.Contexts; + +namespace TransactionProcessor.Database.Migrations.MySql +{ + [DbContext(typeof(EstateManagementMySqlContext))] + [Migration("20231228135806_addmerchantcontracttable")] + partial class addmerchantcontracttable + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "7.0.7") + .HasAnnotation("Relational:MaxIdentifierLength", 64); + + modelBuilder.Entity("EstateManagement.Database.Entities.Calendar", b => + { + b.Property("Date") + .HasColumnType("datetime(6)"); + + b.Property("DayOfWeek") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("DayOfWeekNumber") + .HasColumnType("int"); + + b.Property("DayOfWeekShort") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("MonthNameLong") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("MonthNameShort") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("MonthNumber") + .HasColumnType("int"); + + b.Property("WeekNumber") + .HasColumnType("int"); + + b.Property("WeekNumberString") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("Year") + .HasColumnType("int"); + + b.Property("YearWeekNumber") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("Date"); + + b.ToTable("calendar"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Contract", b => + { + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("OperatorId") + .HasColumnType("char(36)"); + + b.Property("ContractId") + .HasColumnType("char(36)"); + + b.Property("ContractReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("Description") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("EstateReportingId", "OperatorId", "ContractId"); + + b.ToTable("contract"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.ContractProduct", b => + { + b.Property("ContractReportingId") + .HasColumnType("int"); + + b.Property("ProductId") + .HasColumnType("char(36)"); + + b.Property("ContractProductReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("DisplayText") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ProductName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ProductType") + .HasColumnType("int"); + + b.Property("Value") + .HasColumnType("decimal(65,30)"); + + b.HasKey("ContractReportingId", "ProductId"); + + b.ToTable("contractproduct"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.ContractProductTransactionFee", b => + { + b.Property("ContractProductReportingId") + .HasColumnType("int"); + + b.Property("TransactionFeeId") + .HasColumnType("char(36)"); + + b.Property("CalculationType") + .HasColumnType("int"); + + b.Property("Description") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("FeeType") + .HasColumnType("int"); + + b.Property("IsEnabled") + .HasColumnType("tinyint(1)"); + + b.Property("TransactionFeeReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("Value") + .HasColumnType("decimal(18,4)"); + + b.HasKey("ContractProductReportingId", "TransactionFeeId"); + + b.ToTable("contractproducttransactionfee"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Estate", b => + { + b.Property("EstateReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("EstateId") + .HasColumnType("char(36)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("Reference") + .HasColumnType("longtext"); + + b.HasKey("EstateReportingId"); + + b.HasIndex("EstateId") + .IsUnique(); + + b.ToTable("estate"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.EstateOperator", b => + { + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("OperatorId") + .HasColumnType("char(36)"); + + b.Property("EstateOperatorReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("Name") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("RequireCustomMerchantNumber") + .HasColumnType("tinyint(1)"); + + b.Property("RequireCustomTerminalNumber") + .HasColumnType("tinyint(1)"); + + b.HasKey("EstateReportingId", "OperatorId"); + + b.ToTable("estateoperator"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.EstateSecurityUser", b => + { + b.Property("SecurityUserId") + .HasColumnType("char(36)"); + + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("EmailAddress") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("SecurityUserId", "EstateReportingId"); + + b.ToTable("estatesecurityuser"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.File", b => + { + b.Property("FileReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("FileId") + .HasColumnType("char(36)"); + + b.Property("FileImportLogReportingId") + .HasColumnType("int"); + + b.Property("FileLocation") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("FileProfileId") + .HasColumnType("char(36)"); + + b.Property("FileReceivedDate") + .HasColumnType("date"); + + b.Property("FileReceivedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("IsCompleted") + .HasColumnType("tinyint(1)"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("UserId") + .HasColumnType("char(36)"); + + b.HasKey("FileReportingId"); + + b.HasIndex("FileId") + .IsUnique(); + + b.ToTable("file"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.FileImportLog", b => + { + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("FileImportLogReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("FileImportLogId") + .HasColumnType("char(36)"); + + b.Property("ImportLogDate") + .HasColumnType("date"); + + b.Property("ImportLogDateTime") + .HasColumnType("datetime(6)"); + + b.HasKey("EstateReportingId", "FileImportLogReportingId"); + + b.HasIndex("EstateReportingId", "FileImportLogId") + .IsUnique(); + + b.ToTable("fileimportlog"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.FileImportLogFile", b => + { + b.Property("FileImportLogReportingId") + .HasColumnType("int"); + + b.Property("FileReportingId") + .HasColumnType("int"); + + b.Property("FilePath") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("FileProfileId") + .HasColumnType("char(36)"); + + b.Property("FileUploadedDate") + .HasColumnType("date"); + + b.Property("FileUploadedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("OriginalFileName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("UserId") + .HasColumnType("char(36)"); + + b.HasKey("FileImportLogReportingId", "FileReportingId"); + + b.ToTable("fileimportlogfile"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.FileLine", b => + { + b.Property("FileReportingId") + .HasColumnType("int"); + + b.Property("LineNumber") + .HasColumnType("int"); + + b.Property("FileLineData") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("Status") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.HasKey("FileReportingId", "LineNumber") + .HasAnnotation("SqlServer:Clustered", true); + + b.HasIndex("TransactionReportingId"); + + b.ToTable("fileline"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Merchant", b => + { + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("MerchantReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("LastSaleDate") + .HasColumnType("date"); + + b.Property("LastSaleDateTime") + .HasColumnType("datetime(6)"); + + b.Property("LastStatementGenerated") + .HasColumnType("datetime(6)"); + + b.Property("MerchantId") + .HasColumnType("char(36)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("Reference") + .HasColumnType("longtext"); + + b.Property("SettlementSchedule") + .HasColumnType("int"); + + b.HasKey("EstateReportingId", "MerchantReportingId"); + + b.HasIndex("EstateReportingId", "MerchantId") + .IsUnique(); + + b.ToTable("merchant"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantAddress", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("AddressId") + .HasColumnType("char(36)"); + + b.Property("AddressLine1") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("AddressLine2") + .HasColumnType("longtext"); + + b.Property("AddressLine3") + .HasColumnType("longtext"); + + b.Property("AddressLine4") + .HasColumnType("longtext"); + + b.Property("Country") + .HasColumnType("longtext"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("PostalCode") + .HasColumnType("longtext"); + + b.Property("Region") + .HasColumnType("longtext"); + + b.Property("Town") + .HasColumnType("longtext"); + + b.HasKey("MerchantReportingId", "AddressId"); + + b.ToTable("merchantaddress"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantContact", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("ContactId") + .HasColumnType("char(36)"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("EmailAddress") + .HasColumnType("longtext"); + + b.Property("Name") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("PhoneNumber") + .HasColumnType("longtext"); + + b.HasKey("MerchantReportingId", "ContactId"); + + b.ToTable("merchantcontact"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantContract", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("ContractReportingId") + .HasColumnType("int"); + + b.HasKey("MerchantReportingId", "ContractReportingId"); + + b.ToTable("MerchantContracts"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantDevice", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("DeviceId") + .HasColumnType("char(36)"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("DeviceIdentifier") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("MerchantReportingId", "DeviceId"); + + b.ToTable("merchantdevice"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantOperator", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("OperatorId") + .HasColumnType("char(36)"); + + b.Property("MerchantNumber") + .HasColumnType("longtext"); + + b.Property("Name") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("TerminalNumber") + .HasColumnType("longtext"); + + b.HasKey("MerchantReportingId", "OperatorId"); + + b.ToTable("merchantoperator"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantSecurityUser", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("SecurityUserId") + .HasColumnType("char(36)"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("EmailAddress") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("MerchantReportingId", "SecurityUserId"); + + b.ToTable("merchantsecurityuser"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantSettlementFee", b => + { + b.Property("SettlementReportingId") + .HasColumnType("int"); + + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.Property("TransactionFeeReportingId") + .HasColumnType("int"); + + b.Property("CalculatedValue") + .HasColumnType("decimal(65,30)"); + + b.Property("FeeCalculatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("FeeValue") + .HasColumnType("decimal(65,30)"); + + b.Property("IsSettled") + .HasColumnType("tinyint(1)"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.HasKey("SettlementReportingId", "TransactionReportingId", "TransactionFeeReportingId"); + + b.HasIndex("TransactionReportingId"); + + b.ToTable("merchantsettlementfee"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Reconciliation", b => + { + b.Property("TransactionReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("DeviceIdentifier") + .HasColumnType("longtext"); + + b.Property("IsAuthorised") + .HasColumnType("tinyint(1)"); + + b.Property("IsCompleted") + .HasColumnType("tinyint(1)"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("ResponseCode") + .HasColumnType("longtext"); + + b.Property("ResponseMessage") + .HasColumnType("longtext"); + + b.Property("TransactionCount") + .HasColumnType("int"); + + b.Property("TransactionDate") + .HasColumnType("date"); + + b.Property("TransactionDateTime") + .HasColumnType("datetime(6)"); + + b.Property("TransactionId") + .HasColumnType("char(36)"); + + b.Property("TransactionTime") + .HasColumnType("time(6)"); + + b.Property("TransactionValue") + .HasColumnType("decimal(65,30)"); + + b.HasKey("TransactionReportingId") + .HasAnnotation("SqlServer:Clustered", false); + + b.HasIndex("TransactionDate", "MerchantReportingId") + .HasAnnotation("SqlServer:Clustered", true); + + b.HasIndex("TransactionId", "MerchantReportingId") + .IsUnique() + .HasAnnotation("SqlServer:Clustered", false); + + b.ToTable("reconciliation"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.ResponseCodes", b => + { + b.Property("ResponseCode") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("Description") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("ResponseCode"); + + b.ToTable("responsecodes"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Settlement", b => + { + b.Property("SettlementReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("IsCompleted") + .HasColumnType("tinyint(1)"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("ProcessingStarted") + .HasColumnType("tinyint(1)"); + + b.Property("ProcessingStartedDateTIme") + .HasColumnType("datetime(6)"); + + b.Property("SettlementDate") + .HasColumnType("date"); + + b.Property("SettlementId") + .HasColumnType("char(36)"); + + b.HasKey("SettlementReportingId") + .HasAnnotation("SqlServer:Clustered", false); + + b.HasIndex("EstateReportingId", "SettlementId") + .IsUnique() + .HasAnnotation("SqlServer:Clustered", false); + + b.HasIndex("SettlementDate", "EstateReportingId") + .HasAnnotation("SqlServer:Clustered", true); + + b.ToTable("settlement"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.StatementHeader", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("StatementId") + .HasColumnType("char(36)"); + + b.Property("StatementCreatedDate") + .HasColumnType("date"); + + b.Property("StatementCreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("StatementGeneratedDate") + .HasColumnType("date"); + + b.Property("StatementGeneratedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("StatementReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.HasKey("MerchantReportingId", "StatementId") + .HasAnnotation("SqlServer:Clustered", false); + + b.HasIndex("MerchantReportingId", "StatementGeneratedDate") + .IsUnique() + .HasAnnotation("SqlServer:Clustered", true); + + b.ToTable("statementheader"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.StatementLine", b => + { + b.Property("StatementReportingId") + .HasColumnType("int"); + + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.Property("ActivityDateTime") + .HasColumnType("datetime(6)"); + + b.Property("ActivityType") + .HasColumnType("int"); + + b.Property("ActivityDate") + .HasColumnType("date"); + + b.Property("ActivityDescription") + .HasColumnType("longtext"); + + b.Property("InAmount") + .HasColumnType("decimal(65,30)"); + + b.Property("OutAmount") + .HasColumnType("decimal(65,30)"); + + b.HasKey("StatementReportingId", "TransactionReportingId", "ActivityDateTime", "ActivityType"); + + b.ToTable("statementline"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Transaction", b => + { + b.Property("TransactionReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("AuthorisationCode") + .HasColumnType("longtext"); + + b.Property("ContractProductReportingId") + .HasColumnType("int"); + + b.Property("ContractReportingId") + .HasColumnType("int"); + + b.Property("DeviceIdentifier") + .HasColumnType("longtext"); + + b.Property("EstateOperatorReportingId") + .HasColumnType("int"); + + b.Property("IsAuthorised") + .HasColumnType("tinyint(1)"); + + b.Property("IsCompleted") + .HasColumnType("tinyint(1)"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("ResponseCode") + .HasColumnType("longtext"); + + b.Property("ResponseMessage") + .HasColumnType("longtext"); + + b.Property("TransactionAmount") + .HasColumnType("decimal(65,30)"); + + b.Property("TransactionDate") + .HasColumnType("date"); + + b.Property("TransactionDateTime") + .HasColumnType("datetime(6)"); + + b.Property("TransactionId") + .HasColumnType("char(36)"); + + b.Property("TransactionNumber") + .HasColumnType("longtext"); + + b.Property("TransactionReference") + .HasColumnType("longtext"); + + b.Property("TransactionSource") + .HasColumnType("int"); + + b.Property("TransactionTime") + .HasColumnType("time(6)"); + + b.Property("TransactionType") + .HasColumnType("longtext"); + + b.HasKey("TransactionReportingId") + .HasAnnotation("SqlServer:Clustered", false); + + b.HasIndex("TransactionId") + .IsUnique() + .HasAnnotation("SqlServer:Clustered", false); + + b.HasIndex("TransactionDate", "MerchantReportingId") + .HasAnnotation("SqlServer:Clustered", true); + + b.HasIndex("TransactionId", "MerchantReportingId") + .IsUnique() + .HasAnnotation("SqlServer:Clustered", false); + + b.ToTable("transaction"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.TransactionAdditionalRequestData", b => + { + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.Property("Amount") + .HasColumnType("longtext"); + + b.Property("CustomerAccountNumber") + .HasColumnType("longtext"); + + b.HasKey("TransactionReportingId"); + + b.ToTable("transactionadditionalrequestdata"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.TransactionAdditionalResponseData", b => + { + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.HasKey("TransactionReportingId"); + + b.ToTable("transactionadditionalresponsedata"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Voucher", b => + { + b.Property("VoucherId") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("ExpiryDate") + .HasColumnType("date"); + + b.Property("ExpiryDateTime") + .HasColumnType("datetime(6)"); + + b.Property("GenerateDate") + .HasColumnType("date"); + + b.Property("GenerateDateTime") + .HasColumnType("datetime(6)"); + + b.Property("IsGenerated") + .HasColumnType("tinyint(1)"); + + b.Property("IsIssued") + .HasColumnType("tinyint(1)"); + + b.Property("IsRedeemed") + .HasColumnType("tinyint(1)"); + + b.Property("IssuedDate") + .HasColumnType("date"); + + b.Property("IssuedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("OperatorIdentifier") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("RecipientEmail") + .HasColumnType("longtext"); + + b.Property("RecipientMobile") + .HasColumnType("longtext"); + + b.Property("RedeemedDate") + .HasColumnType("datetime(6)"); + + b.Property("RedeemedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.Property("Value") + .HasColumnType("decimal(65,30)"); + + b.Property("VoucherCode") + .IsRequired() + .HasColumnType("varchar(255)"); + + b.HasKey("VoucherId"); + + b.HasIndex("TransactionReportingId"); + + b.HasIndex("VoucherCode"); + + b.ToTable("voucher"); + }); + + modelBuilder.Entity("EstateManagement.Database.ViewEntities.SettlementView", b => + { + b.Property("Amount") + .HasColumnType("decimal(65,30)"); + + b.Property("CalculatedValue") + .HasColumnType("decimal(65,30)"); + + b.Property("DayOfWeek") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("EstateId") + .HasColumnType("char(36)"); + + b.Property("FeeDescription") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("IsCompleted") + .HasColumnType("tinyint(1)"); + + b.Property("IsSettled") + .HasColumnType("tinyint(1)"); + + b.Property("MerchantId") + .HasColumnType("char(36)"); + + b.Property("MerchantName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("Month") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("MonthNumber") + .HasColumnType("int"); + + b.Property("OperatorIdentifier") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("SettlementDate") + .HasColumnType("datetime(6)"); + + b.Property("SettlementId") + .HasColumnType("char(36)"); + + b.Property("TransactionId") + .HasColumnType("char(36)"); + + b.Property("WeekNumber") + .HasColumnType("int"); + + b.Property("YearNumber") + .HasColumnType("int"); + + b.ToTable((string)null); + + b.ToView("uvwSettlements", (string)null); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/TransactionProcessor.Database/Migrations/MySql/20231228135806_addmerchantcontracttable.cs b/TransactionProcessor.Database/Migrations/MySql/20231228135806_addmerchantcontracttable.cs new file mode 100644 index 00000000..892668e5 --- /dev/null +++ b/TransactionProcessor.Database/Migrations/MySql/20231228135806_addmerchantcontracttable.cs @@ -0,0 +1,34 @@ +#nullable disable + +using Microsoft.EntityFrameworkCore.Migrations; + +namespace TransactionProcessor.Database.Migrations.MySql +{ + /// + public partial class addmerchantcontracttable : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "MerchantContracts", + columns: table => new + { + MerchantReportingId = table.Column(type: "int", nullable: false), + ContractReportingId = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_MerchantContracts", x => new { x.MerchantReportingId, x.ContractReportingId }); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "MerchantContracts"); + } + } +} diff --git a/TransactionProcessor.Database/Migrations/MySql/20240210074240_floattables.Designer.cs b/TransactionProcessor.Database/Migrations/MySql/20240210074240_floattables.Designer.cs new file mode 100644 index 00000000..d7a5d3c8 --- /dev/null +++ b/TransactionProcessor.Database/Migrations/MySql/20240210074240_floattables.Designer.cs @@ -0,0 +1,1062 @@ +// + +#nullable disable + +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using TransactionProcessor.Database.Contexts; + +namespace TransactionProcessor.Database.Migrations.MySql +{ + [DbContext(typeof(EstateManagementMySqlContext))] + [Migration("20240210074240_floattables")] + partial class floattables + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "7.0.7") + .HasAnnotation("Relational:MaxIdentifierLength", 64); + + modelBuilder.Entity("EstateManagement.Database.Entities.Calendar", b => + { + b.Property("Date") + .HasColumnType("datetime(6)"); + + b.Property("DayOfWeek") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("DayOfWeekNumber") + .HasColumnType("int"); + + b.Property("DayOfWeekShort") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("MonthNameLong") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("MonthNameShort") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("MonthNumber") + .HasColumnType("int"); + + b.Property("WeekNumber") + .HasColumnType("int"); + + b.Property("WeekNumberString") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("Year") + .HasColumnType("int"); + + b.Property("YearWeekNumber") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("Date"); + + b.ToTable("calendar"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Contract", b => + { + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("OperatorId") + .HasColumnType("char(36)"); + + b.Property("ContractId") + .HasColumnType("char(36)"); + + b.Property("ContractReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("Description") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("EstateReportingId", "OperatorId", "ContractId"); + + b.ToTable("contract"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.ContractProduct", b => + { + b.Property("ContractReportingId") + .HasColumnType("int"); + + b.Property("ProductId") + .HasColumnType("char(36)"); + + b.Property("ContractProductReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("DisplayText") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ProductName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ProductType") + .HasColumnType("int"); + + b.Property("Value") + .HasColumnType("decimal(65,30)"); + + b.HasKey("ContractReportingId", "ProductId"); + + b.ToTable("contractproduct"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.ContractProductTransactionFee", b => + { + b.Property("ContractProductReportingId") + .HasColumnType("int"); + + b.Property("TransactionFeeId") + .HasColumnType("char(36)"); + + b.Property("CalculationType") + .HasColumnType("int"); + + b.Property("Description") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("FeeType") + .HasColumnType("int"); + + b.Property("IsEnabled") + .HasColumnType("tinyint(1)"); + + b.Property("TransactionFeeReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("Value") + .HasColumnType("decimal(18,4)"); + + b.HasKey("ContractProductReportingId", "TransactionFeeId"); + + b.ToTable("contractproducttransactionfee"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Estate", b => + { + b.Property("EstateReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("EstateId") + .HasColumnType("char(36)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("Reference") + .HasColumnType("longtext"); + + b.HasKey("EstateReportingId"); + + b.HasIndex("EstateId") + .IsUnique(); + + b.ToTable("estate"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.EstateOperator", b => + { + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("OperatorId") + .HasColumnType("char(36)"); + + b.Property("EstateOperatorReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("Name") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("RequireCustomMerchantNumber") + .HasColumnType("tinyint(1)"); + + b.Property("RequireCustomTerminalNumber") + .HasColumnType("tinyint(1)"); + + b.HasKey("EstateReportingId", "OperatorId"); + + b.ToTable("estateoperator"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.EstateSecurityUser", b => + { + b.Property("SecurityUserId") + .HasColumnType("char(36)"); + + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("EmailAddress") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("SecurityUserId", "EstateReportingId"); + + b.ToTable("estatesecurityuser"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.File", b => + { + b.Property("FileReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("FileId") + .HasColumnType("char(36)"); + + b.Property("FileImportLogReportingId") + .HasColumnType("int"); + + b.Property("FileLocation") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("FileProfileId") + .HasColumnType("char(36)"); + + b.Property("FileReceivedDate") + .HasColumnType("date"); + + b.Property("FileReceivedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("IsCompleted") + .HasColumnType("tinyint(1)"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("UserId") + .HasColumnType("char(36)"); + + b.HasKey("FileReportingId"); + + b.HasIndex("FileId") + .IsUnique(); + + b.ToTable("file"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.FileImportLog", b => + { + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("FileImportLogReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("FileImportLogId") + .HasColumnType("char(36)"); + + b.Property("ImportLogDate") + .HasColumnType("date"); + + b.Property("ImportLogDateTime") + .HasColumnType("datetime(6)"); + + b.HasKey("EstateReportingId", "FileImportLogReportingId"); + + b.HasIndex("EstateReportingId", "FileImportLogId") + .IsUnique(); + + b.ToTable("fileimportlog"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.FileImportLogFile", b => + { + b.Property("FileImportLogReportingId") + .HasColumnType("int"); + + b.Property("FileReportingId") + .HasColumnType("int"); + + b.Property("FilePath") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("FileProfileId") + .HasColumnType("char(36)"); + + b.Property("FileUploadedDate") + .HasColumnType("date"); + + b.Property("FileUploadedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("OriginalFileName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("UserId") + .HasColumnType("char(36)"); + + b.HasKey("FileImportLogReportingId", "FileReportingId"); + + b.ToTable("fileimportlogfile"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.FileLine", b => + { + b.Property("FileReportingId") + .HasColumnType("int"); + + b.Property("LineNumber") + .HasColumnType("int"); + + b.Property("FileLineData") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("Status") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.HasKey("FileReportingId", "LineNumber") + .HasAnnotation("SqlServer:Clustered", true); + + b.HasIndex("TransactionReportingId"); + + b.ToTable("fileline"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Float", b => + { + b.Property("FloatId") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("ContractId") + .HasColumnType("char(36)"); + + b.Property("CreatedDate") + .HasColumnType("date"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("EstateId") + .HasColumnType("char(36)"); + + b.Property("ProductId") + .HasColumnType("char(36)"); + + b.HasKey("FloatId") + .HasAnnotation("SqlServer:Clustered", false); + + b.HasIndex("CreatedDate") + .HasAnnotation("SqlServer:Clustered", true); + + b.ToTable("Floats"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.FloatActivity", b => + { + b.Property("EventId") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("ActivityDate") + .HasColumnType("date"); + + b.Property("ActivityDateTime") + .HasColumnType("datetime(6)"); + + b.Property("Amount") + .HasColumnType("decimal(65,30)"); + + b.Property("CostPrice") + .HasColumnType("decimal(65,30)"); + + b.Property("CreditOrDebit") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("FloatId") + .HasColumnType("char(36)"); + + b.HasKey("EventId") + .HasAnnotation("SqlServer:Clustered", false); + + b.HasIndex("ActivityDate") + .HasAnnotation("SqlServer:Clustered", true); + + b.ToTable("FloatActivity"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Merchant", b => + { + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("MerchantReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("LastSaleDate") + .HasColumnType("date"); + + b.Property("LastSaleDateTime") + .HasColumnType("datetime(6)"); + + b.Property("LastStatementGenerated") + .HasColumnType("datetime(6)"); + + b.Property("MerchantId") + .HasColumnType("char(36)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("Reference") + .HasColumnType("longtext"); + + b.Property("SettlementSchedule") + .HasColumnType("int"); + + b.HasKey("EstateReportingId", "MerchantReportingId"); + + b.HasIndex("EstateReportingId", "MerchantId") + .IsUnique(); + + b.ToTable("merchant"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantAddress", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("AddressId") + .HasColumnType("char(36)"); + + b.Property("AddressLine1") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("AddressLine2") + .HasColumnType("longtext"); + + b.Property("AddressLine3") + .HasColumnType("longtext"); + + b.Property("AddressLine4") + .HasColumnType("longtext"); + + b.Property("Country") + .HasColumnType("longtext"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("PostalCode") + .HasColumnType("longtext"); + + b.Property("Region") + .HasColumnType("longtext"); + + b.Property("Town") + .HasColumnType("longtext"); + + b.HasKey("MerchantReportingId", "AddressId"); + + b.ToTable("merchantaddress"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantContact", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("ContactId") + .HasColumnType("char(36)"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("EmailAddress") + .HasColumnType("longtext"); + + b.Property("Name") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("PhoneNumber") + .HasColumnType("longtext"); + + b.HasKey("MerchantReportingId", "ContactId"); + + b.ToTable("merchantcontact"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantContract", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("ContractReportingId") + .HasColumnType("int"); + + b.HasKey("MerchantReportingId", "ContractReportingId"); + + b.ToTable("MerchantContracts"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantDevice", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("DeviceId") + .HasColumnType("char(36)"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("DeviceIdentifier") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("MerchantReportingId", "DeviceId"); + + b.ToTable("merchantdevice"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantOperator", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("OperatorId") + .HasColumnType("char(36)"); + + b.Property("MerchantNumber") + .HasColumnType("longtext"); + + b.Property("Name") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("TerminalNumber") + .HasColumnType("longtext"); + + b.HasKey("MerchantReportingId", "OperatorId"); + + b.ToTable("merchantoperator"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantSecurityUser", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("SecurityUserId") + .HasColumnType("char(36)"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("EmailAddress") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("MerchantReportingId", "SecurityUserId"); + + b.ToTable("merchantsecurityuser"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantSettlementFee", b => + { + b.Property("SettlementReportingId") + .HasColumnType("int"); + + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.Property("TransactionFeeReportingId") + .HasColumnType("int"); + + b.Property("CalculatedValue") + .HasColumnType("decimal(65,30)"); + + b.Property("FeeCalculatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("FeeValue") + .HasColumnType("decimal(65,30)"); + + b.Property("IsSettled") + .HasColumnType("tinyint(1)"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.HasKey("SettlementReportingId", "TransactionReportingId", "TransactionFeeReportingId"); + + b.HasIndex("TransactionReportingId"); + + b.ToTable("merchantsettlementfee"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Reconciliation", b => + { + b.Property("TransactionReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("DeviceIdentifier") + .HasColumnType("longtext"); + + b.Property("IsAuthorised") + .HasColumnType("tinyint(1)"); + + b.Property("IsCompleted") + .HasColumnType("tinyint(1)"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("ResponseCode") + .HasColumnType("longtext"); + + b.Property("ResponseMessage") + .HasColumnType("longtext"); + + b.Property("TransactionCount") + .HasColumnType("int"); + + b.Property("TransactionDate") + .HasColumnType("date"); + + b.Property("TransactionDateTime") + .HasColumnType("datetime(6)"); + + b.Property("TransactionId") + .HasColumnType("char(36)"); + + b.Property("TransactionTime") + .HasColumnType("time(6)"); + + b.Property("TransactionValue") + .HasColumnType("decimal(65,30)"); + + b.HasKey("TransactionReportingId") + .HasAnnotation("SqlServer:Clustered", false); + + b.HasIndex("TransactionDate", "MerchantReportingId") + .HasAnnotation("SqlServer:Clustered", true); + + b.HasIndex("TransactionId", "MerchantReportingId") + .IsUnique() + .HasAnnotation("SqlServer:Clustered", false); + + b.ToTable("reconciliation"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.ResponseCodes", b => + { + b.Property("ResponseCode") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("Description") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("ResponseCode"); + + b.ToTable("responsecodes"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Settlement", b => + { + b.Property("SettlementReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("IsCompleted") + .HasColumnType("tinyint(1)"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("ProcessingStarted") + .HasColumnType("tinyint(1)"); + + b.Property("ProcessingStartedDateTIme") + .HasColumnType("datetime(6)"); + + b.Property("SettlementDate") + .HasColumnType("date"); + + b.Property("SettlementId") + .HasColumnType("char(36)"); + + b.HasKey("SettlementReportingId") + .HasAnnotation("SqlServer:Clustered", false); + + b.HasIndex("EstateReportingId", "SettlementId") + .IsUnique() + .HasAnnotation("SqlServer:Clustered", false); + + b.HasIndex("SettlementDate", "EstateReportingId") + .HasAnnotation("SqlServer:Clustered", true); + + b.ToTable("settlement"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.StatementHeader", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("StatementId") + .HasColumnType("char(36)"); + + b.Property("StatementCreatedDate") + .HasColumnType("date"); + + b.Property("StatementCreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("StatementGeneratedDate") + .HasColumnType("date"); + + b.Property("StatementGeneratedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("StatementReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.HasKey("MerchantReportingId", "StatementId") + .HasAnnotation("SqlServer:Clustered", false); + + b.HasIndex("MerchantReportingId", "StatementGeneratedDate") + .IsUnique() + .HasAnnotation("SqlServer:Clustered", true); + + b.ToTable("statementheader"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.StatementLine", b => + { + b.Property("StatementReportingId") + .HasColumnType("int"); + + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.Property("ActivityDateTime") + .HasColumnType("datetime(6)"); + + b.Property("ActivityType") + .HasColumnType("int"); + + b.Property("ActivityDate") + .HasColumnType("date"); + + b.Property("ActivityDescription") + .HasColumnType("longtext"); + + b.Property("InAmount") + .HasColumnType("decimal(65,30)"); + + b.Property("OutAmount") + .HasColumnType("decimal(65,30)"); + + b.HasKey("StatementReportingId", "TransactionReportingId", "ActivityDateTime", "ActivityType"); + + b.ToTable("statementline"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Transaction", b => + { + b.Property("TransactionReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("AuthorisationCode") + .HasColumnType("longtext"); + + b.Property("ContractProductReportingId") + .HasColumnType("int"); + + b.Property("ContractReportingId") + .HasColumnType("int"); + + b.Property("DeviceIdentifier") + .HasColumnType("longtext"); + + b.Property("EstateOperatorReportingId") + .HasColumnType("int"); + + b.Property("IsAuthorised") + .HasColumnType("tinyint(1)"); + + b.Property("IsCompleted") + .HasColumnType("tinyint(1)"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("ResponseCode") + .HasColumnType("longtext"); + + b.Property("ResponseMessage") + .HasColumnType("longtext"); + + b.Property("TransactionAmount") + .HasColumnType("decimal(65,30)"); + + b.Property("TransactionDate") + .HasColumnType("date"); + + b.Property("TransactionDateTime") + .HasColumnType("datetime(6)"); + + b.Property("TransactionId") + .HasColumnType("char(36)"); + + b.Property("TransactionNumber") + .HasColumnType("longtext"); + + b.Property("TransactionReference") + .HasColumnType("longtext"); + + b.Property("TransactionSource") + .HasColumnType("int"); + + b.Property("TransactionTime") + .HasColumnType("time(6)"); + + b.Property("TransactionType") + .HasColumnType("longtext"); + + b.HasKey("TransactionReportingId") + .HasAnnotation("SqlServer:Clustered", false); + + b.HasIndex("TransactionId") + .IsUnique() + .HasAnnotation("SqlServer:Clustered", false); + + b.HasIndex("TransactionDate", "MerchantReportingId") + .HasAnnotation("SqlServer:Clustered", true); + + b.HasIndex("TransactionId", "MerchantReportingId") + .IsUnique() + .HasAnnotation("SqlServer:Clustered", false); + + b.ToTable("transaction"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.TransactionAdditionalRequestData", b => + { + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.Property("Amount") + .HasColumnType("longtext"); + + b.Property("CustomerAccountNumber") + .HasColumnType("longtext"); + + b.HasKey("TransactionReportingId"); + + b.ToTable("transactionadditionalrequestdata"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.TransactionAdditionalResponseData", b => + { + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.HasKey("TransactionReportingId"); + + b.ToTable("transactionadditionalresponsedata"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Voucher", b => + { + b.Property("VoucherId") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("ExpiryDate") + .HasColumnType("date"); + + b.Property("ExpiryDateTime") + .HasColumnType("datetime(6)"); + + b.Property("GenerateDate") + .HasColumnType("date"); + + b.Property("GenerateDateTime") + .HasColumnType("datetime(6)"); + + b.Property("IsGenerated") + .HasColumnType("tinyint(1)"); + + b.Property("IsIssued") + .HasColumnType("tinyint(1)"); + + b.Property("IsRedeemed") + .HasColumnType("tinyint(1)"); + + b.Property("IssuedDate") + .HasColumnType("date"); + + b.Property("IssuedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("OperatorIdentifier") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("RecipientEmail") + .HasColumnType("longtext"); + + b.Property("RecipientMobile") + .HasColumnType("longtext"); + + b.Property("RedeemedDate") + .HasColumnType("datetime(6)"); + + b.Property("RedeemedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.Property("Value") + .HasColumnType("decimal(65,30)"); + + b.Property("VoucherCode") + .IsRequired() + .HasColumnType("varchar(255)"); + + b.HasKey("VoucherId"); + + b.HasIndex("TransactionReportingId"); + + b.HasIndex("VoucherCode"); + + b.ToTable("voucher"); + }); + + modelBuilder.Entity("EstateManagement.Database.ViewEntities.SettlementView", b => + { + b.Property("Amount") + .HasColumnType("decimal(65,30)"); + + b.Property("CalculatedValue") + .HasColumnType("decimal(65,30)"); + + b.Property("DayOfWeek") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("EstateId") + .HasColumnType("char(36)"); + + b.Property("FeeDescription") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("IsCompleted") + .HasColumnType("tinyint(1)"); + + b.Property("IsSettled") + .HasColumnType("tinyint(1)"); + + b.Property("MerchantId") + .HasColumnType("char(36)"); + + b.Property("MerchantName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("Month") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("MonthNumber") + .HasColumnType("int"); + + b.Property("OperatorIdentifier") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("SettlementDate") + .HasColumnType("datetime(6)"); + + b.Property("SettlementId") + .HasColumnType("char(36)"); + + b.Property("TransactionId") + .HasColumnType("char(36)"); + + b.Property("WeekNumber") + .HasColumnType("int"); + + b.Property("YearNumber") + .HasColumnType("int"); + + b.ToTable((string)null); + + b.ToView("uvwSettlements", (string)null); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/TransactionProcessor.Database/Migrations/MySql/20240210074240_floattables.cs b/TransactionProcessor.Database/Migrations/MySql/20240210074240_floattables.cs new file mode 100644 index 00000000..8c90b6a8 --- /dev/null +++ b/TransactionProcessor.Database/Migrations/MySql/20240210074240_floattables.cs @@ -0,0 +1,70 @@ +#nullable disable + +using Microsoft.EntityFrameworkCore.Migrations; + +namespace TransactionProcessor.Database.Migrations.MySql +{ + /// + public partial class floattables : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "FloatActivity", + columns: table => new + { + EventId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + FloatId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + ActivityDate = table.Column(type: "date", nullable: false), + ActivityDateTime = table.Column(type: "datetime(6)", nullable: false), + CreditOrDebit = table.Column(type: "longtext", nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + Amount = table.Column(type: "decimal(65,30)", nullable: false), + CostPrice = table.Column(type: "decimal(65,30)", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_FloatActivity", x => x.EventId); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "Floats", + columns: table => new + { + FloatId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + EstateId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + ContractId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + ProductId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + CreatedDateTime = table.Column(type: "datetime(6)", nullable: false), + CreatedDate = table.Column(type: "date", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Floats", x => x.FloatId); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateIndex( + name: "IX_FloatActivity_ActivityDate", + table: "FloatActivity", + column: "ActivityDate"); + + migrationBuilder.CreateIndex( + name: "IX_Floats_CreatedDate", + table: "Floats", + column: "CreatedDate"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "FloatActivity"); + + migrationBuilder.DropTable( + name: "Floats"); + } + } +} diff --git a/TransactionProcessor.Database/Migrations/MySql/20240313172001_fixstatementheaderindex.Designer.cs b/TransactionProcessor.Database/Migrations/MySql/20240313172001_fixstatementheaderindex.Designer.cs new file mode 100644 index 00000000..7d232ffb --- /dev/null +++ b/TransactionProcessor.Database/Migrations/MySql/20240313172001_fixstatementheaderindex.Designer.cs @@ -0,0 +1,1061 @@ +// + +#nullable disable + +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using TransactionProcessor.Database.Contexts; + +namespace TransactionProcessor.Database.Migrations.MySql +{ + [DbContext(typeof(EstateManagementMySqlContext))] + [Migration("20240313172001_fixstatementheaderindex")] + partial class fixstatementheaderindex + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "7.0.7") + .HasAnnotation("Relational:MaxIdentifierLength", 64); + + modelBuilder.Entity("EstateManagement.Database.Entities.Calendar", b => + { + b.Property("Date") + .HasColumnType("datetime(6)"); + + b.Property("DayOfWeek") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("DayOfWeekNumber") + .HasColumnType("int"); + + b.Property("DayOfWeekShort") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("MonthNameLong") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("MonthNameShort") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("MonthNumber") + .HasColumnType("int"); + + b.Property("WeekNumber") + .HasColumnType("int"); + + b.Property("WeekNumberString") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("Year") + .HasColumnType("int"); + + b.Property("YearWeekNumber") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("Date"); + + b.ToTable("calendar"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Contract", b => + { + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("OperatorId") + .HasColumnType("char(36)"); + + b.Property("ContractId") + .HasColumnType("char(36)"); + + b.Property("ContractReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("Description") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("EstateReportingId", "OperatorId", "ContractId"); + + b.ToTable("contract"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.ContractProduct", b => + { + b.Property("ContractReportingId") + .HasColumnType("int"); + + b.Property("ProductId") + .HasColumnType("char(36)"); + + b.Property("ContractProductReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("DisplayText") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ProductName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ProductType") + .HasColumnType("int"); + + b.Property("Value") + .HasColumnType("decimal(65,30)"); + + b.HasKey("ContractReportingId", "ProductId"); + + b.ToTable("contractproduct"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.ContractProductTransactionFee", b => + { + b.Property("ContractProductReportingId") + .HasColumnType("int"); + + b.Property("TransactionFeeId") + .HasColumnType("char(36)"); + + b.Property("CalculationType") + .HasColumnType("int"); + + b.Property("Description") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("FeeType") + .HasColumnType("int"); + + b.Property("IsEnabled") + .HasColumnType("tinyint(1)"); + + b.Property("TransactionFeeReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("Value") + .HasColumnType("decimal(18,4)"); + + b.HasKey("ContractProductReportingId", "TransactionFeeId"); + + b.ToTable("contractproducttransactionfee"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Estate", b => + { + b.Property("EstateReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("EstateId") + .HasColumnType("char(36)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("Reference") + .HasColumnType("longtext"); + + b.HasKey("EstateReportingId"); + + b.HasIndex("EstateId") + .IsUnique(); + + b.ToTable("estate"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.EstateOperator", b => + { + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("OperatorId") + .HasColumnType("char(36)"); + + b.Property("EstateOperatorReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("Name") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("RequireCustomMerchantNumber") + .HasColumnType("tinyint(1)"); + + b.Property("RequireCustomTerminalNumber") + .HasColumnType("tinyint(1)"); + + b.HasKey("EstateReportingId", "OperatorId"); + + b.ToTable("estateoperator"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.EstateSecurityUser", b => + { + b.Property("SecurityUserId") + .HasColumnType("char(36)"); + + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("EmailAddress") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("SecurityUserId", "EstateReportingId"); + + b.ToTable("estatesecurityuser"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.File", b => + { + b.Property("FileReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("FileId") + .HasColumnType("char(36)"); + + b.Property("FileImportLogReportingId") + .HasColumnType("int"); + + b.Property("FileLocation") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("FileProfileId") + .HasColumnType("char(36)"); + + b.Property("FileReceivedDate") + .HasColumnType("date"); + + b.Property("FileReceivedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("IsCompleted") + .HasColumnType("tinyint(1)"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("UserId") + .HasColumnType("char(36)"); + + b.HasKey("FileReportingId"); + + b.HasIndex("FileId") + .IsUnique(); + + b.ToTable("file"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.FileImportLog", b => + { + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("FileImportLogReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("FileImportLogId") + .HasColumnType("char(36)"); + + b.Property("ImportLogDate") + .HasColumnType("date"); + + b.Property("ImportLogDateTime") + .HasColumnType("datetime(6)"); + + b.HasKey("EstateReportingId", "FileImportLogReportingId"); + + b.HasIndex("EstateReportingId", "FileImportLogId") + .IsUnique(); + + b.ToTable("fileimportlog"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.FileImportLogFile", b => + { + b.Property("FileImportLogReportingId") + .HasColumnType("int"); + + b.Property("FileReportingId") + .HasColumnType("int"); + + b.Property("FilePath") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("FileProfileId") + .HasColumnType("char(36)"); + + b.Property("FileUploadedDate") + .HasColumnType("date"); + + b.Property("FileUploadedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("OriginalFileName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("UserId") + .HasColumnType("char(36)"); + + b.HasKey("FileImportLogReportingId", "FileReportingId"); + + b.ToTable("fileimportlogfile"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.FileLine", b => + { + b.Property("FileReportingId") + .HasColumnType("int"); + + b.Property("LineNumber") + .HasColumnType("int"); + + b.Property("FileLineData") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("Status") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.HasKey("FileReportingId", "LineNumber") + .HasAnnotation("SqlServer:Clustered", true); + + b.HasIndex("TransactionReportingId"); + + b.ToTable("fileline"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Float", b => + { + b.Property("FloatId") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("ContractId") + .HasColumnType("char(36)"); + + b.Property("CreatedDate") + .HasColumnType("date"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("EstateId") + .HasColumnType("char(36)"); + + b.Property("ProductId") + .HasColumnType("char(36)"); + + b.HasKey("FloatId") + .HasAnnotation("SqlServer:Clustered", false); + + b.HasIndex("CreatedDate") + .HasAnnotation("SqlServer:Clustered", true); + + b.ToTable("Floats"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.FloatActivity", b => + { + b.Property("EventId") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("ActivityDate") + .HasColumnType("date"); + + b.Property("ActivityDateTime") + .HasColumnType("datetime(6)"); + + b.Property("Amount") + .HasColumnType("decimal(65,30)"); + + b.Property("CostPrice") + .HasColumnType("decimal(65,30)"); + + b.Property("CreditOrDebit") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("FloatId") + .HasColumnType("char(36)"); + + b.HasKey("EventId") + .HasAnnotation("SqlServer:Clustered", false); + + b.HasIndex("ActivityDate") + .HasAnnotation("SqlServer:Clustered", true); + + b.ToTable("FloatActivity"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Merchant", b => + { + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("MerchantReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("LastSaleDate") + .HasColumnType("date"); + + b.Property("LastSaleDateTime") + .HasColumnType("datetime(6)"); + + b.Property("LastStatementGenerated") + .HasColumnType("datetime(6)"); + + b.Property("MerchantId") + .HasColumnType("char(36)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("Reference") + .HasColumnType("longtext"); + + b.Property("SettlementSchedule") + .HasColumnType("int"); + + b.HasKey("EstateReportingId", "MerchantReportingId"); + + b.HasIndex("EstateReportingId", "MerchantId") + .IsUnique(); + + b.ToTable("merchant"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantAddress", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("AddressId") + .HasColumnType("char(36)"); + + b.Property("AddressLine1") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("AddressLine2") + .HasColumnType("longtext"); + + b.Property("AddressLine3") + .HasColumnType("longtext"); + + b.Property("AddressLine4") + .HasColumnType("longtext"); + + b.Property("Country") + .HasColumnType("longtext"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("PostalCode") + .HasColumnType("longtext"); + + b.Property("Region") + .HasColumnType("longtext"); + + b.Property("Town") + .HasColumnType("longtext"); + + b.HasKey("MerchantReportingId", "AddressId"); + + b.ToTable("merchantaddress"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantContact", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("ContactId") + .HasColumnType("char(36)"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("EmailAddress") + .HasColumnType("longtext"); + + b.Property("Name") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("PhoneNumber") + .HasColumnType("longtext"); + + b.HasKey("MerchantReportingId", "ContactId"); + + b.ToTable("merchantcontact"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantContract", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("ContractReportingId") + .HasColumnType("int"); + + b.HasKey("MerchantReportingId", "ContractReportingId"); + + b.ToTable("MerchantContracts"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantDevice", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("DeviceId") + .HasColumnType("char(36)"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("DeviceIdentifier") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("MerchantReportingId", "DeviceId"); + + b.ToTable("merchantdevice"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantOperator", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("OperatorId") + .HasColumnType("char(36)"); + + b.Property("MerchantNumber") + .HasColumnType("longtext"); + + b.Property("Name") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("TerminalNumber") + .HasColumnType("longtext"); + + b.HasKey("MerchantReportingId", "OperatorId"); + + b.ToTable("merchantoperator"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantSecurityUser", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("SecurityUserId") + .HasColumnType("char(36)"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("EmailAddress") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("MerchantReportingId", "SecurityUserId"); + + b.ToTable("merchantsecurityuser"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantSettlementFee", b => + { + b.Property("SettlementReportingId") + .HasColumnType("int"); + + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.Property("TransactionFeeReportingId") + .HasColumnType("int"); + + b.Property("CalculatedValue") + .HasColumnType("decimal(65,30)"); + + b.Property("FeeCalculatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("FeeValue") + .HasColumnType("decimal(65,30)"); + + b.Property("IsSettled") + .HasColumnType("tinyint(1)"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.HasKey("SettlementReportingId", "TransactionReportingId", "TransactionFeeReportingId"); + + b.HasIndex("TransactionReportingId"); + + b.ToTable("merchantsettlementfee"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Reconciliation", b => + { + b.Property("TransactionReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("DeviceIdentifier") + .HasColumnType("longtext"); + + b.Property("IsAuthorised") + .HasColumnType("tinyint(1)"); + + b.Property("IsCompleted") + .HasColumnType("tinyint(1)"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("ResponseCode") + .HasColumnType("longtext"); + + b.Property("ResponseMessage") + .HasColumnType("longtext"); + + b.Property("TransactionCount") + .HasColumnType("int"); + + b.Property("TransactionDate") + .HasColumnType("date"); + + b.Property("TransactionDateTime") + .HasColumnType("datetime(6)"); + + b.Property("TransactionId") + .HasColumnType("char(36)"); + + b.Property("TransactionTime") + .HasColumnType("time(6)"); + + b.Property("TransactionValue") + .HasColumnType("decimal(65,30)"); + + b.HasKey("TransactionReportingId") + .HasAnnotation("SqlServer:Clustered", false); + + b.HasIndex("TransactionDate", "MerchantReportingId") + .HasAnnotation("SqlServer:Clustered", true); + + b.HasIndex("TransactionId", "MerchantReportingId") + .IsUnique() + .HasAnnotation("SqlServer:Clustered", false); + + b.ToTable("reconciliation"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.ResponseCodes", b => + { + b.Property("ResponseCode") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("Description") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("ResponseCode"); + + b.ToTable("responsecodes"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Settlement", b => + { + b.Property("SettlementReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("IsCompleted") + .HasColumnType("tinyint(1)"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("ProcessingStarted") + .HasColumnType("tinyint(1)"); + + b.Property("ProcessingStartedDateTIme") + .HasColumnType("datetime(6)"); + + b.Property("SettlementDate") + .HasColumnType("date"); + + b.Property("SettlementId") + .HasColumnType("char(36)"); + + b.HasKey("SettlementReportingId") + .HasAnnotation("SqlServer:Clustered", false); + + b.HasIndex("EstateReportingId", "SettlementId") + .IsUnique() + .HasAnnotation("SqlServer:Clustered", false); + + b.HasIndex("SettlementDate", "EstateReportingId") + .HasAnnotation("SqlServer:Clustered", true); + + b.ToTable("settlement"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.StatementHeader", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("StatementId") + .HasColumnType("char(36)"); + + b.Property("StatementCreatedDate") + .HasColumnType("date"); + + b.Property("StatementCreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("StatementGeneratedDate") + .HasColumnType("date"); + + b.Property("StatementGeneratedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("StatementReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.HasKey("MerchantReportingId", "StatementId") + .HasAnnotation("SqlServer:Clustered", false); + + b.HasIndex("MerchantReportingId", "StatementGeneratedDate") + .HasAnnotation("SqlServer:Clustered", true); + + b.ToTable("statementheader"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.StatementLine", b => + { + b.Property("StatementReportingId") + .HasColumnType("int"); + + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.Property("ActivityDateTime") + .HasColumnType("datetime(6)"); + + b.Property("ActivityType") + .HasColumnType("int"); + + b.Property("ActivityDate") + .HasColumnType("date"); + + b.Property("ActivityDescription") + .HasColumnType("longtext"); + + b.Property("InAmount") + .HasColumnType("decimal(65,30)"); + + b.Property("OutAmount") + .HasColumnType("decimal(65,30)"); + + b.HasKey("StatementReportingId", "TransactionReportingId", "ActivityDateTime", "ActivityType"); + + b.ToTable("statementline"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Transaction", b => + { + b.Property("TransactionReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("AuthorisationCode") + .HasColumnType("longtext"); + + b.Property("ContractProductReportingId") + .HasColumnType("int"); + + b.Property("ContractReportingId") + .HasColumnType("int"); + + b.Property("DeviceIdentifier") + .HasColumnType("longtext"); + + b.Property("EstateOperatorReportingId") + .HasColumnType("int"); + + b.Property("IsAuthorised") + .HasColumnType("tinyint(1)"); + + b.Property("IsCompleted") + .HasColumnType("tinyint(1)"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("ResponseCode") + .HasColumnType("longtext"); + + b.Property("ResponseMessage") + .HasColumnType("longtext"); + + b.Property("TransactionAmount") + .HasColumnType("decimal(65,30)"); + + b.Property("TransactionDate") + .HasColumnType("date"); + + b.Property("TransactionDateTime") + .HasColumnType("datetime(6)"); + + b.Property("TransactionId") + .HasColumnType("char(36)"); + + b.Property("TransactionNumber") + .HasColumnType("longtext"); + + b.Property("TransactionReference") + .HasColumnType("longtext"); + + b.Property("TransactionSource") + .HasColumnType("int"); + + b.Property("TransactionTime") + .HasColumnType("time(6)"); + + b.Property("TransactionType") + .HasColumnType("longtext"); + + b.HasKey("TransactionReportingId") + .HasAnnotation("SqlServer:Clustered", false); + + b.HasIndex("TransactionId") + .IsUnique() + .HasAnnotation("SqlServer:Clustered", false); + + b.HasIndex("TransactionDate", "MerchantReportingId") + .HasAnnotation("SqlServer:Clustered", true); + + b.HasIndex("TransactionId", "MerchantReportingId") + .IsUnique() + .HasAnnotation("SqlServer:Clustered", false); + + b.ToTable("transaction"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.TransactionAdditionalRequestData", b => + { + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.Property("Amount") + .HasColumnType("longtext"); + + b.Property("CustomerAccountNumber") + .HasColumnType("longtext"); + + b.HasKey("TransactionReportingId"); + + b.ToTable("transactionadditionalrequestdata"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.TransactionAdditionalResponseData", b => + { + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.HasKey("TransactionReportingId"); + + b.ToTable("transactionadditionalresponsedata"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Voucher", b => + { + b.Property("VoucherId") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("ExpiryDate") + .HasColumnType("date"); + + b.Property("ExpiryDateTime") + .HasColumnType("datetime(6)"); + + b.Property("GenerateDate") + .HasColumnType("date"); + + b.Property("GenerateDateTime") + .HasColumnType("datetime(6)"); + + b.Property("IsGenerated") + .HasColumnType("tinyint(1)"); + + b.Property("IsIssued") + .HasColumnType("tinyint(1)"); + + b.Property("IsRedeemed") + .HasColumnType("tinyint(1)"); + + b.Property("IssuedDate") + .HasColumnType("date"); + + b.Property("IssuedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("OperatorIdentifier") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("RecipientEmail") + .HasColumnType("longtext"); + + b.Property("RecipientMobile") + .HasColumnType("longtext"); + + b.Property("RedeemedDate") + .HasColumnType("datetime(6)"); + + b.Property("RedeemedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.Property("Value") + .HasColumnType("decimal(65,30)"); + + b.Property("VoucherCode") + .IsRequired() + .HasColumnType("varchar(255)"); + + b.HasKey("VoucherId"); + + b.HasIndex("TransactionReportingId"); + + b.HasIndex("VoucherCode"); + + b.ToTable("voucher"); + }); + + modelBuilder.Entity("EstateManagement.Database.ViewEntities.SettlementView", b => + { + b.Property("Amount") + .HasColumnType("decimal(65,30)"); + + b.Property("CalculatedValue") + .HasColumnType("decimal(65,30)"); + + b.Property("DayOfWeek") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("EstateId") + .HasColumnType("char(36)"); + + b.Property("FeeDescription") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("IsCompleted") + .HasColumnType("tinyint(1)"); + + b.Property("IsSettled") + .HasColumnType("tinyint(1)"); + + b.Property("MerchantId") + .HasColumnType("char(36)"); + + b.Property("MerchantName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("Month") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("MonthNumber") + .HasColumnType("int"); + + b.Property("OperatorIdentifier") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("SettlementDate") + .HasColumnType("datetime(6)"); + + b.Property("SettlementId") + .HasColumnType("char(36)"); + + b.Property("TransactionId") + .HasColumnType("char(36)"); + + b.Property("WeekNumber") + .HasColumnType("int"); + + b.Property("YearNumber") + .HasColumnType("int"); + + b.ToTable((string)null); + + b.ToView("uvwSettlements", (string)null); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/TransactionProcessor.Database/Migrations/MySql/20240313172001_fixstatementheaderindex.cs b/TransactionProcessor.Database/Migrations/MySql/20240313172001_fixstatementheaderindex.cs new file mode 100644 index 00000000..9a5fe84a --- /dev/null +++ b/TransactionProcessor.Database/Migrations/MySql/20240313172001_fixstatementheaderindex.cs @@ -0,0 +1,37 @@ +#nullable disable + +using Microsoft.EntityFrameworkCore.Migrations; + +namespace TransactionProcessor.Database.Migrations.MySql +{ + /// + public partial class fixstatementheaderindex : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropIndex( + name: "IX_statementheader_MerchantReportingId_StatementGeneratedDate", + table: "statementheader"); + + migrationBuilder.CreateIndex( + name: "IX_statementheader_MerchantReportingId_StatementGeneratedDate", + table: "statementheader", + columns: new[] { "MerchantReportingId", "StatementGeneratedDate" }); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropIndex( + name: "IX_statementheader_MerchantReportingId_StatementGeneratedDate", + table: "statementheader"); + + migrationBuilder.CreateIndex( + name: "IX_statementheader_MerchantReportingId_StatementGeneratedDate", + table: "statementheader", + columns: new[] { "MerchantReportingId", "StatementGeneratedDate" }, + unique: true); + } + } +} diff --git a/TransactionProcessor.Database/Migrations/MySql/20240420163033_merchantupdates.Designer.cs b/TransactionProcessor.Database/Migrations/MySql/20240420163033_merchantupdates.Designer.cs new file mode 100644 index 00000000..bdc07839 --- /dev/null +++ b/TransactionProcessor.Database/Migrations/MySql/20240420163033_merchantupdates.Designer.cs @@ -0,0 +1,1095 @@ +// + +#nullable disable + +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using TransactionProcessor.Database.Contexts; + +namespace TransactionProcessor.Database.Migrations.MySql +{ + [DbContext(typeof(EstateManagementMySqlContext))] + [Migration("20240420163033_merchantupdates")] + partial class merchantupdates + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.3") + .HasAnnotation("Relational:MaxIdentifierLength", 64); + + MySqlModelBuilderExtensions.AutoIncrementColumns(modelBuilder); + + modelBuilder.Entity("EstateManagement.Database.Entities.Calendar", b => + { + b.Property("Date") + .HasColumnType("datetime(6)"); + + b.Property("DayOfWeek") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("DayOfWeekNumber") + .HasColumnType("int"); + + b.Property("DayOfWeekShort") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("MonthNameLong") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("MonthNameShort") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("MonthNumber") + .HasColumnType("int"); + + b.Property("WeekNumber") + .HasColumnType("int"); + + b.Property("WeekNumberString") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("Year") + .HasColumnType("int"); + + b.Property("YearWeekNumber") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("Date"); + + b.ToTable("calendar"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Contract", b => + { + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("OperatorId") + .HasColumnType("char(36)"); + + b.Property("ContractId") + .HasColumnType("char(36)"); + + b.Property("ContractReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("ContractReportingId")); + + b.Property("Description") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("EstateReportingId", "OperatorId", "ContractId"); + + b.ToTable("contract"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.ContractProduct", b => + { + b.Property("ContractReportingId") + .HasColumnType("int"); + + b.Property("ProductId") + .HasColumnType("char(36)"); + + b.Property("ContractProductReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("ContractProductReportingId")); + + b.Property("DisplayText") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ProductName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ProductType") + .HasColumnType("int"); + + b.Property("Value") + .HasColumnType("decimal(65,30)"); + + b.HasKey("ContractReportingId", "ProductId"); + + b.ToTable("contractproduct"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.ContractProductTransactionFee", b => + { + b.Property("ContractProductReportingId") + .HasColumnType("int"); + + b.Property("TransactionFeeId") + .HasColumnType("char(36)"); + + b.Property("CalculationType") + .HasColumnType("int"); + + b.Property("Description") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("FeeType") + .HasColumnType("int"); + + b.Property("IsEnabled") + .HasColumnType("tinyint(1)"); + + b.Property("TransactionFeeReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("TransactionFeeReportingId")); + + b.Property("Value") + .HasColumnType("decimal(18,4)"); + + b.HasKey("ContractProductReportingId", "TransactionFeeId"); + + b.ToTable("contractproducttransactionfee"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Estate", b => + { + b.Property("EstateReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("EstateReportingId")); + + b.Property("CreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("EstateId") + .HasColumnType("char(36)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("Reference") + .HasColumnType("longtext"); + + b.HasKey("EstateReportingId"); + + b.HasIndex("EstateId") + .IsUnique(); + + b.ToTable("estate"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.EstateOperator", b => + { + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("OperatorId") + .HasColumnType("char(36)"); + + b.Property("EstateOperatorReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("EstateOperatorReportingId")); + + b.Property("Name") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("RequireCustomMerchantNumber") + .HasColumnType("tinyint(1)"); + + b.Property("RequireCustomTerminalNumber") + .HasColumnType("tinyint(1)"); + + b.HasKey("EstateReportingId", "OperatorId"); + + b.ToTable("estateoperator"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.EstateSecurityUser", b => + { + b.Property("SecurityUserId") + .HasColumnType("char(36)"); + + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("EmailAddress") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("SecurityUserId", "EstateReportingId"); + + b.ToTable("estatesecurityuser"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.File", b => + { + b.Property("FileReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("FileReportingId")); + + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("FileId") + .HasColumnType("char(36)"); + + b.Property("FileImportLogReportingId") + .HasColumnType("int"); + + b.Property("FileLocation") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("FileProfileId") + .HasColumnType("char(36)"); + + b.Property("FileReceivedDate") + .HasColumnType("date"); + + b.Property("FileReceivedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("IsCompleted") + .HasColumnType("tinyint(1)"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("UserId") + .HasColumnType("char(36)"); + + b.HasKey("FileReportingId"); + + b.HasIndex("FileId") + .IsUnique(); + + b.ToTable("file"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.FileImportLog", b => + { + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("FileImportLogReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("FileImportLogReportingId")); + + b.Property("FileImportLogId") + .HasColumnType("char(36)"); + + b.Property("ImportLogDate") + .HasColumnType("date"); + + b.Property("ImportLogDateTime") + .HasColumnType("datetime(6)"); + + b.HasKey("EstateReportingId", "FileImportLogReportingId"); + + b.HasIndex("EstateReportingId", "FileImportLogId") + .IsUnique(); + + b.ToTable("fileimportlog"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.FileImportLogFile", b => + { + b.Property("FileImportLogReportingId") + .HasColumnType("int"); + + b.Property("FileReportingId") + .HasColumnType("int"); + + b.Property("FilePath") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("FileProfileId") + .HasColumnType("char(36)"); + + b.Property("FileUploadedDate") + .HasColumnType("date"); + + b.Property("FileUploadedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("OriginalFileName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("UserId") + .HasColumnType("char(36)"); + + b.HasKey("FileImportLogReportingId", "FileReportingId"); + + b.ToTable("fileimportlogfile"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.FileLine", b => + { + b.Property("FileReportingId") + .HasColumnType("int"); + + b.Property("LineNumber") + .HasColumnType("int"); + + b.Property("FileLineData") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("Status") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.HasKey("FileReportingId", "LineNumber") + .HasAnnotation("SqlServer:Clustered", true); + + b.HasIndex("TransactionReportingId"); + + b.ToTable("fileline"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Float", b => + { + b.Property("FloatId") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("ContractId") + .HasColumnType("char(36)"); + + b.Property("CreatedDate") + .HasColumnType("date"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("EstateId") + .HasColumnType("char(36)"); + + b.Property("ProductId") + .HasColumnType("char(36)"); + + b.HasKey("FloatId") + .HasAnnotation("SqlServer:Clustered", false); + + b.HasIndex("CreatedDate") + .HasAnnotation("SqlServer:Clustered", true); + + b.ToTable("Floats"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.FloatActivity", b => + { + b.Property("EventId") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("ActivityDate") + .HasColumnType("date"); + + b.Property("ActivityDateTime") + .HasColumnType("datetime(6)"); + + b.Property("Amount") + .HasColumnType("decimal(65,30)"); + + b.Property("CostPrice") + .HasColumnType("decimal(65,30)"); + + b.Property("CreditOrDebit") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("FloatId") + .HasColumnType("char(36)"); + + b.HasKey("EventId") + .HasAnnotation("SqlServer:Clustered", false); + + b.HasIndex("ActivityDate") + .HasAnnotation("SqlServer:Clustered", true); + + b.ToTable("FloatActivity"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Merchant", b => + { + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("MerchantReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("MerchantReportingId")); + + b.Property("CreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("LastSaleDate") + .HasColumnType("date"); + + b.Property("LastSaleDateTime") + .HasColumnType("datetime(6)"); + + b.Property("LastStatementGenerated") + .HasColumnType("datetime(6)"); + + b.Property("MerchantId") + .HasColumnType("char(36)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("Reference") + .HasColumnType("longtext"); + + b.Property("SettlementSchedule") + .HasColumnType("int"); + + b.HasKey("EstateReportingId", "MerchantReportingId"); + + b.HasIndex("EstateReportingId", "MerchantId") + .IsUnique(); + + b.ToTable("merchant"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantAddress", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("AddressId") + .HasColumnType("char(36)"); + + b.Property("AddressLine1") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("AddressLine2") + .HasColumnType("longtext"); + + b.Property("AddressLine3") + .HasColumnType("longtext"); + + b.Property("AddressLine4") + .HasColumnType("longtext"); + + b.Property("Country") + .HasColumnType("longtext"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("PostalCode") + .HasColumnType("longtext"); + + b.Property("Region") + .HasColumnType("longtext"); + + b.Property("Town") + .HasColumnType("longtext"); + + b.HasKey("MerchantReportingId", "AddressId"); + + b.ToTable("merchantaddress"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantContact", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("ContactId") + .HasColumnType("char(36)"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("EmailAddress") + .HasColumnType("longtext"); + + b.Property("Name") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("PhoneNumber") + .HasColumnType("longtext"); + + b.HasKey("MerchantReportingId", "ContactId"); + + b.ToTable("merchantcontact"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantContract", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("ContractReportingId") + .HasColumnType("int"); + + b.Property("IsDeleted") + .HasColumnType("tinyint(1)"); + + b.HasKey("MerchantReportingId", "ContractReportingId"); + + b.ToTable("MerchantContracts"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantDevice", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("DeviceId") + .HasColumnType("char(36)"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("DeviceIdentifier") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("MerchantReportingId", "DeviceId"); + + b.ToTable("merchantdevice"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantOperator", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("OperatorId") + .HasColumnType("char(36)"); + + b.Property("IsDeleted") + .HasColumnType("tinyint(1)"); + + b.Property("MerchantNumber") + .HasColumnType("longtext"); + + b.Property("Name") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("TerminalNumber") + .HasColumnType("longtext"); + + b.HasKey("MerchantReportingId", "OperatorId"); + + b.ToTable("merchantoperator"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantSecurityUser", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("SecurityUserId") + .HasColumnType("char(36)"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("EmailAddress") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("MerchantReportingId", "SecurityUserId"); + + b.ToTable("merchantsecurityuser"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantSettlementFee", b => + { + b.Property("SettlementReportingId") + .HasColumnType("int"); + + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.Property("TransactionFeeReportingId") + .HasColumnType("int"); + + b.Property("CalculatedValue") + .HasColumnType("decimal(65,30)"); + + b.Property("FeeCalculatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("FeeValue") + .HasColumnType("decimal(65,30)"); + + b.Property("IsSettled") + .HasColumnType("tinyint(1)"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.HasKey("SettlementReportingId", "TransactionReportingId", "TransactionFeeReportingId"); + + b.HasIndex("TransactionReportingId"); + + b.ToTable("merchantsettlementfee"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Reconciliation", b => + { + b.Property("TransactionReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("TransactionReportingId")); + + b.Property("DeviceIdentifier") + .HasColumnType("longtext"); + + b.Property("IsAuthorised") + .HasColumnType("tinyint(1)"); + + b.Property("IsCompleted") + .HasColumnType("tinyint(1)"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("ResponseCode") + .HasColumnType("longtext"); + + b.Property("ResponseMessage") + .HasColumnType("longtext"); + + b.Property("TransactionCount") + .HasColumnType("int"); + + b.Property("TransactionDate") + .HasColumnType("date"); + + b.Property("TransactionDateTime") + .HasColumnType("datetime(6)"); + + b.Property("TransactionId") + .HasColumnType("char(36)"); + + b.Property("TransactionTime") + .HasColumnType("time(6)"); + + b.Property("TransactionValue") + .HasColumnType("decimal(65,30)"); + + b.HasKey("TransactionReportingId") + .HasAnnotation("SqlServer:Clustered", false); + + b.HasIndex("TransactionDate", "MerchantReportingId") + .HasAnnotation("SqlServer:Clustered", true); + + b.HasIndex("TransactionId", "MerchantReportingId") + .IsUnique() + .HasAnnotation("SqlServer:Clustered", false); + + b.ToTable("reconciliation"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.ResponseCodes", b => + { + b.Property("ResponseCode") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("ResponseCode")); + + b.Property("Description") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("ResponseCode"); + + b.ToTable("responsecodes"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Settlement", b => + { + b.Property("SettlementReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("SettlementReportingId")); + + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("IsCompleted") + .HasColumnType("tinyint(1)"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("ProcessingStarted") + .HasColumnType("tinyint(1)"); + + b.Property("ProcessingStartedDateTIme") + .HasColumnType("datetime(6)"); + + b.Property("SettlementDate") + .HasColumnType("date"); + + b.Property("SettlementId") + .HasColumnType("char(36)"); + + b.HasKey("SettlementReportingId") + .HasAnnotation("SqlServer:Clustered", false); + + b.HasIndex("EstateReportingId", "SettlementId") + .IsUnique() + .HasAnnotation("SqlServer:Clustered", false); + + b.HasIndex("SettlementDate", "EstateReportingId") + .HasAnnotation("SqlServer:Clustered", true); + + b.ToTable("settlement"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.StatementHeader", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("StatementId") + .HasColumnType("char(36)"); + + b.Property("StatementCreatedDate") + .HasColumnType("date"); + + b.Property("StatementCreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("StatementGeneratedDate") + .HasColumnType("date"); + + b.Property("StatementGeneratedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("StatementReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("StatementReportingId")); + + b.HasKey("MerchantReportingId", "StatementId") + .HasAnnotation("SqlServer:Clustered", false); + + b.HasIndex("MerchantReportingId", "StatementGeneratedDate") + .HasAnnotation("SqlServer:Clustered", true); + + b.ToTable("statementheader"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.StatementLine", b => + { + b.Property("StatementReportingId") + .HasColumnType("int"); + + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.Property("ActivityDateTime") + .HasColumnType("datetime(6)"); + + b.Property("ActivityType") + .HasColumnType("int"); + + b.Property("ActivityDate") + .HasColumnType("date"); + + b.Property("ActivityDescription") + .HasColumnType("longtext"); + + b.Property("InAmount") + .HasColumnType("decimal(65,30)"); + + b.Property("OutAmount") + .HasColumnType("decimal(65,30)"); + + b.HasKey("StatementReportingId", "TransactionReportingId", "ActivityDateTime", "ActivityType"); + + b.ToTable("statementline"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Transaction", b => + { + b.Property("TransactionReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("TransactionReportingId")); + + b.Property("AuthorisationCode") + .HasColumnType("longtext"); + + b.Property("ContractProductReportingId") + .HasColumnType("int"); + + b.Property("ContractReportingId") + .HasColumnType("int"); + + b.Property("DeviceIdentifier") + .HasColumnType("longtext"); + + b.Property("EstateOperatorReportingId") + .HasColumnType("int"); + + b.Property("IsAuthorised") + .HasColumnType("tinyint(1)"); + + b.Property("IsCompleted") + .HasColumnType("tinyint(1)"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("ResponseCode") + .HasColumnType("longtext"); + + b.Property("ResponseMessage") + .HasColumnType("longtext"); + + b.Property("TransactionAmount") + .HasColumnType("decimal(65,30)"); + + b.Property("TransactionDate") + .HasColumnType("date"); + + b.Property("TransactionDateTime") + .HasColumnType("datetime(6)"); + + b.Property("TransactionId") + .HasColumnType("char(36)"); + + b.Property("TransactionNumber") + .HasColumnType("longtext"); + + b.Property("TransactionReference") + .HasColumnType("longtext"); + + b.Property("TransactionSource") + .HasColumnType("int"); + + b.Property("TransactionTime") + .HasColumnType("time(6)"); + + b.Property("TransactionType") + .HasColumnType("longtext"); + + b.HasKey("TransactionReportingId") + .HasAnnotation("SqlServer:Clustered", false); + + b.HasIndex("TransactionId") + .IsUnique() + .HasAnnotation("SqlServer:Clustered", false); + + b.HasIndex("TransactionDate", "MerchantReportingId") + .HasAnnotation("SqlServer:Clustered", true); + + b.HasIndex("TransactionId", "MerchantReportingId") + .IsUnique() + .HasAnnotation("SqlServer:Clustered", false); + + b.ToTable("transaction"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.TransactionAdditionalRequestData", b => + { + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.Property("Amount") + .HasColumnType("longtext"); + + b.Property("CustomerAccountNumber") + .HasColumnType("longtext"); + + b.HasKey("TransactionReportingId"); + + b.ToTable("transactionadditionalrequestdata"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.TransactionAdditionalResponseData", b => + { + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.HasKey("TransactionReportingId"); + + b.ToTable("transactionadditionalresponsedata"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Voucher", b => + { + b.Property("VoucherId") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("ExpiryDate") + .HasColumnType("date"); + + b.Property("ExpiryDateTime") + .HasColumnType("datetime(6)"); + + b.Property("GenerateDate") + .HasColumnType("date"); + + b.Property("GenerateDateTime") + .HasColumnType("datetime(6)"); + + b.Property("IsGenerated") + .HasColumnType("tinyint(1)"); + + b.Property("IsIssued") + .HasColumnType("tinyint(1)"); + + b.Property("IsRedeemed") + .HasColumnType("tinyint(1)"); + + b.Property("IssuedDate") + .HasColumnType("date"); + + b.Property("IssuedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("OperatorIdentifier") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("RecipientEmail") + .HasColumnType("longtext"); + + b.Property("RecipientMobile") + .HasColumnType("longtext"); + + b.Property("RedeemedDate") + .HasColumnType("datetime(6)"); + + b.Property("RedeemedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.Property("Value") + .HasColumnType("decimal(65,30)"); + + b.Property("VoucherCode") + .IsRequired() + .HasColumnType("varchar(255)"); + + b.HasKey("VoucherId"); + + b.HasIndex("TransactionReportingId"); + + b.HasIndex("VoucherCode"); + + b.ToTable("voucher"); + }); + + modelBuilder.Entity("EstateManagement.Database.ViewEntities.SettlementView", b => + { + b.Property("Amount") + .HasColumnType("decimal(65,30)"); + + b.Property("CalculatedValue") + .HasColumnType("decimal(65,30)"); + + b.Property("DayOfWeek") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("EstateId") + .HasColumnType("char(36)"); + + b.Property("FeeDescription") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("IsCompleted") + .HasColumnType("tinyint(1)"); + + b.Property("IsSettled") + .HasColumnType("tinyint(1)"); + + b.Property("MerchantId") + .HasColumnType("char(36)"); + + b.Property("MerchantName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("Month") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("MonthNumber") + .HasColumnType("int"); + + b.Property("OperatorIdentifier") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("SettlementDate") + .HasColumnType("datetime(6)"); + + b.Property("SettlementId") + .HasColumnType("char(36)"); + + b.Property("TransactionId") + .HasColumnType("char(36)"); + + b.Property("WeekNumber") + .HasColumnType("int"); + + b.Property("YearNumber") + .HasColumnType("int"); + + b.ToTable((string)null); + + b.ToView("uvwSettlements", (string)null); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/TransactionProcessor.Database/Migrations/MySql/20240420163033_merchantupdates.cs b/TransactionProcessor.Database/Migrations/MySql/20240420163033_merchantupdates.cs new file mode 100644 index 00000000..eff72764 --- /dev/null +++ b/TransactionProcessor.Database/Migrations/MySql/20240420163033_merchantupdates.cs @@ -0,0 +1,275 @@ +#nullable disable + +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; + +namespace TransactionProcessor.Database.Migrations.MySql +{ + /// + public partial class merchantupdates : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterColumn( + name: "TransactionReportingId", + table: "transaction", + type: "int", + nullable: false, + oldClrType: typeof(int), + oldType: "int") + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn); + + migrationBuilder.AlterColumn( + name: "StatementReportingId", + table: "statementheader", + type: "int", + nullable: false, + oldClrType: typeof(int), + oldType: "int") + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn); + + migrationBuilder.AlterColumn( + name: "SettlementReportingId", + table: "settlement", + type: "int", + nullable: false, + oldClrType: typeof(int), + oldType: "int") + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn); + + migrationBuilder.AlterColumn( + name: "ResponseCode", + table: "responsecodes", + type: "int", + nullable: false, + oldClrType: typeof(int), + oldType: "int") + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn); + + migrationBuilder.AlterColumn( + name: "TransactionReportingId", + table: "reconciliation", + type: "int", + nullable: false, + oldClrType: typeof(int), + oldType: "int") + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn); + + migrationBuilder.AddColumn( + name: "IsDeleted", + table: "merchantoperator", + type: "tinyint(1)", + nullable: false, + defaultValue: false); + + migrationBuilder.AddColumn( + name: "IsDeleted", + table: "MerchantContracts", + type: "tinyint(1)", + nullable: false, + defaultValue: false); + + migrationBuilder.AlterColumn( + name: "MerchantReportingId", + table: "merchant", + type: "int", + nullable: false, + oldClrType: typeof(int), + oldType: "int") + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn); + + migrationBuilder.AlterColumn( + name: "FileImportLogReportingId", + table: "fileimportlog", + type: "int", + nullable: false, + oldClrType: typeof(int), + oldType: "int") + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn); + + migrationBuilder.AlterColumn( + name: "FileReportingId", + table: "file", + type: "int", + nullable: false, + oldClrType: typeof(int), + oldType: "int") + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn); + + migrationBuilder.AlterColumn( + name: "EstateOperatorReportingId", + table: "estateoperator", + type: "int", + nullable: false, + oldClrType: typeof(int), + oldType: "int") + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn); + + migrationBuilder.AlterColumn( + name: "EstateReportingId", + table: "estate", + type: "int", + nullable: false, + oldClrType: typeof(int), + oldType: "int") + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn); + + migrationBuilder.AlterColumn( + name: "TransactionFeeReportingId", + table: "contractproducttransactionfee", + type: "int", + nullable: false, + oldClrType: typeof(int), + oldType: "int") + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn); + + migrationBuilder.AlterColumn( + name: "ContractProductReportingId", + table: "contractproduct", + type: "int", + nullable: false, + oldClrType: typeof(int), + oldType: "int") + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn); + + migrationBuilder.AlterColumn( + name: "ContractReportingId", + table: "contract", + type: "int", + nullable: false, + oldClrType: typeof(int), + oldType: "int") + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "IsDeleted", + table: "merchantoperator"); + + migrationBuilder.DropColumn( + name: "IsDeleted", + table: "MerchantContracts"); + + migrationBuilder.AlterColumn( + name: "TransactionReportingId", + table: "transaction", + type: "int", + nullable: false, + oldClrType: typeof(int), + oldType: "int") + .OldAnnotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn); + + migrationBuilder.AlterColumn( + name: "StatementReportingId", + table: "statementheader", + type: "int", + nullable: false, + oldClrType: typeof(int), + oldType: "int") + .OldAnnotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn); + + migrationBuilder.AlterColumn( + name: "SettlementReportingId", + table: "settlement", + type: "int", + nullable: false, + oldClrType: typeof(int), + oldType: "int") + .OldAnnotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn); + + migrationBuilder.AlterColumn( + name: "ResponseCode", + table: "responsecodes", + type: "int", + nullable: false, + oldClrType: typeof(int), + oldType: "int") + .OldAnnotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn); + + migrationBuilder.AlterColumn( + name: "TransactionReportingId", + table: "reconciliation", + type: "int", + nullable: false, + oldClrType: typeof(int), + oldType: "int") + .OldAnnotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn); + + migrationBuilder.AlterColumn( + name: "MerchantReportingId", + table: "merchant", + type: "int", + nullable: false, + oldClrType: typeof(int), + oldType: "int") + .OldAnnotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn); + + migrationBuilder.AlterColumn( + name: "FileImportLogReportingId", + table: "fileimportlog", + type: "int", + nullable: false, + oldClrType: typeof(int), + oldType: "int") + .OldAnnotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn); + + migrationBuilder.AlterColumn( + name: "FileReportingId", + table: "file", + type: "int", + nullable: false, + oldClrType: typeof(int), + oldType: "int") + .OldAnnotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn); + + migrationBuilder.AlterColumn( + name: "EstateOperatorReportingId", + table: "estateoperator", + type: "int", + nullable: false, + oldClrType: typeof(int), + oldType: "int") + .OldAnnotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn); + + migrationBuilder.AlterColumn( + name: "EstateReportingId", + table: "estate", + type: "int", + nullable: false, + oldClrType: typeof(int), + oldType: "int") + .OldAnnotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn); + + migrationBuilder.AlterColumn( + name: "TransactionFeeReportingId", + table: "contractproducttransactionfee", + type: "int", + nullable: false, + oldClrType: typeof(int), + oldType: "int") + .OldAnnotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn); + + migrationBuilder.AlterColumn( + name: "ContractProductReportingId", + table: "contractproduct", + type: "int", + nullable: false, + oldClrType: typeof(int), + oldType: "int") + .OldAnnotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn); + + migrationBuilder.AlterColumn( + name: "ContractReportingId", + table: "contract", + type: "int", + nullable: false, + oldClrType: typeof(int), + oldType: "int") + .OldAnnotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn); + } + } +} diff --git a/TransactionProcessor.Database/Migrations/MySql/20240425094256_record_operatators_at_readmodel.Designer.cs b/TransactionProcessor.Database/Migrations/MySql/20240425094256_record_operatators_at_readmodel.Designer.cs new file mode 100644 index 00000000..0c591c6f --- /dev/null +++ b/TransactionProcessor.Database/Migrations/MySql/20240425094256_record_operatators_at_readmodel.Designer.cs @@ -0,0 +1,1112 @@ +// + +#nullable disable + +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using TransactionProcessor.Database.Contexts; + +namespace TransactionProcessor.Database.Migrations.MySql +{ + [DbContext(typeof(EstateManagementMySqlContext))] + [Migration("20240425094256_record_operatators_at_readmodel")] + partial class record_operatators_at_readmodel + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.3") + .HasAnnotation("Relational:MaxIdentifierLength", 64); + + MySqlModelBuilderExtensions.AutoIncrementColumns(modelBuilder); + + modelBuilder.Entity("EstateManagement.Database.Entities.Calendar", b => + { + b.Property("Date") + .HasColumnType("datetime(6)"); + + b.Property("DayOfWeek") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("DayOfWeekNumber") + .HasColumnType("int"); + + b.Property("DayOfWeekShort") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("MonthNameLong") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("MonthNameShort") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("MonthNumber") + .HasColumnType("int"); + + b.Property("WeekNumber") + .HasColumnType("int"); + + b.Property("WeekNumberString") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("Year") + .HasColumnType("int"); + + b.Property("YearWeekNumber") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("Date"); + + b.ToTable("calendar"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Contract", b => + { + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("OperatorId") + .HasColumnType("char(36)"); + + b.Property("ContractId") + .HasColumnType("char(36)"); + + b.Property("ContractReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("ContractReportingId")); + + b.Property("Description") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("EstateReportingId", "OperatorId", "ContractId"); + + b.ToTable("contract"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.ContractProduct", b => + { + b.Property("ContractReportingId") + .HasColumnType("int"); + + b.Property("ProductId") + .HasColumnType("char(36)"); + + b.Property("ContractProductReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("ContractProductReportingId")); + + b.Property("DisplayText") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ProductName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ProductType") + .HasColumnType("int"); + + b.Property("Value") + .HasColumnType("decimal(65,30)"); + + b.HasKey("ContractReportingId", "ProductId"); + + b.ToTable("contractproduct"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.ContractProductTransactionFee", b => + { + b.Property("ContractProductReportingId") + .HasColumnType("int"); + + b.Property("TransactionFeeId") + .HasColumnType("char(36)"); + + b.Property("CalculationType") + .HasColumnType("int"); + + b.Property("Description") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("FeeType") + .HasColumnType("int"); + + b.Property("IsEnabled") + .HasColumnType("tinyint(1)"); + + b.Property("TransactionFeeReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("TransactionFeeReportingId")); + + b.Property("Value") + .HasColumnType("decimal(18,4)"); + + b.HasKey("ContractProductReportingId", "TransactionFeeId"); + + b.ToTable("contractproducttransactionfee"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Estate", b => + { + b.Property("EstateReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("EstateReportingId")); + + b.Property("CreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("EstateId") + .HasColumnType("char(36)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("Reference") + .HasColumnType("longtext"); + + b.HasKey("EstateReportingId"); + + b.HasIndex("EstateId") + .IsUnique(); + + b.ToTable("estate"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.EstateOperator", b => + { + b.Property("OperatorReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("OperatorReportingId")); + + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.HasKey("OperatorReportingId"); + + b.ToTable("estateoperator"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.EstateSecurityUser", b => + { + b.Property("SecurityUserId") + .HasColumnType("char(36)"); + + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("EmailAddress") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("SecurityUserId", "EstateReportingId"); + + b.ToTable("estatesecurityuser"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.File", b => + { + b.Property("FileReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("FileReportingId")); + + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("FileId") + .HasColumnType("char(36)"); + + b.Property("FileImportLogReportingId") + .HasColumnType("int"); + + b.Property("FileLocation") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("FileProfileId") + .HasColumnType("char(36)"); + + b.Property("FileReceivedDate") + .HasColumnType("date"); + + b.Property("FileReceivedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("IsCompleted") + .HasColumnType("tinyint(1)"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("UserId") + .HasColumnType("char(36)"); + + b.HasKey("FileReportingId"); + + b.HasIndex("FileId") + .IsUnique(); + + b.ToTable("file"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.FileImportLog", b => + { + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("FileImportLogReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("FileImportLogReportingId")); + + b.Property("FileImportLogId") + .HasColumnType("char(36)"); + + b.Property("ImportLogDate") + .HasColumnType("date"); + + b.Property("ImportLogDateTime") + .HasColumnType("datetime(6)"); + + b.HasKey("EstateReportingId", "FileImportLogReportingId"); + + b.HasIndex("EstateReportingId", "FileImportLogId") + .IsUnique(); + + b.ToTable("fileimportlog"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.FileImportLogFile", b => + { + b.Property("FileImportLogReportingId") + .HasColumnType("int"); + + b.Property("FileReportingId") + .HasColumnType("int"); + + b.Property("FilePath") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("FileProfileId") + .HasColumnType("char(36)"); + + b.Property("FileUploadedDate") + .HasColumnType("date"); + + b.Property("FileUploadedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("OriginalFileName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("UserId") + .HasColumnType("char(36)"); + + b.HasKey("FileImportLogReportingId", "FileReportingId"); + + b.ToTable("fileimportlogfile"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.FileLine", b => + { + b.Property("FileReportingId") + .HasColumnType("int"); + + b.Property("LineNumber") + .HasColumnType("int"); + + b.Property("FileLineData") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("Status") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.HasKey("FileReportingId", "LineNumber") + .HasAnnotation("SqlServer:Clustered", true); + + b.HasIndex("TransactionReportingId"); + + b.ToTable("fileline"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Float", b => + { + b.Property("FloatId") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("ContractId") + .HasColumnType("char(36)"); + + b.Property("CreatedDate") + .HasColumnType("date"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("EstateId") + .HasColumnType("char(36)"); + + b.Property("ProductId") + .HasColumnType("char(36)"); + + b.HasKey("FloatId") + .HasAnnotation("SqlServer:Clustered", false); + + b.HasIndex("CreatedDate") + .HasAnnotation("SqlServer:Clustered", true); + + b.ToTable("Floats"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.FloatActivity", b => + { + b.Property("EventId") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("ActivityDate") + .HasColumnType("date"); + + b.Property("ActivityDateTime") + .HasColumnType("datetime(6)"); + + b.Property("Amount") + .HasColumnType("decimal(65,30)"); + + b.Property("CostPrice") + .HasColumnType("decimal(65,30)"); + + b.Property("CreditOrDebit") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("FloatId") + .HasColumnType("char(36)"); + + b.HasKey("EventId") + .HasAnnotation("SqlServer:Clustered", false); + + b.HasIndex("ActivityDate") + .HasAnnotation("SqlServer:Clustered", true); + + b.ToTable("FloatActivity"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Merchant", b => + { + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("MerchantReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("MerchantReportingId")); + + b.Property("CreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("LastSaleDate") + .HasColumnType("date"); + + b.Property("LastSaleDateTime") + .HasColumnType("datetime(6)"); + + b.Property("LastStatementGenerated") + .HasColumnType("datetime(6)"); + + b.Property("MerchantId") + .HasColumnType("char(36)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("Reference") + .HasColumnType("longtext"); + + b.Property("SettlementSchedule") + .HasColumnType("int"); + + b.HasKey("EstateReportingId", "MerchantReportingId"); + + b.HasIndex("EstateReportingId", "MerchantId") + .IsUnique(); + + b.ToTable("merchant"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantAddress", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("AddressId") + .HasColumnType("char(36)"); + + b.Property("AddressLine1") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("AddressLine2") + .HasColumnType("longtext"); + + b.Property("AddressLine3") + .HasColumnType("longtext"); + + b.Property("AddressLine4") + .HasColumnType("longtext"); + + b.Property("Country") + .HasColumnType("longtext"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("PostalCode") + .HasColumnType("longtext"); + + b.Property("Region") + .HasColumnType("longtext"); + + b.Property("Town") + .HasColumnType("longtext"); + + b.HasKey("MerchantReportingId", "AddressId"); + + b.ToTable("merchantaddress"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantContact", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("ContactId") + .HasColumnType("char(36)"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("EmailAddress") + .HasColumnType("longtext"); + + b.Property("Name") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("PhoneNumber") + .HasColumnType("longtext"); + + b.HasKey("MerchantReportingId", "ContactId"); + + b.ToTable("merchantcontact"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantContract", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("ContractReportingId") + .HasColumnType("int"); + + b.Property("IsDeleted") + .HasColumnType("tinyint(1)"); + + b.HasKey("MerchantReportingId", "ContractReportingId"); + + b.ToTable("MerchantContracts"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantDevice", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("DeviceId") + .HasColumnType("char(36)"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("DeviceIdentifier") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("MerchantReportingId", "DeviceId"); + + b.ToTable("merchantdevice"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantOperator", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("OperatorId") + .HasColumnType("char(36)"); + + b.Property("IsDeleted") + .HasColumnType("tinyint(1)"); + + b.Property("MerchantNumber") + .HasColumnType("longtext"); + + b.Property("Name") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("TerminalNumber") + .HasColumnType("longtext"); + + b.HasKey("MerchantReportingId", "OperatorId"); + + b.ToTable("merchantoperator"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantSecurityUser", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("SecurityUserId") + .HasColumnType("char(36)"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("EmailAddress") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("MerchantReportingId", "SecurityUserId"); + + b.ToTable("merchantsecurityuser"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantSettlementFee", b => + { + b.Property("SettlementReportingId") + .HasColumnType("int"); + + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.Property("TransactionFeeReportingId") + .HasColumnType("int"); + + b.Property("CalculatedValue") + .HasColumnType("decimal(65,30)"); + + b.Property("FeeCalculatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("FeeValue") + .HasColumnType("decimal(65,30)"); + + b.Property("IsSettled") + .HasColumnType("tinyint(1)"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.HasKey("SettlementReportingId", "TransactionReportingId", "TransactionFeeReportingId"); + + b.HasIndex("TransactionReportingId"); + + b.ToTable("merchantsettlementfee"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Operator", b => + { + b.Property("OperatorId") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("Name") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("OperatorReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("OperatorReportingId")); + + b.Property("RequireCustomMerchantNumber") + .HasColumnType("tinyint(1)"); + + b.Property("RequireCustomTerminalNumber") + .HasColumnType("tinyint(1)"); + + b.HasKey("OperatorId"); + + b.ToTable("operator"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Reconciliation", b => + { + b.Property("TransactionReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("TransactionReportingId")); + + b.Property("DeviceIdentifier") + .HasColumnType("longtext"); + + b.Property("IsAuthorised") + .HasColumnType("tinyint(1)"); + + b.Property("IsCompleted") + .HasColumnType("tinyint(1)"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("ResponseCode") + .HasColumnType("longtext"); + + b.Property("ResponseMessage") + .HasColumnType("longtext"); + + b.Property("TransactionCount") + .HasColumnType("int"); + + b.Property("TransactionDate") + .HasColumnType("date"); + + b.Property("TransactionDateTime") + .HasColumnType("datetime(6)"); + + b.Property("TransactionId") + .HasColumnType("char(36)"); + + b.Property("TransactionTime") + .HasColumnType("time(6)"); + + b.Property("TransactionValue") + .HasColumnType("decimal(65,30)"); + + b.HasKey("TransactionReportingId") + .HasAnnotation("SqlServer:Clustered", false); + + b.HasIndex("TransactionDate", "MerchantReportingId") + .HasAnnotation("SqlServer:Clustered", true); + + b.HasIndex("TransactionId", "MerchantReportingId") + .IsUnique() + .HasAnnotation("SqlServer:Clustered", false); + + b.ToTable("reconciliation"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.ResponseCodes", b => + { + b.Property("ResponseCode") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("ResponseCode")); + + b.Property("Description") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("ResponseCode"); + + b.ToTable("responsecodes"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Settlement", b => + { + b.Property("SettlementReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("SettlementReportingId")); + + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("IsCompleted") + .HasColumnType("tinyint(1)"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("ProcessingStarted") + .HasColumnType("tinyint(1)"); + + b.Property("ProcessingStartedDateTIme") + .HasColumnType("datetime(6)"); + + b.Property("SettlementDate") + .HasColumnType("date"); + + b.Property("SettlementId") + .HasColumnType("char(36)"); + + b.HasKey("SettlementReportingId") + .HasAnnotation("SqlServer:Clustered", false); + + b.HasIndex("EstateReportingId", "SettlementId") + .IsUnique() + .HasAnnotation("SqlServer:Clustered", false); + + b.HasIndex("SettlementDate", "EstateReportingId") + .HasAnnotation("SqlServer:Clustered", true); + + b.ToTable("settlement"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.StatementHeader", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("StatementId") + .HasColumnType("char(36)"); + + b.Property("StatementCreatedDate") + .HasColumnType("date"); + + b.Property("StatementCreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("StatementGeneratedDate") + .HasColumnType("date"); + + b.Property("StatementGeneratedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("StatementReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("StatementReportingId")); + + b.HasKey("MerchantReportingId", "StatementId") + .HasAnnotation("SqlServer:Clustered", false); + + b.HasIndex("MerchantReportingId", "StatementGeneratedDate") + .HasAnnotation("SqlServer:Clustered", true); + + b.ToTable("statementheader"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.StatementLine", b => + { + b.Property("StatementReportingId") + .HasColumnType("int"); + + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.Property("ActivityDateTime") + .HasColumnType("datetime(6)"); + + b.Property("ActivityType") + .HasColumnType("int"); + + b.Property("ActivityDate") + .HasColumnType("date"); + + b.Property("ActivityDescription") + .HasColumnType("longtext"); + + b.Property("InAmount") + .HasColumnType("decimal(65,30)"); + + b.Property("OutAmount") + .HasColumnType("decimal(65,30)"); + + b.HasKey("StatementReportingId", "TransactionReportingId", "ActivityDateTime", "ActivityType"); + + b.ToTable("statementline"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Transaction", b => + { + b.Property("TransactionReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("TransactionReportingId")); + + b.Property("AuthorisationCode") + .HasColumnType("longtext"); + + b.Property("ContractProductReportingId") + .HasColumnType("int"); + + b.Property("ContractReportingId") + .HasColumnType("int"); + + b.Property("DeviceIdentifier") + .HasColumnType("longtext"); + + b.Property("EstateOperatorReportingId") + .HasColumnType("int"); + + b.Property("IsAuthorised") + .HasColumnType("tinyint(1)"); + + b.Property("IsCompleted") + .HasColumnType("tinyint(1)"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("ResponseCode") + .HasColumnType("longtext"); + + b.Property("ResponseMessage") + .HasColumnType("longtext"); + + b.Property("TransactionAmount") + .HasColumnType("decimal(65,30)"); + + b.Property("TransactionDate") + .HasColumnType("date"); + + b.Property("TransactionDateTime") + .HasColumnType("datetime(6)"); + + b.Property("TransactionId") + .HasColumnType("char(36)"); + + b.Property("TransactionNumber") + .HasColumnType("longtext"); + + b.Property("TransactionReference") + .HasColumnType("longtext"); + + b.Property("TransactionSource") + .HasColumnType("int"); + + b.Property("TransactionTime") + .HasColumnType("time(6)"); + + b.Property("TransactionType") + .HasColumnType("longtext"); + + b.HasKey("TransactionReportingId") + .HasAnnotation("SqlServer:Clustered", false); + + b.HasIndex("TransactionId") + .IsUnique() + .HasAnnotation("SqlServer:Clustered", false); + + b.HasIndex("TransactionDate", "MerchantReportingId") + .HasAnnotation("SqlServer:Clustered", true); + + b.HasIndex("TransactionId", "MerchantReportingId") + .IsUnique() + .HasAnnotation("SqlServer:Clustered", false); + + b.ToTable("transaction"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.TransactionAdditionalRequestData", b => + { + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.Property("Amount") + .HasColumnType("longtext"); + + b.Property("CustomerAccountNumber") + .HasColumnType("longtext"); + + b.HasKey("TransactionReportingId"); + + b.ToTable("transactionadditionalrequestdata"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.TransactionAdditionalResponseData", b => + { + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.HasKey("TransactionReportingId"); + + b.ToTable("transactionadditionalresponsedata"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Voucher", b => + { + b.Property("VoucherId") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("ExpiryDate") + .HasColumnType("date"); + + b.Property("ExpiryDateTime") + .HasColumnType("datetime(6)"); + + b.Property("GenerateDate") + .HasColumnType("date"); + + b.Property("GenerateDateTime") + .HasColumnType("datetime(6)"); + + b.Property("IsGenerated") + .HasColumnType("tinyint(1)"); + + b.Property("IsIssued") + .HasColumnType("tinyint(1)"); + + b.Property("IsRedeemed") + .HasColumnType("tinyint(1)"); + + b.Property("IssuedDate") + .HasColumnType("date"); + + b.Property("IssuedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("OperatorIdentifier") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("RecipientEmail") + .HasColumnType("longtext"); + + b.Property("RecipientMobile") + .HasColumnType("longtext"); + + b.Property("RedeemedDate") + .HasColumnType("datetime(6)"); + + b.Property("RedeemedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.Property("Value") + .HasColumnType("decimal(65,30)"); + + b.Property("VoucherCode") + .IsRequired() + .HasColumnType("varchar(255)"); + + b.HasKey("VoucherId"); + + b.HasIndex("TransactionReportingId"); + + b.HasIndex("VoucherCode"); + + b.ToTable("voucher"); + }); + + modelBuilder.Entity("EstateManagement.Database.ViewEntities.SettlementView", b => + { + b.Property("Amount") + .HasColumnType("decimal(65,30)"); + + b.Property("CalculatedValue") + .HasColumnType("decimal(65,30)"); + + b.Property("DayOfWeek") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("EstateId") + .HasColumnType("char(36)"); + + b.Property("FeeDescription") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("IsCompleted") + .HasColumnType("tinyint(1)"); + + b.Property("IsSettled") + .HasColumnType("tinyint(1)"); + + b.Property("MerchantId") + .HasColumnType("char(36)"); + + b.Property("MerchantName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("Month") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("MonthNumber") + .HasColumnType("int"); + + b.Property("OperatorIdentifier") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("SettlementDate") + .HasColumnType("datetime(6)"); + + b.Property("SettlementId") + .HasColumnType("char(36)"); + + b.Property("TransactionId") + .HasColumnType("char(36)"); + + b.Property("WeekNumber") + .HasColumnType("int"); + + b.Property("YearNumber") + .HasColumnType("int"); + + b.ToTable((string)null); + + b.ToView("uvwSettlements", (string)null); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/TransactionProcessor.Database/Migrations/MySql/20240425094256_record_operatators_at_readmodel.cs b/TransactionProcessor.Database/Migrations/MySql/20240425094256_record_operatators_at_readmodel.cs new file mode 100644 index 00000000..627a0f3d --- /dev/null +++ b/TransactionProcessor.Database/Migrations/MySql/20240425094256_record_operatators_at_readmodel.cs @@ -0,0 +1,114 @@ +#nullable disable + +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; + +namespace TransactionProcessor.Database.Migrations.MySql +{ + /// + public partial class record_operatators_at_readmodel : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropPrimaryKey( + name: "PK_estateoperator", + table: "estateoperator"); + + migrationBuilder.DropColumn( + name: "OperatorId", + table: "estateoperator"); + + migrationBuilder.DropColumn( + name: "Name", + table: "estateoperator"); + + migrationBuilder.DropColumn( + name: "RequireCustomMerchantNumber", + table: "estateoperator"); + + migrationBuilder.DropColumn( + name: "RequireCustomTerminalNumber", + table: "estateoperator"); + + migrationBuilder.RenameColumn( + name: "EstateOperatorReportingId", + table: "estateoperator", + newName: "OperatorReportingId"); + + migrationBuilder.AddPrimaryKey( + name: "PK_estateoperator", + table: "estateoperator", + column: "OperatorReportingId"); + + migrationBuilder.CreateTable( + name: "operator", + columns: table => new + { + OperatorId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + OperatorReportingId = table.Column(type: "int", nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + EstateReportingId = table.Column(type: "int", nullable: false), + Name = table.Column(type: "longtext", nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + RequireCustomMerchantNumber = table.Column(type: "tinyint(1)", nullable: false), + RequireCustomTerminalNumber = table.Column(type: "tinyint(1)", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_operator", x => x.OperatorId); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "operator"); + + migrationBuilder.DropPrimaryKey( + name: "PK_estateoperator", + table: "estateoperator"); + + migrationBuilder.RenameColumn( + name: "OperatorReportingId", + table: "estateoperator", + newName: "EstateOperatorReportingId"); + + migrationBuilder.AddColumn( + name: "OperatorId", + table: "estateoperator", + type: "char(36)", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), + collation: "ascii_general_ci"); + + migrationBuilder.AddColumn( + name: "Name", + table: "estateoperator", + type: "longtext", + nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.AddColumn( + name: "RequireCustomMerchantNumber", + table: "estateoperator", + type: "tinyint(1)", + nullable: false, + defaultValue: false); + + migrationBuilder.AddColumn( + name: "RequireCustomTerminalNumber", + table: "estateoperator", + type: "tinyint(1)", + nullable: false, + defaultValue: false); + + migrationBuilder.AddPrimaryKey( + name: "PK_estateoperator", + table: "estateoperator", + columns: new[] { "EstateReportingId", "OperatorId" }); + } + } +} diff --git a/TransactionProcessor.Database/Migrations/MySql/20240425132550_record_operatators_at_readmodel_1.Designer.cs b/TransactionProcessor.Database/Migrations/MySql/20240425132550_record_operatators_at_readmodel_1.Designer.cs new file mode 100644 index 00000000..4fef017c --- /dev/null +++ b/TransactionProcessor.Database/Migrations/MySql/20240425132550_record_operatators_at_readmodel_1.Designer.cs @@ -0,0 +1,1114 @@ +// + +#nullable disable + +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using TransactionProcessor.Database.Contexts; + +namespace TransactionProcessor.Database.Migrations.MySql +{ + [DbContext(typeof(EstateManagementMySqlContext))] + [Migration("20240425132550_record_operatators_at_readmodel_1")] + partial class record_operatators_at_readmodel_1 + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.3") + .HasAnnotation("Relational:MaxIdentifierLength", 64); + + MySqlModelBuilderExtensions.AutoIncrementColumns(modelBuilder); + + modelBuilder.Entity("EstateManagement.Database.Entities.Calendar", b => + { + b.Property("Date") + .HasColumnType("datetime(6)"); + + b.Property("DayOfWeek") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("DayOfWeekNumber") + .HasColumnType("int"); + + b.Property("DayOfWeekShort") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("MonthNameLong") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("MonthNameShort") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("MonthNumber") + .HasColumnType("int"); + + b.Property("WeekNumber") + .HasColumnType("int"); + + b.Property("WeekNumberString") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("Year") + .HasColumnType("int"); + + b.Property("YearWeekNumber") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("Date"); + + b.ToTable("calendar"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Contract", b => + { + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("OperatorId") + .HasColumnType("char(36)"); + + b.Property("ContractId") + .HasColumnType("char(36)"); + + b.Property("ContractReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("ContractReportingId")); + + b.Property("Description") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("EstateReportingId", "OperatorId", "ContractId"); + + b.ToTable("contract"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.ContractProduct", b => + { + b.Property("ContractReportingId") + .HasColumnType("int"); + + b.Property("ProductId") + .HasColumnType("char(36)"); + + b.Property("ContractProductReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("ContractProductReportingId")); + + b.Property("DisplayText") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ProductName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ProductType") + .HasColumnType("int"); + + b.Property("Value") + .HasColumnType("decimal(65,30)"); + + b.HasKey("ContractReportingId", "ProductId"); + + b.ToTable("contractproduct"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.ContractProductTransactionFee", b => + { + b.Property("ContractProductReportingId") + .HasColumnType("int"); + + b.Property("TransactionFeeId") + .HasColumnType("char(36)"); + + b.Property("CalculationType") + .HasColumnType("int"); + + b.Property("Description") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("FeeType") + .HasColumnType("int"); + + b.Property("IsEnabled") + .HasColumnType("tinyint(1)"); + + b.Property("TransactionFeeReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("TransactionFeeReportingId")); + + b.Property("Value") + .HasColumnType("decimal(18,4)"); + + b.HasKey("ContractProductReportingId", "TransactionFeeId"); + + b.ToTable("contractproducttransactionfee"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Estate", b => + { + b.Property("EstateReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("EstateReportingId")); + + b.Property("CreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("EstateId") + .HasColumnType("char(36)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("Reference") + .HasColumnType("longtext"); + + b.HasKey("EstateReportingId"); + + b.HasIndex("EstateId") + .IsUnique(); + + b.ToTable("estate"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.EstateOperator", b => + { + b.Property("OperatorReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("OperatorReportingId")); + + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.HasKey("OperatorReportingId"); + + b.ToTable("estateoperator"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.EstateSecurityUser", b => + { + b.Property("SecurityUserId") + .HasColumnType("char(36)"); + + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("EmailAddress") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("SecurityUserId", "EstateReportingId"); + + b.ToTable("estatesecurityuser"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.File", b => + { + b.Property("FileReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("FileReportingId")); + + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("FileId") + .HasColumnType("char(36)"); + + b.Property("FileImportLogReportingId") + .HasColumnType("int"); + + b.Property("FileLocation") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("FileProfileId") + .HasColumnType("char(36)"); + + b.Property("FileReceivedDate") + .HasColumnType("date"); + + b.Property("FileReceivedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("IsCompleted") + .HasColumnType("tinyint(1)"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("UserId") + .HasColumnType("char(36)"); + + b.HasKey("FileReportingId"); + + b.HasIndex("FileId") + .IsUnique(); + + b.ToTable("file"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.FileImportLog", b => + { + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("FileImportLogReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("FileImportLogReportingId")); + + b.Property("FileImportLogId") + .HasColumnType("char(36)"); + + b.Property("ImportLogDate") + .HasColumnType("date"); + + b.Property("ImportLogDateTime") + .HasColumnType("datetime(6)"); + + b.HasKey("EstateReportingId", "FileImportLogReportingId"); + + b.HasIndex("EstateReportingId", "FileImportLogId") + .IsUnique(); + + b.ToTable("fileimportlog"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.FileImportLogFile", b => + { + b.Property("FileImportLogReportingId") + .HasColumnType("int"); + + b.Property("FileReportingId") + .HasColumnType("int"); + + b.Property("FilePath") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("FileProfileId") + .HasColumnType("char(36)"); + + b.Property("FileUploadedDate") + .HasColumnType("date"); + + b.Property("FileUploadedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("OriginalFileName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("UserId") + .HasColumnType("char(36)"); + + b.HasKey("FileImportLogReportingId", "FileReportingId"); + + b.ToTable("fileimportlogfile"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.FileLine", b => + { + b.Property("FileReportingId") + .HasColumnType("int"); + + b.Property("LineNumber") + .HasColumnType("int"); + + b.Property("FileLineData") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("Status") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.HasKey("FileReportingId", "LineNumber") + .HasAnnotation("SqlServer:Clustered", true); + + b.HasIndex("TransactionReportingId"); + + b.ToTable("fileline"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Float", b => + { + b.Property("FloatId") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("ContractId") + .HasColumnType("char(36)"); + + b.Property("CreatedDate") + .HasColumnType("date"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("EstateId") + .HasColumnType("char(36)"); + + b.Property("ProductId") + .HasColumnType("char(36)"); + + b.HasKey("FloatId") + .HasAnnotation("SqlServer:Clustered", false); + + b.HasIndex("CreatedDate") + .HasAnnotation("SqlServer:Clustered", true); + + b.ToTable("Floats"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.FloatActivity", b => + { + b.Property("EventId") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("ActivityDate") + .HasColumnType("date"); + + b.Property("ActivityDateTime") + .HasColumnType("datetime(6)"); + + b.Property("Amount") + .HasColumnType("decimal(65,30)"); + + b.Property("CostPrice") + .HasColumnType("decimal(65,30)"); + + b.Property("CreditOrDebit") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("FloatId") + .HasColumnType("char(36)"); + + b.HasKey("EventId") + .HasAnnotation("SqlServer:Clustered", false); + + b.HasIndex("ActivityDate") + .HasAnnotation("SqlServer:Clustered", true); + + b.ToTable("FloatActivity"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Merchant", b => + { + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("MerchantReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("MerchantReportingId")); + + b.Property("CreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("LastSaleDate") + .HasColumnType("date"); + + b.Property("LastSaleDateTime") + .HasColumnType("datetime(6)"); + + b.Property("LastStatementGenerated") + .HasColumnType("datetime(6)"); + + b.Property("MerchantId") + .HasColumnType("char(36)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("Reference") + .HasColumnType("longtext"); + + b.Property("SettlementSchedule") + .HasColumnType("int"); + + b.HasKey("EstateReportingId", "MerchantReportingId"); + + b.HasIndex("EstateReportingId", "MerchantId") + .IsUnique(); + + b.ToTable("merchant"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantAddress", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("AddressId") + .HasColumnType("char(36)"); + + b.Property("AddressLine1") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("AddressLine2") + .HasColumnType("longtext"); + + b.Property("AddressLine3") + .HasColumnType("longtext"); + + b.Property("AddressLine4") + .HasColumnType("longtext"); + + b.Property("Country") + .HasColumnType("longtext"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("PostalCode") + .HasColumnType("longtext"); + + b.Property("Region") + .HasColumnType("longtext"); + + b.Property("Town") + .HasColumnType("longtext"); + + b.HasKey("MerchantReportingId", "AddressId"); + + b.ToTable("merchantaddress"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantContact", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("ContactId") + .HasColumnType("char(36)"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("EmailAddress") + .HasColumnType("longtext"); + + b.Property("Name") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("PhoneNumber") + .HasColumnType("longtext"); + + b.HasKey("MerchantReportingId", "ContactId"); + + b.ToTable("merchantcontact"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantContract", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("ContractReportingId") + .HasColumnType("int"); + + b.Property("IsDeleted") + .HasColumnType("tinyint(1)"); + + b.HasKey("MerchantReportingId", "ContractReportingId"); + + b.ToTable("MerchantContracts"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantDevice", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("DeviceId") + .HasColumnType("char(36)"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("DeviceIdentifier") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("MerchantReportingId", "DeviceId"); + + b.ToTable("merchantdevice"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantOperator", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("OperatorId") + .HasColumnType("char(36)"); + + b.Property("IsDeleted") + .HasColumnType("tinyint(1)"); + + b.Property("MerchantNumber") + .HasColumnType("longtext"); + + b.Property("Name") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("TerminalNumber") + .HasColumnType("longtext"); + + b.HasKey("MerchantReportingId", "OperatorId"); + + b.ToTable("merchantoperator"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantSecurityUser", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("SecurityUserId") + .HasColumnType("char(36)"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("EmailAddress") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("MerchantReportingId", "SecurityUserId"); + + b.ToTable("merchantsecurityuser"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantSettlementFee", b => + { + b.Property("SettlementReportingId") + .HasColumnType("int"); + + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.Property("TransactionFeeReportingId") + .HasColumnType("int"); + + b.Property("CalculatedValue") + .HasColumnType("decimal(65,30)"); + + b.Property("FeeCalculatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("FeeValue") + .HasColumnType("decimal(65,30)"); + + b.Property("IsSettled") + .HasColumnType("tinyint(1)"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.HasKey("SettlementReportingId", "TransactionReportingId", "TransactionFeeReportingId"); + + b.HasIndex("TransactionReportingId"); + + b.ToTable("merchantsettlementfee"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Operator", b => + { + b.Property("OperatorReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("OperatorReportingId")); + + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("Name") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("OperatorId") + .HasColumnType("char(36)"); + + b.Property("RequireCustomMerchantNumber") + .HasColumnType("tinyint(1)"); + + b.Property("RequireCustomTerminalNumber") + .HasColumnType("tinyint(1)"); + + b.HasKey("OperatorReportingId"); + + b.HasIndex("OperatorId") + .IsUnique(); + + b.ToTable("operator"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Reconciliation", b => + { + b.Property("TransactionReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("TransactionReportingId")); + + b.Property("DeviceIdentifier") + .HasColumnType("longtext"); + + b.Property("IsAuthorised") + .HasColumnType("tinyint(1)"); + + b.Property("IsCompleted") + .HasColumnType("tinyint(1)"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("ResponseCode") + .HasColumnType("longtext"); + + b.Property("ResponseMessage") + .HasColumnType("longtext"); + + b.Property("TransactionCount") + .HasColumnType("int"); + + b.Property("TransactionDate") + .HasColumnType("date"); + + b.Property("TransactionDateTime") + .HasColumnType("datetime(6)"); + + b.Property("TransactionId") + .HasColumnType("char(36)"); + + b.Property("TransactionTime") + .HasColumnType("time(6)"); + + b.Property("TransactionValue") + .HasColumnType("decimal(65,30)"); + + b.HasKey("TransactionReportingId") + .HasAnnotation("SqlServer:Clustered", false); + + b.HasIndex("TransactionDate", "MerchantReportingId") + .HasAnnotation("SqlServer:Clustered", true); + + b.HasIndex("TransactionId", "MerchantReportingId") + .IsUnique() + .HasAnnotation("SqlServer:Clustered", false); + + b.ToTable("reconciliation"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.ResponseCodes", b => + { + b.Property("ResponseCode") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("ResponseCode")); + + b.Property("Description") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("ResponseCode"); + + b.ToTable("responsecodes"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Settlement", b => + { + b.Property("SettlementReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("SettlementReportingId")); + + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("IsCompleted") + .HasColumnType("tinyint(1)"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("ProcessingStarted") + .HasColumnType("tinyint(1)"); + + b.Property("ProcessingStartedDateTIme") + .HasColumnType("datetime(6)"); + + b.Property("SettlementDate") + .HasColumnType("date"); + + b.Property("SettlementId") + .HasColumnType("char(36)"); + + b.HasKey("SettlementReportingId") + .HasAnnotation("SqlServer:Clustered", false); + + b.HasIndex("EstateReportingId", "SettlementId") + .IsUnique() + .HasAnnotation("SqlServer:Clustered", false); + + b.HasIndex("SettlementDate", "EstateReportingId") + .HasAnnotation("SqlServer:Clustered", true); + + b.ToTable("settlement"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.StatementHeader", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("StatementId") + .HasColumnType("char(36)"); + + b.Property("StatementCreatedDate") + .HasColumnType("date"); + + b.Property("StatementCreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("StatementGeneratedDate") + .HasColumnType("date"); + + b.Property("StatementGeneratedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("StatementReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("StatementReportingId")); + + b.HasKey("MerchantReportingId", "StatementId") + .HasAnnotation("SqlServer:Clustered", false); + + b.HasIndex("MerchantReportingId", "StatementGeneratedDate") + .HasAnnotation("SqlServer:Clustered", true); + + b.ToTable("statementheader"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.StatementLine", b => + { + b.Property("StatementReportingId") + .HasColumnType("int"); + + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.Property("ActivityDateTime") + .HasColumnType("datetime(6)"); + + b.Property("ActivityType") + .HasColumnType("int"); + + b.Property("ActivityDate") + .HasColumnType("date"); + + b.Property("ActivityDescription") + .HasColumnType("longtext"); + + b.Property("InAmount") + .HasColumnType("decimal(65,30)"); + + b.Property("OutAmount") + .HasColumnType("decimal(65,30)"); + + b.HasKey("StatementReportingId", "TransactionReportingId", "ActivityDateTime", "ActivityType"); + + b.ToTable("statementline"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Transaction", b => + { + b.Property("TransactionReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("TransactionReportingId")); + + b.Property("AuthorisationCode") + .HasColumnType("longtext"); + + b.Property("ContractProductReportingId") + .HasColumnType("int"); + + b.Property("ContractReportingId") + .HasColumnType("int"); + + b.Property("DeviceIdentifier") + .HasColumnType("longtext"); + + b.Property("EstateOperatorReportingId") + .HasColumnType("int"); + + b.Property("IsAuthorised") + .HasColumnType("tinyint(1)"); + + b.Property("IsCompleted") + .HasColumnType("tinyint(1)"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("ResponseCode") + .HasColumnType("longtext"); + + b.Property("ResponseMessage") + .HasColumnType("longtext"); + + b.Property("TransactionAmount") + .HasColumnType("decimal(65,30)"); + + b.Property("TransactionDate") + .HasColumnType("date"); + + b.Property("TransactionDateTime") + .HasColumnType("datetime(6)"); + + b.Property("TransactionId") + .HasColumnType("char(36)"); + + b.Property("TransactionNumber") + .HasColumnType("longtext"); + + b.Property("TransactionReference") + .HasColumnType("longtext"); + + b.Property("TransactionSource") + .HasColumnType("int"); + + b.Property("TransactionTime") + .HasColumnType("time(6)"); + + b.Property("TransactionType") + .HasColumnType("longtext"); + + b.HasKey("TransactionReportingId") + .HasAnnotation("SqlServer:Clustered", false); + + b.HasIndex("TransactionId") + .IsUnique() + .HasAnnotation("SqlServer:Clustered", false); + + b.HasIndex("TransactionDate", "MerchantReportingId") + .HasAnnotation("SqlServer:Clustered", true); + + b.HasIndex("TransactionId", "MerchantReportingId") + .IsUnique() + .HasAnnotation("SqlServer:Clustered", false); + + b.ToTable("transaction"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.TransactionAdditionalRequestData", b => + { + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.Property("Amount") + .HasColumnType("longtext"); + + b.Property("CustomerAccountNumber") + .HasColumnType("longtext"); + + b.HasKey("TransactionReportingId"); + + b.ToTable("transactionadditionalrequestdata"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.TransactionAdditionalResponseData", b => + { + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.HasKey("TransactionReportingId"); + + b.ToTable("transactionadditionalresponsedata"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Voucher", b => + { + b.Property("VoucherId") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("ExpiryDate") + .HasColumnType("date"); + + b.Property("ExpiryDateTime") + .HasColumnType("datetime(6)"); + + b.Property("GenerateDate") + .HasColumnType("date"); + + b.Property("GenerateDateTime") + .HasColumnType("datetime(6)"); + + b.Property("IsGenerated") + .HasColumnType("tinyint(1)"); + + b.Property("IsIssued") + .HasColumnType("tinyint(1)"); + + b.Property("IsRedeemed") + .HasColumnType("tinyint(1)"); + + b.Property("IssuedDate") + .HasColumnType("date"); + + b.Property("IssuedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("OperatorIdentifier") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("RecipientEmail") + .HasColumnType("longtext"); + + b.Property("RecipientMobile") + .HasColumnType("longtext"); + + b.Property("RedeemedDate") + .HasColumnType("datetime(6)"); + + b.Property("RedeemedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.Property("Value") + .HasColumnType("decimal(65,30)"); + + b.Property("VoucherCode") + .IsRequired() + .HasColumnType("varchar(255)"); + + b.HasKey("VoucherId"); + + b.HasIndex("TransactionReportingId"); + + b.HasIndex("VoucherCode"); + + b.ToTable("voucher"); + }); + + modelBuilder.Entity("EstateManagement.Database.ViewEntities.SettlementView", b => + { + b.Property("Amount") + .HasColumnType("decimal(65,30)"); + + b.Property("CalculatedValue") + .HasColumnType("decimal(65,30)"); + + b.Property("DayOfWeek") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("EstateId") + .HasColumnType("char(36)"); + + b.Property("FeeDescription") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("IsCompleted") + .HasColumnType("tinyint(1)"); + + b.Property("IsSettled") + .HasColumnType("tinyint(1)"); + + b.Property("MerchantId") + .HasColumnType("char(36)"); + + b.Property("MerchantName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("Month") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("MonthNumber") + .HasColumnType("int"); + + b.Property("OperatorIdentifier") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("SettlementDate") + .HasColumnType("datetime(6)"); + + b.Property("SettlementId") + .HasColumnType("char(36)"); + + b.Property("TransactionId") + .HasColumnType("char(36)"); + + b.Property("WeekNumber") + .HasColumnType("int"); + + b.Property("YearNumber") + .HasColumnType("int"); + + b.ToTable((string)null); + + b.ToView("uvwSettlements", (string)null); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/TransactionProcessor.Database/Migrations/MySql/20240425132550_record_operatators_at_readmodel_1.cs b/TransactionProcessor.Database/Migrations/MySql/20240425132550_record_operatators_at_readmodel_1.cs new file mode 100644 index 00000000..a84113a0 --- /dev/null +++ b/TransactionProcessor.Database/Migrations/MySql/20240425132550_record_operatators_at_readmodel_1.cs @@ -0,0 +1,46 @@ +#nullable disable + +using Microsoft.EntityFrameworkCore.Migrations; + +namespace TransactionProcessor.Database.Migrations.MySql +{ + /// + public partial class record_operatators_at_readmodel_1 : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropPrimaryKey( + name: "PK_operator", + table: "operator"); + + migrationBuilder.AddPrimaryKey( + name: "PK_operator", + table: "operator", + column: "OperatorReportingId"); + + migrationBuilder.CreateIndex( + name: "IX_operator_OperatorId", + table: "operator", + column: "OperatorId", + unique: true); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropPrimaryKey( + name: "PK_operator", + table: "operator"); + + migrationBuilder.DropIndex( + name: "IX_operator_OperatorId", + table: "operator"); + + migrationBuilder.AddPrimaryKey( + name: "PK_operator", + table: "operator", + column: "OperatorId"); + } + } +} diff --git a/TransactionProcessor.Database/Migrations/MySql/20240425164125_record_operatators_at_readmodel_2.Designer.cs b/TransactionProcessor.Database/Migrations/MySql/20240425164125_record_operatators_at_readmodel_2.Designer.cs new file mode 100644 index 00000000..6cae8421 --- /dev/null +++ b/TransactionProcessor.Database/Migrations/MySql/20240425164125_record_operatators_at_readmodel_2.Designer.cs @@ -0,0 +1,1111 @@ +// + +#nullable disable + +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using TransactionProcessor.Database.Contexts; + +namespace TransactionProcessor.Database.Migrations.MySql +{ + [DbContext(typeof(EstateManagementMySqlContext))] + [Migration("20240425164125_record_operatators_at_readmodel_2")] + partial class record_operatators_at_readmodel_2 + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.3") + .HasAnnotation("Relational:MaxIdentifierLength", 64); + + MySqlModelBuilderExtensions.AutoIncrementColumns(modelBuilder); + + modelBuilder.Entity("EstateManagement.Database.Entities.Calendar", b => + { + b.Property("Date") + .HasColumnType("datetime(6)"); + + b.Property("DayOfWeek") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("DayOfWeekNumber") + .HasColumnType("int"); + + b.Property("DayOfWeekShort") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("MonthNameLong") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("MonthNameShort") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("MonthNumber") + .HasColumnType("int"); + + b.Property("WeekNumber") + .HasColumnType("int"); + + b.Property("WeekNumberString") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("Year") + .HasColumnType("int"); + + b.Property("YearWeekNumber") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("Date"); + + b.ToTable("calendar"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Contract", b => + { + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("OperatorId") + .HasColumnType("char(36)"); + + b.Property("ContractId") + .HasColumnType("char(36)"); + + b.Property("ContractReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("ContractReportingId")); + + b.Property("Description") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("EstateReportingId", "OperatorId", "ContractId"); + + b.ToTable("contract"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.ContractProduct", b => + { + b.Property("ContractReportingId") + .HasColumnType("int"); + + b.Property("ProductId") + .HasColumnType("char(36)"); + + b.Property("ContractProductReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("ContractProductReportingId")); + + b.Property("DisplayText") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ProductName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ProductType") + .HasColumnType("int"); + + b.Property("Value") + .HasColumnType("decimal(65,30)"); + + b.HasKey("ContractReportingId", "ProductId"); + + b.ToTable("contractproduct"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.ContractProductTransactionFee", b => + { + b.Property("ContractProductReportingId") + .HasColumnType("int"); + + b.Property("TransactionFeeId") + .HasColumnType("char(36)"); + + b.Property("CalculationType") + .HasColumnType("int"); + + b.Property("Description") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("FeeType") + .HasColumnType("int"); + + b.Property("IsEnabled") + .HasColumnType("tinyint(1)"); + + b.Property("TransactionFeeReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("TransactionFeeReportingId")); + + b.Property("Value") + .HasColumnType("decimal(18,4)"); + + b.HasKey("ContractProductReportingId", "TransactionFeeId"); + + b.ToTable("contractproducttransactionfee"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Estate", b => + { + b.Property("EstateReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("EstateReportingId")); + + b.Property("CreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("EstateId") + .HasColumnType("char(36)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("Reference") + .HasColumnType("longtext"); + + b.HasKey("EstateReportingId"); + + b.HasIndex("EstateId") + .IsUnique(); + + b.ToTable("estate"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.EstateOperator", b => + { + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("OperatorReportingId") + .HasColumnType("int"); + + b.HasKey("EstateReportingId", "OperatorReportingId"); + + b.ToTable("estateoperator"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.EstateSecurityUser", b => + { + b.Property("SecurityUserId") + .HasColumnType("char(36)"); + + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("EmailAddress") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("SecurityUserId", "EstateReportingId"); + + b.ToTable("estatesecurityuser"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.File", b => + { + b.Property("FileReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("FileReportingId")); + + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("FileId") + .HasColumnType("char(36)"); + + b.Property("FileImportLogReportingId") + .HasColumnType("int"); + + b.Property("FileLocation") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("FileProfileId") + .HasColumnType("char(36)"); + + b.Property("FileReceivedDate") + .HasColumnType("date"); + + b.Property("FileReceivedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("IsCompleted") + .HasColumnType("tinyint(1)"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("UserId") + .HasColumnType("char(36)"); + + b.HasKey("FileReportingId"); + + b.HasIndex("FileId") + .IsUnique(); + + b.ToTable("file"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.FileImportLog", b => + { + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("FileImportLogReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("FileImportLogReportingId")); + + b.Property("FileImportLogId") + .HasColumnType("char(36)"); + + b.Property("ImportLogDate") + .HasColumnType("date"); + + b.Property("ImportLogDateTime") + .HasColumnType("datetime(6)"); + + b.HasKey("EstateReportingId", "FileImportLogReportingId"); + + b.HasIndex("EstateReportingId", "FileImportLogId") + .IsUnique(); + + b.ToTable("fileimportlog"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.FileImportLogFile", b => + { + b.Property("FileImportLogReportingId") + .HasColumnType("int"); + + b.Property("FileReportingId") + .HasColumnType("int"); + + b.Property("FilePath") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("FileProfileId") + .HasColumnType("char(36)"); + + b.Property("FileUploadedDate") + .HasColumnType("date"); + + b.Property("FileUploadedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("OriginalFileName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("UserId") + .HasColumnType("char(36)"); + + b.HasKey("FileImportLogReportingId", "FileReportingId"); + + b.ToTable("fileimportlogfile"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.FileLine", b => + { + b.Property("FileReportingId") + .HasColumnType("int"); + + b.Property("LineNumber") + .HasColumnType("int"); + + b.Property("FileLineData") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("Status") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.HasKey("FileReportingId", "LineNumber") + .HasAnnotation("SqlServer:Clustered", true); + + b.HasIndex("TransactionReportingId"); + + b.ToTable("fileline"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Float", b => + { + b.Property("FloatId") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("ContractId") + .HasColumnType("char(36)"); + + b.Property("CreatedDate") + .HasColumnType("date"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("EstateId") + .HasColumnType("char(36)"); + + b.Property("ProductId") + .HasColumnType("char(36)"); + + b.HasKey("FloatId") + .HasAnnotation("SqlServer:Clustered", false); + + b.HasIndex("CreatedDate") + .HasAnnotation("SqlServer:Clustered", true); + + b.ToTable("Floats"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.FloatActivity", b => + { + b.Property("EventId") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("ActivityDate") + .HasColumnType("date"); + + b.Property("ActivityDateTime") + .HasColumnType("datetime(6)"); + + b.Property("Amount") + .HasColumnType("decimal(65,30)"); + + b.Property("CostPrice") + .HasColumnType("decimal(65,30)"); + + b.Property("CreditOrDebit") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("FloatId") + .HasColumnType("char(36)"); + + b.HasKey("EventId") + .HasAnnotation("SqlServer:Clustered", false); + + b.HasIndex("ActivityDate") + .HasAnnotation("SqlServer:Clustered", true); + + b.ToTable("FloatActivity"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Merchant", b => + { + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("MerchantReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("MerchantReportingId")); + + b.Property("CreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("LastSaleDate") + .HasColumnType("date"); + + b.Property("LastSaleDateTime") + .HasColumnType("datetime(6)"); + + b.Property("LastStatementGenerated") + .HasColumnType("datetime(6)"); + + b.Property("MerchantId") + .HasColumnType("char(36)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("Reference") + .HasColumnType("longtext"); + + b.Property("SettlementSchedule") + .HasColumnType("int"); + + b.HasKey("EstateReportingId", "MerchantReportingId"); + + b.HasIndex("EstateReportingId", "MerchantId") + .IsUnique(); + + b.ToTable("merchant"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantAddress", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("AddressId") + .HasColumnType("char(36)"); + + b.Property("AddressLine1") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("AddressLine2") + .HasColumnType("longtext"); + + b.Property("AddressLine3") + .HasColumnType("longtext"); + + b.Property("AddressLine4") + .HasColumnType("longtext"); + + b.Property("Country") + .HasColumnType("longtext"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("PostalCode") + .HasColumnType("longtext"); + + b.Property("Region") + .HasColumnType("longtext"); + + b.Property("Town") + .HasColumnType("longtext"); + + b.HasKey("MerchantReportingId", "AddressId"); + + b.ToTable("merchantaddress"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantContact", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("ContactId") + .HasColumnType("char(36)"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("EmailAddress") + .HasColumnType("longtext"); + + b.Property("Name") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("PhoneNumber") + .HasColumnType("longtext"); + + b.HasKey("MerchantReportingId", "ContactId"); + + b.ToTable("merchantcontact"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantContract", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("ContractReportingId") + .HasColumnType("int"); + + b.Property("IsDeleted") + .HasColumnType("tinyint(1)"); + + b.HasKey("MerchantReportingId", "ContractReportingId"); + + b.ToTable("MerchantContracts"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantDevice", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("DeviceId") + .HasColumnType("char(36)"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("DeviceIdentifier") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("MerchantReportingId", "DeviceId"); + + b.ToTable("merchantdevice"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantOperator", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("OperatorId") + .HasColumnType("char(36)"); + + b.Property("IsDeleted") + .HasColumnType("tinyint(1)"); + + b.Property("MerchantNumber") + .HasColumnType("longtext"); + + b.Property("Name") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("TerminalNumber") + .HasColumnType("longtext"); + + b.HasKey("MerchantReportingId", "OperatorId"); + + b.ToTable("merchantoperator"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantSecurityUser", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("SecurityUserId") + .HasColumnType("char(36)"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("EmailAddress") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("MerchantReportingId", "SecurityUserId"); + + b.ToTable("merchantsecurityuser"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantSettlementFee", b => + { + b.Property("SettlementReportingId") + .HasColumnType("int"); + + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.Property("TransactionFeeReportingId") + .HasColumnType("int"); + + b.Property("CalculatedValue") + .HasColumnType("decimal(65,30)"); + + b.Property("FeeCalculatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("FeeValue") + .HasColumnType("decimal(65,30)"); + + b.Property("IsSettled") + .HasColumnType("tinyint(1)"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.HasKey("SettlementReportingId", "TransactionReportingId", "TransactionFeeReportingId"); + + b.HasIndex("TransactionReportingId"); + + b.ToTable("merchantsettlementfee"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Operator", b => + { + b.Property("OperatorReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("OperatorReportingId")); + + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("Name") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("OperatorId") + .HasColumnType("char(36)"); + + b.Property("RequireCustomMerchantNumber") + .HasColumnType("tinyint(1)"); + + b.Property("RequireCustomTerminalNumber") + .HasColumnType("tinyint(1)"); + + b.HasKey("OperatorReportingId"); + + b.HasIndex("OperatorId") + .IsUnique(); + + b.ToTable("operator"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Reconciliation", b => + { + b.Property("TransactionReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("TransactionReportingId")); + + b.Property("DeviceIdentifier") + .HasColumnType("longtext"); + + b.Property("IsAuthorised") + .HasColumnType("tinyint(1)"); + + b.Property("IsCompleted") + .HasColumnType("tinyint(1)"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("ResponseCode") + .HasColumnType("longtext"); + + b.Property("ResponseMessage") + .HasColumnType("longtext"); + + b.Property("TransactionCount") + .HasColumnType("int"); + + b.Property("TransactionDate") + .HasColumnType("date"); + + b.Property("TransactionDateTime") + .HasColumnType("datetime(6)"); + + b.Property("TransactionId") + .HasColumnType("char(36)"); + + b.Property("TransactionTime") + .HasColumnType("time(6)"); + + b.Property("TransactionValue") + .HasColumnType("decimal(65,30)"); + + b.HasKey("TransactionReportingId") + .HasAnnotation("SqlServer:Clustered", false); + + b.HasIndex("TransactionDate", "MerchantReportingId") + .HasAnnotation("SqlServer:Clustered", true); + + b.HasIndex("TransactionId", "MerchantReportingId") + .IsUnique() + .HasAnnotation("SqlServer:Clustered", false); + + b.ToTable("reconciliation"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.ResponseCodes", b => + { + b.Property("ResponseCode") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("ResponseCode")); + + b.Property("Description") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("ResponseCode"); + + b.ToTable("responsecodes"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Settlement", b => + { + b.Property("SettlementReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("SettlementReportingId")); + + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("IsCompleted") + .HasColumnType("tinyint(1)"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("ProcessingStarted") + .HasColumnType("tinyint(1)"); + + b.Property("ProcessingStartedDateTIme") + .HasColumnType("datetime(6)"); + + b.Property("SettlementDate") + .HasColumnType("date"); + + b.Property("SettlementId") + .HasColumnType("char(36)"); + + b.HasKey("SettlementReportingId") + .HasAnnotation("SqlServer:Clustered", false); + + b.HasIndex("EstateReportingId", "SettlementId") + .IsUnique() + .HasAnnotation("SqlServer:Clustered", false); + + b.HasIndex("SettlementDate", "EstateReportingId") + .HasAnnotation("SqlServer:Clustered", true); + + b.ToTable("settlement"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.StatementHeader", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("StatementId") + .HasColumnType("char(36)"); + + b.Property("StatementCreatedDate") + .HasColumnType("date"); + + b.Property("StatementCreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("StatementGeneratedDate") + .HasColumnType("date"); + + b.Property("StatementGeneratedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("StatementReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("StatementReportingId")); + + b.HasKey("MerchantReportingId", "StatementId") + .HasAnnotation("SqlServer:Clustered", false); + + b.HasIndex("MerchantReportingId", "StatementGeneratedDate") + .HasAnnotation("SqlServer:Clustered", true); + + b.ToTable("statementheader"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.StatementLine", b => + { + b.Property("StatementReportingId") + .HasColumnType("int"); + + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.Property("ActivityDateTime") + .HasColumnType("datetime(6)"); + + b.Property("ActivityType") + .HasColumnType("int"); + + b.Property("ActivityDate") + .HasColumnType("date"); + + b.Property("ActivityDescription") + .HasColumnType("longtext"); + + b.Property("InAmount") + .HasColumnType("decimal(65,30)"); + + b.Property("OutAmount") + .HasColumnType("decimal(65,30)"); + + b.HasKey("StatementReportingId", "TransactionReportingId", "ActivityDateTime", "ActivityType"); + + b.ToTable("statementline"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Transaction", b => + { + b.Property("TransactionReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("TransactionReportingId")); + + b.Property("AuthorisationCode") + .HasColumnType("longtext"); + + b.Property("ContractProductReportingId") + .HasColumnType("int"); + + b.Property("ContractReportingId") + .HasColumnType("int"); + + b.Property("DeviceIdentifier") + .HasColumnType("longtext"); + + b.Property("EstateOperatorReportingId") + .HasColumnType("int"); + + b.Property("IsAuthorised") + .HasColumnType("tinyint(1)"); + + b.Property("IsCompleted") + .HasColumnType("tinyint(1)"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("ResponseCode") + .HasColumnType("longtext"); + + b.Property("ResponseMessage") + .HasColumnType("longtext"); + + b.Property("TransactionAmount") + .HasColumnType("decimal(65,30)"); + + b.Property("TransactionDate") + .HasColumnType("date"); + + b.Property("TransactionDateTime") + .HasColumnType("datetime(6)"); + + b.Property("TransactionId") + .HasColumnType("char(36)"); + + b.Property("TransactionNumber") + .HasColumnType("longtext"); + + b.Property("TransactionReference") + .HasColumnType("longtext"); + + b.Property("TransactionSource") + .HasColumnType("int"); + + b.Property("TransactionTime") + .HasColumnType("time(6)"); + + b.Property("TransactionType") + .HasColumnType("longtext"); + + b.HasKey("TransactionReportingId") + .HasAnnotation("SqlServer:Clustered", false); + + b.HasIndex("TransactionId") + .IsUnique() + .HasAnnotation("SqlServer:Clustered", false); + + b.HasIndex("TransactionDate", "MerchantReportingId") + .HasAnnotation("SqlServer:Clustered", true); + + b.HasIndex("TransactionId", "MerchantReportingId") + .IsUnique() + .HasAnnotation("SqlServer:Clustered", false); + + b.ToTable("transaction"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.TransactionAdditionalRequestData", b => + { + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.Property("Amount") + .HasColumnType("longtext"); + + b.Property("CustomerAccountNumber") + .HasColumnType("longtext"); + + b.HasKey("TransactionReportingId"); + + b.ToTable("transactionadditionalrequestdata"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.TransactionAdditionalResponseData", b => + { + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.HasKey("TransactionReportingId"); + + b.ToTable("transactionadditionalresponsedata"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Voucher", b => + { + b.Property("VoucherId") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("ExpiryDate") + .HasColumnType("date"); + + b.Property("ExpiryDateTime") + .HasColumnType("datetime(6)"); + + b.Property("GenerateDate") + .HasColumnType("date"); + + b.Property("GenerateDateTime") + .HasColumnType("datetime(6)"); + + b.Property("IsGenerated") + .HasColumnType("tinyint(1)"); + + b.Property("IsIssued") + .HasColumnType("tinyint(1)"); + + b.Property("IsRedeemed") + .HasColumnType("tinyint(1)"); + + b.Property("IssuedDate") + .HasColumnType("date"); + + b.Property("IssuedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("OperatorIdentifier") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("RecipientEmail") + .HasColumnType("longtext"); + + b.Property("RecipientMobile") + .HasColumnType("longtext"); + + b.Property("RedeemedDate") + .HasColumnType("datetime(6)"); + + b.Property("RedeemedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.Property("Value") + .HasColumnType("decimal(65,30)"); + + b.Property("VoucherCode") + .IsRequired() + .HasColumnType("varchar(255)"); + + b.HasKey("VoucherId"); + + b.HasIndex("TransactionReportingId"); + + b.HasIndex("VoucherCode"); + + b.ToTable("voucher"); + }); + + modelBuilder.Entity("EstateManagement.Database.ViewEntities.SettlementView", b => + { + b.Property("Amount") + .HasColumnType("decimal(65,30)"); + + b.Property("CalculatedValue") + .HasColumnType("decimal(65,30)"); + + b.Property("DayOfWeek") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("EstateId") + .HasColumnType("char(36)"); + + b.Property("FeeDescription") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("IsCompleted") + .HasColumnType("tinyint(1)"); + + b.Property("IsSettled") + .HasColumnType("tinyint(1)"); + + b.Property("MerchantId") + .HasColumnType("char(36)"); + + b.Property("MerchantName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("Month") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("MonthNumber") + .HasColumnType("int"); + + b.Property("OperatorIdentifier") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("SettlementDate") + .HasColumnType("datetime(6)"); + + b.Property("SettlementId") + .HasColumnType("char(36)"); + + b.Property("TransactionId") + .HasColumnType("char(36)"); + + b.Property("WeekNumber") + .HasColumnType("int"); + + b.Property("YearNumber") + .HasColumnType("int"); + + b.ToTable((string)null); + + b.ToView("uvwSettlements", (string)null); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/TransactionProcessor.Database/Migrations/MySql/20240425164125_record_operatators_at_readmodel_2.cs b/TransactionProcessor.Database/Migrations/MySql/20240425164125_record_operatators_at_readmodel_2.cs new file mode 100644 index 00000000..a10b252e --- /dev/null +++ b/TransactionProcessor.Database/Migrations/MySql/20240425164125_record_operatators_at_readmodel_2.cs @@ -0,0 +1,55 @@ +#nullable disable + +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; + +namespace TransactionProcessor.Database.Migrations.MySql +{ + /// + public partial class record_operatators_at_readmodel_2 : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropPrimaryKey( + name: "PK_estateoperator", + table: "estateoperator"); + + migrationBuilder.AlterColumn( + name: "OperatorReportingId", + table: "estateoperator", + type: "int", + nullable: false, + oldClrType: typeof(int), + oldType: "int") + .OldAnnotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn); + + migrationBuilder.AddPrimaryKey( + name: "PK_estateoperator", + table: "estateoperator", + columns: new[] { "EstateReportingId", "OperatorReportingId" }); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropPrimaryKey( + name: "PK_estateoperator", + table: "estateoperator"); + + migrationBuilder.AlterColumn( + name: "OperatorReportingId", + table: "estateoperator", + type: "int", + nullable: false, + oldClrType: typeof(int), + oldType: "int") + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn); + + migrationBuilder.AddPrimaryKey( + name: "PK_estateoperator", + table: "estateoperator", + column: "OperatorReportingId"); + } + } +} diff --git a/TransactionProcessor.Database/Migrations/MySql/20240501155336_make_voucher_operatoridentifier_nullable.Designer.cs b/TransactionProcessor.Database/Migrations/MySql/20240501155336_make_voucher_operatoridentifier_nullable.Designer.cs new file mode 100644 index 00000000..320cd60c --- /dev/null +++ b/TransactionProcessor.Database/Migrations/MySql/20240501155336_make_voucher_operatoridentifier_nullable.Designer.cs @@ -0,0 +1,1110 @@ +// + +#nullable disable + +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using TransactionProcessor.Database.Contexts; + +namespace TransactionProcessor.Database.Migrations.MySql +{ + [DbContext(typeof(EstateManagementMySqlContext))] + [Migration("20240501155336_make_voucher_operatoridentifier_nullable")] + partial class make_voucher_operatoridentifier_nullable + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.3") + .HasAnnotation("Relational:MaxIdentifierLength", 64); + + MySqlModelBuilderExtensions.AutoIncrementColumns(modelBuilder); + + modelBuilder.Entity("EstateManagement.Database.Entities.Calendar", b => + { + b.Property("Date") + .HasColumnType("datetime(6)"); + + b.Property("DayOfWeek") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("DayOfWeekNumber") + .HasColumnType("int"); + + b.Property("DayOfWeekShort") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("MonthNameLong") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("MonthNameShort") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("MonthNumber") + .HasColumnType("int"); + + b.Property("WeekNumber") + .HasColumnType("int"); + + b.Property("WeekNumberString") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("Year") + .HasColumnType("int"); + + b.Property("YearWeekNumber") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("Date"); + + b.ToTable("calendar"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Contract", b => + { + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("OperatorId") + .HasColumnType("char(36)"); + + b.Property("ContractId") + .HasColumnType("char(36)"); + + b.Property("ContractReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("ContractReportingId")); + + b.Property("Description") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("EstateReportingId", "OperatorId", "ContractId"); + + b.ToTable("contract"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.ContractProduct", b => + { + b.Property("ContractReportingId") + .HasColumnType("int"); + + b.Property("ProductId") + .HasColumnType("char(36)"); + + b.Property("ContractProductReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("ContractProductReportingId")); + + b.Property("DisplayText") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ProductName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ProductType") + .HasColumnType("int"); + + b.Property("Value") + .HasColumnType("decimal(65,30)"); + + b.HasKey("ContractReportingId", "ProductId"); + + b.ToTable("contractproduct"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.ContractProductTransactionFee", b => + { + b.Property("ContractProductReportingId") + .HasColumnType("int"); + + b.Property("TransactionFeeId") + .HasColumnType("char(36)"); + + b.Property("CalculationType") + .HasColumnType("int"); + + b.Property("Description") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("FeeType") + .HasColumnType("int"); + + b.Property("IsEnabled") + .HasColumnType("tinyint(1)"); + + b.Property("TransactionFeeReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("TransactionFeeReportingId")); + + b.Property("Value") + .HasColumnType("decimal(18,4)"); + + b.HasKey("ContractProductReportingId", "TransactionFeeId"); + + b.ToTable("contractproducttransactionfee"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Estate", b => + { + b.Property("EstateReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("EstateReportingId")); + + b.Property("CreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("EstateId") + .HasColumnType("char(36)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("Reference") + .HasColumnType("longtext"); + + b.HasKey("EstateReportingId"); + + b.HasIndex("EstateId") + .IsUnique(); + + b.ToTable("estate"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.EstateOperator", b => + { + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("OperatorReportingId") + .HasColumnType("int"); + + b.HasKey("EstateReportingId", "OperatorReportingId"); + + b.ToTable("estateoperator"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.EstateSecurityUser", b => + { + b.Property("SecurityUserId") + .HasColumnType("char(36)"); + + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("EmailAddress") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("SecurityUserId", "EstateReportingId"); + + b.ToTable("estatesecurityuser"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.File", b => + { + b.Property("FileReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("FileReportingId")); + + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("FileId") + .HasColumnType("char(36)"); + + b.Property("FileImportLogReportingId") + .HasColumnType("int"); + + b.Property("FileLocation") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("FileProfileId") + .HasColumnType("char(36)"); + + b.Property("FileReceivedDate") + .HasColumnType("date"); + + b.Property("FileReceivedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("IsCompleted") + .HasColumnType("tinyint(1)"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("UserId") + .HasColumnType("char(36)"); + + b.HasKey("FileReportingId"); + + b.HasIndex("FileId") + .IsUnique(); + + b.ToTable("file"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.FileImportLog", b => + { + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("FileImportLogReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("FileImportLogReportingId")); + + b.Property("FileImportLogId") + .HasColumnType("char(36)"); + + b.Property("ImportLogDate") + .HasColumnType("date"); + + b.Property("ImportLogDateTime") + .HasColumnType("datetime(6)"); + + b.HasKey("EstateReportingId", "FileImportLogReportingId"); + + b.HasIndex("EstateReportingId", "FileImportLogId") + .IsUnique(); + + b.ToTable("fileimportlog"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.FileImportLogFile", b => + { + b.Property("FileImportLogReportingId") + .HasColumnType("int"); + + b.Property("FileReportingId") + .HasColumnType("int"); + + b.Property("FilePath") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("FileProfileId") + .HasColumnType("char(36)"); + + b.Property("FileUploadedDate") + .HasColumnType("date"); + + b.Property("FileUploadedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("OriginalFileName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("UserId") + .HasColumnType("char(36)"); + + b.HasKey("FileImportLogReportingId", "FileReportingId"); + + b.ToTable("fileimportlogfile"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.FileLine", b => + { + b.Property("FileReportingId") + .HasColumnType("int"); + + b.Property("LineNumber") + .HasColumnType("int"); + + b.Property("FileLineData") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("Status") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.HasKey("FileReportingId", "LineNumber") + .HasAnnotation("SqlServer:Clustered", true); + + b.HasIndex("TransactionReportingId"); + + b.ToTable("fileline"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Float", b => + { + b.Property("FloatId") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("ContractId") + .HasColumnType("char(36)"); + + b.Property("CreatedDate") + .HasColumnType("date"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("EstateId") + .HasColumnType("char(36)"); + + b.Property("ProductId") + .HasColumnType("char(36)"); + + b.HasKey("FloatId") + .HasAnnotation("SqlServer:Clustered", false); + + b.HasIndex("CreatedDate") + .HasAnnotation("SqlServer:Clustered", true); + + b.ToTable("Floats"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.FloatActivity", b => + { + b.Property("EventId") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("ActivityDate") + .HasColumnType("date"); + + b.Property("ActivityDateTime") + .HasColumnType("datetime(6)"); + + b.Property("Amount") + .HasColumnType("decimal(65,30)"); + + b.Property("CostPrice") + .HasColumnType("decimal(65,30)"); + + b.Property("CreditOrDebit") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("FloatId") + .HasColumnType("char(36)"); + + b.HasKey("EventId") + .HasAnnotation("SqlServer:Clustered", false); + + b.HasIndex("ActivityDate") + .HasAnnotation("SqlServer:Clustered", true); + + b.ToTable("FloatActivity"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Merchant", b => + { + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("MerchantReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("MerchantReportingId")); + + b.Property("CreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("LastSaleDate") + .HasColumnType("date"); + + b.Property("LastSaleDateTime") + .HasColumnType("datetime(6)"); + + b.Property("LastStatementGenerated") + .HasColumnType("datetime(6)"); + + b.Property("MerchantId") + .HasColumnType("char(36)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("Reference") + .HasColumnType("longtext"); + + b.Property("SettlementSchedule") + .HasColumnType("int"); + + b.HasKey("EstateReportingId", "MerchantReportingId"); + + b.HasIndex("EstateReportingId", "MerchantId") + .IsUnique(); + + b.ToTable("merchant"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantAddress", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("AddressId") + .HasColumnType("char(36)"); + + b.Property("AddressLine1") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("AddressLine2") + .HasColumnType("longtext"); + + b.Property("AddressLine3") + .HasColumnType("longtext"); + + b.Property("AddressLine4") + .HasColumnType("longtext"); + + b.Property("Country") + .HasColumnType("longtext"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("PostalCode") + .HasColumnType("longtext"); + + b.Property("Region") + .HasColumnType("longtext"); + + b.Property("Town") + .HasColumnType("longtext"); + + b.HasKey("MerchantReportingId", "AddressId"); + + b.ToTable("merchantaddress"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantContact", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("ContactId") + .HasColumnType("char(36)"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("EmailAddress") + .HasColumnType("longtext"); + + b.Property("Name") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("PhoneNumber") + .HasColumnType("longtext"); + + b.HasKey("MerchantReportingId", "ContactId"); + + b.ToTable("merchantcontact"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantContract", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("ContractReportingId") + .HasColumnType("int"); + + b.Property("IsDeleted") + .HasColumnType("tinyint(1)"); + + b.HasKey("MerchantReportingId", "ContractReportingId"); + + b.ToTable("MerchantContracts"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantDevice", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("DeviceId") + .HasColumnType("char(36)"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("DeviceIdentifier") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("MerchantReportingId", "DeviceId"); + + b.ToTable("merchantdevice"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantOperator", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("OperatorId") + .HasColumnType("char(36)"); + + b.Property("IsDeleted") + .HasColumnType("tinyint(1)"); + + b.Property("MerchantNumber") + .HasColumnType("longtext"); + + b.Property("Name") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("TerminalNumber") + .HasColumnType("longtext"); + + b.HasKey("MerchantReportingId", "OperatorId"); + + b.ToTable("merchantoperator"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantSecurityUser", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("SecurityUserId") + .HasColumnType("char(36)"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("EmailAddress") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("MerchantReportingId", "SecurityUserId"); + + b.ToTable("merchantsecurityuser"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantSettlementFee", b => + { + b.Property("SettlementReportingId") + .HasColumnType("int"); + + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.Property("TransactionFeeReportingId") + .HasColumnType("int"); + + b.Property("CalculatedValue") + .HasColumnType("decimal(65,30)"); + + b.Property("FeeCalculatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("FeeValue") + .HasColumnType("decimal(65,30)"); + + b.Property("IsSettled") + .HasColumnType("tinyint(1)"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.HasKey("SettlementReportingId", "TransactionReportingId", "TransactionFeeReportingId"); + + b.HasIndex("TransactionReportingId"); + + b.ToTable("merchantsettlementfee"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Operator", b => + { + b.Property("OperatorReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("OperatorReportingId")); + + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("Name") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("OperatorId") + .HasColumnType("char(36)"); + + b.Property("RequireCustomMerchantNumber") + .HasColumnType("tinyint(1)"); + + b.Property("RequireCustomTerminalNumber") + .HasColumnType("tinyint(1)"); + + b.HasKey("OperatorReportingId"); + + b.HasIndex("OperatorId") + .IsUnique(); + + b.ToTable("operator"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Reconciliation", b => + { + b.Property("TransactionReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("TransactionReportingId")); + + b.Property("DeviceIdentifier") + .HasColumnType("longtext"); + + b.Property("IsAuthorised") + .HasColumnType("tinyint(1)"); + + b.Property("IsCompleted") + .HasColumnType("tinyint(1)"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("ResponseCode") + .HasColumnType("longtext"); + + b.Property("ResponseMessage") + .HasColumnType("longtext"); + + b.Property("TransactionCount") + .HasColumnType("int"); + + b.Property("TransactionDate") + .HasColumnType("date"); + + b.Property("TransactionDateTime") + .HasColumnType("datetime(6)"); + + b.Property("TransactionId") + .HasColumnType("char(36)"); + + b.Property("TransactionTime") + .HasColumnType("time(6)"); + + b.Property("TransactionValue") + .HasColumnType("decimal(65,30)"); + + b.HasKey("TransactionReportingId") + .HasAnnotation("SqlServer:Clustered", false); + + b.HasIndex("TransactionDate", "MerchantReportingId") + .HasAnnotation("SqlServer:Clustered", true); + + b.HasIndex("TransactionId", "MerchantReportingId") + .IsUnique() + .HasAnnotation("SqlServer:Clustered", false); + + b.ToTable("reconciliation"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.ResponseCodes", b => + { + b.Property("ResponseCode") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("ResponseCode")); + + b.Property("Description") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("ResponseCode"); + + b.ToTable("responsecodes"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Settlement", b => + { + b.Property("SettlementReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("SettlementReportingId")); + + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("IsCompleted") + .HasColumnType("tinyint(1)"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("ProcessingStarted") + .HasColumnType("tinyint(1)"); + + b.Property("ProcessingStartedDateTIme") + .HasColumnType("datetime(6)"); + + b.Property("SettlementDate") + .HasColumnType("date"); + + b.Property("SettlementId") + .HasColumnType("char(36)"); + + b.HasKey("SettlementReportingId") + .HasAnnotation("SqlServer:Clustered", false); + + b.HasIndex("EstateReportingId", "SettlementId") + .IsUnique() + .HasAnnotation("SqlServer:Clustered", false); + + b.HasIndex("SettlementDate", "EstateReportingId") + .HasAnnotation("SqlServer:Clustered", true); + + b.ToTable("settlement"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.StatementHeader", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("StatementId") + .HasColumnType("char(36)"); + + b.Property("StatementCreatedDate") + .HasColumnType("date"); + + b.Property("StatementCreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("StatementGeneratedDate") + .HasColumnType("date"); + + b.Property("StatementGeneratedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("StatementReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("StatementReportingId")); + + b.HasKey("MerchantReportingId", "StatementId") + .HasAnnotation("SqlServer:Clustered", false); + + b.HasIndex("MerchantReportingId", "StatementGeneratedDate") + .HasAnnotation("SqlServer:Clustered", true); + + b.ToTable("statementheader"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.StatementLine", b => + { + b.Property("StatementReportingId") + .HasColumnType("int"); + + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.Property("ActivityDateTime") + .HasColumnType("datetime(6)"); + + b.Property("ActivityType") + .HasColumnType("int"); + + b.Property("ActivityDate") + .HasColumnType("date"); + + b.Property("ActivityDescription") + .HasColumnType("longtext"); + + b.Property("InAmount") + .HasColumnType("decimal(65,30)"); + + b.Property("OutAmount") + .HasColumnType("decimal(65,30)"); + + b.HasKey("StatementReportingId", "TransactionReportingId", "ActivityDateTime", "ActivityType"); + + b.ToTable("statementline"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Transaction", b => + { + b.Property("TransactionReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("TransactionReportingId")); + + b.Property("AuthorisationCode") + .HasColumnType("longtext"); + + b.Property("ContractProductReportingId") + .HasColumnType("int"); + + b.Property("ContractReportingId") + .HasColumnType("int"); + + b.Property("DeviceIdentifier") + .HasColumnType("longtext"); + + b.Property("EstateOperatorReportingId") + .HasColumnType("int"); + + b.Property("IsAuthorised") + .HasColumnType("tinyint(1)"); + + b.Property("IsCompleted") + .HasColumnType("tinyint(1)"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("ResponseCode") + .HasColumnType("longtext"); + + b.Property("ResponseMessage") + .HasColumnType("longtext"); + + b.Property("TransactionAmount") + .HasColumnType("decimal(65,30)"); + + b.Property("TransactionDate") + .HasColumnType("date"); + + b.Property("TransactionDateTime") + .HasColumnType("datetime(6)"); + + b.Property("TransactionId") + .HasColumnType("char(36)"); + + b.Property("TransactionNumber") + .HasColumnType("longtext"); + + b.Property("TransactionReference") + .HasColumnType("longtext"); + + b.Property("TransactionSource") + .HasColumnType("int"); + + b.Property("TransactionTime") + .HasColumnType("time(6)"); + + b.Property("TransactionType") + .HasColumnType("longtext"); + + b.HasKey("TransactionReportingId") + .HasAnnotation("SqlServer:Clustered", false); + + b.HasIndex("TransactionId") + .IsUnique() + .HasAnnotation("SqlServer:Clustered", false); + + b.HasIndex("TransactionDate", "MerchantReportingId") + .HasAnnotation("SqlServer:Clustered", true); + + b.HasIndex("TransactionId", "MerchantReportingId") + .IsUnique() + .HasAnnotation("SqlServer:Clustered", false); + + b.ToTable("transaction"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.TransactionAdditionalRequestData", b => + { + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.Property("Amount") + .HasColumnType("longtext"); + + b.Property("CustomerAccountNumber") + .HasColumnType("longtext"); + + b.HasKey("TransactionReportingId"); + + b.ToTable("transactionadditionalrequestdata"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.TransactionAdditionalResponseData", b => + { + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.HasKey("TransactionReportingId"); + + b.ToTable("transactionadditionalresponsedata"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Voucher", b => + { + b.Property("VoucherId") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("ExpiryDate") + .HasColumnType("date"); + + b.Property("ExpiryDateTime") + .HasColumnType("datetime(6)"); + + b.Property("GenerateDate") + .HasColumnType("date"); + + b.Property("GenerateDateTime") + .HasColumnType("datetime(6)"); + + b.Property("IsGenerated") + .HasColumnType("tinyint(1)"); + + b.Property("IsIssued") + .HasColumnType("tinyint(1)"); + + b.Property("IsRedeemed") + .HasColumnType("tinyint(1)"); + + b.Property("IssuedDate") + .HasColumnType("date"); + + b.Property("IssuedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("OperatorIdentifier") + .HasColumnType("longtext"); + + b.Property("RecipientEmail") + .HasColumnType("longtext"); + + b.Property("RecipientMobile") + .HasColumnType("longtext"); + + b.Property("RedeemedDate") + .HasColumnType("datetime(6)"); + + b.Property("RedeemedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.Property("Value") + .HasColumnType("decimal(65,30)"); + + b.Property("VoucherCode") + .IsRequired() + .HasColumnType("varchar(255)"); + + b.HasKey("VoucherId"); + + b.HasIndex("TransactionReportingId"); + + b.HasIndex("VoucherCode"); + + b.ToTable("voucher"); + }); + + modelBuilder.Entity("EstateManagement.Database.ViewEntities.SettlementView", b => + { + b.Property("Amount") + .HasColumnType("decimal(65,30)"); + + b.Property("CalculatedValue") + .HasColumnType("decimal(65,30)"); + + b.Property("DayOfWeek") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("EstateId") + .HasColumnType("char(36)"); + + b.Property("FeeDescription") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("IsCompleted") + .HasColumnType("tinyint(1)"); + + b.Property("IsSettled") + .HasColumnType("tinyint(1)"); + + b.Property("MerchantId") + .HasColumnType("char(36)"); + + b.Property("MerchantName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("Month") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("MonthNumber") + .HasColumnType("int"); + + b.Property("OperatorIdentifier") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("SettlementDate") + .HasColumnType("datetime(6)"); + + b.Property("SettlementId") + .HasColumnType("char(36)"); + + b.Property("TransactionId") + .HasColumnType("char(36)"); + + b.Property("WeekNumber") + .HasColumnType("int"); + + b.Property("YearNumber") + .HasColumnType("int"); + + b.ToTable((string)null); + + b.ToView("uvwSettlements", (string)null); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/TransactionProcessor.Database/Migrations/MySql/20240501155336_make_voucher_operatoridentifier_nullable.cs b/TransactionProcessor.Database/Migrations/MySql/20240501155336_make_voucher_operatoridentifier_nullable.cs new file mode 100644 index 00000000..74129edf --- /dev/null +++ b/TransactionProcessor.Database/Migrations/MySql/20240501155336_make_voucher_operatoridentifier_nullable.cs @@ -0,0 +1,46 @@ +#nullable disable + +using Microsoft.EntityFrameworkCore.Migrations; + +namespace TransactionProcessor.Database.Migrations.MySql +{ + /// + public partial class make_voucher_operatoridentifier_nullable : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterColumn( + name: "OperatorIdentifier", + table: "voucher", + type: "longtext", + nullable: true, + oldClrType: typeof(string), + oldType: "longtext") + .Annotation("MySql:CharSet", "utf8mb4") + .OldAnnotation("MySql:CharSet", "utf8mb4"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.UpdateData( + table: "voucher", + keyColumn: "OperatorIdentifier", + keyValue: null, + column: "OperatorIdentifier", + value: ""); + + migrationBuilder.AlterColumn( + name: "OperatorIdentifier", + table: "voucher", + type: "longtext", + nullable: false, + oldClrType: typeof(string), + oldType: "longtext", + oldNullable: true) + .Annotation("MySql:CharSet", "utf8mb4") + .OldAnnotation("MySql:CharSet", "utf8mb4"); + } + } +} diff --git a/TransactionProcessor.Database/Migrations/MySql/20240606143402_20240605061637_remove_reportingids_from_transaction.Designer.cs b/TransactionProcessor.Database/Migrations/MySql/20240606143402_20240605061637_remove_reportingids_from_transaction.Designer.cs new file mode 100644 index 00000000..97194d1d --- /dev/null +++ b/TransactionProcessor.Database/Migrations/MySql/20240606143402_20240605061637_remove_reportingids_from_transaction.Designer.cs @@ -0,0 +1,1098 @@ +// + +#nullable disable + +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using TransactionProcessor.Database.Contexts; + +namespace TransactionProcessor.Database.Migrations.MySql +{ + [DbContext(typeof(EstateManagementMySqlContext))] + [Migration("20240606143402_20240605061637_remove_reportingids_from_transaction")] + partial class _20240605061637_remove_reportingids_from_transaction + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.3") + .HasAnnotation("Relational:MaxIdentifierLength", 64); + + MySqlModelBuilderExtensions.AutoIncrementColumns(modelBuilder); + + modelBuilder.Entity("EstateManagement.Database.Entities.Calendar", b => + { + b.Property("Date") + .HasColumnType("datetime(6)"); + + b.Property("DayOfWeek") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("DayOfWeekNumber") + .HasColumnType("int"); + + b.Property("DayOfWeekShort") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("MonthNameLong") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("MonthNameShort") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("MonthNumber") + .HasColumnType("int"); + + b.Property("WeekNumber") + .HasColumnType("int"); + + b.Property("WeekNumberString") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("Year") + .HasColumnType("int"); + + b.Property("YearWeekNumber") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("Date"); + + b.ToTable("calendar"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Contract", b => + { + b.Property("EstateId") + .HasColumnType("char(36)"); + + b.Property("OperatorId") + .HasColumnType("char(36)"); + + b.Property("ContractId") + .HasColumnType("char(36)"); + + b.Property("ContractReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("ContractReportingId")); + + b.Property("Description") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("EstateId", "OperatorId", "ContractId"); + + b.ToTable("contract"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.ContractProduct", b => + { + b.Property("ContractProductReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("ContractProductReportingId")); + + b.Property("ContractId") + .HasColumnType("char(36)"); + + b.Property("ContractProductId") + .HasColumnType("char(36)"); + + b.Property("DisplayText") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ProductName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ProductType") + .HasColumnType("int"); + + b.Property("Value") + .HasColumnType("decimal(65,30)"); + + b.HasKey("ContractProductReportingId"); + + b.HasIndex("ContractProductId", "ContractId") + .IsUnique(); + + b.ToTable("contractproduct"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.ContractProductTransactionFee", b => + { + b.Property("ContractProductTransactionFeeReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("ContractProductTransactionFeeReportingId")); + + b.Property("CalculationType") + .HasColumnType("int"); + + b.Property("ContractProductId") + .HasColumnType("char(36)"); + + b.Property("ContractProductTransactionFeeId") + .HasColumnType("char(36)"); + + b.Property("Description") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("FeeType") + .HasColumnType("int"); + + b.Property("IsEnabled") + .HasColumnType("tinyint(1)"); + + b.Property("Value") + .HasColumnType("decimal(18,4)"); + + b.HasKey("ContractProductTransactionFeeReportingId"); + + b.HasIndex("ContractProductTransactionFeeId", "ContractProductId") + .IsUnique(); + + b.ToTable("contractproducttransactionfee"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Estate", b => + { + b.Property("EstateReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("EstateReportingId")); + + b.Property("CreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("EstateId") + .HasColumnType("char(36)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("Reference") + .HasColumnType("longtext"); + + b.HasKey("EstateReportingId"); + + b.HasIndex("EstateId") + .IsUnique(); + + b.ToTable("estate"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.EstateSecurityUser", b => + { + b.Property("SecurityUserId") + .HasColumnType("char(36)"); + + b.Property("EstateId") + .HasColumnType("char(36)"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("EmailAddress") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("SecurityUserId", "EstateId"); + + b.ToTable("estatesecurityuser"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.File", b => + { + b.Property("FileReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("FileReportingId")); + + b.Property("EstateId") + .HasColumnType("char(36)"); + + b.Property("FileId") + .HasColumnType("char(36)"); + + b.Property("FileImportLogId") + .HasColumnType("char(36)"); + + b.Property("FileLocation") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("FileProfileId") + .HasColumnType("char(36)"); + + b.Property("FileReceivedDate") + .HasColumnType("date"); + + b.Property("FileReceivedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("IsCompleted") + .HasColumnType("tinyint(1)"); + + b.Property("MerchantId") + .HasColumnType("char(36)"); + + b.Property("UserId") + .HasColumnType("char(36)"); + + b.HasKey("FileReportingId"); + + b.HasIndex("FileId") + .IsUnique(); + + b.ToTable("file"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.FileImportLog", b => + { + b.Property("EstateId") + .HasColumnType("char(36)"); + + b.Property("FileImportLogReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("FileImportLogReportingId")); + + b.Property("FileImportLogId") + .HasColumnType("char(36)"); + + b.Property("ImportLogDate") + .HasColumnType("date"); + + b.Property("ImportLogDateTime") + .HasColumnType("datetime(6)"); + + b.HasKey("EstateId", "FileImportLogReportingId"); + + b.HasIndex("EstateId", "FileImportLogId") + .IsUnique(); + + b.ToTable("fileimportlog"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.FileImportLogFile", b => + { + b.Property("FileImportLogId") + .HasColumnType("char(36)"); + + b.Property("FileId") + .HasColumnType("char(36)"); + + b.Property("FilePath") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("FileProfileId") + .HasColumnType("char(36)"); + + b.Property("FileUploadedDate") + .HasColumnType("date"); + + b.Property("FileUploadedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("MerchantId") + .HasColumnType("char(36)"); + + b.Property("OriginalFileName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("UserId") + .HasColumnType("char(36)"); + + b.HasKey("FileImportLogId", "FileId"); + + b.ToTable("fileimportlogfile"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.FileLine", b => + { + b.Property("FileId") + .HasColumnType("char(36)"); + + b.Property("LineNumber") + .HasColumnType("int"); + + b.Property("FileLineData") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("Status") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("TransactionId") + .HasColumnType("char(36)"); + + b.HasKey("FileId", "LineNumber") + .HasAnnotation("SqlServer:Clustered", true); + + b.ToTable("fileline"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Float", b => + { + b.Property("FloatId") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("ContractId") + .HasColumnType("char(36)"); + + b.Property("CreatedDate") + .HasColumnType("date"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("EstateId") + .HasColumnType("char(36)"); + + b.Property("ProductId") + .HasColumnType("char(36)"); + + b.HasKey("FloatId") + .HasAnnotation("SqlServer:Clustered", false); + + b.HasIndex("CreatedDate") + .HasAnnotation("SqlServer:Clustered", true); + + b.ToTable("Floats"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.FloatActivity", b => + { + b.Property("EventId") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("ActivityDate") + .HasColumnType("date"); + + b.Property("ActivityDateTime") + .HasColumnType("datetime(6)"); + + b.Property("Amount") + .HasColumnType("decimal(65,30)"); + + b.Property("CostPrice") + .HasColumnType("decimal(65,30)"); + + b.Property("CreditOrDebit") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("FloatId") + .HasColumnType("char(36)"); + + b.HasKey("EventId") + .HasAnnotation("SqlServer:Clustered", false); + + b.HasIndex("ActivityDate") + .HasAnnotation("SqlServer:Clustered", true); + + b.ToTable("FloatActivity"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Merchant", b => + { + b.Property("MerchantReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("MerchantReportingId")); + + b.Property("CreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("EstateId") + .HasColumnType("char(36)"); + + b.Property("LastSaleDate") + .HasColumnType("date"); + + b.Property("LastSaleDateTime") + .HasColumnType("datetime(6)"); + + b.Property("LastStatementGenerated") + .HasColumnType("datetime(6)"); + + b.Property("MerchantId") + .HasColumnType("char(36)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("Reference") + .HasColumnType("longtext"); + + b.Property("SettlementSchedule") + .HasColumnType("int"); + + b.HasKey("MerchantReportingId"); + + b.HasIndex("EstateId", "MerchantId") + .IsUnique(); + + b.ToTable("merchant"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantAddress", b => + { + b.Property("MerchantId") + .HasColumnType("char(36)"); + + b.Property("AddressId") + .HasColumnType("char(36)"); + + b.Property("AddressLine1") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("AddressLine2") + .HasColumnType("longtext"); + + b.Property("AddressLine3") + .HasColumnType("longtext"); + + b.Property("AddressLine4") + .HasColumnType("longtext"); + + b.Property("Country") + .HasColumnType("longtext"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("PostalCode") + .HasColumnType("longtext"); + + b.Property("Region") + .HasColumnType("longtext"); + + b.Property("Town") + .HasColumnType("longtext"); + + b.HasKey("MerchantId", "AddressId"); + + b.ToTable("merchantaddress"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantContact", b => + { + b.Property("MerchantId") + .HasColumnType("char(36)"); + + b.Property("ContactId") + .HasColumnType("char(36)"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("EmailAddress") + .HasColumnType("longtext"); + + b.Property("Name") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("PhoneNumber") + .HasColumnType("longtext"); + + b.HasKey("MerchantId", "ContactId"); + + b.ToTable("merchantcontact"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantContract", b => + { + b.Property("MerchantId") + .HasColumnType("char(36)"); + + b.Property("ContractId") + .HasColumnType("char(36)"); + + b.Property("IsDeleted") + .HasColumnType("tinyint(1)"); + + b.HasKey("MerchantId", "ContractId"); + + b.ToTable("MerchantContracts"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantDevice", b => + { + b.Property("MerchantId") + .HasColumnType("char(36)"); + + b.Property("DeviceId") + .HasColumnType("char(36)"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("DeviceIdentifier") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("MerchantId", "DeviceId"); + + b.ToTable("merchantdevice"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantOperator", b => + { + b.Property("MerchantId") + .HasColumnType("char(36)"); + + b.Property("OperatorId") + .HasColumnType("char(36)"); + + b.Property("IsDeleted") + .HasColumnType("tinyint(1)"); + + b.Property("MerchantNumber") + .HasColumnType("longtext"); + + b.Property("Name") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("TerminalNumber") + .HasColumnType("longtext"); + + b.HasKey("MerchantId", "OperatorId"); + + b.ToTable("merchantoperator"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantSecurityUser", b => + { + b.Property("MerchantId") + .HasColumnType("char(36)"); + + b.Property("SecurityUserId") + .HasColumnType("char(36)"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("EmailAddress") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("MerchantId", "SecurityUserId"); + + b.ToTable("merchantsecurityuser"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantSettlementFee", b => + { + b.Property("SettlementId") + .HasColumnType("char(36)"); + + b.Property("TransactionId") + .HasColumnType("char(36)"); + + b.Property("ContractProductTransactionFeeId") + .HasColumnType("char(36)"); + + b.Property("CalculatedValue") + .HasColumnType("decimal(65,30)"); + + b.Property("FeeCalculatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("FeeValue") + .HasColumnType("decimal(65,30)"); + + b.Property("IsSettled") + .HasColumnType("tinyint(1)"); + + b.Property("MerchantId") + .HasColumnType("char(36)"); + + b.HasKey("SettlementId", "TransactionId", "ContractProductTransactionFeeId"); + + b.ToTable("merchantsettlementfee"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Operator", b => + { + b.Property("OperatorReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("OperatorReportingId")); + + b.Property("EstateId") + .HasColumnType("char(36)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("OperatorId") + .HasColumnType("char(36)"); + + b.Property("RequireCustomMerchantNumber") + .HasColumnType("tinyint(1)"); + + b.Property("RequireCustomTerminalNumber") + .HasColumnType("tinyint(1)"); + + b.HasKey("OperatorReportingId"); + + b.HasIndex("OperatorId") + .IsUnique(); + + b.ToTable("operator"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Reconciliation", b => + { + b.Property("TransactionReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("TransactionReportingId")); + + b.Property("DeviceIdentifier") + .HasColumnType("longtext"); + + b.Property("IsAuthorised") + .HasColumnType("tinyint(1)"); + + b.Property("IsCompleted") + .HasColumnType("tinyint(1)"); + + b.Property("MerchantId") + .HasColumnType("char(36)"); + + b.Property("ResponseCode") + .HasColumnType("longtext"); + + b.Property("ResponseMessage") + .HasColumnType("longtext"); + + b.Property("TransactionCount") + .HasColumnType("int"); + + b.Property("TransactionDate") + .HasColumnType("date"); + + b.Property("TransactionDateTime") + .HasColumnType("datetime(6)"); + + b.Property("TransactionId") + .HasColumnType("char(36)"); + + b.Property("TransactionTime") + .HasColumnType("time(6)"); + + b.Property("TransactionValue") + .HasColumnType("decimal(65,30)"); + + b.HasKey("TransactionReportingId") + .HasAnnotation("SqlServer:Clustered", false); + + b.HasIndex("TransactionDate") + .HasAnnotation("SqlServer:Clustered", true); + + b.HasIndex("TransactionId", "MerchantId") + .IsUnique() + .HasAnnotation("SqlServer:Clustered", false); + + b.ToTable("reconciliation"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.ResponseCodes", b => + { + b.Property("ResponseCode") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("ResponseCode")); + + b.Property("Description") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("ResponseCode"); + + b.ToTable("responsecodes"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Settlement", b => + { + b.Property("SettlementReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("SettlementReportingId")); + + b.Property("EstateId") + .HasColumnType("char(36)"); + + b.Property("IsCompleted") + .HasColumnType("tinyint(1)"); + + b.Property("MerchantId") + .HasColumnType("char(36)"); + + b.Property("ProcessingStarted") + .HasColumnType("tinyint(1)"); + + b.Property("ProcessingStartedDateTIme") + .HasColumnType("datetime(6)"); + + b.Property("SettlementDate") + .HasColumnType("date"); + + b.Property("SettlementId") + .HasColumnType("char(36)"); + + b.HasKey("SettlementReportingId") + .HasAnnotation("SqlServer:Clustered", false); + + b.HasIndex("SettlementDate") + .HasAnnotation("SqlServer:Clustered", true); + + b.HasIndex("EstateId", "SettlementId") + .IsUnique() + .HasAnnotation("SqlServer:Clustered", false); + + b.ToTable("settlement"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.StatementHeader", b => + { + b.Property("MerchantId") + .HasColumnType("char(36)"); + + b.Property("StatementId") + .HasColumnType("char(36)"); + + b.Property("StatementCreatedDate") + .HasColumnType("date"); + + b.Property("StatementCreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("StatementGeneratedDate") + .HasColumnType("date"); + + b.Property("StatementGeneratedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("StatementReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("StatementReportingId")); + + b.HasKey("MerchantId", "StatementId") + .HasAnnotation("SqlServer:Clustered", false); + + b.HasIndex("StatementGeneratedDate") + .HasAnnotation("SqlServer:Clustered", true); + + b.ToTable("statementheader"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.StatementLine", b => + { + b.Property("StatementId") + .HasColumnType("char(36)"); + + b.Property("TransactionId") + .HasColumnType("char(36)"); + + b.Property("ActivityDateTime") + .HasColumnType("datetime(6)"); + + b.Property("ActivityType") + .HasColumnType("int"); + + b.Property("ActivityDate") + .HasColumnType("date"); + + b.Property("ActivityDescription") + .HasColumnType("longtext"); + + b.Property("InAmount") + .HasColumnType("decimal(65,30)"); + + b.Property("OutAmount") + .HasColumnType("decimal(65,30)"); + + b.HasKey("StatementId", "TransactionId", "ActivityDateTime", "ActivityType"); + + b.ToTable("statementline"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Transaction", b => + { + b.Property("TransactionReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("TransactionReportingId")); + + b.Property("AuthorisationCode") + .HasColumnType("longtext"); + + b.Property("ContractId") + .HasColumnType("char(36)"); + + b.Property("ContractProductId") + .HasColumnType("char(36)"); + + b.Property("DeviceIdentifier") + .HasColumnType("longtext"); + + b.Property("IsAuthorised") + .HasColumnType("tinyint(1)"); + + b.Property("IsCompleted") + .HasColumnType("tinyint(1)"); + + b.Property("MerchantId") + .HasColumnType("char(36)"); + + b.Property("OperatorId") + .HasColumnType("char(36)"); + + b.Property("ResponseCode") + .HasColumnType("longtext"); + + b.Property("ResponseMessage") + .HasColumnType("longtext"); + + b.Property("TransactionAmount") + .HasColumnType("decimal(65,30)"); + + b.Property("TransactionDate") + .HasColumnType("date"); + + b.Property("TransactionDateTime") + .HasColumnType("datetime(6)"); + + b.Property("TransactionId") + .HasColumnType("char(36)"); + + b.Property("TransactionNumber") + .HasColumnType("longtext"); + + b.Property("TransactionReference") + .HasColumnType("longtext"); + + b.Property("TransactionSource") + .HasColumnType("int"); + + b.Property("TransactionTime") + .HasColumnType("time(6)"); + + b.Property("TransactionType") + .HasColumnType("longtext"); + + b.HasKey("TransactionReportingId") + .HasAnnotation("SqlServer:Clustered", false); + + b.HasIndex("TransactionDate") + .HasAnnotation("SqlServer:Clustered", true); + + b.HasIndex("TransactionId") + .IsUnique() + .HasAnnotation("SqlServer:Clustered", false); + + b.ToTable("transaction"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.TransactionAdditionalRequestData", b => + { + b.Property("TransactionId") + .HasColumnType("char(36)"); + + b.Property("Amount") + .HasColumnType("longtext"); + + b.Property("CustomerAccountNumber") + .HasColumnType("longtext"); + + b.HasKey("TransactionId"); + + b.ToTable("transactionadditionalrequestdata"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.TransactionAdditionalResponseData", b => + { + b.Property("TransactionId") + .HasColumnType("char(36)"); + + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.HasKey("TransactionId"); + + b.ToTable("transactionadditionalresponsedata"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Voucher", b => + { + b.Property("VoucherId") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("ExpiryDate") + .HasColumnType("date"); + + b.Property("ExpiryDateTime") + .HasColumnType("datetime(6)"); + + b.Property("GenerateDate") + .HasColumnType("date"); + + b.Property("GenerateDateTime") + .HasColumnType("datetime(6)"); + + b.Property("IsGenerated") + .HasColumnType("tinyint(1)"); + + b.Property("IsIssued") + .HasColumnType("tinyint(1)"); + + b.Property("IsRedeemed") + .HasColumnType("tinyint(1)"); + + b.Property("IssuedDate") + .HasColumnType("date"); + + b.Property("IssuedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("OperatorIdentifier") + .HasColumnType("longtext"); + + b.Property("RecipientEmail") + .HasColumnType("longtext"); + + b.Property("RecipientMobile") + .HasColumnType("longtext"); + + b.Property("RedeemedDate") + .HasColumnType("datetime(6)"); + + b.Property("RedeemedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("TransactionId") + .HasColumnType("char(36)"); + + b.Property("Value") + .HasColumnType("decimal(65,30)"); + + b.Property("VoucherCode") + .IsRequired() + .HasColumnType("varchar(255)"); + + b.HasKey("VoucherId"); + + b.HasIndex("TransactionId"); + + b.HasIndex("VoucherCode"); + + b.ToTable("voucher"); + }); + + modelBuilder.Entity("EstateManagement.Database.ViewEntities.SettlementView", b => + { + b.Property("Amount") + .HasColumnType("decimal(65,30)"); + + b.Property("CalculatedValue") + .HasColumnType("decimal(65,30)"); + + b.Property("DayOfWeek") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("EstateId") + .HasColumnType("char(36)"); + + b.Property("FeeDescription") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("IsCompleted") + .HasColumnType("tinyint(1)"); + + b.Property("IsSettled") + .HasColumnType("tinyint(1)"); + + b.Property("MerchantId") + .HasColumnType("char(36)"); + + b.Property("MerchantName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("Month") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("MonthNumber") + .HasColumnType("int"); + + b.Property("OperatorIdentifier") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("SettlementDate") + .HasColumnType("datetime(6)"); + + b.Property("SettlementId") + .HasColumnType("char(36)"); + + b.Property("TransactionId") + .HasColumnType("char(36)"); + + b.Property("WeekNumber") + .HasColumnType("int"); + + b.Property("YearNumber") + .HasColumnType("int"); + + b.ToTable((string)null); + + b.ToView("uvwSettlements", (string)null); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/TransactionProcessor.Database/Migrations/MySql/20240606143402_20240605061637_remove_reportingids_from_transaction.cs b/TransactionProcessor.Database/Migrations/MySql/20240606143402_20240605061637_remove_reportingids_from_transaction.cs new file mode 100644 index 00000000..2844f5ef --- /dev/null +++ b/TransactionProcessor.Database/Migrations/MySql/20240606143402_20240605061637_remove_reportingids_from_transaction.cs @@ -0,0 +1,1510 @@ +#nullable disable + +using Microsoft.EntityFrameworkCore.Migrations; + +namespace TransactionProcessor.Database.Migrations.MySql +{ + /// + public partial class _20240605061637_remove_reportingids_from_transaction : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "estateoperator"); + + migrationBuilder.DropIndex( + name: "IX_voucher_TransactionReportingId", + table: "voucher"); + + migrationBuilder.DropPrimaryKey( + name: "PK_transactionadditionalresponsedata", + table: "transactionadditionalresponsedata"); + + migrationBuilder.DropPrimaryKey( + name: "PK_transactionadditionalrequestdata", + table: "transactionadditionalrequestdata"); + + migrationBuilder.DropIndex( + name: "IX_transaction_TransactionDate_MerchantReportingId", + table: "transaction"); + + migrationBuilder.DropIndex( + name: "IX_transaction_TransactionId_MerchantReportingId", + table: "transaction"); + + migrationBuilder.DropPrimaryKey( + name: "PK_statementline", + table: "statementline"); + + migrationBuilder.DropPrimaryKey( + name: "PK_statementheader", + table: "statementheader"); + + migrationBuilder.DropIndex( + name: "IX_statementheader_MerchantReportingId_StatementGeneratedDate", + table: "statementheader"); + + migrationBuilder.DropIndex( + name: "IX_settlement_EstateReportingId_SettlementId", + table: "settlement"); + + migrationBuilder.DropIndex( + name: "IX_settlement_SettlementDate_EstateReportingId", + table: "settlement"); + + migrationBuilder.DropIndex( + name: "IX_reconciliation_TransactionDate_MerchantReportingId", + table: "reconciliation"); + + migrationBuilder.DropIndex( + name: "IX_reconciliation_TransactionId_MerchantReportingId", + table: "reconciliation"); + + migrationBuilder.DropPrimaryKey( + name: "PK_merchantsettlementfee", + table: "merchantsettlementfee"); + + migrationBuilder.DropIndex( + name: "IX_merchantsettlementfee_TransactionReportingId", + table: "merchantsettlementfee"); + + migrationBuilder.DropPrimaryKey( + name: "PK_merchantsecurityuser", + table: "merchantsecurityuser"); + + migrationBuilder.DropPrimaryKey( + name: "PK_merchantoperator", + table: "merchantoperator"); + + migrationBuilder.DropPrimaryKey( + name: "PK_merchantdevice", + table: "merchantdevice"); + + migrationBuilder.DropPrimaryKey( + name: "PK_MerchantContracts", + table: "MerchantContracts"); + + migrationBuilder.DropPrimaryKey( + name: "PK_merchantcontact", + table: "merchantcontact"); + + migrationBuilder.DropPrimaryKey( + name: "PK_merchantaddress", + table: "merchantaddress"); + + migrationBuilder.DropPrimaryKey( + name: "PK_merchant", + table: "merchant"); + + migrationBuilder.DropIndex( + name: "IX_merchant_EstateReportingId_MerchantId", + table: "merchant"); + + migrationBuilder.DropPrimaryKey( + name: "PK_fileline", + table: "fileline"); + + migrationBuilder.DropIndex( + name: "IX_fileline_TransactionReportingId", + table: "fileline"); + + migrationBuilder.DropPrimaryKey( + name: "PK_fileimportlogfile", + table: "fileimportlogfile"); + + migrationBuilder.DropPrimaryKey( + name: "PK_fileimportlog", + table: "fileimportlog"); + + migrationBuilder.DropIndex( + name: "IX_fileimportlog_EstateReportingId_FileImportLogId", + table: "fileimportlog"); + + migrationBuilder.DropPrimaryKey( + name: "PK_estatesecurityuser", + table: "estatesecurityuser"); + + migrationBuilder.DropPrimaryKey( + name: "PK_contractproducttransactionfee", + table: "contractproducttransactionfee"); + + migrationBuilder.DropPrimaryKey( + name: "PK_contractproduct", + table: "contractproduct"); + + migrationBuilder.DropPrimaryKey( + name: "PK_contract", + table: "contract"); + + migrationBuilder.DropColumn( + name: "TransactionReportingId", + table: "voucher"); + + migrationBuilder.DropColumn( + name: "TransactionReportingId", + table: "transactionadditionalrequestdata"); + + migrationBuilder.DropColumn( + name: "ContractProductReportingId", + table: "transaction"); + + migrationBuilder.DropColumn( + name: "ContractReportingId", + table: "transaction"); + + migrationBuilder.DropColumn( + name: "EstateOperatorReportingId", + table: "transaction"); + + migrationBuilder.DropColumn( + name: "MerchantReportingId", + table: "transaction"); + + migrationBuilder.DropColumn( + name: "StatementReportingId", + table: "statementline"); + + migrationBuilder.DropColumn( + name: "TransactionReportingId", + table: "statementline"); + + migrationBuilder.DropColumn( + name: "MerchantReportingId", + table: "statementheader"); + + migrationBuilder.DropColumn( + name: "EstateReportingId", + table: "settlement"); + + migrationBuilder.DropColumn( + name: "MerchantReportingId", + table: "settlement"); + + migrationBuilder.DropColumn( + name: "MerchantReportingId", + table: "reconciliation"); + + migrationBuilder.DropColumn( + name: "EstateReportingId", + table: "operator"); + + migrationBuilder.DropColumn( + name: "SettlementReportingId", + table: "merchantsettlementfee"); + + migrationBuilder.DropColumn( + name: "TransactionReportingId", + table: "merchantsettlementfee"); + + migrationBuilder.DropColumn( + name: "TransactionFeeReportingId", + table: "merchantsettlementfee"); + + migrationBuilder.DropColumn( + name: "MerchantReportingId", + table: "merchantsettlementfee"); + + migrationBuilder.DropColumn( + name: "MerchantReportingId", + table: "merchantsecurityuser"); + + migrationBuilder.DropColumn( + name: "MerchantReportingId", + table: "merchantoperator"); + + migrationBuilder.DropColumn( + name: "MerchantReportingId", + table: "merchantdevice"); + + migrationBuilder.DropColumn( + name: "MerchantReportingId", + table: "MerchantContracts"); + + migrationBuilder.DropColumn( + name: "ContractReportingId", + table: "MerchantContracts"); + + migrationBuilder.DropColumn( + name: "MerchantReportingId", + table: "merchantcontact"); + + migrationBuilder.DropColumn( + name: "MerchantReportingId", + table: "merchantaddress"); + + migrationBuilder.DropColumn( + name: "EstateReportingId", + table: "merchant"); + + migrationBuilder.DropColumn( + name: "FileReportingId", + table: "fileline"); + + migrationBuilder.DropColumn( + name: "TransactionReportingId", + table: "fileline"); + + migrationBuilder.DropColumn( + name: "FileImportLogReportingId", + table: "fileimportlogfile"); + + migrationBuilder.DropColumn( + name: "FileReportingId", + table: "fileimportlogfile"); + + migrationBuilder.DropColumn( + name: "MerchantReportingId", + table: "fileimportlogfile"); + + migrationBuilder.DropColumn( + name: "EstateReportingId", + table: "fileimportlog"); + + migrationBuilder.DropColumn( + name: "EstateReportingId", + table: "file"); + + migrationBuilder.DropColumn( + name: "FileImportLogReportingId", + table: "file"); + + migrationBuilder.DropColumn( + name: "MerchantReportingId", + table: "file"); + + migrationBuilder.DropColumn( + name: "EstateReportingId", + table: "estatesecurityuser"); + + migrationBuilder.DropColumn( + name: "ContractProductReportingId", + table: "contractproducttransactionfee"); + + migrationBuilder.DropColumn( + name: "ContractReportingId", + table: "contractproduct"); + + migrationBuilder.DropColumn( + name: "EstateReportingId", + table: "contract"); + + migrationBuilder.RenameColumn( + name: "TransactionFeeReportingId", + table: "contractproducttransactionfee", + newName: "ContractProductTransactionFeeReportingId"); + + migrationBuilder.RenameColumn( + name: "TransactionFeeId", + table: "contractproducttransactionfee", + newName: "ContractProductTransactionFeeId"); + + migrationBuilder.RenameColumn( + name: "ProductId", + table: "contractproduct", + newName: "ContractProductId"); + + migrationBuilder.AddColumn( + name: "TransactionId", + table: "voucher", + type: "char(36)", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), + collation: "ascii_general_ci"); + + migrationBuilder.AddColumn( + name: "TransactionId", + table: "transactionadditionalresponsedata", + type: "char(36)", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), + collation: "ascii_general_ci"); + + migrationBuilder.AddColumn( + name: "TransactionId", + table: "transactionadditionalrequestdata", + type: "char(36)", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), + collation: "ascii_general_ci"); + + migrationBuilder.AddColumn( + name: "ContractId", + table: "transaction", + type: "char(36)", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), + collation: "ascii_general_ci"); + + migrationBuilder.AddColumn( + name: "ContractProductId", + table: "transaction", + type: "char(36)", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), + collation: "ascii_general_ci"); + + migrationBuilder.AddColumn( + name: "MerchantId", + table: "transaction", + type: "char(36)", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), + collation: "ascii_general_ci"); + + migrationBuilder.AddColumn( + name: "OperatorId", + table: "transaction", + type: "char(36)", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), + collation: "ascii_general_ci"); + + migrationBuilder.AddColumn( + name: "StatementId", + table: "statementline", + type: "char(36)", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), + collation: "ascii_general_ci"); + + migrationBuilder.AddColumn( + name: "TransactionId", + table: "statementline", + type: "char(36)", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), + collation: "ascii_general_ci"); + + migrationBuilder.AddColumn( + name: "MerchantId", + table: "statementheader", + type: "char(36)", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), + collation: "ascii_general_ci"); + + migrationBuilder.AddColumn( + name: "EstateId", + table: "settlement", + type: "char(36)", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), + collation: "ascii_general_ci"); + + migrationBuilder.AddColumn( + name: "MerchantId", + table: "settlement", + type: "char(36)", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), + collation: "ascii_general_ci"); + + migrationBuilder.AddColumn( + name: "MerchantId", + table: "reconciliation", + type: "char(36)", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), + collation: "ascii_general_ci"); + + migrationBuilder.AddColumn( + name: "EstateId", + table: "operator", + type: "char(36)", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), + collation: "ascii_general_ci"); + + migrationBuilder.AddColumn( + name: "SettlementId", + table: "merchantsettlementfee", + type: "char(36)", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), + collation: "ascii_general_ci"); + + migrationBuilder.AddColumn( + name: "TransactionId", + table: "merchantsettlementfee", + type: "char(36)", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), + collation: "ascii_general_ci"); + + migrationBuilder.AddColumn( + name: "ContractProductTransactionFeeId", + table: "merchantsettlementfee", + type: "char(36)", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), + collation: "ascii_general_ci"); + + migrationBuilder.AddColumn( + name: "MerchantId", + table: "merchantsettlementfee", + type: "char(36)", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), + collation: "ascii_general_ci"); + + migrationBuilder.AddColumn( + name: "MerchantId", + table: "merchantsecurityuser", + type: "char(36)", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), + collation: "ascii_general_ci"); + + migrationBuilder.AddColumn( + name: "MerchantId", + table: "merchantoperator", + type: "char(36)", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), + collation: "ascii_general_ci"); + + migrationBuilder.AddColumn( + name: "MerchantId", + table: "merchantdevice", + type: "char(36)", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), + collation: "ascii_general_ci"); + + migrationBuilder.AddColumn( + name: "MerchantId", + table: "MerchantContracts", + type: "char(36)", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), + collation: "ascii_general_ci"); + + migrationBuilder.AddColumn( + name: "ContractId", + table: "MerchantContracts", + type: "char(36)", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), + collation: "ascii_general_ci"); + + migrationBuilder.AddColumn( + name: "MerchantId", + table: "merchantcontact", + type: "char(36)", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), + collation: "ascii_general_ci"); + + migrationBuilder.AddColumn( + name: "MerchantId", + table: "merchantaddress", + type: "char(36)", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), + collation: "ascii_general_ci"); + + migrationBuilder.AddColumn( + name: "EstateId", + table: "merchant", + type: "char(36)", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), + collation: "ascii_general_ci"); + + migrationBuilder.AddColumn( + name: "FileId", + table: "fileline", + type: "char(36)", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), + collation: "ascii_general_ci"); + + migrationBuilder.AddColumn( + name: "TransactionId", + table: "fileline", + type: "char(36)", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), + collation: "ascii_general_ci"); + + migrationBuilder.AddColumn( + name: "FileImportLogId", + table: "fileimportlogfile", + type: "char(36)", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), + collation: "ascii_general_ci"); + + migrationBuilder.AddColumn( + name: "FileId", + table: "fileimportlogfile", + type: "char(36)", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), + collation: "ascii_general_ci"); + + migrationBuilder.AddColumn( + name: "MerchantId", + table: "fileimportlogfile", + type: "char(36)", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), + collation: "ascii_general_ci"); + + migrationBuilder.AddColumn( + name: "EstateId", + table: "fileimportlog", + type: "char(36)", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), + collation: "ascii_general_ci"); + + migrationBuilder.AddColumn( + name: "EstateId", + table: "file", + type: "char(36)", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), + collation: "ascii_general_ci"); + + migrationBuilder.AddColumn( + name: "FileImportLogId", + table: "file", + type: "char(36)", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), + collation: "ascii_general_ci"); + + migrationBuilder.AddColumn( + name: "MerchantId", + table: "file", + type: "char(36)", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), + collation: "ascii_general_ci"); + + migrationBuilder.AddColumn( + name: "EstateId", + table: "estatesecurityuser", + type: "char(36)", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), + collation: "ascii_general_ci"); + + migrationBuilder.AddColumn( + name: "ContractProductId", + table: "contractproducttransactionfee", + type: "char(36)", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), + collation: "ascii_general_ci"); + + migrationBuilder.AddColumn( + name: "ContractId", + table: "contractproduct", + type: "char(36)", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), + collation: "ascii_general_ci"); + + migrationBuilder.AddColumn( + name: "EstateId", + table: "contract", + type: "char(36)", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), + collation: "ascii_general_ci"); + + migrationBuilder.AddPrimaryKey( + name: "PK_transactionadditionalresponsedata", + table: "transactionadditionalresponsedata", + column: "TransactionId"); + + migrationBuilder.AddPrimaryKey( + name: "PK_transactionadditionalrequestdata", + table: "transactionadditionalrequestdata", + column: "TransactionId"); + + migrationBuilder.AddPrimaryKey( + name: "PK_statementline", + table: "statementline", + columns: new[] { "StatementId", "TransactionId", "ActivityDateTime", "ActivityType" }); + + migrationBuilder.AddPrimaryKey( + name: "PK_statementheader", + table: "statementheader", + columns: new[] { "MerchantId", "StatementId" }); + + migrationBuilder.AddPrimaryKey( + name: "PK_merchantsettlementfee", + table: "merchantsettlementfee", + columns: new[] { "SettlementId", "TransactionId", "ContractProductTransactionFeeId" }); + + migrationBuilder.AddPrimaryKey( + name: "PK_merchantsecurityuser", + table: "merchantsecurityuser", + columns: new[] { "MerchantId", "SecurityUserId" }); + + migrationBuilder.AddPrimaryKey( + name: "PK_merchantoperator", + table: "merchantoperator", + columns: new[] { "MerchantId", "OperatorId" }); + + migrationBuilder.AddPrimaryKey( + name: "PK_merchantdevice", + table: "merchantdevice", + columns: new[] { "MerchantId", "DeviceId" }); + + migrationBuilder.AddPrimaryKey( + name: "PK_MerchantContracts", + table: "MerchantContracts", + columns: new[] { "MerchantId", "ContractId" }); + + migrationBuilder.AddPrimaryKey( + name: "PK_merchantcontact", + table: "merchantcontact", + columns: new[] { "MerchantId", "ContactId" }); + + migrationBuilder.AddPrimaryKey( + name: "PK_merchantaddress", + table: "merchantaddress", + columns: new[] { "MerchantId", "AddressId" }); + + migrationBuilder.AddPrimaryKey( + name: "PK_merchant", + table: "merchant", + column: "MerchantReportingId"); + + migrationBuilder.AddPrimaryKey( + name: "PK_fileline", + table: "fileline", + columns: new[] { "FileId", "LineNumber" }); + + migrationBuilder.AddPrimaryKey( + name: "PK_fileimportlogfile", + table: "fileimportlogfile", + columns: new[] { "FileImportLogId", "FileId" }); + + migrationBuilder.AddPrimaryKey( + name: "PK_fileimportlog", + table: "fileimportlog", + columns: new[] { "EstateId", "FileImportLogReportingId" }); + + migrationBuilder.AddPrimaryKey( + name: "PK_estatesecurityuser", + table: "estatesecurityuser", + columns: new[] { "SecurityUserId", "EstateId" }); + + migrationBuilder.AddPrimaryKey( + name: "PK_contractproducttransactionfee", + table: "contractproducttransactionfee", + column: "ContractProductTransactionFeeReportingId"); + + migrationBuilder.AddPrimaryKey( + name: "PK_contractproduct", + table: "contractproduct", + column: "ContractProductReportingId"); + + migrationBuilder.AddPrimaryKey( + name: "PK_contract", + table: "contract", + columns: new[] { "EstateId", "OperatorId", "ContractId" }); + + migrationBuilder.CreateIndex( + name: "IX_voucher_TransactionId", + table: "voucher", + column: "TransactionId"); + + migrationBuilder.CreateIndex( + name: "IX_transaction_TransactionDate", + table: "transaction", + column: "TransactionDate"); + + migrationBuilder.CreateIndex( + name: "IX_statementheader_StatementGeneratedDate", + table: "statementheader", + column: "StatementGeneratedDate"); + + migrationBuilder.CreateIndex( + name: "IX_settlement_EstateId_SettlementId", + table: "settlement", + columns: new[] { "EstateId", "SettlementId" }, + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_settlement_SettlementDate", + table: "settlement", + column: "SettlementDate"); + + migrationBuilder.CreateIndex( + name: "IX_reconciliation_TransactionDate", + table: "reconciliation", + column: "TransactionDate"); + + migrationBuilder.CreateIndex( + name: "IX_reconciliation_TransactionId_MerchantId", + table: "reconciliation", + columns: new[] { "TransactionId", "MerchantId" }, + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_merchant_EstateId_MerchantId", + table: "merchant", + columns: new[] { "EstateId", "MerchantId" }, + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_fileimportlog_EstateId_FileImportLogId", + table: "fileimportlog", + columns: new[] { "EstateId", "FileImportLogId" }, + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_contractproducttransactionfee_ContractProductTransactionFeeI~", + table: "contractproducttransactionfee", + columns: new[] { "ContractProductTransactionFeeId", "ContractProductId" }, + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_contractproduct_ContractProductId_ContractId", + table: "contractproduct", + columns: new[] { "ContractProductId", "ContractId" }, + unique: true); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropIndex( + name: "IX_voucher_TransactionId", + table: "voucher"); + + migrationBuilder.DropPrimaryKey( + name: "PK_transactionadditionalresponsedata", + table: "transactionadditionalresponsedata"); + + migrationBuilder.DropPrimaryKey( + name: "PK_transactionadditionalrequestdata", + table: "transactionadditionalrequestdata"); + + migrationBuilder.DropIndex( + name: "IX_transaction_TransactionDate", + table: "transaction"); + + migrationBuilder.DropPrimaryKey( + name: "PK_statementline", + table: "statementline"); + + migrationBuilder.DropPrimaryKey( + name: "PK_statementheader", + table: "statementheader"); + + migrationBuilder.DropIndex( + name: "IX_statementheader_StatementGeneratedDate", + table: "statementheader"); + + migrationBuilder.DropIndex( + name: "IX_settlement_EstateId_SettlementId", + table: "settlement"); + + migrationBuilder.DropIndex( + name: "IX_settlement_SettlementDate", + table: "settlement"); + + migrationBuilder.DropIndex( + name: "IX_reconciliation_TransactionDate", + table: "reconciliation"); + + migrationBuilder.DropIndex( + name: "IX_reconciliation_TransactionId_MerchantId", + table: "reconciliation"); + + migrationBuilder.DropPrimaryKey( + name: "PK_merchantsettlementfee", + table: "merchantsettlementfee"); + + migrationBuilder.DropPrimaryKey( + name: "PK_merchantsecurityuser", + table: "merchantsecurityuser"); + + migrationBuilder.DropPrimaryKey( + name: "PK_merchantoperator", + table: "merchantoperator"); + + migrationBuilder.DropPrimaryKey( + name: "PK_merchantdevice", + table: "merchantdevice"); + + migrationBuilder.DropPrimaryKey( + name: "PK_MerchantContracts", + table: "MerchantContracts"); + + migrationBuilder.DropPrimaryKey( + name: "PK_merchantcontact", + table: "merchantcontact"); + + migrationBuilder.DropPrimaryKey( + name: "PK_merchantaddress", + table: "merchantaddress"); + + migrationBuilder.DropPrimaryKey( + name: "PK_merchant", + table: "merchant"); + + migrationBuilder.DropIndex( + name: "IX_merchant_EstateId_MerchantId", + table: "merchant"); + + migrationBuilder.DropPrimaryKey( + name: "PK_fileline", + table: "fileline"); + + migrationBuilder.DropPrimaryKey( + name: "PK_fileimportlogfile", + table: "fileimportlogfile"); + + migrationBuilder.DropPrimaryKey( + name: "PK_fileimportlog", + table: "fileimportlog"); + + migrationBuilder.DropIndex( + name: "IX_fileimportlog_EstateId_FileImportLogId", + table: "fileimportlog"); + + migrationBuilder.DropPrimaryKey( + name: "PK_estatesecurityuser", + table: "estatesecurityuser"); + + migrationBuilder.DropPrimaryKey( + name: "PK_contractproducttransactionfee", + table: "contractproducttransactionfee"); + + migrationBuilder.DropIndex( + name: "IX_contractproducttransactionfee_ContractProductTransactionFeeI~", + table: "contractproducttransactionfee"); + + migrationBuilder.DropPrimaryKey( + name: "PK_contractproduct", + table: "contractproduct"); + + migrationBuilder.DropIndex( + name: "IX_contractproduct_ContractProductId_ContractId", + table: "contractproduct"); + + migrationBuilder.DropPrimaryKey( + name: "PK_contract", + table: "contract"); + + migrationBuilder.DropColumn( + name: "TransactionId", + table: "voucher"); + + migrationBuilder.DropColumn( + name: "TransactionId", + table: "transactionadditionalresponsedata"); + + migrationBuilder.DropColumn( + name: "TransactionId", + table: "transactionadditionalrequestdata"); + + migrationBuilder.DropColumn( + name: "ContractId", + table: "transaction"); + + migrationBuilder.DropColumn( + name: "ContractProductId", + table: "transaction"); + + migrationBuilder.DropColumn( + name: "MerchantId", + table: "transaction"); + + migrationBuilder.DropColumn( + name: "OperatorId", + table: "transaction"); + + migrationBuilder.DropColumn( + name: "StatementId", + table: "statementline"); + + migrationBuilder.DropColumn( + name: "TransactionId", + table: "statementline"); + + migrationBuilder.DropColumn( + name: "MerchantId", + table: "statementheader"); + + migrationBuilder.DropColumn( + name: "EstateId", + table: "settlement"); + + migrationBuilder.DropColumn( + name: "MerchantId", + table: "settlement"); + + migrationBuilder.DropColumn( + name: "MerchantId", + table: "reconciliation"); + + migrationBuilder.DropColumn( + name: "EstateId", + table: "operator"); + + migrationBuilder.DropColumn( + name: "SettlementId", + table: "merchantsettlementfee"); + + migrationBuilder.DropColumn( + name: "TransactionId", + table: "merchantsettlementfee"); + + migrationBuilder.DropColumn( + name: "ContractProductTransactionFeeId", + table: "merchantsettlementfee"); + + migrationBuilder.DropColumn( + name: "MerchantId", + table: "merchantsettlementfee"); + + migrationBuilder.DropColumn( + name: "MerchantId", + table: "merchantsecurityuser"); + + migrationBuilder.DropColumn( + name: "MerchantId", + table: "merchantoperator"); + + migrationBuilder.DropColumn( + name: "MerchantId", + table: "merchantdevice"); + + migrationBuilder.DropColumn( + name: "MerchantId", + table: "MerchantContracts"); + + migrationBuilder.DropColumn( + name: "ContractId", + table: "MerchantContracts"); + + migrationBuilder.DropColumn( + name: "MerchantId", + table: "merchantcontact"); + + migrationBuilder.DropColumn( + name: "MerchantId", + table: "merchantaddress"); + + migrationBuilder.DropColumn( + name: "EstateId", + table: "merchant"); + + migrationBuilder.DropColumn( + name: "FileId", + table: "fileline"); + + migrationBuilder.DropColumn( + name: "TransactionId", + table: "fileline"); + + migrationBuilder.DropColumn( + name: "FileImportLogId", + table: "fileimportlogfile"); + + migrationBuilder.DropColumn( + name: "FileId", + table: "fileimportlogfile"); + + migrationBuilder.DropColumn( + name: "MerchantId", + table: "fileimportlogfile"); + + migrationBuilder.DropColumn( + name: "EstateId", + table: "fileimportlog"); + + migrationBuilder.DropColumn( + name: "EstateId", + table: "file"); + + migrationBuilder.DropColumn( + name: "FileImportLogId", + table: "file"); + + migrationBuilder.DropColumn( + name: "MerchantId", + table: "file"); + + migrationBuilder.DropColumn( + name: "EstateId", + table: "estatesecurityuser"); + + migrationBuilder.DropColumn( + name: "ContractProductId", + table: "contractproducttransactionfee"); + + migrationBuilder.DropColumn( + name: "ContractId", + table: "contractproduct"); + + migrationBuilder.DropColumn( + name: "EstateId", + table: "contract"); + + migrationBuilder.RenameColumn( + name: "ContractProductTransactionFeeId", + table: "contractproducttransactionfee", + newName: "TransactionFeeId"); + + migrationBuilder.RenameColumn( + name: "ContractProductTransactionFeeReportingId", + table: "contractproducttransactionfee", + newName: "TransactionFeeReportingId"); + + migrationBuilder.RenameColumn( + name: "ContractProductId", + table: "contractproduct", + newName: "ProductId"); + + migrationBuilder.AddColumn( + name: "TransactionReportingId", + table: "voucher", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "TransactionReportingId", + table: "transactionadditionalrequestdata", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "ContractProductReportingId", + table: "transaction", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "ContractReportingId", + table: "transaction", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "EstateOperatorReportingId", + table: "transaction", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "MerchantReportingId", + table: "transaction", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "StatementReportingId", + table: "statementline", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "TransactionReportingId", + table: "statementline", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "MerchantReportingId", + table: "statementheader", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "EstateReportingId", + table: "settlement", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "MerchantReportingId", + table: "settlement", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "MerchantReportingId", + table: "reconciliation", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "EstateReportingId", + table: "operator", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "SettlementReportingId", + table: "merchantsettlementfee", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "TransactionReportingId", + table: "merchantsettlementfee", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "TransactionFeeReportingId", + table: "merchantsettlementfee", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "MerchantReportingId", + table: "merchantsettlementfee", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "MerchantReportingId", + table: "merchantsecurityuser", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "MerchantReportingId", + table: "merchantoperator", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "MerchantReportingId", + table: "merchantdevice", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "MerchantReportingId", + table: "MerchantContracts", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "ContractReportingId", + table: "MerchantContracts", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "MerchantReportingId", + table: "merchantcontact", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "MerchantReportingId", + table: "merchantaddress", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "EstateReportingId", + table: "merchant", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "FileReportingId", + table: "fileline", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "TransactionReportingId", + table: "fileline", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "FileImportLogReportingId", + table: "fileimportlogfile", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "FileReportingId", + table: "fileimportlogfile", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "MerchantReportingId", + table: "fileimportlogfile", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "EstateReportingId", + table: "fileimportlog", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "EstateReportingId", + table: "file", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "FileImportLogReportingId", + table: "file", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "MerchantReportingId", + table: "file", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "EstateReportingId", + table: "estatesecurityuser", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "ContractProductReportingId", + table: "contractproducttransactionfee", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "ContractReportingId", + table: "contractproduct", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "EstateReportingId", + table: "contract", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddPrimaryKey( + name: "PK_transactionadditionalresponsedata", + table: "transactionadditionalresponsedata", + column: "TransactionReportingId"); + + migrationBuilder.AddPrimaryKey( + name: "PK_transactionadditionalrequestdata", + table: "transactionadditionalrequestdata", + column: "TransactionReportingId"); + + migrationBuilder.AddPrimaryKey( + name: "PK_statementline", + table: "statementline", + columns: new[] { "StatementReportingId", "TransactionReportingId", "ActivityDateTime", "ActivityType" }); + + migrationBuilder.AddPrimaryKey( + name: "PK_statementheader", + table: "statementheader", + columns: new[] { "MerchantReportingId", "StatementId" }); + + migrationBuilder.AddPrimaryKey( + name: "PK_merchantsettlementfee", + table: "merchantsettlementfee", + columns: new[] { "SettlementReportingId", "TransactionReportingId", "TransactionFeeReportingId" }); + + migrationBuilder.AddPrimaryKey( + name: "PK_merchantsecurityuser", + table: "merchantsecurityuser", + columns: new[] { "MerchantReportingId", "SecurityUserId" }); + + migrationBuilder.AddPrimaryKey( + name: "PK_merchantoperator", + table: "merchantoperator", + columns: new[] { "MerchantReportingId", "OperatorId" }); + + migrationBuilder.AddPrimaryKey( + name: "PK_merchantdevice", + table: "merchantdevice", + columns: new[] { "MerchantReportingId", "DeviceId" }); + + migrationBuilder.AddPrimaryKey( + name: "PK_MerchantContracts", + table: "MerchantContracts", + columns: new[] { "MerchantReportingId", "ContractReportingId" }); + + migrationBuilder.AddPrimaryKey( + name: "PK_merchantcontact", + table: "merchantcontact", + columns: new[] { "MerchantReportingId", "ContactId" }); + + migrationBuilder.AddPrimaryKey( + name: "PK_merchantaddress", + table: "merchantaddress", + columns: new[] { "MerchantReportingId", "AddressId" }); + + migrationBuilder.AddPrimaryKey( + name: "PK_merchant", + table: "merchant", + columns: new[] { "EstateReportingId", "MerchantReportingId" }); + + migrationBuilder.AddPrimaryKey( + name: "PK_fileline", + table: "fileline", + columns: new[] { "FileReportingId", "LineNumber" }); + + migrationBuilder.AddPrimaryKey( + name: "PK_fileimportlogfile", + table: "fileimportlogfile", + columns: new[] { "FileImportLogReportingId", "FileReportingId" }); + + migrationBuilder.AddPrimaryKey( + name: "PK_fileimportlog", + table: "fileimportlog", + columns: new[] { "EstateReportingId", "FileImportLogReportingId" }); + + migrationBuilder.AddPrimaryKey( + name: "PK_estatesecurityuser", + table: "estatesecurityuser", + columns: new[] { "SecurityUserId", "EstateReportingId" }); + + migrationBuilder.AddPrimaryKey( + name: "PK_contractproducttransactionfee", + table: "contractproducttransactionfee", + columns: new[] { "ContractProductReportingId", "TransactionFeeId" }); + + migrationBuilder.AddPrimaryKey( + name: "PK_contractproduct", + table: "contractproduct", + columns: new[] { "ContractReportingId", "ProductId" }); + + migrationBuilder.AddPrimaryKey( + name: "PK_contract", + table: "contract", + columns: new[] { "EstateReportingId", "OperatorId", "ContractId" }); + + migrationBuilder.CreateTable( + name: "estateoperator", + columns: table => new + { + EstateReportingId = table.Column(type: "int", nullable: false), + OperatorReportingId = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_estateoperator", x => new { x.EstateReportingId, x.OperatorReportingId }); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateIndex( + name: "IX_voucher_TransactionReportingId", + table: "voucher", + column: "TransactionReportingId"); + + migrationBuilder.CreateIndex( + name: "IX_transaction_TransactionDate_MerchantReportingId", + table: "transaction", + columns: new[] { "TransactionDate", "MerchantReportingId" }); + + migrationBuilder.CreateIndex( + name: "IX_transaction_TransactionId_MerchantReportingId", + table: "transaction", + columns: new[] { "TransactionId", "MerchantReportingId" }, + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_statementheader_MerchantReportingId_StatementGeneratedDate", + table: "statementheader", + columns: new[] { "MerchantReportingId", "StatementGeneratedDate" }); + + migrationBuilder.CreateIndex( + name: "IX_settlement_EstateReportingId_SettlementId", + table: "settlement", + columns: new[] { "EstateReportingId", "SettlementId" }, + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_settlement_SettlementDate_EstateReportingId", + table: "settlement", + columns: new[] { "SettlementDate", "EstateReportingId" }); + + migrationBuilder.CreateIndex( + name: "IX_reconciliation_TransactionDate_MerchantReportingId", + table: "reconciliation", + columns: new[] { "TransactionDate", "MerchantReportingId" }); + + migrationBuilder.CreateIndex( + name: "IX_reconciliation_TransactionId_MerchantReportingId", + table: "reconciliation", + columns: new[] { "TransactionId", "MerchantReportingId" }, + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_merchantsettlementfee_TransactionReportingId", + table: "merchantsettlementfee", + column: "TransactionReportingId"); + + migrationBuilder.CreateIndex( + name: "IX_merchant_EstateReportingId_MerchantId", + table: "merchant", + columns: new[] { "EstateReportingId", "MerchantId" }, + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_fileline_TransactionReportingId", + table: "fileline", + column: "TransactionReportingId"); + + migrationBuilder.CreateIndex( + name: "IX_fileimportlog_EstateReportingId_FileImportLogId", + table: "fileimportlog", + columns: new[] { "EstateReportingId", "FileImportLogId" }, + unique: true); + } + } +} diff --git a/TransactionProcessor.Database/Migrations/MySql/EstateManagementMySqlContextModelSnapshot.cs b/TransactionProcessor.Database/Migrations/MySql/EstateManagementMySqlContextModelSnapshot.cs new file mode 100644 index 00000000..bbf1992d --- /dev/null +++ b/TransactionProcessor.Database/Migrations/MySql/EstateManagementMySqlContextModelSnapshot.cs @@ -0,0 +1,1097 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using TransactionProcessor.Database.Contexts; + +#nullable disable + +namespace EstateManagement.Database.Migrations.MySql +{ + [DbContext(typeof(EstateManagementMySqlContext))] + partial class EstateManagementMySqlContextModelSnapshot : ModelSnapshot + { + protected override void BuildModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.3") + .HasAnnotation("Relational:MaxIdentifierLength", 64); + + MySqlModelBuilderExtensions.AutoIncrementColumns(modelBuilder); + + modelBuilder.Entity("EstateManagement.Database.Entities.Calendar", b => + { + b.Property("Date") + .HasColumnType("datetime(6)"); + + b.Property("DayOfWeek") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("DayOfWeekNumber") + .HasColumnType("int"); + + b.Property("DayOfWeekShort") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("MonthNameLong") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("MonthNameShort") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("MonthNumber") + .HasColumnType("int"); + + b.Property("WeekNumber") + .HasColumnType("int"); + + b.Property("WeekNumberString") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("Year") + .HasColumnType("int"); + + b.Property("YearWeekNumber") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("Date"); + + b.ToTable("calendar"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Contract", b => + { + b.Property("EstateId") + .HasColumnType("char(36)"); + + b.Property("OperatorId") + .HasColumnType("char(36)"); + + b.Property("ContractId") + .HasColumnType("char(36)"); + + b.Property("ContractReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("ContractReportingId")); + + b.Property("Description") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("EstateId", "OperatorId", "ContractId"); + + b.ToTable("contract"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.ContractProduct", b => + { + b.Property("ContractProductReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("ContractProductReportingId")); + + b.Property("ContractId") + .HasColumnType("char(36)"); + + b.Property("ContractProductId") + .HasColumnType("char(36)"); + + b.Property("DisplayText") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ProductName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ProductType") + .HasColumnType("int"); + + b.Property("Value") + .HasColumnType("decimal(65,30)"); + + b.HasKey("ContractProductReportingId"); + + b.HasIndex("ContractProductId", "ContractId") + .IsUnique(); + + b.ToTable("contractproduct"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.ContractProductTransactionFee", b => + { + b.Property("ContractProductTransactionFeeReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("ContractProductTransactionFeeReportingId")); + + b.Property("CalculationType") + .HasColumnType("int"); + + b.Property("ContractProductId") + .HasColumnType("char(36)"); + + b.Property("ContractProductTransactionFeeId") + .HasColumnType("char(36)"); + + b.Property("Description") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("FeeType") + .HasColumnType("int"); + + b.Property("IsEnabled") + .HasColumnType("tinyint(1)"); + + b.Property("Value") + .HasColumnType("decimal(18,4)"); + + b.HasKey("ContractProductTransactionFeeReportingId"); + + b.HasIndex("ContractProductTransactionFeeId", "ContractProductId") + .IsUnique(); + + b.ToTable("contractproducttransactionfee"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Estate", b => + { + b.Property("EstateReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("EstateReportingId")); + + b.Property("CreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("EstateId") + .HasColumnType("char(36)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("Reference") + .HasColumnType("longtext"); + + b.HasKey("EstateReportingId"); + + b.HasIndex("EstateId") + .IsUnique(); + + b.ToTable("estate"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.EstateSecurityUser", b => + { + b.Property("SecurityUserId") + .HasColumnType("char(36)"); + + b.Property("EstateId") + .HasColumnType("char(36)"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("EmailAddress") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("SecurityUserId", "EstateId"); + + b.ToTable("estatesecurityuser"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.File", b => + { + b.Property("FileReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("FileReportingId")); + + b.Property("EstateId") + .HasColumnType("char(36)"); + + b.Property("FileId") + .HasColumnType("char(36)"); + + b.Property("FileImportLogId") + .HasColumnType("char(36)"); + + b.Property("FileLocation") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("FileProfileId") + .HasColumnType("char(36)"); + + b.Property("FileReceivedDate") + .HasColumnType("date"); + + b.Property("FileReceivedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("IsCompleted") + .HasColumnType("tinyint(1)"); + + b.Property("MerchantId") + .HasColumnType("char(36)"); + + b.Property("UserId") + .HasColumnType("char(36)"); + + b.HasKey("FileReportingId"); + + b.HasIndex("FileId") + .IsUnique(); + + b.ToTable("file"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.FileImportLog", b => + { + b.Property("EstateId") + .HasColumnType("char(36)"); + + b.Property("FileImportLogReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("FileImportLogReportingId")); + + b.Property("FileImportLogId") + .HasColumnType("char(36)"); + + b.Property("ImportLogDate") + .HasColumnType("date"); + + b.Property("ImportLogDateTime") + .HasColumnType("datetime(6)"); + + b.HasKey("EstateId", "FileImportLogReportingId"); + + b.HasIndex("EstateId", "FileImportLogId") + .IsUnique(); + + b.ToTable("fileimportlog"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.FileImportLogFile", b => + { + b.Property("FileImportLogId") + .HasColumnType("char(36)"); + + b.Property("FileId") + .HasColumnType("char(36)"); + + b.Property("FilePath") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("FileProfileId") + .HasColumnType("char(36)"); + + b.Property("FileUploadedDate") + .HasColumnType("date"); + + b.Property("FileUploadedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("MerchantId") + .HasColumnType("char(36)"); + + b.Property("OriginalFileName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("UserId") + .HasColumnType("char(36)"); + + b.HasKey("FileImportLogId", "FileId"); + + b.ToTable("fileimportlogfile"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.FileLine", b => + { + b.Property("FileId") + .HasColumnType("char(36)"); + + b.Property("LineNumber") + .HasColumnType("int"); + + b.Property("FileLineData") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("Status") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("TransactionId") + .HasColumnType("char(36)"); + + b.HasKey("FileId", "LineNumber") + .HasAnnotation("SqlServer:Clustered", true); + + b.ToTable("fileline"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Float", b => + { + b.Property("FloatId") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("ContractId") + .HasColumnType("char(36)"); + + b.Property("CreatedDate") + .HasColumnType("date"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("EstateId") + .HasColumnType("char(36)"); + + b.Property("ProductId") + .HasColumnType("char(36)"); + + b.HasKey("FloatId") + .HasAnnotation("SqlServer:Clustered", false); + + b.HasIndex("CreatedDate") + .HasAnnotation("SqlServer:Clustered", true); + + b.ToTable("Floats"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.FloatActivity", b => + { + b.Property("EventId") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("ActivityDate") + .HasColumnType("date"); + + b.Property("ActivityDateTime") + .HasColumnType("datetime(6)"); + + b.Property("Amount") + .HasColumnType("decimal(65,30)"); + + b.Property("CostPrice") + .HasColumnType("decimal(65,30)"); + + b.Property("CreditOrDebit") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("FloatId") + .HasColumnType("char(36)"); + + b.HasKey("EventId") + .HasAnnotation("SqlServer:Clustered", false); + + b.HasIndex("ActivityDate") + .HasAnnotation("SqlServer:Clustered", true); + + b.ToTable("FloatActivity"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Merchant", b => + { + b.Property("MerchantReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("MerchantReportingId")); + + b.Property("CreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("EstateId") + .HasColumnType("char(36)"); + + b.Property("LastSaleDate") + .HasColumnType("date"); + + b.Property("LastSaleDateTime") + .HasColumnType("datetime(6)"); + + b.Property("LastStatementGenerated") + .HasColumnType("datetime(6)"); + + b.Property("MerchantId") + .HasColumnType("char(36)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("Reference") + .HasColumnType("longtext"); + + b.Property("SettlementSchedule") + .HasColumnType("int"); + + b.HasKey("MerchantReportingId"); + + b.HasIndex("EstateId", "MerchantId") + .IsUnique(); + + b.ToTable("merchant"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantAddress", b => + { + b.Property("MerchantId") + .HasColumnType("char(36)"); + + b.Property("AddressId") + .HasColumnType("char(36)"); + + b.Property("AddressLine1") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("AddressLine2") + .HasColumnType("longtext"); + + b.Property("AddressLine3") + .HasColumnType("longtext"); + + b.Property("AddressLine4") + .HasColumnType("longtext"); + + b.Property("Country") + .HasColumnType("longtext"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("PostalCode") + .HasColumnType("longtext"); + + b.Property("Region") + .HasColumnType("longtext"); + + b.Property("Town") + .HasColumnType("longtext"); + + b.HasKey("MerchantId", "AddressId"); + + b.ToTable("merchantaddress"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantContact", b => + { + b.Property("MerchantId") + .HasColumnType("char(36)"); + + b.Property("ContactId") + .HasColumnType("char(36)"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("EmailAddress") + .HasColumnType("longtext"); + + b.Property("Name") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("PhoneNumber") + .HasColumnType("longtext"); + + b.HasKey("MerchantId", "ContactId"); + + b.ToTable("merchantcontact"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantContract", b => + { + b.Property("MerchantId") + .HasColumnType("char(36)"); + + b.Property("ContractId") + .HasColumnType("char(36)"); + + b.Property("IsDeleted") + .HasColumnType("tinyint(1)"); + + b.HasKey("MerchantId", "ContractId"); + + b.ToTable("MerchantContracts"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantDevice", b => + { + b.Property("MerchantId") + .HasColumnType("char(36)"); + + b.Property("DeviceId") + .HasColumnType("char(36)"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("DeviceIdentifier") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("MerchantId", "DeviceId"); + + b.ToTable("merchantdevice"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantOperator", b => + { + b.Property("MerchantId") + .HasColumnType("char(36)"); + + b.Property("OperatorId") + .HasColumnType("char(36)"); + + b.Property("IsDeleted") + .HasColumnType("tinyint(1)"); + + b.Property("MerchantNumber") + .HasColumnType("longtext"); + + b.Property("Name") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("TerminalNumber") + .HasColumnType("longtext"); + + b.HasKey("MerchantId", "OperatorId"); + + b.ToTable("merchantoperator"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantSecurityUser", b => + { + b.Property("MerchantId") + .HasColumnType("char(36)"); + + b.Property("SecurityUserId") + .HasColumnType("char(36)"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("EmailAddress") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("MerchantId", "SecurityUserId"); + + b.ToTable("merchantsecurityuser"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantSettlementFee", b => + { + b.Property("SettlementId") + .HasColumnType("char(36)"); + + b.Property("TransactionId") + .HasColumnType("char(36)"); + + b.Property("ContractProductTransactionFeeId") + .HasColumnType("char(36)"); + + b.Property("CalculatedValue") + .HasColumnType("decimal(65,30)"); + + b.Property("FeeCalculatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("FeeValue") + .HasColumnType("decimal(65,30)"); + + b.Property("IsSettled") + .HasColumnType("tinyint(1)"); + + b.Property("MerchantId") + .HasColumnType("char(36)"); + + b.HasKey("SettlementId", "TransactionId", "ContractProductTransactionFeeId"); + + b.ToTable("merchantsettlementfee"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Operator", b => + { + b.Property("OperatorReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("OperatorReportingId")); + + b.Property("EstateId") + .HasColumnType("char(36)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("OperatorId") + .HasColumnType("char(36)"); + + b.Property("RequireCustomMerchantNumber") + .HasColumnType("tinyint(1)"); + + b.Property("RequireCustomTerminalNumber") + .HasColumnType("tinyint(1)"); + + b.HasKey("OperatorReportingId"); + + b.HasIndex("OperatorId") + .IsUnique(); + + b.ToTable("operator"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Reconciliation", b => + { + b.Property("TransactionReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("TransactionReportingId")); + + b.Property("DeviceIdentifier") + .HasColumnType("longtext"); + + b.Property("IsAuthorised") + .HasColumnType("tinyint(1)"); + + b.Property("IsCompleted") + .HasColumnType("tinyint(1)"); + + b.Property("MerchantId") + .HasColumnType("char(36)"); + + b.Property("ResponseCode") + .HasColumnType("longtext"); + + b.Property("ResponseMessage") + .HasColumnType("longtext"); + + b.Property("TransactionCount") + .HasColumnType("int"); + + b.Property("TransactionDate") + .HasColumnType("date"); + + b.Property("TransactionDateTime") + .HasColumnType("datetime(6)"); + + b.Property("TransactionId") + .HasColumnType("char(36)"); + + b.Property("TransactionTime") + .HasColumnType("time(6)"); + + b.Property("TransactionValue") + .HasColumnType("decimal(65,30)"); + + b.HasKey("TransactionReportingId") + .HasAnnotation("SqlServer:Clustered", false); + + b.HasIndex("TransactionDate") + .HasAnnotation("SqlServer:Clustered", true); + + b.HasIndex("TransactionId", "MerchantId") + .IsUnique() + .HasAnnotation("SqlServer:Clustered", false); + + b.ToTable("reconciliation"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.ResponseCodes", b => + { + b.Property("ResponseCode") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("ResponseCode")); + + b.Property("Description") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("ResponseCode"); + + b.ToTable("responsecodes"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Settlement", b => + { + b.Property("SettlementReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("SettlementReportingId")); + + b.Property("EstateId") + .HasColumnType("char(36)"); + + b.Property("IsCompleted") + .HasColumnType("tinyint(1)"); + + b.Property("MerchantId") + .HasColumnType("char(36)"); + + b.Property("ProcessingStarted") + .HasColumnType("tinyint(1)"); + + b.Property("ProcessingStartedDateTIme") + .HasColumnType("datetime(6)"); + + b.Property("SettlementDate") + .HasColumnType("date"); + + b.Property("SettlementId") + .HasColumnType("char(36)"); + + b.HasKey("SettlementReportingId") + .HasAnnotation("SqlServer:Clustered", false); + + b.HasIndex("SettlementDate") + .HasAnnotation("SqlServer:Clustered", true); + + b.HasIndex("EstateId", "SettlementId") + .IsUnique() + .HasAnnotation("SqlServer:Clustered", false); + + b.ToTable("settlement"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.StatementHeader", b => + { + b.Property("MerchantId") + .HasColumnType("char(36)"); + + b.Property("StatementId") + .HasColumnType("char(36)"); + + b.Property("StatementCreatedDate") + .HasColumnType("date"); + + b.Property("StatementCreatedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("StatementGeneratedDate") + .HasColumnType("date"); + + b.Property("StatementGeneratedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("StatementReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("StatementReportingId")); + + b.HasKey("MerchantId", "StatementId") + .HasAnnotation("SqlServer:Clustered", false); + + b.HasIndex("StatementGeneratedDate") + .HasAnnotation("SqlServer:Clustered", true); + + b.ToTable("statementheader"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.StatementLine", b => + { + b.Property("StatementId") + .HasColumnType("char(36)"); + + b.Property("TransactionId") + .HasColumnType("char(36)"); + + b.Property("ActivityDateTime") + .HasColumnType("datetime(6)"); + + b.Property("ActivityType") + .HasColumnType("int"); + + b.Property("ActivityDate") + .HasColumnType("date"); + + b.Property("ActivityDescription") + .HasColumnType("longtext"); + + b.Property("InAmount") + .HasColumnType("decimal(65,30)"); + + b.Property("OutAmount") + .HasColumnType("decimal(65,30)"); + + b.HasKey("StatementId", "TransactionId", "ActivityDateTime", "ActivityType"); + + b.ToTable("statementline"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Transaction", b => + { + b.Property("TransactionReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("TransactionReportingId")); + + b.Property("AuthorisationCode") + .HasColumnType("longtext"); + + b.Property("ContractId") + .HasColumnType("char(36)"); + + b.Property("ContractProductId") + .HasColumnType("char(36)"); + + b.Property("DeviceIdentifier") + .HasColumnType("longtext"); + + b.Property("IsAuthorised") + .HasColumnType("tinyint(1)"); + + b.Property("IsCompleted") + .HasColumnType("tinyint(1)"); + + b.Property("MerchantId") + .HasColumnType("char(36)"); + + b.Property("OperatorId") + .HasColumnType("char(36)"); + + b.Property("ResponseCode") + .HasColumnType("longtext"); + + b.Property("ResponseMessage") + .HasColumnType("longtext"); + + b.Property("TransactionAmount") + .HasColumnType("decimal(65,30)"); + + b.Property("TransactionDate") + .HasColumnType("date"); + + b.Property("TransactionDateTime") + .HasColumnType("datetime(6)"); + + b.Property("TransactionId") + .HasColumnType("char(36)"); + + b.Property("TransactionNumber") + .HasColumnType("longtext"); + + b.Property("TransactionReference") + .HasColumnType("longtext"); + + b.Property("TransactionSource") + .HasColumnType("int"); + + b.Property("TransactionTime") + .HasColumnType("time(6)"); + + b.Property("TransactionType") + .HasColumnType("longtext"); + + b.HasKey("TransactionReportingId") + .HasAnnotation("SqlServer:Clustered", false); + + b.HasIndex("TransactionDate") + .HasAnnotation("SqlServer:Clustered", true); + + b.HasIndex("TransactionId") + .IsUnique() + .HasAnnotation("SqlServer:Clustered", false); + + b.ToTable("transaction"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.TransactionAdditionalRequestData", b => + { + b.Property("TransactionId") + .HasColumnType("char(36)"); + + b.Property("Amount") + .HasColumnType("longtext"); + + b.Property("CustomerAccountNumber") + .HasColumnType("longtext"); + + b.HasKey("TransactionId"); + + b.ToTable("transactionadditionalrequestdata"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.TransactionAdditionalResponseData", b => + { + b.Property("TransactionId") + .HasColumnType("char(36)"); + + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.HasKey("TransactionId"); + + b.ToTable("transactionadditionalresponsedata"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Voucher", b => + { + b.Property("VoucherId") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("ExpiryDate") + .HasColumnType("date"); + + b.Property("ExpiryDateTime") + .HasColumnType("datetime(6)"); + + b.Property("GenerateDate") + .HasColumnType("date"); + + b.Property("GenerateDateTime") + .HasColumnType("datetime(6)"); + + b.Property("IsGenerated") + .HasColumnType("tinyint(1)"); + + b.Property("IsIssued") + .HasColumnType("tinyint(1)"); + + b.Property("IsRedeemed") + .HasColumnType("tinyint(1)"); + + b.Property("IssuedDate") + .HasColumnType("date"); + + b.Property("IssuedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("OperatorIdentifier") + .HasColumnType("longtext"); + + b.Property("RecipientEmail") + .HasColumnType("longtext"); + + b.Property("RecipientMobile") + .HasColumnType("longtext"); + + b.Property("RedeemedDate") + .HasColumnType("datetime(6)"); + + b.Property("RedeemedDateTime") + .HasColumnType("datetime(6)"); + + b.Property("TransactionId") + .HasColumnType("char(36)"); + + b.Property("Value") + .HasColumnType("decimal(65,30)"); + + b.Property("VoucherCode") + .IsRequired() + .HasColumnType("varchar(255)"); + + b.HasKey("VoucherId"); + + b.HasIndex("TransactionId"); + + b.HasIndex("VoucherCode"); + + b.ToTable("voucher"); + }); + + modelBuilder.Entity("EstateManagement.Database.ViewEntities.SettlementView", b => + { + b.Property("Amount") + .HasColumnType("decimal(65,30)"); + + b.Property("CalculatedValue") + .HasColumnType("decimal(65,30)"); + + b.Property("DayOfWeek") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("EstateId") + .HasColumnType("char(36)"); + + b.Property("FeeDescription") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("IsCompleted") + .HasColumnType("tinyint(1)"); + + b.Property("IsSettled") + .HasColumnType("tinyint(1)"); + + b.Property("MerchantId") + .HasColumnType("char(36)"); + + b.Property("MerchantName") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("Month") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("MonthNumber") + .HasColumnType("int"); + + b.Property("OperatorIdentifier") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("SettlementDate") + .HasColumnType("datetime(6)"); + + b.Property("SettlementId") + .HasColumnType("char(36)"); + + b.Property("TransactionId") + .HasColumnType("char(36)"); + + b.Property("WeekNumber") + .HasColumnType("int"); + + b.Property("YearNumber") + .HasColumnType("int"); + + b.ToTable((string)null); + + b.ToView("uvwSettlements", (string)null); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/TransactionProcessor.Database/Migrations/SqlServer/20221115191516_InitialDatabase.Designer.cs b/TransactionProcessor.Database/Migrations/SqlServer/20221115191516_InitialDatabase.Designer.cs new file mode 100644 index 00000000..31402949 --- /dev/null +++ b/TransactionProcessor.Database/Migrations/SqlServer/20221115191516_InitialDatabase.Designer.cs @@ -0,0 +1,1069 @@ +// + +#nullable disable + +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using TransactionProcessor.Database.Contexts; + +namespace TransactionProcessor.Database.Migrations.SqlServer +{ + [DbContext(typeof(EstateManagementSqlServerContext))] + [Migration("20221115191516_InitialDatabase")] + partial class InitialDatabase + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "6.0.5") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1); + + modelBuilder.Entity("EstateManagement.Database.Entities.Calendar", b => + { + b.Property("Date") + .HasColumnType("datetime2"); + + b.Property("DayOfWeek") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("DayOfWeekNumber") + .HasColumnType("int"); + + b.Property("DayOfWeekShort") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("MonthNameLong") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("MonthNameShort") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("MonthNumber") + .HasColumnType("int"); + + b.Property("WeekNumber") + .HasColumnType("int"); + + b.Property("WeekNumberString") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Year") + .HasColumnType("int"); + + b.Property("YearWeekNumber") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Date"); + + b.ToTable("calendar"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Contract", b => + { + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("OperatorId") + .HasColumnType("uniqueidentifier"); + + b.Property("ContractId") + .HasColumnType("uniqueidentifier"); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("EstateId", "OperatorId", "ContractId"); + + b.ToTable("contract"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.ContractProduct", b => + { + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("ContractId") + .HasColumnType("uniqueidentifier"); + + b.Property("ProductId") + .HasColumnType("uniqueidentifier"); + + b.Property("DisplayText") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ProductName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Value") + .HasColumnType("decimal(18,2)"); + + b.HasKey("EstateId", "ContractId", "ProductId"); + + b.ToTable("contractproduct"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.ContractProductTransactionFee", b => + { + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("ContractId") + .HasColumnType("uniqueidentifier"); + + b.Property("ProductId") + .HasColumnType("uniqueidentifier"); + + b.Property("TransactionFeeId") + .HasColumnType("uniqueidentifier"); + + b.Property("CalculationType") + .HasColumnType("int"); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("FeeType") + .HasColumnType("int"); + + b.Property("IsEnabled") + .HasColumnType("bit"); + + b.Property("Value") + .HasColumnType("decimal(18,4)"); + + b.HasKey("EstateId", "ContractId", "ProductId", "TransactionFeeId"); + + b.ToTable("contractproducttransactionfee"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Estate", b => + { + b.Property("EstateId") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Reference") + .HasColumnType("nvarchar(max)"); + + b.HasKey("EstateId"); + + b.ToTable("estate"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.EstateOperator", b => + { + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("OperatorId") + .HasColumnType("uniqueidentifier"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("RequireCustomMerchantNumber") + .HasColumnType("bit"); + + b.Property("RequireCustomTerminalNumber") + .HasColumnType("bit"); + + b.HasKey("EstateId", "OperatorId"); + + b.ToTable("estateoperator"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.EstateSecurityUser", b => + { + b.Property("SecurityUserId") + .HasColumnType("uniqueidentifier"); + + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("EmailAddress") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("SecurityUserId", "EstateId"); + + b.ToTable("estatesecurityuser"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.File", b => + { + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("FileImportLogId") + .HasColumnType("uniqueidentifier"); + + b.Property("FileId") + .HasColumnType("uniqueidentifier"); + + b.Property("FileLocation") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("FileProfileId") + .HasColumnType("uniqueidentifier"); + + b.Property("FileReceivedDateTime") + .HasColumnType("datetime2"); + + b.Property("IsCompleted") + .HasColumnType("bit"); + + b.Property("MerchantId") + .HasColumnType("uniqueidentifier"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("EstateId", "FileImportLogId", "FileId"); + + b.ToTable("file"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.FileImportLog", b => + { + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("FileImportLogId") + .HasColumnType("uniqueidentifier"); + + b.Property("ImportLogDateTime") + .HasColumnType("datetime2"); + + b.HasKey("EstateId", "FileImportLogId"); + + b.ToTable("fileimportlog"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.FileImportLogFile", b => + { + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("FileImportLogId") + .HasColumnType("uniqueidentifier"); + + b.Property("FileId") + .HasColumnType("uniqueidentifier"); + + b.Property("FilePath") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("FileProfileId") + .HasColumnType("uniqueidentifier"); + + b.Property("FileUploadedDateTime") + .HasColumnType("datetime2"); + + b.Property("MerchantId") + .HasColumnType("uniqueidentifier"); + + b.Property("OriginalFileName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("EstateId", "FileImportLogId", "FileId"); + + b.ToTable("fileimportlogfile"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.FileLine", b => + { + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("FileId") + .HasColumnType("uniqueidentifier"); + + b.Property("LineNumber") + .HasColumnType("int"); + + b.Property("FileLineData") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Status") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("TransactionId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("EstateId", "FileId", "LineNumber"); + + b.ToTable("fileline"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Merchant", b => + { + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("MerchantId") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("LastStatementGenerated") + .HasColumnType("datetime2"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Reference") + .HasColumnType("nvarchar(max)"); + + b.Property("SettlementSchedule") + .HasColumnType("int"); + + b.HasKey("EstateId", "MerchantId"); + + b.ToTable("merchant"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantAddress", b => + { + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("MerchantId") + .HasColumnType("uniqueidentifier"); + + b.Property("AddressId") + .HasColumnType("uniqueidentifier"); + + b.Property("AddressLine1") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("AddressLine2") + .HasColumnType("nvarchar(max)"); + + b.Property("AddressLine3") + .HasColumnType("nvarchar(max)"); + + b.Property("AddressLine4") + .HasColumnType("nvarchar(max)"); + + b.Property("Country") + .HasColumnType("nvarchar(max)"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("PostalCode") + .HasColumnType("nvarchar(max)"); + + b.Property("Region") + .HasColumnType("nvarchar(max)"); + + b.Property("Town") + .HasColumnType("nvarchar(max)"); + + b.HasKey("EstateId", "MerchantId", "AddressId"); + + b.ToTable("merchantaddress"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantContact", b => + { + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("MerchantId") + .HasColumnType("uniqueidentifier"); + + b.Property("ContactId") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("EmailAddress") + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("PhoneNumber") + .HasColumnType("nvarchar(max)"); + + b.HasKey("EstateId", "MerchantId", "ContactId"); + + b.ToTable("merchantcontact"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantDevice", b => + { + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("MerchantId") + .HasColumnType("uniqueidentifier"); + + b.Property("DeviceId") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("DeviceIdentifier") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("EstateId", "MerchantId", "DeviceId"); + + b.ToTable("merchantdevice"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantOperator", b => + { + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("MerchantId") + .HasColumnType("uniqueidentifier"); + + b.Property("OperatorId") + .HasColumnType("uniqueidentifier"); + + b.Property("MerchantNumber") + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("TerminalNumber") + .HasColumnType("nvarchar(max)"); + + b.HasKey("EstateId", "MerchantId", "OperatorId"); + + b.ToTable("merchantoperator"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantSecurityUser", b => + { + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("MerchantId") + .HasColumnType("uniqueidentifier"); + + b.Property("SecurityUserId") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("EmailAddress") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("EstateId", "MerchantId", "SecurityUserId"); + + b.ToTable("merchantsecurityuser"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantSettlementFee", b => + { + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("SettlementId") + .HasColumnType("uniqueidentifier"); + + b.Property("TransactionId") + .HasColumnType("uniqueidentifier"); + + b.Property("FeeId") + .HasColumnType("uniqueidentifier"); + + b.Property("CalculatedValue") + .HasColumnType("decimal(18,2)"); + + b.Property("FeeCalculatedDateTime") + .HasColumnType("datetime2"); + + b.Property("FeeValue") + .HasColumnType("decimal(18,2)"); + + b.Property("IsSettled") + .HasColumnType("bit"); + + b.Property("MerchantId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("EstateId", "SettlementId", "TransactionId", "FeeId"); + + b.ToTable("merchantsettlementfee"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Reconciliation", b => + { + b.Property("TransactionId") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("DeviceIdentifier") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("IsAuthorised") + .HasColumnType("bit"); + + b.Property("IsCompleted") + .HasColumnType("bit"); + + b.Property("MerchantId") + .HasColumnType("uniqueidentifier"); + + b.Property("ResponseCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ResponseMessage") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("TransactionCount") + .HasColumnType("int"); + + b.Property("TransactionDate") + .HasColumnType("datetime2"); + + b.Property("TransactionDateTime") + .HasColumnType("datetime2"); + + b.Property("TransactionTime") + .HasColumnType("time"); + + b.Property("TransactionValue") + .HasColumnType("decimal(18,2)"); + + b.HasKey("TransactionId"); + + b.ToTable("reconciliation"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.ResponseCodes", b => + { + b.Property("ResponseCode") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("ResponseCode"), 1L, 1); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("ResponseCode"); + + b.ToTable("responsecodes"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Settlement", b => + { + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("SettlementId") + .HasColumnType("uniqueidentifier"); + + b.Property("IsCompleted") + .HasColumnType("bit"); + + b.Property("SettlementDate") + .HasColumnType("datetime2"); + + b.HasKey("EstateId", "SettlementId"); + + b.ToTable("settlement"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.StatementHeader", b => + { + b.Property("StatementId") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("MerchantId") + .HasColumnType("uniqueidentifier"); + + b.Property("StatementCreatedDate") + .HasColumnType("datetime2"); + + b.Property("StatementGeneratedDate") + .HasColumnType("datetime2"); + + b.HasKey("StatementId"); + + b.ToTable("statementheader"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.StatementLine", b => + { + b.Property("StatementId") + .HasColumnType("uniqueidentifier"); + + b.Property("TransactionId") + .HasColumnType("uniqueidentifier"); + + b.Property("ActivityDateTime") + .HasColumnType("datetime2"); + + b.Property("ActivityType") + .HasColumnType("int"); + + b.Property("ActivityDescription") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("InAmount") + .HasColumnType("decimal(18,2)"); + + b.Property("MerchantId") + .HasColumnType("uniqueidentifier"); + + b.Property("OutAmount") + .HasColumnType("decimal(18,2)"); + + b.HasKey("StatementId", "TransactionId", "ActivityDateTime", "ActivityType"); + + b.ToTable("statementline"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Transaction", b => + { + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("MerchantId") + .HasColumnType("uniqueidentifier"); + + b.Property("TransactionId") + .HasColumnType("uniqueidentifier"); + + b.Property("AuthorisationCode") + .HasColumnType("nvarchar(max)"); + + b.Property("ContractId") + .HasColumnType("uniqueidentifier"); + + b.Property("DeviceIdentifier") + .HasColumnType("nvarchar(max)"); + + b.Property("IsAuthorised") + .HasColumnType("bit"); + + b.Property("IsCompleted") + .HasColumnType("bit"); + + b.Property("OperatorIdentifier") + .HasColumnType("nvarchar(max)"); + + b.Property("ProductId") + .HasColumnType("uniqueidentifier"); + + b.Property("ResponseCode") + .HasColumnType("nvarchar(max)"); + + b.Property("ResponseMessage") + .HasColumnType("nvarchar(max)"); + + b.Property("TransactionDate") + .HasColumnType("datetime2"); + + b.Property("TransactionDateTime") + .HasColumnType("datetime2"); + + b.Property("TransactionNumber") + .HasColumnType("nvarchar(max)"); + + b.Property("TransactionReference") + .HasColumnType("nvarchar(max)"); + + b.Property("TransactionSource") + .HasColumnType("int"); + + b.Property("TransactionTime") + .HasColumnType("time"); + + b.Property("TransactionType") + .HasColumnType("nvarchar(max)"); + + b.HasKey("EstateId", "MerchantId", "TransactionId"); + + b.ToTable("transaction"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.TransactionAdditionalRequestData", b => + { + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("MerchantId") + .HasColumnType("uniqueidentifier"); + + b.Property("TransactionId") + .HasColumnType("uniqueidentifier"); + + b.Property("Amount") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("CustomerAccountNumber") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("EstateId", "MerchantId", "TransactionId"); + + b.ToTable("transactionadditionalrequestdata"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.TransactionAdditionalResponseData", b => + { + b.Property("TransactionId") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("MerchantId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("TransactionId"); + + b.ToTable("transactionadditionalresponsedata"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.TransactionFee", b => + { + b.Property("TransactionId") + .HasColumnType("uniqueidentifier"); + + b.Property("FeeId") + .HasColumnType("uniqueidentifier"); + + b.Property("CalculatedValue") + .HasColumnType("decimal(18,2)"); + + b.Property("CalculationType") + .HasColumnType("int"); + + b.Property("EventId") + .HasColumnType("uniqueidentifier"); + + b.Property("FeeType") + .HasColumnType("int"); + + b.Property("FeeValue") + .HasColumnType("decimal(18,2)"); + + b.HasKey("TransactionId", "FeeId"); + + b.ToTable("transactionfee"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Voucher", b => + { + b.Property("VoucherId") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("ExpiryDate") + .HasColumnType("datetime2"); + + b.Property("GenerateDateTime") + .HasColumnType("datetime2"); + + b.Property("IsGenerated") + .HasColumnType("bit"); + + b.Property("IsIssued") + .HasColumnType("bit"); + + b.Property("IsRedeemed") + .HasColumnType("bit"); + + b.Property("IssuedDateTime") + .HasColumnType("datetime2"); + + b.Property("OperatorIdentifier") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("RecipientEmail") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("RecipientMobile") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("RedeemedDateTime") + .HasColumnType("datetime2"); + + b.Property("TransactionId") + .HasColumnType("uniqueidentifier"); + + b.Property("Value") + .HasColumnType("decimal(18,2)"); + + b.Property("VoucherCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("VoucherId"); + + b.ToTable("voucher"); + }); + + modelBuilder.Entity("EstateManagement.Database.ViewEntities.FileImportLogView", b => + { + b.Property("FileCount") + .HasColumnType("int"); + + b.Property("FileImportLogId") + .HasColumnType("uniqueidentifier"); + + b.Property("ImportLogDate") + .HasColumnType("datetime2"); + + b.Property("ImportLogDateTime") + .HasColumnType("datetime2"); + + b.Property("ImportLogTime") + .HasColumnType("time"); + + b.Property("MerchantId") + .HasColumnType("uniqueidentifier"); + + b.ToTable("uvwFileImportLogView"); + + b.ToView("uvwFileImportLog"); + }); + + modelBuilder.Entity("EstateManagement.Database.ViewEntities.FileView", b => + { + b.Property("EmailAddress") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("FailedCount") + .HasColumnType("int"); + + b.Property("FileId") + .HasColumnType("uniqueidentifier"); + + b.Property("FileReceivedDate") + .HasColumnType("datetime2"); + + b.Property("FileReceivedDateTime") + .HasColumnType("datetime2"); + + b.Property("FileReceivedTime") + .HasColumnType("time"); + + b.Property("IsCompleted") + .HasColumnType("bit"); + + b.Property("LineCount") + .HasColumnType("int"); + + b.Property("MerchantId") + .HasColumnType("uniqueidentifier"); + + b.Property("MerchantName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("PendingCount") + .HasColumnType("int"); + + b.Property("SuccessCount") + .HasColumnType("int"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.ToTable("uvwFileView"); + + b.ToView("uvwFile"); + }); + + modelBuilder.Entity("EstateManagement.Database.ViewEntities.SettlementView", b => + { + b.Property("Amount") + .HasColumnType("decimal(18,2)"); + + b.Property("CalculatedValue") + .HasColumnType("decimal(18,2)"); + + b.Property("DayOfWeek") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("FeeDescription") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsCompleted") + .HasColumnType("bit"); + + b.Property("IsSettled") + .HasColumnType("bit"); + + b.Property("MerchantId") + .HasColumnType("uniqueidentifier"); + + b.Property("MerchantName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Month") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("MonthNumber") + .HasColumnType("int"); + + b.Property("OperatorIdentifier") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("SettlementDate") + .HasColumnType("datetime2"); + + b.Property("SettlementId") + .HasColumnType("uniqueidentifier"); + + b.Property("TransactionId") + .HasColumnType("uniqueidentifier"); + + b.Property("WeekNumber") + .HasColumnType("int"); + + b.Property("YearNumber") + .HasColumnType("int"); + + b.ToView("uvwSettlements"); + }); + + modelBuilder.Entity("EstateManagement.Database.ViewEntities.TransactionsView", b => + { + b.Property("Amount") + .HasColumnType("decimal(18,2)"); + + b.Property("DayOfWeek") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("IsAuthorised") + .HasColumnType("bit"); + + b.Property("IsCompleted") + .HasColumnType("bit"); + + b.Property("MerchantId") + .HasColumnType("uniqueidentifier"); + + b.Property("Month") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("MonthNumber") + .HasColumnType("int"); + + b.Property("OperatorIdentifier") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ResponseCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("TransactionDate") + .HasColumnType("datetime2"); + + b.Property("TransactionDateTime") + .HasColumnType("datetime2"); + + b.Property("TransactionId") + .HasColumnType("uniqueidentifier"); + + b.Property("TransactionType") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("WeekNumber") + .HasColumnType("int"); + + b.Property("YearNumber") + .HasColumnType("int"); + + b.ToTable("uvwTransactionsView"); + + b.ToView("uvwTransactions"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/TransactionProcessor.Database/Migrations/SqlServer/20221115191516_InitialDatabase.cs b/TransactionProcessor.Database/Migrations/SqlServer/20221115191516_InitialDatabase.cs new file mode 100644 index 00000000..d66f0be8 --- /dev/null +++ b/TransactionProcessor.Database/Migrations/SqlServer/20221115191516_InitialDatabase.cs @@ -0,0 +1,654 @@ +#nullable disable + +using Microsoft.EntityFrameworkCore.Migrations; + +namespace TransactionProcessor.Database.Migrations.SqlServer +{ + public partial class InitialDatabase : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "calendar", + columns: table => new + { + Date = table.Column(type: "datetime2", nullable: false), + DayOfWeek = table.Column(type: "nvarchar(max)", nullable: false), + DayOfWeekNumber = table.Column(type: "int", nullable: false), + DayOfWeekShort = table.Column(type: "nvarchar(max)", nullable: false), + MonthNameLong = table.Column(type: "nvarchar(max)", nullable: false), + MonthNameShort = table.Column(type: "nvarchar(max)", nullable: false), + MonthNumber = table.Column(type: "int", nullable: false), + WeekNumber = table.Column(type: "int", nullable: true), + WeekNumberString = table.Column(type: "nvarchar(max)", nullable: false), + Year = table.Column(type: "int", nullable: false), + YearWeekNumber = table.Column(type: "nvarchar(max)", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_calendar", x => x.Date); + }); + + migrationBuilder.CreateTable( + name: "contract", + columns: table => new + { + ContractId = table.Column(type: "uniqueidentifier", nullable: false), + EstateId = table.Column(type: "uniqueidentifier", nullable: false), + OperatorId = table.Column(type: "uniqueidentifier", nullable: false), + Description = table.Column(type: "nvarchar(max)", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_contract", x => new { x.EstateId, x.OperatorId, x.ContractId }); + }); + + migrationBuilder.CreateTable( + name: "contractproduct", + columns: table => new + { + ContractId = table.Column(type: "uniqueidentifier", nullable: false), + EstateId = table.Column(type: "uniqueidentifier", nullable: false), + ProductId = table.Column(type: "uniqueidentifier", nullable: false), + DisplayText = table.Column(type: "nvarchar(max)", nullable: false), + ProductName = table.Column(type: "nvarchar(max)", nullable: false), + Value = table.Column(type: "decimal(18,2)", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_contractproduct", x => new { x.EstateId, x.ContractId, x.ProductId }); + }); + + migrationBuilder.CreateTable( + name: "contractproducttransactionfee", + columns: table => new + { + ContractId = table.Column(type: "uniqueidentifier", nullable: false), + EstateId = table.Column(type: "uniqueidentifier", nullable: false), + ProductId = table.Column(type: "uniqueidentifier", nullable: false), + TransactionFeeId = table.Column(type: "uniqueidentifier", nullable: false), + CalculationType = table.Column(type: "int", nullable: false), + FeeType = table.Column(type: "int", nullable: false), + IsEnabled = table.Column(type: "bit", nullable: false), + Description = table.Column(type: "nvarchar(max)", nullable: false), + Value = table.Column(type: "decimal(18,4)", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_contractproducttransactionfee", x => new { x.EstateId, x.ContractId, x.ProductId, x.TransactionFeeId }); + }); + + migrationBuilder.CreateTable( + name: "estate", + columns: table => new + { + EstateId = table.Column(type: "uniqueidentifier", nullable: false), + CreatedDateTime = table.Column(type: "datetime2", nullable: false), + Name = table.Column(type: "nvarchar(max)", nullable: false), + Reference = table.Column(type: "nvarchar(max)", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_estate", x => x.EstateId); + }); + + migrationBuilder.CreateTable( + name: "estateoperator", + columns: table => new + { + EstateId = table.Column(type: "uniqueidentifier", nullable: false), + OperatorId = table.Column(type: "uniqueidentifier", nullable: false), + Name = table.Column(type: "nvarchar(max)", nullable: false), + RequireCustomMerchantNumber = table.Column(type: "bit", nullable: false), + RequireCustomTerminalNumber = table.Column(type: "bit", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_estateoperator", x => new { x.EstateId, x.OperatorId }); + }); + + migrationBuilder.CreateTable( + name: "estatesecurityuser", + columns: table => new + { + EstateId = table.Column(type: "uniqueidentifier", nullable: false), + SecurityUserId = table.Column(type: "uniqueidentifier", nullable: false), + CreatedDateTime = table.Column(type: "datetime2", nullable: false), + EmailAddress = table.Column(type: "nvarchar(max)", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_estatesecurityuser", x => new { x.SecurityUserId, x.EstateId }); + }); + + migrationBuilder.CreateTable( + name: "file", + columns: table => new + { + EstateId = table.Column(type: "uniqueidentifier", nullable: false), + FileId = table.Column(type: "uniqueidentifier", nullable: false), + FileImportLogId = table.Column(type: "uniqueidentifier", nullable: false), + FileLocation = table.Column(type: "nvarchar(max)", nullable: false), + FileProfileId = table.Column(type: "uniqueidentifier", nullable: false), + FileReceivedDateTime = table.Column(type: "datetime2", nullable: false), + MerchantId = table.Column(type: "uniqueidentifier", nullable: false), + UserId = table.Column(type: "uniqueidentifier", nullable: false), + IsCompleted = table.Column(type: "bit", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_file", x => new { x.EstateId, x.FileImportLogId, x.FileId }); + }); + + migrationBuilder.CreateTable( + name: "fileimportlog", + columns: table => new + { + EstateId = table.Column(type: "uniqueidentifier", nullable: false), + FileImportLogId = table.Column(type: "uniqueidentifier", nullable: false), + ImportLogDateTime = table.Column(type: "datetime2", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_fileimportlog", x => new { x.EstateId, x.FileImportLogId }); + }); + + migrationBuilder.CreateTable( + name: "fileimportlogfile", + columns: table => new + { + EstateId = table.Column(type: "uniqueidentifier", nullable: false), + FileId = table.Column(type: "uniqueidentifier", nullable: false), + FileImportLogId = table.Column(type: "uniqueidentifier", nullable: false), + FilePath = table.Column(type: "nvarchar(max)", nullable: false), + FileProfileId = table.Column(type: "uniqueidentifier", nullable: false), + FileUploadedDateTime = table.Column(type: "datetime2", nullable: false), + MerchantId = table.Column(type: "uniqueidentifier", nullable: false), + OriginalFileName = table.Column(type: "nvarchar(max)", nullable: false), + UserId = table.Column(type: "uniqueidentifier", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_fileimportlogfile", x => new { x.EstateId, x.FileImportLogId, x.FileId }); + }); + + migrationBuilder.CreateTable( + name: "fileline", + columns: table => new + { + EstateId = table.Column(type: "uniqueidentifier", nullable: false), + FileId = table.Column(type: "uniqueidentifier", nullable: false), + LineNumber = table.Column(type: "int", nullable: false), + FileLineData = table.Column(type: "nvarchar(max)", nullable: false), + Status = table.Column(type: "nvarchar(max)", nullable: false), + TransactionId = table.Column(type: "uniqueidentifier", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_fileline", x => new { x.EstateId, x.FileId, x.LineNumber }); + }); + + migrationBuilder.CreateTable( + name: "merchant", + columns: table => new + { + EstateId = table.Column(type: "uniqueidentifier", nullable: false), + MerchantId = table.Column(type: "uniqueidentifier", nullable: false), + CreatedDateTime = table.Column(type: "datetime2", nullable: false), + Name = table.Column(type: "nvarchar(max)", nullable: false), + SettlementSchedule = table.Column(type: "int", nullable: false), + Reference = table.Column(type: "nvarchar(max)", nullable: true), + LastStatementGenerated = table.Column(type: "datetime2", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_merchant", x => new { x.EstateId, x.MerchantId }); + }); + + migrationBuilder.CreateTable( + name: "merchantaddress", + columns: table => new + { + AddressId = table.Column(type: "uniqueidentifier", nullable: false), + EstateId = table.Column(type: "uniqueidentifier", nullable: false), + MerchantId = table.Column(type: "uniqueidentifier", nullable: false), + AddressLine1 = table.Column(type: "nvarchar(max)", nullable: false), + AddressLine2 = table.Column(type: "nvarchar(max)", nullable: true), + AddressLine3 = table.Column(type: "nvarchar(max)", nullable: true), + AddressLine4 = table.Column(type: "nvarchar(max)", nullable: true), + Country = table.Column(type: "nvarchar(max)", nullable: true), + CreatedDateTime = table.Column(type: "datetime2", nullable: false), + PostalCode = table.Column(type: "nvarchar(max)", nullable: true), + Region = table.Column(type: "nvarchar(max)", nullable: true), + Town = table.Column(type: "nvarchar(max)", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_merchantaddress", x => new { x.EstateId, x.MerchantId, x.AddressId }); + }); + + migrationBuilder.CreateTable( + name: "merchantcontact", + columns: table => new + { + ContactId = table.Column(type: "uniqueidentifier", nullable: false), + EstateId = table.Column(type: "uniqueidentifier", nullable: false), + MerchantId = table.Column(type: "uniqueidentifier", nullable: false), + CreatedDateTime = table.Column(type: "datetime2", nullable: false), + EmailAddress = table.Column(type: "nvarchar(max)", nullable: true), + Name = table.Column(type: "nvarchar(max)", nullable: false), + PhoneNumber = table.Column(type: "nvarchar(max)", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_merchantcontact", x => new { x.EstateId, x.MerchantId, x.ContactId }); + }); + + migrationBuilder.CreateTable( + name: "merchantdevice", + columns: table => new + { + DeviceId = table.Column(type: "uniqueidentifier", nullable: false), + EstateId = table.Column(type: "uniqueidentifier", nullable: false), + MerchantId = table.Column(type: "uniqueidentifier", nullable: false), + CreatedDateTime = table.Column(type: "datetime2", nullable: false), + DeviceIdentifier = table.Column(type: "nvarchar(max)", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_merchantdevice", x => new { x.EstateId, x.MerchantId, x.DeviceId }); + }); + + migrationBuilder.CreateTable( + name: "merchantoperator", + columns: table => new + { + EstateId = table.Column(type: "uniqueidentifier", nullable: false), + MerchantId = table.Column(type: "uniqueidentifier", nullable: false), + OperatorId = table.Column(type: "uniqueidentifier", nullable: false), + MerchantNumber = table.Column(type: "nvarchar(max)", nullable: true), + Name = table.Column(type: "nvarchar(max)", nullable: false), + TerminalNumber = table.Column(type: "nvarchar(max)", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_merchantoperator", x => new { x.EstateId, x.MerchantId, x.OperatorId }); + }); + + migrationBuilder.CreateTable( + name: "merchantsecurityuser", + columns: table => new + { + EstateId = table.Column(type: "uniqueidentifier", nullable: false), + MerchantId = table.Column(type: "uniqueidentifier", nullable: false), + SecurityUserId = table.Column(type: "uniqueidentifier", nullable: false), + CreatedDateTime = table.Column(type: "datetime2", nullable: false), + EmailAddress = table.Column(type: "nvarchar(max)", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_merchantsecurityuser", x => new { x.EstateId, x.MerchantId, x.SecurityUserId }); + }); + + migrationBuilder.CreateTable( + name: "merchantsettlementfee", + columns: table => new + { + EstateId = table.Column(type: "uniqueidentifier", nullable: false), + FeeId = table.Column(type: "uniqueidentifier", nullable: false), + SettlementId = table.Column(type: "uniqueidentifier", nullable: false), + TransactionId = table.Column(type: "uniqueidentifier", nullable: false), + CalculatedValue = table.Column(type: "decimal(18,2)", nullable: false), + FeeCalculatedDateTime = table.Column(type: "datetime2", nullable: false), + FeeValue = table.Column(type: "decimal(18,2)", nullable: false), + IsSettled = table.Column(type: "bit", nullable: false), + MerchantId = table.Column(type: "uniqueidentifier", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_merchantsettlementfee", x => new { x.EstateId, x.SettlementId, x.TransactionId, x.FeeId }); + }); + + migrationBuilder.CreateTable( + name: "reconciliation", + columns: table => new + { + TransactionId = table.Column(type: "uniqueidentifier", nullable: false), + DeviceIdentifier = table.Column(type: "nvarchar(max)", nullable: false), + EstateId = table.Column(type: "uniqueidentifier", nullable: false), + IsAuthorised = table.Column(type: "bit", nullable: false), + IsCompleted = table.Column(type: "bit", nullable: false), + MerchantId = table.Column(type: "uniqueidentifier", nullable: false), + ResponseCode = table.Column(type: "nvarchar(max)", nullable: false), + ResponseMessage = table.Column(type: "nvarchar(max)", nullable: false), + TransactionCount = table.Column(type: "int", nullable: false), + TransactionDate = table.Column(type: "datetime2", nullable: false), + TransactionDateTime = table.Column(type: "datetime2", nullable: false), + TransactionTime = table.Column(type: "time", nullable: false), + TransactionValue = table.Column(type: "decimal(18,2)", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_reconciliation", x => x.TransactionId); + }); + + migrationBuilder.CreateTable( + name: "responsecodes", + columns: table => new + { + ResponseCode = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + Description = table.Column(type: "nvarchar(max)", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_responsecodes", x => x.ResponseCode); + }); + + migrationBuilder.CreateTable( + name: "settlement", + columns: table => new + { + EstateId = table.Column(type: "uniqueidentifier", nullable: false), + SettlementId = table.Column(type: "uniqueidentifier", nullable: false), + IsCompleted = table.Column(type: "bit", nullable: false), + SettlementDate = table.Column(type: "datetime2", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_settlement", x => new { x.EstateId, x.SettlementId }); + }); + + migrationBuilder.CreateTable( + name: "statementheader", + columns: table => new + { + StatementId = table.Column(type: "uniqueidentifier", nullable: false), + EstateId = table.Column(type: "uniqueidentifier", nullable: false), + MerchantId = table.Column(type: "uniqueidentifier", nullable: false), + StatementCreatedDate = table.Column(type: "datetime2", nullable: false), + StatementGeneratedDate = table.Column(type: "datetime2", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_statementheader", x => x.StatementId); + }); + + migrationBuilder.CreateTable( + name: "statementline", + columns: table => new + { + StatementId = table.Column(type: "uniqueidentifier", nullable: false), + ActivityDateTime = table.Column(type: "datetime2", nullable: false), + ActivityType = table.Column(type: "int", nullable: false), + TransactionId = table.Column(type: "uniqueidentifier", nullable: false), + EstateId = table.Column(type: "uniqueidentifier", nullable: false), + MerchantId = table.Column(type: "uniqueidentifier", nullable: false), + ActivityDescription = table.Column(type: "nvarchar(max)", nullable: false), + InAmount = table.Column(type: "decimal(18,2)", nullable: false), + OutAmount = table.Column(type: "decimal(18,2)", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_statementline", x => new { x.StatementId, x.TransactionId, x.ActivityDateTime, x.ActivityType }); + }); + + migrationBuilder.CreateTable( + name: "transaction", + columns: table => new + { + EstateId = table.Column(type: "uniqueidentifier", nullable: false), + MerchantId = table.Column(type: "uniqueidentifier", nullable: false), + TransactionId = table.Column(type: "uniqueidentifier", nullable: false), + AuthorisationCode = table.Column(type: "nvarchar(max)", nullable: true), + ContractId = table.Column(type: "uniqueidentifier", nullable: false), + DeviceIdentifier = table.Column(type: "nvarchar(max)", nullable: true), + IsAuthorised = table.Column(type: "bit", nullable: false), + IsCompleted = table.Column(type: "bit", nullable: false), + OperatorIdentifier = table.Column(type: "nvarchar(max)", nullable: true), + ProductId = table.Column(type: "uniqueidentifier", nullable: false), + ResponseCode = table.Column(type: "nvarchar(max)", nullable: true), + ResponseMessage = table.Column(type: "nvarchar(max)", nullable: true), + TransactionDate = table.Column(type: "datetime2", nullable: false), + TransactionDateTime = table.Column(type: "datetime2", nullable: false), + TransactionNumber = table.Column(type: "nvarchar(max)", nullable: true), + TransactionReference = table.Column(type: "nvarchar(max)", nullable: true), + TransactionTime = table.Column(type: "time", nullable: false), + TransactionType = table.Column(type: "nvarchar(max)", nullable: true), + TransactionSource = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_transaction", x => new { x.EstateId, x.MerchantId, x.TransactionId }); + }); + + migrationBuilder.CreateTable( + name: "transactionadditionalrequestdata", + columns: table => new + { + EstateId = table.Column(type: "uniqueidentifier", nullable: false), + MerchantId = table.Column(type: "uniqueidentifier", nullable: false), + TransactionId = table.Column(type: "uniqueidentifier", nullable: false), + Amount = table.Column(type: "nvarchar(max)", nullable: false), + CustomerAccountNumber = table.Column(type: "nvarchar(max)", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_transactionadditionalrequestdata", x => new { x.EstateId, x.MerchantId, x.TransactionId }); + }); + + migrationBuilder.CreateTable( + name: "transactionadditionalresponsedata", + columns: table => new + { + TransactionId = table.Column(type: "uniqueidentifier", nullable: false), + EstateId = table.Column(type: "uniqueidentifier", nullable: false), + MerchantId = table.Column(type: "uniqueidentifier", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_transactionadditionalresponsedata", x => x.TransactionId); + }); + + migrationBuilder.CreateTable( + name: "transactionfee", + columns: table => new + { + FeeId = table.Column(type: "uniqueidentifier", nullable: false), + TransactionId = table.Column(type: "uniqueidentifier", nullable: false), + CalculatedValue = table.Column(type: "decimal(18,2)", nullable: false), + CalculationType = table.Column(type: "int", nullable: false), + EventId = table.Column(type: "uniqueidentifier", nullable: false), + FeeType = table.Column(type: "int", nullable: false), + FeeValue = table.Column(type: "decimal(18,2)", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_transactionfee", x => new { x.TransactionId, x.FeeId }); + }); + + migrationBuilder.CreateTable( + name: "uvwFileImportLogView", + columns: table => new + { + FileImportLogId = table.Column(type: "uniqueidentifier", nullable: false), + ImportLogDateTime = table.Column(type: "datetime2", nullable: false), + ImportLogDate = table.Column(type: "datetime2", nullable: false), + ImportLogTime = table.Column(type: "time", nullable: false), + FileCount = table.Column(type: "int", nullable: false), + MerchantId = table.Column(type: "uniqueidentifier", nullable: false) + }, + constraints: table => + { + }); + + migrationBuilder.CreateTable( + name: "uvwFileView", + columns: table => new + { + FileId = table.Column(type: "uniqueidentifier", nullable: false), + FileReceivedDateTime = table.Column(type: "datetime2", nullable: false), + FileReceivedDate = table.Column(type: "datetime2", nullable: false), + FileReceivedTime = table.Column(type: "time", nullable: false), + IsCompleted = table.Column(type: "bit", nullable: false), + MerchantId = table.Column(type: "uniqueidentifier", nullable: false), + MerchantName = table.Column(type: "nvarchar(max)", nullable: false), + UserId = table.Column(type: "uniqueidentifier", nullable: false), + EmailAddress = table.Column(type: "nvarchar(max)", nullable: false), + LineCount = table.Column(type: "int", nullable: false), + PendingCount = table.Column(type: "int", nullable: false), + FailedCount = table.Column(type: "int", nullable: false), + SuccessCount = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + }); + + migrationBuilder.CreateTable( + name: "uvwTransactionsView", + columns: table => new + { + TransactionId = table.Column(type: "uniqueidentifier", nullable: false), + TransactionDateTime = table.Column(type: "datetime2", nullable: false), + TransactionDate = table.Column(type: "datetime2", nullable: false), + DayOfWeek = table.Column(type: "nvarchar(max)", nullable: false), + WeekNumber = table.Column(type: "int", nullable: false), + Month = table.Column(type: "nvarchar(max)", nullable: false), + MonthNumber = table.Column(type: "int", nullable: false), + YearNumber = table.Column(type: "int", nullable: false), + EstateId = table.Column(type: "uniqueidentifier", nullable: false), + MerchantId = table.Column(type: "uniqueidentifier", nullable: false), + IsAuthorised = table.Column(type: "bit", nullable: false), + IsCompleted = table.Column(type: "bit", nullable: false), + TransactionType = table.Column(type: "nvarchar(max)", nullable: false), + ResponseCode = table.Column(type: "nvarchar(max)", nullable: false), + Amount = table.Column(type: "decimal(18,2)", nullable: false), + OperatorIdentifier = table.Column(type: "nvarchar(max)", nullable: false) + }, + constraints: table => + { + }); + + migrationBuilder.CreateTable( + name: "voucher", + columns: table => new + { + VoucherId = table.Column(type: "uniqueidentifier", nullable: false), + EstateId = table.Column(type: "uniqueidentifier", nullable: false), + ExpiryDate = table.Column(type: "datetime2", nullable: false), + IsGenerated = table.Column(type: "bit", nullable: false), + IsIssued = table.Column(type: "bit", nullable: false), + IsRedeemed = table.Column(type: "bit", nullable: false), + OperatorIdentifier = table.Column(type: "nvarchar(max)", nullable: false), + RecipientEmail = table.Column(type: "nvarchar(max)", nullable: false), + RecipientMobile = table.Column(type: "nvarchar(max)", nullable: false), + Value = table.Column(type: "decimal(18,2)", nullable: false), + VoucherCode = table.Column(type: "nvarchar(max)", nullable: false), + TransactionId = table.Column(type: "uniqueidentifier", nullable: false), + GenerateDateTime = table.Column(type: "datetime2", nullable: false), + IssuedDateTime = table.Column(type: "datetime2", nullable: false), + RedeemedDateTime = table.Column(type: "datetime2", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_voucher", x => x.VoucherId); + }); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "calendar"); + + migrationBuilder.DropTable( + name: "contract"); + + migrationBuilder.DropTable( + name: "contractproduct"); + + migrationBuilder.DropTable( + name: "contractproducttransactionfee"); + + migrationBuilder.DropTable( + name: "estate"); + + migrationBuilder.DropTable( + name: "estateoperator"); + + migrationBuilder.DropTable( + name: "estatesecurityuser"); + + migrationBuilder.DropTable( + name: "file"); + + migrationBuilder.DropTable( + name: "fileimportlog"); + + migrationBuilder.DropTable( + name: "fileimportlogfile"); + + migrationBuilder.DropTable( + name: "fileline"); + + migrationBuilder.DropTable( + name: "merchant"); + + migrationBuilder.DropTable( + name: "merchantaddress"); + + migrationBuilder.DropTable( + name: "merchantcontact"); + + migrationBuilder.DropTable( + name: "merchantdevice"); + + migrationBuilder.DropTable( + name: "merchantoperator"); + + migrationBuilder.DropTable( + name: "merchantsecurityuser"); + + migrationBuilder.DropTable( + name: "merchantsettlementfee"); + + migrationBuilder.DropTable( + name: "reconciliation"); + + migrationBuilder.DropTable( + name: "responsecodes"); + + migrationBuilder.DropTable( + name: "settlement"); + + migrationBuilder.DropTable( + name: "statementheader"); + + migrationBuilder.DropTable( + name: "statementline"); + + migrationBuilder.DropTable( + name: "transaction"); + + migrationBuilder.DropTable( + name: "transactionadditionalrequestdata"); + + migrationBuilder.DropTable( + name: "transactionadditionalresponsedata"); + + migrationBuilder.DropTable( + name: "transactionfee"); + + migrationBuilder.DropTable( + name: "uvwFileImportLogView"); + + migrationBuilder.DropTable( + name: "uvwFileView"); + + migrationBuilder.DropTable( + name: "uvwTransactionsView"); + + migrationBuilder.DropTable( + name: "voucher"); + } + } +} diff --git a/TransactionProcessor.Database/Migrations/SqlServer/20221116081939_somenullfixes.Designer.cs b/TransactionProcessor.Database/Migrations/SqlServer/20221116081939_somenullfixes.Designer.cs new file mode 100644 index 00000000..4872005f --- /dev/null +++ b/TransactionProcessor.Database/Migrations/SqlServer/20221116081939_somenullfixes.Designer.cs @@ -0,0 +1,1061 @@ +// + +#nullable disable + +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using TransactionProcessor.Database.Contexts; + +namespace TransactionProcessor.Database.Migrations.SqlServer +{ + [DbContext(typeof(EstateManagementSqlServerContext))] + [Migration("20221116081939_somenullfixes")] + partial class somenullfixes + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "6.0.5") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1); + + modelBuilder.Entity("EstateManagement.Database.Entities.Calendar", b => + { + b.Property("Date") + .HasColumnType("datetime2"); + + b.Property("DayOfWeek") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("DayOfWeekNumber") + .HasColumnType("int"); + + b.Property("DayOfWeekShort") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("MonthNameLong") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("MonthNameShort") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("MonthNumber") + .HasColumnType("int"); + + b.Property("WeekNumber") + .HasColumnType("int"); + + b.Property("WeekNumberString") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Year") + .HasColumnType("int"); + + b.Property("YearWeekNumber") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Date"); + + b.ToTable("calendar"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Contract", b => + { + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("OperatorId") + .HasColumnType("uniqueidentifier"); + + b.Property("ContractId") + .HasColumnType("uniqueidentifier"); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("EstateId", "OperatorId", "ContractId"); + + b.ToTable("contract"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.ContractProduct", b => + { + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("ContractId") + .HasColumnType("uniqueidentifier"); + + b.Property("ProductId") + .HasColumnType("uniqueidentifier"); + + b.Property("DisplayText") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ProductName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Value") + .HasColumnType("decimal(18,2)"); + + b.HasKey("EstateId", "ContractId", "ProductId"); + + b.ToTable("contractproduct"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.ContractProductTransactionFee", b => + { + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("ContractId") + .HasColumnType("uniqueidentifier"); + + b.Property("ProductId") + .HasColumnType("uniqueidentifier"); + + b.Property("TransactionFeeId") + .HasColumnType("uniqueidentifier"); + + b.Property("CalculationType") + .HasColumnType("int"); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("FeeType") + .HasColumnType("int"); + + b.Property("IsEnabled") + .HasColumnType("bit"); + + b.Property("Value") + .HasColumnType("decimal(18,4)"); + + b.HasKey("EstateId", "ContractId", "ProductId", "TransactionFeeId"); + + b.ToTable("contractproducttransactionfee"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Estate", b => + { + b.Property("EstateId") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Reference") + .HasColumnType("nvarchar(max)"); + + b.HasKey("EstateId"); + + b.ToTable("estate"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.EstateOperator", b => + { + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("OperatorId") + .HasColumnType("uniqueidentifier"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("RequireCustomMerchantNumber") + .HasColumnType("bit"); + + b.Property("RequireCustomTerminalNumber") + .HasColumnType("bit"); + + b.HasKey("EstateId", "OperatorId"); + + b.ToTable("estateoperator"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.EstateSecurityUser", b => + { + b.Property("SecurityUserId") + .HasColumnType("uniqueidentifier"); + + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("EmailAddress") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("SecurityUserId", "EstateId"); + + b.ToTable("estatesecurityuser"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.File", b => + { + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("FileImportLogId") + .HasColumnType("uniqueidentifier"); + + b.Property("FileId") + .HasColumnType("uniqueidentifier"); + + b.Property("FileLocation") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("FileProfileId") + .HasColumnType("uniqueidentifier"); + + b.Property("FileReceivedDateTime") + .HasColumnType("datetime2"); + + b.Property("IsCompleted") + .HasColumnType("bit"); + + b.Property("MerchantId") + .HasColumnType("uniqueidentifier"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("EstateId", "FileImportLogId", "FileId"); + + b.ToTable("file"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.FileImportLog", b => + { + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("FileImportLogId") + .HasColumnType("uniqueidentifier"); + + b.Property("ImportLogDateTime") + .HasColumnType("datetime2"); + + b.HasKey("EstateId", "FileImportLogId"); + + b.ToTable("fileimportlog"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.FileImportLogFile", b => + { + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("FileImportLogId") + .HasColumnType("uniqueidentifier"); + + b.Property("FileId") + .HasColumnType("uniqueidentifier"); + + b.Property("FilePath") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("FileProfileId") + .HasColumnType("uniqueidentifier"); + + b.Property("FileUploadedDateTime") + .HasColumnType("datetime2"); + + b.Property("MerchantId") + .HasColumnType("uniqueidentifier"); + + b.Property("OriginalFileName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("EstateId", "FileImportLogId", "FileId"); + + b.ToTable("fileimportlogfile"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.FileLine", b => + { + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("FileId") + .HasColumnType("uniqueidentifier"); + + b.Property("LineNumber") + .HasColumnType("int"); + + b.Property("FileLineData") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Status") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("TransactionId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("EstateId", "FileId", "LineNumber"); + + b.ToTable("fileline"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Merchant", b => + { + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("MerchantId") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("LastStatementGenerated") + .HasColumnType("datetime2"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Reference") + .HasColumnType("nvarchar(max)"); + + b.Property("SettlementSchedule") + .HasColumnType("int"); + + b.HasKey("EstateId", "MerchantId"); + + b.ToTable("merchant"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantAddress", b => + { + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("MerchantId") + .HasColumnType("uniqueidentifier"); + + b.Property("AddressId") + .HasColumnType("uniqueidentifier"); + + b.Property("AddressLine1") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("AddressLine2") + .HasColumnType("nvarchar(max)"); + + b.Property("AddressLine3") + .HasColumnType("nvarchar(max)"); + + b.Property("AddressLine4") + .HasColumnType("nvarchar(max)"); + + b.Property("Country") + .HasColumnType("nvarchar(max)"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("PostalCode") + .HasColumnType("nvarchar(max)"); + + b.Property("Region") + .HasColumnType("nvarchar(max)"); + + b.Property("Town") + .HasColumnType("nvarchar(max)"); + + b.HasKey("EstateId", "MerchantId", "AddressId"); + + b.ToTable("merchantaddress"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantContact", b => + { + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("MerchantId") + .HasColumnType("uniqueidentifier"); + + b.Property("ContactId") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("EmailAddress") + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("PhoneNumber") + .HasColumnType("nvarchar(max)"); + + b.HasKey("EstateId", "MerchantId", "ContactId"); + + b.ToTable("merchantcontact"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantDevice", b => + { + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("MerchantId") + .HasColumnType("uniqueidentifier"); + + b.Property("DeviceId") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("DeviceIdentifier") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("EstateId", "MerchantId", "DeviceId"); + + b.ToTable("merchantdevice"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantOperator", b => + { + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("MerchantId") + .HasColumnType("uniqueidentifier"); + + b.Property("OperatorId") + .HasColumnType("uniqueidentifier"); + + b.Property("MerchantNumber") + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("TerminalNumber") + .HasColumnType("nvarchar(max)"); + + b.HasKey("EstateId", "MerchantId", "OperatorId"); + + b.ToTable("merchantoperator"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantSecurityUser", b => + { + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("MerchantId") + .HasColumnType("uniqueidentifier"); + + b.Property("SecurityUserId") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("EmailAddress") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("EstateId", "MerchantId", "SecurityUserId"); + + b.ToTable("merchantsecurityuser"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantSettlementFee", b => + { + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("SettlementId") + .HasColumnType("uniqueidentifier"); + + b.Property("TransactionId") + .HasColumnType("uniqueidentifier"); + + b.Property("FeeId") + .HasColumnType("uniqueidentifier"); + + b.Property("CalculatedValue") + .HasColumnType("decimal(18,2)"); + + b.Property("FeeCalculatedDateTime") + .HasColumnType("datetime2"); + + b.Property("FeeValue") + .HasColumnType("decimal(18,2)"); + + b.Property("IsSettled") + .HasColumnType("bit"); + + b.Property("MerchantId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("EstateId", "SettlementId", "TransactionId", "FeeId"); + + b.ToTable("merchantsettlementfee"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Reconciliation", b => + { + b.Property("TransactionId") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("DeviceIdentifier") + .HasColumnType("nvarchar(max)"); + + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("IsAuthorised") + .HasColumnType("bit"); + + b.Property("IsCompleted") + .HasColumnType("bit"); + + b.Property("MerchantId") + .HasColumnType("uniqueidentifier"); + + b.Property("ResponseCode") + .HasColumnType("nvarchar(max)"); + + b.Property("ResponseMessage") + .HasColumnType("nvarchar(max)"); + + b.Property("TransactionCount") + .HasColumnType("int"); + + b.Property("TransactionDate") + .HasColumnType("datetime2"); + + b.Property("TransactionDateTime") + .HasColumnType("datetime2"); + + b.Property("TransactionTime") + .HasColumnType("time"); + + b.Property("TransactionValue") + .HasColumnType("decimal(18,2)"); + + b.HasKey("TransactionId"); + + b.ToTable("reconciliation"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.ResponseCodes", b => + { + b.Property("ResponseCode") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("ResponseCode"), 1L, 1); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("ResponseCode"); + + b.ToTable("responsecodes"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Settlement", b => + { + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("SettlementId") + .HasColumnType("uniqueidentifier"); + + b.Property("IsCompleted") + .HasColumnType("bit"); + + b.Property("SettlementDate") + .HasColumnType("datetime2"); + + b.HasKey("EstateId", "SettlementId"); + + b.ToTable("settlement"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.StatementHeader", b => + { + b.Property("StatementId") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("MerchantId") + .HasColumnType("uniqueidentifier"); + + b.Property("StatementCreatedDate") + .HasColumnType("datetime2"); + + b.Property("StatementGeneratedDate") + .HasColumnType("datetime2"); + + b.HasKey("StatementId"); + + b.ToTable("statementheader"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.StatementLine", b => + { + b.Property("StatementId") + .HasColumnType("uniqueidentifier"); + + b.Property("TransactionId") + .HasColumnType("uniqueidentifier"); + + b.Property("ActivityDateTime") + .HasColumnType("datetime2"); + + b.Property("ActivityType") + .HasColumnType("int"); + + b.Property("ActivityDescription") + .HasColumnType("nvarchar(max)"); + + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("InAmount") + .HasColumnType("decimal(18,2)"); + + b.Property("MerchantId") + .HasColumnType("uniqueidentifier"); + + b.Property("OutAmount") + .HasColumnType("decimal(18,2)"); + + b.HasKey("StatementId", "TransactionId", "ActivityDateTime", "ActivityType"); + + b.ToTable("statementline"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Transaction", b => + { + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("MerchantId") + .HasColumnType("uniqueidentifier"); + + b.Property("TransactionId") + .HasColumnType("uniqueidentifier"); + + b.Property("AuthorisationCode") + .HasColumnType("nvarchar(max)"); + + b.Property("ContractId") + .HasColumnType("uniqueidentifier"); + + b.Property("DeviceIdentifier") + .HasColumnType("nvarchar(max)"); + + b.Property("IsAuthorised") + .HasColumnType("bit"); + + b.Property("IsCompleted") + .HasColumnType("bit"); + + b.Property("OperatorIdentifier") + .HasColumnType("nvarchar(max)"); + + b.Property("ProductId") + .HasColumnType("uniqueidentifier"); + + b.Property("ResponseCode") + .HasColumnType("nvarchar(max)"); + + b.Property("ResponseMessage") + .HasColumnType("nvarchar(max)"); + + b.Property("TransactionDate") + .HasColumnType("datetime2"); + + b.Property("TransactionDateTime") + .HasColumnType("datetime2"); + + b.Property("TransactionNumber") + .HasColumnType("nvarchar(max)"); + + b.Property("TransactionReference") + .HasColumnType("nvarchar(max)"); + + b.Property("TransactionSource") + .HasColumnType("int"); + + b.Property("TransactionTime") + .HasColumnType("time"); + + b.Property("TransactionType") + .HasColumnType("nvarchar(max)"); + + b.HasKey("EstateId", "MerchantId", "TransactionId"); + + b.ToTable("transaction"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.TransactionAdditionalRequestData", b => + { + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("MerchantId") + .HasColumnType("uniqueidentifier"); + + b.Property("TransactionId") + .HasColumnType("uniqueidentifier"); + + b.Property("Amount") + .HasColumnType("nvarchar(max)"); + + b.Property("CustomerAccountNumber") + .HasColumnType("nvarchar(max)"); + + b.HasKey("EstateId", "MerchantId", "TransactionId"); + + b.ToTable("transactionadditionalrequestdata"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.TransactionAdditionalResponseData", b => + { + b.Property("TransactionId") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("MerchantId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("TransactionId"); + + b.ToTable("transactionadditionalresponsedata"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.TransactionFee", b => + { + b.Property("TransactionId") + .HasColumnType("uniqueidentifier"); + + b.Property("FeeId") + .HasColumnType("uniqueidentifier"); + + b.Property("CalculatedValue") + .HasColumnType("decimal(18,2)"); + + b.Property("CalculationType") + .HasColumnType("int"); + + b.Property("EventId") + .HasColumnType("uniqueidentifier"); + + b.Property("FeeType") + .HasColumnType("int"); + + b.Property("FeeValue") + .HasColumnType("decimal(18,2)"); + + b.HasKey("TransactionId", "FeeId"); + + b.ToTable("transactionfee"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Voucher", b => + { + b.Property("VoucherId") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("ExpiryDate") + .HasColumnType("datetime2"); + + b.Property("GenerateDateTime") + .HasColumnType("datetime2"); + + b.Property("IsGenerated") + .HasColumnType("bit"); + + b.Property("IsIssued") + .HasColumnType("bit"); + + b.Property("IsRedeemed") + .HasColumnType("bit"); + + b.Property("IssuedDateTime") + .HasColumnType("datetime2"); + + b.Property("OperatorIdentifier") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("RecipientEmail") + .HasColumnType("nvarchar(max)"); + + b.Property("RecipientMobile") + .HasColumnType("nvarchar(max)"); + + b.Property("RedeemedDateTime") + .HasColumnType("datetime2"); + + b.Property("TransactionId") + .HasColumnType("uniqueidentifier"); + + b.Property("Value") + .HasColumnType("decimal(18,2)"); + + b.Property("VoucherCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("VoucherId"); + + b.ToTable("voucher"); + }); + + modelBuilder.Entity("EstateManagement.Database.ViewEntities.FileImportLogView", b => + { + b.Property("FileCount") + .HasColumnType("int"); + + b.Property("FileImportLogId") + .HasColumnType("uniqueidentifier"); + + b.Property("ImportLogDate") + .HasColumnType("datetime2"); + + b.Property("ImportLogDateTime") + .HasColumnType("datetime2"); + + b.Property("ImportLogTime") + .HasColumnType("time"); + + b.Property("MerchantId") + .HasColumnType("uniqueidentifier"); + + b.ToTable("uvwFileImportLogView"); + + b.ToView("uvwFileImportLog"); + }); + + modelBuilder.Entity("EstateManagement.Database.ViewEntities.FileView", b => + { + b.Property("EmailAddress") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("FailedCount") + .HasColumnType("int"); + + b.Property("FileId") + .HasColumnType("uniqueidentifier"); + + b.Property("FileReceivedDate") + .HasColumnType("datetime2"); + + b.Property("FileReceivedDateTime") + .HasColumnType("datetime2"); + + b.Property("FileReceivedTime") + .HasColumnType("time"); + + b.Property("IsCompleted") + .HasColumnType("bit"); + + b.Property("LineCount") + .HasColumnType("int"); + + b.Property("MerchantId") + .HasColumnType("uniqueidentifier"); + + b.Property("MerchantName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("PendingCount") + .HasColumnType("int"); + + b.Property("SuccessCount") + .HasColumnType("int"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.ToTable("uvwFileView"); + + b.ToView("uvwFile"); + }); + + modelBuilder.Entity("EstateManagement.Database.ViewEntities.SettlementView", b => + { + b.Property("Amount") + .HasColumnType("decimal(18,2)"); + + b.Property("CalculatedValue") + .HasColumnType("decimal(18,2)"); + + b.Property("DayOfWeek") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("FeeDescription") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsCompleted") + .HasColumnType("bit"); + + b.Property("IsSettled") + .HasColumnType("bit"); + + b.Property("MerchantId") + .HasColumnType("uniqueidentifier"); + + b.Property("MerchantName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Month") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("MonthNumber") + .HasColumnType("int"); + + b.Property("OperatorIdentifier") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("SettlementDate") + .HasColumnType("datetime2"); + + b.Property("SettlementId") + .HasColumnType("uniqueidentifier"); + + b.Property("TransactionId") + .HasColumnType("uniqueidentifier"); + + b.Property("WeekNumber") + .HasColumnType("int"); + + b.Property("YearNumber") + .HasColumnType("int"); + + b.ToView("uvwSettlements"); + }); + + modelBuilder.Entity("EstateManagement.Database.ViewEntities.TransactionsView", b => + { + b.Property("Amount") + .HasColumnType("decimal(18,2)"); + + b.Property("DayOfWeek") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("IsAuthorised") + .HasColumnType("bit"); + + b.Property("IsCompleted") + .HasColumnType("bit"); + + b.Property("MerchantId") + .HasColumnType("uniqueidentifier"); + + b.Property("Month") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("MonthNumber") + .HasColumnType("int"); + + b.Property("OperatorIdentifier") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ResponseCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("TransactionDate") + .HasColumnType("datetime2"); + + b.Property("TransactionDateTime") + .HasColumnType("datetime2"); + + b.Property("TransactionId") + .HasColumnType("uniqueidentifier"); + + b.Property("TransactionType") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("WeekNumber") + .HasColumnType("int"); + + b.Property("YearNumber") + .HasColumnType("int"); + + b.ToTable("uvwTransactionsView"); + + b.ToView("uvwTransactions"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/TransactionProcessor.Database/Migrations/SqlServer/20221116081939_somenullfixes.cs b/TransactionProcessor.Database/Migrations/SqlServer/20221116081939_somenullfixes.cs new file mode 100644 index 00000000..16f1a34c --- /dev/null +++ b/TransactionProcessor.Database/Migrations/SqlServer/20221116081939_somenullfixes.cs @@ -0,0 +1,159 @@ +#nullable disable + +using Microsoft.EntityFrameworkCore.Migrations; + +namespace TransactionProcessor.Database.Migrations.SqlServer +{ + public partial class somenullfixes : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterColumn( + name: "RecipientMobile", + table: "voucher", + type: "nvarchar(max)", + nullable: true, + oldClrType: typeof(string), + oldType: "nvarchar(max)"); + + migrationBuilder.AlterColumn( + name: "RecipientEmail", + table: "voucher", + type: "nvarchar(max)", + nullable: true, + oldClrType: typeof(string), + oldType: "nvarchar(max)"); + + migrationBuilder.AlterColumn( + name: "CustomerAccountNumber", + table: "transactionadditionalrequestdata", + type: "nvarchar(max)", + nullable: true, + oldClrType: typeof(string), + oldType: "nvarchar(max)"); + + migrationBuilder.AlterColumn( + name: "Amount", + table: "transactionadditionalrequestdata", + type: "nvarchar(max)", + nullable: true, + oldClrType: typeof(string), + oldType: "nvarchar(max)"); + + migrationBuilder.AlterColumn( + name: "ActivityDescription", + table: "statementline", + type: "nvarchar(max)", + nullable: true, + oldClrType: typeof(string), + oldType: "nvarchar(max)"); + + migrationBuilder.AlterColumn( + name: "ResponseMessage", + table: "reconciliation", + type: "nvarchar(max)", + nullable: true, + oldClrType: typeof(string), + oldType: "nvarchar(max)"); + + migrationBuilder.AlterColumn( + name: "ResponseCode", + table: "reconciliation", + type: "nvarchar(max)", + nullable: true, + oldClrType: typeof(string), + oldType: "nvarchar(max)"); + + migrationBuilder.AlterColumn( + name: "DeviceIdentifier", + table: "reconciliation", + type: "nvarchar(max)", + nullable: true, + oldClrType: typeof(string), + oldType: "nvarchar(max)"); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterColumn( + name: "RecipientMobile", + table: "voucher", + type: "nvarchar(max)", + nullable: false, + defaultValue: "", + oldClrType: typeof(string), + oldType: "nvarchar(max)", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "RecipientEmail", + table: "voucher", + type: "nvarchar(max)", + nullable: false, + defaultValue: "", + oldClrType: typeof(string), + oldType: "nvarchar(max)", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CustomerAccountNumber", + table: "transactionadditionalrequestdata", + type: "nvarchar(max)", + nullable: false, + defaultValue: "", + oldClrType: typeof(string), + oldType: "nvarchar(max)", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "Amount", + table: "transactionadditionalrequestdata", + type: "nvarchar(max)", + nullable: false, + defaultValue: "", + oldClrType: typeof(string), + oldType: "nvarchar(max)", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "ActivityDescription", + table: "statementline", + type: "nvarchar(max)", + nullable: false, + defaultValue: "", + oldClrType: typeof(string), + oldType: "nvarchar(max)", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "ResponseMessage", + table: "reconciliation", + type: "nvarchar(max)", + nullable: false, + defaultValue: "", + oldClrType: typeof(string), + oldType: "nvarchar(max)", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "ResponseCode", + table: "reconciliation", + type: "nvarchar(max)", + nullable: false, + defaultValue: "", + oldClrType: typeof(string), + oldType: "nvarchar(max)", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "DeviceIdentifier", + table: "reconciliation", + type: "nvarchar(max)", + nullable: false, + defaultValue: "", + oldClrType: typeof(string), + oldType: "nvarchar(max)", + oldNullable: true); + } + } +} diff --git a/TransactionProcessor.Database/Migrations/SqlServer/20230116113030_recordproducttype.Designer.cs b/TransactionProcessor.Database/Migrations/SqlServer/20230116113030_recordproducttype.Designer.cs new file mode 100644 index 00000000..b29e717f --- /dev/null +++ b/TransactionProcessor.Database/Migrations/SqlServer/20230116113030_recordproducttype.Designer.cs @@ -0,0 +1,1067 @@ +// + +#nullable disable + +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using TransactionProcessor.Database.Contexts; + +namespace TransactionProcessor.Database.Migrations.SqlServer +{ + [DbContext(typeof(EstateManagementSqlServerContext))] + [Migration("20230116113030_recordproducttype")] + partial class recordproducttype + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "7.0.0") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("EstateManagement.Database.Entities.Calendar", b => + { + b.Property("Date") + .HasColumnType("datetime2"); + + b.Property("DayOfWeek") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("DayOfWeekNumber") + .HasColumnType("int"); + + b.Property("DayOfWeekShort") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("MonthNameLong") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("MonthNameShort") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("MonthNumber") + .HasColumnType("int"); + + b.Property("WeekNumber") + .HasColumnType("int"); + + b.Property("WeekNumberString") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Year") + .HasColumnType("int"); + + b.Property("YearWeekNumber") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Date"); + + b.ToTable("calendar"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Contract", b => + { + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("OperatorId") + .HasColumnType("uniqueidentifier"); + + b.Property("ContractId") + .HasColumnType("uniqueidentifier"); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("EstateId", "OperatorId", "ContractId"); + + b.ToTable("contract"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.ContractProduct", b => + { + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("ContractId") + .HasColumnType("uniqueidentifier"); + + b.Property("ProductId") + .HasColumnType("uniqueidentifier"); + + b.Property("DisplayText") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ProductName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ProductType") + .HasColumnType("int"); + + b.Property("Value") + .HasColumnType("decimal(18,2)"); + + b.HasKey("EstateId", "ContractId", "ProductId"); + + b.ToTable("contractproduct"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.ContractProductTransactionFee", b => + { + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("ContractId") + .HasColumnType("uniqueidentifier"); + + b.Property("ProductId") + .HasColumnType("uniqueidentifier"); + + b.Property("TransactionFeeId") + .HasColumnType("uniqueidentifier"); + + b.Property("CalculationType") + .HasColumnType("int"); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("FeeType") + .HasColumnType("int"); + + b.Property("IsEnabled") + .HasColumnType("bit"); + + b.Property("Value") + .HasColumnType("decimal(18,4)"); + + b.HasKey("EstateId", "ContractId", "ProductId", "TransactionFeeId"); + + b.ToTable("contractproducttransactionfee"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Estate", b => + { + b.Property("EstateId") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Reference") + .HasColumnType("nvarchar(max)"); + + b.HasKey("EstateId"); + + b.ToTable("estate"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.EstateOperator", b => + { + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("OperatorId") + .HasColumnType("uniqueidentifier"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("RequireCustomMerchantNumber") + .HasColumnType("bit"); + + b.Property("RequireCustomTerminalNumber") + .HasColumnType("bit"); + + b.HasKey("EstateId", "OperatorId"); + + b.ToTable("estateoperator"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.EstateSecurityUser", b => + { + b.Property("SecurityUserId") + .HasColumnType("uniqueidentifier"); + + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("EmailAddress") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("SecurityUserId", "EstateId"); + + b.ToTable("estatesecurityuser"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.File", b => + { + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("FileImportLogId") + .HasColumnType("uniqueidentifier"); + + b.Property("FileId") + .HasColumnType("uniqueidentifier"); + + b.Property("FileLocation") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("FileProfileId") + .HasColumnType("uniqueidentifier"); + + b.Property("FileReceivedDateTime") + .HasColumnType("datetime2"); + + b.Property("IsCompleted") + .HasColumnType("bit"); + + b.Property("MerchantId") + .HasColumnType("uniqueidentifier"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("EstateId", "FileImportLogId", "FileId"); + + b.ToTable("file"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.FileImportLog", b => + { + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("FileImportLogId") + .HasColumnType("uniqueidentifier"); + + b.Property("ImportLogDateTime") + .HasColumnType("datetime2"); + + b.HasKey("EstateId", "FileImportLogId"); + + b.ToTable("fileimportlog"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.FileImportLogFile", b => + { + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("FileImportLogId") + .HasColumnType("uniqueidentifier"); + + b.Property("FileId") + .HasColumnType("uniqueidentifier"); + + b.Property("FilePath") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("FileProfileId") + .HasColumnType("uniqueidentifier"); + + b.Property("FileUploadedDateTime") + .HasColumnType("datetime2"); + + b.Property("MerchantId") + .HasColumnType("uniqueidentifier"); + + b.Property("OriginalFileName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("EstateId", "FileImportLogId", "FileId"); + + b.ToTable("fileimportlogfile"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.FileLine", b => + { + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("FileId") + .HasColumnType("uniqueidentifier"); + + b.Property("LineNumber") + .HasColumnType("int"); + + b.Property("FileLineData") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Status") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("TransactionId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("EstateId", "FileId", "LineNumber"); + + b.ToTable("fileline"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Merchant", b => + { + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("MerchantId") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("LastStatementGenerated") + .HasColumnType("datetime2"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Reference") + .HasColumnType("nvarchar(max)"); + + b.Property("SettlementSchedule") + .HasColumnType("int"); + + b.HasKey("EstateId", "MerchantId"); + + b.ToTable("merchant"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantAddress", b => + { + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("MerchantId") + .HasColumnType("uniqueidentifier"); + + b.Property("AddressId") + .HasColumnType("uniqueidentifier"); + + b.Property("AddressLine1") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("AddressLine2") + .HasColumnType("nvarchar(max)"); + + b.Property("AddressLine3") + .HasColumnType("nvarchar(max)"); + + b.Property("AddressLine4") + .HasColumnType("nvarchar(max)"); + + b.Property("Country") + .HasColumnType("nvarchar(max)"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("PostalCode") + .HasColumnType("nvarchar(max)"); + + b.Property("Region") + .HasColumnType("nvarchar(max)"); + + b.Property("Town") + .HasColumnType("nvarchar(max)"); + + b.HasKey("EstateId", "MerchantId", "AddressId"); + + b.ToTable("merchantaddress"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantContact", b => + { + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("MerchantId") + .HasColumnType("uniqueidentifier"); + + b.Property("ContactId") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("EmailAddress") + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("PhoneNumber") + .HasColumnType("nvarchar(max)"); + + b.HasKey("EstateId", "MerchantId", "ContactId"); + + b.ToTable("merchantcontact"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantDevice", b => + { + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("MerchantId") + .HasColumnType("uniqueidentifier"); + + b.Property("DeviceId") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("DeviceIdentifier") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("EstateId", "MerchantId", "DeviceId"); + + b.ToTable("merchantdevice"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantOperator", b => + { + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("MerchantId") + .HasColumnType("uniqueidentifier"); + + b.Property("OperatorId") + .HasColumnType("uniqueidentifier"); + + b.Property("MerchantNumber") + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("TerminalNumber") + .HasColumnType("nvarchar(max)"); + + b.HasKey("EstateId", "MerchantId", "OperatorId"); + + b.ToTable("merchantoperator"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantSecurityUser", b => + { + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("MerchantId") + .HasColumnType("uniqueidentifier"); + + b.Property("SecurityUserId") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("EmailAddress") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("EstateId", "MerchantId", "SecurityUserId"); + + b.ToTable("merchantsecurityuser"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantSettlementFee", b => + { + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("SettlementId") + .HasColumnType("uniqueidentifier"); + + b.Property("TransactionId") + .HasColumnType("uniqueidentifier"); + + b.Property("FeeId") + .HasColumnType("uniqueidentifier"); + + b.Property("CalculatedValue") + .HasColumnType("decimal(18,2)"); + + b.Property("FeeCalculatedDateTime") + .HasColumnType("datetime2"); + + b.Property("FeeValue") + .HasColumnType("decimal(18,2)"); + + b.Property("IsSettled") + .HasColumnType("bit"); + + b.Property("MerchantId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("EstateId", "SettlementId", "TransactionId", "FeeId"); + + b.ToTable("merchantsettlementfee"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Reconciliation", b => + { + b.Property("TransactionId") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("DeviceIdentifier") + .HasColumnType("nvarchar(max)"); + + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("IsAuthorised") + .HasColumnType("bit"); + + b.Property("IsCompleted") + .HasColumnType("bit"); + + b.Property("MerchantId") + .HasColumnType("uniqueidentifier"); + + b.Property("ResponseCode") + .HasColumnType("nvarchar(max)"); + + b.Property("ResponseMessage") + .HasColumnType("nvarchar(max)"); + + b.Property("TransactionCount") + .HasColumnType("int"); + + b.Property("TransactionDate") + .HasColumnType("datetime2"); + + b.Property("TransactionDateTime") + .HasColumnType("datetime2"); + + b.Property("TransactionTime") + .HasColumnType("time"); + + b.Property("TransactionValue") + .HasColumnType("decimal(18,2)"); + + b.HasKey("TransactionId"); + + b.ToTable("reconciliation"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.ResponseCodes", b => + { + b.Property("ResponseCode") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("ResponseCode")); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("ResponseCode"); + + b.ToTable("responsecodes"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Settlement", b => + { + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("SettlementId") + .HasColumnType("uniqueidentifier"); + + b.Property("IsCompleted") + .HasColumnType("bit"); + + b.Property("SettlementDate") + .HasColumnType("datetime2"); + + b.HasKey("EstateId", "SettlementId"); + + b.ToTable("settlement"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.StatementHeader", b => + { + b.Property("StatementId") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("MerchantId") + .HasColumnType("uniqueidentifier"); + + b.Property("StatementCreatedDate") + .HasColumnType("datetime2"); + + b.Property("StatementGeneratedDate") + .HasColumnType("datetime2"); + + b.HasKey("StatementId"); + + b.ToTable("statementheader"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.StatementLine", b => + { + b.Property("StatementId") + .HasColumnType("uniqueidentifier"); + + b.Property("TransactionId") + .HasColumnType("uniqueidentifier"); + + b.Property("ActivityDateTime") + .HasColumnType("datetime2"); + + b.Property("ActivityType") + .HasColumnType("int"); + + b.Property("ActivityDescription") + .HasColumnType("nvarchar(max)"); + + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("InAmount") + .HasColumnType("decimal(18,2)"); + + b.Property("MerchantId") + .HasColumnType("uniqueidentifier"); + + b.Property("OutAmount") + .HasColumnType("decimal(18,2)"); + + b.HasKey("StatementId", "TransactionId", "ActivityDateTime", "ActivityType"); + + b.ToTable("statementline"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Transaction", b => + { + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("MerchantId") + .HasColumnType("uniqueidentifier"); + + b.Property("TransactionId") + .HasColumnType("uniqueidentifier"); + + b.Property("AuthorisationCode") + .HasColumnType("nvarchar(max)"); + + b.Property("ContractId") + .HasColumnType("uniqueidentifier"); + + b.Property("DeviceIdentifier") + .HasColumnType("nvarchar(max)"); + + b.Property("IsAuthorised") + .HasColumnType("bit"); + + b.Property("IsCompleted") + .HasColumnType("bit"); + + b.Property("OperatorIdentifier") + .HasColumnType("nvarchar(max)"); + + b.Property("ProductId") + .HasColumnType("uniqueidentifier"); + + b.Property("ResponseCode") + .HasColumnType("nvarchar(max)"); + + b.Property("ResponseMessage") + .HasColumnType("nvarchar(max)"); + + b.Property("TransactionDate") + .HasColumnType("datetime2"); + + b.Property("TransactionDateTime") + .HasColumnType("datetime2"); + + b.Property("TransactionNumber") + .HasColumnType("nvarchar(max)"); + + b.Property("TransactionReference") + .HasColumnType("nvarchar(max)"); + + b.Property("TransactionSource") + .HasColumnType("int"); + + b.Property("TransactionTime") + .HasColumnType("time"); + + b.Property("TransactionType") + .HasColumnType("nvarchar(max)"); + + b.HasKey("EstateId", "MerchantId", "TransactionId"); + + b.ToTable("transaction"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.TransactionAdditionalRequestData", b => + { + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("MerchantId") + .HasColumnType("uniqueidentifier"); + + b.Property("TransactionId") + .HasColumnType("uniqueidentifier"); + + b.Property("Amount") + .HasColumnType("nvarchar(max)"); + + b.Property("CustomerAccountNumber") + .HasColumnType("nvarchar(max)"); + + b.HasKey("EstateId", "MerchantId", "TransactionId"); + + b.ToTable("transactionadditionalrequestdata"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.TransactionAdditionalResponseData", b => + { + b.Property("TransactionId") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("MerchantId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("TransactionId"); + + b.ToTable("transactionadditionalresponsedata"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.TransactionFee", b => + { + b.Property("TransactionId") + .HasColumnType("uniqueidentifier"); + + b.Property("FeeId") + .HasColumnType("uniqueidentifier"); + + b.Property("CalculatedValue") + .HasColumnType("decimal(18,2)"); + + b.Property("CalculationType") + .HasColumnType("int"); + + b.Property("EventId") + .HasColumnType("uniqueidentifier"); + + b.Property("FeeType") + .HasColumnType("int"); + + b.Property("FeeValue") + .HasColumnType("decimal(18,2)"); + + b.HasKey("TransactionId", "FeeId"); + + b.ToTable("transactionfee"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Voucher", b => + { + b.Property("VoucherId") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("ExpiryDate") + .HasColumnType("datetime2"); + + b.Property("GenerateDateTime") + .HasColumnType("datetime2"); + + b.Property("IsGenerated") + .HasColumnType("bit"); + + b.Property("IsIssued") + .HasColumnType("bit"); + + b.Property("IsRedeemed") + .HasColumnType("bit"); + + b.Property("IssuedDateTime") + .HasColumnType("datetime2"); + + b.Property("OperatorIdentifier") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("RecipientEmail") + .HasColumnType("nvarchar(max)"); + + b.Property("RecipientMobile") + .HasColumnType("nvarchar(max)"); + + b.Property("RedeemedDateTime") + .HasColumnType("datetime2"); + + b.Property("TransactionId") + .HasColumnType("uniqueidentifier"); + + b.Property("Value") + .HasColumnType("decimal(18,2)"); + + b.Property("VoucherCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("VoucherId"); + + b.ToTable("voucher"); + }); + + modelBuilder.Entity("EstateManagement.Database.ViewEntities.FileImportLogView", b => + { + b.Property("FileCount") + .HasColumnType("int"); + + b.Property("FileImportLogId") + .HasColumnType("uniqueidentifier"); + + b.Property("ImportLogDate") + .HasColumnType("datetime2"); + + b.Property("ImportLogDateTime") + .HasColumnType("datetime2"); + + b.Property("ImportLogTime") + .HasColumnType("time"); + + b.Property("MerchantId") + .HasColumnType("uniqueidentifier"); + + b.ToTable("uvwFileImportLogView"); + + b.ToView("uvwFileImportLog", (string)null); + }); + + modelBuilder.Entity("EstateManagement.Database.ViewEntities.FileView", b => + { + b.Property("EmailAddress") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("FailedCount") + .HasColumnType("int"); + + b.Property("FileId") + .HasColumnType("uniqueidentifier"); + + b.Property("FileReceivedDate") + .HasColumnType("datetime2"); + + b.Property("FileReceivedDateTime") + .HasColumnType("datetime2"); + + b.Property("FileReceivedTime") + .HasColumnType("time"); + + b.Property("IsCompleted") + .HasColumnType("bit"); + + b.Property("LineCount") + .HasColumnType("int"); + + b.Property("MerchantId") + .HasColumnType("uniqueidentifier"); + + b.Property("MerchantName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("PendingCount") + .HasColumnType("int"); + + b.Property("SuccessCount") + .HasColumnType("int"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.ToTable("uvwFileView"); + + b.ToView("uvwFile", (string)null); + }); + + modelBuilder.Entity("EstateManagement.Database.ViewEntities.SettlementView", b => + { + b.Property("Amount") + .HasColumnType("decimal(18,2)"); + + b.Property("CalculatedValue") + .HasColumnType("decimal(18,2)"); + + b.Property("DayOfWeek") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("FeeDescription") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsCompleted") + .HasColumnType("bit"); + + b.Property("IsSettled") + .HasColumnType("bit"); + + b.Property("MerchantId") + .HasColumnType("uniqueidentifier"); + + b.Property("MerchantName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Month") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("MonthNumber") + .HasColumnType("int"); + + b.Property("OperatorIdentifier") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("SettlementDate") + .HasColumnType("datetime2"); + + b.Property("SettlementId") + .HasColumnType("uniqueidentifier"); + + b.Property("TransactionId") + .HasColumnType("uniqueidentifier"); + + b.Property("WeekNumber") + .HasColumnType("int"); + + b.Property("YearNumber") + .HasColumnType("int"); + + b.ToTable((string)null); + + b.ToView("uvwSettlements", (string)null); + }); + + modelBuilder.Entity("EstateManagement.Database.ViewEntities.TransactionsView", b => + { + b.Property("Amount") + .HasColumnType("decimal(18,2)"); + + b.Property("DayOfWeek") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("IsAuthorised") + .HasColumnType("bit"); + + b.Property("IsCompleted") + .HasColumnType("bit"); + + b.Property("MerchantId") + .HasColumnType("uniqueidentifier"); + + b.Property("Month") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("MonthNumber") + .HasColumnType("int"); + + b.Property("OperatorIdentifier") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ResponseCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("TransactionDate") + .HasColumnType("datetime2"); + + b.Property("TransactionDateTime") + .HasColumnType("datetime2"); + + b.Property("TransactionId") + .HasColumnType("uniqueidentifier"); + + b.Property("TransactionType") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("WeekNumber") + .HasColumnType("int"); + + b.Property("YearNumber") + .HasColumnType("int"); + + b.ToTable("uvwTransactionsView"); + + b.ToView("uvwTransactions", (string)null); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/TransactionProcessor.Database/Migrations/SqlServer/20230116113030_recordproducttype.cs b/TransactionProcessor.Database/Migrations/SqlServer/20230116113030_recordproducttype.cs new file mode 100644 index 00000000..f85321c7 --- /dev/null +++ b/TransactionProcessor.Database/Migrations/SqlServer/20230116113030_recordproducttype.cs @@ -0,0 +1,29 @@ +#nullable disable + +using Microsoft.EntityFrameworkCore.Migrations; + +namespace TransactionProcessor.Database.Migrations.SqlServer +{ + /// + public partial class recordproducttype : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "ProductType", + table: "contractproduct", + type: "int", + nullable: false, + defaultValue: 0); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "ProductType", + table: "contractproduct"); + } + } +} diff --git a/TransactionProcessor.Database/Migrations/SqlServer/20230630113913_task384_datamodelrefactoring.Designer.cs b/TransactionProcessor.Database/Migrations/SqlServer/20230630113913_task384_datamodelrefactoring.Designer.cs new file mode 100644 index 00000000..35c66326 --- /dev/null +++ b/TransactionProcessor.Database/Migrations/SqlServer/20230630113913_task384_datamodelrefactoring.Designer.cs @@ -0,0 +1,1032 @@ +// + +#nullable disable + +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using TransactionProcessor.Database.Contexts; + +namespace TransactionProcessor.Database.Migrations.SqlServer +{ + [DbContext(typeof(EstateManagementSqlServerContext))] + [Migration("20230630113913_task384_datamodelrefactoring")] + partial class task384_datamodelrefactoring + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "7.0.7") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("EstateManagement.Database.Entities.Calendar", b => + { + b.Property("Date") + .HasColumnType("datetime2"); + + b.Property("DayOfWeek") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("DayOfWeekNumber") + .HasColumnType("int"); + + b.Property("DayOfWeekShort") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("MonthNameLong") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("MonthNameShort") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("MonthNumber") + .HasColumnType("int"); + + b.Property("WeekNumber") + .HasColumnType("int"); + + b.Property("WeekNumberString") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Year") + .HasColumnType("int"); + + b.Property("YearWeekNumber") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Date"); + + b.ToTable("calendar"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Contract", b => + { + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("OperatorId") + .HasColumnType("uniqueidentifier"); + + b.Property("ContractId") + .HasColumnType("uniqueidentifier"); + + b.Property("ContractReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("ContractReportingId")); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("EstateReportingId", "OperatorId", "ContractId"); + + b.ToTable("contract"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.ContractProduct", b => + { + b.Property("ContractReportingId") + .HasColumnType("int"); + + b.Property("ProductId") + .HasColumnType("uniqueidentifier"); + + b.Property("ContractProductReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("ContractProductReportingId")); + + b.Property("DisplayText") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ProductName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ProductType") + .HasColumnType("int"); + + b.Property("Value") + .HasColumnType("decimal(18,2)"); + + b.HasKey("ContractReportingId", "ProductId"); + + b.ToTable("contractproduct"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.ContractProductTransactionFee", b => + { + b.Property("ContractProductReportingId") + .HasColumnType("int"); + + b.Property("TransactionFeeId") + .HasColumnType("uniqueidentifier"); + + b.Property("CalculationType") + .HasColumnType("int"); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("FeeType") + .HasColumnType("int"); + + b.Property("IsEnabled") + .HasColumnType("bit"); + + b.Property("TransactionFeeReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("TransactionFeeReportingId")); + + b.Property("Value") + .HasColumnType("decimal(18,4)"); + + b.HasKey("ContractProductReportingId", "TransactionFeeId"); + + b.ToTable("contractproducttransactionfee"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Estate", b => + { + b.Property("EstateReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("EstateReportingId")); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Reference") + .HasColumnType("nvarchar(max)"); + + b.HasKey("EstateReportingId"); + + b.HasIndex("EstateId") + .IsUnique(); + + b.ToTable("estate"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.EstateOperator", b => + { + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("OperatorId") + .HasColumnType("uniqueidentifier"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("RequireCustomMerchantNumber") + .HasColumnType("bit"); + + b.Property("RequireCustomTerminalNumber") + .HasColumnType("bit"); + + b.HasKey("EstateReportingId", "OperatorId"); + + b.ToTable("estateoperator"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.EstateSecurityUser", b => + { + b.Property("SecurityUserId") + .HasColumnType("uniqueidentifier"); + + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("EmailAddress") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("SecurityUserId", "EstateReportingId"); + + b.ToTable("estatesecurityuser"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.File", b => + { + b.Property("FileReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("FileReportingId")); + + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("FileId") + .HasColumnType("uniqueidentifier"); + + b.Property("FileImportLogReportingId") + .HasColumnType("int"); + + b.Property("FileLocation") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("FileProfileId") + .HasColumnType("uniqueidentifier"); + + b.Property("FileReceivedDate") + .HasColumnType("date"); + + b.Property("FileReceivedDateTime") + .HasColumnType("datetime2"); + + b.Property("IsCompleted") + .HasColumnType("bit"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("FileReportingId"); + + b.HasIndex("FileId") + .IsUnique(); + + b.ToTable("file"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.FileImportLog", b => + { + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("FileImportLogReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("FileImportLogReportingId")); + + b.Property("FileImportLogId") + .HasColumnType("uniqueidentifier"); + + b.Property("ImportLogDate") + .HasColumnType("date"); + + b.Property("ImportLogDateTime") + .HasColumnType("datetime2"); + + b.HasKey("EstateReportingId", "FileImportLogReportingId"); + + b.HasIndex("EstateReportingId", "FileImportLogId") + .IsUnique(); + + b.ToTable("fileimportlog"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.FileImportLogFile", b => + { + b.Property("FileImportLogReportingId") + .HasColumnType("int"); + + b.Property("FileReportingId") + .HasColumnType("int"); + + b.Property("FilePath") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("FileProfileId") + .HasColumnType("uniqueidentifier"); + + b.Property("FileUploadedDate") + .HasColumnType("date"); + + b.Property("FileUploadedDateTime") + .HasColumnType("datetime2"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("OriginalFileName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("FileImportLogReportingId", "FileReportingId"); + + b.ToTable("fileimportlogfile"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.FileLine", b => + { + b.Property("FileReportingId") + .HasColumnType("int"); + + b.Property("LineNumber") + .HasColumnType("int"); + + b.Property("FileLineData") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Status") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.HasKey("FileReportingId", "LineNumber"); + + SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("FileReportingId", "LineNumber")); + + b.HasIndex("TransactionReportingId"); + + b.ToTable("fileline"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Merchant", b => + { + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("MerchantReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("MerchantReportingId")); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("LastStatementGenerated") + .HasColumnType("datetime2"); + + b.Property("MerchantId") + .HasColumnType("uniqueidentifier"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Reference") + .HasColumnType("nvarchar(max)"); + + b.Property("SettlementSchedule") + .HasColumnType("int"); + + b.HasKey("EstateReportingId", "MerchantReportingId"); + + b.HasIndex("EstateReportingId", "MerchantId") + .IsUnique(); + + b.ToTable("merchant"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantAddress", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("AddressId") + .HasColumnType("uniqueidentifier"); + + b.Property("AddressLine1") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("AddressLine2") + .HasColumnType("nvarchar(max)"); + + b.Property("AddressLine3") + .HasColumnType("nvarchar(max)"); + + b.Property("AddressLine4") + .HasColumnType("nvarchar(max)"); + + b.Property("Country") + .HasColumnType("nvarchar(max)"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("PostalCode") + .HasColumnType("nvarchar(max)"); + + b.Property("Region") + .HasColumnType("nvarchar(max)"); + + b.Property("Town") + .HasColumnType("nvarchar(max)"); + + b.HasKey("MerchantReportingId", "AddressId"); + + b.ToTable("merchantaddress"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantContact", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("ContactId") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("EmailAddress") + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("PhoneNumber") + .HasColumnType("nvarchar(max)"); + + b.HasKey("MerchantReportingId", "ContactId"); + + b.ToTable("merchantcontact"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantDevice", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("DeviceId") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("DeviceIdentifier") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("MerchantReportingId", "DeviceId"); + + b.ToTable("merchantdevice"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantOperator", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("OperatorId") + .HasColumnType("uniqueidentifier"); + + b.Property("MerchantNumber") + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("TerminalNumber") + .HasColumnType("nvarchar(max)"); + + b.HasKey("MerchantReportingId", "OperatorId"); + + b.ToTable("merchantoperator"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantSecurityUser", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("SecurityUserId") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("EmailAddress") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("MerchantReportingId", "SecurityUserId"); + + b.ToTable("merchantsecurityuser"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantSettlementFee", b => + { + b.Property("SettlementReportingId") + .HasColumnType("int"); + + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.Property("TransactionFeeReportingId") + .HasColumnType("int"); + + b.Property("CalculatedValue") + .HasColumnType("decimal(18,2)"); + + b.Property("FeeCalculatedDateTime") + .HasColumnType("datetime2"); + + b.Property("FeeValue") + .HasColumnType("decimal(18,2)"); + + b.Property("IsSettled") + .HasColumnType("bit"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.HasKey("SettlementReportingId", "TransactionReportingId", "TransactionFeeReportingId"); + + b.ToTable("merchantsettlementfee"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Reconciliation", b => + { + b.Property("TransactionReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("TransactionReportingId")); + + b.Property("DeviceIdentifier") + .HasColumnType("nvarchar(max)"); + + b.Property("IsAuthorised") + .HasColumnType("bit"); + + b.Property("IsCompleted") + .HasColumnType("bit"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("ResponseCode") + .HasColumnType("nvarchar(max)"); + + b.Property("ResponseMessage") + .HasColumnType("nvarchar(max)"); + + b.Property("TransactionCount") + .HasColumnType("int"); + + b.Property("TransactionDate") + .HasColumnType("date"); + + b.Property("TransactionDateTime") + .HasColumnType("datetime2"); + + b.Property("TransactionId") + .HasColumnType("uniqueidentifier"); + + b.Property("TransactionTime") + .HasColumnType("time"); + + b.Property("TransactionValue") + .HasColumnType("decimal(18,2)"); + + b.HasKey("TransactionReportingId"); + + SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("TransactionReportingId"), false); + + b.HasIndex("TransactionDate", "MerchantReportingId"); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("TransactionDate", "MerchantReportingId")); + + b.HasIndex("TransactionId", "MerchantReportingId") + .IsUnique(); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("TransactionId", "MerchantReportingId"), false); + + b.ToTable("reconciliation"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.ResponseCodes", b => + { + b.Property("ResponseCode") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("ResponseCode")); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("ResponseCode"); + + b.ToTable("responsecodes"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Settlement", b => + { + b.Property("SettlementReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("SettlementReportingId")); + + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("IsCompleted") + .HasColumnType("bit"); + + b.Property("SettlementDate") + .HasColumnType("date"); + + b.Property("SettlementId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("SettlementReportingId"); + + SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("SettlementReportingId"), false); + + b.HasIndex("EstateReportingId", "SettlementId") + .IsUnique(); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("EstateReportingId", "SettlementId"), false); + + b.HasIndex("SettlementDate", "EstateReportingId"); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("SettlementDate", "EstateReportingId")); + + b.ToTable("settlement"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.StatementHeader", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("StatementId") + .HasColumnType("uniqueidentifier"); + + b.Property("StatementCreatedDate") + .HasColumnType("date"); + + b.Property("StatementCreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("StatementGeneratedDate") + .HasColumnType("date"); + + b.Property("StatementGeneratedDateTime") + .HasColumnType("datetime2"); + + b.Property("StatementReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("StatementReportingId")); + + b.HasKey("MerchantReportingId", "StatementId"); + + SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("MerchantReportingId", "StatementId"), false); + + b.HasIndex("MerchantReportingId", "StatementGeneratedDate") + .IsUnique(); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("MerchantReportingId", "StatementGeneratedDate")); + + b.ToTable("statementheader"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.StatementLine", b => + { + b.Property("StatementReportingId") + .HasColumnType("int"); + + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.Property("ActivityDateTime") + .HasColumnType("datetime2"); + + b.Property("ActivityType") + .HasColumnType("int"); + + b.Property("ActivityDate") + .HasColumnType("date"); + + b.Property("ActivityDescription") + .HasColumnType("nvarchar(max)"); + + b.Property("InAmount") + .HasColumnType("decimal(18,2)"); + + b.Property("OutAmount") + .HasColumnType("decimal(18,2)"); + + b.HasKey("StatementReportingId", "TransactionReportingId", "ActivityDateTime", "ActivityType"); + + b.ToTable("statementline"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Transaction", b => + { + b.Property("TransactionReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("TransactionReportingId")); + + b.Property("AuthorisationCode") + .HasColumnType("nvarchar(max)"); + + b.Property("ContractProductReportingId") + .HasColumnType("int"); + + b.Property("ContractReportingId") + .HasColumnType("int"); + + b.Property("DeviceIdentifier") + .HasColumnType("nvarchar(max)"); + + b.Property("IsAuthorised") + .HasColumnType("bit"); + + b.Property("IsCompleted") + .HasColumnType("bit"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("OperatorIdentifier") + .HasColumnType("nvarchar(max)"); + + b.Property("ResponseCode") + .HasColumnType("nvarchar(max)"); + + b.Property("ResponseMessage") + .HasColumnType("nvarchar(max)"); + + b.Property("TransactionDate") + .HasColumnType("date"); + + b.Property("TransactionDateTime") + .HasColumnType("datetime2"); + + b.Property("TransactionId") + .HasColumnType("uniqueidentifier"); + + b.Property("TransactionNumber") + .HasColumnType("nvarchar(max)"); + + b.Property("TransactionReference") + .HasColumnType("nvarchar(max)"); + + b.Property("TransactionSource") + .HasColumnType("int"); + + b.Property("TransactionTime") + .HasColumnType("time"); + + b.Property("TransactionType") + .HasColumnType("nvarchar(max)"); + + b.HasKey("TransactionReportingId"); + + SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("TransactionReportingId"), false); + + b.HasIndex("TransactionDate", "MerchantReportingId"); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("TransactionDate", "MerchantReportingId")); + + b.HasIndex("TransactionId", "MerchantReportingId") + .IsUnique(); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("TransactionId", "MerchantReportingId"), false); + + b.ToTable("transaction"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.TransactionAdditionalRequestData", b => + { + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.Property("Amount") + .HasColumnType("nvarchar(max)"); + + b.Property("CustomerAccountNumber") + .HasColumnType("nvarchar(max)"); + + b.HasKey("TransactionReportingId"); + + b.ToTable("transactionadditionalrequestdata"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.TransactionAdditionalResponseData", b => + { + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.HasKey("TransactionReportingId"); + + b.ToTable("transactionadditionalresponsedata"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.TransactionFee", b => + { + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.Property("TransactionFeeReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("TransactionFeeReportingId")); + + b.Property("CalculatedValue") + .HasColumnType("decimal(18,2)"); + + b.Property("CalculationType") + .HasColumnType("int"); + + b.Property("EventId") + .HasColumnType("uniqueidentifier"); + + b.Property("FeeId") + .HasColumnType("uniqueidentifier"); + + b.Property("FeeType") + .HasColumnType("int"); + + b.Property("FeeValue") + .HasColumnType("decimal(18,2)"); + + b.HasKey("TransactionReportingId", "TransactionFeeReportingId"); + + b.HasIndex("FeeId") + .IsUnique(); + + b.ToTable("transactionfee"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Voucher", b => + { + b.Property("VoucherId") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("ExpiryDate") + .HasColumnType("date"); + + b.Property("ExpiryDateTime") + .HasColumnType("datetime2"); + + b.Property("GenerateDate") + .HasColumnType("date"); + + b.Property("GenerateDateTime") + .HasColumnType("datetime2"); + + b.Property("IsGenerated") + .HasColumnType("bit"); + + b.Property("IsIssued") + .HasColumnType("bit"); + + b.Property("IsRedeemed") + .HasColumnType("bit"); + + b.Property("IssuedDate") + .HasColumnType("date"); + + b.Property("IssuedDateTime") + .HasColumnType("datetime2"); + + b.Property("OperatorIdentifier") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("RecipientEmail") + .HasColumnType("nvarchar(max)"); + + b.Property("RecipientMobile") + .HasColumnType("nvarchar(max)"); + + b.Property("RedeemedDate") + .HasColumnType("datetime2"); + + b.Property("RedeemedDateTime") + .HasColumnType("datetime2"); + + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.Property("Value") + .HasColumnType("decimal(18,2)"); + + b.Property("VoucherCode") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.HasKey("VoucherId"); + + b.HasIndex("TransactionReportingId"); + + b.HasIndex("VoucherCode"); + + b.ToTable("voucher"); + }); + + modelBuilder.Entity("EstateManagement.Database.ViewEntities.SettlementView", b => + { + b.Property("Amount") + .HasColumnType("decimal(18,2)"); + + b.Property("CalculatedValue") + .HasColumnType("decimal(18,2)"); + + b.Property("DayOfWeek") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("FeeDescription") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsCompleted") + .HasColumnType("bit"); + + b.Property("IsSettled") + .HasColumnType("bit"); + + b.Property("MerchantId") + .HasColumnType("uniqueidentifier"); + + b.Property("MerchantName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Month") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("MonthNumber") + .HasColumnType("int"); + + b.Property("OperatorIdentifier") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("SettlementDate") + .HasColumnType("datetime2"); + + b.Property("SettlementId") + .HasColumnType("uniqueidentifier"); + + b.Property("TransactionId") + .HasColumnType("uniqueidentifier"); + + b.Property("WeekNumber") + .HasColumnType("int"); + + b.Property("YearNumber") + .HasColumnType("int"); + + b.ToTable((string)null); + + b.ToView("uvwSettlements", (string)null); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/TransactionProcessor.Database/Migrations/SqlServer/20230630113913_task384_datamodelrefactoring.cs b/TransactionProcessor.Database/Migrations/SqlServer/20230630113913_task384_datamodelrefactoring.cs new file mode 100644 index 00000000..2520c63a --- /dev/null +++ b/TransactionProcessor.Database/Migrations/SqlServer/20230630113913_task384_datamodelrefactoring.cs @@ -0,0 +1,2084 @@ +#nullable disable + +using Microsoft.EntityFrameworkCore.Migrations; + +namespace TransactionProcessor.Database.Migrations.SqlServer +{ + /// + public partial class task384_datamodelrefactoring : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "uvwFileImportLogView"); + + migrationBuilder.DropTable( + name: "uvwFileView"); + + migrationBuilder.DropTable( + name: "uvwTransactionsView"); + + migrationBuilder.DropPrimaryKey( + name: "PK_transactionfee", + table: "transactionfee"); + + migrationBuilder.DropPrimaryKey( + name: "PK_transactionadditionalresponsedata", + table: "transactionadditionalresponsedata"); + + migrationBuilder.DropPrimaryKey( + name: "PK_transactionadditionalrequestdata", + table: "transactionadditionalrequestdata"); + + migrationBuilder.DropPrimaryKey( + name: "PK_transaction", + table: "transaction"); + + migrationBuilder.DropPrimaryKey( + name: "PK_statementline", + table: "statementline"); + + migrationBuilder.DropPrimaryKey( + name: "PK_statementheader", + table: "statementheader"); + + migrationBuilder.DropPrimaryKey( + name: "PK_settlement", + table: "settlement"); + + migrationBuilder.DropPrimaryKey( + name: "PK_reconciliation", + table: "reconciliation"); + + migrationBuilder.DropPrimaryKey( + name: "PK_merchantsettlementfee", + table: "merchantsettlementfee"); + + migrationBuilder.DropPrimaryKey( + name: "PK_merchantsecurityuser", + table: "merchantsecurityuser"); + + migrationBuilder.DropPrimaryKey( + name: "PK_merchantoperator", + table: "merchantoperator"); + + migrationBuilder.DropPrimaryKey( + name: "PK_merchantdevice", + table: "merchantdevice"); + + migrationBuilder.DropPrimaryKey( + name: "PK_merchantcontact", + table: "merchantcontact"); + + migrationBuilder.DropPrimaryKey( + name: "PK_merchantaddress", + table: "merchantaddress"); + + migrationBuilder.DropPrimaryKey( + name: "PK_merchant", + table: "merchant"); + + migrationBuilder.DropPrimaryKey( + name: "PK_fileline", + table: "fileline"); + + migrationBuilder.DropPrimaryKey( + name: "PK_fileimportlogfile", + table: "fileimportlogfile"); + + migrationBuilder.DropPrimaryKey( + name: "PK_fileimportlog", + table: "fileimportlog"); + + migrationBuilder.DropPrimaryKey( + name: "PK_file", + table: "file"); + + migrationBuilder.DropPrimaryKey( + name: "PK_estatesecurityuser", + table: "estatesecurityuser"); + + migrationBuilder.DropPrimaryKey( + name: "PK_estateoperator", + table: "estateoperator"); + + migrationBuilder.DropPrimaryKey( + name: "PK_estate", + table: "estate"); + + migrationBuilder.DropPrimaryKey( + name: "PK_contractproducttransactionfee", + table: "contractproducttransactionfee"); + + migrationBuilder.DropPrimaryKey( + name: "PK_contractproduct", + table: "contractproduct"); + + migrationBuilder.DropPrimaryKey( + name: "PK_contract", + table: "contract"); + + migrationBuilder.DropColumn( + name: "EstateId", + table: "voucher"); + + migrationBuilder.DropColumn( + name: "TransactionId", + table: "voucher"); + + migrationBuilder.DropColumn( + name: "TransactionId", + table: "transactionfee"); + + migrationBuilder.AddColumn( + name: "TransactionReportingId", + table: "transactionadditionalresponsedata", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "TransactionReportingId", + table: "transactionadditionalrequestdata", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.DropColumn( + name: "TransactionId", + table: "transactionadditionalresponsedata"); + + migrationBuilder.DropColumn( + name: "EstateId", + table: "transactionadditionalresponsedata"); + + migrationBuilder.DropColumn( + name: "MerchantId", + table: "transactionadditionalresponsedata"); + + migrationBuilder.DropColumn( + name: "EstateId", + table: "transactionadditionalrequestdata"); + + migrationBuilder.DropColumn( + name: "MerchantId", + table: "transactionadditionalrequestdata"); + + migrationBuilder.DropColumn( + name: "TransactionId", + table: "transactionadditionalrequestdata"); + + migrationBuilder.DropColumn( + name: "EstateId", + table: "transaction"); + + migrationBuilder.DropColumn( + name: "MerchantId", + table: "transaction"); + + migrationBuilder.DropColumn( + name: "ContractId", + table: "transaction"); + + migrationBuilder.DropColumn( + name: "ProductId", + table: "transaction"); + + migrationBuilder.DropColumn( + name: "StatementId", + table: "statementline"); + + migrationBuilder.DropColumn( + name: "TransactionId", + table: "statementline"); + + migrationBuilder.DropColumn( + name: "EstateId", + table: "statementline"); + + migrationBuilder.DropColumn( + name: "MerchantId", + table: "statementline"); + + migrationBuilder.DropColumn( + name: "EstateId", + table: "statementheader"); + + migrationBuilder.DropColumn( + name: "MerchantId", + table: "statementheader"); + + migrationBuilder.DropColumn( + name: "EstateId", + table: "settlement"); + + migrationBuilder.DropColumn( + name: "EstateId", + table: "reconciliation"); + + migrationBuilder.DropColumn( + name: "MerchantId", + table: "reconciliation"); + + migrationBuilder.DropColumn( + name: "EstateId", + table: "merchantsettlementfee"); + + migrationBuilder.DropColumn( + name: "SettlementId", + table: "merchantsettlementfee"); + + migrationBuilder.DropColumn( + name: "TransactionId", + table: "merchantsettlementfee"); + + migrationBuilder.DropColumn( + name: "FeeId", + table: "merchantsettlementfee"); + + migrationBuilder.DropColumn( + name: "MerchantId", + table: "merchantsettlementfee"); + + migrationBuilder.DropColumn( + name: "EstateId", + table: "merchantsecurityuser"); + + migrationBuilder.DropColumn( + name: "MerchantId", + table: "merchantsecurityuser"); + + migrationBuilder.DropColumn( + name: "EstateId", + table: "merchantoperator"); + + migrationBuilder.DropColumn( + name: "MerchantId", + table: "merchantoperator"); + + migrationBuilder.DropColumn( + name: "EstateId", + table: "merchantdevice"); + + migrationBuilder.DropColumn( + name: "MerchantId", + table: "merchantdevice"); + + migrationBuilder.DropColumn( + name: "EstateId", + table: "merchantcontact"); + + migrationBuilder.DropColumn( + name: "MerchantId", + table: "merchantcontact"); + + migrationBuilder.DropColumn( + name: "EstateId", + table: "merchantaddress"); + + migrationBuilder.DropColumn( + name: "MerchantId", + table: "merchantaddress"); + + migrationBuilder.DropColumn( + name: "EstateId", + table: "merchant"); + + migrationBuilder.DropColumn( + name: "EstateId", + table: "fileline"); + + migrationBuilder.DropColumn( + name: "FileId", + table: "fileline"); + + migrationBuilder.DropColumn( + name: "TransactionId", + table: "fileline"); + + migrationBuilder.DropColumn( + name: "EstateId", + table: "fileimportlogfile"); + + migrationBuilder.DropColumn( + name: "FileImportLogId", + table: "fileimportlogfile"); + + migrationBuilder.DropColumn( + name: "FileId", + table: "fileimportlogfile"); + + migrationBuilder.DropColumn( + name: "MerchantId", + table: "fileimportlogfile"); + + migrationBuilder.DropColumn( + name: "EstateId", + table: "fileimportlog"); + + migrationBuilder.DropColumn( + name: "EstateId", + table: "file"); + + migrationBuilder.DropColumn( + name: "FileImportLogId", + table: "file"); + + migrationBuilder.DropColumn( + name: "MerchantId", + table: "file"); + + migrationBuilder.DropColumn( + name: "EstateId", + table: "estatesecurityuser"); + + migrationBuilder.DropColumn( + name: "EstateId", + table: "estateoperator"); + + migrationBuilder.DropColumn( + name: "EstateId", + table: "contractproducttransactionfee"); + + migrationBuilder.DropColumn( + name: "ContractId", + table: "contractproducttransactionfee"); + + migrationBuilder.DropColumn( + name: "ProductId", + table: "contractproducttransactionfee"); + + migrationBuilder.DropColumn( + name: "EstateId", + table: "contractproduct"); + + migrationBuilder.DropColumn( + name: "ContractId", + table: "contractproduct"); + + migrationBuilder.DropColumn( + name: "EstateId", + table: "contract"); + + migrationBuilder.AlterColumn( + name: "VoucherCode", + table: "voucher", + type: "nvarchar(450)", + nullable: false, + oldClrType: typeof(string), + oldType: "nvarchar(max)"); + + migrationBuilder.AlterColumn( + name: "ExpiryDate", + table: "voucher", + type: "date", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "datetime2"); + + migrationBuilder.AddColumn( + name: "ExpiryDateTime", + table: "voucher", + type: "datetime2", + nullable: false, + defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified)); + + migrationBuilder.AddColumn( + name: "GenerateDate", + table: "voucher", + type: "date", + nullable: false, + defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified)); + + migrationBuilder.AddColumn( + name: "IssuedDate", + table: "voucher", + type: "date", + nullable: false, + defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified)); + + migrationBuilder.AddColumn( + name: "RedeemedDate", + table: "voucher", + type: "datetime2", + nullable: false, + defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified)); + + migrationBuilder.AddColumn( + name: "TransactionReportingId", + table: "voucher", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "TransactionReportingId", + table: "transactionfee", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "TransactionFeeReportingId", + table: "transactionfee", + type: "int", + nullable: false, + defaultValue: 0) + .Annotation("SqlServer:Identity", "1, 1"); + + migrationBuilder.AlterColumn( + name: "TransactionDate", + table: "transaction", + type: "date", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "datetime2"); + + migrationBuilder.AddColumn( + name: "TransactionReportingId", + table: "transaction", + type: "int", + nullable: false, + defaultValue: 0) + .Annotation("SqlServer:Identity", "1, 1"); + + migrationBuilder.AddColumn( + name: "ContractProductReportingId", + table: "transaction", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "ContractReportingId", + table: "transaction", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "MerchantReportingId", + table: "transaction", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "StatementReportingId", + table: "statementline", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "TransactionReportingId", + table: "statementline", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "ActivityDate", + table: "statementline", + type: "date", + nullable: false, + defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified)); + + migrationBuilder.AlterColumn( + name: "StatementGeneratedDate", + table: "statementheader", + type: "date", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "datetime2"); + + migrationBuilder.AlterColumn( + name: "StatementCreatedDate", + table: "statementheader", + type: "date", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "datetime2"); + + migrationBuilder.AddColumn( + name: "MerchantReportingId", + table: "statementheader", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "StatementCreatedDateTime", + table: "statementheader", + type: "datetime2", + nullable: false, + defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified)); + + migrationBuilder.AddColumn( + name: "StatementGeneratedDateTime", + table: "statementheader", + type: "datetime2", + nullable: false, + defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified)); + + migrationBuilder.AddColumn( + name: "StatementReportingId", + table: "statementheader", + type: "int", + nullable: false, + defaultValue: 0) + .Annotation("SqlServer:Identity", "1, 1"); + + migrationBuilder.AlterColumn( + name: "SettlementDate", + table: "settlement", + type: "date", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "datetime2"); + + migrationBuilder.AddColumn( + name: "SettlementReportingId", + table: "settlement", + type: "int", + nullable: false, + defaultValue: 0) + .Annotation("SqlServer:Identity", "1, 1"); + + migrationBuilder.AddColumn( + name: "EstateReportingId", + table: "settlement", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AlterColumn( + name: "TransactionDate", + table: "reconciliation", + type: "date", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "datetime2"); + + migrationBuilder.AddColumn( + name: "TransactionReportingId", + table: "reconciliation", + type: "int", + nullable: false, + defaultValue: 0) + .Annotation("SqlServer:Identity", "1, 1"); + + migrationBuilder.AddColumn( + name: "MerchantReportingId", + table: "reconciliation", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "SettlementReportingId", + table: "merchantsettlementfee", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "TransactionReportingId", + table: "merchantsettlementfee", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "TransactionFeeReportingId", + table: "merchantsettlementfee", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "MerchantReportingId", + table: "merchantsettlementfee", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "MerchantReportingId", + table: "merchantsecurityuser", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "MerchantReportingId", + table: "merchantoperator", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "MerchantReportingId", + table: "merchantdevice", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "MerchantReportingId", + table: "merchantcontact", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "MerchantReportingId", + table: "merchantaddress", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "EstateReportingId", + table: "merchant", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "MerchantReportingId", + table: "merchant", + type: "int", + nullable: false, + defaultValue: 0) + .Annotation("SqlServer:Identity", "1, 1"); + + migrationBuilder.AddColumn( + name: "FileReportingId", + table: "fileline", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "TransactionReportingId", + table: "fileline", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "FileImportLogReportingId", + table: "fileimportlogfile", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "FileReportingId", + table: "fileimportlogfile", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "FileUploadedDate", + table: "fileimportlogfile", + type: "date", + nullable: false, + defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified)); + + migrationBuilder.AddColumn( + name: "MerchantReportingId", + table: "fileimportlogfile", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "EstateReportingId", + table: "fileimportlog", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "FileImportLogReportingId", + table: "fileimportlog", + type: "int", + nullable: false, + defaultValue: 0) + .Annotation("SqlServer:Identity", "1, 1"); + + migrationBuilder.AddColumn( + name: "ImportLogDate", + table: "fileimportlog", + type: "date", + nullable: false, + defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified)); + + migrationBuilder.AddColumn( + name: "FileReportingId", + table: "file", + type: "int", + nullable: false, + defaultValue: 0) + .Annotation("SqlServer:Identity", "1, 1"); + + migrationBuilder.AddColumn( + name: "EstateReportingId", + table: "file", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "FileImportLogReportingId", + table: "file", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "FileReceivedDate", + table: "file", + type: "date", + nullable: false, + defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified)); + + migrationBuilder.AddColumn( + name: "MerchantReportingId", + table: "file", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "EstateReportingId", + table: "estatesecurityuser", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "EstateReportingId", + table: "estateoperator", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "EstateReportingId", + table: "estate", + type: "int", + nullable: false, + defaultValue: 0) + .Annotation("SqlServer:Identity", "1, 1"); + + migrationBuilder.AddColumn( + name: "ContractProductReportingId", + table: "contractproducttransactionfee", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "TransactionFeeReportingId", + table: "contractproducttransactionfee", + type: "int", + nullable: false, + defaultValue: 0) + .Annotation("SqlServer:Identity", "1, 1"); + + migrationBuilder.AddColumn( + name: "ContractReportingId", + table: "contractproduct", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "ContractProductReportingId", + table: "contractproduct", + type: "int", + nullable: false, + defaultValue: 0) + .Annotation("SqlServer:Identity", "1, 1"); + + migrationBuilder.AddColumn( + name: "EstateReportingId", + table: "contract", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "ContractReportingId", + table: "contract", + type: "int", + nullable: false, + defaultValue: 0) + .Annotation("SqlServer:Identity", "1, 1"); + + migrationBuilder.AddPrimaryKey( + name: "PK_transactionfee", + table: "transactionfee", + columns: new[] { "TransactionReportingId", "TransactionFeeReportingId" }); + + migrationBuilder.AddPrimaryKey( + name: "PK_transactionadditionalresponsedata", + table: "transactionadditionalresponsedata", + column: "TransactionReportingId"); + + migrationBuilder.AddPrimaryKey( + name: "PK_transactionadditionalrequestdata", + table: "transactionadditionalrequestdata", + column: "TransactionReportingId"); + + migrationBuilder.AddPrimaryKey( + name: "PK_transaction", + table: "transaction", + column: "TransactionReportingId") + .Annotation("SqlServer:Clustered", false); + + migrationBuilder.AddPrimaryKey( + name: "PK_statementline", + table: "statementline", + columns: new[] { "StatementReportingId", "TransactionReportingId", "ActivityDateTime", "ActivityType" }); + + migrationBuilder.AddPrimaryKey( + name: "PK_statementheader", + table: "statementheader", + columns: new[] { "MerchantReportingId", "StatementId" }) + .Annotation("SqlServer:Clustered", false); + + migrationBuilder.AddPrimaryKey( + name: "PK_settlement", + table: "settlement", + column: "SettlementReportingId") + .Annotation("SqlServer:Clustered", false); + + migrationBuilder.AddPrimaryKey( + name: "PK_reconciliation", + table: "reconciliation", + column: "TransactionReportingId") + .Annotation("SqlServer:Clustered", false); + + migrationBuilder.AddPrimaryKey( + name: "PK_merchantsettlementfee", + table: "merchantsettlementfee", + columns: new[] { "SettlementReportingId", "TransactionReportingId", "TransactionFeeReportingId" }); + + migrationBuilder.AddPrimaryKey( + name: "PK_merchantsecurityuser", + table: "merchantsecurityuser", + columns: new[] { "MerchantReportingId", "SecurityUserId" }); + + migrationBuilder.AddPrimaryKey( + name: "PK_merchantoperator", + table: "merchantoperator", + columns: new[] { "MerchantReportingId", "OperatorId" }); + + migrationBuilder.AddPrimaryKey( + name: "PK_merchantdevice", + table: "merchantdevice", + columns: new[] { "MerchantReportingId", "DeviceId" }); + + migrationBuilder.AddPrimaryKey( + name: "PK_merchantcontact", + table: "merchantcontact", + columns: new[] { "MerchantReportingId", "ContactId" }); + + migrationBuilder.AddPrimaryKey( + name: "PK_merchantaddress", + table: "merchantaddress", + columns: new[] { "MerchantReportingId", "AddressId" }); + + migrationBuilder.AddPrimaryKey( + name: "PK_merchant", + table: "merchant", + columns: new[] { "EstateReportingId", "MerchantReportingId" }); + + migrationBuilder.AddPrimaryKey( + name: "PK_fileline", + table: "fileline", + columns: new[] { "FileReportingId", "LineNumber" }) + .Annotation("SqlServer:Clustered", true); + + migrationBuilder.AddPrimaryKey( + name: "PK_fileimportlogfile", + table: "fileimportlogfile", + columns: new[] { "FileImportLogReportingId", "FileReportingId" }); + + migrationBuilder.AddPrimaryKey( + name: "PK_fileimportlog", + table: "fileimportlog", + columns: new[] { "EstateReportingId", "FileImportLogReportingId" }); + + migrationBuilder.AddPrimaryKey( + name: "PK_file", + table: "file", + column: "FileReportingId"); + + migrationBuilder.AddPrimaryKey( + name: "PK_estatesecurityuser", + table: "estatesecurityuser", + columns: new[] { "SecurityUserId", "EstateReportingId" }); + + migrationBuilder.AddPrimaryKey( + name: "PK_estateoperator", + table: "estateoperator", + columns: new[] { "EstateReportingId", "OperatorId" }); + + migrationBuilder.AddPrimaryKey( + name: "PK_estate", + table: "estate", + column: "EstateReportingId"); + + migrationBuilder.AddPrimaryKey( + name: "PK_contractproducttransactionfee", + table: "contractproducttransactionfee", + columns: new[] { "ContractProductReportingId", "TransactionFeeId" }); + + migrationBuilder.AddPrimaryKey( + name: "PK_contractproduct", + table: "contractproduct", + columns: new[] { "ContractReportingId", "ProductId" }); + + migrationBuilder.AddPrimaryKey( + name: "PK_contract", + table: "contract", + columns: new[] { "EstateReportingId", "OperatorId", "ContractId" }); + + migrationBuilder.CreateIndex( + name: "IX_voucher_TransactionReportingId", + table: "voucher", + column: "TransactionReportingId"); + + migrationBuilder.CreateIndex( + name: "IX_voucher_VoucherCode", + table: "voucher", + column: "VoucherCode"); + + migrationBuilder.CreateIndex( + name: "IX_transactionfee_FeeId", + table: "transactionfee", + column: "FeeId", + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_transaction_TransactionDate_MerchantReportingId", + table: "transaction", + columns: new[] { "TransactionDate", "MerchantReportingId" }) + .Annotation("SqlServer:Clustered", true); + + migrationBuilder.CreateIndex( + name: "IX_transaction_TransactionId_MerchantReportingId", + table: "transaction", + columns: new[] { "TransactionId", "MerchantReportingId" }, + unique: true) + .Annotation("SqlServer:Clustered", false); + + migrationBuilder.CreateIndex( + name: "IX_statementheader_MerchantReportingId_StatementGeneratedDate", + table: "statementheader", + columns: new[] { "MerchantReportingId", "StatementGeneratedDate" }, + unique: true) + .Annotation("SqlServer:Clustered", true); + + migrationBuilder.CreateIndex( + name: "IX_settlement_EstateReportingId_SettlementId", + table: "settlement", + columns: new[] { "EstateReportingId", "SettlementId" }, + unique: true) + .Annotation("SqlServer:Clustered", false); + + migrationBuilder.CreateIndex( + name: "IX_settlement_SettlementDate_EstateReportingId", + table: "settlement", + columns: new[] { "SettlementDate", "EstateReportingId" }) + .Annotation("SqlServer:Clustered", true); + + migrationBuilder.CreateIndex( + name: "IX_reconciliation_TransactionDate_MerchantReportingId", + table: "reconciliation", + columns: new[] { "TransactionDate", "MerchantReportingId" }) + .Annotation("SqlServer:Clustered", true); + + migrationBuilder.CreateIndex( + name: "IX_reconciliation_TransactionId_MerchantReportingId", + table: "reconciliation", + columns: new[] { "TransactionId", "MerchantReportingId" }, + unique: true) + .Annotation("SqlServer:Clustered", false); + + migrationBuilder.CreateIndex( + name: "IX_merchant_EstateReportingId_MerchantId", + table: "merchant", + columns: new[] { "EstateReportingId", "MerchantId" }, + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_fileline_TransactionReportingId", + table: "fileline", + column: "TransactionReportingId"); + + migrationBuilder.CreateIndex( + name: "IX_fileimportlog_EstateReportingId_FileImportLogId", + table: "fileimportlog", + columns: new[] { "EstateReportingId", "FileImportLogId" }, + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_file_FileId", + table: "file", + column: "FileId", + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_estate_EstateId", + table: "estate", + column: "EstateId", + unique: true); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropIndex( + name: "IX_voucher_TransactionReportingId", + table: "voucher"); + + migrationBuilder.DropIndex( + name: "IX_voucher_VoucherCode", + table: "voucher"); + + migrationBuilder.DropPrimaryKey( + name: "PK_transactionfee", + table: "transactionfee"); + + migrationBuilder.DropIndex( + name: "IX_transactionfee_FeeId", + table: "transactionfee"); + + migrationBuilder.DropPrimaryKey( + name: "PK_transactionadditionalresponsedata", + table: "transactionadditionalresponsedata"); + + migrationBuilder.DropPrimaryKey( + name: "PK_transactionadditionalrequestdata", + table: "transactionadditionalrequestdata"); + + migrationBuilder.DropPrimaryKey( + name: "PK_transaction", + table: "transaction"); + + migrationBuilder.DropIndex( + name: "IX_transaction_TransactionDate_MerchantReportingId", + table: "transaction"); + + migrationBuilder.DropIndex( + name: "IX_transaction_TransactionId_MerchantReportingId", + table: "transaction"); + + migrationBuilder.DropPrimaryKey( + name: "PK_statementline", + table: "statementline"); + + migrationBuilder.DropPrimaryKey( + name: "PK_statementheader", + table: "statementheader"); + + migrationBuilder.DropIndex( + name: "IX_statementheader_MerchantReportingId_StatementGeneratedDate", + table: "statementheader"); + + migrationBuilder.DropPrimaryKey( + name: "PK_settlement", + table: "settlement"); + + migrationBuilder.DropIndex( + name: "IX_settlement_EstateReportingId_SettlementId", + table: "settlement"); + + migrationBuilder.DropIndex( + name: "IX_settlement_SettlementDate_EstateReportingId", + table: "settlement"); + + migrationBuilder.DropPrimaryKey( + name: "PK_reconciliation", + table: "reconciliation"); + + migrationBuilder.DropIndex( + name: "IX_reconciliation_TransactionDate_MerchantReportingId", + table: "reconciliation"); + + migrationBuilder.DropIndex( + name: "IX_reconciliation_TransactionId_MerchantReportingId", + table: "reconciliation"); + + migrationBuilder.DropPrimaryKey( + name: "PK_merchantsettlementfee", + table: "merchantsettlementfee"); + + migrationBuilder.DropPrimaryKey( + name: "PK_merchantsecurityuser", + table: "merchantsecurityuser"); + + migrationBuilder.DropPrimaryKey( + name: "PK_merchantoperator", + table: "merchantoperator"); + + migrationBuilder.DropPrimaryKey( + name: "PK_merchantdevice", + table: "merchantdevice"); + + migrationBuilder.DropPrimaryKey( + name: "PK_merchantcontact", + table: "merchantcontact"); + + migrationBuilder.DropPrimaryKey( + name: "PK_merchantaddress", + table: "merchantaddress"); + + migrationBuilder.DropPrimaryKey( + name: "PK_merchant", + table: "merchant"); + + migrationBuilder.DropIndex( + name: "IX_merchant_EstateReportingId_MerchantId", + table: "merchant"); + + migrationBuilder.DropPrimaryKey( + name: "PK_fileline", + table: "fileline"); + + migrationBuilder.DropIndex( + name: "IX_fileline_TransactionReportingId", + table: "fileline"); + + migrationBuilder.DropPrimaryKey( + name: "PK_fileimportlogfile", + table: "fileimportlogfile"); + + migrationBuilder.DropPrimaryKey( + name: "PK_fileimportlog", + table: "fileimportlog"); + + migrationBuilder.DropIndex( + name: "IX_fileimportlog_EstateReportingId_FileImportLogId", + table: "fileimportlog"); + + migrationBuilder.DropPrimaryKey( + name: "PK_file", + table: "file"); + + migrationBuilder.DropIndex( + name: "IX_file_FileId", + table: "file"); + + migrationBuilder.DropPrimaryKey( + name: "PK_estatesecurityuser", + table: "estatesecurityuser"); + + migrationBuilder.DropPrimaryKey( + name: "PK_estateoperator", + table: "estateoperator"); + + migrationBuilder.DropPrimaryKey( + name: "PK_estate", + table: "estate"); + + migrationBuilder.DropIndex( + name: "IX_estate_EstateId", + table: "estate"); + + migrationBuilder.DropPrimaryKey( + name: "PK_contractproducttransactionfee", + table: "contractproducttransactionfee"); + + migrationBuilder.DropPrimaryKey( + name: "PK_contractproduct", + table: "contractproduct"); + + migrationBuilder.DropPrimaryKey( + name: "PK_contract", + table: "contract"); + + migrationBuilder.DropColumn( + name: "ExpiryDateTime", + table: "voucher"); + + migrationBuilder.DropColumn( + name: "GenerateDate", + table: "voucher"); + + migrationBuilder.DropColumn( + name: "IssuedDate", + table: "voucher"); + + migrationBuilder.DropColumn( + name: "RedeemedDate", + table: "voucher"); + + migrationBuilder.DropColumn( + name: "TransactionReportingId", + table: "voucher"); + + migrationBuilder.DropColumn( + name: "TransactionReportingId", + table: "transactionfee"); + + migrationBuilder.DropColumn( + name: "TransactionFeeReportingId", + table: "transactionfee"); + + migrationBuilder.DropColumn( + name: "TransactionReportingId", + table: "transactionadditionalresponsedata"); + + migrationBuilder.DropColumn( + name: "TransactionReportingId", + table: "transactionadditionalrequestdata"); + + migrationBuilder.DropColumn( + name: "TransactionReportingId", + table: "transaction"); + + migrationBuilder.DropColumn( + name: "ContractProductReportingId", + table: "transaction"); + + migrationBuilder.DropColumn( + name: "ContractReportingId", + table: "transaction"); + + migrationBuilder.DropColumn( + name: "MerchantReportingId", + table: "transaction"); + + migrationBuilder.DropColumn( + name: "StatementReportingId", + table: "statementline"); + + migrationBuilder.DropColumn( + name: "TransactionReportingId", + table: "statementline"); + + migrationBuilder.DropColumn( + name: "ActivityDate", + table: "statementline"); + + migrationBuilder.DropColumn( + name: "MerchantReportingId", + table: "statementheader"); + + migrationBuilder.DropColumn( + name: "StatementCreatedDateTime", + table: "statementheader"); + + migrationBuilder.DropColumn( + name: "StatementGeneratedDateTime", + table: "statementheader"); + + migrationBuilder.DropColumn( + name: "StatementReportingId", + table: "statementheader"); + + migrationBuilder.DropColumn( + name: "SettlementReportingId", + table: "settlement"); + + migrationBuilder.DropColumn( + name: "EstateReportingId", + table: "settlement"); + + migrationBuilder.DropColumn( + name: "TransactionReportingId", + table: "reconciliation"); + + migrationBuilder.DropColumn( + name: "MerchantReportingId", + table: "reconciliation"); + + migrationBuilder.DropColumn( + name: "SettlementReportingId", + table: "merchantsettlementfee"); + + migrationBuilder.DropColumn( + name: "TransactionReportingId", + table: "merchantsettlementfee"); + + migrationBuilder.DropColumn( + name: "TransactionFeeReportingId", + table: "merchantsettlementfee"); + + migrationBuilder.DropColumn( + name: "MerchantReportingId", + table: "merchantsettlementfee"); + + migrationBuilder.DropColumn( + name: "MerchantReportingId", + table: "merchantsecurityuser"); + + migrationBuilder.DropColumn( + name: "MerchantReportingId", + table: "merchantoperator"); + + migrationBuilder.DropColumn( + name: "MerchantReportingId", + table: "merchantdevice"); + + migrationBuilder.DropColumn( + name: "MerchantReportingId", + table: "merchantcontact"); + + migrationBuilder.DropColumn( + name: "MerchantReportingId", + table: "merchantaddress"); + + migrationBuilder.DropColumn( + name: "EstateReportingId", + table: "merchant"); + + migrationBuilder.DropColumn( + name: "MerchantReportingId", + table: "merchant"); + + migrationBuilder.DropColumn( + name: "FileReportingId", + table: "fileline"); + + migrationBuilder.DropColumn( + name: "TransactionReportingId", + table: "fileline"); + + migrationBuilder.DropColumn( + name: "FileImportLogReportingId", + table: "fileimportlogfile"); + + migrationBuilder.DropColumn( + name: "FileReportingId", + table: "fileimportlogfile"); + + migrationBuilder.DropColumn( + name: "FileUploadedDate", + table: "fileimportlogfile"); + + migrationBuilder.DropColumn( + name: "MerchantReportingId", + table: "fileimportlogfile"); + + migrationBuilder.DropColumn( + name: "EstateReportingId", + table: "fileimportlog"); + + migrationBuilder.DropColumn( + name: "FileImportLogReportingId", + table: "fileimportlog"); + + migrationBuilder.DropColumn( + name: "ImportLogDate", + table: "fileimportlog"); + + migrationBuilder.DropColumn( + name: "FileReportingId", + table: "file"); + + migrationBuilder.DropColumn( + name: "EstateReportingId", + table: "file"); + + migrationBuilder.DropColumn( + name: "FileImportLogReportingId", + table: "file"); + + migrationBuilder.DropColumn( + name: "FileReceivedDate", + table: "file"); + + migrationBuilder.DropColumn( + name: "MerchantReportingId", + table: "file"); + + migrationBuilder.DropColumn( + name: "EstateReportingId", + table: "estatesecurityuser"); + + migrationBuilder.DropColumn( + name: "EstateReportingId", + table: "estateoperator"); + + migrationBuilder.DropColumn( + name: "EstateReportingId", + table: "estate"); + + migrationBuilder.DropColumn( + name: "ContractProductReportingId", + table: "contractproducttransactionfee"); + + migrationBuilder.DropColumn( + name: "TransactionFeeReportingId", + table: "contractproducttransactionfee"); + + migrationBuilder.DropColumn( + name: "ContractReportingId", + table: "contractproduct"); + + migrationBuilder.DropColumn( + name: "ContractProductReportingId", + table: "contractproduct"); + + migrationBuilder.DropColumn( + name: "EstateReportingId", + table: "contract"); + + migrationBuilder.DropColumn( + name: "ContractReportingId", + table: "contract"); + + migrationBuilder.AlterColumn( + name: "VoucherCode", + table: "voucher", + type: "nvarchar(max)", + nullable: false, + oldClrType: typeof(string), + oldType: "nvarchar(450)"); + + migrationBuilder.AlterColumn( + name: "ExpiryDate", + table: "voucher", + type: "datetime2", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "date"); + + migrationBuilder.AddColumn( + name: "EstateId", + table: "voucher", + type: "uniqueidentifier", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); + + migrationBuilder.AddColumn( + name: "TransactionId", + table: "voucher", + type: "uniqueidentifier", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); + + migrationBuilder.AddColumn( + name: "TransactionId", + table: "transactionfee", + type: "uniqueidentifier", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); + + migrationBuilder.AddColumn( + name: "TransactionId", + table: "transactionadditionalresponsedata", + type: "uniqueidentifier", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); + + migrationBuilder.AddColumn( + name: "EstateId", + table: "transactionadditionalresponsedata", + type: "uniqueidentifier", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); + + migrationBuilder.AddColumn( + name: "MerchantId", + table: "transactionadditionalresponsedata", + type: "uniqueidentifier", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); + + migrationBuilder.AddColumn( + name: "EstateId", + table: "transactionadditionalrequestdata", + type: "uniqueidentifier", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); + + migrationBuilder.AddColumn( + name: "MerchantId", + table: "transactionadditionalrequestdata", + type: "uniqueidentifier", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); + + migrationBuilder.AddColumn( + name: "TransactionId", + table: "transactionadditionalrequestdata", + type: "uniqueidentifier", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); + + migrationBuilder.AlterColumn( + name: "TransactionDate", + table: "transaction", + type: "datetime2", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "date"); + + migrationBuilder.AddColumn( + name: "EstateId", + table: "transaction", + type: "uniqueidentifier", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); + + migrationBuilder.AddColumn( + name: "MerchantId", + table: "transaction", + type: "uniqueidentifier", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); + + migrationBuilder.AddColumn( + name: "ContractId", + table: "transaction", + type: "uniqueidentifier", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); + + migrationBuilder.AddColumn( + name: "ProductId", + table: "transaction", + type: "uniqueidentifier", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); + + migrationBuilder.AddColumn( + name: "StatementId", + table: "statementline", + type: "uniqueidentifier", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); + + migrationBuilder.AddColumn( + name: "TransactionId", + table: "statementline", + type: "uniqueidentifier", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); + + migrationBuilder.AddColumn( + name: "EstateId", + table: "statementline", + type: "uniqueidentifier", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); + + migrationBuilder.AddColumn( + name: "MerchantId", + table: "statementline", + type: "uniqueidentifier", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); + + migrationBuilder.AlterColumn( + name: "StatementGeneratedDate", + table: "statementheader", + type: "datetime2", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "date"); + + migrationBuilder.AlterColumn( + name: "StatementCreatedDate", + table: "statementheader", + type: "datetime2", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "date"); + + migrationBuilder.AddColumn( + name: "EstateId", + table: "statementheader", + type: "uniqueidentifier", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); + + migrationBuilder.AddColumn( + name: "MerchantId", + table: "statementheader", + type: "uniqueidentifier", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); + + migrationBuilder.AlterColumn( + name: "SettlementDate", + table: "settlement", + type: "datetime2", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "date"); + + migrationBuilder.AddColumn( + name: "EstateId", + table: "settlement", + type: "uniqueidentifier", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); + + migrationBuilder.AlterColumn( + name: "TransactionDate", + table: "reconciliation", + type: "datetime2", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "date"); + + migrationBuilder.AddColumn( + name: "EstateId", + table: "reconciliation", + type: "uniqueidentifier", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); + + migrationBuilder.AddColumn( + name: "MerchantId", + table: "reconciliation", + type: "uniqueidentifier", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); + + migrationBuilder.AddColumn( + name: "EstateId", + table: "merchantsettlementfee", + type: "uniqueidentifier", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); + + migrationBuilder.AddColumn( + name: "SettlementId", + table: "merchantsettlementfee", + type: "uniqueidentifier", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); + + migrationBuilder.AddColumn( + name: "TransactionId", + table: "merchantsettlementfee", + type: "uniqueidentifier", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); + + migrationBuilder.AddColumn( + name: "FeeId", + table: "merchantsettlementfee", + type: "uniqueidentifier", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); + + migrationBuilder.AddColumn( + name: "MerchantId", + table: "merchantsettlementfee", + type: "uniqueidentifier", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); + + migrationBuilder.AddColumn( + name: "EstateId", + table: "merchantsecurityuser", + type: "uniqueidentifier", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); + + migrationBuilder.AddColumn( + name: "MerchantId", + table: "merchantsecurityuser", + type: "uniqueidentifier", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); + + migrationBuilder.AddColumn( + name: "EstateId", + table: "merchantoperator", + type: "uniqueidentifier", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); + + migrationBuilder.AddColumn( + name: "MerchantId", + table: "merchantoperator", + type: "uniqueidentifier", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); + + migrationBuilder.AddColumn( + name: "EstateId", + table: "merchantdevice", + type: "uniqueidentifier", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); + + migrationBuilder.AddColumn( + name: "MerchantId", + table: "merchantdevice", + type: "uniqueidentifier", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); + + migrationBuilder.AddColumn( + name: "EstateId", + table: "merchantcontact", + type: "uniqueidentifier", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); + + migrationBuilder.AddColumn( + name: "MerchantId", + table: "merchantcontact", + type: "uniqueidentifier", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); + + migrationBuilder.AddColumn( + name: "EstateId", + table: "merchantaddress", + type: "uniqueidentifier", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); + + migrationBuilder.AddColumn( + name: "MerchantId", + table: "merchantaddress", + type: "uniqueidentifier", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); + + migrationBuilder.AddColumn( + name: "EstateId", + table: "merchant", + type: "uniqueidentifier", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); + + migrationBuilder.AddColumn( + name: "EstateId", + table: "fileline", + type: "uniqueidentifier", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); + + migrationBuilder.AddColumn( + name: "FileId", + table: "fileline", + type: "uniqueidentifier", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); + + migrationBuilder.AddColumn( + name: "TransactionId", + table: "fileline", + type: "uniqueidentifier", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); + + migrationBuilder.AddColumn( + name: "EstateId", + table: "fileimportlogfile", + type: "uniqueidentifier", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); + + migrationBuilder.AddColumn( + name: "FileImportLogId", + table: "fileimportlogfile", + type: "uniqueidentifier", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); + + migrationBuilder.AddColumn( + name: "FileId", + table: "fileimportlogfile", + type: "uniqueidentifier", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); + + migrationBuilder.AddColumn( + name: "MerchantId", + table: "fileimportlogfile", + type: "uniqueidentifier", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); + + migrationBuilder.AddColumn( + name: "EstateId", + table: "fileimportlog", + type: "uniqueidentifier", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); + + migrationBuilder.AddColumn( + name: "EstateId", + table: "file", + type: "uniqueidentifier", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); + + migrationBuilder.AddColumn( + name: "FileImportLogId", + table: "file", + type: "uniqueidentifier", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); + + migrationBuilder.AddColumn( + name: "MerchantId", + table: "file", + type: "uniqueidentifier", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); + + migrationBuilder.AddColumn( + name: "EstateId", + table: "estatesecurityuser", + type: "uniqueidentifier", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); + + migrationBuilder.AddColumn( + name: "EstateId", + table: "estateoperator", + type: "uniqueidentifier", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); + + migrationBuilder.AddColumn( + name: "EstateId", + table: "contractproducttransactionfee", + type: "uniqueidentifier", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); + + migrationBuilder.AddColumn( + name: "ContractId", + table: "contractproducttransactionfee", + type: "uniqueidentifier", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); + + migrationBuilder.AddColumn( + name: "ProductId", + table: "contractproducttransactionfee", + type: "uniqueidentifier", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); + + migrationBuilder.AddColumn( + name: "EstateId", + table: "contractproduct", + type: "uniqueidentifier", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); + + migrationBuilder.AddColumn( + name: "ContractId", + table: "contractproduct", + type: "uniqueidentifier", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); + + migrationBuilder.AddColumn( + name: "EstateId", + table: "contract", + type: "uniqueidentifier", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); + + migrationBuilder.AddPrimaryKey( + name: "PK_transactionfee", + table: "transactionfee", + columns: new[] { "TransactionId", "FeeId" }); + + migrationBuilder.AddPrimaryKey( + name: "PK_transactionadditionalresponsedata", + table: "transactionadditionalresponsedata", + column: "TransactionId"); + + migrationBuilder.AddPrimaryKey( + name: "PK_transactionadditionalrequestdata", + table: "transactionadditionalrequestdata", + columns: new[] { "EstateId", "MerchantId", "TransactionId" }); + + migrationBuilder.AddPrimaryKey( + name: "PK_transaction", + table: "transaction", + columns: new[] { "EstateId", "MerchantId", "TransactionId" }); + + migrationBuilder.AddPrimaryKey( + name: "PK_statementline", + table: "statementline", + columns: new[] { "StatementId", "TransactionId", "ActivityDateTime", "ActivityType" }); + + migrationBuilder.AddPrimaryKey( + name: "PK_statementheader", + table: "statementheader", + column: "StatementId"); + + migrationBuilder.AddPrimaryKey( + name: "PK_settlement", + table: "settlement", + columns: new[] { "EstateId", "SettlementId" }); + + migrationBuilder.AddPrimaryKey( + name: "PK_reconciliation", + table: "reconciliation", + column: "TransactionId"); + + migrationBuilder.AddPrimaryKey( + name: "PK_merchantsettlementfee", + table: "merchantsettlementfee", + columns: new[] { "EstateId", "SettlementId", "TransactionId", "FeeId" }); + + migrationBuilder.AddPrimaryKey( + name: "PK_merchantsecurityuser", + table: "merchantsecurityuser", + columns: new[] { "EstateId", "MerchantId", "SecurityUserId" }); + + migrationBuilder.AddPrimaryKey( + name: "PK_merchantoperator", + table: "merchantoperator", + columns: new[] { "EstateId", "MerchantId", "OperatorId" }); + + migrationBuilder.AddPrimaryKey( + name: "PK_merchantdevice", + table: "merchantdevice", + columns: new[] { "EstateId", "MerchantId", "DeviceId" }); + + migrationBuilder.AddPrimaryKey( + name: "PK_merchantcontact", + table: "merchantcontact", + columns: new[] { "EstateId", "MerchantId", "ContactId" }); + + migrationBuilder.AddPrimaryKey( + name: "PK_merchantaddress", + table: "merchantaddress", + columns: new[] { "EstateId", "MerchantId", "AddressId" }); + + migrationBuilder.AddPrimaryKey( + name: "PK_merchant", + table: "merchant", + columns: new[] { "EstateId", "MerchantId" }); + + migrationBuilder.AddPrimaryKey( + name: "PK_fileline", + table: "fileline", + columns: new[] { "EstateId", "FileId", "LineNumber" }); + + migrationBuilder.AddPrimaryKey( + name: "PK_fileimportlogfile", + table: "fileimportlogfile", + columns: new[] { "EstateId", "FileImportLogId", "FileId" }); + + migrationBuilder.AddPrimaryKey( + name: "PK_fileimportlog", + table: "fileimportlog", + columns: new[] { "EstateId", "FileImportLogId" }); + + migrationBuilder.AddPrimaryKey( + name: "PK_file", + table: "file", + columns: new[] { "EstateId", "FileImportLogId", "FileId" }); + + migrationBuilder.AddPrimaryKey( + name: "PK_estatesecurityuser", + table: "estatesecurityuser", + columns: new[] { "SecurityUserId", "EstateId" }); + + migrationBuilder.AddPrimaryKey( + name: "PK_estateoperator", + table: "estateoperator", + columns: new[] { "EstateId", "OperatorId" }); + + migrationBuilder.AddPrimaryKey( + name: "PK_estate", + table: "estate", + column: "EstateId"); + + migrationBuilder.AddPrimaryKey( + name: "PK_contractproducttransactionfee", + table: "contractproducttransactionfee", + columns: new[] { "EstateId", "ContractId", "ProductId", "TransactionFeeId" }); + + migrationBuilder.AddPrimaryKey( + name: "PK_contractproduct", + table: "contractproduct", + columns: new[] { "EstateId", "ContractId", "ProductId" }); + + migrationBuilder.AddPrimaryKey( + name: "PK_contract", + table: "contract", + columns: new[] { "EstateId", "OperatorId", "ContractId" }); + + migrationBuilder.CreateTable( + name: "uvwFileImportLogView", + columns: table => new + { + FileCount = table.Column(type: "int", nullable: false), + FileImportLogId = table.Column(type: "uniqueidentifier", nullable: false), + ImportLogDate = table.Column(type: "datetime2", nullable: false), + ImportLogDateTime = table.Column(type: "datetime2", nullable: false), + ImportLogTime = table.Column(type: "time", nullable: false), + MerchantId = table.Column(type: "uniqueidentifier", nullable: false) + }, + constraints: table => + { + }); + + migrationBuilder.CreateTable( + name: "uvwFileView", + columns: table => new + { + EmailAddress = table.Column(type: "nvarchar(max)", nullable: false), + FailedCount = table.Column(type: "int", nullable: false), + FileId = table.Column(type: "uniqueidentifier", nullable: false), + FileReceivedDate = table.Column(type: "datetime2", nullable: false), + FileReceivedDateTime = table.Column(type: "datetime2", nullable: false), + FileReceivedTime = table.Column(type: "time", nullable: false), + IsCompleted = table.Column(type: "bit", nullable: false), + LineCount = table.Column(type: "int", nullable: false), + MerchantId = table.Column(type: "uniqueidentifier", nullable: false), + MerchantName = table.Column(type: "nvarchar(max)", nullable: false), + PendingCount = table.Column(type: "int", nullable: false), + SuccessCount = table.Column(type: "int", nullable: false), + UserId = table.Column(type: "uniqueidentifier", nullable: false) + }, + constraints: table => + { + }); + + migrationBuilder.CreateTable( + name: "uvwTransactionsView", + columns: table => new + { + Amount = table.Column(type: "decimal(18,2)", nullable: false), + DayOfWeek = table.Column(type: "nvarchar(max)", nullable: false), + EstateId = table.Column(type: "uniqueidentifier", nullable: false), + IsAuthorised = table.Column(type: "bit", nullable: false), + IsCompleted = table.Column(type: "bit", nullable: false), + MerchantId = table.Column(type: "uniqueidentifier", nullable: false), + Month = table.Column(type: "nvarchar(max)", nullable: false), + MonthNumber = table.Column(type: "int", nullable: false), + OperatorIdentifier = table.Column(type: "nvarchar(max)", nullable: false), + ResponseCode = table.Column(type: "nvarchar(max)", nullable: false), + TransactionDate = table.Column(type: "datetime2", nullable: false), + TransactionDateTime = table.Column(type: "datetime2", nullable: false), + TransactionId = table.Column(type: "uniqueidentifier", nullable: false), + TransactionType = table.Column(type: "nvarchar(max)", nullable: false), + WeekNumber = table.Column(type: "int", nullable: false), + YearNumber = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + }); + } + } +} diff --git a/TransactionProcessor.Database/Migrations/SqlServer/20230717125919_handleSettlementProcessingStartedEvent.Designer.cs b/TransactionProcessor.Database/Migrations/SqlServer/20230717125919_handleSettlementProcessingStartedEvent.Designer.cs new file mode 100644 index 00000000..5b4cd2a5 --- /dev/null +++ b/TransactionProcessor.Database/Migrations/SqlServer/20230717125919_handleSettlementProcessingStartedEvent.Designer.cs @@ -0,0 +1,1001 @@ +// + +#nullable disable + +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using TransactionProcessor.Database.Contexts; + +namespace TransactionProcessor.Database.Migrations.SqlServer +{ + [DbContext(typeof(EstateManagementSqlServerContext))] + [Migration("20230717125919_handleSettlementProcessingStartedEvent")] + partial class handleSettlementProcessingStartedEvent + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "7.0.7") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("EstateManagement.Database.Entities.Calendar", b => + { + b.Property("Date") + .HasColumnType("datetime2"); + + b.Property("DayOfWeek") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("DayOfWeekNumber") + .HasColumnType("int"); + + b.Property("DayOfWeekShort") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("MonthNameLong") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("MonthNameShort") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("MonthNumber") + .HasColumnType("int"); + + b.Property("WeekNumber") + .HasColumnType("int"); + + b.Property("WeekNumberString") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Year") + .HasColumnType("int"); + + b.Property("YearWeekNumber") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Date"); + + b.ToTable("calendar"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Contract", b => + { + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("OperatorId") + .HasColumnType("uniqueidentifier"); + + b.Property("ContractId") + .HasColumnType("uniqueidentifier"); + + b.Property("ContractReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("ContractReportingId")); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("EstateReportingId", "OperatorId", "ContractId"); + + b.ToTable("contract"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.ContractProduct", b => + { + b.Property("ContractReportingId") + .HasColumnType("int"); + + b.Property("ProductId") + .HasColumnType("uniqueidentifier"); + + b.Property("ContractProductReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("ContractProductReportingId")); + + b.Property("DisplayText") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ProductName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ProductType") + .HasColumnType("int"); + + b.Property("Value") + .HasColumnType("decimal(18,2)"); + + b.HasKey("ContractReportingId", "ProductId"); + + b.ToTable("contractproduct"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.ContractProductTransactionFee", b => + { + b.Property("ContractProductReportingId") + .HasColumnType("int"); + + b.Property("TransactionFeeId") + .HasColumnType("uniqueidentifier"); + + b.Property("CalculationType") + .HasColumnType("int"); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("FeeType") + .HasColumnType("int"); + + b.Property("IsEnabled") + .HasColumnType("bit"); + + b.Property("TransactionFeeReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("TransactionFeeReportingId")); + + b.Property("Value") + .HasColumnType("decimal(18,4)"); + + b.HasKey("ContractProductReportingId", "TransactionFeeId"); + + b.ToTable("contractproducttransactionfee"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Estate", b => + { + b.Property("EstateReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("EstateReportingId")); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Reference") + .HasColumnType("nvarchar(max)"); + + b.HasKey("EstateReportingId"); + + b.HasIndex("EstateId") + .IsUnique(); + + b.ToTable("estate"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.EstateOperator", b => + { + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("OperatorId") + .HasColumnType("uniqueidentifier"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("RequireCustomMerchantNumber") + .HasColumnType("bit"); + + b.Property("RequireCustomTerminalNumber") + .HasColumnType("bit"); + + b.HasKey("EstateReportingId", "OperatorId"); + + b.ToTable("estateoperator"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.EstateSecurityUser", b => + { + b.Property("SecurityUserId") + .HasColumnType("uniqueidentifier"); + + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("EmailAddress") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("SecurityUserId", "EstateReportingId"); + + b.ToTable("estatesecurityuser"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.File", b => + { + b.Property("FileReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("FileReportingId")); + + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("FileId") + .HasColumnType("uniqueidentifier"); + + b.Property("FileImportLogReportingId") + .HasColumnType("int"); + + b.Property("FileLocation") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("FileProfileId") + .HasColumnType("uniqueidentifier"); + + b.Property("FileReceivedDate") + .HasColumnType("date"); + + b.Property("FileReceivedDateTime") + .HasColumnType("datetime2"); + + b.Property("IsCompleted") + .HasColumnType("bit"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("FileReportingId"); + + b.HasIndex("FileId") + .IsUnique(); + + b.ToTable("file"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.FileImportLog", b => + { + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("FileImportLogReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("FileImportLogReportingId")); + + b.Property("FileImportLogId") + .HasColumnType("uniqueidentifier"); + + b.Property("ImportLogDate") + .HasColumnType("date"); + + b.Property("ImportLogDateTime") + .HasColumnType("datetime2"); + + b.HasKey("EstateReportingId", "FileImportLogReportingId"); + + b.HasIndex("EstateReportingId", "FileImportLogId") + .IsUnique(); + + b.ToTable("fileimportlog"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.FileImportLogFile", b => + { + b.Property("FileImportLogReportingId") + .HasColumnType("int"); + + b.Property("FileReportingId") + .HasColumnType("int"); + + b.Property("FilePath") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("FileProfileId") + .HasColumnType("uniqueidentifier"); + + b.Property("FileUploadedDate") + .HasColumnType("date"); + + b.Property("FileUploadedDateTime") + .HasColumnType("datetime2"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("OriginalFileName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("FileImportLogReportingId", "FileReportingId"); + + b.ToTable("fileimportlogfile"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.FileLine", b => + { + b.Property("FileReportingId") + .HasColumnType("int"); + + b.Property("LineNumber") + .HasColumnType("int"); + + b.Property("FileLineData") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Status") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.HasKey("FileReportingId", "LineNumber"); + + SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("FileReportingId", "LineNumber")); + + b.HasIndex("TransactionReportingId"); + + b.ToTable("fileline"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Merchant", b => + { + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("MerchantReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("MerchantReportingId")); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("LastStatementGenerated") + .HasColumnType("datetime2"); + + b.Property("MerchantId") + .HasColumnType("uniqueidentifier"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Reference") + .HasColumnType("nvarchar(max)"); + + b.Property("SettlementSchedule") + .HasColumnType("int"); + + b.HasKey("EstateReportingId", "MerchantReportingId"); + + b.HasIndex("EstateReportingId", "MerchantId") + .IsUnique(); + + b.ToTable("merchant"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantAddress", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("AddressId") + .HasColumnType("uniqueidentifier"); + + b.Property("AddressLine1") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("AddressLine2") + .HasColumnType("nvarchar(max)"); + + b.Property("AddressLine3") + .HasColumnType("nvarchar(max)"); + + b.Property("AddressLine4") + .HasColumnType("nvarchar(max)"); + + b.Property("Country") + .HasColumnType("nvarchar(max)"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("PostalCode") + .HasColumnType("nvarchar(max)"); + + b.Property("Region") + .HasColumnType("nvarchar(max)"); + + b.Property("Town") + .HasColumnType("nvarchar(max)"); + + b.HasKey("MerchantReportingId", "AddressId"); + + b.ToTable("merchantaddress"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantContact", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("ContactId") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("EmailAddress") + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("PhoneNumber") + .HasColumnType("nvarchar(max)"); + + b.HasKey("MerchantReportingId", "ContactId"); + + b.ToTable("merchantcontact"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantDevice", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("DeviceId") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("DeviceIdentifier") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("MerchantReportingId", "DeviceId"); + + b.ToTable("merchantdevice"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantOperator", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("OperatorId") + .HasColumnType("uniqueidentifier"); + + b.Property("MerchantNumber") + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("TerminalNumber") + .HasColumnType("nvarchar(max)"); + + b.HasKey("MerchantReportingId", "OperatorId"); + + b.ToTable("merchantoperator"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantSecurityUser", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("SecurityUserId") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("EmailAddress") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("MerchantReportingId", "SecurityUserId"); + + b.ToTable("merchantsecurityuser"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantSettlementFee", b => + { + b.Property("SettlementReportingId") + .HasColumnType("int"); + + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.Property("TransactionFeeReportingId") + .HasColumnType("int"); + + b.Property("CalculatedValue") + .HasColumnType("decimal(18,2)"); + + b.Property("FeeCalculatedDateTime") + .HasColumnType("datetime2"); + + b.Property("FeeValue") + .HasColumnType("decimal(18,2)"); + + b.Property("IsSettled") + .HasColumnType("bit"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.HasKey("SettlementReportingId", "TransactionReportingId", "TransactionFeeReportingId"); + + b.ToTable("merchantsettlementfee"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Reconciliation", b => + { + b.Property("TransactionReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("TransactionReportingId")); + + b.Property("DeviceIdentifier") + .HasColumnType("nvarchar(max)"); + + b.Property("IsAuthorised") + .HasColumnType("bit"); + + b.Property("IsCompleted") + .HasColumnType("bit"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("ResponseCode") + .HasColumnType("nvarchar(max)"); + + b.Property("ResponseMessage") + .HasColumnType("nvarchar(max)"); + + b.Property("TransactionCount") + .HasColumnType("int"); + + b.Property("TransactionDate") + .HasColumnType("date"); + + b.Property("TransactionDateTime") + .HasColumnType("datetime2"); + + b.Property("TransactionId") + .HasColumnType("uniqueidentifier"); + + b.Property("TransactionTime") + .HasColumnType("time"); + + b.Property("TransactionValue") + .HasColumnType("decimal(18,2)"); + + b.HasKey("TransactionReportingId"); + + SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("TransactionReportingId"), false); + + b.HasIndex("TransactionDate", "MerchantReportingId"); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("TransactionDate", "MerchantReportingId")); + + b.HasIndex("TransactionId", "MerchantReportingId") + .IsUnique(); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("TransactionId", "MerchantReportingId"), false); + + b.ToTable("reconciliation"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.ResponseCodes", b => + { + b.Property("ResponseCode") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("ResponseCode")); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("ResponseCode"); + + b.ToTable("responsecodes"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Settlement", b => + { + b.Property("SettlementReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("SettlementReportingId")); + + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("IsCompleted") + .HasColumnType("bit"); + + b.Property("ProcessingStarted") + .HasColumnType("bit"); + + b.Property("ProcessingStartedDateTIme") + .HasColumnType("datetime2"); + + b.Property("SettlementDate") + .HasColumnType("date"); + + b.Property("SettlementId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("SettlementReportingId"); + + SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("SettlementReportingId"), false); + + b.HasIndex("EstateReportingId", "SettlementId") + .IsUnique(); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("EstateReportingId", "SettlementId"), false); + + b.HasIndex("SettlementDate", "EstateReportingId"); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("SettlementDate", "EstateReportingId")); + + b.ToTable("settlement"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.StatementHeader", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("StatementId") + .HasColumnType("uniqueidentifier"); + + b.Property("StatementCreatedDate") + .HasColumnType("date"); + + b.Property("StatementCreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("StatementGeneratedDate") + .HasColumnType("date"); + + b.Property("StatementGeneratedDateTime") + .HasColumnType("datetime2"); + + b.Property("StatementReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("StatementReportingId")); + + b.HasKey("MerchantReportingId", "StatementId"); + + SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("MerchantReportingId", "StatementId"), false); + + b.HasIndex("MerchantReportingId", "StatementGeneratedDate") + .IsUnique(); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("MerchantReportingId", "StatementGeneratedDate")); + + b.ToTable("statementheader"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.StatementLine", b => + { + b.Property("StatementReportingId") + .HasColumnType("int"); + + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.Property("ActivityDateTime") + .HasColumnType("datetime2"); + + b.Property("ActivityType") + .HasColumnType("int"); + + b.Property("ActivityDate") + .HasColumnType("date"); + + b.Property("ActivityDescription") + .HasColumnType("nvarchar(max)"); + + b.Property("InAmount") + .HasColumnType("decimal(18,2)"); + + b.Property("OutAmount") + .HasColumnType("decimal(18,2)"); + + b.HasKey("StatementReportingId", "TransactionReportingId", "ActivityDateTime", "ActivityType"); + + b.ToTable("statementline"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Transaction", b => + { + b.Property("TransactionReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("TransactionReportingId")); + + b.Property("AuthorisationCode") + .HasColumnType("nvarchar(max)"); + + b.Property("ContractProductReportingId") + .HasColumnType("int"); + + b.Property("ContractReportingId") + .HasColumnType("int"); + + b.Property("DeviceIdentifier") + .HasColumnType("nvarchar(max)"); + + b.Property("IsAuthorised") + .HasColumnType("bit"); + + b.Property("IsCompleted") + .HasColumnType("bit"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("OperatorIdentifier") + .HasColumnType("nvarchar(max)"); + + b.Property("ResponseCode") + .HasColumnType("nvarchar(max)"); + + b.Property("ResponseMessage") + .HasColumnType("nvarchar(max)"); + + b.Property("TransactionDate") + .HasColumnType("date"); + + b.Property("TransactionDateTime") + .HasColumnType("datetime2"); + + b.Property("TransactionId") + .HasColumnType("uniqueidentifier"); + + b.Property("TransactionNumber") + .HasColumnType("nvarchar(max)"); + + b.Property("TransactionReference") + .HasColumnType("nvarchar(max)"); + + b.Property("TransactionSource") + .HasColumnType("int"); + + b.Property("TransactionTime") + .HasColumnType("time"); + + b.Property("TransactionType") + .HasColumnType("nvarchar(max)"); + + b.HasKey("TransactionReportingId"); + + SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("TransactionReportingId"), false); + + b.HasIndex("TransactionDate", "MerchantReportingId"); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("TransactionDate", "MerchantReportingId")); + + b.HasIndex("TransactionId", "MerchantReportingId") + .IsUnique(); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("TransactionId", "MerchantReportingId"), false); + + b.ToTable("transaction"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.TransactionAdditionalRequestData", b => + { + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.Property("Amount") + .HasColumnType("nvarchar(max)"); + + b.Property("CustomerAccountNumber") + .HasColumnType("nvarchar(max)"); + + b.HasKey("TransactionReportingId"); + + b.ToTable("transactionadditionalrequestdata"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.TransactionAdditionalResponseData", b => + { + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.HasKey("TransactionReportingId"); + + b.ToTable("transactionadditionalresponsedata"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Voucher", b => + { + b.Property("VoucherId") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("ExpiryDate") + .HasColumnType("date"); + + b.Property("ExpiryDateTime") + .HasColumnType("datetime2"); + + b.Property("GenerateDate") + .HasColumnType("date"); + + b.Property("GenerateDateTime") + .HasColumnType("datetime2"); + + b.Property("IsGenerated") + .HasColumnType("bit"); + + b.Property("IsIssued") + .HasColumnType("bit"); + + b.Property("IsRedeemed") + .HasColumnType("bit"); + + b.Property("IssuedDate") + .HasColumnType("date"); + + b.Property("IssuedDateTime") + .HasColumnType("datetime2"); + + b.Property("OperatorIdentifier") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("RecipientEmail") + .HasColumnType("nvarchar(max)"); + + b.Property("RecipientMobile") + .HasColumnType("nvarchar(max)"); + + b.Property("RedeemedDate") + .HasColumnType("datetime2"); + + b.Property("RedeemedDateTime") + .HasColumnType("datetime2"); + + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.Property("Value") + .HasColumnType("decimal(18,2)"); + + b.Property("VoucherCode") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.HasKey("VoucherId"); + + b.HasIndex("TransactionReportingId"); + + b.HasIndex("VoucherCode"); + + b.ToTable("voucher"); + }); + + modelBuilder.Entity("EstateManagement.Database.ViewEntities.SettlementView", b => + { + b.Property("Amount") + .HasColumnType("decimal(18,2)"); + + b.Property("CalculatedValue") + .HasColumnType("decimal(18,2)"); + + b.Property("DayOfWeek") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("FeeDescription") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsCompleted") + .HasColumnType("bit"); + + b.Property("IsSettled") + .HasColumnType("bit"); + + b.Property("MerchantId") + .HasColumnType("uniqueidentifier"); + + b.Property("MerchantName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Month") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("MonthNumber") + .HasColumnType("int"); + + b.Property("OperatorIdentifier") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("SettlementDate") + .HasColumnType("datetime2"); + + b.Property("SettlementId") + .HasColumnType("uniqueidentifier"); + + b.Property("TransactionId") + .HasColumnType("uniqueidentifier"); + + b.Property("WeekNumber") + .HasColumnType("int"); + + b.Property("YearNumber") + .HasColumnType("int"); + + b.ToTable((string)null); + + b.ToView("uvwSettlements", (string)null); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/TransactionProcessor.Database/Migrations/SqlServer/20230717125919_handleSettlementProcessingStartedEvent.cs b/TransactionProcessor.Database/Migrations/SqlServer/20230717125919_handleSettlementProcessingStartedEvent.cs new file mode 100644 index 00000000..3582500b --- /dev/null +++ b/TransactionProcessor.Database/Migrations/SqlServer/20230717125919_handleSettlementProcessingStartedEvent.cs @@ -0,0 +1,68 @@ +#nullable disable + +using Microsoft.EntityFrameworkCore.Migrations; + +namespace TransactionProcessor.Database.Migrations.SqlServer +{ + /// + public partial class handleSettlementProcessingStartedEvent : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "transactionfee"); + + migrationBuilder.AddColumn( + name: "ProcessingStarted", + table: "settlement", + type: "bit", + nullable: false, + defaultValue: false); + + migrationBuilder.AddColumn( + name: "ProcessingStartedDateTIme", + table: "settlement", + type: "datetime2", + nullable: false, + defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified)); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "ProcessingStarted", + table: "settlement"); + + migrationBuilder.DropColumn( + name: "ProcessingStartedDateTIme", + table: "settlement"); + + migrationBuilder.CreateTable( + name: "transactionfee", + columns: table => new + { + TransactionReportingId = table.Column(type: "int", nullable: false), + TransactionFeeReportingId = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + CalculatedValue = table.Column(type: "decimal(18,2)", nullable: false), + CalculationType = table.Column(type: "int", nullable: false), + EventId = table.Column(type: "uniqueidentifier", nullable: false), + FeeId = table.Column(type: "uniqueidentifier", nullable: false), + FeeType = table.Column(type: "int", nullable: false), + FeeValue = table.Column(type: "decimal(18,2)", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_transactionfee", x => new { x.TransactionReportingId, x.TransactionFeeReportingId }); + }); + + migrationBuilder.CreateIndex( + name: "IX_transactionfee_FeeId", + table: "transactionfee", + column: "FeeId", + unique: true); + } + } +} diff --git a/TransactionProcessor.Database/Migrations/SqlServer/20230717133118_merchantsettlementfee_missingindex.Designer.cs b/TransactionProcessor.Database/Migrations/SqlServer/20230717133118_merchantsettlementfee_missingindex.Designer.cs new file mode 100644 index 00000000..3635e1a2 --- /dev/null +++ b/TransactionProcessor.Database/Migrations/SqlServer/20230717133118_merchantsettlementfee_missingindex.Designer.cs @@ -0,0 +1,1003 @@ +// + +#nullable disable + +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using TransactionProcessor.Database.Contexts; + +namespace TransactionProcessor.Database.Migrations.SqlServer +{ + [DbContext(typeof(EstateManagementSqlServerContext))] + [Migration("20230717133118_merchantsettlementfee_missingindex")] + partial class merchantsettlementfee_missingindex + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "7.0.7") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("EstateManagement.Database.Entities.Calendar", b => + { + b.Property("Date") + .HasColumnType("datetime2"); + + b.Property("DayOfWeek") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("DayOfWeekNumber") + .HasColumnType("int"); + + b.Property("DayOfWeekShort") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("MonthNameLong") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("MonthNameShort") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("MonthNumber") + .HasColumnType("int"); + + b.Property("WeekNumber") + .HasColumnType("int"); + + b.Property("WeekNumberString") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Year") + .HasColumnType("int"); + + b.Property("YearWeekNumber") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Date"); + + b.ToTable("calendar"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Contract", b => + { + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("OperatorId") + .HasColumnType("uniqueidentifier"); + + b.Property("ContractId") + .HasColumnType("uniqueidentifier"); + + b.Property("ContractReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("ContractReportingId")); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("EstateReportingId", "OperatorId", "ContractId"); + + b.ToTable("contract"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.ContractProduct", b => + { + b.Property("ContractReportingId") + .HasColumnType("int"); + + b.Property("ProductId") + .HasColumnType("uniqueidentifier"); + + b.Property("ContractProductReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("ContractProductReportingId")); + + b.Property("DisplayText") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ProductName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ProductType") + .HasColumnType("int"); + + b.Property("Value") + .HasColumnType("decimal(18,2)"); + + b.HasKey("ContractReportingId", "ProductId"); + + b.ToTable("contractproduct"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.ContractProductTransactionFee", b => + { + b.Property("ContractProductReportingId") + .HasColumnType("int"); + + b.Property("TransactionFeeId") + .HasColumnType("uniqueidentifier"); + + b.Property("CalculationType") + .HasColumnType("int"); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("FeeType") + .HasColumnType("int"); + + b.Property("IsEnabled") + .HasColumnType("bit"); + + b.Property("TransactionFeeReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("TransactionFeeReportingId")); + + b.Property("Value") + .HasColumnType("decimal(18,4)"); + + b.HasKey("ContractProductReportingId", "TransactionFeeId"); + + b.ToTable("contractproducttransactionfee"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Estate", b => + { + b.Property("EstateReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("EstateReportingId")); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Reference") + .HasColumnType("nvarchar(max)"); + + b.HasKey("EstateReportingId"); + + b.HasIndex("EstateId") + .IsUnique(); + + b.ToTable("estate"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.EstateOperator", b => + { + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("OperatorId") + .HasColumnType("uniqueidentifier"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("RequireCustomMerchantNumber") + .HasColumnType("bit"); + + b.Property("RequireCustomTerminalNumber") + .HasColumnType("bit"); + + b.HasKey("EstateReportingId", "OperatorId"); + + b.ToTable("estateoperator"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.EstateSecurityUser", b => + { + b.Property("SecurityUserId") + .HasColumnType("uniqueidentifier"); + + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("EmailAddress") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("SecurityUserId", "EstateReportingId"); + + b.ToTable("estatesecurityuser"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.File", b => + { + b.Property("FileReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("FileReportingId")); + + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("FileId") + .HasColumnType("uniqueidentifier"); + + b.Property("FileImportLogReportingId") + .HasColumnType("int"); + + b.Property("FileLocation") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("FileProfileId") + .HasColumnType("uniqueidentifier"); + + b.Property("FileReceivedDate") + .HasColumnType("date"); + + b.Property("FileReceivedDateTime") + .HasColumnType("datetime2"); + + b.Property("IsCompleted") + .HasColumnType("bit"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("FileReportingId"); + + b.HasIndex("FileId") + .IsUnique(); + + b.ToTable("file"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.FileImportLog", b => + { + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("FileImportLogReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("FileImportLogReportingId")); + + b.Property("FileImportLogId") + .HasColumnType("uniqueidentifier"); + + b.Property("ImportLogDate") + .HasColumnType("date"); + + b.Property("ImportLogDateTime") + .HasColumnType("datetime2"); + + b.HasKey("EstateReportingId", "FileImportLogReportingId"); + + b.HasIndex("EstateReportingId", "FileImportLogId") + .IsUnique(); + + b.ToTable("fileimportlog"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.FileImportLogFile", b => + { + b.Property("FileImportLogReportingId") + .HasColumnType("int"); + + b.Property("FileReportingId") + .HasColumnType("int"); + + b.Property("FilePath") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("FileProfileId") + .HasColumnType("uniqueidentifier"); + + b.Property("FileUploadedDate") + .HasColumnType("date"); + + b.Property("FileUploadedDateTime") + .HasColumnType("datetime2"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("OriginalFileName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("FileImportLogReportingId", "FileReportingId"); + + b.ToTable("fileimportlogfile"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.FileLine", b => + { + b.Property("FileReportingId") + .HasColumnType("int"); + + b.Property("LineNumber") + .HasColumnType("int"); + + b.Property("FileLineData") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Status") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.HasKey("FileReportingId", "LineNumber"); + + SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("FileReportingId", "LineNumber")); + + b.HasIndex("TransactionReportingId"); + + b.ToTable("fileline"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Merchant", b => + { + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("MerchantReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("MerchantReportingId")); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("LastStatementGenerated") + .HasColumnType("datetime2"); + + b.Property("MerchantId") + .HasColumnType("uniqueidentifier"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Reference") + .HasColumnType("nvarchar(max)"); + + b.Property("SettlementSchedule") + .HasColumnType("int"); + + b.HasKey("EstateReportingId", "MerchantReportingId"); + + b.HasIndex("EstateReportingId", "MerchantId") + .IsUnique(); + + b.ToTable("merchant"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantAddress", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("AddressId") + .HasColumnType("uniqueidentifier"); + + b.Property("AddressLine1") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("AddressLine2") + .HasColumnType("nvarchar(max)"); + + b.Property("AddressLine3") + .HasColumnType("nvarchar(max)"); + + b.Property("AddressLine4") + .HasColumnType("nvarchar(max)"); + + b.Property("Country") + .HasColumnType("nvarchar(max)"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("PostalCode") + .HasColumnType("nvarchar(max)"); + + b.Property("Region") + .HasColumnType("nvarchar(max)"); + + b.Property("Town") + .HasColumnType("nvarchar(max)"); + + b.HasKey("MerchantReportingId", "AddressId"); + + b.ToTable("merchantaddress"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantContact", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("ContactId") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("EmailAddress") + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("PhoneNumber") + .HasColumnType("nvarchar(max)"); + + b.HasKey("MerchantReportingId", "ContactId"); + + b.ToTable("merchantcontact"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantDevice", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("DeviceId") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("DeviceIdentifier") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("MerchantReportingId", "DeviceId"); + + b.ToTable("merchantdevice"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantOperator", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("OperatorId") + .HasColumnType("uniqueidentifier"); + + b.Property("MerchantNumber") + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("TerminalNumber") + .HasColumnType("nvarchar(max)"); + + b.HasKey("MerchantReportingId", "OperatorId"); + + b.ToTable("merchantoperator"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantSecurityUser", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("SecurityUserId") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("EmailAddress") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("MerchantReportingId", "SecurityUserId"); + + b.ToTable("merchantsecurityuser"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantSettlementFee", b => + { + b.Property("SettlementReportingId") + .HasColumnType("int"); + + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.Property("TransactionFeeReportingId") + .HasColumnType("int"); + + b.Property("CalculatedValue") + .HasColumnType("decimal(18,2)"); + + b.Property("FeeCalculatedDateTime") + .HasColumnType("datetime2"); + + b.Property("FeeValue") + .HasColumnType("decimal(18,2)"); + + b.Property("IsSettled") + .HasColumnType("bit"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.HasKey("SettlementReportingId", "TransactionReportingId", "TransactionFeeReportingId"); + + b.HasIndex("TransactionReportingId"); + + b.ToTable("merchantsettlementfee"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Reconciliation", b => + { + b.Property("TransactionReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("TransactionReportingId")); + + b.Property("DeviceIdentifier") + .HasColumnType("nvarchar(max)"); + + b.Property("IsAuthorised") + .HasColumnType("bit"); + + b.Property("IsCompleted") + .HasColumnType("bit"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("ResponseCode") + .HasColumnType("nvarchar(max)"); + + b.Property("ResponseMessage") + .HasColumnType("nvarchar(max)"); + + b.Property("TransactionCount") + .HasColumnType("int"); + + b.Property("TransactionDate") + .HasColumnType("date"); + + b.Property("TransactionDateTime") + .HasColumnType("datetime2"); + + b.Property("TransactionId") + .HasColumnType("uniqueidentifier"); + + b.Property("TransactionTime") + .HasColumnType("time"); + + b.Property("TransactionValue") + .HasColumnType("decimal(18,2)"); + + b.HasKey("TransactionReportingId"); + + SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("TransactionReportingId"), false); + + b.HasIndex("TransactionDate", "MerchantReportingId"); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("TransactionDate", "MerchantReportingId")); + + b.HasIndex("TransactionId", "MerchantReportingId") + .IsUnique(); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("TransactionId", "MerchantReportingId"), false); + + b.ToTable("reconciliation"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.ResponseCodes", b => + { + b.Property("ResponseCode") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("ResponseCode")); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("ResponseCode"); + + b.ToTable("responsecodes"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Settlement", b => + { + b.Property("SettlementReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("SettlementReportingId")); + + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("IsCompleted") + .HasColumnType("bit"); + + b.Property("ProcessingStarted") + .HasColumnType("bit"); + + b.Property("ProcessingStartedDateTIme") + .HasColumnType("datetime2"); + + b.Property("SettlementDate") + .HasColumnType("date"); + + b.Property("SettlementId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("SettlementReportingId"); + + SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("SettlementReportingId"), false); + + b.HasIndex("EstateReportingId", "SettlementId") + .IsUnique(); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("EstateReportingId", "SettlementId"), false); + + b.HasIndex("SettlementDate", "EstateReportingId"); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("SettlementDate", "EstateReportingId")); + + b.ToTable("settlement"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.StatementHeader", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("StatementId") + .HasColumnType("uniqueidentifier"); + + b.Property("StatementCreatedDate") + .HasColumnType("date"); + + b.Property("StatementCreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("StatementGeneratedDate") + .HasColumnType("date"); + + b.Property("StatementGeneratedDateTime") + .HasColumnType("datetime2"); + + b.Property("StatementReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("StatementReportingId")); + + b.HasKey("MerchantReportingId", "StatementId"); + + SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("MerchantReportingId", "StatementId"), false); + + b.HasIndex("MerchantReportingId", "StatementGeneratedDate") + .IsUnique(); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("MerchantReportingId", "StatementGeneratedDate")); + + b.ToTable("statementheader"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.StatementLine", b => + { + b.Property("StatementReportingId") + .HasColumnType("int"); + + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.Property("ActivityDateTime") + .HasColumnType("datetime2"); + + b.Property("ActivityType") + .HasColumnType("int"); + + b.Property("ActivityDate") + .HasColumnType("date"); + + b.Property("ActivityDescription") + .HasColumnType("nvarchar(max)"); + + b.Property("InAmount") + .HasColumnType("decimal(18,2)"); + + b.Property("OutAmount") + .HasColumnType("decimal(18,2)"); + + b.HasKey("StatementReportingId", "TransactionReportingId", "ActivityDateTime", "ActivityType"); + + b.ToTable("statementline"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Transaction", b => + { + b.Property("TransactionReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("TransactionReportingId")); + + b.Property("AuthorisationCode") + .HasColumnType("nvarchar(max)"); + + b.Property("ContractProductReportingId") + .HasColumnType("int"); + + b.Property("ContractReportingId") + .HasColumnType("int"); + + b.Property("DeviceIdentifier") + .HasColumnType("nvarchar(max)"); + + b.Property("IsAuthorised") + .HasColumnType("bit"); + + b.Property("IsCompleted") + .HasColumnType("bit"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("OperatorIdentifier") + .HasColumnType("nvarchar(max)"); + + b.Property("ResponseCode") + .HasColumnType("nvarchar(max)"); + + b.Property("ResponseMessage") + .HasColumnType("nvarchar(max)"); + + b.Property("TransactionDate") + .HasColumnType("date"); + + b.Property("TransactionDateTime") + .HasColumnType("datetime2"); + + b.Property("TransactionId") + .HasColumnType("uniqueidentifier"); + + b.Property("TransactionNumber") + .HasColumnType("nvarchar(max)"); + + b.Property("TransactionReference") + .HasColumnType("nvarchar(max)"); + + b.Property("TransactionSource") + .HasColumnType("int"); + + b.Property("TransactionTime") + .HasColumnType("time"); + + b.Property("TransactionType") + .HasColumnType("nvarchar(max)"); + + b.HasKey("TransactionReportingId"); + + SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("TransactionReportingId"), false); + + b.HasIndex("TransactionDate", "MerchantReportingId"); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("TransactionDate", "MerchantReportingId")); + + b.HasIndex("TransactionId", "MerchantReportingId") + .IsUnique(); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("TransactionId", "MerchantReportingId"), false); + + b.ToTable("transaction"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.TransactionAdditionalRequestData", b => + { + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.Property("Amount") + .HasColumnType("nvarchar(max)"); + + b.Property("CustomerAccountNumber") + .HasColumnType("nvarchar(max)"); + + b.HasKey("TransactionReportingId"); + + b.ToTable("transactionadditionalrequestdata"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.TransactionAdditionalResponseData", b => + { + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.HasKey("TransactionReportingId"); + + b.ToTable("transactionadditionalresponsedata"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Voucher", b => + { + b.Property("VoucherId") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("ExpiryDate") + .HasColumnType("date"); + + b.Property("ExpiryDateTime") + .HasColumnType("datetime2"); + + b.Property("GenerateDate") + .HasColumnType("date"); + + b.Property("GenerateDateTime") + .HasColumnType("datetime2"); + + b.Property("IsGenerated") + .HasColumnType("bit"); + + b.Property("IsIssued") + .HasColumnType("bit"); + + b.Property("IsRedeemed") + .HasColumnType("bit"); + + b.Property("IssuedDate") + .HasColumnType("date"); + + b.Property("IssuedDateTime") + .HasColumnType("datetime2"); + + b.Property("OperatorIdentifier") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("RecipientEmail") + .HasColumnType("nvarchar(max)"); + + b.Property("RecipientMobile") + .HasColumnType("nvarchar(max)"); + + b.Property("RedeemedDate") + .HasColumnType("datetime2"); + + b.Property("RedeemedDateTime") + .HasColumnType("datetime2"); + + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.Property("Value") + .HasColumnType("decimal(18,2)"); + + b.Property("VoucherCode") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.HasKey("VoucherId"); + + b.HasIndex("TransactionReportingId"); + + b.HasIndex("VoucherCode"); + + b.ToTable("voucher"); + }); + + modelBuilder.Entity("EstateManagement.Database.ViewEntities.SettlementView", b => + { + b.Property("Amount") + .HasColumnType("decimal(18,2)"); + + b.Property("CalculatedValue") + .HasColumnType("decimal(18,2)"); + + b.Property("DayOfWeek") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("FeeDescription") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsCompleted") + .HasColumnType("bit"); + + b.Property("IsSettled") + .HasColumnType("bit"); + + b.Property("MerchantId") + .HasColumnType("uniqueidentifier"); + + b.Property("MerchantName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Month") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("MonthNumber") + .HasColumnType("int"); + + b.Property("OperatorIdentifier") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("SettlementDate") + .HasColumnType("datetime2"); + + b.Property("SettlementId") + .HasColumnType("uniqueidentifier"); + + b.Property("TransactionId") + .HasColumnType("uniqueidentifier"); + + b.Property("WeekNumber") + .HasColumnType("int"); + + b.Property("YearNumber") + .HasColumnType("int"); + + b.ToTable((string)null); + + b.ToView("uvwSettlements", (string)null); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/TransactionProcessor.Database/Migrations/SqlServer/20230717133118_merchantsettlementfee_missingindex.cs b/TransactionProcessor.Database/Migrations/SqlServer/20230717133118_merchantsettlementfee_missingindex.cs new file mode 100644 index 00000000..996863b1 --- /dev/null +++ b/TransactionProcessor.Database/Migrations/SqlServer/20230717133118_merchantsettlementfee_missingindex.cs @@ -0,0 +1,27 @@ +#nullable disable + +using Microsoft.EntityFrameworkCore.Migrations; + +namespace TransactionProcessor.Database.Migrations.SqlServer +{ + /// + public partial class merchantsettlementfee_missingindex : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateIndex( + name: "IX_merchantsettlementfee_TransactionReportingId", + table: "merchantsettlementfee", + column: "TransactionReportingId"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropIndex( + name: "IX_merchantsettlementfee_TransactionReportingId", + table: "merchantsettlementfee"); + } + } +} diff --git a/TransactionProcessor.Database/Migrations/SqlServer/20230721142728_addmerchanttosettlementtable.Designer.cs b/TransactionProcessor.Database/Migrations/SqlServer/20230721142728_addmerchanttosettlementtable.Designer.cs new file mode 100644 index 00000000..9f0464d6 --- /dev/null +++ b/TransactionProcessor.Database/Migrations/SqlServer/20230721142728_addmerchanttosettlementtable.Designer.cs @@ -0,0 +1,1006 @@ +// + +#nullable disable + +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using TransactionProcessor.Database.Contexts; + +namespace TransactionProcessor.Database.Migrations.SqlServer +{ + [DbContext(typeof(EstateManagementSqlServerContext))] + [Migration("20230721142728_addmerchanttosettlementtable")] + partial class addmerchanttosettlementtable + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "7.0.7") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("EstateManagement.Database.Entities.Calendar", b => + { + b.Property("Date") + .HasColumnType("datetime2"); + + b.Property("DayOfWeek") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("DayOfWeekNumber") + .HasColumnType("int"); + + b.Property("DayOfWeekShort") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("MonthNameLong") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("MonthNameShort") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("MonthNumber") + .HasColumnType("int"); + + b.Property("WeekNumber") + .HasColumnType("int"); + + b.Property("WeekNumberString") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Year") + .HasColumnType("int"); + + b.Property("YearWeekNumber") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Date"); + + b.ToTable("calendar"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Contract", b => + { + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("OperatorId") + .HasColumnType("uniqueidentifier"); + + b.Property("ContractId") + .HasColumnType("uniqueidentifier"); + + b.Property("ContractReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("ContractReportingId")); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("EstateReportingId", "OperatorId", "ContractId"); + + b.ToTable("contract"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.ContractProduct", b => + { + b.Property("ContractReportingId") + .HasColumnType("int"); + + b.Property("ProductId") + .HasColumnType("uniqueidentifier"); + + b.Property("ContractProductReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("ContractProductReportingId")); + + b.Property("DisplayText") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ProductName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ProductType") + .HasColumnType("int"); + + b.Property("Value") + .HasColumnType("decimal(18,2)"); + + b.HasKey("ContractReportingId", "ProductId"); + + b.ToTable("contractproduct"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.ContractProductTransactionFee", b => + { + b.Property("ContractProductReportingId") + .HasColumnType("int"); + + b.Property("TransactionFeeId") + .HasColumnType("uniqueidentifier"); + + b.Property("CalculationType") + .HasColumnType("int"); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("FeeType") + .HasColumnType("int"); + + b.Property("IsEnabled") + .HasColumnType("bit"); + + b.Property("TransactionFeeReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("TransactionFeeReportingId")); + + b.Property("Value") + .HasColumnType("decimal(18,4)"); + + b.HasKey("ContractProductReportingId", "TransactionFeeId"); + + b.ToTable("contractproducttransactionfee"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Estate", b => + { + b.Property("EstateReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("EstateReportingId")); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Reference") + .HasColumnType("nvarchar(max)"); + + b.HasKey("EstateReportingId"); + + b.HasIndex("EstateId") + .IsUnique(); + + b.ToTable("estate"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.EstateOperator", b => + { + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("OperatorId") + .HasColumnType("uniqueidentifier"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("RequireCustomMerchantNumber") + .HasColumnType("bit"); + + b.Property("RequireCustomTerminalNumber") + .HasColumnType("bit"); + + b.HasKey("EstateReportingId", "OperatorId"); + + b.ToTable("estateoperator"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.EstateSecurityUser", b => + { + b.Property("SecurityUserId") + .HasColumnType("uniqueidentifier"); + + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("EmailAddress") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("SecurityUserId", "EstateReportingId"); + + b.ToTable("estatesecurityuser"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.File", b => + { + b.Property("FileReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("FileReportingId")); + + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("FileId") + .HasColumnType("uniqueidentifier"); + + b.Property("FileImportLogReportingId") + .HasColumnType("int"); + + b.Property("FileLocation") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("FileProfileId") + .HasColumnType("uniqueidentifier"); + + b.Property("FileReceivedDate") + .HasColumnType("date"); + + b.Property("FileReceivedDateTime") + .HasColumnType("datetime2"); + + b.Property("IsCompleted") + .HasColumnType("bit"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("FileReportingId"); + + b.HasIndex("FileId") + .IsUnique(); + + b.ToTable("file"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.FileImportLog", b => + { + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("FileImportLogReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("FileImportLogReportingId")); + + b.Property("FileImportLogId") + .HasColumnType("uniqueidentifier"); + + b.Property("ImportLogDate") + .HasColumnType("date"); + + b.Property("ImportLogDateTime") + .HasColumnType("datetime2"); + + b.HasKey("EstateReportingId", "FileImportLogReportingId"); + + b.HasIndex("EstateReportingId", "FileImportLogId") + .IsUnique(); + + b.ToTable("fileimportlog"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.FileImportLogFile", b => + { + b.Property("FileImportLogReportingId") + .HasColumnType("int"); + + b.Property("FileReportingId") + .HasColumnType("int"); + + b.Property("FilePath") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("FileProfileId") + .HasColumnType("uniqueidentifier"); + + b.Property("FileUploadedDate") + .HasColumnType("date"); + + b.Property("FileUploadedDateTime") + .HasColumnType("datetime2"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("OriginalFileName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("FileImportLogReportingId", "FileReportingId"); + + b.ToTable("fileimportlogfile"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.FileLine", b => + { + b.Property("FileReportingId") + .HasColumnType("int"); + + b.Property("LineNumber") + .HasColumnType("int"); + + b.Property("FileLineData") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Status") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.HasKey("FileReportingId", "LineNumber"); + + SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("FileReportingId", "LineNumber")); + + b.HasIndex("TransactionReportingId"); + + b.ToTable("fileline"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Merchant", b => + { + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("MerchantReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("MerchantReportingId")); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("LastStatementGenerated") + .HasColumnType("datetime2"); + + b.Property("MerchantId") + .HasColumnType("uniqueidentifier"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Reference") + .HasColumnType("nvarchar(max)"); + + b.Property("SettlementSchedule") + .HasColumnType("int"); + + b.HasKey("EstateReportingId", "MerchantReportingId"); + + b.HasIndex("EstateReportingId", "MerchantId") + .IsUnique(); + + b.ToTable("merchant"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantAddress", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("AddressId") + .HasColumnType("uniqueidentifier"); + + b.Property("AddressLine1") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("AddressLine2") + .HasColumnType("nvarchar(max)"); + + b.Property("AddressLine3") + .HasColumnType("nvarchar(max)"); + + b.Property("AddressLine4") + .HasColumnType("nvarchar(max)"); + + b.Property("Country") + .HasColumnType("nvarchar(max)"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("PostalCode") + .HasColumnType("nvarchar(max)"); + + b.Property("Region") + .HasColumnType("nvarchar(max)"); + + b.Property("Town") + .HasColumnType("nvarchar(max)"); + + b.HasKey("MerchantReportingId", "AddressId"); + + b.ToTable("merchantaddress"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantContact", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("ContactId") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("EmailAddress") + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("PhoneNumber") + .HasColumnType("nvarchar(max)"); + + b.HasKey("MerchantReportingId", "ContactId"); + + b.ToTable("merchantcontact"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantDevice", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("DeviceId") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("DeviceIdentifier") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("MerchantReportingId", "DeviceId"); + + b.ToTable("merchantdevice"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantOperator", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("OperatorId") + .HasColumnType("uniqueidentifier"); + + b.Property("MerchantNumber") + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("TerminalNumber") + .HasColumnType("nvarchar(max)"); + + b.HasKey("MerchantReportingId", "OperatorId"); + + b.ToTable("merchantoperator"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantSecurityUser", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("SecurityUserId") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("EmailAddress") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("MerchantReportingId", "SecurityUserId"); + + b.ToTable("merchantsecurityuser"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantSettlementFee", b => + { + b.Property("SettlementReportingId") + .HasColumnType("int"); + + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.Property("TransactionFeeReportingId") + .HasColumnType("int"); + + b.Property("CalculatedValue") + .HasColumnType("decimal(18,2)"); + + b.Property("FeeCalculatedDateTime") + .HasColumnType("datetime2"); + + b.Property("FeeValue") + .HasColumnType("decimal(18,2)"); + + b.Property("IsSettled") + .HasColumnType("bit"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.HasKey("SettlementReportingId", "TransactionReportingId", "TransactionFeeReportingId"); + + b.HasIndex("TransactionReportingId"); + + b.ToTable("merchantsettlementfee"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Reconciliation", b => + { + b.Property("TransactionReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("TransactionReportingId")); + + b.Property("DeviceIdentifier") + .HasColumnType("nvarchar(max)"); + + b.Property("IsAuthorised") + .HasColumnType("bit"); + + b.Property("IsCompleted") + .HasColumnType("bit"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("ResponseCode") + .HasColumnType("nvarchar(max)"); + + b.Property("ResponseMessage") + .HasColumnType("nvarchar(max)"); + + b.Property("TransactionCount") + .HasColumnType("int"); + + b.Property("TransactionDate") + .HasColumnType("date"); + + b.Property("TransactionDateTime") + .HasColumnType("datetime2"); + + b.Property("TransactionId") + .HasColumnType("uniqueidentifier"); + + b.Property("TransactionTime") + .HasColumnType("time"); + + b.Property("TransactionValue") + .HasColumnType("decimal(18,2)"); + + b.HasKey("TransactionReportingId"); + + SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("TransactionReportingId"), false); + + b.HasIndex("TransactionDate", "MerchantReportingId"); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("TransactionDate", "MerchantReportingId")); + + b.HasIndex("TransactionId", "MerchantReportingId") + .IsUnique(); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("TransactionId", "MerchantReportingId"), false); + + b.ToTable("reconciliation"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.ResponseCodes", b => + { + b.Property("ResponseCode") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("ResponseCode")); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("ResponseCode"); + + b.ToTable("responsecodes"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Settlement", b => + { + b.Property("SettlementReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("SettlementReportingId")); + + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("IsCompleted") + .HasColumnType("bit"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("ProcessingStarted") + .HasColumnType("bit"); + + b.Property("ProcessingStartedDateTIme") + .HasColumnType("datetime2"); + + b.Property("SettlementDate") + .HasColumnType("date"); + + b.Property("SettlementId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("SettlementReportingId"); + + SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("SettlementReportingId"), false); + + b.HasIndex("EstateReportingId", "SettlementId") + .IsUnique(); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("EstateReportingId", "SettlementId"), false); + + b.HasIndex("SettlementDate", "EstateReportingId"); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("SettlementDate", "EstateReportingId")); + + b.ToTable("settlement"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.StatementHeader", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("StatementId") + .HasColumnType("uniqueidentifier"); + + b.Property("StatementCreatedDate") + .HasColumnType("date"); + + b.Property("StatementCreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("StatementGeneratedDate") + .HasColumnType("date"); + + b.Property("StatementGeneratedDateTime") + .HasColumnType("datetime2"); + + b.Property("StatementReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("StatementReportingId")); + + b.HasKey("MerchantReportingId", "StatementId"); + + SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("MerchantReportingId", "StatementId"), false); + + b.HasIndex("MerchantReportingId", "StatementGeneratedDate") + .IsUnique(); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("MerchantReportingId", "StatementGeneratedDate")); + + b.ToTable("statementheader"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.StatementLine", b => + { + b.Property("StatementReportingId") + .HasColumnType("int"); + + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.Property("ActivityDateTime") + .HasColumnType("datetime2"); + + b.Property("ActivityType") + .HasColumnType("int"); + + b.Property("ActivityDate") + .HasColumnType("date"); + + b.Property("ActivityDescription") + .HasColumnType("nvarchar(max)"); + + b.Property("InAmount") + .HasColumnType("decimal(18,2)"); + + b.Property("OutAmount") + .HasColumnType("decimal(18,2)"); + + b.HasKey("StatementReportingId", "TransactionReportingId", "ActivityDateTime", "ActivityType"); + + b.ToTable("statementline"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Transaction", b => + { + b.Property("TransactionReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("TransactionReportingId")); + + b.Property("AuthorisationCode") + .HasColumnType("nvarchar(max)"); + + b.Property("ContractProductReportingId") + .HasColumnType("int"); + + b.Property("ContractReportingId") + .HasColumnType("int"); + + b.Property("DeviceIdentifier") + .HasColumnType("nvarchar(max)"); + + b.Property("IsAuthorised") + .HasColumnType("bit"); + + b.Property("IsCompleted") + .HasColumnType("bit"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("OperatorIdentifier") + .HasColumnType("nvarchar(max)"); + + b.Property("ResponseCode") + .HasColumnType("nvarchar(max)"); + + b.Property("ResponseMessage") + .HasColumnType("nvarchar(max)"); + + b.Property("TransactionDate") + .HasColumnType("date"); + + b.Property("TransactionDateTime") + .HasColumnType("datetime2"); + + b.Property("TransactionId") + .HasColumnType("uniqueidentifier"); + + b.Property("TransactionNumber") + .HasColumnType("nvarchar(max)"); + + b.Property("TransactionReference") + .HasColumnType("nvarchar(max)"); + + b.Property("TransactionSource") + .HasColumnType("int"); + + b.Property("TransactionTime") + .HasColumnType("time"); + + b.Property("TransactionType") + .HasColumnType("nvarchar(max)"); + + b.HasKey("TransactionReportingId"); + + SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("TransactionReportingId"), false); + + b.HasIndex("TransactionDate", "MerchantReportingId"); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("TransactionDate", "MerchantReportingId")); + + b.HasIndex("TransactionId", "MerchantReportingId") + .IsUnique(); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("TransactionId", "MerchantReportingId"), false); + + b.ToTable("transaction"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.TransactionAdditionalRequestData", b => + { + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.Property("Amount") + .HasColumnType("nvarchar(max)"); + + b.Property("CustomerAccountNumber") + .HasColumnType("nvarchar(max)"); + + b.HasKey("TransactionReportingId"); + + b.ToTable("transactionadditionalrequestdata"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.TransactionAdditionalResponseData", b => + { + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.HasKey("TransactionReportingId"); + + b.ToTable("transactionadditionalresponsedata"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Voucher", b => + { + b.Property("VoucherId") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("ExpiryDate") + .HasColumnType("date"); + + b.Property("ExpiryDateTime") + .HasColumnType("datetime2"); + + b.Property("GenerateDate") + .HasColumnType("date"); + + b.Property("GenerateDateTime") + .HasColumnType("datetime2"); + + b.Property("IsGenerated") + .HasColumnType("bit"); + + b.Property("IsIssued") + .HasColumnType("bit"); + + b.Property("IsRedeemed") + .HasColumnType("bit"); + + b.Property("IssuedDate") + .HasColumnType("date"); + + b.Property("IssuedDateTime") + .HasColumnType("datetime2"); + + b.Property("OperatorIdentifier") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("RecipientEmail") + .HasColumnType("nvarchar(max)"); + + b.Property("RecipientMobile") + .HasColumnType("nvarchar(max)"); + + b.Property("RedeemedDate") + .HasColumnType("datetime2"); + + b.Property("RedeemedDateTime") + .HasColumnType("datetime2"); + + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.Property("Value") + .HasColumnType("decimal(18,2)"); + + b.Property("VoucherCode") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.HasKey("VoucherId"); + + b.HasIndex("TransactionReportingId"); + + b.HasIndex("VoucherCode"); + + b.ToTable("voucher"); + }); + + modelBuilder.Entity("EstateManagement.Database.ViewEntities.SettlementView", b => + { + b.Property("Amount") + .HasColumnType("decimal(18,2)"); + + b.Property("CalculatedValue") + .HasColumnType("decimal(18,2)"); + + b.Property("DayOfWeek") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("FeeDescription") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsCompleted") + .HasColumnType("bit"); + + b.Property("IsSettled") + .HasColumnType("bit"); + + b.Property("MerchantId") + .HasColumnType("uniqueidentifier"); + + b.Property("MerchantName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Month") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("MonthNumber") + .HasColumnType("int"); + + b.Property("OperatorIdentifier") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("SettlementDate") + .HasColumnType("datetime2"); + + b.Property("SettlementId") + .HasColumnType("uniqueidentifier"); + + b.Property("TransactionId") + .HasColumnType("uniqueidentifier"); + + b.Property("WeekNumber") + .HasColumnType("int"); + + b.Property("YearNumber") + .HasColumnType("int"); + + b.ToTable((string)null); + + b.ToView("uvwSettlements", (string)null); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/TransactionProcessor.Database/Migrations/SqlServer/20230721142728_addmerchanttosettlementtable.cs b/TransactionProcessor.Database/Migrations/SqlServer/20230721142728_addmerchanttosettlementtable.cs new file mode 100644 index 00000000..92ee6e4a --- /dev/null +++ b/TransactionProcessor.Database/Migrations/SqlServer/20230721142728_addmerchanttosettlementtable.cs @@ -0,0 +1,29 @@ +#nullable disable + +using Microsoft.EntityFrameworkCore.Migrations; + +namespace TransactionProcessor.Database.Migrations.SqlServer +{ + /// + public partial class addmerchanttosettlementtable : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "MerchantReportingId", + table: "settlement", + type: "int", + nullable: false, + defaultValue: 0); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "MerchantReportingId", + table: "settlement"); + } + } +} diff --git a/TransactionProcessor.Database/Migrations/SqlServer/20230801201426_storelastsaleagainstmerchant.Designer.cs b/TransactionProcessor.Database/Migrations/SqlServer/20230801201426_storelastsaleagainstmerchant.Designer.cs new file mode 100644 index 00000000..5c9abbaf --- /dev/null +++ b/TransactionProcessor.Database/Migrations/SqlServer/20230801201426_storelastsaleagainstmerchant.Designer.cs @@ -0,0 +1,1012 @@ +// + +#nullable disable + +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using TransactionProcessor.Database.Contexts; + +namespace TransactionProcessor.Database.Migrations.SqlServer +{ + [DbContext(typeof(EstateManagementSqlServerContext))] + [Migration("20230801201426_storelastsaleagainstmerchant")] + partial class storelastsaleagainstmerchant + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "7.0.7") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("EstateManagement.Database.Entities.Calendar", b => + { + b.Property("Date") + .HasColumnType("datetime2"); + + b.Property("DayOfWeek") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("DayOfWeekNumber") + .HasColumnType("int"); + + b.Property("DayOfWeekShort") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("MonthNameLong") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("MonthNameShort") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("MonthNumber") + .HasColumnType("int"); + + b.Property("WeekNumber") + .HasColumnType("int"); + + b.Property("WeekNumberString") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Year") + .HasColumnType("int"); + + b.Property("YearWeekNumber") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Date"); + + b.ToTable("calendar"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Contract", b => + { + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("OperatorId") + .HasColumnType("uniqueidentifier"); + + b.Property("ContractId") + .HasColumnType("uniqueidentifier"); + + b.Property("ContractReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("ContractReportingId")); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("EstateReportingId", "OperatorId", "ContractId"); + + b.ToTable("contract"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.ContractProduct", b => + { + b.Property("ContractReportingId") + .HasColumnType("int"); + + b.Property("ProductId") + .HasColumnType("uniqueidentifier"); + + b.Property("ContractProductReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("ContractProductReportingId")); + + b.Property("DisplayText") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ProductName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ProductType") + .HasColumnType("int"); + + b.Property("Value") + .HasColumnType("decimal(18,2)"); + + b.HasKey("ContractReportingId", "ProductId"); + + b.ToTable("contractproduct"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.ContractProductTransactionFee", b => + { + b.Property("ContractProductReportingId") + .HasColumnType("int"); + + b.Property("TransactionFeeId") + .HasColumnType("uniqueidentifier"); + + b.Property("CalculationType") + .HasColumnType("int"); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("FeeType") + .HasColumnType("int"); + + b.Property("IsEnabled") + .HasColumnType("bit"); + + b.Property("TransactionFeeReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("TransactionFeeReportingId")); + + b.Property("Value") + .HasColumnType("decimal(18,4)"); + + b.HasKey("ContractProductReportingId", "TransactionFeeId"); + + b.ToTable("contractproducttransactionfee"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Estate", b => + { + b.Property("EstateReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("EstateReportingId")); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Reference") + .HasColumnType("nvarchar(max)"); + + b.HasKey("EstateReportingId"); + + b.HasIndex("EstateId") + .IsUnique(); + + b.ToTable("estate"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.EstateOperator", b => + { + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("OperatorId") + .HasColumnType("uniqueidentifier"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("RequireCustomMerchantNumber") + .HasColumnType("bit"); + + b.Property("RequireCustomTerminalNumber") + .HasColumnType("bit"); + + b.HasKey("EstateReportingId", "OperatorId"); + + b.ToTable("estateoperator"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.EstateSecurityUser", b => + { + b.Property("SecurityUserId") + .HasColumnType("uniqueidentifier"); + + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("EmailAddress") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("SecurityUserId", "EstateReportingId"); + + b.ToTable("estatesecurityuser"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.File", b => + { + b.Property("FileReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("FileReportingId")); + + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("FileId") + .HasColumnType("uniqueidentifier"); + + b.Property("FileImportLogReportingId") + .HasColumnType("int"); + + b.Property("FileLocation") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("FileProfileId") + .HasColumnType("uniqueidentifier"); + + b.Property("FileReceivedDate") + .HasColumnType("date"); + + b.Property("FileReceivedDateTime") + .HasColumnType("datetime2"); + + b.Property("IsCompleted") + .HasColumnType("bit"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("FileReportingId"); + + b.HasIndex("FileId") + .IsUnique(); + + b.ToTable("file"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.FileImportLog", b => + { + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("FileImportLogReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("FileImportLogReportingId")); + + b.Property("FileImportLogId") + .HasColumnType("uniqueidentifier"); + + b.Property("ImportLogDate") + .HasColumnType("date"); + + b.Property("ImportLogDateTime") + .HasColumnType("datetime2"); + + b.HasKey("EstateReportingId", "FileImportLogReportingId"); + + b.HasIndex("EstateReportingId", "FileImportLogId") + .IsUnique(); + + b.ToTable("fileimportlog"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.FileImportLogFile", b => + { + b.Property("FileImportLogReportingId") + .HasColumnType("int"); + + b.Property("FileReportingId") + .HasColumnType("int"); + + b.Property("FilePath") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("FileProfileId") + .HasColumnType("uniqueidentifier"); + + b.Property("FileUploadedDate") + .HasColumnType("date"); + + b.Property("FileUploadedDateTime") + .HasColumnType("datetime2"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("OriginalFileName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("FileImportLogReportingId", "FileReportingId"); + + b.ToTable("fileimportlogfile"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.FileLine", b => + { + b.Property("FileReportingId") + .HasColumnType("int"); + + b.Property("LineNumber") + .HasColumnType("int"); + + b.Property("FileLineData") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Status") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.HasKey("FileReportingId", "LineNumber"); + + SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("FileReportingId", "LineNumber")); + + b.HasIndex("TransactionReportingId"); + + b.ToTable("fileline"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Merchant", b => + { + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("MerchantReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("MerchantReportingId")); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("LastSaleDate") + .HasColumnType("date"); + + b.Property("LastSaleDateTime") + .HasColumnType("datetime2"); + + b.Property("LastStatementGenerated") + .HasColumnType("datetime2"); + + b.Property("MerchantId") + .HasColumnType("uniqueidentifier"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Reference") + .HasColumnType("nvarchar(max)"); + + b.Property("SettlementSchedule") + .HasColumnType("int"); + + b.HasKey("EstateReportingId", "MerchantReportingId"); + + b.HasIndex("EstateReportingId", "MerchantId") + .IsUnique(); + + b.ToTable("merchant"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantAddress", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("AddressId") + .HasColumnType("uniqueidentifier"); + + b.Property("AddressLine1") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("AddressLine2") + .HasColumnType("nvarchar(max)"); + + b.Property("AddressLine3") + .HasColumnType("nvarchar(max)"); + + b.Property("AddressLine4") + .HasColumnType("nvarchar(max)"); + + b.Property("Country") + .HasColumnType("nvarchar(max)"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("PostalCode") + .HasColumnType("nvarchar(max)"); + + b.Property("Region") + .HasColumnType("nvarchar(max)"); + + b.Property("Town") + .HasColumnType("nvarchar(max)"); + + b.HasKey("MerchantReportingId", "AddressId"); + + b.ToTable("merchantaddress"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantContact", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("ContactId") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("EmailAddress") + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("PhoneNumber") + .HasColumnType("nvarchar(max)"); + + b.HasKey("MerchantReportingId", "ContactId"); + + b.ToTable("merchantcontact"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantDevice", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("DeviceId") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("DeviceIdentifier") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("MerchantReportingId", "DeviceId"); + + b.ToTable("merchantdevice"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantOperator", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("OperatorId") + .HasColumnType("uniqueidentifier"); + + b.Property("MerchantNumber") + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("TerminalNumber") + .HasColumnType("nvarchar(max)"); + + b.HasKey("MerchantReportingId", "OperatorId"); + + b.ToTable("merchantoperator"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantSecurityUser", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("SecurityUserId") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("EmailAddress") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("MerchantReportingId", "SecurityUserId"); + + b.ToTable("merchantsecurityuser"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantSettlementFee", b => + { + b.Property("SettlementReportingId") + .HasColumnType("int"); + + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.Property("TransactionFeeReportingId") + .HasColumnType("int"); + + b.Property("CalculatedValue") + .HasColumnType("decimal(18,2)"); + + b.Property("FeeCalculatedDateTime") + .HasColumnType("datetime2"); + + b.Property("FeeValue") + .HasColumnType("decimal(18,2)"); + + b.Property("IsSettled") + .HasColumnType("bit"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.HasKey("SettlementReportingId", "TransactionReportingId", "TransactionFeeReportingId"); + + b.HasIndex("TransactionReportingId"); + + b.ToTable("merchantsettlementfee"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Reconciliation", b => + { + b.Property("TransactionReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("TransactionReportingId")); + + b.Property("DeviceIdentifier") + .HasColumnType("nvarchar(max)"); + + b.Property("IsAuthorised") + .HasColumnType("bit"); + + b.Property("IsCompleted") + .HasColumnType("bit"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("ResponseCode") + .HasColumnType("nvarchar(max)"); + + b.Property("ResponseMessage") + .HasColumnType("nvarchar(max)"); + + b.Property("TransactionCount") + .HasColumnType("int"); + + b.Property("TransactionDate") + .HasColumnType("date"); + + b.Property("TransactionDateTime") + .HasColumnType("datetime2"); + + b.Property("TransactionId") + .HasColumnType("uniqueidentifier"); + + b.Property("TransactionTime") + .HasColumnType("time"); + + b.Property("TransactionValue") + .HasColumnType("decimal(18,2)"); + + b.HasKey("TransactionReportingId"); + + SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("TransactionReportingId"), false); + + b.HasIndex("TransactionDate", "MerchantReportingId"); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("TransactionDate", "MerchantReportingId")); + + b.HasIndex("TransactionId", "MerchantReportingId") + .IsUnique(); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("TransactionId", "MerchantReportingId"), false); + + b.ToTable("reconciliation"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.ResponseCodes", b => + { + b.Property("ResponseCode") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("ResponseCode")); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("ResponseCode"); + + b.ToTable("responsecodes"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Settlement", b => + { + b.Property("SettlementReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("SettlementReportingId")); + + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("IsCompleted") + .HasColumnType("bit"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("ProcessingStarted") + .HasColumnType("bit"); + + b.Property("ProcessingStartedDateTIme") + .HasColumnType("datetime2"); + + b.Property("SettlementDate") + .HasColumnType("date"); + + b.Property("SettlementId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("SettlementReportingId"); + + SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("SettlementReportingId"), false); + + b.HasIndex("EstateReportingId", "SettlementId") + .IsUnique(); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("EstateReportingId", "SettlementId"), false); + + b.HasIndex("SettlementDate", "EstateReportingId"); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("SettlementDate", "EstateReportingId")); + + b.ToTable("settlement"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.StatementHeader", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("StatementId") + .HasColumnType("uniqueidentifier"); + + b.Property("StatementCreatedDate") + .HasColumnType("date"); + + b.Property("StatementCreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("StatementGeneratedDate") + .HasColumnType("date"); + + b.Property("StatementGeneratedDateTime") + .HasColumnType("datetime2"); + + b.Property("StatementReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("StatementReportingId")); + + b.HasKey("MerchantReportingId", "StatementId"); + + SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("MerchantReportingId", "StatementId"), false); + + b.HasIndex("MerchantReportingId", "StatementGeneratedDate") + .IsUnique(); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("MerchantReportingId", "StatementGeneratedDate")); + + b.ToTable("statementheader"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.StatementLine", b => + { + b.Property("StatementReportingId") + .HasColumnType("int"); + + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.Property("ActivityDateTime") + .HasColumnType("datetime2"); + + b.Property("ActivityType") + .HasColumnType("int"); + + b.Property("ActivityDate") + .HasColumnType("date"); + + b.Property("ActivityDescription") + .HasColumnType("nvarchar(max)"); + + b.Property("InAmount") + .HasColumnType("decimal(18,2)"); + + b.Property("OutAmount") + .HasColumnType("decimal(18,2)"); + + b.HasKey("StatementReportingId", "TransactionReportingId", "ActivityDateTime", "ActivityType"); + + b.ToTable("statementline"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Transaction", b => + { + b.Property("TransactionReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("TransactionReportingId")); + + b.Property("AuthorisationCode") + .HasColumnType("nvarchar(max)"); + + b.Property("ContractProductReportingId") + .HasColumnType("int"); + + b.Property("ContractReportingId") + .HasColumnType("int"); + + b.Property("DeviceIdentifier") + .HasColumnType("nvarchar(max)"); + + b.Property("IsAuthorised") + .HasColumnType("bit"); + + b.Property("IsCompleted") + .HasColumnType("bit"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("OperatorIdentifier") + .HasColumnType("nvarchar(max)"); + + b.Property("ResponseCode") + .HasColumnType("nvarchar(max)"); + + b.Property("ResponseMessage") + .HasColumnType("nvarchar(max)"); + + b.Property("TransactionDate") + .HasColumnType("date"); + + b.Property("TransactionDateTime") + .HasColumnType("datetime2"); + + b.Property("TransactionId") + .HasColumnType("uniqueidentifier"); + + b.Property("TransactionNumber") + .HasColumnType("nvarchar(max)"); + + b.Property("TransactionReference") + .HasColumnType("nvarchar(max)"); + + b.Property("TransactionSource") + .HasColumnType("int"); + + b.Property("TransactionTime") + .HasColumnType("time"); + + b.Property("TransactionType") + .HasColumnType("nvarchar(max)"); + + b.HasKey("TransactionReportingId"); + + SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("TransactionReportingId"), false); + + b.HasIndex("TransactionDate", "MerchantReportingId"); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("TransactionDate", "MerchantReportingId")); + + b.HasIndex("TransactionId", "MerchantReportingId") + .IsUnique(); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("TransactionId", "MerchantReportingId"), false); + + b.ToTable("transaction"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.TransactionAdditionalRequestData", b => + { + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.Property("Amount") + .HasColumnType("nvarchar(max)"); + + b.Property("CustomerAccountNumber") + .HasColumnType("nvarchar(max)"); + + b.HasKey("TransactionReportingId"); + + b.ToTable("transactionadditionalrequestdata"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.TransactionAdditionalResponseData", b => + { + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.HasKey("TransactionReportingId"); + + b.ToTable("transactionadditionalresponsedata"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Voucher", b => + { + b.Property("VoucherId") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("ExpiryDate") + .HasColumnType("date"); + + b.Property("ExpiryDateTime") + .HasColumnType("datetime2"); + + b.Property("GenerateDate") + .HasColumnType("date"); + + b.Property("GenerateDateTime") + .HasColumnType("datetime2"); + + b.Property("IsGenerated") + .HasColumnType("bit"); + + b.Property("IsIssued") + .HasColumnType("bit"); + + b.Property("IsRedeemed") + .HasColumnType("bit"); + + b.Property("IssuedDate") + .HasColumnType("date"); + + b.Property("IssuedDateTime") + .HasColumnType("datetime2"); + + b.Property("OperatorIdentifier") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("RecipientEmail") + .HasColumnType("nvarchar(max)"); + + b.Property("RecipientMobile") + .HasColumnType("nvarchar(max)"); + + b.Property("RedeemedDate") + .HasColumnType("datetime2"); + + b.Property("RedeemedDateTime") + .HasColumnType("datetime2"); + + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.Property("Value") + .HasColumnType("decimal(18,2)"); + + b.Property("VoucherCode") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.HasKey("VoucherId"); + + b.HasIndex("TransactionReportingId"); + + b.HasIndex("VoucherCode"); + + b.ToTable("voucher"); + }); + + modelBuilder.Entity("EstateManagement.Database.ViewEntities.SettlementView", b => + { + b.Property("Amount") + .HasColumnType("decimal(18,2)"); + + b.Property("CalculatedValue") + .HasColumnType("decimal(18,2)"); + + b.Property("DayOfWeek") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("FeeDescription") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsCompleted") + .HasColumnType("bit"); + + b.Property("IsSettled") + .HasColumnType("bit"); + + b.Property("MerchantId") + .HasColumnType("uniqueidentifier"); + + b.Property("MerchantName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Month") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("MonthNumber") + .HasColumnType("int"); + + b.Property("OperatorIdentifier") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("SettlementDate") + .HasColumnType("datetime2"); + + b.Property("SettlementId") + .HasColumnType("uniqueidentifier"); + + b.Property("TransactionId") + .HasColumnType("uniqueidentifier"); + + b.Property("WeekNumber") + .HasColumnType("int"); + + b.Property("YearNumber") + .HasColumnType("int"); + + b.ToTable((string)null); + + b.ToView("uvwSettlements", (string)null); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/TransactionProcessor.Database/Migrations/SqlServer/20230801201426_storelastsaleagainstmerchant.cs b/TransactionProcessor.Database/Migrations/SqlServer/20230801201426_storelastsaleagainstmerchant.cs new file mode 100644 index 00000000..935b1a13 --- /dev/null +++ b/TransactionProcessor.Database/Migrations/SqlServer/20230801201426_storelastsaleagainstmerchant.cs @@ -0,0 +1,40 @@ +#nullable disable + +using Microsoft.EntityFrameworkCore.Migrations; + +namespace TransactionProcessor.Database.Migrations.SqlServer +{ + /// + public partial class storelastsaleagainstmerchant : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "LastSaleDate", + table: "merchant", + type: "date", + nullable: false, + defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified)); + + migrationBuilder.AddColumn( + name: "LastSaleDateTime", + table: "merchant", + type: "datetime2", + nullable: false, + defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified)); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "LastSaleDate", + table: "merchant"); + + migrationBuilder.DropColumn( + name: "LastSaleDateTime", + table: "merchant"); + } + } +} diff --git a/TransactionProcessor.Database/Migrations/SqlServer/20230905183930_amountintransaction.Designer.cs b/TransactionProcessor.Database/Migrations/SqlServer/20230905183930_amountintransaction.Designer.cs new file mode 100644 index 00000000..4adea019 --- /dev/null +++ b/TransactionProcessor.Database/Migrations/SqlServer/20230905183930_amountintransaction.Designer.cs @@ -0,0 +1,1020 @@ +// + +#nullable disable + +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using TransactionProcessor.Database.Contexts; + +namespace TransactionProcessor.Database.Migrations.SqlServer +{ + [DbContext(typeof(EstateManagementSqlServerContext))] + [Migration("20230905183930_amountintransaction")] + partial class amountintransaction + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "7.0.7") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("EstateManagement.Database.Entities.Calendar", b => + { + b.Property("Date") + .HasColumnType("datetime2"); + + b.Property("DayOfWeek") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("DayOfWeekNumber") + .HasColumnType("int"); + + b.Property("DayOfWeekShort") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("MonthNameLong") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("MonthNameShort") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("MonthNumber") + .HasColumnType("int"); + + b.Property("WeekNumber") + .HasColumnType("int"); + + b.Property("WeekNumberString") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Year") + .HasColumnType("int"); + + b.Property("YearWeekNumber") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Date"); + + b.ToTable("calendar"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Contract", b => + { + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("OperatorId") + .HasColumnType("uniqueidentifier"); + + b.Property("ContractId") + .HasColumnType("uniqueidentifier"); + + b.Property("ContractReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("ContractReportingId")); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("EstateReportingId", "OperatorId", "ContractId"); + + b.ToTable("contract"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.ContractProduct", b => + { + b.Property("ContractReportingId") + .HasColumnType("int"); + + b.Property("ProductId") + .HasColumnType("uniqueidentifier"); + + b.Property("ContractProductReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("ContractProductReportingId")); + + b.Property("DisplayText") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ProductName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ProductType") + .HasColumnType("int"); + + b.Property("Value") + .HasColumnType("decimal(18,2)"); + + b.HasKey("ContractReportingId", "ProductId"); + + b.ToTable("contractproduct"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.ContractProductTransactionFee", b => + { + b.Property("ContractProductReportingId") + .HasColumnType("int"); + + b.Property("TransactionFeeId") + .HasColumnType("uniqueidentifier"); + + b.Property("CalculationType") + .HasColumnType("int"); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("FeeType") + .HasColumnType("int"); + + b.Property("IsEnabled") + .HasColumnType("bit"); + + b.Property("TransactionFeeReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("TransactionFeeReportingId")); + + b.Property("Value") + .HasColumnType("decimal(18,4)"); + + b.HasKey("ContractProductReportingId", "TransactionFeeId"); + + b.ToTable("contractproducttransactionfee"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Estate", b => + { + b.Property("EstateReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("EstateReportingId")); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Reference") + .HasColumnType("nvarchar(max)"); + + b.HasKey("EstateReportingId"); + + b.HasIndex("EstateId") + .IsUnique(); + + b.ToTable("estate"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.EstateOperator", b => + { + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("OperatorId") + .HasColumnType("uniqueidentifier"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("RequireCustomMerchantNumber") + .HasColumnType("bit"); + + b.Property("RequireCustomTerminalNumber") + .HasColumnType("bit"); + + b.HasKey("EstateReportingId", "OperatorId"); + + b.ToTable("estateoperator"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.EstateSecurityUser", b => + { + b.Property("SecurityUserId") + .HasColumnType("uniqueidentifier"); + + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("EmailAddress") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("SecurityUserId", "EstateReportingId"); + + b.ToTable("estatesecurityuser"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.File", b => + { + b.Property("FileReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("FileReportingId")); + + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("FileId") + .HasColumnType("uniqueidentifier"); + + b.Property("FileImportLogReportingId") + .HasColumnType("int"); + + b.Property("FileLocation") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("FileProfileId") + .HasColumnType("uniqueidentifier"); + + b.Property("FileReceivedDate") + .HasColumnType("date"); + + b.Property("FileReceivedDateTime") + .HasColumnType("datetime2"); + + b.Property("IsCompleted") + .HasColumnType("bit"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("FileReportingId"); + + b.HasIndex("FileId") + .IsUnique(); + + b.ToTable("file"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.FileImportLog", b => + { + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("FileImportLogReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("FileImportLogReportingId")); + + b.Property("FileImportLogId") + .HasColumnType("uniqueidentifier"); + + b.Property("ImportLogDate") + .HasColumnType("date"); + + b.Property("ImportLogDateTime") + .HasColumnType("datetime2"); + + b.HasKey("EstateReportingId", "FileImportLogReportingId"); + + b.HasIndex("EstateReportingId", "FileImportLogId") + .IsUnique(); + + b.ToTable("fileimportlog"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.FileImportLogFile", b => + { + b.Property("FileImportLogReportingId") + .HasColumnType("int"); + + b.Property("FileReportingId") + .HasColumnType("int"); + + b.Property("FilePath") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("FileProfileId") + .HasColumnType("uniqueidentifier"); + + b.Property("FileUploadedDate") + .HasColumnType("date"); + + b.Property("FileUploadedDateTime") + .HasColumnType("datetime2"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("OriginalFileName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("FileImportLogReportingId", "FileReportingId"); + + b.ToTable("fileimportlogfile"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.FileLine", b => + { + b.Property("FileReportingId") + .HasColumnType("int"); + + b.Property("LineNumber") + .HasColumnType("int"); + + b.Property("FileLineData") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Status") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.HasKey("FileReportingId", "LineNumber"); + + SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("FileReportingId", "LineNumber")); + + b.HasIndex("TransactionReportingId"); + + b.ToTable("fileline"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Merchant", b => + { + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("MerchantReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("MerchantReportingId")); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("LastSaleDate") + .HasColumnType("date"); + + b.Property("LastSaleDateTime") + .HasColumnType("datetime2"); + + b.Property("LastStatementGenerated") + .HasColumnType("datetime2"); + + b.Property("MerchantId") + .HasColumnType("uniqueidentifier"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Reference") + .HasColumnType("nvarchar(max)"); + + b.Property("SettlementSchedule") + .HasColumnType("int"); + + b.HasKey("EstateReportingId", "MerchantReportingId"); + + b.HasIndex("EstateReportingId", "MerchantId") + .IsUnique(); + + b.ToTable("merchant"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantAddress", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("AddressId") + .HasColumnType("uniqueidentifier"); + + b.Property("AddressLine1") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("AddressLine2") + .HasColumnType("nvarchar(max)"); + + b.Property("AddressLine3") + .HasColumnType("nvarchar(max)"); + + b.Property("AddressLine4") + .HasColumnType("nvarchar(max)"); + + b.Property("Country") + .HasColumnType("nvarchar(max)"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("PostalCode") + .HasColumnType("nvarchar(max)"); + + b.Property("Region") + .HasColumnType("nvarchar(max)"); + + b.Property("Town") + .HasColumnType("nvarchar(max)"); + + b.HasKey("MerchantReportingId", "AddressId"); + + b.ToTable("merchantaddress"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantContact", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("ContactId") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("EmailAddress") + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("PhoneNumber") + .HasColumnType("nvarchar(max)"); + + b.HasKey("MerchantReportingId", "ContactId"); + + b.ToTable("merchantcontact"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantDevice", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("DeviceId") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("DeviceIdentifier") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("MerchantReportingId", "DeviceId"); + + b.ToTable("merchantdevice"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantOperator", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("OperatorId") + .HasColumnType("uniqueidentifier"); + + b.Property("MerchantNumber") + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("TerminalNumber") + .HasColumnType("nvarchar(max)"); + + b.HasKey("MerchantReportingId", "OperatorId"); + + b.ToTable("merchantoperator"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantSecurityUser", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("SecurityUserId") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("EmailAddress") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("MerchantReportingId", "SecurityUserId"); + + b.ToTable("merchantsecurityuser"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantSettlementFee", b => + { + b.Property("SettlementReportingId") + .HasColumnType("int"); + + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.Property("TransactionFeeReportingId") + .HasColumnType("int"); + + b.Property("CalculatedValue") + .HasColumnType("decimal(18,2)"); + + b.Property("FeeCalculatedDateTime") + .HasColumnType("datetime2"); + + b.Property("FeeValue") + .HasColumnType("decimal(18,2)"); + + b.Property("IsSettled") + .HasColumnType("bit"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.HasKey("SettlementReportingId", "TransactionReportingId", "TransactionFeeReportingId"); + + b.HasIndex("TransactionReportingId"); + + b.ToTable("merchantsettlementfee"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Reconciliation", b => + { + b.Property("TransactionReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("TransactionReportingId")); + + b.Property("DeviceIdentifier") + .HasColumnType("nvarchar(max)"); + + b.Property("IsAuthorised") + .HasColumnType("bit"); + + b.Property("IsCompleted") + .HasColumnType("bit"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("ResponseCode") + .HasColumnType("nvarchar(max)"); + + b.Property("ResponseMessage") + .HasColumnType("nvarchar(max)"); + + b.Property("TransactionCount") + .HasColumnType("int"); + + b.Property("TransactionDate") + .HasColumnType("date"); + + b.Property("TransactionDateTime") + .HasColumnType("datetime2"); + + b.Property("TransactionId") + .HasColumnType("uniqueidentifier"); + + b.Property("TransactionTime") + .HasColumnType("time"); + + b.Property("TransactionValue") + .HasColumnType("decimal(18,2)"); + + b.HasKey("TransactionReportingId"); + + SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("TransactionReportingId"), false); + + b.HasIndex("TransactionDate", "MerchantReportingId"); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("TransactionDate", "MerchantReportingId")); + + b.HasIndex("TransactionId", "MerchantReportingId") + .IsUnique(); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("TransactionId", "MerchantReportingId"), false); + + b.ToTable("reconciliation"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.ResponseCodes", b => + { + b.Property("ResponseCode") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("ResponseCode")); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("ResponseCode"); + + b.ToTable("responsecodes"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Settlement", b => + { + b.Property("SettlementReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("SettlementReportingId")); + + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("IsCompleted") + .HasColumnType("bit"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("ProcessingStarted") + .HasColumnType("bit"); + + b.Property("ProcessingStartedDateTIme") + .HasColumnType("datetime2"); + + b.Property("SettlementDate") + .HasColumnType("date"); + + b.Property("SettlementId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("SettlementReportingId"); + + SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("SettlementReportingId"), false); + + b.HasIndex("EstateReportingId", "SettlementId") + .IsUnique(); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("EstateReportingId", "SettlementId"), false); + + b.HasIndex("SettlementDate", "EstateReportingId"); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("SettlementDate", "EstateReportingId")); + + b.ToTable("settlement"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.StatementHeader", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("StatementId") + .HasColumnType("uniqueidentifier"); + + b.Property("StatementCreatedDate") + .HasColumnType("date"); + + b.Property("StatementCreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("StatementGeneratedDate") + .HasColumnType("date"); + + b.Property("StatementGeneratedDateTime") + .HasColumnType("datetime2"); + + b.Property("StatementReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("StatementReportingId")); + + b.HasKey("MerchantReportingId", "StatementId"); + + SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("MerchantReportingId", "StatementId"), false); + + b.HasIndex("MerchantReportingId", "StatementGeneratedDate") + .IsUnique(); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("MerchantReportingId", "StatementGeneratedDate")); + + b.ToTable("statementheader"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.StatementLine", b => + { + b.Property("StatementReportingId") + .HasColumnType("int"); + + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.Property("ActivityDateTime") + .HasColumnType("datetime2"); + + b.Property("ActivityType") + .HasColumnType("int"); + + b.Property("ActivityDate") + .HasColumnType("date"); + + b.Property("ActivityDescription") + .HasColumnType("nvarchar(max)"); + + b.Property("InAmount") + .HasColumnType("decimal(18,2)"); + + b.Property("OutAmount") + .HasColumnType("decimal(18,2)"); + + b.HasKey("StatementReportingId", "TransactionReportingId", "ActivityDateTime", "ActivityType"); + + b.ToTable("statementline"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Transaction", b => + { + b.Property("TransactionReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("TransactionReportingId")); + + b.Property("AuthorisationCode") + .HasColumnType("nvarchar(max)"); + + b.Property("ContractProductReportingId") + .HasColumnType("int"); + + b.Property("ContractReportingId") + .HasColumnType("int"); + + b.Property("DeviceIdentifier") + .HasColumnType("nvarchar(max)"); + + b.Property("IsAuthorised") + .HasColumnType("bit"); + + b.Property("IsCompleted") + .HasColumnType("bit"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("OperatorIdentifier") + .HasColumnType("nvarchar(max)"); + + b.Property("ResponseCode") + .HasColumnType("nvarchar(max)"); + + b.Property("ResponseMessage") + .HasColumnType("nvarchar(max)"); + + b.Property("TransactionAmount") + .HasColumnType("decimal(18,2)"); + + b.Property("TransactionDate") + .HasColumnType("date"); + + b.Property("TransactionDateTime") + .HasColumnType("datetime2"); + + b.Property("TransactionId") + .HasColumnType("uniqueidentifier"); + + b.Property("TransactionNumber") + .HasColumnType("nvarchar(max)"); + + b.Property("TransactionReference") + .HasColumnType("nvarchar(max)"); + + b.Property("TransactionSource") + .HasColumnType("int"); + + b.Property("TransactionTime") + .HasColumnType("time"); + + b.Property("TransactionType") + .HasColumnType("nvarchar(max)"); + + b.HasKey("TransactionReportingId"); + + SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("TransactionReportingId"), false); + + b.HasIndex("TransactionId") + .IsUnique(); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("TransactionId"), false); + + b.HasIndex("TransactionDate", "MerchantReportingId"); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("TransactionDate", "MerchantReportingId")); + + b.HasIndex("TransactionId", "MerchantReportingId") + .IsUnique(); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("TransactionId", "MerchantReportingId"), false); + + b.ToTable("transaction"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.TransactionAdditionalRequestData", b => + { + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.Property("Amount") + .HasColumnType("nvarchar(max)"); + + b.Property("CustomerAccountNumber") + .HasColumnType("nvarchar(max)"); + + b.HasKey("TransactionReportingId"); + + b.ToTable("transactionadditionalrequestdata"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.TransactionAdditionalResponseData", b => + { + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.HasKey("TransactionReportingId"); + + b.ToTable("transactionadditionalresponsedata"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Voucher", b => + { + b.Property("VoucherId") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("ExpiryDate") + .HasColumnType("date"); + + b.Property("ExpiryDateTime") + .HasColumnType("datetime2"); + + b.Property("GenerateDate") + .HasColumnType("date"); + + b.Property("GenerateDateTime") + .HasColumnType("datetime2"); + + b.Property("IsGenerated") + .HasColumnType("bit"); + + b.Property("IsIssued") + .HasColumnType("bit"); + + b.Property("IsRedeemed") + .HasColumnType("bit"); + + b.Property("IssuedDate") + .HasColumnType("date"); + + b.Property("IssuedDateTime") + .HasColumnType("datetime2"); + + b.Property("OperatorIdentifier") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("RecipientEmail") + .HasColumnType("nvarchar(max)"); + + b.Property("RecipientMobile") + .HasColumnType("nvarchar(max)"); + + b.Property("RedeemedDate") + .HasColumnType("datetime2"); + + b.Property("RedeemedDateTime") + .HasColumnType("datetime2"); + + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.Property("Value") + .HasColumnType("decimal(18,2)"); + + b.Property("VoucherCode") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.HasKey("VoucherId"); + + b.HasIndex("TransactionReportingId"); + + b.HasIndex("VoucherCode"); + + b.ToTable("voucher"); + }); + + modelBuilder.Entity("EstateManagement.Database.ViewEntities.SettlementView", b => + { + b.Property("Amount") + .HasColumnType("decimal(18,2)"); + + b.Property("CalculatedValue") + .HasColumnType("decimal(18,2)"); + + b.Property("DayOfWeek") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("FeeDescription") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsCompleted") + .HasColumnType("bit"); + + b.Property("IsSettled") + .HasColumnType("bit"); + + b.Property("MerchantId") + .HasColumnType("uniqueidentifier"); + + b.Property("MerchantName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Month") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("MonthNumber") + .HasColumnType("int"); + + b.Property("OperatorIdentifier") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("SettlementDate") + .HasColumnType("datetime2"); + + b.Property("SettlementId") + .HasColumnType("uniqueidentifier"); + + b.Property("TransactionId") + .HasColumnType("uniqueidentifier"); + + b.Property("WeekNumber") + .HasColumnType("int"); + + b.Property("YearNumber") + .HasColumnType("int"); + + b.ToTable((string)null); + + b.ToView("uvwSettlements", (string)null); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/TransactionProcessor.Database/Migrations/SqlServer/20230905183930_amountintransaction.cs b/TransactionProcessor.Database/Migrations/SqlServer/20230905183930_amountintransaction.cs new file mode 100644 index 00000000..d3310a28 --- /dev/null +++ b/TransactionProcessor.Database/Migrations/SqlServer/20230905183930_amountintransaction.cs @@ -0,0 +1,40 @@ +#nullable disable + +using Microsoft.EntityFrameworkCore.Migrations; + +namespace TransactionProcessor.Database.Migrations.SqlServer +{ + /// + public partial class amountintransaction : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "TransactionAmount", + table: "transaction", + type: "decimal(18,2)", + nullable: false, + defaultValue: 0m); + + migrationBuilder.CreateIndex( + name: "IX_transaction_TransactionId", + table: "transaction", + column: "TransactionId", + unique: true) + .Annotation("SqlServer:Clustered", false); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropIndex( + name: "IX_transaction_TransactionId", + table: "transaction"); + + migrationBuilder.DropColumn( + name: "TransactionAmount", + table: "transaction"); + } + } +} diff --git a/TransactionProcessor.Database/Migrations/SqlServer/20231115193804_recordestateoperatorreportingidwithtxn.Designer.cs b/TransactionProcessor.Database/Migrations/SqlServer/20231115193804_recordestateoperatorreportingidwithtxn.Designer.cs new file mode 100644 index 00000000..29f5f10a --- /dev/null +++ b/TransactionProcessor.Database/Migrations/SqlServer/20231115193804_recordestateoperatorreportingidwithtxn.Designer.cs @@ -0,0 +1,1026 @@ +// + +#nullable disable + +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using TransactionProcessor.Database.Contexts; + +namespace TransactionProcessor.Database.Migrations.SqlServer +{ + [DbContext(typeof(EstateManagementSqlServerContext))] + [Migration("20231115193804_recordestateoperatorreportingidwithtxn")] + partial class recordestateoperatorreportingidwithtxn + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "7.0.7") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("EstateManagement.Database.Entities.Calendar", b => + { + b.Property("Date") + .HasColumnType("datetime2"); + + b.Property("DayOfWeek") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("DayOfWeekNumber") + .HasColumnType("int"); + + b.Property("DayOfWeekShort") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("MonthNameLong") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("MonthNameShort") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("MonthNumber") + .HasColumnType("int"); + + b.Property("WeekNumber") + .HasColumnType("int"); + + b.Property("WeekNumberString") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Year") + .HasColumnType("int"); + + b.Property("YearWeekNumber") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Date"); + + b.ToTable("calendar"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Contract", b => + { + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("OperatorId") + .HasColumnType("uniqueidentifier"); + + b.Property("ContractId") + .HasColumnType("uniqueidentifier"); + + b.Property("ContractReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("ContractReportingId")); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("EstateReportingId", "OperatorId", "ContractId"); + + b.ToTable("contract"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.ContractProduct", b => + { + b.Property("ContractReportingId") + .HasColumnType("int"); + + b.Property("ProductId") + .HasColumnType("uniqueidentifier"); + + b.Property("ContractProductReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("ContractProductReportingId")); + + b.Property("DisplayText") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ProductName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ProductType") + .HasColumnType("int"); + + b.Property("Value") + .HasColumnType("decimal(18,2)"); + + b.HasKey("ContractReportingId", "ProductId"); + + b.ToTable("contractproduct"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.ContractProductTransactionFee", b => + { + b.Property("ContractProductReportingId") + .HasColumnType("int"); + + b.Property("TransactionFeeId") + .HasColumnType("uniqueidentifier"); + + b.Property("CalculationType") + .HasColumnType("int"); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("FeeType") + .HasColumnType("int"); + + b.Property("IsEnabled") + .HasColumnType("bit"); + + b.Property("TransactionFeeReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("TransactionFeeReportingId")); + + b.Property("Value") + .HasColumnType("decimal(18,4)"); + + b.HasKey("ContractProductReportingId", "TransactionFeeId"); + + b.ToTable("contractproducttransactionfee"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Estate", b => + { + b.Property("EstateReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("EstateReportingId")); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Reference") + .HasColumnType("nvarchar(max)"); + + b.HasKey("EstateReportingId"); + + b.HasIndex("EstateId") + .IsUnique(); + + b.ToTable("estate"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.EstateOperator", b => + { + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("OperatorId") + .HasColumnType("uniqueidentifier"); + + b.Property("EstateOperatorReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("EstateOperatorReportingId")); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("RequireCustomMerchantNumber") + .HasColumnType("bit"); + + b.Property("RequireCustomTerminalNumber") + .HasColumnType("bit"); + + b.HasKey("EstateReportingId", "OperatorId"); + + b.ToTable("estateoperator"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.EstateSecurityUser", b => + { + b.Property("SecurityUserId") + .HasColumnType("uniqueidentifier"); + + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("EmailAddress") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("SecurityUserId", "EstateReportingId"); + + b.ToTable("estatesecurityuser"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.File", b => + { + b.Property("FileReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("FileReportingId")); + + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("FileId") + .HasColumnType("uniqueidentifier"); + + b.Property("FileImportLogReportingId") + .HasColumnType("int"); + + b.Property("FileLocation") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("FileProfileId") + .HasColumnType("uniqueidentifier"); + + b.Property("FileReceivedDate") + .HasColumnType("date"); + + b.Property("FileReceivedDateTime") + .HasColumnType("datetime2"); + + b.Property("IsCompleted") + .HasColumnType("bit"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("FileReportingId"); + + b.HasIndex("FileId") + .IsUnique(); + + b.ToTable("file"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.FileImportLog", b => + { + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("FileImportLogReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("FileImportLogReportingId")); + + b.Property("FileImportLogId") + .HasColumnType("uniqueidentifier"); + + b.Property("ImportLogDate") + .HasColumnType("date"); + + b.Property("ImportLogDateTime") + .HasColumnType("datetime2"); + + b.HasKey("EstateReportingId", "FileImportLogReportingId"); + + b.HasIndex("EstateReportingId", "FileImportLogId") + .IsUnique(); + + b.ToTable("fileimportlog"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.FileImportLogFile", b => + { + b.Property("FileImportLogReportingId") + .HasColumnType("int"); + + b.Property("FileReportingId") + .HasColumnType("int"); + + b.Property("FilePath") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("FileProfileId") + .HasColumnType("uniqueidentifier"); + + b.Property("FileUploadedDate") + .HasColumnType("date"); + + b.Property("FileUploadedDateTime") + .HasColumnType("datetime2"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("OriginalFileName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("FileImportLogReportingId", "FileReportingId"); + + b.ToTable("fileimportlogfile"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.FileLine", b => + { + b.Property("FileReportingId") + .HasColumnType("int"); + + b.Property("LineNumber") + .HasColumnType("int"); + + b.Property("FileLineData") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Status") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.HasKey("FileReportingId", "LineNumber"); + + SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("FileReportingId", "LineNumber")); + + b.HasIndex("TransactionReportingId"); + + b.ToTable("fileline"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Merchant", b => + { + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("MerchantReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("MerchantReportingId")); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("LastSaleDate") + .HasColumnType("date"); + + b.Property("LastSaleDateTime") + .HasColumnType("datetime2"); + + b.Property("LastStatementGenerated") + .HasColumnType("datetime2"); + + b.Property("MerchantId") + .HasColumnType("uniqueidentifier"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Reference") + .HasColumnType("nvarchar(max)"); + + b.Property("SettlementSchedule") + .HasColumnType("int"); + + b.HasKey("EstateReportingId", "MerchantReportingId"); + + b.HasIndex("EstateReportingId", "MerchantId") + .IsUnique(); + + b.ToTable("merchant"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantAddress", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("AddressId") + .HasColumnType("uniqueidentifier"); + + b.Property("AddressLine1") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("AddressLine2") + .HasColumnType("nvarchar(max)"); + + b.Property("AddressLine3") + .HasColumnType("nvarchar(max)"); + + b.Property("AddressLine4") + .HasColumnType("nvarchar(max)"); + + b.Property("Country") + .HasColumnType("nvarchar(max)"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("PostalCode") + .HasColumnType("nvarchar(max)"); + + b.Property("Region") + .HasColumnType("nvarchar(max)"); + + b.Property("Town") + .HasColumnType("nvarchar(max)"); + + b.HasKey("MerchantReportingId", "AddressId"); + + b.ToTable("merchantaddress"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantContact", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("ContactId") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("EmailAddress") + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("PhoneNumber") + .HasColumnType("nvarchar(max)"); + + b.HasKey("MerchantReportingId", "ContactId"); + + b.ToTable("merchantcontact"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantDevice", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("DeviceId") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("DeviceIdentifier") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("MerchantReportingId", "DeviceId"); + + b.ToTable("merchantdevice"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantOperator", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("OperatorId") + .HasColumnType("uniqueidentifier"); + + b.Property("MerchantNumber") + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("TerminalNumber") + .HasColumnType("nvarchar(max)"); + + b.HasKey("MerchantReportingId", "OperatorId"); + + b.ToTable("merchantoperator"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantSecurityUser", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("SecurityUserId") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("EmailAddress") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("MerchantReportingId", "SecurityUserId"); + + b.ToTable("merchantsecurityuser"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantSettlementFee", b => + { + b.Property("SettlementReportingId") + .HasColumnType("int"); + + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.Property("TransactionFeeReportingId") + .HasColumnType("int"); + + b.Property("CalculatedValue") + .HasColumnType("decimal(18,2)"); + + b.Property("FeeCalculatedDateTime") + .HasColumnType("datetime2"); + + b.Property("FeeValue") + .HasColumnType("decimal(18,2)"); + + b.Property("IsSettled") + .HasColumnType("bit"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.HasKey("SettlementReportingId", "TransactionReportingId", "TransactionFeeReportingId"); + + b.HasIndex("TransactionReportingId"); + + b.ToTable("merchantsettlementfee"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Reconciliation", b => + { + b.Property("TransactionReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("TransactionReportingId")); + + b.Property("DeviceIdentifier") + .HasColumnType("nvarchar(max)"); + + b.Property("IsAuthorised") + .HasColumnType("bit"); + + b.Property("IsCompleted") + .HasColumnType("bit"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("ResponseCode") + .HasColumnType("nvarchar(max)"); + + b.Property("ResponseMessage") + .HasColumnType("nvarchar(max)"); + + b.Property("TransactionCount") + .HasColumnType("int"); + + b.Property("TransactionDate") + .HasColumnType("date"); + + b.Property("TransactionDateTime") + .HasColumnType("datetime2"); + + b.Property("TransactionId") + .HasColumnType("uniqueidentifier"); + + b.Property("TransactionTime") + .HasColumnType("time"); + + b.Property("TransactionValue") + .HasColumnType("decimal(18,2)"); + + b.HasKey("TransactionReportingId"); + + SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("TransactionReportingId"), false); + + b.HasIndex("TransactionDate", "MerchantReportingId"); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("TransactionDate", "MerchantReportingId")); + + b.HasIndex("TransactionId", "MerchantReportingId") + .IsUnique(); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("TransactionId", "MerchantReportingId"), false); + + b.ToTable("reconciliation"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.ResponseCodes", b => + { + b.Property("ResponseCode") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("ResponseCode")); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("ResponseCode"); + + b.ToTable("responsecodes"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Settlement", b => + { + b.Property("SettlementReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("SettlementReportingId")); + + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("IsCompleted") + .HasColumnType("bit"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("ProcessingStarted") + .HasColumnType("bit"); + + b.Property("ProcessingStartedDateTIme") + .HasColumnType("datetime2"); + + b.Property("SettlementDate") + .HasColumnType("date"); + + b.Property("SettlementId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("SettlementReportingId"); + + SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("SettlementReportingId"), false); + + b.HasIndex("EstateReportingId", "SettlementId") + .IsUnique(); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("EstateReportingId", "SettlementId"), false); + + b.HasIndex("SettlementDate", "EstateReportingId"); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("SettlementDate", "EstateReportingId")); + + b.ToTable("settlement"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.StatementHeader", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("StatementId") + .HasColumnType("uniqueidentifier"); + + b.Property("StatementCreatedDate") + .HasColumnType("date"); + + b.Property("StatementCreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("StatementGeneratedDate") + .HasColumnType("date"); + + b.Property("StatementGeneratedDateTime") + .HasColumnType("datetime2"); + + b.Property("StatementReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("StatementReportingId")); + + b.HasKey("MerchantReportingId", "StatementId"); + + SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("MerchantReportingId", "StatementId"), false); + + b.HasIndex("MerchantReportingId", "StatementGeneratedDate") + .IsUnique(); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("MerchantReportingId", "StatementGeneratedDate")); + + b.ToTable("statementheader"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.StatementLine", b => + { + b.Property("StatementReportingId") + .HasColumnType("int"); + + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.Property("ActivityDateTime") + .HasColumnType("datetime2"); + + b.Property("ActivityType") + .HasColumnType("int"); + + b.Property("ActivityDate") + .HasColumnType("date"); + + b.Property("ActivityDescription") + .HasColumnType("nvarchar(max)"); + + b.Property("InAmount") + .HasColumnType("decimal(18,2)"); + + b.Property("OutAmount") + .HasColumnType("decimal(18,2)"); + + b.HasKey("StatementReportingId", "TransactionReportingId", "ActivityDateTime", "ActivityType"); + + b.ToTable("statementline"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Transaction", b => + { + b.Property("TransactionReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("TransactionReportingId")); + + b.Property("AuthorisationCode") + .HasColumnType("nvarchar(max)"); + + b.Property("ContractProductReportingId") + .HasColumnType("int"); + + b.Property("ContractReportingId") + .HasColumnType("int"); + + b.Property("DeviceIdentifier") + .HasColumnType("nvarchar(max)"); + + b.Property("EstateOperatorReportingId") + .HasColumnType("int"); + + b.Property("IsAuthorised") + .HasColumnType("bit"); + + b.Property("IsCompleted") + .HasColumnType("bit"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("ResponseCode") + .HasColumnType("nvarchar(max)"); + + b.Property("ResponseMessage") + .HasColumnType("nvarchar(max)"); + + b.Property("TransactionAmount") + .HasColumnType("decimal(18,2)"); + + b.Property("TransactionDate") + .HasColumnType("date"); + + b.Property("TransactionDateTime") + .HasColumnType("datetime2"); + + b.Property("TransactionId") + .HasColumnType("uniqueidentifier"); + + b.Property("TransactionNumber") + .HasColumnType("nvarchar(max)"); + + b.Property("TransactionReference") + .HasColumnType("nvarchar(max)"); + + b.Property("TransactionSource") + .HasColumnType("int"); + + b.Property("TransactionTime") + .HasColumnType("time"); + + b.Property("TransactionType") + .HasColumnType("nvarchar(max)"); + + b.HasKey("TransactionReportingId"); + + SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("TransactionReportingId"), false); + + b.HasIndex("TransactionId") + .IsUnique(); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("TransactionId"), false); + + b.HasIndex("TransactionDate", "MerchantReportingId"); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("TransactionDate", "MerchantReportingId")); + + b.HasIndex("TransactionId", "MerchantReportingId") + .IsUnique(); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("TransactionId", "MerchantReportingId"), false); + + b.ToTable("transaction"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.TransactionAdditionalRequestData", b => + { + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.Property("Amount") + .HasColumnType("nvarchar(max)"); + + b.Property("CustomerAccountNumber") + .HasColumnType("nvarchar(max)"); + + b.HasKey("TransactionReportingId"); + + b.ToTable("transactionadditionalrequestdata"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.TransactionAdditionalResponseData", b => + { + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.HasKey("TransactionReportingId"); + + b.ToTable("transactionadditionalresponsedata"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Voucher", b => + { + b.Property("VoucherId") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("ExpiryDate") + .HasColumnType("date"); + + b.Property("ExpiryDateTime") + .HasColumnType("datetime2"); + + b.Property("GenerateDate") + .HasColumnType("date"); + + b.Property("GenerateDateTime") + .HasColumnType("datetime2"); + + b.Property("IsGenerated") + .HasColumnType("bit"); + + b.Property("IsIssued") + .HasColumnType("bit"); + + b.Property("IsRedeemed") + .HasColumnType("bit"); + + b.Property("IssuedDate") + .HasColumnType("date"); + + b.Property("IssuedDateTime") + .HasColumnType("datetime2"); + + b.Property("OperatorIdentifier") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("RecipientEmail") + .HasColumnType("nvarchar(max)"); + + b.Property("RecipientMobile") + .HasColumnType("nvarchar(max)"); + + b.Property("RedeemedDate") + .HasColumnType("datetime2"); + + b.Property("RedeemedDateTime") + .HasColumnType("datetime2"); + + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.Property("Value") + .HasColumnType("decimal(18,2)"); + + b.Property("VoucherCode") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.HasKey("VoucherId"); + + b.HasIndex("TransactionReportingId"); + + b.HasIndex("VoucherCode"); + + b.ToTable("voucher"); + }); + + modelBuilder.Entity("EstateManagement.Database.ViewEntities.SettlementView", b => + { + b.Property("Amount") + .HasColumnType("decimal(18,2)"); + + b.Property("CalculatedValue") + .HasColumnType("decimal(18,2)"); + + b.Property("DayOfWeek") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("FeeDescription") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsCompleted") + .HasColumnType("bit"); + + b.Property("IsSettled") + .HasColumnType("bit"); + + b.Property("MerchantId") + .HasColumnType("uniqueidentifier"); + + b.Property("MerchantName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Month") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("MonthNumber") + .HasColumnType("int"); + + b.Property("OperatorIdentifier") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("SettlementDate") + .HasColumnType("datetime2"); + + b.Property("SettlementId") + .HasColumnType("uniqueidentifier"); + + b.Property("TransactionId") + .HasColumnType("uniqueidentifier"); + + b.Property("WeekNumber") + .HasColumnType("int"); + + b.Property("YearNumber") + .HasColumnType("int"); + + b.ToTable((string)null); + + b.ToView("uvwSettlements", (string)null); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/TransactionProcessor.Database/Migrations/SqlServer/20231115193804_recordestateoperatorreportingidwithtxn.cs b/TransactionProcessor.Database/Migrations/SqlServer/20231115193804_recordestateoperatorreportingidwithtxn.cs new file mode 100644 index 00000000..25b8afac --- /dev/null +++ b/TransactionProcessor.Database/Migrations/SqlServer/20231115193804_recordestateoperatorreportingidwithtxn.cs @@ -0,0 +1,51 @@ +#nullable disable + +using Microsoft.EntityFrameworkCore.Migrations; + +namespace TransactionProcessor.Database.Migrations.SqlServer +{ + /// + public partial class recordestateoperatorreportingidwithtxn : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "OperatorIdentifier", + table: "transaction"); + + migrationBuilder.AddColumn( + name: "EstateOperatorReportingId", + table: "transaction", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "EstateOperatorReportingId", + table: "estateoperator", + type: "int", + nullable: false, + defaultValue: 0) + .Annotation("SqlServer:Identity", "1, 1"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "EstateOperatorReportingId", + table: "transaction"); + + migrationBuilder.DropColumn( + name: "EstateOperatorReportingId", + table: "estateoperator"); + + migrationBuilder.AddColumn( + name: "OperatorIdentifier", + table: "transaction", + type: "nvarchar(max)", + nullable: true); + } + } +} diff --git a/TransactionProcessor.Database/Migrations/SqlServer/20231228135707_addmerchantcontracttable.Designer.cs b/TransactionProcessor.Database/Migrations/SqlServer/20231228135707_addmerchantcontracttable.Designer.cs new file mode 100644 index 00000000..0e4db4e9 --- /dev/null +++ b/TransactionProcessor.Database/Migrations/SqlServer/20231228135707_addmerchantcontracttable.Designer.cs @@ -0,0 +1,1039 @@ +// + +#nullable disable + +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using TransactionProcessor.Database.Contexts; + +namespace TransactionProcessor.Database.Migrations.SqlServer +{ + [DbContext(typeof(EstateManagementSqlServerContext))] + [Migration("20231228135707_addmerchantcontracttable")] + partial class addmerchantcontracttable + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "7.0.7") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("EstateManagement.Database.Entities.Calendar", b => + { + b.Property("Date") + .HasColumnType("datetime2"); + + b.Property("DayOfWeek") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("DayOfWeekNumber") + .HasColumnType("int"); + + b.Property("DayOfWeekShort") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("MonthNameLong") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("MonthNameShort") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("MonthNumber") + .HasColumnType("int"); + + b.Property("WeekNumber") + .HasColumnType("int"); + + b.Property("WeekNumberString") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Year") + .HasColumnType("int"); + + b.Property("YearWeekNumber") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Date"); + + b.ToTable("calendar"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Contract", b => + { + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("OperatorId") + .HasColumnType("uniqueidentifier"); + + b.Property("ContractId") + .HasColumnType("uniqueidentifier"); + + b.Property("ContractReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("ContractReportingId")); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("EstateReportingId", "OperatorId", "ContractId"); + + b.ToTable("contract"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.ContractProduct", b => + { + b.Property("ContractReportingId") + .HasColumnType("int"); + + b.Property("ProductId") + .HasColumnType("uniqueidentifier"); + + b.Property("ContractProductReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("ContractProductReportingId")); + + b.Property("DisplayText") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ProductName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ProductType") + .HasColumnType("int"); + + b.Property("Value") + .HasColumnType("decimal(18,2)"); + + b.HasKey("ContractReportingId", "ProductId"); + + b.ToTable("contractproduct"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.ContractProductTransactionFee", b => + { + b.Property("ContractProductReportingId") + .HasColumnType("int"); + + b.Property("TransactionFeeId") + .HasColumnType("uniqueidentifier"); + + b.Property("CalculationType") + .HasColumnType("int"); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("FeeType") + .HasColumnType("int"); + + b.Property("IsEnabled") + .HasColumnType("bit"); + + b.Property("TransactionFeeReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("TransactionFeeReportingId")); + + b.Property("Value") + .HasColumnType("decimal(18,4)"); + + b.HasKey("ContractProductReportingId", "TransactionFeeId"); + + b.ToTable("contractproducttransactionfee"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Estate", b => + { + b.Property("EstateReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("EstateReportingId")); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Reference") + .HasColumnType("nvarchar(max)"); + + b.HasKey("EstateReportingId"); + + b.HasIndex("EstateId") + .IsUnique(); + + b.ToTable("estate"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.EstateOperator", b => + { + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("OperatorId") + .HasColumnType("uniqueidentifier"); + + b.Property("EstateOperatorReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("EstateOperatorReportingId")); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("RequireCustomMerchantNumber") + .HasColumnType("bit"); + + b.Property("RequireCustomTerminalNumber") + .HasColumnType("bit"); + + b.HasKey("EstateReportingId", "OperatorId"); + + b.ToTable("estateoperator"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.EstateSecurityUser", b => + { + b.Property("SecurityUserId") + .HasColumnType("uniqueidentifier"); + + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("EmailAddress") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("SecurityUserId", "EstateReportingId"); + + b.ToTable("estatesecurityuser"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.File", b => + { + b.Property("FileReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("FileReportingId")); + + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("FileId") + .HasColumnType("uniqueidentifier"); + + b.Property("FileImportLogReportingId") + .HasColumnType("int"); + + b.Property("FileLocation") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("FileProfileId") + .HasColumnType("uniqueidentifier"); + + b.Property("FileReceivedDate") + .HasColumnType("date"); + + b.Property("FileReceivedDateTime") + .HasColumnType("datetime2"); + + b.Property("IsCompleted") + .HasColumnType("bit"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("FileReportingId"); + + b.HasIndex("FileId") + .IsUnique(); + + b.ToTable("file"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.FileImportLog", b => + { + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("FileImportLogReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("FileImportLogReportingId")); + + b.Property("FileImportLogId") + .HasColumnType("uniqueidentifier"); + + b.Property("ImportLogDate") + .HasColumnType("date"); + + b.Property("ImportLogDateTime") + .HasColumnType("datetime2"); + + b.HasKey("EstateReportingId", "FileImportLogReportingId"); + + b.HasIndex("EstateReportingId", "FileImportLogId") + .IsUnique(); + + b.ToTable("fileimportlog"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.FileImportLogFile", b => + { + b.Property("FileImportLogReportingId") + .HasColumnType("int"); + + b.Property("FileReportingId") + .HasColumnType("int"); + + b.Property("FilePath") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("FileProfileId") + .HasColumnType("uniqueidentifier"); + + b.Property("FileUploadedDate") + .HasColumnType("date"); + + b.Property("FileUploadedDateTime") + .HasColumnType("datetime2"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("OriginalFileName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("FileImportLogReportingId", "FileReportingId"); + + b.ToTable("fileimportlogfile"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.FileLine", b => + { + b.Property("FileReportingId") + .HasColumnType("int"); + + b.Property("LineNumber") + .HasColumnType("int"); + + b.Property("FileLineData") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Status") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.HasKey("FileReportingId", "LineNumber"); + + SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("FileReportingId", "LineNumber")); + + b.HasIndex("TransactionReportingId"); + + b.ToTable("fileline"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Merchant", b => + { + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("MerchantReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("MerchantReportingId")); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("LastSaleDate") + .HasColumnType("date"); + + b.Property("LastSaleDateTime") + .HasColumnType("datetime2"); + + b.Property("LastStatementGenerated") + .HasColumnType("datetime2"); + + b.Property("MerchantId") + .HasColumnType("uniqueidentifier"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Reference") + .HasColumnType("nvarchar(max)"); + + b.Property("SettlementSchedule") + .HasColumnType("int"); + + b.HasKey("EstateReportingId", "MerchantReportingId"); + + b.HasIndex("EstateReportingId", "MerchantId") + .IsUnique(); + + b.ToTable("merchant"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantAddress", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("AddressId") + .HasColumnType("uniqueidentifier"); + + b.Property("AddressLine1") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("AddressLine2") + .HasColumnType("nvarchar(max)"); + + b.Property("AddressLine3") + .HasColumnType("nvarchar(max)"); + + b.Property("AddressLine4") + .HasColumnType("nvarchar(max)"); + + b.Property("Country") + .HasColumnType("nvarchar(max)"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("PostalCode") + .HasColumnType("nvarchar(max)"); + + b.Property("Region") + .HasColumnType("nvarchar(max)"); + + b.Property("Town") + .HasColumnType("nvarchar(max)"); + + b.HasKey("MerchantReportingId", "AddressId"); + + b.ToTable("merchantaddress"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantContact", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("ContactId") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("EmailAddress") + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("PhoneNumber") + .HasColumnType("nvarchar(max)"); + + b.HasKey("MerchantReportingId", "ContactId"); + + b.ToTable("merchantcontact"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantContract", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("ContractReportingId") + .HasColumnType("int"); + + b.HasKey("MerchantReportingId", "ContractReportingId"); + + b.ToTable("MerchantContracts"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantDevice", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("DeviceId") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("DeviceIdentifier") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("MerchantReportingId", "DeviceId"); + + b.ToTable("merchantdevice"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantOperator", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("OperatorId") + .HasColumnType("uniqueidentifier"); + + b.Property("MerchantNumber") + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("TerminalNumber") + .HasColumnType("nvarchar(max)"); + + b.HasKey("MerchantReportingId", "OperatorId"); + + b.ToTable("merchantoperator"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantSecurityUser", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("SecurityUserId") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("EmailAddress") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("MerchantReportingId", "SecurityUserId"); + + b.ToTable("merchantsecurityuser"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantSettlementFee", b => + { + b.Property("SettlementReportingId") + .HasColumnType("int"); + + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.Property("TransactionFeeReportingId") + .HasColumnType("int"); + + b.Property("CalculatedValue") + .HasColumnType("decimal(18,2)"); + + b.Property("FeeCalculatedDateTime") + .HasColumnType("datetime2"); + + b.Property("FeeValue") + .HasColumnType("decimal(18,2)"); + + b.Property("IsSettled") + .HasColumnType("bit"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.HasKey("SettlementReportingId", "TransactionReportingId", "TransactionFeeReportingId"); + + b.HasIndex("TransactionReportingId"); + + b.ToTable("merchantsettlementfee"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Reconciliation", b => + { + b.Property("TransactionReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("TransactionReportingId")); + + b.Property("DeviceIdentifier") + .HasColumnType("nvarchar(max)"); + + b.Property("IsAuthorised") + .HasColumnType("bit"); + + b.Property("IsCompleted") + .HasColumnType("bit"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("ResponseCode") + .HasColumnType("nvarchar(max)"); + + b.Property("ResponseMessage") + .HasColumnType("nvarchar(max)"); + + b.Property("TransactionCount") + .HasColumnType("int"); + + b.Property("TransactionDate") + .HasColumnType("date"); + + b.Property("TransactionDateTime") + .HasColumnType("datetime2"); + + b.Property("TransactionId") + .HasColumnType("uniqueidentifier"); + + b.Property("TransactionTime") + .HasColumnType("time"); + + b.Property("TransactionValue") + .HasColumnType("decimal(18,2)"); + + b.HasKey("TransactionReportingId"); + + SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("TransactionReportingId"), false); + + b.HasIndex("TransactionDate", "MerchantReportingId"); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("TransactionDate", "MerchantReportingId")); + + b.HasIndex("TransactionId", "MerchantReportingId") + .IsUnique(); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("TransactionId", "MerchantReportingId"), false); + + b.ToTable("reconciliation"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.ResponseCodes", b => + { + b.Property("ResponseCode") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("ResponseCode")); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("ResponseCode"); + + b.ToTable("responsecodes"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Settlement", b => + { + b.Property("SettlementReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("SettlementReportingId")); + + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("IsCompleted") + .HasColumnType("bit"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("ProcessingStarted") + .HasColumnType("bit"); + + b.Property("ProcessingStartedDateTIme") + .HasColumnType("datetime2"); + + b.Property("SettlementDate") + .HasColumnType("date"); + + b.Property("SettlementId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("SettlementReportingId"); + + SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("SettlementReportingId"), false); + + b.HasIndex("EstateReportingId", "SettlementId") + .IsUnique(); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("EstateReportingId", "SettlementId"), false); + + b.HasIndex("SettlementDate", "EstateReportingId"); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("SettlementDate", "EstateReportingId")); + + b.ToTable("settlement"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.StatementHeader", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("StatementId") + .HasColumnType("uniqueidentifier"); + + b.Property("StatementCreatedDate") + .HasColumnType("date"); + + b.Property("StatementCreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("StatementGeneratedDate") + .HasColumnType("date"); + + b.Property("StatementGeneratedDateTime") + .HasColumnType("datetime2"); + + b.Property("StatementReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("StatementReportingId")); + + b.HasKey("MerchantReportingId", "StatementId"); + + SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("MerchantReportingId", "StatementId"), false); + + b.HasIndex("MerchantReportingId", "StatementGeneratedDate") + .IsUnique(); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("MerchantReportingId", "StatementGeneratedDate")); + + b.ToTable("statementheader"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.StatementLine", b => + { + b.Property("StatementReportingId") + .HasColumnType("int"); + + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.Property("ActivityDateTime") + .HasColumnType("datetime2"); + + b.Property("ActivityType") + .HasColumnType("int"); + + b.Property("ActivityDate") + .HasColumnType("date"); + + b.Property("ActivityDescription") + .HasColumnType("nvarchar(max)"); + + b.Property("InAmount") + .HasColumnType("decimal(18,2)"); + + b.Property("OutAmount") + .HasColumnType("decimal(18,2)"); + + b.HasKey("StatementReportingId", "TransactionReportingId", "ActivityDateTime", "ActivityType"); + + b.ToTable("statementline"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Transaction", b => + { + b.Property("TransactionReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("TransactionReportingId")); + + b.Property("AuthorisationCode") + .HasColumnType("nvarchar(max)"); + + b.Property("ContractProductReportingId") + .HasColumnType("int"); + + b.Property("ContractReportingId") + .HasColumnType("int"); + + b.Property("DeviceIdentifier") + .HasColumnType("nvarchar(max)"); + + b.Property("EstateOperatorReportingId") + .HasColumnType("int"); + + b.Property("IsAuthorised") + .HasColumnType("bit"); + + b.Property("IsCompleted") + .HasColumnType("bit"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("ResponseCode") + .HasColumnType("nvarchar(max)"); + + b.Property("ResponseMessage") + .HasColumnType("nvarchar(max)"); + + b.Property("TransactionAmount") + .HasColumnType("decimal(18,2)"); + + b.Property("TransactionDate") + .HasColumnType("date"); + + b.Property("TransactionDateTime") + .HasColumnType("datetime2"); + + b.Property("TransactionId") + .HasColumnType("uniqueidentifier"); + + b.Property("TransactionNumber") + .HasColumnType("nvarchar(max)"); + + b.Property("TransactionReference") + .HasColumnType("nvarchar(max)"); + + b.Property("TransactionSource") + .HasColumnType("int"); + + b.Property("TransactionTime") + .HasColumnType("time"); + + b.Property("TransactionType") + .HasColumnType("nvarchar(max)"); + + b.HasKey("TransactionReportingId"); + + SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("TransactionReportingId"), false); + + b.HasIndex("TransactionId") + .IsUnique(); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("TransactionId"), false); + + b.HasIndex("TransactionDate", "MerchantReportingId"); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("TransactionDate", "MerchantReportingId")); + + b.HasIndex("TransactionId", "MerchantReportingId") + .IsUnique(); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("TransactionId", "MerchantReportingId"), false); + + b.ToTable("transaction"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.TransactionAdditionalRequestData", b => + { + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.Property("Amount") + .HasColumnType("nvarchar(max)"); + + b.Property("CustomerAccountNumber") + .HasColumnType("nvarchar(max)"); + + b.HasKey("TransactionReportingId"); + + b.ToTable("transactionadditionalrequestdata"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.TransactionAdditionalResponseData", b => + { + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.HasKey("TransactionReportingId"); + + b.ToTable("transactionadditionalresponsedata"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Voucher", b => + { + b.Property("VoucherId") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("ExpiryDate") + .HasColumnType("date"); + + b.Property("ExpiryDateTime") + .HasColumnType("datetime2"); + + b.Property("GenerateDate") + .HasColumnType("date"); + + b.Property("GenerateDateTime") + .HasColumnType("datetime2"); + + b.Property("IsGenerated") + .HasColumnType("bit"); + + b.Property("IsIssued") + .HasColumnType("bit"); + + b.Property("IsRedeemed") + .HasColumnType("bit"); + + b.Property("IssuedDate") + .HasColumnType("date"); + + b.Property("IssuedDateTime") + .HasColumnType("datetime2"); + + b.Property("OperatorIdentifier") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("RecipientEmail") + .HasColumnType("nvarchar(max)"); + + b.Property("RecipientMobile") + .HasColumnType("nvarchar(max)"); + + b.Property("RedeemedDate") + .HasColumnType("datetime2"); + + b.Property("RedeemedDateTime") + .HasColumnType("datetime2"); + + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.Property("Value") + .HasColumnType("decimal(18,2)"); + + b.Property("VoucherCode") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.HasKey("VoucherId"); + + b.HasIndex("TransactionReportingId"); + + b.HasIndex("VoucherCode"); + + b.ToTable("voucher"); + }); + + modelBuilder.Entity("EstateManagement.Database.ViewEntities.SettlementView", b => + { + b.Property("Amount") + .HasColumnType("decimal(18,2)"); + + b.Property("CalculatedValue") + .HasColumnType("decimal(18,2)"); + + b.Property("DayOfWeek") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("FeeDescription") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsCompleted") + .HasColumnType("bit"); + + b.Property("IsSettled") + .HasColumnType("bit"); + + b.Property("MerchantId") + .HasColumnType("uniqueidentifier"); + + b.Property("MerchantName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Month") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("MonthNumber") + .HasColumnType("int"); + + b.Property("OperatorIdentifier") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("SettlementDate") + .HasColumnType("datetime2"); + + b.Property("SettlementId") + .HasColumnType("uniqueidentifier"); + + b.Property("TransactionId") + .HasColumnType("uniqueidentifier"); + + b.Property("WeekNumber") + .HasColumnType("int"); + + b.Property("YearNumber") + .HasColumnType("int"); + + b.ToTable((string)null); + + b.ToView("uvwSettlements", (string)null); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/TransactionProcessor.Database/Migrations/SqlServer/20231228135707_addmerchantcontracttable.cs b/TransactionProcessor.Database/Migrations/SqlServer/20231228135707_addmerchantcontracttable.cs new file mode 100644 index 00000000..dc404e3a --- /dev/null +++ b/TransactionProcessor.Database/Migrations/SqlServer/20231228135707_addmerchantcontracttable.cs @@ -0,0 +1,33 @@ +#nullable disable + +using Microsoft.EntityFrameworkCore.Migrations; + +namespace TransactionProcessor.Database.Migrations.SqlServer +{ + /// + public partial class addmerchantcontracttable : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "MerchantContracts", + columns: table => new + { + MerchantReportingId = table.Column(type: "int", nullable: false), + ContractReportingId = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_MerchantContracts", x => new { x.MerchantReportingId, x.ContractReportingId }); + }); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "MerchantContracts"); + } + } +} diff --git a/TransactionProcessor.Database/Migrations/SqlServer/20240210074115_floattables.Designer.cs b/TransactionProcessor.Database/Migrations/SqlServer/20240210074115_floattables.Designer.cs new file mode 100644 index 00000000..c5dbf308 --- /dev/null +++ b/TransactionProcessor.Database/Migrations/SqlServer/20240210074115_floattables.Designer.cs @@ -0,0 +1,1107 @@ +// + +#nullable disable + +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using TransactionProcessor.Database.Contexts; + +namespace TransactionProcessor.Database.Migrations.SqlServer +{ + [DbContext(typeof(EstateManagementSqlServerContext))] + [Migration("20240210074115_floattables")] + partial class floattables + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "7.0.7") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("EstateManagement.Database.Entities.Calendar", b => + { + b.Property("Date") + .HasColumnType("datetime2"); + + b.Property("DayOfWeek") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("DayOfWeekNumber") + .HasColumnType("int"); + + b.Property("DayOfWeekShort") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("MonthNameLong") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("MonthNameShort") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("MonthNumber") + .HasColumnType("int"); + + b.Property("WeekNumber") + .HasColumnType("int"); + + b.Property("WeekNumberString") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Year") + .HasColumnType("int"); + + b.Property("YearWeekNumber") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Date"); + + b.ToTable("calendar"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Contract", b => + { + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("OperatorId") + .HasColumnType("uniqueidentifier"); + + b.Property("ContractId") + .HasColumnType("uniqueidentifier"); + + b.Property("ContractReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("ContractReportingId")); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("EstateReportingId", "OperatorId", "ContractId"); + + b.ToTable("contract"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.ContractProduct", b => + { + b.Property("ContractReportingId") + .HasColumnType("int"); + + b.Property("ProductId") + .HasColumnType("uniqueidentifier"); + + b.Property("ContractProductReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("ContractProductReportingId")); + + b.Property("DisplayText") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ProductName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ProductType") + .HasColumnType("int"); + + b.Property("Value") + .HasColumnType("decimal(18,2)"); + + b.HasKey("ContractReportingId", "ProductId"); + + b.ToTable("contractproduct"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.ContractProductTransactionFee", b => + { + b.Property("ContractProductReportingId") + .HasColumnType("int"); + + b.Property("TransactionFeeId") + .HasColumnType("uniqueidentifier"); + + b.Property("CalculationType") + .HasColumnType("int"); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("FeeType") + .HasColumnType("int"); + + b.Property("IsEnabled") + .HasColumnType("bit"); + + b.Property("TransactionFeeReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("TransactionFeeReportingId")); + + b.Property("Value") + .HasColumnType("decimal(18,4)"); + + b.HasKey("ContractProductReportingId", "TransactionFeeId"); + + b.ToTable("contractproducttransactionfee"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Estate", b => + { + b.Property("EstateReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("EstateReportingId")); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Reference") + .HasColumnType("nvarchar(max)"); + + b.HasKey("EstateReportingId"); + + b.HasIndex("EstateId") + .IsUnique(); + + b.ToTable("estate"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.EstateOperator", b => + { + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("OperatorId") + .HasColumnType("uniqueidentifier"); + + b.Property("EstateOperatorReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("EstateOperatorReportingId")); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("RequireCustomMerchantNumber") + .HasColumnType("bit"); + + b.Property("RequireCustomTerminalNumber") + .HasColumnType("bit"); + + b.HasKey("EstateReportingId", "OperatorId"); + + b.ToTable("estateoperator"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.EstateSecurityUser", b => + { + b.Property("SecurityUserId") + .HasColumnType("uniqueidentifier"); + + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("EmailAddress") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("SecurityUserId", "EstateReportingId"); + + b.ToTable("estatesecurityuser"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.File", b => + { + b.Property("FileReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("FileReportingId")); + + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("FileId") + .HasColumnType("uniqueidentifier"); + + b.Property("FileImportLogReportingId") + .HasColumnType("int"); + + b.Property("FileLocation") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("FileProfileId") + .HasColumnType("uniqueidentifier"); + + b.Property("FileReceivedDate") + .HasColumnType("date"); + + b.Property("FileReceivedDateTime") + .HasColumnType("datetime2"); + + b.Property("IsCompleted") + .HasColumnType("bit"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("FileReportingId"); + + b.HasIndex("FileId") + .IsUnique(); + + b.ToTable("file"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.FileImportLog", b => + { + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("FileImportLogReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("FileImportLogReportingId")); + + b.Property("FileImportLogId") + .HasColumnType("uniqueidentifier"); + + b.Property("ImportLogDate") + .HasColumnType("date"); + + b.Property("ImportLogDateTime") + .HasColumnType("datetime2"); + + b.HasKey("EstateReportingId", "FileImportLogReportingId"); + + b.HasIndex("EstateReportingId", "FileImportLogId") + .IsUnique(); + + b.ToTable("fileimportlog"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.FileImportLogFile", b => + { + b.Property("FileImportLogReportingId") + .HasColumnType("int"); + + b.Property("FileReportingId") + .HasColumnType("int"); + + b.Property("FilePath") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("FileProfileId") + .HasColumnType("uniqueidentifier"); + + b.Property("FileUploadedDate") + .HasColumnType("date"); + + b.Property("FileUploadedDateTime") + .HasColumnType("datetime2"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("OriginalFileName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("FileImportLogReportingId", "FileReportingId"); + + b.ToTable("fileimportlogfile"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.FileLine", b => + { + b.Property("FileReportingId") + .HasColumnType("int"); + + b.Property("LineNumber") + .HasColumnType("int"); + + b.Property("FileLineData") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Status") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.HasKey("FileReportingId", "LineNumber"); + + SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("FileReportingId", "LineNumber")); + + b.HasIndex("TransactionReportingId"); + + b.ToTable("fileline"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Float", b => + { + b.Property("FloatId") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("ContractId") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedDate") + .HasColumnType("date"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("ProductId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("FloatId"); + + SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("FloatId"), false); + + b.HasIndex("CreatedDate"); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("CreatedDate")); + + b.ToTable("Floats"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.FloatActivity", b => + { + b.Property("EventId") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("ActivityDate") + .HasColumnType("date"); + + b.Property("ActivityDateTime") + .HasColumnType("datetime2"); + + b.Property("Amount") + .HasColumnType("decimal(18,2)"); + + b.Property("CostPrice") + .HasColumnType("decimal(18,2)"); + + b.Property("CreditOrDebit") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("FloatId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("EventId"); + + SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("EventId"), false); + + b.HasIndex("ActivityDate"); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("ActivityDate")); + + b.ToTable("FloatActivity"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Merchant", b => + { + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("MerchantReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("MerchantReportingId")); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("LastSaleDate") + .HasColumnType("date"); + + b.Property("LastSaleDateTime") + .HasColumnType("datetime2"); + + b.Property("LastStatementGenerated") + .HasColumnType("datetime2"); + + b.Property("MerchantId") + .HasColumnType("uniqueidentifier"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Reference") + .HasColumnType("nvarchar(max)"); + + b.Property("SettlementSchedule") + .HasColumnType("int"); + + b.HasKey("EstateReportingId", "MerchantReportingId"); + + b.HasIndex("EstateReportingId", "MerchantId") + .IsUnique(); + + b.ToTable("merchant"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantAddress", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("AddressId") + .HasColumnType("uniqueidentifier"); + + b.Property("AddressLine1") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("AddressLine2") + .HasColumnType("nvarchar(max)"); + + b.Property("AddressLine3") + .HasColumnType("nvarchar(max)"); + + b.Property("AddressLine4") + .HasColumnType("nvarchar(max)"); + + b.Property("Country") + .HasColumnType("nvarchar(max)"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("PostalCode") + .HasColumnType("nvarchar(max)"); + + b.Property("Region") + .HasColumnType("nvarchar(max)"); + + b.Property("Town") + .HasColumnType("nvarchar(max)"); + + b.HasKey("MerchantReportingId", "AddressId"); + + b.ToTable("merchantaddress"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantContact", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("ContactId") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("EmailAddress") + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("PhoneNumber") + .HasColumnType("nvarchar(max)"); + + b.HasKey("MerchantReportingId", "ContactId"); + + b.ToTable("merchantcontact"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantContract", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("ContractReportingId") + .HasColumnType("int"); + + b.HasKey("MerchantReportingId", "ContractReportingId"); + + b.ToTable("MerchantContracts"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantDevice", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("DeviceId") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("DeviceIdentifier") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("MerchantReportingId", "DeviceId"); + + b.ToTable("merchantdevice"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantOperator", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("OperatorId") + .HasColumnType("uniqueidentifier"); + + b.Property("MerchantNumber") + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("TerminalNumber") + .HasColumnType("nvarchar(max)"); + + b.HasKey("MerchantReportingId", "OperatorId"); + + b.ToTable("merchantoperator"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantSecurityUser", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("SecurityUserId") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("EmailAddress") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("MerchantReportingId", "SecurityUserId"); + + b.ToTable("merchantsecurityuser"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantSettlementFee", b => + { + b.Property("SettlementReportingId") + .HasColumnType("int"); + + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.Property("TransactionFeeReportingId") + .HasColumnType("int"); + + b.Property("CalculatedValue") + .HasColumnType("decimal(18,2)"); + + b.Property("FeeCalculatedDateTime") + .HasColumnType("datetime2"); + + b.Property("FeeValue") + .HasColumnType("decimal(18,2)"); + + b.Property("IsSettled") + .HasColumnType("bit"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.HasKey("SettlementReportingId", "TransactionReportingId", "TransactionFeeReportingId"); + + b.HasIndex("TransactionReportingId"); + + b.ToTable("merchantsettlementfee"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Reconciliation", b => + { + b.Property("TransactionReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("TransactionReportingId")); + + b.Property("DeviceIdentifier") + .HasColumnType("nvarchar(max)"); + + b.Property("IsAuthorised") + .HasColumnType("bit"); + + b.Property("IsCompleted") + .HasColumnType("bit"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("ResponseCode") + .HasColumnType("nvarchar(max)"); + + b.Property("ResponseMessage") + .HasColumnType("nvarchar(max)"); + + b.Property("TransactionCount") + .HasColumnType("int"); + + b.Property("TransactionDate") + .HasColumnType("date"); + + b.Property("TransactionDateTime") + .HasColumnType("datetime2"); + + b.Property("TransactionId") + .HasColumnType("uniqueidentifier"); + + b.Property("TransactionTime") + .HasColumnType("time"); + + b.Property("TransactionValue") + .HasColumnType("decimal(18,2)"); + + b.HasKey("TransactionReportingId"); + + SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("TransactionReportingId"), false); + + b.HasIndex("TransactionDate", "MerchantReportingId"); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("TransactionDate", "MerchantReportingId")); + + b.HasIndex("TransactionId", "MerchantReportingId") + .IsUnique(); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("TransactionId", "MerchantReportingId"), false); + + b.ToTable("reconciliation"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.ResponseCodes", b => + { + b.Property("ResponseCode") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("ResponseCode")); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("ResponseCode"); + + b.ToTable("responsecodes"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Settlement", b => + { + b.Property("SettlementReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("SettlementReportingId")); + + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("IsCompleted") + .HasColumnType("bit"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("ProcessingStarted") + .HasColumnType("bit"); + + b.Property("ProcessingStartedDateTIme") + .HasColumnType("datetime2"); + + b.Property("SettlementDate") + .HasColumnType("date"); + + b.Property("SettlementId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("SettlementReportingId"); + + SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("SettlementReportingId"), false); + + b.HasIndex("EstateReportingId", "SettlementId") + .IsUnique(); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("EstateReportingId", "SettlementId"), false); + + b.HasIndex("SettlementDate", "EstateReportingId"); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("SettlementDate", "EstateReportingId")); + + b.ToTable("settlement"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.StatementHeader", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("StatementId") + .HasColumnType("uniqueidentifier"); + + b.Property("StatementCreatedDate") + .HasColumnType("date"); + + b.Property("StatementCreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("StatementGeneratedDate") + .HasColumnType("date"); + + b.Property("StatementGeneratedDateTime") + .HasColumnType("datetime2"); + + b.Property("StatementReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("StatementReportingId")); + + b.HasKey("MerchantReportingId", "StatementId"); + + SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("MerchantReportingId", "StatementId"), false); + + b.HasIndex("MerchantReportingId", "StatementGeneratedDate") + .IsUnique(); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("MerchantReportingId", "StatementGeneratedDate")); + + b.ToTable("statementheader"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.StatementLine", b => + { + b.Property("StatementReportingId") + .HasColumnType("int"); + + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.Property("ActivityDateTime") + .HasColumnType("datetime2"); + + b.Property("ActivityType") + .HasColumnType("int"); + + b.Property("ActivityDate") + .HasColumnType("date"); + + b.Property("ActivityDescription") + .HasColumnType("nvarchar(max)"); + + b.Property("InAmount") + .HasColumnType("decimal(18,2)"); + + b.Property("OutAmount") + .HasColumnType("decimal(18,2)"); + + b.HasKey("StatementReportingId", "TransactionReportingId", "ActivityDateTime", "ActivityType"); + + b.ToTable("statementline"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Transaction", b => + { + b.Property("TransactionReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("TransactionReportingId")); + + b.Property("AuthorisationCode") + .HasColumnType("nvarchar(max)"); + + b.Property("ContractProductReportingId") + .HasColumnType("int"); + + b.Property("ContractReportingId") + .HasColumnType("int"); + + b.Property("DeviceIdentifier") + .HasColumnType("nvarchar(max)"); + + b.Property("EstateOperatorReportingId") + .HasColumnType("int"); + + b.Property("IsAuthorised") + .HasColumnType("bit"); + + b.Property("IsCompleted") + .HasColumnType("bit"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("ResponseCode") + .HasColumnType("nvarchar(max)"); + + b.Property("ResponseMessage") + .HasColumnType("nvarchar(max)"); + + b.Property("TransactionAmount") + .HasColumnType("decimal(18,2)"); + + b.Property("TransactionDate") + .HasColumnType("date"); + + b.Property("TransactionDateTime") + .HasColumnType("datetime2"); + + b.Property("TransactionId") + .HasColumnType("uniqueidentifier"); + + b.Property("TransactionNumber") + .HasColumnType("nvarchar(max)"); + + b.Property("TransactionReference") + .HasColumnType("nvarchar(max)"); + + b.Property("TransactionSource") + .HasColumnType("int"); + + b.Property("TransactionTime") + .HasColumnType("time"); + + b.Property("TransactionType") + .HasColumnType("nvarchar(max)"); + + b.HasKey("TransactionReportingId"); + + SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("TransactionReportingId"), false); + + b.HasIndex("TransactionId") + .IsUnique(); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("TransactionId"), false); + + b.HasIndex("TransactionDate", "MerchantReportingId"); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("TransactionDate", "MerchantReportingId")); + + b.HasIndex("TransactionId", "MerchantReportingId") + .IsUnique(); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("TransactionId", "MerchantReportingId"), false); + + b.ToTable("transaction"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.TransactionAdditionalRequestData", b => + { + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.Property("Amount") + .HasColumnType("nvarchar(max)"); + + b.Property("CustomerAccountNumber") + .HasColumnType("nvarchar(max)"); + + b.HasKey("TransactionReportingId"); + + b.ToTable("transactionadditionalrequestdata"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.TransactionAdditionalResponseData", b => + { + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.HasKey("TransactionReportingId"); + + b.ToTable("transactionadditionalresponsedata"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Voucher", b => + { + b.Property("VoucherId") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("ExpiryDate") + .HasColumnType("date"); + + b.Property("ExpiryDateTime") + .HasColumnType("datetime2"); + + b.Property("GenerateDate") + .HasColumnType("date"); + + b.Property("GenerateDateTime") + .HasColumnType("datetime2"); + + b.Property("IsGenerated") + .HasColumnType("bit"); + + b.Property("IsIssued") + .HasColumnType("bit"); + + b.Property("IsRedeemed") + .HasColumnType("bit"); + + b.Property("IssuedDate") + .HasColumnType("date"); + + b.Property("IssuedDateTime") + .HasColumnType("datetime2"); + + b.Property("OperatorIdentifier") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("RecipientEmail") + .HasColumnType("nvarchar(max)"); + + b.Property("RecipientMobile") + .HasColumnType("nvarchar(max)"); + + b.Property("RedeemedDate") + .HasColumnType("datetime2"); + + b.Property("RedeemedDateTime") + .HasColumnType("datetime2"); + + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.Property("Value") + .HasColumnType("decimal(18,2)"); + + b.Property("VoucherCode") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.HasKey("VoucherId"); + + b.HasIndex("TransactionReportingId"); + + b.HasIndex("VoucherCode"); + + b.ToTable("voucher"); + }); + + modelBuilder.Entity("EstateManagement.Database.ViewEntities.SettlementView", b => + { + b.Property("Amount") + .HasColumnType("decimal(18,2)"); + + b.Property("CalculatedValue") + .HasColumnType("decimal(18,2)"); + + b.Property("DayOfWeek") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("FeeDescription") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsCompleted") + .HasColumnType("bit"); + + b.Property("IsSettled") + .HasColumnType("bit"); + + b.Property("MerchantId") + .HasColumnType("uniqueidentifier"); + + b.Property("MerchantName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Month") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("MonthNumber") + .HasColumnType("int"); + + b.Property("OperatorIdentifier") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("SettlementDate") + .HasColumnType("datetime2"); + + b.Property("SettlementId") + .HasColumnType("uniqueidentifier"); + + b.Property("TransactionId") + .HasColumnType("uniqueidentifier"); + + b.Property("WeekNumber") + .HasColumnType("int"); + + b.Property("YearNumber") + .HasColumnType("int"); + + b.ToTable((string)null); + + b.ToView("uvwSettlements", (string)null); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/TransactionProcessor.Database/Migrations/SqlServer/20240210074115_floattables.cs b/TransactionProcessor.Database/Migrations/SqlServer/20240210074115_floattables.cs new file mode 100644 index 00000000..94662f55 --- /dev/null +++ b/TransactionProcessor.Database/Migrations/SqlServer/20240210074115_floattables.cs @@ -0,0 +1,71 @@ +#nullable disable + +using Microsoft.EntityFrameworkCore.Migrations; + +namespace TransactionProcessor.Database.Migrations.SqlServer +{ + /// + public partial class floattables : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "FloatActivity", + columns: table => new + { + EventId = table.Column(type: "uniqueidentifier", nullable: false), + FloatId = table.Column(type: "uniqueidentifier", nullable: false), + ActivityDate = table.Column(type: "date", nullable: false), + ActivityDateTime = table.Column(type: "datetime2", nullable: false), + CreditOrDebit = table.Column(type: "nvarchar(max)", nullable: false), + Amount = table.Column(type: "decimal(18,2)", nullable: false), + CostPrice = table.Column(type: "decimal(18,2)", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_FloatActivity", x => x.EventId) + .Annotation("SqlServer:Clustered", false); + }); + + migrationBuilder.CreateTable( + name: "Floats", + columns: table => new + { + FloatId = table.Column(type: "uniqueidentifier", nullable: false), + EstateId = table.Column(type: "uniqueidentifier", nullable: false), + ContractId = table.Column(type: "uniqueidentifier", nullable: false), + ProductId = table.Column(type: "uniqueidentifier", nullable: false), + CreatedDateTime = table.Column(type: "datetime2", nullable: false), + CreatedDate = table.Column(type: "date", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Floats", x => x.FloatId) + .Annotation("SqlServer:Clustered", false); + }); + + migrationBuilder.CreateIndex( + name: "IX_FloatActivity_ActivityDate", + table: "FloatActivity", + column: "ActivityDate") + .Annotation("SqlServer:Clustered", true); + + migrationBuilder.CreateIndex( + name: "IX_Floats_CreatedDate", + table: "Floats", + column: "CreatedDate") + .Annotation("SqlServer:Clustered", true); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "FloatActivity"); + + migrationBuilder.DropTable( + name: "Floats"); + } + } +} diff --git a/TransactionProcessor.Database/Migrations/SqlServer/20240313170318_fixstatementheaderindex.Designer.cs b/TransactionProcessor.Database/Migrations/SqlServer/20240313170318_fixstatementheaderindex.Designer.cs new file mode 100644 index 00000000..1ec0a54e --- /dev/null +++ b/TransactionProcessor.Database/Migrations/SqlServer/20240313170318_fixstatementheaderindex.Designer.cs @@ -0,0 +1,1106 @@ +// + +#nullable disable + +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using TransactionProcessor.Database.Contexts; + +namespace TransactionProcessor.Database.Migrations.SqlServer +{ + [DbContext(typeof(EstateManagementSqlServerContext))] + [Migration("20240313170318_fixstatementheaderindex")] + partial class fixstatementheaderindex + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "7.0.7") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("EstateManagement.Database.Entities.Calendar", b => + { + b.Property("Date") + .HasColumnType("datetime2"); + + b.Property("DayOfWeek") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("DayOfWeekNumber") + .HasColumnType("int"); + + b.Property("DayOfWeekShort") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("MonthNameLong") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("MonthNameShort") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("MonthNumber") + .HasColumnType("int"); + + b.Property("WeekNumber") + .HasColumnType("int"); + + b.Property("WeekNumberString") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Year") + .HasColumnType("int"); + + b.Property("YearWeekNumber") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Date"); + + b.ToTable("calendar"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Contract", b => + { + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("OperatorId") + .HasColumnType("uniqueidentifier"); + + b.Property("ContractId") + .HasColumnType("uniqueidentifier"); + + b.Property("ContractReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("ContractReportingId")); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("EstateReportingId", "OperatorId", "ContractId"); + + b.ToTable("contract"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.ContractProduct", b => + { + b.Property("ContractReportingId") + .HasColumnType("int"); + + b.Property("ProductId") + .HasColumnType("uniqueidentifier"); + + b.Property("ContractProductReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("ContractProductReportingId")); + + b.Property("DisplayText") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ProductName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ProductType") + .HasColumnType("int"); + + b.Property("Value") + .HasColumnType("decimal(18,2)"); + + b.HasKey("ContractReportingId", "ProductId"); + + b.ToTable("contractproduct"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.ContractProductTransactionFee", b => + { + b.Property("ContractProductReportingId") + .HasColumnType("int"); + + b.Property("TransactionFeeId") + .HasColumnType("uniqueidentifier"); + + b.Property("CalculationType") + .HasColumnType("int"); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("FeeType") + .HasColumnType("int"); + + b.Property("IsEnabled") + .HasColumnType("bit"); + + b.Property("TransactionFeeReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("TransactionFeeReportingId")); + + b.Property("Value") + .HasColumnType("decimal(18,4)"); + + b.HasKey("ContractProductReportingId", "TransactionFeeId"); + + b.ToTable("contractproducttransactionfee"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Estate", b => + { + b.Property("EstateReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("EstateReportingId")); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Reference") + .HasColumnType("nvarchar(max)"); + + b.HasKey("EstateReportingId"); + + b.HasIndex("EstateId") + .IsUnique(); + + b.ToTable("estate"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.EstateOperator", b => + { + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("OperatorId") + .HasColumnType("uniqueidentifier"); + + b.Property("EstateOperatorReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("EstateOperatorReportingId")); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("RequireCustomMerchantNumber") + .HasColumnType("bit"); + + b.Property("RequireCustomTerminalNumber") + .HasColumnType("bit"); + + b.HasKey("EstateReportingId", "OperatorId"); + + b.ToTable("estateoperator"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.EstateSecurityUser", b => + { + b.Property("SecurityUserId") + .HasColumnType("uniqueidentifier"); + + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("EmailAddress") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("SecurityUserId", "EstateReportingId"); + + b.ToTable("estatesecurityuser"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.File", b => + { + b.Property("FileReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("FileReportingId")); + + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("FileId") + .HasColumnType("uniqueidentifier"); + + b.Property("FileImportLogReportingId") + .HasColumnType("int"); + + b.Property("FileLocation") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("FileProfileId") + .HasColumnType("uniqueidentifier"); + + b.Property("FileReceivedDate") + .HasColumnType("date"); + + b.Property("FileReceivedDateTime") + .HasColumnType("datetime2"); + + b.Property("IsCompleted") + .HasColumnType("bit"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("FileReportingId"); + + b.HasIndex("FileId") + .IsUnique(); + + b.ToTable("file"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.FileImportLog", b => + { + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("FileImportLogReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("FileImportLogReportingId")); + + b.Property("FileImportLogId") + .HasColumnType("uniqueidentifier"); + + b.Property("ImportLogDate") + .HasColumnType("date"); + + b.Property("ImportLogDateTime") + .HasColumnType("datetime2"); + + b.HasKey("EstateReportingId", "FileImportLogReportingId"); + + b.HasIndex("EstateReportingId", "FileImportLogId") + .IsUnique(); + + b.ToTable("fileimportlog"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.FileImportLogFile", b => + { + b.Property("FileImportLogReportingId") + .HasColumnType("int"); + + b.Property("FileReportingId") + .HasColumnType("int"); + + b.Property("FilePath") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("FileProfileId") + .HasColumnType("uniqueidentifier"); + + b.Property("FileUploadedDate") + .HasColumnType("date"); + + b.Property("FileUploadedDateTime") + .HasColumnType("datetime2"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("OriginalFileName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("FileImportLogReportingId", "FileReportingId"); + + b.ToTable("fileimportlogfile"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.FileLine", b => + { + b.Property("FileReportingId") + .HasColumnType("int"); + + b.Property("LineNumber") + .HasColumnType("int"); + + b.Property("FileLineData") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Status") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.HasKey("FileReportingId", "LineNumber"); + + SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("FileReportingId", "LineNumber")); + + b.HasIndex("TransactionReportingId"); + + b.ToTable("fileline"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Float", b => + { + b.Property("FloatId") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("ContractId") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedDate") + .HasColumnType("date"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("ProductId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("FloatId"); + + SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("FloatId"), false); + + b.HasIndex("CreatedDate"); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("CreatedDate")); + + b.ToTable("Floats"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.FloatActivity", b => + { + b.Property("EventId") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("ActivityDate") + .HasColumnType("date"); + + b.Property("ActivityDateTime") + .HasColumnType("datetime2"); + + b.Property("Amount") + .HasColumnType("decimal(18,2)"); + + b.Property("CostPrice") + .HasColumnType("decimal(18,2)"); + + b.Property("CreditOrDebit") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("FloatId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("EventId"); + + SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("EventId"), false); + + b.HasIndex("ActivityDate"); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("ActivityDate")); + + b.ToTable("FloatActivity"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Merchant", b => + { + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("MerchantReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("MerchantReportingId")); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("LastSaleDate") + .HasColumnType("date"); + + b.Property("LastSaleDateTime") + .HasColumnType("datetime2"); + + b.Property("LastStatementGenerated") + .HasColumnType("datetime2"); + + b.Property("MerchantId") + .HasColumnType("uniqueidentifier"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Reference") + .HasColumnType("nvarchar(max)"); + + b.Property("SettlementSchedule") + .HasColumnType("int"); + + b.HasKey("EstateReportingId", "MerchantReportingId"); + + b.HasIndex("EstateReportingId", "MerchantId") + .IsUnique(); + + b.ToTable("merchant"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantAddress", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("AddressId") + .HasColumnType("uniqueidentifier"); + + b.Property("AddressLine1") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("AddressLine2") + .HasColumnType("nvarchar(max)"); + + b.Property("AddressLine3") + .HasColumnType("nvarchar(max)"); + + b.Property("AddressLine4") + .HasColumnType("nvarchar(max)"); + + b.Property("Country") + .HasColumnType("nvarchar(max)"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("PostalCode") + .HasColumnType("nvarchar(max)"); + + b.Property("Region") + .HasColumnType("nvarchar(max)"); + + b.Property("Town") + .HasColumnType("nvarchar(max)"); + + b.HasKey("MerchantReportingId", "AddressId"); + + b.ToTable("merchantaddress"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantContact", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("ContactId") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("EmailAddress") + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("PhoneNumber") + .HasColumnType("nvarchar(max)"); + + b.HasKey("MerchantReportingId", "ContactId"); + + b.ToTable("merchantcontact"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantContract", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("ContractReportingId") + .HasColumnType("int"); + + b.HasKey("MerchantReportingId", "ContractReportingId"); + + b.ToTable("MerchantContracts"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantDevice", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("DeviceId") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("DeviceIdentifier") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("MerchantReportingId", "DeviceId"); + + b.ToTable("merchantdevice"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantOperator", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("OperatorId") + .HasColumnType("uniqueidentifier"); + + b.Property("MerchantNumber") + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("TerminalNumber") + .HasColumnType("nvarchar(max)"); + + b.HasKey("MerchantReportingId", "OperatorId"); + + b.ToTable("merchantoperator"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantSecurityUser", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("SecurityUserId") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("EmailAddress") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("MerchantReportingId", "SecurityUserId"); + + b.ToTable("merchantsecurityuser"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantSettlementFee", b => + { + b.Property("SettlementReportingId") + .HasColumnType("int"); + + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.Property("TransactionFeeReportingId") + .HasColumnType("int"); + + b.Property("CalculatedValue") + .HasColumnType("decimal(18,2)"); + + b.Property("FeeCalculatedDateTime") + .HasColumnType("datetime2"); + + b.Property("FeeValue") + .HasColumnType("decimal(18,2)"); + + b.Property("IsSettled") + .HasColumnType("bit"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.HasKey("SettlementReportingId", "TransactionReportingId", "TransactionFeeReportingId"); + + b.HasIndex("TransactionReportingId"); + + b.ToTable("merchantsettlementfee"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Reconciliation", b => + { + b.Property("TransactionReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("TransactionReportingId")); + + b.Property("DeviceIdentifier") + .HasColumnType("nvarchar(max)"); + + b.Property("IsAuthorised") + .HasColumnType("bit"); + + b.Property("IsCompleted") + .HasColumnType("bit"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("ResponseCode") + .HasColumnType("nvarchar(max)"); + + b.Property("ResponseMessage") + .HasColumnType("nvarchar(max)"); + + b.Property("TransactionCount") + .HasColumnType("int"); + + b.Property("TransactionDate") + .HasColumnType("date"); + + b.Property("TransactionDateTime") + .HasColumnType("datetime2"); + + b.Property("TransactionId") + .HasColumnType("uniqueidentifier"); + + b.Property("TransactionTime") + .HasColumnType("time"); + + b.Property("TransactionValue") + .HasColumnType("decimal(18,2)"); + + b.HasKey("TransactionReportingId"); + + SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("TransactionReportingId"), false); + + b.HasIndex("TransactionDate", "MerchantReportingId"); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("TransactionDate", "MerchantReportingId")); + + b.HasIndex("TransactionId", "MerchantReportingId") + .IsUnique(); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("TransactionId", "MerchantReportingId"), false); + + b.ToTable("reconciliation"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.ResponseCodes", b => + { + b.Property("ResponseCode") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("ResponseCode")); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("ResponseCode"); + + b.ToTable("responsecodes"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Settlement", b => + { + b.Property("SettlementReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("SettlementReportingId")); + + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("IsCompleted") + .HasColumnType("bit"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("ProcessingStarted") + .HasColumnType("bit"); + + b.Property("ProcessingStartedDateTIme") + .HasColumnType("datetime2"); + + b.Property("SettlementDate") + .HasColumnType("date"); + + b.Property("SettlementId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("SettlementReportingId"); + + SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("SettlementReportingId"), false); + + b.HasIndex("EstateReportingId", "SettlementId") + .IsUnique(); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("EstateReportingId", "SettlementId"), false); + + b.HasIndex("SettlementDate", "EstateReportingId"); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("SettlementDate", "EstateReportingId")); + + b.ToTable("settlement"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.StatementHeader", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("StatementId") + .HasColumnType("uniqueidentifier"); + + b.Property("StatementCreatedDate") + .HasColumnType("date"); + + b.Property("StatementCreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("StatementGeneratedDate") + .HasColumnType("date"); + + b.Property("StatementGeneratedDateTime") + .HasColumnType("datetime2"); + + b.Property("StatementReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("StatementReportingId")); + + b.HasKey("MerchantReportingId", "StatementId"); + + SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("MerchantReportingId", "StatementId"), false); + + b.HasIndex("MerchantReportingId", "StatementGeneratedDate"); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("MerchantReportingId", "StatementGeneratedDate")); + + b.ToTable("statementheader"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.StatementLine", b => + { + b.Property("StatementReportingId") + .HasColumnType("int"); + + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.Property("ActivityDateTime") + .HasColumnType("datetime2"); + + b.Property("ActivityType") + .HasColumnType("int"); + + b.Property("ActivityDate") + .HasColumnType("date"); + + b.Property("ActivityDescription") + .HasColumnType("nvarchar(max)"); + + b.Property("InAmount") + .HasColumnType("decimal(18,2)"); + + b.Property("OutAmount") + .HasColumnType("decimal(18,2)"); + + b.HasKey("StatementReportingId", "TransactionReportingId", "ActivityDateTime", "ActivityType"); + + b.ToTable("statementline"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Transaction", b => + { + b.Property("TransactionReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("TransactionReportingId")); + + b.Property("AuthorisationCode") + .HasColumnType("nvarchar(max)"); + + b.Property("ContractProductReportingId") + .HasColumnType("int"); + + b.Property("ContractReportingId") + .HasColumnType("int"); + + b.Property("DeviceIdentifier") + .HasColumnType("nvarchar(max)"); + + b.Property("EstateOperatorReportingId") + .HasColumnType("int"); + + b.Property("IsAuthorised") + .HasColumnType("bit"); + + b.Property("IsCompleted") + .HasColumnType("bit"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("ResponseCode") + .HasColumnType("nvarchar(max)"); + + b.Property("ResponseMessage") + .HasColumnType("nvarchar(max)"); + + b.Property("TransactionAmount") + .HasColumnType("decimal(18,2)"); + + b.Property("TransactionDate") + .HasColumnType("date"); + + b.Property("TransactionDateTime") + .HasColumnType("datetime2"); + + b.Property("TransactionId") + .HasColumnType("uniqueidentifier"); + + b.Property("TransactionNumber") + .HasColumnType("nvarchar(max)"); + + b.Property("TransactionReference") + .HasColumnType("nvarchar(max)"); + + b.Property("TransactionSource") + .HasColumnType("int"); + + b.Property("TransactionTime") + .HasColumnType("time"); + + b.Property("TransactionType") + .HasColumnType("nvarchar(max)"); + + b.HasKey("TransactionReportingId"); + + SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("TransactionReportingId"), false); + + b.HasIndex("TransactionId") + .IsUnique(); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("TransactionId"), false); + + b.HasIndex("TransactionDate", "MerchantReportingId"); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("TransactionDate", "MerchantReportingId")); + + b.HasIndex("TransactionId", "MerchantReportingId") + .IsUnique(); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("TransactionId", "MerchantReportingId"), false); + + b.ToTable("transaction"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.TransactionAdditionalRequestData", b => + { + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.Property("Amount") + .HasColumnType("nvarchar(max)"); + + b.Property("CustomerAccountNumber") + .HasColumnType("nvarchar(max)"); + + b.HasKey("TransactionReportingId"); + + b.ToTable("transactionadditionalrequestdata"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.TransactionAdditionalResponseData", b => + { + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.HasKey("TransactionReportingId"); + + b.ToTable("transactionadditionalresponsedata"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Voucher", b => + { + b.Property("VoucherId") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("ExpiryDate") + .HasColumnType("date"); + + b.Property("ExpiryDateTime") + .HasColumnType("datetime2"); + + b.Property("GenerateDate") + .HasColumnType("date"); + + b.Property("GenerateDateTime") + .HasColumnType("datetime2"); + + b.Property("IsGenerated") + .HasColumnType("bit"); + + b.Property("IsIssued") + .HasColumnType("bit"); + + b.Property("IsRedeemed") + .HasColumnType("bit"); + + b.Property("IssuedDate") + .HasColumnType("date"); + + b.Property("IssuedDateTime") + .HasColumnType("datetime2"); + + b.Property("OperatorIdentifier") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("RecipientEmail") + .HasColumnType("nvarchar(max)"); + + b.Property("RecipientMobile") + .HasColumnType("nvarchar(max)"); + + b.Property("RedeemedDate") + .HasColumnType("datetime2"); + + b.Property("RedeemedDateTime") + .HasColumnType("datetime2"); + + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.Property("Value") + .HasColumnType("decimal(18,2)"); + + b.Property("VoucherCode") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.HasKey("VoucherId"); + + b.HasIndex("TransactionReportingId"); + + b.HasIndex("VoucherCode"); + + b.ToTable("voucher"); + }); + + modelBuilder.Entity("EstateManagement.Database.ViewEntities.SettlementView", b => + { + b.Property("Amount") + .HasColumnType("decimal(18,2)"); + + b.Property("CalculatedValue") + .HasColumnType("decimal(18,2)"); + + b.Property("DayOfWeek") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("FeeDescription") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsCompleted") + .HasColumnType("bit"); + + b.Property("IsSettled") + .HasColumnType("bit"); + + b.Property("MerchantId") + .HasColumnType("uniqueidentifier"); + + b.Property("MerchantName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Month") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("MonthNumber") + .HasColumnType("int"); + + b.Property("OperatorIdentifier") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("SettlementDate") + .HasColumnType("datetime2"); + + b.Property("SettlementId") + .HasColumnType("uniqueidentifier"); + + b.Property("TransactionId") + .HasColumnType("uniqueidentifier"); + + b.Property("WeekNumber") + .HasColumnType("int"); + + b.Property("YearNumber") + .HasColumnType("int"); + + b.ToTable((string)null); + + b.ToView("uvwSettlements", (string)null); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/TransactionProcessor.Database/Migrations/SqlServer/20240313170318_fixstatementheaderindex.cs b/TransactionProcessor.Database/Migrations/SqlServer/20240313170318_fixstatementheaderindex.cs new file mode 100644 index 00000000..728b87ef --- /dev/null +++ b/TransactionProcessor.Database/Migrations/SqlServer/20240313170318_fixstatementheaderindex.cs @@ -0,0 +1,39 @@ +#nullable disable + +using Microsoft.EntityFrameworkCore.Migrations; + +namespace TransactionProcessor.Database.Migrations.SqlServer +{ + /// + public partial class fixstatementheaderindex : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropIndex( + name: "IX_statementheader_MerchantReportingId_StatementGeneratedDate", + table: "statementheader"); + + migrationBuilder.CreateIndex( + name: "IX_statementheader_MerchantReportingId_StatementGeneratedDate", + table: "statementheader", + columns: new[] { "MerchantReportingId", "StatementGeneratedDate" }) + .Annotation("SqlServer:Clustered", true); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropIndex( + name: "IX_statementheader_MerchantReportingId_StatementGeneratedDate", + table: "statementheader"); + + migrationBuilder.CreateIndex( + name: "IX_statementheader_MerchantReportingId_StatementGeneratedDate", + table: "statementheader", + columns: new[] { "MerchantReportingId", "StatementGeneratedDate" }, + unique: true) + .Annotation("SqlServer:Clustered", true); + } + } +} diff --git a/TransactionProcessor.Database/Migrations/SqlServer/20240420162900_merchantupdates.Designer.cs b/TransactionProcessor.Database/Migrations/SqlServer/20240420162900_merchantupdates.Designer.cs new file mode 100644 index 00000000..c6322cc2 --- /dev/null +++ b/TransactionProcessor.Database/Migrations/SqlServer/20240420162900_merchantupdates.Designer.cs @@ -0,0 +1,1112 @@ +// + +#nullable disable + +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using TransactionProcessor.Database.Contexts; + +namespace TransactionProcessor.Database.Migrations.SqlServer +{ + [DbContext(typeof(EstateManagementSqlServerContext))] + [Migration("20240420162900_merchantupdates")] + partial class merchantupdates + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.3") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("EstateManagement.Database.Entities.Calendar", b => + { + b.Property("Date") + .HasColumnType("datetime2"); + + b.Property("DayOfWeek") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("DayOfWeekNumber") + .HasColumnType("int"); + + b.Property("DayOfWeekShort") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("MonthNameLong") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("MonthNameShort") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("MonthNumber") + .HasColumnType("int"); + + b.Property("WeekNumber") + .HasColumnType("int"); + + b.Property("WeekNumberString") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Year") + .HasColumnType("int"); + + b.Property("YearWeekNumber") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Date"); + + b.ToTable("calendar"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Contract", b => + { + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("OperatorId") + .HasColumnType("uniqueidentifier"); + + b.Property("ContractId") + .HasColumnType("uniqueidentifier"); + + b.Property("ContractReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("ContractReportingId")); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("EstateReportingId", "OperatorId", "ContractId"); + + b.ToTable("contract"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.ContractProduct", b => + { + b.Property("ContractReportingId") + .HasColumnType("int"); + + b.Property("ProductId") + .HasColumnType("uniqueidentifier"); + + b.Property("ContractProductReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("ContractProductReportingId")); + + b.Property("DisplayText") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ProductName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ProductType") + .HasColumnType("int"); + + b.Property("Value") + .HasColumnType("decimal(18,2)"); + + b.HasKey("ContractReportingId", "ProductId"); + + b.ToTable("contractproduct"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.ContractProductTransactionFee", b => + { + b.Property("ContractProductReportingId") + .HasColumnType("int"); + + b.Property("TransactionFeeId") + .HasColumnType("uniqueidentifier"); + + b.Property("CalculationType") + .HasColumnType("int"); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("FeeType") + .HasColumnType("int"); + + b.Property("IsEnabled") + .HasColumnType("bit"); + + b.Property("TransactionFeeReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("TransactionFeeReportingId")); + + b.Property("Value") + .HasColumnType("decimal(18,4)"); + + b.HasKey("ContractProductReportingId", "TransactionFeeId"); + + b.ToTable("contractproducttransactionfee"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Estate", b => + { + b.Property("EstateReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("EstateReportingId")); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Reference") + .HasColumnType("nvarchar(max)"); + + b.HasKey("EstateReportingId"); + + b.HasIndex("EstateId") + .IsUnique(); + + b.ToTable("estate"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.EstateOperator", b => + { + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("OperatorId") + .HasColumnType("uniqueidentifier"); + + b.Property("EstateOperatorReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("EstateOperatorReportingId")); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("RequireCustomMerchantNumber") + .HasColumnType("bit"); + + b.Property("RequireCustomTerminalNumber") + .HasColumnType("bit"); + + b.HasKey("EstateReportingId", "OperatorId"); + + b.ToTable("estateoperator"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.EstateSecurityUser", b => + { + b.Property("SecurityUserId") + .HasColumnType("uniqueidentifier"); + + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("EmailAddress") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("SecurityUserId", "EstateReportingId"); + + b.ToTable("estatesecurityuser"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.File", b => + { + b.Property("FileReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("FileReportingId")); + + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("FileId") + .HasColumnType("uniqueidentifier"); + + b.Property("FileImportLogReportingId") + .HasColumnType("int"); + + b.Property("FileLocation") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("FileProfileId") + .HasColumnType("uniqueidentifier"); + + b.Property("FileReceivedDate") + .HasColumnType("date"); + + b.Property("FileReceivedDateTime") + .HasColumnType("datetime2"); + + b.Property("IsCompleted") + .HasColumnType("bit"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("FileReportingId"); + + b.HasIndex("FileId") + .IsUnique(); + + b.ToTable("file"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.FileImportLog", b => + { + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("FileImportLogReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("FileImportLogReportingId")); + + b.Property("FileImportLogId") + .HasColumnType("uniqueidentifier"); + + b.Property("ImportLogDate") + .HasColumnType("date"); + + b.Property("ImportLogDateTime") + .HasColumnType("datetime2"); + + b.HasKey("EstateReportingId", "FileImportLogReportingId"); + + b.HasIndex("EstateReportingId", "FileImportLogId") + .IsUnique(); + + b.ToTable("fileimportlog"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.FileImportLogFile", b => + { + b.Property("FileImportLogReportingId") + .HasColumnType("int"); + + b.Property("FileReportingId") + .HasColumnType("int"); + + b.Property("FilePath") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("FileProfileId") + .HasColumnType("uniqueidentifier"); + + b.Property("FileUploadedDate") + .HasColumnType("date"); + + b.Property("FileUploadedDateTime") + .HasColumnType("datetime2"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("OriginalFileName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("FileImportLogReportingId", "FileReportingId"); + + b.ToTable("fileimportlogfile"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.FileLine", b => + { + b.Property("FileReportingId") + .HasColumnType("int"); + + b.Property("LineNumber") + .HasColumnType("int"); + + b.Property("FileLineData") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Status") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.HasKey("FileReportingId", "LineNumber"); + + SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("FileReportingId", "LineNumber")); + + b.HasIndex("TransactionReportingId"); + + b.ToTable("fileline"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Float", b => + { + b.Property("FloatId") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("ContractId") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedDate") + .HasColumnType("date"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("ProductId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("FloatId"); + + SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("FloatId"), false); + + b.HasIndex("CreatedDate"); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("CreatedDate")); + + b.ToTable("Floats"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.FloatActivity", b => + { + b.Property("EventId") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("ActivityDate") + .HasColumnType("date"); + + b.Property("ActivityDateTime") + .HasColumnType("datetime2"); + + b.Property("Amount") + .HasColumnType("decimal(18,2)"); + + b.Property("CostPrice") + .HasColumnType("decimal(18,2)"); + + b.Property("CreditOrDebit") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("FloatId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("EventId"); + + SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("EventId"), false); + + b.HasIndex("ActivityDate"); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("ActivityDate")); + + b.ToTable("FloatActivity"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Merchant", b => + { + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("MerchantReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("MerchantReportingId")); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("LastSaleDate") + .HasColumnType("date"); + + b.Property("LastSaleDateTime") + .HasColumnType("datetime2"); + + b.Property("LastStatementGenerated") + .HasColumnType("datetime2"); + + b.Property("MerchantId") + .HasColumnType("uniqueidentifier"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Reference") + .HasColumnType("nvarchar(max)"); + + b.Property("SettlementSchedule") + .HasColumnType("int"); + + b.HasKey("EstateReportingId", "MerchantReportingId"); + + b.HasIndex("EstateReportingId", "MerchantId") + .IsUnique(); + + b.ToTable("merchant"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantAddress", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("AddressId") + .HasColumnType("uniqueidentifier"); + + b.Property("AddressLine1") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("AddressLine2") + .HasColumnType("nvarchar(max)"); + + b.Property("AddressLine3") + .HasColumnType("nvarchar(max)"); + + b.Property("AddressLine4") + .HasColumnType("nvarchar(max)"); + + b.Property("Country") + .HasColumnType("nvarchar(max)"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("PostalCode") + .HasColumnType("nvarchar(max)"); + + b.Property("Region") + .HasColumnType("nvarchar(max)"); + + b.Property("Town") + .HasColumnType("nvarchar(max)"); + + b.HasKey("MerchantReportingId", "AddressId"); + + b.ToTable("merchantaddress"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantContact", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("ContactId") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("EmailAddress") + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("PhoneNumber") + .HasColumnType("nvarchar(max)"); + + b.HasKey("MerchantReportingId", "ContactId"); + + b.ToTable("merchantcontact"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantContract", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("ContractReportingId") + .HasColumnType("int"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.HasKey("MerchantReportingId", "ContractReportingId"); + + b.ToTable("MerchantContracts"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantDevice", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("DeviceId") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("DeviceIdentifier") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("MerchantReportingId", "DeviceId"); + + b.ToTable("merchantdevice"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantOperator", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("OperatorId") + .HasColumnType("uniqueidentifier"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("MerchantNumber") + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("TerminalNumber") + .HasColumnType("nvarchar(max)"); + + b.HasKey("MerchantReportingId", "OperatorId"); + + b.ToTable("merchantoperator"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantSecurityUser", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("SecurityUserId") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("EmailAddress") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("MerchantReportingId", "SecurityUserId"); + + b.ToTable("merchantsecurityuser"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantSettlementFee", b => + { + b.Property("SettlementReportingId") + .HasColumnType("int"); + + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.Property("TransactionFeeReportingId") + .HasColumnType("int"); + + b.Property("CalculatedValue") + .HasColumnType("decimal(18,2)"); + + b.Property("FeeCalculatedDateTime") + .HasColumnType("datetime2"); + + b.Property("FeeValue") + .HasColumnType("decimal(18,2)"); + + b.Property("IsSettled") + .HasColumnType("bit"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.HasKey("SettlementReportingId", "TransactionReportingId", "TransactionFeeReportingId"); + + b.HasIndex("TransactionReportingId"); + + b.ToTable("merchantsettlementfee"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Reconciliation", b => + { + b.Property("TransactionReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("TransactionReportingId")); + + b.Property("DeviceIdentifier") + .HasColumnType("nvarchar(max)"); + + b.Property("IsAuthorised") + .HasColumnType("bit"); + + b.Property("IsCompleted") + .HasColumnType("bit"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("ResponseCode") + .HasColumnType("nvarchar(max)"); + + b.Property("ResponseMessage") + .HasColumnType("nvarchar(max)"); + + b.Property("TransactionCount") + .HasColumnType("int"); + + b.Property("TransactionDate") + .HasColumnType("date"); + + b.Property("TransactionDateTime") + .HasColumnType("datetime2"); + + b.Property("TransactionId") + .HasColumnType("uniqueidentifier"); + + b.Property("TransactionTime") + .HasColumnType("time"); + + b.Property("TransactionValue") + .HasColumnType("decimal(18,2)"); + + b.HasKey("TransactionReportingId"); + + SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("TransactionReportingId"), false); + + b.HasIndex("TransactionDate", "MerchantReportingId"); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("TransactionDate", "MerchantReportingId")); + + b.HasIndex("TransactionId", "MerchantReportingId") + .IsUnique(); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("TransactionId", "MerchantReportingId"), false); + + b.ToTable("reconciliation"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.ResponseCodes", b => + { + b.Property("ResponseCode") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("ResponseCode")); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("ResponseCode"); + + b.ToTable("responsecodes"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Settlement", b => + { + b.Property("SettlementReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("SettlementReportingId")); + + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("IsCompleted") + .HasColumnType("bit"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("ProcessingStarted") + .HasColumnType("bit"); + + b.Property("ProcessingStartedDateTIme") + .HasColumnType("datetime2"); + + b.Property("SettlementDate") + .HasColumnType("date"); + + b.Property("SettlementId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("SettlementReportingId"); + + SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("SettlementReportingId"), false); + + b.HasIndex("EstateReportingId", "SettlementId") + .IsUnique(); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("EstateReportingId", "SettlementId"), false); + + b.HasIndex("SettlementDate", "EstateReportingId"); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("SettlementDate", "EstateReportingId")); + + b.ToTable("settlement"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.StatementHeader", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("StatementId") + .HasColumnType("uniqueidentifier"); + + b.Property("StatementCreatedDate") + .HasColumnType("date"); + + b.Property("StatementCreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("StatementGeneratedDate") + .HasColumnType("date"); + + b.Property("StatementGeneratedDateTime") + .HasColumnType("datetime2"); + + b.Property("StatementReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("StatementReportingId")); + + b.HasKey("MerchantReportingId", "StatementId"); + + SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("MerchantReportingId", "StatementId"), false); + + b.HasIndex("MerchantReportingId", "StatementGeneratedDate"); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("MerchantReportingId", "StatementGeneratedDate")); + + b.ToTable("statementheader"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.StatementLine", b => + { + b.Property("StatementReportingId") + .HasColumnType("int"); + + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.Property("ActivityDateTime") + .HasColumnType("datetime2"); + + b.Property("ActivityType") + .HasColumnType("int"); + + b.Property("ActivityDate") + .HasColumnType("date"); + + b.Property("ActivityDescription") + .HasColumnType("nvarchar(max)"); + + b.Property("InAmount") + .HasColumnType("decimal(18,2)"); + + b.Property("OutAmount") + .HasColumnType("decimal(18,2)"); + + b.HasKey("StatementReportingId", "TransactionReportingId", "ActivityDateTime", "ActivityType"); + + b.ToTable("statementline"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Transaction", b => + { + b.Property("TransactionReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("TransactionReportingId")); + + b.Property("AuthorisationCode") + .HasColumnType("nvarchar(max)"); + + b.Property("ContractProductReportingId") + .HasColumnType("int"); + + b.Property("ContractReportingId") + .HasColumnType("int"); + + b.Property("DeviceIdentifier") + .HasColumnType("nvarchar(max)"); + + b.Property("EstateOperatorReportingId") + .HasColumnType("int"); + + b.Property("IsAuthorised") + .HasColumnType("bit"); + + b.Property("IsCompleted") + .HasColumnType("bit"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("ResponseCode") + .HasColumnType("nvarchar(max)"); + + b.Property("ResponseMessage") + .HasColumnType("nvarchar(max)"); + + b.Property("TransactionAmount") + .HasColumnType("decimal(18,2)"); + + b.Property("TransactionDate") + .HasColumnType("date"); + + b.Property("TransactionDateTime") + .HasColumnType("datetime2"); + + b.Property("TransactionId") + .HasColumnType("uniqueidentifier"); + + b.Property("TransactionNumber") + .HasColumnType("nvarchar(max)"); + + b.Property("TransactionReference") + .HasColumnType("nvarchar(max)"); + + b.Property("TransactionSource") + .HasColumnType("int"); + + b.Property("TransactionTime") + .HasColumnType("time"); + + b.Property("TransactionType") + .HasColumnType("nvarchar(max)"); + + b.HasKey("TransactionReportingId"); + + SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("TransactionReportingId"), false); + + b.HasIndex("TransactionId") + .IsUnique(); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("TransactionId"), false); + + b.HasIndex("TransactionDate", "MerchantReportingId"); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("TransactionDate", "MerchantReportingId")); + + b.HasIndex("TransactionId", "MerchantReportingId") + .IsUnique(); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("TransactionId", "MerchantReportingId"), false); + + b.ToTable("transaction"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.TransactionAdditionalRequestData", b => + { + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.Property("Amount") + .HasColumnType("nvarchar(max)"); + + b.Property("CustomerAccountNumber") + .HasColumnType("nvarchar(max)"); + + b.HasKey("TransactionReportingId"); + + b.ToTable("transactionadditionalrequestdata"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.TransactionAdditionalResponseData", b => + { + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.HasKey("TransactionReportingId"); + + b.ToTable("transactionadditionalresponsedata"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Voucher", b => + { + b.Property("VoucherId") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("ExpiryDate") + .HasColumnType("date"); + + b.Property("ExpiryDateTime") + .HasColumnType("datetime2"); + + b.Property("GenerateDate") + .HasColumnType("date"); + + b.Property("GenerateDateTime") + .HasColumnType("datetime2"); + + b.Property("IsGenerated") + .HasColumnType("bit"); + + b.Property("IsIssued") + .HasColumnType("bit"); + + b.Property("IsRedeemed") + .HasColumnType("bit"); + + b.Property("IssuedDate") + .HasColumnType("date"); + + b.Property("IssuedDateTime") + .HasColumnType("datetime2"); + + b.Property("OperatorIdentifier") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("RecipientEmail") + .HasColumnType("nvarchar(max)"); + + b.Property("RecipientMobile") + .HasColumnType("nvarchar(max)"); + + b.Property("RedeemedDate") + .HasColumnType("datetime2"); + + b.Property("RedeemedDateTime") + .HasColumnType("datetime2"); + + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.Property("Value") + .HasColumnType("decimal(18,2)"); + + b.Property("VoucherCode") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.HasKey("VoucherId"); + + b.HasIndex("TransactionReportingId"); + + b.HasIndex("VoucherCode"); + + b.ToTable("voucher"); + }); + + modelBuilder.Entity("EstateManagement.Database.ViewEntities.SettlementView", b => + { + b.Property("Amount") + .HasColumnType("decimal(18,2)"); + + b.Property("CalculatedValue") + .HasColumnType("decimal(18,2)"); + + b.Property("DayOfWeek") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("FeeDescription") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsCompleted") + .HasColumnType("bit"); + + b.Property("IsSettled") + .HasColumnType("bit"); + + b.Property("MerchantId") + .HasColumnType("uniqueidentifier"); + + b.Property("MerchantName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Month") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("MonthNumber") + .HasColumnType("int"); + + b.Property("OperatorIdentifier") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("SettlementDate") + .HasColumnType("datetime2"); + + b.Property("SettlementId") + .HasColumnType("uniqueidentifier"); + + b.Property("TransactionId") + .HasColumnType("uniqueidentifier"); + + b.Property("WeekNumber") + .HasColumnType("int"); + + b.Property("YearNumber") + .HasColumnType("int"); + + b.ToTable((string)null); + + b.ToView("uvwSettlements", (string)null); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/TransactionProcessor.Database/Migrations/SqlServer/20240420162900_merchantupdates.cs b/TransactionProcessor.Database/Migrations/SqlServer/20240420162900_merchantupdates.cs new file mode 100644 index 00000000..9ed83ea6 --- /dev/null +++ b/TransactionProcessor.Database/Migrations/SqlServer/20240420162900_merchantupdates.cs @@ -0,0 +1,40 @@ +#nullable disable + +using Microsoft.EntityFrameworkCore.Migrations; + +namespace TransactionProcessor.Database.Migrations.SqlServer +{ + /// + public partial class merchantupdates : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "IsDeleted", + table: "merchantoperator", + type: "bit", + nullable: false, + defaultValue: false); + + migrationBuilder.AddColumn( + name: "IsDeleted", + table: "MerchantContracts", + type: "bit", + nullable: false, + defaultValue: false); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "IsDeleted", + table: "merchantoperator"); + + migrationBuilder.DropColumn( + name: "IsDeleted", + table: "MerchantContracts"); + } + } +} diff --git a/TransactionProcessor.Database/Migrations/SqlServer/20240425094035_record_operatators_at_readmodel.Designer.cs b/TransactionProcessor.Database/Migrations/SqlServer/20240425094035_record_operatators_at_readmodel.Designer.cs new file mode 100644 index 00000000..7a42d3a3 --- /dev/null +++ b/TransactionProcessor.Database/Migrations/SqlServer/20240425094035_record_operatators_at_readmodel.Designer.cs @@ -0,0 +1,1129 @@ +// + +#nullable disable + +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using TransactionProcessor.Database.Contexts; + +namespace TransactionProcessor.Database.Migrations.SqlServer +{ + [DbContext(typeof(EstateManagementSqlServerContext))] + [Migration("20240425094035_record_operatators_at_readmodel")] + partial class record_operatators_at_readmodel + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.3") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("EstateManagement.Database.Entities.Calendar", b => + { + b.Property("Date") + .HasColumnType("datetime2"); + + b.Property("DayOfWeek") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("DayOfWeekNumber") + .HasColumnType("int"); + + b.Property("DayOfWeekShort") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("MonthNameLong") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("MonthNameShort") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("MonthNumber") + .HasColumnType("int"); + + b.Property("WeekNumber") + .HasColumnType("int"); + + b.Property("WeekNumberString") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Year") + .HasColumnType("int"); + + b.Property("YearWeekNumber") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Date"); + + b.ToTable("calendar"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Contract", b => + { + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("OperatorId") + .HasColumnType("uniqueidentifier"); + + b.Property("ContractId") + .HasColumnType("uniqueidentifier"); + + b.Property("ContractReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("ContractReportingId")); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("EstateReportingId", "OperatorId", "ContractId"); + + b.ToTable("contract"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.ContractProduct", b => + { + b.Property("ContractReportingId") + .HasColumnType("int"); + + b.Property("ProductId") + .HasColumnType("uniqueidentifier"); + + b.Property("ContractProductReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("ContractProductReportingId")); + + b.Property("DisplayText") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ProductName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ProductType") + .HasColumnType("int"); + + b.Property("Value") + .HasColumnType("decimal(18,2)"); + + b.HasKey("ContractReportingId", "ProductId"); + + b.ToTable("contractproduct"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.ContractProductTransactionFee", b => + { + b.Property("ContractProductReportingId") + .HasColumnType("int"); + + b.Property("TransactionFeeId") + .HasColumnType("uniqueidentifier"); + + b.Property("CalculationType") + .HasColumnType("int"); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("FeeType") + .HasColumnType("int"); + + b.Property("IsEnabled") + .HasColumnType("bit"); + + b.Property("TransactionFeeReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("TransactionFeeReportingId")); + + b.Property("Value") + .HasColumnType("decimal(18,4)"); + + b.HasKey("ContractProductReportingId", "TransactionFeeId"); + + b.ToTable("contractproducttransactionfee"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Estate", b => + { + b.Property("EstateReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("EstateReportingId")); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Reference") + .HasColumnType("nvarchar(max)"); + + b.HasKey("EstateReportingId"); + + b.HasIndex("EstateId") + .IsUnique(); + + b.ToTable("estate"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.EstateOperator", b => + { + b.Property("OperatorReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("OperatorReportingId")); + + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.HasKey("OperatorReportingId"); + + b.ToTable("estateoperator"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.EstateSecurityUser", b => + { + b.Property("SecurityUserId") + .HasColumnType("uniqueidentifier"); + + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("EmailAddress") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("SecurityUserId", "EstateReportingId"); + + b.ToTable("estatesecurityuser"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.File", b => + { + b.Property("FileReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("FileReportingId")); + + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("FileId") + .HasColumnType("uniqueidentifier"); + + b.Property("FileImportLogReportingId") + .HasColumnType("int"); + + b.Property("FileLocation") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("FileProfileId") + .HasColumnType("uniqueidentifier"); + + b.Property("FileReceivedDate") + .HasColumnType("date"); + + b.Property("FileReceivedDateTime") + .HasColumnType("datetime2"); + + b.Property("IsCompleted") + .HasColumnType("bit"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("FileReportingId"); + + b.HasIndex("FileId") + .IsUnique(); + + b.ToTable("file"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.FileImportLog", b => + { + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("FileImportLogReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("FileImportLogReportingId")); + + b.Property("FileImportLogId") + .HasColumnType("uniqueidentifier"); + + b.Property("ImportLogDate") + .HasColumnType("date"); + + b.Property("ImportLogDateTime") + .HasColumnType("datetime2"); + + b.HasKey("EstateReportingId", "FileImportLogReportingId"); + + b.HasIndex("EstateReportingId", "FileImportLogId") + .IsUnique(); + + b.ToTable("fileimportlog"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.FileImportLogFile", b => + { + b.Property("FileImportLogReportingId") + .HasColumnType("int"); + + b.Property("FileReportingId") + .HasColumnType("int"); + + b.Property("FilePath") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("FileProfileId") + .HasColumnType("uniqueidentifier"); + + b.Property("FileUploadedDate") + .HasColumnType("date"); + + b.Property("FileUploadedDateTime") + .HasColumnType("datetime2"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("OriginalFileName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("FileImportLogReportingId", "FileReportingId"); + + b.ToTable("fileimportlogfile"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.FileLine", b => + { + b.Property("FileReportingId") + .HasColumnType("int"); + + b.Property("LineNumber") + .HasColumnType("int"); + + b.Property("FileLineData") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Status") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.HasKey("FileReportingId", "LineNumber"); + + SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("FileReportingId", "LineNumber")); + + b.HasIndex("TransactionReportingId"); + + b.ToTable("fileline"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Float", b => + { + b.Property("FloatId") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("ContractId") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedDate") + .HasColumnType("date"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("ProductId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("FloatId"); + + SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("FloatId"), false); + + b.HasIndex("CreatedDate"); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("CreatedDate")); + + b.ToTable("Floats"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.FloatActivity", b => + { + b.Property("EventId") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("ActivityDate") + .HasColumnType("date"); + + b.Property("ActivityDateTime") + .HasColumnType("datetime2"); + + b.Property("Amount") + .HasColumnType("decimal(18,2)"); + + b.Property("CostPrice") + .HasColumnType("decimal(18,2)"); + + b.Property("CreditOrDebit") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("FloatId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("EventId"); + + SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("EventId"), false); + + b.HasIndex("ActivityDate"); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("ActivityDate")); + + b.ToTable("FloatActivity"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Merchant", b => + { + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("MerchantReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("MerchantReportingId")); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("LastSaleDate") + .HasColumnType("date"); + + b.Property("LastSaleDateTime") + .HasColumnType("datetime2"); + + b.Property("LastStatementGenerated") + .HasColumnType("datetime2"); + + b.Property("MerchantId") + .HasColumnType("uniqueidentifier"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Reference") + .HasColumnType("nvarchar(max)"); + + b.Property("SettlementSchedule") + .HasColumnType("int"); + + b.HasKey("EstateReportingId", "MerchantReportingId"); + + b.HasIndex("EstateReportingId", "MerchantId") + .IsUnique(); + + b.ToTable("merchant"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantAddress", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("AddressId") + .HasColumnType("uniqueidentifier"); + + b.Property("AddressLine1") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("AddressLine2") + .HasColumnType("nvarchar(max)"); + + b.Property("AddressLine3") + .HasColumnType("nvarchar(max)"); + + b.Property("AddressLine4") + .HasColumnType("nvarchar(max)"); + + b.Property("Country") + .HasColumnType("nvarchar(max)"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("PostalCode") + .HasColumnType("nvarchar(max)"); + + b.Property("Region") + .HasColumnType("nvarchar(max)"); + + b.Property("Town") + .HasColumnType("nvarchar(max)"); + + b.HasKey("MerchantReportingId", "AddressId"); + + b.ToTable("merchantaddress"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantContact", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("ContactId") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("EmailAddress") + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("PhoneNumber") + .HasColumnType("nvarchar(max)"); + + b.HasKey("MerchantReportingId", "ContactId"); + + b.ToTable("merchantcontact"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantContract", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("ContractReportingId") + .HasColumnType("int"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.HasKey("MerchantReportingId", "ContractReportingId"); + + b.ToTable("MerchantContracts"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantDevice", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("DeviceId") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("DeviceIdentifier") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("MerchantReportingId", "DeviceId"); + + b.ToTable("merchantdevice"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantOperator", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("OperatorId") + .HasColumnType("uniqueidentifier"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("MerchantNumber") + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("TerminalNumber") + .HasColumnType("nvarchar(max)"); + + b.HasKey("MerchantReportingId", "OperatorId"); + + b.ToTable("merchantoperator"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantSecurityUser", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("SecurityUserId") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("EmailAddress") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("MerchantReportingId", "SecurityUserId"); + + b.ToTable("merchantsecurityuser"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantSettlementFee", b => + { + b.Property("SettlementReportingId") + .HasColumnType("int"); + + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.Property("TransactionFeeReportingId") + .HasColumnType("int"); + + b.Property("CalculatedValue") + .HasColumnType("decimal(18,2)"); + + b.Property("FeeCalculatedDateTime") + .HasColumnType("datetime2"); + + b.Property("FeeValue") + .HasColumnType("decimal(18,2)"); + + b.Property("IsSettled") + .HasColumnType("bit"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.HasKey("SettlementReportingId", "TransactionReportingId", "TransactionFeeReportingId"); + + b.HasIndex("TransactionReportingId"); + + b.ToTable("merchantsettlementfee"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Operator", b => + { + b.Property("OperatorId") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("OperatorReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("OperatorReportingId")); + + b.Property("RequireCustomMerchantNumber") + .HasColumnType("bit"); + + b.Property("RequireCustomTerminalNumber") + .HasColumnType("bit"); + + b.HasKey("OperatorId"); + + b.ToTable("operator"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Reconciliation", b => + { + b.Property("TransactionReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("TransactionReportingId")); + + b.Property("DeviceIdentifier") + .HasColumnType("nvarchar(max)"); + + b.Property("IsAuthorised") + .HasColumnType("bit"); + + b.Property("IsCompleted") + .HasColumnType("bit"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("ResponseCode") + .HasColumnType("nvarchar(max)"); + + b.Property("ResponseMessage") + .HasColumnType("nvarchar(max)"); + + b.Property("TransactionCount") + .HasColumnType("int"); + + b.Property("TransactionDate") + .HasColumnType("date"); + + b.Property("TransactionDateTime") + .HasColumnType("datetime2"); + + b.Property("TransactionId") + .HasColumnType("uniqueidentifier"); + + b.Property("TransactionTime") + .HasColumnType("time"); + + b.Property("TransactionValue") + .HasColumnType("decimal(18,2)"); + + b.HasKey("TransactionReportingId"); + + SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("TransactionReportingId"), false); + + b.HasIndex("TransactionDate", "MerchantReportingId"); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("TransactionDate", "MerchantReportingId")); + + b.HasIndex("TransactionId", "MerchantReportingId") + .IsUnique(); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("TransactionId", "MerchantReportingId"), false); + + b.ToTable("reconciliation"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.ResponseCodes", b => + { + b.Property("ResponseCode") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("ResponseCode")); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("ResponseCode"); + + b.ToTable("responsecodes"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Settlement", b => + { + b.Property("SettlementReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("SettlementReportingId")); + + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("IsCompleted") + .HasColumnType("bit"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("ProcessingStarted") + .HasColumnType("bit"); + + b.Property("ProcessingStartedDateTIme") + .HasColumnType("datetime2"); + + b.Property("SettlementDate") + .HasColumnType("date"); + + b.Property("SettlementId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("SettlementReportingId"); + + SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("SettlementReportingId"), false); + + b.HasIndex("EstateReportingId", "SettlementId") + .IsUnique(); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("EstateReportingId", "SettlementId"), false); + + b.HasIndex("SettlementDate", "EstateReportingId"); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("SettlementDate", "EstateReportingId")); + + b.ToTable("settlement"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.StatementHeader", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("StatementId") + .HasColumnType("uniqueidentifier"); + + b.Property("StatementCreatedDate") + .HasColumnType("date"); + + b.Property("StatementCreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("StatementGeneratedDate") + .HasColumnType("date"); + + b.Property("StatementGeneratedDateTime") + .HasColumnType("datetime2"); + + b.Property("StatementReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("StatementReportingId")); + + b.HasKey("MerchantReportingId", "StatementId"); + + SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("MerchantReportingId", "StatementId"), false); + + b.HasIndex("MerchantReportingId", "StatementGeneratedDate"); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("MerchantReportingId", "StatementGeneratedDate")); + + b.ToTable("statementheader"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.StatementLine", b => + { + b.Property("StatementReportingId") + .HasColumnType("int"); + + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.Property("ActivityDateTime") + .HasColumnType("datetime2"); + + b.Property("ActivityType") + .HasColumnType("int"); + + b.Property("ActivityDate") + .HasColumnType("date"); + + b.Property("ActivityDescription") + .HasColumnType("nvarchar(max)"); + + b.Property("InAmount") + .HasColumnType("decimal(18,2)"); + + b.Property("OutAmount") + .HasColumnType("decimal(18,2)"); + + b.HasKey("StatementReportingId", "TransactionReportingId", "ActivityDateTime", "ActivityType"); + + b.ToTable("statementline"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Transaction", b => + { + b.Property("TransactionReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("TransactionReportingId")); + + b.Property("AuthorisationCode") + .HasColumnType("nvarchar(max)"); + + b.Property("ContractProductReportingId") + .HasColumnType("int"); + + b.Property("ContractReportingId") + .HasColumnType("int"); + + b.Property("DeviceIdentifier") + .HasColumnType("nvarchar(max)"); + + b.Property("EstateOperatorReportingId") + .HasColumnType("int"); + + b.Property("IsAuthorised") + .HasColumnType("bit"); + + b.Property("IsCompleted") + .HasColumnType("bit"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("ResponseCode") + .HasColumnType("nvarchar(max)"); + + b.Property("ResponseMessage") + .HasColumnType("nvarchar(max)"); + + b.Property("TransactionAmount") + .HasColumnType("decimal(18,2)"); + + b.Property("TransactionDate") + .HasColumnType("date"); + + b.Property("TransactionDateTime") + .HasColumnType("datetime2"); + + b.Property("TransactionId") + .HasColumnType("uniqueidentifier"); + + b.Property("TransactionNumber") + .HasColumnType("nvarchar(max)"); + + b.Property("TransactionReference") + .HasColumnType("nvarchar(max)"); + + b.Property("TransactionSource") + .HasColumnType("int"); + + b.Property("TransactionTime") + .HasColumnType("time"); + + b.Property("TransactionType") + .HasColumnType("nvarchar(max)"); + + b.HasKey("TransactionReportingId"); + + SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("TransactionReportingId"), false); + + b.HasIndex("TransactionId") + .IsUnique(); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("TransactionId"), false); + + b.HasIndex("TransactionDate", "MerchantReportingId"); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("TransactionDate", "MerchantReportingId")); + + b.HasIndex("TransactionId", "MerchantReportingId") + .IsUnique(); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("TransactionId", "MerchantReportingId"), false); + + b.ToTable("transaction"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.TransactionAdditionalRequestData", b => + { + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.Property("Amount") + .HasColumnType("nvarchar(max)"); + + b.Property("CustomerAccountNumber") + .HasColumnType("nvarchar(max)"); + + b.HasKey("TransactionReportingId"); + + b.ToTable("transactionadditionalrequestdata"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.TransactionAdditionalResponseData", b => + { + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.HasKey("TransactionReportingId"); + + b.ToTable("transactionadditionalresponsedata"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Voucher", b => + { + b.Property("VoucherId") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("ExpiryDate") + .HasColumnType("date"); + + b.Property("ExpiryDateTime") + .HasColumnType("datetime2"); + + b.Property("GenerateDate") + .HasColumnType("date"); + + b.Property("GenerateDateTime") + .HasColumnType("datetime2"); + + b.Property("IsGenerated") + .HasColumnType("bit"); + + b.Property("IsIssued") + .HasColumnType("bit"); + + b.Property("IsRedeemed") + .HasColumnType("bit"); + + b.Property("IssuedDate") + .HasColumnType("date"); + + b.Property("IssuedDateTime") + .HasColumnType("datetime2"); + + b.Property("OperatorIdentifier") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("RecipientEmail") + .HasColumnType("nvarchar(max)"); + + b.Property("RecipientMobile") + .HasColumnType("nvarchar(max)"); + + b.Property("RedeemedDate") + .HasColumnType("datetime2"); + + b.Property("RedeemedDateTime") + .HasColumnType("datetime2"); + + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.Property("Value") + .HasColumnType("decimal(18,2)"); + + b.Property("VoucherCode") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.HasKey("VoucherId"); + + b.HasIndex("TransactionReportingId"); + + b.HasIndex("VoucherCode"); + + b.ToTable("voucher"); + }); + + modelBuilder.Entity("EstateManagement.Database.ViewEntities.SettlementView", b => + { + b.Property("Amount") + .HasColumnType("decimal(18,2)"); + + b.Property("CalculatedValue") + .HasColumnType("decimal(18,2)"); + + b.Property("DayOfWeek") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("FeeDescription") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsCompleted") + .HasColumnType("bit"); + + b.Property("IsSettled") + .HasColumnType("bit"); + + b.Property("MerchantId") + .HasColumnType("uniqueidentifier"); + + b.Property("MerchantName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Month") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("MonthNumber") + .HasColumnType("int"); + + b.Property("OperatorIdentifier") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("SettlementDate") + .HasColumnType("datetime2"); + + b.Property("SettlementId") + .HasColumnType("uniqueidentifier"); + + b.Property("TransactionId") + .HasColumnType("uniqueidentifier"); + + b.Property("WeekNumber") + .HasColumnType("int"); + + b.Property("YearNumber") + .HasColumnType("int"); + + b.ToTable((string)null); + + b.ToView("uvwSettlements", (string)null); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/TransactionProcessor.Database/Migrations/SqlServer/20240425094035_record_operatators_at_readmodel.cs b/TransactionProcessor.Database/Migrations/SqlServer/20240425094035_record_operatators_at_readmodel.cs new file mode 100644 index 00000000..e8f0e378 --- /dev/null +++ b/TransactionProcessor.Database/Migrations/SqlServer/20240425094035_record_operatators_at_readmodel.cs @@ -0,0 +1,110 @@ +#nullable disable + +using Microsoft.EntityFrameworkCore.Migrations; + +namespace TransactionProcessor.Database.Migrations.SqlServer +{ + /// + public partial class record_operatators_at_readmodel : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropPrimaryKey( + name: "PK_estateoperator", + table: "estateoperator"); + + migrationBuilder.DropColumn( + name: "OperatorId", + table: "estateoperator"); + + migrationBuilder.DropColumn( + name: "Name", + table: "estateoperator"); + + migrationBuilder.DropColumn( + name: "RequireCustomMerchantNumber", + table: "estateoperator"); + + migrationBuilder.DropColumn( + name: "RequireCustomTerminalNumber", + table: "estateoperator"); + + migrationBuilder.RenameColumn( + name: "EstateOperatorReportingId", + table: "estateoperator", + newName: "OperatorReportingId"); + + migrationBuilder.AddPrimaryKey( + name: "PK_estateoperator", + table: "estateoperator", + column: "OperatorReportingId"); + + migrationBuilder.CreateTable( + name: "operator", + columns: table => new + { + OperatorId = table.Column(type: "uniqueidentifier", nullable: false), + OperatorReportingId = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + EstateReportingId = table.Column(type: "int", nullable: false), + Name = table.Column(type: "nvarchar(max)", nullable: false), + RequireCustomMerchantNumber = table.Column(type: "bit", nullable: false), + RequireCustomTerminalNumber = table.Column(type: "bit", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_operator", x => x.OperatorId); + }); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "operator"); + + migrationBuilder.DropPrimaryKey( + name: "PK_estateoperator", + table: "estateoperator"); + + migrationBuilder.RenameColumn( + name: "OperatorReportingId", + table: "estateoperator", + newName: "EstateOperatorReportingId"); + + migrationBuilder.AddColumn( + name: "OperatorId", + table: "estateoperator", + type: "uniqueidentifier", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); + + migrationBuilder.AddColumn( + name: "Name", + table: "estateoperator", + type: "nvarchar(max)", + nullable: false, + defaultValue: ""); + + migrationBuilder.AddColumn( + name: "RequireCustomMerchantNumber", + table: "estateoperator", + type: "bit", + nullable: false, + defaultValue: false); + + migrationBuilder.AddColumn( + name: "RequireCustomTerminalNumber", + table: "estateoperator", + type: "bit", + nullable: false, + defaultValue: false); + + migrationBuilder.AddPrimaryKey( + name: "PK_estateoperator", + table: "estateoperator", + columns: new[] { "EstateReportingId", "OperatorId" }); + } + } +} diff --git a/TransactionProcessor.Database/Migrations/SqlServer/20240425132448_record_operatators_at_readmodel_1.Designer.cs b/TransactionProcessor.Database/Migrations/SqlServer/20240425132448_record_operatators_at_readmodel_1.Designer.cs new file mode 100644 index 00000000..d95662cd --- /dev/null +++ b/TransactionProcessor.Database/Migrations/SqlServer/20240425132448_record_operatators_at_readmodel_1.Designer.cs @@ -0,0 +1,1131 @@ +// + +#nullable disable + +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using TransactionProcessor.Database.Contexts; + +namespace TransactionProcessor.Database.Migrations.SqlServer +{ + [DbContext(typeof(EstateManagementSqlServerContext))] + [Migration("20240425132448_record_operatators_at_readmodel_1")] + partial class record_operatators_at_readmodel_1 + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.3") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("EstateManagement.Database.Entities.Calendar", b => + { + b.Property("Date") + .HasColumnType("datetime2"); + + b.Property("DayOfWeek") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("DayOfWeekNumber") + .HasColumnType("int"); + + b.Property("DayOfWeekShort") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("MonthNameLong") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("MonthNameShort") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("MonthNumber") + .HasColumnType("int"); + + b.Property("WeekNumber") + .HasColumnType("int"); + + b.Property("WeekNumberString") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Year") + .HasColumnType("int"); + + b.Property("YearWeekNumber") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Date"); + + b.ToTable("calendar"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Contract", b => + { + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("OperatorId") + .HasColumnType("uniqueidentifier"); + + b.Property("ContractId") + .HasColumnType("uniqueidentifier"); + + b.Property("ContractReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("ContractReportingId")); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("EstateReportingId", "OperatorId", "ContractId"); + + b.ToTable("contract"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.ContractProduct", b => + { + b.Property("ContractReportingId") + .HasColumnType("int"); + + b.Property("ProductId") + .HasColumnType("uniqueidentifier"); + + b.Property("ContractProductReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("ContractProductReportingId")); + + b.Property("DisplayText") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ProductName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ProductType") + .HasColumnType("int"); + + b.Property("Value") + .HasColumnType("decimal(18,2)"); + + b.HasKey("ContractReportingId", "ProductId"); + + b.ToTable("contractproduct"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.ContractProductTransactionFee", b => + { + b.Property("ContractProductReportingId") + .HasColumnType("int"); + + b.Property("TransactionFeeId") + .HasColumnType("uniqueidentifier"); + + b.Property("CalculationType") + .HasColumnType("int"); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("FeeType") + .HasColumnType("int"); + + b.Property("IsEnabled") + .HasColumnType("bit"); + + b.Property("TransactionFeeReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("TransactionFeeReportingId")); + + b.Property("Value") + .HasColumnType("decimal(18,4)"); + + b.HasKey("ContractProductReportingId", "TransactionFeeId"); + + b.ToTable("contractproducttransactionfee"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Estate", b => + { + b.Property("EstateReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("EstateReportingId")); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Reference") + .HasColumnType("nvarchar(max)"); + + b.HasKey("EstateReportingId"); + + b.HasIndex("EstateId") + .IsUnique(); + + b.ToTable("estate"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.EstateOperator", b => + { + b.Property("OperatorReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("OperatorReportingId")); + + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.HasKey("OperatorReportingId"); + + b.ToTable("estateoperator"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.EstateSecurityUser", b => + { + b.Property("SecurityUserId") + .HasColumnType("uniqueidentifier"); + + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("EmailAddress") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("SecurityUserId", "EstateReportingId"); + + b.ToTable("estatesecurityuser"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.File", b => + { + b.Property("FileReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("FileReportingId")); + + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("FileId") + .HasColumnType("uniqueidentifier"); + + b.Property("FileImportLogReportingId") + .HasColumnType("int"); + + b.Property("FileLocation") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("FileProfileId") + .HasColumnType("uniqueidentifier"); + + b.Property("FileReceivedDate") + .HasColumnType("date"); + + b.Property("FileReceivedDateTime") + .HasColumnType("datetime2"); + + b.Property("IsCompleted") + .HasColumnType("bit"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("FileReportingId"); + + b.HasIndex("FileId") + .IsUnique(); + + b.ToTable("file"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.FileImportLog", b => + { + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("FileImportLogReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("FileImportLogReportingId")); + + b.Property("FileImportLogId") + .HasColumnType("uniqueidentifier"); + + b.Property("ImportLogDate") + .HasColumnType("date"); + + b.Property("ImportLogDateTime") + .HasColumnType("datetime2"); + + b.HasKey("EstateReportingId", "FileImportLogReportingId"); + + b.HasIndex("EstateReportingId", "FileImportLogId") + .IsUnique(); + + b.ToTable("fileimportlog"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.FileImportLogFile", b => + { + b.Property("FileImportLogReportingId") + .HasColumnType("int"); + + b.Property("FileReportingId") + .HasColumnType("int"); + + b.Property("FilePath") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("FileProfileId") + .HasColumnType("uniqueidentifier"); + + b.Property("FileUploadedDate") + .HasColumnType("date"); + + b.Property("FileUploadedDateTime") + .HasColumnType("datetime2"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("OriginalFileName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("FileImportLogReportingId", "FileReportingId"); + + b.ToTable("fileimportlogfile"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.FileLine", b => + { + b.Property("FileReportingId") + .HasColumnType("int"); + + b.Property("LineNumber") + .HasColumnType("int"); + + b.Property("FileLineData") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Status") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.HasKey("FileReportingId", "LineNumber"); + + SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("FileReportingId", "LineNumber")); + + b.HasIndex("TransactionReportingId"); + + b.ToTable("fileline"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Float", b => + { + b.Property("FloatId") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("ContractId") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedDate") + .HasColumnType("date"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("ProductId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("FloatId"); + + SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("FloatId"), false); + + b.HasIndex("CreatedDate"); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("CreatedDate")); + + b.ToTable("Floats"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.FloatActivity", b => + { + b.Property("EventId") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("ActivityDate") + .HasColumnType("date"); + + b.Property("ActivityDateTime") + .HasColumnType("datetime2"); + + b.Property("Amount") + .HasColumnType("decimal(18,2)"); + + b.Property("CostPrice") + .HasColumnType("decimal(18,2)"); + + b.Property("CreditOrDebit") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("FloatId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("EventId"); + + SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("EventId"), false); + + b.HasIndex("ActivityDate"); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("ActivityDate")); + + b.ToTable("FloatActivity"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Merchant", b => + { + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("MerchantReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("MerchantReportingId")); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("LastSaleDate") + .HasColumnType("date"); + + b.Property("LastSaleDateTime") + .HasColumnType("datetime2"); + + b.Property("LastStatementGenerated") + .HasColumnType("datetime2"); + + b.Property("MerchantId") + .HasColumnType("uniqueidentifier"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Reference") + .HasColumnType("nvarchar(max)"); + + b.Property("SettlementSchedule") + .HasColumnType("int"); + + b.HasKey("EstateReportingId", "MerchantReportingId"); + + b.HasIndex("EstateReportingId", "MerchantId") + .IsUnique(); + + b.ToTable("merchant"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantAddress", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("AddressId") + .HasColumnType("uniqueidentifier"); + + b.Property("AddressLine1") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("AddressLine2") + .HasColumnType("nvarchar(max)"); + + b.Property("AddressLine3") + .HasColumnType("nvarchar(max)"); + + b.Property("AddressLine4") + .HasColumnType("nvarchar(max)"); + + b.Property("Country") + .HasColumnType("nvarchar(max)"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("PostalCode") + .HasColumnType("nvarchar(max)"); + + b.Property("Region") + .HasColumnType("nvarchar(max)"); + + b.Property("Town") + .HasColumnType("nvarchar(max)"); + + b.HasKey("MerchantReportingId", "AddressId"); + + b.ToTable("merchantaddress"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantContact", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("ContactId") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("EmailAddress") + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("PhoneNumber") + .HasColumnType("nvarchar(max)"); + + b.HasKey("MerchantReportingId", "ContactId"); + + b.ToTable("merchantcontact"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantContract", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("ContractReportingId") + .HasColumnType("int"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.HasKey("MerchantReportingId", "ContractReportingId"); + + b.ToTable("MerchantContracts"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantDevice", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("DeviceId") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("DeviceIdentifier") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("MerchantReportingId", "DeviceId"); + + b.ToTable("merchantdevice"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantOperator", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("OperatorId") + .HasColumnType("uniqueidentifier"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("MerchantNumber") + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("TerminalNumber") + .HasColumnType("nvarchar(max)"); + + b.HasKey("MerchantReportingId", "OperatorId"); + + b.ToTable("merchantoperator"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantSecurityUser", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("SecurityUserId") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("EmailAddress") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("MerchantReportingId", "SecurityUserId"); + + b.ToTable("merchantsecurityuser"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantSettlementFee", b => + { + b.Property("SettlementReportingId") + .HasColumnType("int"); + + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.Property("TransactionFeeReportingId") + .HasColumnType("int"); + + b.Property("CalculatedValue") + .HasColumnType("decimal(18,2)"); + + b.Property("FeeCalculatedDateTime") + .HasColumnType("datetime2"); + + b.Property("FeeValue") + .HasColumnType("decimal(18,2)"); + + b.Property("IsSettled") + .HasColumnType("bit"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.HasKey("SettlementReportingId", "TransactionReportingId", "TransactionFeeReportingId"); + + b.HasIndex("TransactionReportingId"); + + b.ToTable("merchantsettlementfee"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Operator", b => + { + b.Property("OperatorReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("OperatorReportingId")); + + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("OperatorId") + .HasColumnType("uniqueidentifier"); + + b.Property("RequireCustomMerchantNumber") + .HasColumnType("bit"); + + b.Property("RequireCustomTerminalNumber") + .HasColumnType("bit"); + + b.HasKey("OperatorReportingId"); + + b.HasIndex("OperatorId") + .IsUnique(); + + b.ToTable("operator"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Reconciliation", b => + { + b.Property("TransactionReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("TransactionReportingId")); + + b.Property("DeviceIdentifier") + .HasColumnType("nvarchar(max)"); + + b.Property("IsAuthorised") + .HasColumnType("bit"); + + b.Property("IsCompleted") + .HasColumnType("bit"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("ResponseCode") + .HasColumnType("nvarchar(max)"); + + b.Property("ResponseMessage") + .HasColumnType("nvarchar(max)"); + + b.Property("TransactionCount") + .HasColumnType("int"); + + b.Property("TransactionDate") + .HasColumnType("date"); + + b.Property("TransactionDateTime") + .HasColumnType("datetime2"); + + b.Property("TransactionId") + .HasColumnType("uniqueidentifier"); + + b.Property("TransactionTime") + .HasColumnType("time"); + + b.Property("TransactionValue") + .HasColumnType("decimal(18,2)"); + + b.HasKey("TransactionReportingId"); + + SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("TransactionReportingId"), false); + + b.HasIndex("TransactionDate", "MerchantReportingId"); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("TransactionDate", "MerchantReportingId")); + + b.HasIndex("TransactionId", "MerchantReportingId") + .IsUnique(); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("TransactionId", "MerchantReportingId"), false); + + b.ToTable("reconciliation"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.ResponseCodes", b => + { + b.Property("ResponseCode") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("ResponseCode")); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("ResponseCode"); + + b.ToTable("responsecodes"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Settlement", b => + { + b.Property("SettlementReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("SettlementReportingId")); + + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("IsCompleted") + .HasColumnType("bit"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("ProcessingStarted") + .HasColumnType("bit"); + + b.Property("ProcessingStartedDateTIme") + .HasColumnType("datetime2"); + + b.Property("SettlementDate") + .HasColumnType("date"); + + b.Property("SettlementId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("SettlementReportingId"); + + SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("SettlementReportingId"), false); + + b.HasIndex("EstateReportingId", "SettlementId") + .IsUnique(); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("EstateReportingId", "SettlementId"), false); + + b.HasIndex("SettlementDate", "EstateReportingId"); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("SettlementDate", "EstateReportingId")); + + b.ToTable("settlement"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.StatementHeader", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("StatementId") + .HasColumnType("uniqueidentifier"); + + b.Property("StatementCreatedDate") + .HasColumnType("date"); + + b.Property("StatementCreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("StatementGeneratedDate") + .HasColumnType("date"); + + b.Property("StatementGeneratedDateTime") + .HasColumnType("datetime2"); + + b.Property("StatementReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("StatementReportingId")); + + b.HasKey("MerchantReportingId", "StatementId"); + + SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("MerchantReportingId", "StatementId"), false); + + b.HasIndex("MerchantReportingId", "StatementGeneratedDate"); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("MerchantReportingId", "StatementGeneratedDate")); + + b.ToTable("statementheader"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.StatementLine", b => + { + b.Property("StatementReportingId") + .HasColumnType("int"); + + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.Property("ActivityDateTime") + .HasColumnType("datetime2"); + + b.Property("ActivityType") + .HasColumnType("int"); + + b.Property("ActivityDate") + .HasColumnType("date"); + + b.Property("ActivityDescription") + .HasColumnType("nvarchar(max)"); + + b.Property("InAmount") + .HasColumnType("decimal(18,2)"); + + b.Property("OutAmount") + .HasColumnType("decimal(18,2)"); + + b.HasKey("StatementReportingId", "TransactionReportingId", "ActivityDateTime", "ActivityType"); + + b.ToTable("statementline"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Transaction", b => + { + b.Property("TransactionReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("TransactionReportingId")); + + b.Property("AuthorisationCode") + .HasColumnType("nvarchar(max)"); + + b.Property("ContractProductReportingId") + .HasColumnType("int"); + + b.Property("ContractReportingId") + .HasColumnType("int"); + + b.Property("DeviceIdentifier") + .HasColumnType("nvarchar(max)"); + + b.Property("EstateOperatorReportingId") + .HasColumnType("int"); + + b.Property("IsAuthorised") + .HasColumnType("bit"); + + b.Property("IsCompleted") + .HasColumnType("bit"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("ResponseCode") + .HasColumnType("nvarchar(max)"); + + b.Property("ResponseMessage") + .HasColumnType("nvarchar(max)"); + + b.Property("TransactionAmount") + .HasColumnType("decimal(18,2)"); + + b.Property("TransactionDate") + .HasColumnType("date"); + + b.Property("TransactionDateTime") + .HasColumnType("datetime2"); + + b.Property("TransactionId") + .HasColumnType("uniqueidentifier"); + + b.Property("TransactionNumber") + .HasColumnType("nvarchar(max)"); + + b.Property("TransactionReference") + .HasColumnType("nvarchar(max)"); + + b.Property("TransactionSource") + .HasColumnType("int"); + + b.Property("TransactionTime") + .HasColumnType("time"); + + b.Property("TransactionType") + .HasColumnType("nvarchar(max)"); + + b.HasKey("TransactionReportingId"); + + SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("TransactionReportingId"), false); + + b.HasIndex("TransactionId") + .IsUnique(); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("TransactionId"), false); + + b.HasIndex("TransactionDate", "MerchantReportingId"); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("TransactionDate", "MerchantReportingId")); + + b.HasIndex("TransactionId", "MerchantReportingId") + .IsUnique(); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("TransactionId", "MerchantReportingId"), false); + + b.ToTable("transaction"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.TransactionAdditionalRequestData", b => + { + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.Property("Amount") + .HasColumnType("nvarchar(max)"); + + b.Property("CustomerAccountNumber") + .HasColumnType("nvarchar(max)"); + + b.HasKey("TransactionReportingId"); + + b.ToTable("transactionadditionalrequestdata"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.TransactionAdditionalResponseData", b => + { + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.HasKey("TransactionReportingId"); + + b.ToTable("transactionadditionalresponsedata"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Voucher", b => + { + b.Property("VoucherId") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("ExpiryDate") + .HasColumnType("date"); + + b.Property("ExpiryDateTime") + .HasColumnType("datetime2"); + + b.Property("GenerateDate") + .HasColumnType("date"); + + b.Property("GenerateDateTime") + .HasColumnType("datetime2"); + + b.Property("IsGenerated") + .HasColumnType("bit"); + + b.Property("IsIssued") + .HasColumnType("bit"); + + b.Property("IsRedeemed") + .HasColumnType("bit"); + + b.Property("IssuedDate") + .HasColumnType("date"); + + b.Property("IssuedDateTime") + .HasColumnType("datetime2"); + + b.Property("OperatorIdentifier") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("RecipientEmail") + .HasColumnType("nvarchar(max)"); + + b.Property("RecipientMobile") + .HasColumnType("nvarchar(max)"); + + b.Property("RedeemedDate") + .HasColumnType("datetime2"); + + b.Property("RedeemedDateTime") + .HasColumnType("datetime2"); + + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.Property("Value") + .HasColumnType("decimal(18,2)"); + + b.Property("VoucherCode") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.HasKey("VoucherId"); + + b.HasIndex("TransactionReportingId"); + + b.HasIndex("VoucherCode"); + + b.ToTable("voucher"); + }); + + modelBuilder.Entity("EstateManagement.Database.ViewEntities.SettlementView", b => + { + b.Property("Amount") + .HasColumnType("decimal(18,2)"); + + b.Property("CalculatedValue") + .HasColumnType("decimal(18,2)"); + + b.Property("DayOfWeek") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("FeeDescription") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsCompleted") + .HasColumnType("bit"); + + b.Property("IsSettled") + .HasColumnType("bit"); + + b.Property("MerchantId") + .HasColumnType("uniqueidentifier"); + + b.Property("MerchantName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Month") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("MonthNumber") + .HasColumnType("int"); + + b.Property("OperatorIdentifier") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("SettlementDate") + .HasColumnType("datetime2"); + + b.Property("SettlementId") + .HasColumnType("uniqueidentifier"); + + b.Property("TransactionId") + .HasColumnType("uniqueidentifier"); + + b.Property("WeekNumber") + .HasColumnType("int"); + + b.Property("YearNumber") + .HasColumnType("int"); + + b.ToTable((string)null); + + b.ToView("uvwSettlements", (string)null); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/TransactionProcessor.Database/Migrations/SqlServer/20240425132448_record_operatators_at_readmodel_1.cs b/TransactionProcessor.Database/Migrations/SqlServer/20240425132448_record_operatators_at_readmodel_1.cs new file mode 100644 index 00000000..bb28d0a7 --- /dev/null +++ b/TransactionProcessor.Database/Migrations/SqlServer/20240425132448_record_operatators_at_readmodel_1.cs @@ -0,0 +1,46 @@ +#nullable disable + +using Microsoft.EntityFrameworkCore.Migrations; + +namespace TransactionProcessor.Database.Migrations.SqlServer +{ + /// + public partial class record_operatators_at_readmodel_1 : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropPrimaryKey( + name: "PK_operator", + table: "operator"); + + migrationBuilder.AddPrimaryKey( + name: "PK_operator", + table: "operator", + column: "OperatorReportingId"); + + migrationBuilder.CreateIndex( + name: "IX_operator_OperatorId", + table: "operator", + column: "OperatorId", + unique: true); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropPrimaryKey( + name: "PK_operator", + table: "operator"); + + migrationBuilder.DropIndex( + name: "IX_operator_OperatorId", + table: "operator"); + + migrationBuilder.AddPrimaryKey( + name: "PK_operator", + table: "operator", + column: "OperatorId"); + } + } +} diff --git a/TransactionProcessor.Database/Migrations/SqlServer/20240425163935_record_operatators_at_readmodel_2.Designer.cs b/TransactionProcessor.Database/Migrations/SqlServer/20240425163935_record_operatators_at_readmodel_2.Designer.cs new file mode 100644 index 00000000..379f69fa --- /dev/null +++ b/TransactionProcessor.Database/Migrations/SqlServer/20240425163935_record_operatators_at_readmodel_2.Designer.cs @@ -0,0 +1,1128 @@ +// + +#nullable disable + +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using TransactionProcessor.Database.Contexts; + +namespace TransactionProcessor.Database.Migrations.SqlServer +{ + [DbContext(typeof(EstateManagementSqlServerContext))] + [Migration("20240425163935_record_operatators_at_readmodel_2")] + partial class record_operatators_at_readmodel_2 + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.3") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("EstateManagement.Database.Entities.Calendar", b => + { + b.Property("Date") + .HasColumnType("datetime2"); + + b.Property("DayOfWeek") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("DayOfWeekNumber") + .HasColumnType("int"); + + b.Property("DayOfWeekShort") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("MonthNameLong") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("MonthNameShort") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("MonthNumber") + .HasColumnType("int"); + + b.Property("WeekNumber") + .HasColumnType("int"); + + b.Property("WeekNumberString") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Year") + .HasColumnType("int"); + + b.Property("YearWeekNumber") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Date"); + + b.ToTable("calendar"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Contract", b => + { + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("OperatorId") + .HasColumnType("uniqueidentifier"); + + b.Property("ContractId") + .HasColumnType("uniqueidentifier"); + + b.Property("ContractReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("ContractReportingId")); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("EstateReportingId", "OperatorId", "ContractId"); + + b.ToTable("contract"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.ContractProduct", b => + { + b.Property("ContractReportingId") + .HasColumnType("int"); + + b.Property("ProductId") + .HasColumnType("uniqueidentifier"); + + b.Property("ContractProductReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("ContractProductReportingId")); + + b.Property("DisplayText") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ProductName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ProductType") + .HasColumnType("int"); + + b.Property("Value") + .HasColumnType("decimal(18,2)"); + + b.HasKey("ContractReportingId", "ProductId"); + + b.ToTable("contractproduct"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.ContractProductTransactionFee", b => + { + b.Property("ContractProductReportingId") + .HasColumnType("int"); + + b.Property("TransactionFeeId") + .HasColumnType("uniqueidentifier"); + + b.Property("CalculationType") + .HasColumnType("int"); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("FeeType") + .HasColumnType("int"); + + b.Property("IsEnabled") + .HasColumnType("bit"); + + b.Property("TransactionFeeReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("TransactionFeeReportingId")); + + b.Property("Value") + .HasColumnType("decimal(18,4)"); + + b.HasKey("ContractProductReportingId", "TransactionFeeId"); + + b.ToTable("contractproducttransactionfee"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Estate", b => + { + b.Property("EstateReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("EstateReportingId")); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Reference") + .HasColumnType("nvarchar(max)"); + + b.HasKey("EstateReportingId"); + + b.HasIndex("EstateId") + .IsUnique(); + + b.ToTable("estate"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.EstateOperator", b => + { + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("OperatorReportingId") + .HasColumnType("int"); + + b.HasKey("EstateReportingId", "OperatorReportingId"); + + b.ToTable("estateoperator"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.EstateSecurityUser", b => + { + b.Property("SecurityUserId") + .HasColumnType("uniqueidentifier"); + + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("EmailAddress") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("SecurityUserId", "EstateReportingId"); + + b.ToTable("estatesecurityuser"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.File", b => + { + b.Property("FileReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("FileReportingId")); + + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("FileId") + .HasColumnType("uniqueidentifier"); + + b.Property("FileImportLogReportingId") + .HasColumnType("int"); + + b.Property("FileLocation") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("FileProfileId") + .HasColumnType("uniqueidentifier"); + + b.Property("FileReceivedDate") + .HasColumnType("date"); + + b.Property("FileReceivedDateTime") + .HasColumnType("datetime2"); + + b.Property("IsCompleted") + .HasColumnType("bit"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("FileReportingId"); + + b.HasIndex("FileId") + .IsUnique(); + + b.ToTable("file"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.FileImportLog", b => + { + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("FileImportLogReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("FileImportLogReportingId")); + + b.Property("FileImportLogId") + .HasColumnType("uniqueidentifier"); + + b.Property("ImportLogDate") + .HasColumnType("date"); + + b.Property("ImportLogDateTime") + .HasColumnType("datetime2"); + + b.HasKey("EstateReportingId", "FileImportLogReportingId"); + + b.HasIndex("EstateReportingId", "FileImportLogId") + .IsUnique(); + + b.ToTable("fileimportlog"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.FileImportLogFile", b => + { + b.Property("FileImportLogReportingId") + .HasColumnType("int"); + + b.Property("FileReportingId") + .HasColumnType("int"); + + b.Property("FilePath") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("FileProfileId") + .HasColumnType("uniqueidentifier"); + + b.Property("FileUploadedDate") + .HasColumnType("date"); + + b.Property("FileUploadedDateTime") + .HasColumnType("datetime2"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("OriginalFileName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("FileImportLogReportingId", "FileReportingId"); + + b.ToTable("fileimportlogfile"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.FileLine", b => + { + b.Property("FileReportingId") + .HasColumnType("int"); + + b.Property("LineNumber") + .HasColumnType("int"); + + b.Property("FileLineData") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Status") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.HasKey("FileReportingId", "LineNumber"); + + SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("FileReportingId", "LineNumber")); + + b.HasIndex("TransactionReportingId"); + + b.ToTable("fileline"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Float", b => + { + b.Property("FloatId") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("ContractId") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedDate") + .HasColumnType("date"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("ProductId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("FloatId"); + + SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("FloatId"), false); + + b.HasIndex("CreatedDate"); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("CreatedDate")); + + b.ToTable("Floats"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.FloatActivity", b => + { + b.Property("EventId") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("ActivityDate") + .HasColumnType("date"); + + b.Property("ActivityDateTime") + .HasColumnType("datetime2"); + + b.Property("Amount") + .HasColumnType("decimal(18,2)"); + + b.Property("CostPrice") + .HasColumnType("decimal(18,2)"); + + b.Property("CreditOrDebit") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("FloatId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("EventId"); + + SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("EventId"), false); + + b.HasIndex("ActivityDate"); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("ActivityDate")); + + b.ToTable("FloatActivity"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Merchant", b => + { + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("MerchantReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("MerchantReportingId")); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("LastSaleDate") + .HasColumnType("date"); + + b.Property("LastSaleDateTime") + .HasColumnType("datetime2"); + + b.Property("LastStatementGenerated") + .HasColumnType("datetime2"); + + b.Property("MerchantId") + .HasColumnType("uniqueidentifier"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Reference") + .HasColumnType("nvarchar(max)"); + + b.Property("SettlementSchedule") + .HasColumnType("int"); + + b.HasKey("EstateReportingId", "MerchantReportingId"); + + b.HasIndex("EstateReportingId", "MerchantId") + .IsUnique(); + + b.ToTable("merchant"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantAddress", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("AddressId") + .HasColumnType("uniqueidentifier"); + + b.Property("AddressLine1") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("AddressLine2") + .HasColumnType("nvarchar(max)"); + + b.Property("AddressLine3") + .HasColumnType("nvarchar(max)"); + + b.Property("AddressLine4") + .HasColumnType("nvarchar(max)"); + + b.Property("Country") + .HasColumnType("nvarchar(max)"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("PostalCode") + .HasColumnType("nvarchar(max)"); + + b.Property("Region") + .HasColumnType("nvarchar(max)"); + + b.Property("Town") + .HasColumnType("nvarchar(max)"); + + b.HasKey("MerchantReportingId", "AddressId"); + + b.ToTable("merchantaddress"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantContact", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("ContactId") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("EmailAddress") + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("PhoneNumber") + .HasColumnType("nvarchar(max)"); + + b.HasKey("MerchantReportingId", "ContactId"); + + b.ToTable("merchantcontact"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantContract", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("ContractReportingId") + .HasColumnType("int"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.HasKey("MerchantReportingId", "ContractReportingId"); + + b.ToTable("MerchantContracts"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantDevice", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("DeviceId") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("DeviceIdentifier") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("MerchantReportingId", "DeviceId"); + + b.ToTable("merchantdevice"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantOperator", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("OperatorId") + .HasColumnType("uniqueidentifier"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("MerchantNumber") + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("TerminalNumber") + .HasColumnType("nvarchar(max)"); + + b.HasKey("MerchantReportingId", "OperatorId"); + + b.ToTable("merchantoperator"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantSecurityUser", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("SecurityUserId") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("EmailAddress") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("MerchantReportingId", "SecurityUserId"); + + b.ToTable("merchantsecurityuser"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantSettlementFee", b => + { + b.Property("SettlementReportingId") + .HasColumnType("int"); + + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.Property("TransactionFeeReportingId") + .HasColumnType("int"); + + b.Property("CalculatedValue") + .HasColumnType("decimal(18,2)"); + + b.Property("FeeCalculatedDateTime") + .HasColumnType("datetime2"); + + b.Property("FeeValue") + .HasColumnType("decimal(18,2)"); + + b.Property("IsSettled") + .HasColumnType("bit"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.HasKey("SettlementReportingId", "TransactionReportingId", "TransactionFeeReportingId"); + + b.HasIndex("TransactionReportingId"); + + b.ToTable("merchantsettlementfee"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Operator", b => + { + b.Property("OperatorReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("OperatorReportingId")); + + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("OperatorId") + .HasColumnType("uniqueidentifier"); + + b.Property("RequireCustomMerchantNumber") + .HasColumnType("bit"); + + b.Property("RequireCustomTerminalNumber") + .HasColumnType("bit"); + + b.HasKey("OperatorReportingId"); + + b.HasIndex("OperatorId") + .IsUnique(); + + b.ToTable("operator"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Reconciliation", b => + { + b.Property("TransactionReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("TransactionReportingId")); + + b.Property("DeviceIdentifier") + .HasColumnType("nvarchar(max)"); + + b.Property("IsAuthorised") + .HasColumnType("bit"); + + b.Property("IsCompleted") + .HasColumnType("bit"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("ResponseCode") + .HasColumnType("nvarchar(max)"); + + b.Property("ResponseMessage") + .HasColumnType("nvarchar(max)"); + + b.Property("TransactionCount") + .HasColumnType("int"); + + b.Property("TransactionDate") + .HasColumnType("date"); + + b.Property("TransactionDateTime") + .HasColumnType("datetime2"); + + b.Property("TransactionId") + .HasColumnType("uniqueidentifier"); + + b.Property("TransactionTime") + .HasColumnType("time"); + + b.Property("TransactionValue") + .HasColumnType("decimal(18,2)"); + + b.HasKey("TransactionReportingId"); + + SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("TransactionReportingId"), false); + + b.HasIndex("TransactionDate", "MerchantReportingId"); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("TransactionDate", "MerchantReportingId")); + + b.HasIndex("TransactionId", "MerchantReportingId") + .IsUnique(); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("TransactionId", "MerchantReportingId"), false); + + b.ToTable("reconciliation"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.ResponseCodes", b => + { + b.Property("ResponseCode") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("ResponseCode")); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("ResponseCode"); + + b.ToTable("responsecodes"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Settlement", b => + { + b.Property("SettlementReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("SettlementReportingId")); + + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("IsCompleted") + .HasColumnType("bit"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("ProcessingStarted") + .HasColumnType("bit"); + + b.Property("ProcessingStartedDateTIme") + .HasColumnType("datetime2"); + + b.Property("SettlementDate") + .HasColumnType("date"); + + b.Property("SettlementId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("SettlementReportingId"); + + SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("SettlementReportingId"), false); + + b.HasIndex("EstateReportingId", "SettlementId") + .IsUnique(); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("EstateReportingId", "SettlementId"), false); + + b.HasIndex("SettlementDate", "EstateReportingId"); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("SettlementDate", "EstateReportingId")); + + b.ToTable("settlement"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.StatementHeader", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("StatementId") + .HasColumnType("uniqueidentifier"); + + b.Property("StatementCreatedDate") + .HasColumnType("date"); + + b.Property("StatementCreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("StatementGeneratedDate") + .HasColumnType("date"); + + b.Property("StatementGeneratedDateTime") + .HasColumnType("datetime2"); + + b.Property("StatementReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("StatementReportingId")); + + b.HasKey("MerchantReportingId", "StatementId"); + + SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("MerchantReportingId", "StatementId"), false); + + b.HasIndex("MerchantReportingId", "StatementGeneratedDate"); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("MerchantReportingId", "StatementGeneratedDate")); + + b.ToTable("statementheader"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.StatementLine", b => + { + b.Property("StatementReportingId") + .HasColumnType("int"); + + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.Property("ActivityDateTime") + .HasColumnType("datetime2"); + + b.Property("ActivityType") + .HasColumnType("int"); + + b.Property("ActivityDate") + .HasColumnType("date"); + + b.Property("ActivityDescription") + .HasColumnType("nvarchar(max)"); + + b.Property("InAmount") + .HasColumnType("decimal(18,2)"); + + b.Property("OutAmount") + .HasColumnType("decimal(18,2)"); + + b.HasKey("StatementReportingId", "TransactionReportingId", "ActivityDateTime", "ActivityType"); + + b.ToTable("statementline"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Transaction", b => + { + b.Property("TransactionReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("TransactionReportingId")); + + b.Property("AuthorisationCode") + .HasColumnType("nvarchar(max)"); + + b.Property("ContractProductReportingId") + .HasColumnType("int"); + + b.Property("ContractReportingId") + .HasColumnType("int"); + + b.Property("DeviceIdentifier") + .HasColumnType("nvarchar(max)"); + + b.Property("EstateOperatorReportingId") + .HasColumnType("int"); + + b.Property("IsAuthorised") + .HasColumnType("bit"); + + b.Property("IsCompleted") + .HasColumnType("bit"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("ResponseCode") + .HasColumnType("nvarchar(max)"); + + b.Property("ResponseMessage") + .HasColumnType("nvarchar(max)"); + + b.Property("TransactionAmount") + .HasColumnType("decimal(18,2)"); + + b.Property("TransactionDate") + .HasColumnType("date"); + + b.Property("TransactionDateTime") + .HasColumnType("datetime2"); + + b.Property("TransactionId") + .HasColumnType("uniqueidentifier"); + + b.Property("TransactionNumber") + .HasColumnType("nvarchar(max)"); + + b.Property("TransactionReference") + .HasColumnType("nvarchar(max)"); + + b.Property("TransactionSource") + .HasColumnType("int"); + + b.Property("TransactionTime") + .HasColumnType("time"); + + b.Property("TransactionType") + .HasColumnType("nvarchar(max)"); + + b.HasKey("TransactionReportingId"); + + SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("TransactionReportingId"), false); + + b.HasIndex("TransactionId") + .IsUnique(); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("TransactionId"), false); + + b.HasIndex("TransactionDate", "MerchantReportingId"); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("TransactionDate", "MerchantReportingId")); + + b.HasIndex("TransactionId", "MerchantReportingId") + .IsUnique(); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("TransactionId", "MerchantReportingId"), false); + + b.ToTable("transaction"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.TransactionAdditionalRequestData", b => + { + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.Property("Amount") + .HasColumnType("nvarchar(max)"); + + b.Property("CustomerAccountNumber") + .HasColumnType("nvarchar(max)"); + + b.HasKey("TransactionReportingId"); + + b.ToTable("transactionadditionalrequestdata"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.TransactionAdditionalResponseData", b => + { + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.HasKey("TransactionReportingId"); + + b.ToTable("transactionadditionalresponsedata"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Voucher", b => + { + b.Property("VoucherId") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("ExpiryDate") + .HasColumnType("date"); + + b.Property("ExpiryDateTime") + .HasColumnType("datetime2"); + + b.Property("GenerateDate") + .HasColumnType("date"); + + b.Property("GenerateDateTime") + .HasColumnType("datetime2"); + + b.Property("IsGenerated") + .HasColumnType("bit"); + + b.Property("IsIssued") + .HasColumnType("bit"); + + b.Property("IsRedeemed") + .HasColumnType("bit"); + + b.Property("IssuedDate") + .HasColumnType("date"); + + b.Property("IssuedDateTime") + .HasColumnType("datetime2"); + + b.Property("OperatorIdentifier") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("RecipientEmail") + .HasColumnType("nvarchar(max)"); + + b.Property("RecipientMobile") + .HasColumnType("nvarchar(max)"); + + b.Property("RedeemedDate") + .HasColumnType("datetime2"); + + b.Property("RedeemedDateTime") + .HasColumnType("datetime2"); + + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.Property("Value") + .HasColumnType("decimal(18,2)"); + + b.Property("VoucherCode") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.HasKey("VoucherId"); + + b.HasIndex("TransactionReportingId"); + + b.HasIndex("VoucherCode"); + + b.ToTable("voucher"); + }); + + modelBuilder.Entity("EstateManagement.Database.ViewEntities.SettlementView", b => + { + b.Property("Amount") + .HasColumnType("decimal(18,2)"); + + b.Property("CalculatedValue") + .HasColumnType("decimal(18,2)"); + + b.Property("DayOfWeek") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("FeeDescription") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsCompleted") + .HasColumnType("bit"); + + b.Property("IsSettled") + .HasColumnType("bit"); + + b.Property("MerchantId") + .HasColumnType("uniqueidentifier"); + + b.Property("MerchantName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Month") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("MonthNumber") + .HasColumnType("int"); + + b.Property("OperatorIdentifier") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("SettlementDate") + .HasColumnType("datetime2"); + + b.Property("SettlementId") + .HasColumnType("uniqueidentifier"); + + b.Property("TransactionId") + .HasColumnType("uniqueidentifier"); + + b.Property("WeekNumber") + .HasColumnType("int"); + + b.Property("YearNumber") + .HasColumnType("int"); + + b.ToTable((string)null); + + b.ToView("uvwSettlements", (string)null); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/TransactionProcessor.Database/Migrations/SqlServer/20240425163935_record_operatators_at_readmodel_2.cs b/TransactionProcessor.Database/Migrations/SqlServer/20240425163935_record_operatators_at_readmodel_2.cs new file mode 100644 index 00000000..39b70124 --- /dev/null +++ b/TransactionProcessor.Database/Migrations/SqlServer/20240425163935_record_operatators_at_readmodel_2.cs @@ -0,0 +1,53 @@ +#nullable disable + +using Microsoft.EntityFrameworkCore.Migrations; + +namespace TransactionProcessor.Database.Migrations.SqlServer +{ + /// + public partial class record_operatators_at_readmodel_2 : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropPrimaryKey( + name: "PK_estateoperator", + table: "estateoperator"); + + migrationBuilder.DropColumn("OperatorReportingId", "estateoperator"); + + migrationBuilder.AddColumn( + name: "OperatorReportingId", + table: "estateoperator", + type: "int", + nullable: false); + + migrationBuilder.AddPrimaryKey( + name: "PK_estateoperator", + table: "estateoperator", + columns: new[] { "EstateReportingId", "OperatorReportingId" }); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropPrimaryKey( + name: "PK_estateoperator", + table: "estateoperator"); + + migrationBuilder.AlterColumn( + name: "OperatorReportingId", + table: "estateoperator", + type: "int", + nullable: false, + oldClrType: typeof(int), + oldType: "int") + .Annotation("SqlServer:Identity", "1, 1"); + + migrationBuilder.AddPrimaryKey( + name: "PK_estateoperator", + table: "estateoperator", + column: "OperatorReportingId"); + } + } +} diff --git a/TransactionProcessor.Database/Migrations/SqlServer/20240501154042_make_voucher_operatoridentifier_nullable.Designer.cs b/TransactionProcessor.Database/Migrations/SqlServer/20240501154042_make_voucher_operatoridentifier_nullable.Designer.cs new file mode 100644 index 00000000..b00d7a7c --- /dev/null +++ b/TransactionProcessor.Database/Migrations/SqlServer/20240501154042_make_voucher_operatoridentifier_nullable.Designer.cs @@ -0,0 +1,1127 @@ +// + +#nullable disable + +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using TransactionProcessor.Database.Contexts; + +namespace TransactionProcessor.Database.Migrations.SqlServer +{ + [DbContext(typeof(EstateManagementSqlServerContext))] + [Migration("20240501154042_make_voucher_operatoridentifier_nullable")] + partial class make_voucher_operatoridentifier_nullable + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.3") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("EstateManagement.Database.Entities.Calendar", b => + { + b.Property("Date") + .HasColumnType("datetime2"); + + b.Property("DayOfWeek") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("DayOfWeekNumber") + .HasColumnType("int"); + + b.Property("DayOfWeekShort") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("MonthNameLong") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("MonthNameShort") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("MonthNumber") + .HasColumnType("int"); + + b.Property("WeekNumber") + .HasColumnType("int"); + + b.Property("WeekNumberString") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Year") + .HasColumnType("int"); + + b.Property("YearWeekNumber") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Date"); + + b.ToTable("calendar"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Contract", b => + { + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("OperatorId") + .HasColumnType("uniqueidentifier"); + + b.Property("ContractId") + .HasColumnType("uniqueidentifier"); + + b.Property("ContractReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("ContractReportingId")); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("EstateReportingId", "OperatorId", "ContractId"); + + b.ToTable("contract"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.ContractProduct", b => + { + b.Property("ContractReportingId") + .HasColumnType("int"); + + b.Property("ProductId") + .HasColumnType("uniqueidentifier"); + + b.Property("ContractProductReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("ContractProductReportingId")); + + b.Property("DisplayText") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ProductName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ProductType") + .HasColumnType("int"); + + b.Property("Value") + .HasColumnType("decimal(18,2)"); + + b.HasKey("ContractReportingId", "ProductId"); + + b.ToTable("contractproduct"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.ContractProductTransactionFee", b => + { + b.Property("ContractProductReportingId") + .HasColumnType("int"); + + b.Property("TransactionFeeId") + .HasColumnType("uniqueidentifier"); + + b.Property("CalculationType") + .HasColumnType("int"); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("FeeType") + .HasColumnType("int"); + + b.Property("IsEnabled") + .HasColumnType("bit"); + + b.Property("TransactionFeeReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("TransactionFeeReportingId")); + + b.Property("Value") + .HasColumnType("decimal(18,4)"); + + b.HasKey("ContractProductReportingId", "TransactionFeeId"); + + b.ToTable("contractproducttransactionfee"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Estate", b => + { + b.Property("EstateReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("EstateReportingId")); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Reference") + .HasColumnType("nvarchar(max)"); + + b.HasKey("EstateReportingId"); + + b.HasIndex("EstateId") + .IsUnique(); + + b.ToTable("estate"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.EstateOperator", b => + { + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("OperatorReportingId") + .HasColumnType("int"); + + b.HasKey("EstateReportingId", "OperatorReportingId"); + + b.ToTable("estateoperator"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.EstateSecurityUser", b => + { + b.Property("SecurityUserId") + .HasColumnType("uniqueidentifier"); + + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("EmailAddress") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("SecurityUserId", "EstateReportingId"); + + b.ToTable("estatesecurityuser"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.File", b => + { + b.Property("FileReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("FileReportingId")); + + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("FileId") + .HasColumnType("uniqueidentifier"); + + b.Property("FileImportLogReportingId") + .HasColumnType("int"); + + b.Property("FileLocation") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("FileProfileId") + .HasColumnType("uniqueidentifier"); + + b.Property("FileReceivedDate") + .HasColumnType("date"); + + b.Property("FileReceivedDateTime") + .HasColumnType("datetime2"); + + b.Property("IsCompleted") + .HasColumnType("bit"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("FileReportingId"); + + b.HasIndex("FileId") + .IsUnique(); + + b.ToTable("file"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.FileImportLog", b => + { + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("FileImportLogReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("FileImportLogReportingId")); + + b.Property("FileImportLogId") + .HasColumnType("uniqueidentifier"); + + b.Property("ImportLogDate") + .HasColumnType("date"); + + b.Property("ImportLogDateTime") + .HasColumnType("datetime2"); + + b.HasKey("EstateReportingId", "FileImportLogReportingId"); + + b.HasIndex("EstateReportingId", "FileImportLogId") + .IsUnique(); + + b.ToTable("fileimportlog"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.FileImportLogFile", b => + { + b.Property("FileImportLogReportingId") + .HasColumnType("int"); + + b.Property("FileReportingId") + .HasColumnType("int"); + + b.Property("FilePath") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("FileProfileId") + .HasColumnType("uniqueidentifier"); + + b.Property("FileUploadedDate") + .HasColumnType("date"); + + b.Property("FileUploadedDateTime") + .HasColumnType("datetime2"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("OriginalFileName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("FileImportLogReportingId", "FileReportingId"); + + b.ToTable("fileimportlogfile"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.FileLine", b => + { + b.Property("FileReportingId") + .HasColumnType("int"); + + b.Property("LineNumber") + .HasColumnType("int"); + + b.Property("FileLineData") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Status") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.HasKey("FileReportingId", "LineNumber"); + + SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("FileReportingId", "LineNumber")); + + b.HasIndex("TransactionReportingId"); + + b.ToTable("fileline"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Float", b => + { + b.Property("FloatId") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("ContractId") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedDate") + .HasColumnType("date"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("ProductId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("FloatId"); + + SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("FloatId"), false); + + b.HasIndex("CreatedDate"); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("CreatedDate")); + + b.ToTable("Floats"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.FloatActivity", b => + { + b.Property("EventId") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("ActivityDate") + .HasColumnType("date"); + + b.Property("ActivityDateTime") + .HasColumnType("datetime2"); + + b.Property("Amount") + .HasColumnType("decimal(18,2)"); + + b.Property("CostPrice") + .HasColumnType("decimal(18,2)"); + + b.Property("CreditOrDebit") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("FloatId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("EventId"); + + SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("EventId"), false); + + b.HasIndex("ActivityDate"); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("ActivityDate")); + + b.ToTable("FloatActivity"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Merchant", b => + { + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("MerchantReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("MerchantReportingId")); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("LastSaleDate") + .HasColumnType("date"); + + b.Property("LastSaleDateTime") + .HasColumnType("datetime2"); + + b.Property("LastStatementGenerated") + .HasColumnType("datetime2"); + + b.Property("MerchantId") + .HasColumnType("uniqueidentifier"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Reference") + .HasColumnType("nvarchar(max)"); + + b.Property("SettlementSchedule") + .HasColumnType("int"); + + b.HasKey("EstateReportingId", "MerchantReportingId"); + + b.HasIndex("EstateReportingId", "MerchantId") + .IsUnique(); + + b.ToTable("merchant"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantAddress", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("AddressId") + .HasColumnType("uniqueidentifier"); + + b.Property("AddressLine1") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("AddressLine2") + .HasColumnType("nvarchar(max)"); + + b.Property("AddressLine3") + .HasColumnType("nvarchar(max)"); + + b.Property("AddressLine4") + .HasColumnType("nvarchar(max)"); + + b.Property("Country") + .HasColumnType("nvarchar(max)"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("PostalCode") + .HasColumnType("nvarchar(max)"); + + b.Property("Region") + .HasColumnType("nvarchar(max)"); + + b.Property("Town") + .HasColumnType("nvarchar(max)"); + + b.HasKey("MerchantReportingId", "AddressId"); + + b.ToTable("merchantaddress"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantContact", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("ContactId") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("EmailAddress") + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("PhoneNumber") + .HasColumnType("nvarchar(max)"); + + b.HasKey("MerchantReportingId", "ContactId"); + + b.ToTable("merchantcontact"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantContract", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("ContractReportingId") + .HasColumnType("int"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.HasKey("MerchantReportingId", "ContractReportingId"); + + b.ToTable("MerchantContracts"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantDevice", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("DeviceId") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("DeviceIdentifier") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("MerchantReportingId", "DeviceId"); + + b.ToTable("merchantdevice"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantOperator", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("OperatorId") + .HasColumnType("uniqueidentifier"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("MerchantNumber") + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("TerminalNumber") + .HasColumnType("nvarchar(max)"); + + b.HasKey("MerchantReportingId", "OperatorId"); + + b.ToTable("merchantoperator"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantSecurityUser", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("SecurityUserId") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("EmailAddress") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("MerchantReportingId", "SecurityUserId"); + + b.ToTable("merchantsecurityuser"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantSettlementFee", b => + { + b.Property("SettlementReportingId") + .HasColumnType("int"); + + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.Property("TransactionFeeReportingId") + .HasColumnType("int"); + + b.Property("CalculatedValue") + .HasColumnType("decimal(18,2)"); + + b.Property("FeeCalculatedDateTime") + .HasColumnType("datetime2"); + + b.Property("FeeValue") + .HasColumnType("decimal(18,2)"); + + b.Property("IsSettled") + .HasColumnType("bit"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.HasKey("SettlementReportingId", "TransactionReportingId", "TransactionFeeReportingId"); + + b.HasIndex("TransactionReportingId"); + + b.ToTable("merchantsettlementfee"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Operator", b => + { + b.Property("OperatorReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("OperatorReportingId")); + + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("OperatorId") + .HasColumnType("uniqueidentifier"); + + b.Property("RequireCustomMerchantNumber") + .HasColumnType("bit"); + + b.Property("RequireCustomTerminalNumber") + .HasColumnType("bit"); + + b.HasKey("OperatorReportingId"); + + b.HasIndex("OperatorId") + .IsUnique(); + + b.ToTable("operator"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Reconciliation", b => + { + b.Property("TransactionReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("TransactionReportingId")); + + b.Property("DeviceIdentifier") + .HasColumnType("nvarchar(max)"); + + b.Property("IsAuthorised") + .HasColumnType("bit"); + + b.Property("IsCompleted") + .HasColumnType("bit"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("ResponseCode") + .HasColumnType("nvarchar(max)"); + + b.Property("ResponseMessage") + .HasColumnType("nvarchar(max)"); + + b.Property("TransactionCount") + .HasColumnType("int"); + + b.Property("TransactionDate") + .HasColumnType("date"); + + b.Property("TransactionDateTime") + .HasColumnType("datetime2"); + + b.Property("TransactionId") + .HasColumnType("uniqueidentifier"); + + b.Property("TransactionTime") + .HasColumnType("time"); + + b.Property("TransactionValue") + .HasColumnType("decimal(18,2)"); + + b.HasKey("TransactionReportingId"); + + SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("TransactionReportingId"), false); + + b.HasIndex("TransactionDate", "MerchantReportingId"); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("TransactionDate", "MerchantReportingId")); + + b.HasIndex("TransactionId", "MerchantReportingId") + .IsUnique(); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("TransactionId", "MerchantReportingId"), false); + + b.ToTable("reconciliation"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.ResponseCodes", b => + { + b.Property("ResponseCode") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("ResponseCode")); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("ResponseCode"); + + b.ToTable("responsecodes"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Settlement", b => + { + b.Property("SettlementReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("SettlementReportingId")); + + b.Property("EstateReportingId") + .HasColumnType("int"); + + b.Property("IsCompleted") + .HasColumnType("bit"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("ProcessingStarted") + .HasColumnType("bit"); + + b.Property("ProcessingStartedDateTIme") + .HasColumnType("datetime2"); + + b.Property("SettlementDate") + .HasColumnType("date"); + + b.Property("SettlementId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("SettlementReportingId"); + + SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("SettlementReportingId"), false); + + b.HasIndex("EstateReportingId", "SettlementId") + .IsUnique(); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("EstateReportingId", "SettlementId"), false); + + b.HasIndex("SettlementDate", "EstateReportingId"); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("SettlementDate", "EstateReportingId")); + + b.ToTable("settlement"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.StatementHeader", b => + { + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("StatementId") + .HasColumnType("uniqueidentifier"); + + b.Property("StatementCreatedDate") + .HasColumnType("date"); + + b.Property("StatementCreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("StatementGeneratedDate") + .HasColumnType("date"); + + b.Property("StatementGeneratedDateTime") + .HasColumnType("datetime2"); + + b.Property("StatementReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("StatementReportingId")); + + b.HasKey("MerchantReportingId", "StatementId"); + + SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("MerchantReportingId", "StatementId"), false); + + b.HasIndex("MerchantReportingId", "StatementGeneratedDate"); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("MerchantReportingId", "StatementGeneratedDate")); + + b.ToTable("statementheader"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.StatementLine", b => + { + b.Property("StatementReportingId") + .HasColumnType("int"); + + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.Property("ActivityDateTime") + .HasColumnType("datetime2"); + + b.Property("ActivityType") + .HasColumnType("int"); + + b.Property("ActivityDate") + .HasColumnType("date"); + + b.Property("ActivityDescription") + .HasColumnType("nvarchar(max)"); + + b.Property("InAmount") + .HasColumnType("decimal(18,2)"); + + b.Property("OutAmount") + .HasColumnType("decimal(18,2)"); + + b.HasKey("StatementReportingId", "TransactionReportingId", "ActivityDateTime", "ActivityType"); + + b.ToTable("statementline"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Transaction", b => + { + b.Property("TransactionReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("TransactionReportingId")); + + b.Property("AuthorisationCode") + .HasColumnType("nvarchar(max)"); + + b.Property("ContractProductReportingId") + .HasColumnType("int"); + + b.Property("ContractReportingId") + .HasColumnType("int"); + + b.Property("DeviceIdentifier") + .HasColumnType("nvarchar(max)"); + + b.Property("EstateOperatorReportingId") + .HasColumnType("int"); + + b.Property("IsAuthorised") + .HasColumnType("bit"); + + b.Property("IsCompleted") + .HasColumnType("bit"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("ResponseCode") + .HasColumnType("nvarchar(max)"); + + b.Property("ResponseMessage") + .HasColumnType("nvarchar(max)"); + + b.Property("TransactionAmount") + .HasColumnType("decimal(18,2)"); + + b.Property("TransactionDate") + .HasColumnType("date"); + + b.Property("TransactionDateTime") + .HasColumnType("datetime2"); + + b.Property("TransactionId") + .HasColumnType("uniqueidentifier"); + + b.Property("TransactionNumber") + .HasColumnType("nvarchar(max)"); + + b.Property("TransactionReference") + .HasColumnType("nvarchar(max)"); + + b.Property("TransactionSource") + .HasColumnType("int"); + + b.Property("TransactionTime") + .HasColumnType("time"); + + b.Property("TransactionType") + .HasColumnType("nvarchar(max)"); + + b.HasKey("TransactionReportingId"); + + SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("TransactionReportingId"), false); + + b.HasIndex("TransactionId") + .IsUnique(); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("TransactionId"), false); + + b.HasIndex("TransactionDate", "MerchantReportingId"); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("TransactionDate", "MerchantReportingId")); + + b.HasIndex("TransactionId", "MerchantReportingId") + .IsUnique(); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("TransactionId", "MerchantReportingId"), false); + + b.ToTable("transaction"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.TransactionAdditionalRequestData", b => + { + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.Property("Amount") + .HasColumnType("nvarchar(max)"); + + b.Property("CustomerAccountNumber") + .HasColumnType("nvarchar(max)"); + + b.HasKey("TransactionReportingId"); + + b.ToTable("transactionadditionalrequestdata"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.TransactionAdditionalResponseData", b => + { + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.HasKey("TransactionReportingId"); + + b.ToTable("transactionadditionalresponsedata"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Voucher", b => + { + b.Property("VoucherId") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("ExpiryDate") + .HasColumnType("date"); + + b.Property("ExpiryDateTime") + .HasColumnType("datetime2"); + + b.Property("GenerateDate") + .HasColumnType("date"); + + b.Property("GenerateDateTime") + .HasColumnType("datetime2"); + + b.Property("IsGenerated") + .HasColumnType("bit"); + + b.Property("IsIssued") + .HasColumnType("bit"); + + b.Property("IsRedeemed") + .HasColumnType("bit"); + + b.Property("IssuedDate") + .HasColumnType("date"); + + b.Property("IssuedDateTime") + .HasColumnType("datetime2"); + + b.Property("OperatorIdentifier") + .HasColumnType("nvarchar(max)"); + + b.Property("RecipientEmail") + .HasColumnType("nvarchar(max)"); + + b.Property("RecipientMobile") + .HasColumnType("nvarchar(max)"); + + b.Property("RedeemedDate") + .HasColumnType("datetime2"); + + b.Property("RedeemedDateTime") + .HasColumnType("datetime2"); + + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.Property("Value") + .HasColumnType("decimal(18,2)"); + + b.Property("VoucherCode") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.HasKey("VoucherId"); + + b.HasIndex("TransactionReportingId"); + + b.HasIndex("VoucherCode"); + + b.ToTable("voucher"); + }); + + modelBuilder.Entity("EstateManagement.Database.ViewEntities.SettlementView", b => + { + b.Property("Amount") + .HasColumnType("decimal(18,2)"); + + b.Property("CalculatedValue") + .HasColumnType("decimal(18,2)"); + + b.Property("DayOfWeek") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("FeeDescription") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsCompleted") + .HasColumnType("bit"); + + b.Property("IsSettled") + .HasColumnType("bit"); + + b.Property("MerchantId") + .HasColumnType("uniqueidentifier"); + + b.Property("MerchantName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Month") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("MonthNumber") + .HasColumnType("int"); + + b.Property("OperatorIdentifier") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("SettlementDate") + .HasColumnType("datetime2"); + + b.Property("SettlementId") + .HasColumnType("uniqueidentifier"); + + b.Property("TransactionId") + .HasColumnType("uniqueidentifier"); + + b.Property("WeekNumber") + .HasColumnType("int"); + + b.Property("YearNumber") + .HasColumnType("int"); + + b.ToTable((string)null); + + b.ToView("uvwSettlements", (string)null); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/TransactionProcessor.Database/Migrations/SqlServer/20240501154042_make_voucher_operatoridentifier_nullable.cs b/TransactionProcessor.Database/Migrations/SqlServer/20240501154042_make_voucher_operatoridentifier_nullable.cs new file mode 100644 index 00000000..32671b51 --- /dev/null +++ b/TransactionProcessor.Database/Migrations/SqlServer/20240501154042_make_voucher_operatoridentifier_nullable.cs @@ -0,0 +1,36 @@ +#nullable disable + +using Microsoft.EntityFrameworkCore.Migrations; + +namespace TransactionProcessor.Database.Migrations.SqlServer +{ + /// + public partial class make_voucher_operatoridentifier_nullable : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterColumn( + name: "OperatorIdentifier", + table: "voucher", + type: "nvarchar(max)", + nullable: true, + oldClrType: typeof(string), + oldType: "nvarchar(max)"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterColumn( + name: "OperatorIdentifier", + table: "voucher", + type: "nvarchar(max)", + nullable: false, + defaultValue: "", + oldClrType: typeof(string), + oldType: "nvarchar(max)", + oldNullable: true); + } + } +} diff --git a/TransactionProcessor.Database/Migrations/SqlServer/20240605061637_remove_reportingids_from_transaction.Designer.cs b/TransactionProcessor.Database/Migrations/SqlServer/20240605061637_remove_reportingids_from_transaction.Designer.cs new file mode 100644 index 00000000..45caf2a8 --- /dev/null +++ b/TransactionProcessor.Database/Migrations/SqlServer/20240605061637_remove_reportingids_from_transaction.Designer.cs @@ -0,0 +1,1117 @@ +// + +#nullable disable + +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using TransactionProcessor.Database.Contexts; + +namespace TransactionProcessor.Database.Migrations.SqlServer +{ + [DbContext(typeof(EstateManagementSqlServerContext))] + [Migration("20240605061637_remove_reportingids_from_transaction")] + partial class remove_reportingids_from_transaction + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.3") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("EstateManagement.Database.Entities.Calendar", b => + { + b.Property("Date") + .HasColumnType("datetime2"); + + b.Property("DayOfWeek") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("DayOfWeekNumber") + .HasColumnType("int"); + + b.Property("DayOfWeekShort") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("MonthNameLong") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("MonthNameShort") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("MonthNumber") + .HasColumnType("int"); + + b.Property("WeekNumber") + .HasColumnType("int"); + + b.Property("WeekNumberString") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Year") + .HasColumnType("int"); + + b.Property("YearWeekNumber") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Date"); + + b.ToTable("calendar"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Contract", b => + { + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("OperatorId") + .HasColumnType("uniqueidentifier"); + + b.Property("ContractId") + .HasColumnType("uniqueidentifier"); + + b.Property("ContractReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("ContractReportingId")); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("EstateId", "OperatorId", "ContractId"); + + b.ToTable("contract"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.ContractProduct", b => + { + b.Property("ContractProductReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("ContractProductReportingId")); + + b.Property("ContractId") + .HasColumnType("uniqueidentifier"); + + b.Property("ContractProductId") + .HasColumnType("uniqueidentifier"); + + b.Property("DisplayText") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ProductName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ProductType") + .HasColumnType("int"); + + b.Property("Value") + .HasColumnType("decimal(18,2)"); + + b.HasKey("ContractProductReportingId"); + + b.HasIndex("ContractProductId", "ContractId") + .IsUnique(); + + b.ToTable("contractproduct"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.ContractProductTransactionFee", b => + { + b.Property("ContractProductTransactionFeeReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("ContractProductTransactionFeeReportingId")); + + b.Property("CalculationType") + .HasColumnType("int"); + + b.Property("ContractProductId") + .HasColumnType("uniqueidentifier"); + + b.Property("ContractProductTransactionFeeId") + .HasColumnType("uniqueidentifier"); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("FeeType") + .HasColumnType("int"); + + b.Property("IsEnabled") + .HasColumnType("bit"); + + b.Property("Value") + .HasColumnType("decimal(18,4)"); + + b.HasKey("ContractProductTransactionFeeReportingId"); + + b.HasIndex("ContractProductTransactionFeeId", "ContractProductId") + .IsUnique(); + + b.ToTable("contractproducttransactionfee"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Estate", b => + { + b.Property("EstateReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("EstateReportingId")); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Reference") + .HasColumnType("nvarchar(max)"); + + b.HasKey("EstateReportingId"); + + b.HasIndex("EstateId") + .IsUnique(); + + b.ToTable("estate"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.EstateSecurityUser", b => + { + b.Property("SecurityUserId") + .HasColumnType("uniqueidentifier"); + + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("EmailAddress") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("SecurityUserId", "EstateId"); + + b.ToTable("estatesecurityuser"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.File", b => + { + b.Property("FileReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("FileReportingId")); + + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("FileId") + .HasColumnType("uniqueidentifier"); + + b.Property("FileImportLogId") + .HasColumnType("uniqueidentifier"); + + b.Property("FileLocation") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("FileProfileId") + .HasColumnType("uniqueidentifier"); + + b.Property("FileReceivedDate") + .HasColumnType("date"); + + b.Property("FileReceivedDateTime") + .HasColumnType("datetime2"); + + b.Property("IsCompleted") + .HasColumnType("bit"); + + b.Property("MerchantId") + .HasColumnType("uniqueidentifier"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("FileReportingId"); + + b.HasIndex("FileId") + .IsUnique(); + + b.ToTable("file"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.FileImportLog", b => + { + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("FileImportLogReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("FileImportLogReportingId")); + + b.Property("FileImportLogId") + .HasColumnType("uniqueidentifier"); + + b.Property("ImportLogDate") + .HasColumnType("date"); + + b.Property("ImportLogDateTime") + .HasColumnType("datetime2"); + + b.HasKey("EstateId", "FileImportLogReportingId"); + + b.HasIndex("EstateId", "FileImportLogId") + .IsUnique(); + + b.ToTable("fileimportlog"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.FileImportLogFile", b => + { + b.Property("FileImportLogId") + .HasColumnType("uniqueidentifier"); + + b.Property("FileId") + .HasColumnType("uniqueidentifier"); + + b.Property("FilePath") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("FileProfileId") + .HasColumnType("uniqueidentifier"); + + b.Property("FileUploadedDate") + .HasColumnType("date"); + + b.Property("FileUploadedDateTime") + .HasColumnType("datetime2"); + + b.Property("MerchantId") + .HasColumnType("uniqueidentifier"); + + b.Property("OriginalFileName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("FileImportLogId", "FileId"); + + b.ToTable("fileimportlogfile"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.FileLine", b => + { + b.Property("FileId") + .HasColumnType("uniqueidentifier"); + + b.Property("LineNumber") + .HasColumnType("int"); + + b.Property("FileLineData") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Status") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("TransactionId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("FileId", "LineNumber"); + + SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("FileId", "LineNumber")); + + b.HasIndex("TransactionId") + .IsUnique(); + + b.ToTable("fileline"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Float", b => + { + b.Property("FloatId") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("ContractId") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedDate") + .HasColumnType("date"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("ProductId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("FloatId"); + + SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("FloatId"), false); + + b.HasIndex("CreatedDate"); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("CreatedDate")); + + b.ToTable("Floats"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.FloatActivity", b => + { + b.Property("EventId") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("ActivityDate") + .HasColumnType("date"); + + b.Property("ActivityDateTime") + .HasColumnType("datetime2"); + + b.Property("Amount") + .HasColumnType("decimal(18,2)"); + + b.Property("CostPrice") + .HasColumnType("decimal(18,2)"); + + b.Property("CreditOrDebit") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("FloatId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("EventId"); + + SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("EventId"), false); + + b.HasIndex("ActivityDate"); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("ActivityDate")); + + b.ToTable("FloatActivity"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Merchant", b => + { + b.Property("MerchantReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("MerchantReportingId")); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("LastSaleDate") + .HasColumnType("date"); + + b.Property("LastSaleDateTime") + .HasColumnType("datetime2"); + + b.Property("LastStatementGenerated") + .HasColumnType("datetime2"); + + b.Property("MerchantId") + .HasColumnType("uniqueidentifier"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Reference") + .HasColumnType("nvarchar(max)"); + + b.Property("SettlementSchedule") + .HasColumnType("int"); + + b.HasKey("MerchantReportingId"); + + b.HasIndex("EstateId", "MerchantId") + .IsUnique(); + + b.ToTable("merchant"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantAddress", b => + { + b.Property("MerchantId") + .HasColumnType("uniqueidentifier"); + + b.Property("AddressId") + .HasColumnType("uniqueidentifier"); + + b.Property("AddressLine1") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("AddressLine2") + .HasColumnType("nvarchar(max)"); + + b.Property("AddressLine3") + .HasColumnType("nvarchar(max)"); + + b.Property("AddressLine4") + .HasColumnType("nvarchar(max)"); + + b.Property("Country") + .HasColumnType("nvarchar(max)"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("PostalCode") + .HasColumnType("nvarchar(max)"); + + b.Property("Region") + .HasColumnType("nvarchar(max)"); + + b.Property("Town") + .HasColumnType("nvarchar(max)"); + + b.HasKey("MerchantId", "AddressId"); + + b.ToTable("merchantaddress"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantContact", b => + { + b.Property("MerchantId") + .HasColumnType("uniqueidentifier"); + + b.Property("ContactId") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("EmailAddress") + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("PhoneNumber") + .HasColumnType("nvarchar(max)"); + + b.HasKey("MerchantId", "ContactId"); + + b.ToTable("merchantcontact"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantContract", b => + { + b.Property("MerchantId") + .HasColumnType("uniqueidentifier"); + + b.Property("ContractId") + .HasColumnType("uniqueidentifier"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.HasKey("MerchantId", "ContractId"); + + b.ToTable("MerchantContracts"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantDevice", b => + { + b.Property("MerchantId") + .HasColumnType("uniqueidentifier"); + + b.Property("DeviceId") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("DeviceIdentifier") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("MerchantId", "DeviceId"); + + b.ToTable("merchantdevice"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantOperator", b => + { + b.Property("MerchantId") + .HasColumnType("uniqueidentifier"); + + b.Property("OperatorId") + .HasColumnType("uniqueidentifier"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("MerchantNumber") + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("TerminalNumber") + .HasColumnType("nvarchar(max)"); + + b.HasKey("MerchantId", "OperatorId"); + + b.ToTable("merchantoperator"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantSecurityUser", b => + { + b.Property("MerchantId") + .HasColumnType("uniqueidentifier"); + + b.Property("SecurityUserId") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("EmailAddress") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("MerchantId", "SecurityUserId"); + + b.ToTable("merchantsecurityuser"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantSettlementFee", b => + { + b.Property("SettlementId") + .HasColumnType("uniqueidentifier"); + + b.Property("TransactionId") + .HasColumnType("uniqueidentifier"); + + b.Property("ContractProductTransactionFeeId") + .HasColumnType("uniqueidentifier"); + + b.Property("CalculatedValue") + .HasColumnType("decimal(18,2)"); + + b.Property("FeeCalculatedDateTime") + .HasColumnType("datetime2"); + + b.Property("FeeValue") + .HasColumnType("decimal(18,2)"); + + b.Property("IsSettled") + .HasColumnType("bit"); + + b.Property("MerchantId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("SettlementId", "TransactionId", "ContractProductTransactionFeeId"); + + b.ToTable("merchantsettlementfee"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Operator", b => + { + b.Property("OperatorReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("OperatorReportingId")); + + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("OperatorId") + .HasColumnType("uniqueidentifier"); + + b.Property("RequireCustomMerchantNumber") + .HasColumnType("bit"); + + b.Property("RequireCustomTerminalNumber") + .HasColumnType("bit"); + + b.HasKey("OperatorReportingId"); + + b.HasIndex("OperatorId") + .IsUnique(); + + b.ToTable("operator"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Reconciliation", b => + { + b.Property("TransactionReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("TransactionReportingId")); + + b.Property("DeviceIdentifier") + .HasColumnType("nvarchar(max)"); + + b.Property("IsAuthorised") + .HasColumnType("bit"); + + b.Property("IsCompleted") + .HasColumnType("bit"); + + b.Property("MerchantId") + .HasColumnType("uniqueidentifier"); + + b.Property("ResponseCode") + .HasColumnType("nvarchar(max)"); + + b.Property("ResponseMessage") + .HasColumnType("nvarchar(max)"); + + b.Property("TransactionCount") + .HasColumnType("int"); + + b.Property("TransactionDate") + .HasColumnType("date"); + + b.Property("TransactionDateTime") + .HasColumnType("datetime2"); + + b.Property("TransactionId") + .HasColumnType("uniqueidentifier"); + + b.Property("TransactionTime") + .HasColumnType("time"); + + b.Property("TransactionValue") + .HasColumnType("decimal(18,2)"); + + b.HasKey("TransactionReportingId"); + + SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("TransactionReportingId"), false); + + b.HasIndex("TransactionDate"); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("TransactionDate")); + + b.HasIndex("TransactionId", "MerchantId") + .IsUnique(); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("TransactionId", "MerchantId"), false); + + b.ToTable("reconciliation"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.ResponseCodes", b => + { + b.Property("ResponseCode") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("ResponseCode")); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("ResponseCode"); + + b.ToTable("responsecodes"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Settlement", b => + { + b.Property("SettlementReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("SettlementReportingId")); + + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("IsCompleted") + .HasColumnType("bit"); + + b.Property("MerchantId") + .HasColumnType("uniqueidentifier"); + + b.Property("ProcessingStarted") + .HasColumnType("bit"); + + b.Property("ProcessingStartedDateTIme") + .HasColumnType("datetime2"); + + b.Property("SettlementDate") + .HasColumnType("date"); + + b.Property("SettlementId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("SettlementReportingId"); + + SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("SettlementReportingId"), false); + + b.HasIndex("SettlementDate"); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("SettlementDate")); + + b.HasIndex("EstateId", "SettlementId") + .IsUnique(); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("EstateId", "SettlementId"), false); + + b.ToTable("settlement"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.StatementHeader", b => + { + b.Property("MerchantId") + .HasColumnType("uniqueidentifier"); + + b.Property("StatementId") + .HasColumnType("uniqueidentifier"); + + b.Property("StatementCreatedDate") + .HasColumnType("date"); + + b.Property("StatementCreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("StatementGeneratedDate") + .HasColumnType("date"); + + b.Property("StatementGeneratedDateTime") + .HasColumnType("datetime2"); + + b.Property("StatementReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("StatementReportingId")); + + b.HasKey("MerchantId", "StatementId"); + + SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("MerchantId", "StatementId"), false); + + b.HasIndex("StatementGeneratedDate"); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("StatementGeneratedDate")); + + b.ToTable("statementheader"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.StatementLine", b => + { + b.Property("StatementId") + .HasColumnType("uniqueidentifier"); + + b.Property("TransactionId") + .HasColumnType("uniqueidentifier"); + + b.Property("ActivityDateTime") + .HasColumnType("datetime2"); + + b.Property("ActivityType") + .HasColumnType("int"); + + b.Property("ActivityDate") + .HasColumnType("date"); + + b.Property("ActivityDescription") + .HasColumnType("nvarchar(max)"); + + b.Property("InAmount") + .HasColumnType("decimal(18,2)"); + + b.Property("OutAmount") + .HasColumnType("decimal(18,2)"); + + b.HasKey("StatementId", "TransactionId", "ActivityDateTime", "ActivityType"); + + b.ToTable("statementline"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Transaction", b => + { + b.Property("TransactionReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("TransactionReportingId")); + + b.Property("AuthorisationCode") + .HasColumnType("nvarchar(max)"); + + b.Property("ContractId") + .HasColumnType("uniqueidentifier"); + + b.Property("ContractProductId") + .HasColumnType("uniqueidentifier"); + + b.Property("DeviceIdentifier") + .HasColumnType("nvarchar(max)"); + + b.Property("IsAuthorised") + .HasColumnType("bit"); + + b.Property("IsCompleted") + .HasColumnType("bit"); + + b.Property("MerchantId") + .HasColumnType("uniqueidentifier"); + + b.Property("OperatorId") + .HasColumnType("uniqueidentifier"); + + b.Property("ResponseCode") + .HasColumnType("nvarchar(max)"); + + b.Property("ResponseMessage") + .HasColumnType("nvarchar(max)"); + + b.Property("TransactionAmount") + .HasColumnType("decimal(18,2)"); + + b.Property("TransactionDate") + .HasColumnType("date"); + + b.Property("TransactionDateTime") + .HasColumnType("datetime2"); + + b.Property("TransactionId") + .HasColumnType("uniqueidentifier"); + + b.Property("TransactionNumber") + .HasColumnType("nvarchar(max)"); + + b.Property("TransactionReference") + .HasColumnType("nvarchar(max)"); + + b.Property("TransactionSource") + .HasColumnType("int"); + + b.Property("TransactionTime") + .HasColumnType("time"); + + b.Property("TransactionType") + .HasColumnType("nvarchar(max)"); + + b.HasKey("TransactionReportingId"); + + SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("TransactionReportingId"), false); + + b.HasIndex("TransactionDate"); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("TransactionDate")); + + b.HasIndex("TransactionId") + .IsUnique(); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("TransactionId"), false); + + b.ToTable("transaction"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.TransactionAdditionalRequestData", b => + { + b.Property("TransactionId") + .HasColumnType("uniqueidentifier"); + + b.Property("Amount") + .HasColumnType("nvarchar(max)"); + + b.Property("CustomerAccountNumber") + .HasColumnType("nvarchar(max)"); + + b.HasKey("TransactionId"); + + b.ToTable("transactionadditionalrequestdata"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.TransactionAdditionalResponseData", b => + { + b.Property("TransactionId") + .HasColumnType("uniqueidentifier"); + + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.HasKey("TransactionId"); + + b.ToTable("transactionadditionalresponsedata"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Voucher", b => + { + b.Property("VoucherId") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("ExpiryDate") + .HasColumnType("date"); + + b.Property("ExpiryDateTime") + .HasColumnType("datetime2"); + + b.Property("GenerateDate") + .HasColumnType("date"); + + b.Property("GenerateDateTime") + .HasColumnType("datetime2"); + + b.Property("IsGenerated") + .HasColumnType("bit"); + + b.Property("IsIssued") + .HasColumnType("bit"); + + b.Property("IsRedeemed") + .HasColumnType("bit"); + + b.Property("IssuedDate") + .HasColumnType("date"); + + b.Property("IssuedDateTime") + .HasColumnType("datetime2"); + + b.Property("OperatorIdentifier") + .HasColumnType("nvarchar(max)"); + + b.Property("RecipientEmail") + .HasColumnType("nvarchar(max)"); + + b.Property("RecipientMobile") + .HasColumnType("nvarchar(max)"); + + b.Property("RedeemedDate") + .HasColumnType("datetime2"); + + b.Property("RedeemedDateTime") + .HasColumnType("datetime2"); + + b.Property("TransactionId") + .HasColumnType("uniqueidentifier"); + + b.Property("Value") + .HasColumnType("decimal(18,2)"); + + b.Property("VoucherCode") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.HasKey("VoucherId"); + + b.HasIndex("TransactionId"); + + b.HasIndex("VoucherCode"); + + b.ToTable("voucher"); + }); + + modelBuilder.Entity("EstateManagement.Database.ViewEntities.SettlementView", b => + { + b.Property("Amount") + .HasColumnType("decimal(18,2)"); + + b.Property("CalculatedValue") + .HasColumnType("decimal(18,2)"); + + b.Property("DayOfWeek") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("FeeDescription") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsCompleted") + .HasColumnType("bit"); + + b.Property("IsSettled") + .HasColumnType("bit"); + + b.Property("MerchantId") + .HasColumnType("uniqueidentifier"); + + b.Property("MerchantName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Month") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("MonthNumber") + .HasColumnType("int"); + + b.Property("OperatorIdentifier") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("SettlementDate") + .HasColumnType("datetime2"); + + b.Property("SettlementId") + .HasColumnType("uniqueidentifier"); + + b.Property("TransactionId") + .HasColumnType("uniqueidentifier"); + + b.Property("WeekNumber") + .HasColumnType("int"); + + b.Property("YearNumber") + .HasColumnType("int"); + + b.ToTable((string)null); + + b.ToView("uvwSettlements", (string)null); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/TransactionProcessor.Database/Migrations/SqlServer/20240605061637_remove_reportingids_from_transaction.cs b/TransactionProcessor.Database/Migrations/SqlServer/20240605061637_remove_reportingids_from_transaction.cs new file mode 100644 index 00000000..8f9e1779 --- /dev/null +++ b/TransactionProcessor.Database/Migrations/SqlServer/20240605061637_remove_reportingids_from_transaction.cs @@ -0,0 +1,1497 @@ +#nullable disable + +using Microsoft.EntityFrameworkCore.Migrations; + +namespace TransactionProcessor.Database.Migrations.SqlServer +{ + /// + public partial class remove_reportingids_from_transaction : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "estateoperator"); + + migrationBuilder.DropIndex( + name: "IX_voucher_TransactionReportingId", + table: "voucher"); + + migrationBuilder.DropPrimaryKey( + name: "PK_transactionadditionalresponsedata", + table: "transactionadditionalresponsedata"); + + migrationBuilder.DropPrimaryKey( + name: "PK_transactionadditionalrequestdata", + table: "transactionadditionalrequestdata"); + + migrationBuilder.DropIndex( + name: "IX_transaction_TransactionDate_MerchantReportingId", + table: "transaction"); + + migrationBuilder.DropIndex( + name: "IX_transaction_TransactionId_MerchantReportingId", + table: "transaction"); + + migrationBuilder.DropPrimaryKey( + name: "PK_statementline", + table: "statementline"); + + migrationBuilder.DropPrimaryKey( + name: "PK_statementheader", + table: "statementheader"); + + migrationBuilder.DropIndex( + name: "IX_statementheader_MerchantReportingId_StatementGeneratedDate", + table: "statementheader"); + + migrationBuilder.DropIndex( + name: "IX_settlement_EstateReportingId_SettlementId", + table: "settlement"); + + migrationBuilder.DropIndex( + name: "IX_settlement_SettlementDate_EstateReportingId", + table: "settlement"); + + migrationBuilder.DropIndex( + name: "IX_reconciliation_TransactionDate_MerchantReportingId", + table: "reconciliation"); + + migrationBuilder.DropIndex( + name: "IX_reconciliation_TransactionId_MerchantReportingId", + table: "reconciliation"); + + migrationBuilder.DropPrimaryKey( + name: "PK_merchantsettlementfee", + table: "merchantsettlementfee"); + + migrationBuilder.DropIndex( + name: "IX_merchantsettlementfee_TransactionReportingId", + table: "merchantsettlementfee"); + + migrationBuilder.DropPrimaryKey( + name: "PK_merchantsecurityuser", + table: "merchantsecurityuser"); + + migrationBuilder.DropPrimaryKey( + name: "PK_merchantoperator", + table: "merchantoperator"); + + migrationBuilder.DropPrimaryKey( + name: "PK_merchantdevice", + table: "merchantdevice"); + + migrationBuilder.DropPrimaryKey( + name: "PK_MerchantContracts", + table: "MerchantContracts"); + + migrationBuilder.DropPrimaryKey( + name: "PK_merchantcontact", + table: "merchantcontact"); + + migrationBuilder.DropPrimaryKey( + name: "PK_merchantaddress", + table: "merchantaddress"); + + migrationBuilder.DropPrimaryKey( + name: "PK_merchant", + table: "merchant"); + + migrationBuilder.DropIndex( + name: "IX_merchant_EstateReportingId_MerchantId", + table: "merchant"); + + migrationBuilder.DropPrimaryKey( + name: "PK_fileline", + table: "fileline"); + + migrationBuilder.DropIndex( + name: "IX_fileline_TransactionReportingId", + table: "fileline"); + + migrationBuilder.DropPrimaryKey( + name: "PK_fileimportlogfile", + table: "fileimportlogfile"); + + migrationBuilder.DropPrimaryKey( + name: "PK_fileimportlog", + table: "fileimportlog"); + + migrationBuilder.DropIndex( + name: "IX_fileimportlog_EstateReportingId_FileImportLogId", + table: "fileimportlog"); + + migrationBuilder.DropPrimaryKey( + name: "PK_estatesecurityuser", + table: "estatesecurityuser"); + + migrationBuilder.DropPrimaryKey( + name: "PK_contractproducttransactionfee", + table: "contractproducttransactionfee"); + + migrationBuilder.DropPrimaryKey( + name: "PK_contractproduct", + table: "contractproduct"); + + migrationBuilder.DropPrimaryKey( + name: "PK_contract", + table: "contract"); + + migrationBuilder.DropColumn( + name: "TransactionReportingId", + table: "voucher"); + + migrationBuilder.DropColumn( + name: "TransactionReportingId", + table: "transactionadditionalrequestdata"); + + migrationBuilder.DropColumn( + name: "ContractProductReportingId", + table: "transaction"); + + migrationBuilder.DropColumn( + name: "ContractReportingId", + table: "transaction"); + + migrationBuilder.DropColumn( + name: "EstateOperatorReportingId", + table: "transaction"); + + migrationBuilder.DropColumn( + name: "MerchantReportingId", + table: "transaction"); + + migrationBuilder.DropColumn( + name: "StatementReportingId", + table: "statementline"); + + migrationBuilder.DropColumn( + name: "TransactionReportingId", + table: "statementline"); + + migrationBuilder.DropColumn( + name: "MerchantReportingId", + table: "statementheader"); + + migrationBuilder.DropColumn( + name: "EstateReportingId", + table: "settlement"); + + migrationBuilder.DropColumn( + name: "MerchantReportingId", + table: "settlement"); + + migrationBuilder.DropColumn( + name: "MerchantReportingId", + table: "reconciliation"); + + migrationBuilder.DropColumn( + name: "EstateReportingId", + table: "operator"); + + migrationBuilder.DropColumn( + name: "SettlementReportingId", + table: "merchantsettlementfee"); + + migrationBuilder.DropColumn( + name: "TransactionReportingId", + table: "merchantsettlementfee"); + + migrationBuilder.DropColumn( + name: "TransactionFeeReportingId", + table: "merchantsettlementfee"); + + migrationBuilder.DropColumn( + name: "MerchantReportingId", + table: "merchantsettlementfee"); + + migrationBuilder.DropColumn( + name: "MerchantReportingId", + table: "merchantsecurityuser"); + + migrationBuilder.DropColumn( + name: "MerchantReportingId", + table: "merchantoperator"); + + migrationBuilder.DropColumn( + name: "MerchantReportingId", + table: "merchantdevice"); + + migrationBuilder.DropColumn( + name: "MerchantReportingId", + table: "MerchantContracts"); + + migrationBuilder.DropColumn( + name: "ContractReportingId", + table: "MerchantContracts"); + + migrationBuilder.DropColumn( + name: "MerchantReportingId", + table: "merchantcontact"); + + migrationBuilder.DropColumn( + name: "MerchantReportingId", + table: "merchantaddress"); + + migrationBuilder.DropColumn( + name: "EstateReportingId", + table: "merchant"); + + migrationBuilder.DropColumn( + name: "FileReportingId", + table: "fileline"); + + migrationBuilder.DropColumn( + name: "TransactionReportingId", + table: "fileline"); + + migrationBuilder.DropColumn( + name: "FileImportLogReportingId", + table: "fileimportlogfile"); + + migrationBuilder.DropColumn( + name: "FileReportingId", + table: "fileimportlogfile"); + + migrationBuilder.DropColumn( + name: "MerchantReportingId", + table: "fileimportlogfile"); + + migrationBuilder.DropColumn( + name: "EstateReportingId", + table: "fileimportlog"); + + migrationBuilder.DropColumn( + name: "EstateReportingId", + table: "file"); + + migrationBuilder.DropColumn( + name: "FileImportLogReportingId", + table: "file"); + + migrationBuilder.DropColumn( + name: "MerchantReportingId", + table: "file"); + + migrationBuilder.DropColumn( + name: "EstateReportingId", + table: "estatesecurityuser"); + + migrationBuilder.DropColumn( + name: "ContractProductReportingId", + table: "contractproducttransactionfee"); + + migrationBuilder.DropColumn( + name: "ContractReportingId", + table: "contractproduct"); + + migrationBuilder.DropColumn( + name: "EstateReportingId", + table: "contract"); + + migrationBuilder.RenameColumn( + name: "TransactionFeeReportingId", + table: "contractproducttransactionfee", + newName: "ContractProductTransactionFeeReportingId"); + + migrationBuilder.RenameColumn( + name: "TransactionFeeId", + table: "contractproducttransactionfee", + newName: "ContractProductTransactionFeeId"); + + migrationBuilder.RenameColumn( + name: "ProductId", + table: "contractproduct", + newName: "ContractProductId"); + + migrationBuilder.AddColumn( + name: "TransactionId", + table: "voucher", + type: "uniqueidentifier", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); + + migrationBuilder.AddColumn( + name: "TransactionId", + table: "transactionadditionalresponsedata", + type: "uniqueidentifier", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); + + migrationBuilder.AddColumn( + name: "TransactionId", + table: "transactionadditionalrequestdata", + type: "uniqueidentifier", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); + + migrationBuilder.AddColumn( + name: "ContractId", + table: "transaction", + type: "uniqueidentifier", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); + + migrationBuilder.AddColumn( + name: "ContractProductId", + table: "transaction", + type: "uniqueidentifier", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); + + migrationBuilder.AddColumn( + name: "MerchantId", + table: "transaction", + type: "uniqueidentifier", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); + + migrationBuilder.AddColumn( + name: "OperatorId", + table: "transaction", + type: "uniqueidentifier", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); + + migrationBuilder.AddColumn( + name: "StatementId", + table: "statementline", + type: "uniqueidentifier", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); + + migrationBuilder.AddColumn( + name: "TransactionId", + table: "statementline", + type: "uniqueidentifier", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); + + migrationBuilder.AddColumn( + name: "MerchantId", + table: "statementheader", + type: "uniqueidentifier", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); + + migrationBuilder.AddColumn( + name: "EstateId", + table: "settlement", + type: "uniqueidentifier", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); + + migrationBuilder.AddColumn( + name: "MerchantId", + table: "settlement", + type: "uniqueidentifier", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); + + migrationBuilder.AddColumn( + name: "MerchantId", + table: "reconciliation", + type: "uniqueidentifier", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); + + migrationBuilder.AddColumn( + name: "EstateId", + table: "operator", + type: "uniqueidentifier", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); + + migrationBuilder.AddColumn( + name: "SettlementId", + table: "merchantsettlementfee", + type: "uniqueidentifier", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); + + migrationBuilder.AddColumn( + name: "TransactionId", + table: "merchantsettlementfee", + type: "uniqueidentifier", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); + + migrationBuilder.AddColumn( + name: "ContractProductTransactionFeeId", + table: "merchantsettlementfee", + type: "uniqueidentifier", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); + + migrationBuilder.AddColumn( + name: "MerchantId", + table: "merchantsettlementfee", + type: "uniqueidentifier", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); + + migrationBuilder.AddColumn( + name: "MerchantId", + table: "merchantsecurityuser", + type: "uniqueidentifier", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); + + migrationBuilder.AddColumn( + name: "MerchantId", + table: "merchantoperator", + type: "uniqueidentifier", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); + + migrationBuilder.AddColumn( + name: "MerchantId", + table: "merchantdevice", + type: "uniqueidentifier", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); + + migrationBuilder.AddColumn( + name: "MerchantId", + table: "MerchantContracts", + type: "uniqueidentifier", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); + + migrationBuilder.AddColumn( + name: "ContractId", + table: "MerchantContracts", + type: "uniqueidentifier", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); + + migrationBuilder.AddColumn( + name: "MerchantId", + table: "merchantcontact", + type: "uniqueidentifier", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); + + migrationBuilder.AddColumn( + name: "MerchantId", + table: "merchantaddress", + type: "uniqueidentifier", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); + + migrationBuilder.AddColumn( + name: "EstateId", + table: "merchant", + type: "uniqueidentifier", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); + + migrationBuilder.AddColumn( + name: "FileId", + table: "fileline", + type: "uniqueidentifier", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); + + migrationBuilder.AddColumn( + name: "TransactionId", + table: "fileline", + type: "uniqueidentifier", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); + + migrationBuilder.AddColumn( + name: "FileImportLogId", + table: "fileimportlogfile", + type: "uniqueidentifier", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); + + migrationBuilder.AddColumn( + name: "FileId", + table: "fileimportlogfile", + type: "uniqueidentifier", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); + + migrationBuilder.AddColumn( + name: "MerchantId", + table: "fileimportlogfile", + type: "uniqueidentifier", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); + + migrationBuilder.AddColumn( + name: "EstateId", + table: "fileimportlog", + type: "uniqueidentifier", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); + + migrationBuilder.AddColumn( + name: "EstateId", + table: "file", + type: "uniqueidentifier", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); + + migrationBuilder.AddColumn( + name: "FileImportLogId", + table: "file", + type: "uniqueidentifier", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); + + migrationBuilder.AddColumn( + name: "MerchantId", + table: "file", + type: "uniqueidentifier", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); + + migrationBuilder.AddColumn( + name: "EstateId", + table: "estatesecurityuser", + type: "uniqueidentifier", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); + + migrationBuilder.AddColumn( + name: "ContractProductId", + table: "contractproducttransactionfee", + type: "uniqueidentifier", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); + + migrationBuilder.AddColumn( + name: "ContractId", + table: "contractproduct", + type: "uniqueidentifier", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); + + migrationBuilder.AddColumn( + name: "EstateId", + table: "contract", + type: "uniqueidentifier", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); + + migrationBuilder.AddPrimaryKey( + name: "PK_transactionadditionalresponsedata", + table: "transactionadditionalresponsedata", + column: "TransactionId"); + + migrationBuilder.AddPrimaryKey( + name: "PK_transactionadditionalrequestdata", + table: "transactionadditionalrequestdata", + column: "TransactionId"); + + migrationBuilder.AddPrimaryKey( + name: "PK_statementline", + table: "statementline", + columns: new[] { "StatementId", "TransactionId", "ActivityDateTime", "ActivityType" }); + + migrationBuilder.AddPrimaryKey( + name: "PK_statementheader", + table: "statementheader", + columns: new[] { "MerchantId", "StatementId" }) + .Annotation("SqlServer:Clustered", false); + + migrationBuilder.AddPrimaryKey( + name: "PK_merchantsettlementfee", + table: "merchantsettlementfee", + columns: new[] { "SettlementId", "TransactionId", "ContractProductTransactionFeeId" }); + + migrationBuilder.AddPrimaryKey( + name: "PK_merchantsecurityuser", + table: "merchantsecurityuser", + columns: new[] { "MerchantId", "SecurityUserId" }); + + migrationBuilder.AddPrimaryKey( + name: "PK_merchantoperator", + table: "merchantoperator", + columns: new[] { "MerchantId", "OperatorId" }); + + migrationBuilder.AddPrimaryKey( + name: "PK_merchantdevice", + table: "merchantdevice", + columns: new[] { "MerchantId", "DeviceId" }); + + migrationBuilder.AddPrimaryKey( + name: "PK_MerchantContracts", + table: "MerchantContracts", + columns: new[] { "MerchantId", "ContractId" }); + + migrationBuilder.AddPrimaryKey( + name: "PK_merchantcontact", + table: "merchantcontact", + columns: new[] { "MerchantId", "ContactId" }); + + migrationBuilder.AddPrimaryKey( + name: "PK_merchantaddress", + table: "merchantaddress", + columns: new[] { "MerchantId", "AddressId" }); + + migrationBuilder.AddPrimaryKey( + name: "PK_merchant", + table: "merchant", + column: "MerchantReportingId"); + + migrationBuilder.AddPrimaryKey( + name: "PK_fileline", + table: "fileline", + columns: new[] { "FileId", "LineNumber" }) + .Annotation("SqlServer:Clustered", true); + + migrationBuilder.AddPrimaryKey( + name: "PK_fileimportlogfile", + table: "fileimportlogfile", + columns: new[] { "FileImportLogId", "FileId" }); + + migrationBuilder.AddPrimaryKey( + name: "PK_fileimportlog", + table: "fileimportlog", + columns: new[] { "EstateId", "FileImportLogReportingId" }); + + migrationBuilder.AddPrimaryKey( + name: "PK_estatesecurityuser", + table: "estatesecurityuser", + columns: new[] { "SecurityUserId", "EstateId" }); + + migrationBuilder.AddPrimaryKey( + name: "PK_contractproducttransactionfee", + table: "contractproducttransactionfee", + column: "ContractProductTransactionFeeReportingId"); + + migrationBuilder.AddPrimaryKey( + name: "PK_contractproduct", + table: "contractproduct", + column: "ContractProductReportingId"); + + migrationBuilder.AddPrimaryKey( + name: "PK_contract", + table: "contract", + columns: new[] { "EstateId", "OperatorId", "ContractId" }); + + migrationBuilder.CreateIndex( + name: "IX_voucher_TransactionId", + table: "voucher", + column: "TransactionId"); + + migrationBuilder.CreateIndex( + name: "IX_transaction_TransactionDate", + table: "transaction", + column: "TransactionDate") + .Annotation("SqlServer:Clustered", true); + + migrationBuilder.CreateIndex( + name: "IX_statementheader_StatementGeneratedDate", + table: "statementheader", + column: "StatementGeneratedDate") + .Annotation("SqlServer:Clustered", true); + + migrationBuilder.CreateIndex( + name: "IX_settlement_EstateId_SettlementId", + table: "settlement", + columns: new[] { "EstateId", "SettlementId" }, + unique: true) + .Annotation("SqlServer:Clustered", false); + + migrationBuilder.CreateIndex( + name: "IX_settlement_SettlementDate", + table: "settlement", + column: "SettlementDate") + .Annotation("SqlServer:Clustered", true); + + migrationBuilder.CreateIndex( + name: "IX_reconciliation_TransactionDate", + table: "reconciliation", + column: "TransactionDate") + .Annotation("SqlServer:Clustered", true); + + migrationBuilder.CreateIndex( + name: "IX_reconciliation_TransactionId_MerchantId", + table: "reconciliation", + columns: new[] { "TransactionId", "MerchantId" }, + unique: true) + .Annotation("SqlServer:Clustered", false); + + migrationBuilder.CreateIndex( + name: "IX_merchant_EstateId_MerchantId", + table: "merchant", + columns: new[] { "EstateId", "MerchantId" }, + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_fileline_TransactionId", + table: "fileline", + column: "TransactionId", + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_fileimportlog_EstateId_FileImportLogId", + table: "fileimportlog", + columns: new[] { "EstateId", "FileImportLogId" }, + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_contractproducttransactionfee_ContractProductTransactionFeeId_ContractProductId", + table: "contractproducttransactionfee", + columns: new[] { "ContractProductTransactionFeeId", "ContractProductId" }, + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_contractproduct_ContractProductId_ContractId", + table: "contractproduct", + columns: new[] { "ContractProductId", "ContractId" }, + unique: true); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropIndex( + name: "IX_voucher_TransactionId", + table: "voucher"); + + migrationBuilder.DropPrimaryKey( + name: "PK_transactionadditionalresponsedata", + table: "transactionadditionalresponsedata"); + + migrationBuilder.DropPrimaryKey( + name: "PK_transactionadditionalrequestdata", + table: "transactionadditionalrequestdata"); + + migrationBuilder.DropIndex( + name: "IX_transaction_TransactionDate", + table: "transaction"); + + migrationBuilder.DropPrimaryKey( + name: "PK_statementline", + table: "statementline"); + + migrationBuilder.DropPrimaryKey( + name: "PK_statementheader", + table: "statementheader"); + + migrationBuilder.DropIndex( + name: "IX_statementheader_StatementGeneratedDate", + table: "statementheader"); + + migrationBuilder.DropIndex( + name: "IX_settlement_EstateId_SettlementId", + table: "settlement"); + + migrationBuilder.DropIndex( + name: "IX_settlement_SettlementDate", + table: "settlement"); + + migrationBuilder.DropIndex( + name: "IX_reconciliation_TransactionDate", + table: "reconciliation"); + + migrationBuilder.DropIndex( + name: "IX_reconciliation_TransactionId_MerchantId", + table: "reconciliation"); + + migrationBuilder.DropPrimaryKey( + name: "PK_merchantsettlementfee", + table: "merchantsettlementfee"); + + migrationBuilder.DropPrimaryKey( + name: "PK_merchantsecurityuser", + table: "merchantsecurityuser"); + + migrationBuilder.DropPrimaryKey( + name: "PK_merchantoperator", + table: "merchantoperator"); + + migrationBuilder.DropPrimaryKey( + name: "PK_merchantdevice", + table: "merchantdevice"); + + migrationBuilder.DropPrimaryKey( + name: "PK_MerchantContracts", + table: "MerchantContracts"); + + migrationBuilder.DropPrimaryKey( + name: "PK_merchantcontact", + table: "merchantcontact"); + + migrationBuilder.DropPrimaryKey( + name: "PK_merchantaddress", + table: "merchantaddress"); + + migrationBuilder.DropPrimaryKey( + name: "PK_merchant", + table: "merchant"); + + migrationBuilder.DropIndex( + name: "IX_merchant_EstateId_MerchantId", + table: "merchant"); + + migrationBuilder.DropPrimaryKey( + name: "PK_fileline", + table: "fileline"); + + migrationBuilder.DropIndex( + name: "IX_fileline_TransactionId", + table: "fileline"); + + migrationBuilder.DropPrimaryKey( + name: "PK_fileimportlogfile", + table: "fileimportlogfile"); + + migrationBuilder.DropPrimaryKey( + name: "PK_fileimportlog", + table: "fileimportlog"); + + migrationBuilder.DropIndex( + name: "IX_fileimportlog_EstateId_FileImportLogId", + table: "fileimportlog"); + + migrationBuilder.DropPrimaryKey( + name: "PK_estatesecurityuser", + table: "estatesecurityuser"); + + migrationBuilder.DropPrimaryKey( + name: "PK_contractproducttransactionfee", + table: "contractproducttransactionfee"); + + migrationBuilder.DropIndex( + name: "IX_contractproducttransactionfee_ContractProductTransactionFeeId_ContractProductId", + table: "contractproducttransactionfee"); + + migrationBuilder.DropPrimaryKey( + name: "PK_contractproduct", + table: "contractproduct"); + + migrationBuilder.DropIndex( + name: "IX_contractproduct_ContractProductId_ContractId", + table: "contractproduct"); + + migrationBuilder.DropPrimaryKey( + name: "PK_contract", + table: "contract"); + + migrationBuilder.DropColumn( + name: "TransactionId", + table: "voucher"); + + migrationBuilder.DropColumn( + name: "TransactionId", + table: "transactionadditionalresponsedata"); + + migrationBuilder.DropColumn( + name: "TransactionId", + table: "transactionadditionalrequestdata"); + + migrationBuilder.DropColumn( + name: "ContractId", + table: "transaction"); + + migrationBuilder.DropColumn( + name: "ContractProductId", + table: "transaction"); + + migrationBuilder.DropColumn( + name: "MerchantId", + table: "transaction"); + + migrationBuilder.DropColumn( + name: "OperatorId", + table: "transaction"); + + migrationBuilder.DropColumn( + name: "StatementId", + table: "statementline"); + + migrationBuilder.DropColumn( + name: "TransactionId", + table: "statementline"); + + migrationBuilder.DropColumn( + name: "MerchantId", + table: "statementheader"); + + migrationBuilder.DropColumn( + name: "EstateId", + table: "settlement"); + + migrationBuilder.DropColumn( + name: "MerchantId", + table: "settlement"); + + migrationBuilder.DropColumn( + name: "MerchantId", + table: "reconciliation"); + + migrationBuilder.DropColumn( + name: "EstateId", + table: "operator"); + + migrationBuilder.DropColumn( + name: "SettlementId", + table: "merchantsettlementfee"); + + migrationBuilder.DropColumn( + name: "TransactionId", + table: "merchantsettlementfee"); + + migrationBuilder.DropColumn( + name: "ContractProductTransactionFeeId", + table: "merchantsettlementfee"); + + migrationBuilder.DropColumn( + name: "MerchantId", + table: "merchantsettlementfee"); + + migrationBuilder.DropColumn( + name: "MerchantId", + table: "merchantsecurityuser"); + + migrationBuilder.DropColumn( + name: "MerchantId", + table: "merchantoperator"); + + migrationBuilder.DropColumn( + name: "MerchantId", + table: "merchantdevice"); + + migrationBuilder.DropColumn( + name: "MerchantId", + table: "MerchantContracts"); + + migrationBuilder.DropColumn( + name: "ContractId", + table: "MerchantContracts"); + + migrationBuilder.DropColumn( + name: "MerchantId", + table: "merchantcontact"); + + migrationBuilder.DropColumn( + name: "MerchantId", + table: "merchantaddress"); + + migrationBuilder.DropColumn( + name: "EstateId", + table: "merchant"); + + migrationBuilder.DropColumn( + name: "FileId", + table: "fileline"); + + migrationBuilder.DropColumn( + name: "TransactionId", + table: "fileline"); + + migrationBuilder.DropColumn( + name: "FileImportLogId", + table: "fileimportlogfile"); + + migrationBuilder.DropColumn( + name: "FileId", + table: "fileimportlogfile"); + + migrationBuilder.DropColumn( + name: "MerchantId", + table: "fileimportlogfile"); + + migrationBuilder.DropColumn( + name: "EstateId", + table: "fileimportlog"); + + migrationBuilder.DropColumn( + name: "EstateId", + table: "file"); + + migrationBuilder.DropColumn( + name: "FileImportLogId", + table: "file"); + + migrationBuilder.DropColumn( + name: "MerchantId", + table: "file"); + + migrationBuilder.DropColumn( + name: "EstateId", + table: "estatesecurityuser"); + + migrationBuilder.DropColumn( + name: "ContractProductId", + table: "contractproducttransactionfee"); + + migrationBuilder.DropColumn( + name: "ContractId", + table: "contractproduct"); + + migrationBuilder.DropColumn( + name: "EstateId", + table: "contract"); + + migrationBuilder.RenameColumn( + name: "ContractProductTransactionFeeId", + table: "contractproducttransactionfee", + newName: "TransactionFeeId"); + + migrationBuilder.RenameColumn( + name: "ContractProductTransactionFeeReportingId", + table: "contractproducttransactionfee", + newName: "TransactionFeeReportingId"); + + migrationBuilder.RenameColumn( + name: "ContractProductId", + table: "contractproduct", + newName: "ProductId"); + + migrationBuilder.AddColumn( + name: "TransactionReportingId", + table: "voucher", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "TransactionReportingId", + table: "transactionadditionalrequestdata", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "ContractProductReportingId", + table: "transaction", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "ContractReportingId", + table: "transaction", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "EstateOperatorReportingId", + table: "transaction", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "MerchantReportingId", + table: "transaction", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "StatementReportingId", + table: "statementline", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "TransactionReportingId", + table: "statementline", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "MerchantReportingId", + table: "statementheader", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "EstateReportingId", + table: "settlement", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "MerchantReportingId", + table: "settlement", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "MerchantReportingId", + table: "reconciliation", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "EstateReportingId", + table: "operator", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "SettlementReportingId", + table: "merchantsettlementfee", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "TransactionReportingId", + table: "merchantsettlementfee", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "TransactionFeeReportingId", + table: "merchantsettlementfee", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "MerchantReportingId", + table: "merchantsettlementfee", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "MerchantReportingId", + table: "merchantsecurityuser", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "MerchantReportingId", + table: "merchantoperator", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "MerchantReportingId", + table: "merchantdevice", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "MerchantReportingId", + table: "MerchantContracts", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "ContractReportingId", + table: "MerchantContracts", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "MerchantReportingId", + table: "merchantcontact", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "MerchantReportingId", + table: "merchantaddress", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "EstateReportingId", + table: "merchant", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "FileReportingId", + table: "fileline", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "TransactionReportingId", + table: "fileline", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "FileImportLogReportingId", + table: "fileimportlogfile", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "FileReportingId", + table: "fileimportlogfile", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "MerchantReportingId", + table: "fileimportlogfile", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "EstateReportingId", + table: "fileimportlog", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "EstateReportingId", + table: "file", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "FileImportLogReportingId", + table: "file", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "MerchantReportingId", + table: "file", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "EstateReportingId", + table: "estatesecurityuser", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "ContractProductReportingId", + table: "contractproducttransactionfee", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "ContractReportingId", + table: "contractproduct", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "EstateReportingId", + table: "contract", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddPrimaryKey( + name: "PK_transactionadditionalresponsedata", + table: "transactionadditionalresponsedata", + column: "TransactionReportingId"); + + migrationBuilder.AddPrimaryKey( + name: "PK_transactionadditionalrequestdata", + table: "transactionadditionalrequestdata", + column: "TransactionReportingId"); + + migrationBuilder.AddPrimaryKey( + name: "PK_statementline", + table: "statementline", + columns: new[] { "StatementReportingId", "TransactionReportingId", "ActivityDateTime", "ActivityType" }); + + migrationBuilder.AddPrimaryKey( + name: "PK_statementheader", + table: "statementheader", + columns: new[] { "MerchantReportingId", "StatementId" }) + .Annotation("SqlServer:Clustered", false); + + migrationBuilder.AddPrimaryKey( + name: "PK_merchantsettlementfee", + table: "merchantsettlementfee", + columns: new[] { "SettlementReportingId", "TransactionReportingId", "TransactionFeeReportingId" }); + + migrationBuilder.AddPrimaryKey( + name: "PK_merchantsecurityuser", + table: "merchantsecurityuser", + columns: new[] { "MerchantReportingId", "SecurityUserId" }); + + migrationBuilder.AddPrimaryKey( + name: "PK_merchantoperator", + table: "merchantoperator", + columns: new[] { "MerchantReportingId", "OperatorId" }); + + migrationBuilder.AddPrimaryKey( + name: "PK_merchantdevice", + table: "merchantdevice", + columns: new[] { "MerchantReportingId", "DeviceId" }); + + migrationBuilder.AddPrimaryKey( + name: "PK_MerchantContracts", + table: "MerchantContracts", + columns: new[] { "MerchantReportingId", "ContractReportingId" }); + + migrationBuilder.AddPrimaryKey( + name: "PK_merchantcontact", + table: "merchantcontact", + columns: new[] { "MerchantReportingId", "ContactId" }); + + migrationBuilder.AddPrimaryKey( + name: "PK_merchantaddress", + table: "merchantaddress", + columns: new[] { "MerchantReportingId", "AddressId" }); + + migrationBuilder.AddPrimaryKey( + name: "PK_merchant", + table: "merchant", + columns: new[] { "EstateReportingId", "MerchantReportingId" }); + + migrationBuilder.AddPrimaryKey( + name: "PK_fileline", + table: "fileline", + columns: new[] { "FileReportingId", "LineNumber" }) + .Annotation("SqlServer:Clustered", true); + + migrationBuilder.AddPrimaryKey( + name: "PK_fileimportlogfile", + table: "fileimportlogfile", + columns: new[] { "FileImportLogReportingId", "FileReportingId" }); + + migrationBuilder.AddPrimaryKey( + name: "PK_fileimportlog", + table: "fileimportlog", + columns: new[] { "EstateReportingId", "FileImportLogReportingId" }); + + migrationBuilder.AddPrimaryKey( + name: "PK_estatesecurityuser", + table: "estatesecurityuser", + columns: new[] { "SecurityUserId", "EstateReportingId" }); + + migrationBuilder.AddPrimaryKey( + name: "PK_contractproducttransactionfee", + table: "contractproducttransactionfee", + columns: new[] { "ContractProductReportingId", "TransactionFeeId" }); + + migrationBuilder.AddPrimaryKey( + name: "PK_contractproduct", + table: "contractproduct", + columns: new[] { "ContractReportingId", "ProductId" }); + + migrationBuilder.AddPrimaryKey( + name: "PK_contract", + table: "contract", + columns: new[] { "EstateReportingId", "OperatorId", "ContractId" }); + + migrationBuilder.CreateTable( + name: "estateoperator", + columns: table => new + { + EstateReportingId = table.Column(type: "int", nullable: false), + OperatorReportingId = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_estateoperator", x => new { x.EstateReportingId, x.OperatorReportingId }); + }); + + migrationBuilder.CreateIndex( + name: "IX_voucher_TransactionReportingId", + table: "voucher", + column: "TransactionReportingId"); + + migrationBuilder.CreateIndex( + name: "IX_transaction_TransactionDate_MerchantReportingId", + table: "transaction", + columns: new[] { "TransactionDate", "MerchantReportingId" }) + .Annotation("SqlServer:Clustered", true); + + migrationBuilder.CreateIndex( + name: "IX_transaction_TransactionId_MerchantReportingId", + table: "transaction", + columns: new[] { "TransactionId", "MerchantReportingId" }, + unique: true) + .Annotation("SqlServer:Clustered", false); + + migrationBuilder.CreateIndex( + name: "IX_statementheader_MerchantReportingId_StatementGeneratedDate", + table: "statementheader", + columns: new[] { "MerchantReportingId", "StatementGeneratedDate" }) + .Annotation("SqlServer:Clustered", true); + + migrationBuilder.CreateIndex( + name: "IX_settlement_EstateReportingId_SettlementId", + table: "settlement", + columns: new[] { "EstateReportingId", "SettlementId" }, + unique: true) + .Annotation("SqlServer:Clustered", false); + + migrationBuilder.CreateIndex( + name: "IX_settlement_SettlementDate_EstateReportingId", + table: "settlement", + columns: new[] { "SettlementDate", "EstateReportingId" }) + .Annotation("SqlServer:Clustered", true); + + migrationBuilder.CreateIndex( + name: "IX_reconciliation_TransactionDate_MerchantReportingId", + table: "reconciliation", + columns: new[] { "TransactionDate", "MerchantReportingId" }) + .Annotation("SqlServer:Clustered", true); + + migrationBuilder.CreateIndex( + name: "IX_reconciliation_TransactionId_MerchantReportingId", + table: "reconciliation", + columns: new[] { "TransactionId", "MerchantReportingId" }, + unique: true) + .Annotation("SqlServer:Clustered", false); + + migrationBuilder.CreateIndex( + name: "IX_merchantsettlementfee_TransactionReportingId", + table: "merchantsettlementfee", + column: "TransactionReportingId"); + + migrationBuilder.CreateIndex( + name: "IX_merchant_EstateReportingId_MerchantId", + table: "merchant", + columns: new[] { "EstateReportingId", "MerchantId" }, + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_fileline_TransactionReportingId", + table: "fileline", + column: "TransactionReportingId"); + + migrationBuilder.CreateIndex( + name: "IX_fileimportlog_EstateReportingId_FileImportLogId", + table: "fileimportlog", + columns: new[] { "EstateReportingId", "FileImportLogId" }, + unique: true); + } + } +} diff --git a/TransactionProcessor.Database/Migrations/SqlServer/20240605133603_remove_reportingids_from_transaction_sp1.Designer.cs b/TransactionProcessor.Database/Migrations/SqlServer/20240605133603_remove_reportingids_from_transaction_sp1.Designer.cs new file mode 100644 index 00000000..cb4c0e71 --- /dev/null +++ b/TransactionProcessor.Database/Migrations/SqlServer/20240605133603_remove_reportingids_from_transaction_sp1.Designer.cs @@ -0,0 +1,1114 @@ +// + +#nullable disable + +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using TransactionProcessor.Database.Contexts; + +namespace TransactionProcessor.Database.Migrations.SqlServer +{ + [DbContext(typeof(EstateManagementSqlServerContext))] + [Migration("20240605133603_remove_reportingids_from_transaction_sp1")] + partial class remove_reportingids_from_transaction_sp1 + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.3") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("EstateManagement.Database.Entities.Calendar", b => + { + b.Property("Date") + .HasColumnType("datetime2"); + + b.Property("DayOfWeek") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("DayOfWeekNumber") + .HasColumnType("int"); + + b.Property("DayOfWeekShort") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("MonthNameLong") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("MonthNameShort") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("MonthNumber") + .HasColumnType("int"); + + b.Property("WeekNumber") + .HasColumnType("int"); + + b.Property("WeekNumberString") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Year") + .HasColumnType("int"); + + b.Property("YearWeekNumber") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Date"); + + b.ToTable("calendar"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Contract", b => + { + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("OperatorId") + .HasColumnType("uniqueidentifier"); + + b.Property("ContractId") + .HasColumnType("uniqueidentifier"); + + b.Property("ContractReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("ContractReportingId")); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("EstateId", "OperatorId", "ContractId"); + + b.ToTable("contract"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.ContractProduct", b => + { + b.Property("ContractProductReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("ContractProductReportingId")); + + b.Property("ContractId") + .HasColumnType("uniqueidentifier"); + + b.Property("ContractProductId") + .HasColumnType("uniqueidentifier"); + + b.Property("DisplayText") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ProductName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ProductType") + .HasColumnType("int"); + + b.Property("Value") + .HasColumnType("decimal(18,2)"); + + b.HasKey("ContractProductReportingId"); + + b.HasIndex("ContractProductId", "ContractId") + .IsUnique(); + + b.ToTable("contractproduct"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.ContractProductTransactionFee", b => + { + b.Property("ContractProductTransactionFeeReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("ContractProductTransactionFeeReportingId")); + + b.Property("CalculationType") + .HasColumnType("int"); + + b.Property("ContractProductId") + .HasColumnType("uniqueidentifier"); + + b.Property("ContractProductTransactionFeeId") + .HasColumnType("uniqueidentifier"); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("FeeType") + .HasColumnType("int"); + + b.Property("IsEnabled") + .HasColumnType("bit"); + + b.Property("Value") + .HasColumnType("decimal(18,4)"); + + b.HasKey("ContractProductTransactionFeeReportingId"); + + b.HasIndex("ContractProductTransactionFeeId", "ContractProductId") + .IsUnique(); + + b.ToTable("contractproducttransactionfee"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Estate", b => + { + b.Property("EstateReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("EstateReportingId")); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Reference") + .HasColumnType("nvarchar(max)"); + + b.HasKey("EstateReportingId"); + + b.HasIndex("EstateId") + .IsUnique(); + + b.ToTable("estate"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.EstateSecurityUser", b => + { + b.Property("SecurityUserId") + .HasColumnType("uniqueidentifier"); + + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("EmailAddress") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("SecurityUserId", "EstateId"); + + b.ToTable("estatesecurityuser"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.File", b => + { + b.Property("FileReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("FileReportingId")); + + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("FileId") + .HasColumnType("uniqueidentifier"); + + b.Property("FileImportLogId") + .HasColumnType("uniqueidentifier"); + + b.Property("FileLocation") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("FileProfileId") + .HasColumnType("uniqueidentifier"); + + b.Property("FileReceivedDate") + .HasColumnType("date"); + + b.Property("FileReceivedDateTime") + .HasColumnType("datetime2"); + + b.Property("IsCompleted") + .HasColumnType("bit"); + + b.Property("MerchantId") + .HasColumnType("uniqueidentifier"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("FileReportingId"); + + b.HasIndex("FileId") + .IsUnique(); + + b.ToTable("file"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.FileImportLog", b => + { + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("FileImportLogReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("FileImportLogReportingId")); + + b.Property("FileImportLogId") + .HasColumnType("uniqueidentifier"); + + b.Property("ImportLogDate") + .HasColumnType("date"); + + b.Property("ImportLogDateTime") + .HasColumnType("datetime2"); + + b.HasKey("EstateId", "FileImportLogReportingId"); + + b.HasIndex("EstateId", "FileImportLogId") + .IsUnique(); + + b.ToTable("fileimportlog"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.FileImportLogFile", b => + { + b.Property("FileImportLogId") + .HasColumnType("uniqueidentifier"); + + b.Property("FileId") + .HasColumnType("uniqueidentifier"); + + b.Property("FilePath") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("FileProfileId") + .HasColumnType("uniqueidentifier"); + + b.Property("FileUploadedDate") + .HasColumnType("date"); + + b.Property("FileUploadedDateTime") + .HasColumnType("datetime2"); + + b.Property("MerchantId") + .HasColumnType("uniqueidentifier"); + + b.Property("OriginalFileName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("FileImportLogId", "FileId"); + + b.ToTable("fileimportlogfile"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.FileLine", b => + { + b.Property("FileId") + .HasColumnType("uniqueidentifier"); + + b.Property("LineNumber") + .HasColumnType("int"); + + b.Property("FileLineData") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Status") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("TransactionId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("FileId", "LineNumber"); + + SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("FileId", "LineNumber")); + + b.ToTable("fileline"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Float", b => + { + b.Property("FloatId") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("ContractId") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedDate") + .HasColumnType("date"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("ProductId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("FloatId"); + + SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("FloatId"), false); + + b.HasIndex("CreatedDate"); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("CreatedDate")); + + b.ToTable("Floats"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.FloatActivity", b => + { + b.Property("EventId") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("ActivityDate") + .HasColumnType("date"); + + b.Property("ActivityDateTime") + .HasColumnType("datetime2"); + + b.Property("Amount") + .HasColumnType("decimal(18,2)"); + + b.Property("CostPrice") + .HasColumnType("decimal(18,2)"); + + b.Property("CreditOrDebit") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("FloatId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("EventId"); + + SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("EventId"), false); + + b.HasIndex("ActivityDate"); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("ActivityDate")); + + b.ToTable("FloatActivity"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Merchant", b => + { + b.Property("MerchantReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("MerchantReportingId")); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("LastSaleDate") + .HasColumnType("date"); + + b.Property("LastSaleDateTime") + .HasColumnType("datetime2"); + + b.Property("LastStatementGenerated") + .HasColumnType("datetime2"); + + b.Property("MerchantId") + .HasColumnType("uniqueidentifier"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Reference") + .HasColumnType("nvarchar(max)"); + + b.Property("SettlementSchedule") + .HasColumnType("int"); + + b.HasKey("MerchantReportingId"); + + b.HasIndex("EstateId", "MerchantId") + .IsUnique(); + + b.ToTable("merchant"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantAddress", b => + { + b.Property("MerchantId") + .HasColumnType("uniqueidentifier"); + + b.Property("AddressId") + .HasColumnType("uniqueidentifier"); + + b.Property("AddressLine1") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("AddressLine2") + .HasColumnType("nvarchar(max)"); + + b.Property("AddressLine3") + .HasColumnType("nvarchar(max)"); + + b.Property("AddressLine4") + .HasColumnType("nvarchar(max)"); + + b.Property("Country") + .HasColumnType("nvarchar(max)"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("PostalCode") + .HasColumnType("nvarchar(max)"); + + b.Property("Region") + .HasColumnType("nvarchar(max)"); + + b.Property("Town") + .HasColumnType("nvarchar(max)"); + + b.HasKey("MerchantId", "AddressId"); + + b.ToTable("merchantaddress"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantContact", b => + { + b.Property("MerchantId") + .HasColumnType("uniqueidentifier"); + + b.Property("ContactId") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("EmailAddress") + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("PhoneNumber") + .HasColumnType("nvarchar(max)"); + + b.HasKey("MerchantId", "ContactId"); + + b.ToTable("merchantcontact"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantContract", b => + { + b.Property("MerchantId") + .HasColumnType("uniqueidentifier"); + + b.Property("ContractId") + .HasColumnType("uniqueidentifier"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.HasKey("MerchantId", "ContractId"); + + b.ToTable("MerchantContracts"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantDevice", b => + { + b.Property("MerchantId") + .HasColumnType("uniqueidentifier"); + + b.Property("DeviceId") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("DeviceIdentifier") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("MerchantId", "DeviceId"); + + b.ToTable("merchantdevice"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantOperator", b => + { + b.Property("MerchantId") + .HasColumnType("uniqueidentifier"); + + b.Property("OperatorId") + .HasColumnType("uniqueidentifier"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("MerchantNumber") + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("TerminalNumber") + .HasColumnType("nvarchar(max)"); + + b.HasKey("MerchantId", "OperatorId"); + + b.ToTable("merchantoperator"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantSecurityUser", b => + { + b.Property("MerchantId") + .HasColumnType("uniqueidentifier"); + + b.Property("SecurityUserId") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("EmailAddress") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("MerchantId", "SecurityUserId"); + + b.ToTable("merchantsecurityuser"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantSettlementFee", b => + { + b.Property("SettlementId") + .HasColumnType("uniqueidentifier"); + + b.Property("TransactionId") + .HasColumnType("uniqueidentifier"); + + b.Property("ContractProductTransactionFeeId") + .HasColumnType("uniqueidentifier"); + + b.Property("CalculatedValue") + .HasColumnType("decimal(18,2)"); + + b.Property("FeeCalculatedDateTime") + .HasColumnType("datetime2"); + + b.Property("FeeValue") + .HasColumnType("decimal(18,2)"); + + b.Property("IsSettled") + .HasColumnType("bit"); + + b.Property("MerchantId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("SettlementId", "TransactionId", "ContractProductTransactionFeeId"); + + b.ToTable("merchantsettlementfee"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Operator", b => + { + b.Property("OperatorReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("OperatorReportingId")); + + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("OperatorId") + .HasColumnType("uniqueidentifier"); + + b.Property("RequireCustomMerchantNumber") + .HasColumnType("bit"); + + b.Property("RequireCustomTerminalNumber") + .HasColumnType("bit"); + + b.HasKey("OperatorReportingId"); + + b.HasIndex("OperatorId") + .IsUnique(); + + b.ToTable("operator"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Reconciliation", b => + { + b.Property("TransactionReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("TransactionReportingId")); + + b.Property("DeviceIdentifier") + .HasColumnType("nvarchar(max)"); + + b.Property("IsAuthorised") + .HasColumnType("bit"); + + b.Property("IsCompleted") + .HasColumnType("bit"); + + b.Property("MerchantId") + .HasColumnType("uniqueidentifier"); + + b.Property("ResponseCode") + .HasColumnType("nvarchar(max)"); + + b.Property("ResponseMessage") + .HasColumnType("nvarchar(max)"); + + b.Property("TransactionCount") + .HasColumnType("int"); + + b.Property("TransactionDate") + .HasColumnType("date"); + + b.Property("TransactionDateTime") + .HasColumnType("datetime2"); + + b.Property("TransactionId") + .HasColumnType("uniqueidentifier"); + + b.Property("TransactionTime") + .HasColumnType("time"); + + b.Property("TransactionValue") + .HasColumnType("decimal(18,2)"); + + b.HasKey("TransactionReportingId"); + + SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("TransactionReportingId"), false); + + b.HasIndex("TransactionDate"); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("TransactionDate")); + + b.HasIndex("TransactionId", "MerchantId") + .IsUnique(); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("TransactionId", "MerchantId"), false); + + b.ToTable("reconciliation"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.ResponseCodes", b => + { + b.Property("ResponseCode") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("ResponseCode")); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("ResponseCode"); + + b.ToTable("responsecodes"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Settlement", b => + { + b.Property("SettlementReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("SettlementReportingId")); + + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("IsCompleted") + .HasColumnType("bit"); + + b.Property("MerchantId") + .HasColumnType("uniqueidentifier"); + + b.Property("ProcessingStarted") + .HasColumnType("bit"); + + b.Property("ProcessingStartedDateTIme") + .HasColumnType("datetime2"); + + b.Property("SettlementDate") + .HasColumnType("date"); + + b.Property("SettlementId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("SettlementReportingId"); + + SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("SettlementReportingId"), false); + + b.HasIndex("SettlementDate"); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("SettlementDate")); + + b.HasIndex("EstateId", "SettlementId") + .IsUnique(); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("EstateId", "SettlementId"), false); + + b.ToTable("settlement"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.StatementHeader", b => + { + b.Property("MerchantId") + .HasColumnType("uniqueidentifier"); + + b.Property("StatementId") + .HasColumnType("uniqueidentifier"); + + b.Property("StatementCreatedDate") + .HasColumnType("date"); + + b.Property("StatementCreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("StatementGeneratedDate") + .HasColumnType("date"); + + b.Property("StatementGeneratedDateTime") + .HasColumnType("datetime2"); + + b.Property("StatementReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("StatementReportingId")); + + b.HasKey("MerchantId", "StatementId"); + + SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("MerchantId", "StatementId"), false); + + b.HasIndex("StatementGeneratedDate"); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("StatementGeneratedDate")); + + b.ToTable("statementheader"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.StatementLine", b => + { + b.Property("StatementId") + .HasColumnType("uniqueidentifier"); + + b.Property("TransactionId") + .HasColumnType("uniqueidentifier"); + + b.Property("ActivityDateTime") + .HasColumnType("datetime2"); + + b.Property("ActivityType") + .HasColumnType("int"); + + b.Property("ActivityDate") + .HasColumnType("date"); + + b.Property("ActivityDescription") + .HasColumnType("nvarchar(max)"); + + b.Property("InAmount") + .HasColumnType("decimal(18,2)"); + + b.Property("OutAmount") + .HasColumnType("decimal(18,2)"); + + b.HasKey("StatementId", "TransactionId", "ActivityDateTime", "ActivityType"); + + b.ToTable("statementline"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Transaction", b => + { + b.Property("TransactionReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("TransactionReportingId")); + + b.Property("AuthorisationCode") + .HasColumnType("nvarchar(max)"); + + b.Property("ContractId") + .HasColumnType("uniqueidentifier"); + + b.Property("ContractProductId") + .HasColumnType("uniqueidentifier"); + + b.Property("DeviceIdentifier") + .HasColumnType("nvarchar(max)"); + + b.Property("IsAuthorised") + .HasColumnType("bit"); + + b.Property("IsCompleted") + .HasColumnType("bit"); + + b.Property("MerchantId") + .HasColumnType("uniqueidentifier"); + + b.Property("OperatorId") + .HasColumnType("uniqueidentifier"); + + b.Property("ResponseCode") + .HasColumnType("nvarchar(max)"); + + b.Property("ResponseMessage") + .HasColumnType("nvarchar(max)"); + + b.Property("TransactionAmount") + .HasColumnType("decimal(18,2)"); + + b.Property("TransactionDate") + .HasColumnType("date"); + + b.Property("TransactionDateTime") + .HasColumnType("datetime2"); + + b.Property("TransactionId") + .HasColumnType("uniqueidentifier"); + + b.Property("TransactionNumber") + .HasColumnType("nvarchar(max)"); + + b.Property("TransactionReference") + .HasColumnType("nvarchar(max)"); + + b.Property("TransactionSource") + .HasColumnType("int"); + + b.Property("TransactionTime") + .HasColumnType("time"); + + b.Property("TransactionType") + .HasColumnType("nvarchar(max)"); + + b.HasKey("TransactionReportingId"); + + SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("TransactionReportingId"), false); + + b.HasIndex("TransactionDate"); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("TransactionDate")); + + b.HasIndex("TransactionId") + .IsUnique(); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("TransactionId"), false); + + b.ToTable("transaction"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.TransactionAdditionalRequestData", b => + { + b.Property("TransactionId") + .HasColumnType("uniqueidentifier"); + + b.Property("Amount") + .HasColumnType("nvarchar(max)"); + + b.Property("CustomerAccountNumber") + .HasColumnType("nvarchar(max)"); + + b.HasKey("TransactionId"); + + b.ToTable("transactionadditionalrequestdata"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.TransactionAdditionalResponseData", b => + { + b.Property("TransactionId") + .HasColumnType("uniqueidentifier"); + + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.HasKey("TransactionId"); + + b.ToTable("transactionadditionalresponsedata"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Voucher", b => + { + b.Property("VoucherId") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("ExpiryDate") + .HasColumnType("date"); + + b.Property("ExpiryDateTime") + .HasColumnType("datetime2"); + + b.Property("GenerateDate") + .HasColumnType("date"); + + b.Property("GenerateDateTime") + .HasColumnType("datetime2"); + + b.Property("IsGenerated") + .HasColumnType("bit"); + + b.Property("IsIssued") + .HasColumnType("bit"); + + b.Property("IsRedeemed") + .HasColumnType("bit"); + + b.Property("IssuedDate") + .HasColumnType("date"); + + b.Property("IssuedDateTime") + .HasColumnType("datetime2"); + + b.Property("OperatorIdentifier") + .HasColumnType("nvarchar(max)"); + + b.Property("RecipientEmail") + .HasColumnType("nvarchar(max)"); + + b.Property("RecipientMobile") + .HasColumnType("nvarchar(max)"); + + b.Property("RedeemedDate") + .HasColumnType("datetime2"); + + b.Property("RedeemedDateTime") + .HasColumnType("datetime2"); + + b.Property("TransactionId") + .HasColumnType("uniqueidentifier"); + + b.Property("Value") + .HasColumnType("decimal(18,2)"); + + b.Property("VoucherCode") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.HasKey("VoucherId"); + + b.HasIndex("TransactionId"); + + b.HasIndex("VoucherCode"); + + b.ToTable("voucher"); + }); + + modelBuilder.Entity("EstateManagement.Database.ViewEntities.SettlementView", b => + { + b.Property("Amount") + .HasColumnType("decimal(18,2)"); + + b.Property("CalculatedValue") + .HasColumnType("decimal(18,2)"); + + b.Property("DayOfWeek") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("FeeDescription") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsCompleted") + .HasColumnType("bit"); + + b.Property("IsSettled") + .HasColumnType("bit"); + + b.Property("MerchantId") + .HasColumnType("uniqueidentifier"); + + b.Property("MerchantName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Month") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("MonthNumber") + .HasColumnType("int"); + + b.Property("OperatorIdentifier") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("SettlementDate") + .HasColumnType("datetime2"); + + b.Property("SettlementId") + .HasColumnType("uniqueidentifier"); + + b.Property("TransactionId") + .HasColumnType("uniqueidentifier"); + + b.Property("WeekNumber") + .HasColumnType("int"); + + b.Property("YearNumber") + .HasColumnType("int"); + + b.ToTable((string)null); + + b.ToView("uvwSettlements", (string)null); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/TransactionProcessor.Database/Migrations/SqlServer/20240605133603_remove_reportingids_from_transaction_sp1.cs b/TransactionProcessor.Database/Migrations/SqlServer/20240605133603_remove_reportingids_from_transaction_sp1.cs new file mode 100644 index 00000000..e6dabfc8 --- /dev/null +++ b/TransactionProcessor.Database/Migrations/SqlServer/20240605133603_remove_reportingids_from_transaction_sp1.cs @@ -0,0 +1,28 @@ +#nullable disable + +using Microsoft.EntityFrameworkCore.Migrations; + +namespace TransactionProcessor.Database.Migrations.SqlServer +{ + /// + public partial class remove_reportingids_from_transaction_sp1 : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropIndex( + name: "IX_fileline_TransactionId", + table: "fileline"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateIndex( + name: "IX_fileline_TransactionId", + table: "fileline", + column: "TransactionId", + unique: true); + } + } +} diff --git a/TransactionProcessor.Database/Migrations/SqlServer/20240607093059_summary_first_cut.Designer.cs b/TransactionProcessor.Database/Migrations/SqlServer/20240607093059_summary_first_cut.Designer.cs new file mode 100644 index 00000000..307386ae --- /dev/null +++ b/TransactionProcessor.Database/Migrations/SqlServer/20240607093059_summary_first_cut.Designer.cs @@ -0,0 +1,1320 @@ +// + +#nullable disable + +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using TransactionProcessor.Database.Contexts; + +namespace TransactionProcessor.Database.Migrations.SqlServer +{ + [DbContext(typeof(EstateManagementSqlServerContext))] + [Migration("20240607093059_summary_first_cut")] + partial class summary_first_cut + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.3") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("EstateManagement.Database.Entities.Calendar", b => + { + b.Property("Date") + .HasColumnType("datetime2"); + + b.Property("DayOfWeek") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("DayOfWeekNumber") + .HasColumnType("int"); + + b.Property("DayOfWeekShort") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("MonthNameLong") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("MonthNameShort") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("MonthNumber") + .HasColumnType("int"); + + b.Property("WeekNumber") + .HasColumnType("int"); + + b.Property("WeekNumberString") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Year") + .HasColumnType("int"); + + b.Property("YearWeekNumber") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Date"); + + b.ToTable("calendar"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Contract", b => + { + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("OperatorId") + .HasColumnType("uniqueidentifier"); + + b.Property("ContractId") + .HasColumnType("uniqueidentifier"); + + b.Property("ContractReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("ContractReportingId")); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("EstateId", "OperatorId", "ContractId"); + + b.ToTable("contract"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.ContractProduct", b => + { + b.Property("ContractProductReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("ContractProductReportingId")); + + b.Property("ContractId") + .HasColumnType("uniqueidentifier"); + + b.Property("ContractProductId") + .HasColumnType("uniqueidentifier"); + + b.Property("DisplayText") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ProductName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ProductType") + .HasColumnType("int"); + + b.Property("Value") + .HasColumnType("decimal(18,2)"); + + b.HasKey("ContractProductReportingId"); + + b.HasIndex("ContractProductId", "ContractId") + .IsUnique(); + + b.ToTable("contractproduct"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.ContractProductTransactionFee", b => + { + b.Property("ContractProductTransactionFeeReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("ContractProductTransactionFeeReportingId")); + + b.Property("CalculationType") + .HasColumnType("int"); + + b.Property("ContractProductId") + .HasColumnType("uniqueidentifier"); + + b.Property("ContractProductTransactionFeeId") + .HasColumnType("uniqueidentifier"); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("FeeType") + .HasColumnType("int"); + + b.Property("IsEnabled") + .HasColumnType("bit"); + + b.Property("Value") + .HasColumnType("decimal(18,4)"); + + b.HasKey("ContractProductTransactionFeeReportingId"); + + b.HasIndex("ContractProductTransactionFeeId", "ContractProductId") + .IsUnique(); + + b.ToTable("contractproducttransactionfee"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Estate", b => + { + b.Property("EstateReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("EstateReportingId")); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Reference") + .HasColumnType("nvarchar(max)"); + + b.HasKey("EstateReportingId"); + + b.HasIndex("EstateId") + .IsUnique(); + + b.ToTable("estate"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.EstateSecurityUser", b => + { + b.Property("SecurityUserId") + .HasColumnType("uniqueidentifier"); + + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("EmailAddress") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("SecurityUserId", "EstateId"); + + b.ToTable("estatesecurityuser"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.File", b => + { + b.Property("FileReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("FileReportingId")); + + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("FileId") + .HasColumnType("uniqueidentifier"); + + b.Property("FileImportLogId") + .HasColumnType("uniqueidentifier"); + + b.Property("FileLocation") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("FileProfileId") + .HasColumnType("uniqueidentifier"); + + b.Property("FileReceivedDate") + .HasColumnType("date"); + + b.Property("FileReceivedDateTime") + .HasColumnType("datetime2"); + + b.Property("IsCompleted") + .HasColumnType("bit"); + + b.Property("MerchantId") + .HasColumnType("uniqueidentifier"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("FileReportingId"); + + b.HasIndex("FileId") + .IsUnique(); + + b.ToTable("file"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.FileImportLog", b => + { + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("FileImportLogReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("FileImportLogReportingId")); + + b.Property("FileImportLogId") + .HasColumnType("uniqueidentifier"); + + b.Property("ImportLogDate") + .HasColumnType("date"); + + b.Property("ImportLogDateTime") + .HasColumnType("datetime2"); + + b.HasKey("EstateId", "FileImportLogReportingId"); + + b.HasIndex("EstateId", "FileImportLogId") + .IsUnique(); + + b.ToTable("fileimportlog"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.FileImportLogFile", b => + { + b.Property("FileImportLogId") + .HasColumnType("uniqueidentifier"); + + b.Property("FileId") + .HasColumnType("uniqueidentifier"); + + b.Property("FilePath") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("FileProfileId") + .HasColumnType("uniqueidentifier"); + + b.Property("FileUploadedDate") + .HasColumnType("date"); + + b.Property("FileUploadedDateTime") + .HasColumnType("datetime2"); + + b.Property("MerchantId") + .HasColumnType("uniqueidentifier"); + + b.Property("OriginalFileName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("FileImportLogId", "FileId"); + + b.ToTable("fileimportlogfile"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.FileLine", b => + { + b.Property("FileId") + .HasColumnType("uniqueidentifier"); + + b.Property("LineNumber") + .HasColumnType("int"); + + b.Property("FileLineData") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Status") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("TransactionId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("FileId", "LineNumber"); + + SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("FileId", "LineNumber")); + + b.ToTable("fileline"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Float", b => + { + b.Property("FloatId") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("ContractId") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedDate") + .HasColumnType("date"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("ProductId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("FloatId"); + + SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("FloatId"), false); + + b.HasIndex("CreatedDate"); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("CreatedDate")); + + b.ToTable("Floats"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.FloatActivity", b => + { + b.Property("EventId") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("ActivityDate") + .HasColumnType("date"); + + b.Property("ActivityDateTime") + .HasColumnType("datetime2"); + + b.Property("Amount") + .HasColumnType("decimal(18,2)"); + + b.Property("CostPrice") + .HasColumnType("decimal(18,2)"); + + b.Property("CreditOrDebit") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("FloatId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("EventId"); + + SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("EventId"), false); + + b.HasIndex("ActivityDate"); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("ActivityDate")); + + b.ToTable("FloatActivity"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Merchant", b => + { + b.Property("MerchantReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("MerchantReportingId")); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("LastSaleDate") + .HasColumnType("date"); + + b.Property("LastSaleDateTime") + .HasColumnType("datetime2"); + + b.Property("LastStatementGenerated") + .HasColumnType("datetime2"); + + b.Property("MerchantId") + .HasColumnType("uniqueidentifier"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Reference") + .HasColumnType("nvarchar(max)"); + + b.Property("SettlementSchedule") + .HasColumnType("int"); + + b.HasKey("MerchantReportingId"); + + b.HasIndex("EstateId", "MerchantId") + .IsUnique(); + + b.ToTable("merchant"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantAddress", b => + { + b.Property("MerchantId") + .HasColumnType("uniqueidentifier"); + + b.Property("AddressId") + .HasColumnType("uniqueidentifier"); + + b.Property("AddressLine1") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("AddressLine2") + .HasColumnType("nvarchar(max)"); + + b.Property("AddressLine3") + .HasColumnType("nvarchar(max)"); + + b.Property("AddressLine4") + .HasColumnType("nvarchar(max)"); + + b.Property("Country") + .HasColumnType("nvarchar(max)"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("PostalCode") + .HasColumnType("nvarchar(max)"); + + b.Property("Region") + .HasColumnType("nvarchar(max)"); + + b.Property("Town") + .HasColumnType("nvarchar(max)"); + + b.HasKey("MerchantId", "AddressId"); + + b.ToTable("merchantaddress"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantContact", b => + { + b.Property("MerchantId") + .HasColumnType("uniqueidentifier"); + + b.Property("ContactId") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("EmailAddress") + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("PhoneNumber") + .HasColumnType("nvarchar(max)"); + + b.HasKey("MerchantId", "ContactId"); + + b.ToTable("merchantcontact"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantContract", b => + { + b.Property("MerchantId") + .HasColumnType("uniqueidentifier"); + + b.Property("ContractId") + .HasColumnType("uniqueidentifier"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.HasKey("MerchantId", "ContractId"); + + b.ToTable("MerchantContracts"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantDevice", b => + { + b.Property("MerchantId") + .HasColumnType("uniqueidentifier"); + + b.Property("DeviceId") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("DeviceIdentifier") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("MerchantId", "DeviceId"); + + b.ToTable("merchantdevice"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantOperator", b => + { + b.Property("MerchantId") + .HasColumnType("uniqueidentifier"); + + b.Property("OperatorId") + .HasColumnType("uniqueidentifier"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("MerchantNumber") + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("TerminalNumber") + .HasColumnType("nvarchar(max)"); + + b.HasKey("MerchantId", "OperatorId"); + + b.ToTable("merchantoperator"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantSecurityUser", b => + { + b.Property("MerchantId") + .HasColumnType("uniqueidentifier"); + + b.Property("SecurityUserId") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("EmailAddress") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("MerchantId", "SecurityUserId"); + + b.ToTable("merchantsecurityuser"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantSettlementFee", b => + { + b.Property("SettlementId") + .HasColumnType("uniqueidentifier"); + + b.Property("TransactionId") + .HasColumnType("uniqueidentifier"); + + b.Property("ContractProductTransactionFeeId") + .HasColumnType("uniqueidentifier"); + + b.Property("CalculatedValue") + .HasColumnType("decimal(18,2)"); + + b.Property("FeeCalculatedDateTime") + .HasColumnType("datetime2"); + + b.Property("FeeValue") + .HasColumnType("decimal(18,2)"); + + b.Property("IsSettled") + .HasColumnType("bit"); + + b.Property("MerchantId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("SettlementId", "TransactionId", "ContractProductTransactionFeeId"); + + b.ToTable("merchantsettlementfee"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Operator", b => + { + b.Property("OperatorReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("OperatorReportingId")); + + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("OperatorId") + .HasColumnType("uniqueidentifier"); + + b.Property("RequireCustomMerchantNumber") + .HasColumnType("bit"); + + b.Property("RequireCustomTerminalNumber") + .HasColumnType("bit"); + + b.HasKey("OperatorReportingId"); + + b.HasIndex("OperatorId") + .IsUnique(); + + b.ToTable("operator"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Reconciliation", b => + { + b.Property("TransactionReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("TransactionReportingId")); + + b.Property("DeviceIdentifier") + .HasColumnType("nvarchar(max)"); + + b.Property("IsAuthorised") + .HasColumnType("bit"); + + b.Property("IsCompleted") + .HasColumnType("bit"); + + b.Property("MerchantId") + .HasColumnType("uniqueidentifier"); + + b.Property("ResponseCode") + .HasColumnType("nvarchar(max)"); + + b.Property("ResponseMessage") + .HasColumnType("nvarchar(max)"); + + b.Property("TransactionCount") + .HasColumnType("int"); + + b.Property("TransactionDate") + .HasColumnType("date"); + + b.Property("TransactionDateTime") + .HasColumnType("datetime2"); + + b.Property("TransactionId") + .HasColumnType("uniqueidentifier"); + + b.Property("TransactionTime") + .HasColumnType("time"); + + b.Property("TransactionValue") + .HasColumnType("decimal(18,2)"); + + b.HasKey("TransactionReportingId"); + + SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("TransactionReportingId"), false); + + b.HasIndex("TransactionDate"); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("TransactionDate")); + + b.HasIndex("TransactionId", "MerchantId") + .IsUnique(); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("TransactionId", "MerchantId"), false); + + b.ToTable("reconciliation"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.ResponseCodes", b => + { + b.Property("ResponseCode") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("ResponseCode")); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("ResponseCode"); + + b.ToTable("responsecodes"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Settlement", b => + { + b.Property("SettlementReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("SettlementReportingId")); + + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("IsCompleted") + .HasColumnType("bit"); + + b.Property("MerchantId") + .HasColumnType("uniqueidentifier"); + + b.Property("ProcessingStarted") + .HasColumnType("bit"); + + b.Property("ProcessingStartedDateTIme") + .HasColumnType("datetime2"); + + b.Property("SettlementDate") + .HasColumnType("date"); + + b.Property("SettlementId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("SettlementReportingId"); + + SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("SettlementReportingId"), false); + + b.HasIndex("SettlementDate"); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("SettlementDate")); + + b.HasIndex("EstateId", "SettlementId") + .IsUnique(); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("EstateId", "SettlementId"), false); + + b.ToTable("settlement"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.StatementHeader", b => + { + b.Property("MerchantId") + .HasColumnType("uniqueidentifier"); + + b.Property("StatementId") + .HasColumnType("uniqueidentifier"); + + b.Property("StatementCreatedDate") + .HasColumnType("date"); + + b.Property("StatementCreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("StatementGeneratedDate") + .HasColumnType("date"); + + b.Property("StatementGeneratedDateTime") + .HasColumnType("datetime2"); + + b.Property("StatementReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("StatementReportingId")); + + b.HasKey("MerchantId", "StatementId"); + + SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("MerchantId", "StatementId"), false); + + b.HasIndex("StatementGeneratedDate"); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("StatementGeneratedDate")); + + b.ToTable("statementheader"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.StatementLine", b => + { + b.Property("StatementId") + .HasColumnType("uniqueidentifier"); + + b.Property("TransactionId") + .HasColumnType("uniqueidentifier"); + + b.Property("ActivityDateTime") + .HasColumnType("datetime2"); + + b.Property("ActivityType") + .HasColumnType("int"); + + b.Property("ActivityDate") + .HasColumnType("date"); + + b.Property("ActivityDescription") + .HasColumnType("nvarchar(max)"); + + b.Property("InAmount") + .HasColumnType("decimal(18,2)"); + + b.Property("OutAmount") + .HasColumnType("decimal(18,2)"); + + b.HasKey("StatementId", "TransactionId", "ActivityDateTime", "ActivityType"); + + b.ToTable("statementline"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Summary.SettlementSummary", b => + { + b.Property("ContractProductReportingId") + .HasColumnType("int"); + + b.Property("FeeCount") + .HasColumnType("int"); + + b.Property("FeeValue") + .HasColumnType("decimal(18,2)"); + + b.Property("IsCompleted") + .HasColumnType("bit"); + + b.Property("IsSettled") + .HasColumnType("bit"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("OperatorReportingId") + .HasColumnType("int"); + + b.Property("SalesCount") + .HasColumnType("int"); + + b.Property("SalesValue") + .HasColumnType("decimal(18,2)"); + + b.Property("SettlementDate") + .HasColumnType("date"); + + b.HasIndex("SettlementDate"); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("SettlementDate")); + + b.HasIndex("SettlementDate", "MerchantReportingId", "OperatorReportingId", "ContractProductReportingId", "IsCompleted", "IsSettled") + .IsUnique(); + + b.ToTable("SettlementSummary"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Summary.TodayTransaction", b => + { + b.Property("AuthorisationCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ContractProductReportingId") + .HasColumnType("int"); + + b.Property("ContractReportingId") + .HasColumnType("int"); + + b.Property("DeviceIdentifier") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Hour") + .HasColumnType("int"); + + b.Property("IsAuthorised") + .HasColumnType("bit"); + + b.Property("IsCompleted") + .HasColumnType("bit"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("OperatorReportingId") + .HasColumnType("int"); + + b.Property("ResponseCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ResponseMessage") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("TransactionAmount") + .HasColumnType("decimal(18,2)"); + + b.Property("TransactionDate") + .HasColumnType("date"); + + b.Property("TransactionDateTime") + .HasColumnType("datetime2"); + + b.Property("TransactionId") + .HasColumnType("uniqueidentifier"); + + b.Property("TransactionNumber") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("TransactionReference") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.Property("TransactionSource") + .HasColumnType("int"); + + b.Property("TransactionTime") + .HasColumnType("time"); + + b.Property("TransactionType") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasIndex("TransactionDate"); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("TransactionDate")); + + b.HasIndex("TransactionId") + .IsUnique(); + + b.ToTable("TodayTransactions"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Summary.TransactionHistory", b => + { + b.Property("AuthorisationCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ContractProductReportingId") + .HasColumnType("int"); + + b.Property("ContractReportingId") + .HasColumnType("int"); + + b.Property("DeviceIdentifier") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Hour") + .HasColumnType("int"); + + b.Property("IsAuthorised") + .HasColumnType("bit"); + + b.Property("IsCompleted") + .HasColumnType("bit"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("OperatorReportingId") + .HasColumnType("int"); + + b.Property("ResponseCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ResponseMessage") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("TransactionAmount") + .HasColumnType("decimal(18,2)"); + + b.Property("TransactionDate") + .HasColumnType("date"); + + b.Property("TransactionDateTime") + .HasColumnType("datetime2"); + + b.Property("TransactionId") + .HasColumnType("uniqueidentifier"); + + b.Property("TransactionNumber") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("TransactionReference") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.Property("TransactionSource") + .HasColumnType("int"); + + b.Property("TransactionTime") + .HasColumnType("time"); + + b.Property("TransactionType") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasIndex("TransactionDate"); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("TransactionDate")); + + b.HasIndex("TransactionId") + .IsUnique(); + + b.ToTable("TransactionHistory"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Transaction", b => + { + b.Property("TransactionReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("TransactionReportingId")); + + b.Property("AuthorisationCode") + .HasColumnType("nvarchar(max)"); + + b.Property("ContractId") + .HasColumnType("uniqueidentifier"); + + b.Property("ContractProductId") + .HasColumnType("uniqueidentifier"); + + b.Property("DeviceIdentifier") + .HasColumnType("nvarchar(max)"); + + b.Property("IsAuthorised") + .HasColumnType("bit"); + + b.Property("IsCompleted") + .HasColumnType("bit"); + + b.Property("MerchantId") + .HasColumnType("uniqueidentifier"); + + b.Property("OperatorId") + .HasColumnType("uniqueidentifier"); + + b.Property("ResponseCode") + .HasColumnType("nvarchar(max)"); + + b.Property("ResponseMessage") + .HasColumnType("nvarchar(max)"); + + b.Property("TransactionAmount") + .HasColumnType("decimal(18,2)"); + + b.Property("TransactionDate") + .HasColumnType("date"); + + b.Property("TransactionDateTime") + .HasColumnType("datetime2"); + + b.Property("TransactionId") + .HasColumnType("uniqueidentifier"); + + b.Property("TransactionNumber") + .HasColumnType("nvarchar(max)"); + + b.Property("TransactionReference") + .HasColumnType("nvarchar(max)"); + + b.Property("TransactionSource") + .HasColumnType("int"); + + b.Property("TransactionTime") + .HasColumnType("time"); + + b.Property("TransactionType") + .HasColumnType("nvarchar(max)"); + + b.HasKey("TransactionReportingId"); + + SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("TransactionReportingId"), false); + + b.HasIndex("TransactionDate"); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("TransactionDate")); + + b.HasIndex("TransactionId") + .IsUnique(); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("TransactionId"), false); + + b.ToTable("transaction"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.TransactionAdditionalRequestData", b => + { + b.Property("TransactionId") + .HasColumnType("uniqueidentifier"); + + b.Property("Amount") + .HasColumnType("nvarchar(max)"); + + b.Property("CustomerAccountNumber") + .HasColumnType("nvarchar(max)"); + + b.HasKey("TransactionId"); + + b.ToTable("transactionadditionalrequestdata"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.TransactionAdditionalResponseData", b => + { + b.Property("TransactionId") + .HasColumnType("uniqueidentifier"); + + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.HasKey("TransactionId"); + + b.ToTable("transactionadditionalresponsedata"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Voucher", b => + { + b.Property("VoucherId") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("ExpiryDate") + .HasColumnType("date"); + + b.Property("ExpiryDateTime") + .HasColumnType("datetime2"); + + b.Property("GenerateDate") + .HasColumnType("date"); + + b.Property("GenerateDateTime") + .HasColumnType("datetime2"); + + b.Property("IsGenerated") + .HasColumnType("bit"); + + b.Property("IsIssued") + .HasColumnType("bit"); + + b.Property("IsRedeemed") + .HasColumnType("bit"); + + b.Property("IssuedDate") + .HasColumnType("date"); + + b.Property("IssuedDateTime") + .HasColumnType("datetime2"); + + b.Property("OperatorIdentifier") + .HasColumnType("nvarchar(max)"); + + b.Property("RecipientEmail") + .HasColumnType("nvarchar(max)"); + + b.Property("RecipientMobile") + .HasColumnType("nvarchar(max)"); + + b.Property("RedeemedDate") + .HasColumnType("datetime2"); + + b.Property("RedeemedDateTime") + .HasColumnType("datetime2"); + + b.Property("TransactionId") + .HasColumnType("uniqueidentifier"); + + b.Property("Value") + .HasColumnType("decimal(18,2)"); + + b.Property("VoucherCode") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.HasKey("VoucherId"); + + b.HasIndex("TransactionId"); + + b.HasIndex("VoucherCode"); + + b.ToTable("voucher"); + }); + + modelBuilder.Entity("EstateManagement.Database.ViewEntities.SettlementView", b => + { + b.Property("Amount") + .HasColumnType("decimal(18,2)"); + + b.Property("CalculatedValue") + .HasColumnType("decimal(18,2)"); + + b.Property("DayOfWeek") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("FeeDescription") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsCompleted") + .HasColumnType("bit"); + + b.Property("IsSettled") + .HasColumnType("bit"); + + b.Property("MerchantId") + .HasColumnType("uniqueidentifier"); + + b.Property("MerchantName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Month") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("MonthNumber") + .HasColumnType("int"); + + b.Property("OperatorIdentifier") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("SettlementDate") + .HasColumnType("datetime2"); + + b.Property("SettlementId") + .HasColumnType("uniqueidentifier"); + + b.Property("TransactionId") + .HasColumnType("uniqueidentifier"); + + b.Property("WeekNumber") + .HasColumnType("int"); + + b.Property("YearNumber") + .HasColumnType("int"); + + b.ToTable((string)null); + + b.ToView("uvwSettlements", (string)null); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/TransactionProcessor.Database/Migrations/SqlServer/20240607093059_summary_first_cut.cs b/TransactionProcessor.Database/Migrations/SqlServer/20240607093059_summary_first_cut.cs new file mode 100644 index 00000000..45a13cdc --- /dev/null +++ b/TransactionProcessor.Database/Migrations/SqlServer/20240607093059_summary_first_cut.cs @@ -0,0 +1,142 @@ +#nullable disable + +using Microsoft.EntityFrameworkCore.Migrations; + +namespace TransactionProcessor.Database.Migrations.SqlServer +{ + /// + public partial class summary_first_cut : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "SettlementSummary", + columns: table => new + { + IsCompleted = table.Column(type: "bit", nullable: false), + IsSettled = table.Column(type: "bit", nullable: false), + SettlementDate = table.Column(type: "date", nullable: false), + MerchantReportingId = table.Column(type: "int", nullable: false), + OperatorReportingId = table.Column(type: "int", nullable: false), + ContractProductReportingId = table.Column(type: "int", nullable: false), + SalesValue = table.Column(type: "decimal(18,2)", nullable: true), + FeeValue = table.Column(type: "decimal(18,2)", nullable: true), + SalesCount = table.Column(type: "int", nullable: true), + FeeCount = table.Column(type: "int", nullable: true) + }, + constraints: table => + { + }); + + migrationBuilder.CreateTable( + name: "TodayTransactions", + columns: table => new + { + MerchantReportingId = table.Column(type: "int", nullable: false), + ContractProductReportingId = table.Column(type: "int", nullable: false), + ContractReportingId = table.Column(type: "int", nullable: false), + OperatorReportingId = table.Column(type: "int", nullable: false), + TransactionId = table.Column(type: "uniqueidentifier", nullable: false), + AuthorisationCode = table.Column(type: "nvarchar(max)", nullable: false), + DeviceIdentifier = table.Column(type: "nvarchar(max)", nullable: false), + IsAuthorised = table.Column(type: "bit", nullable: false), + IsCompleted = table.Column(type: "bit", nullable: false), + ResponseCode = table.Column(type: "nvarchar(max)", nullable: false), + ResponseMessage = table.Column(type: "nvarchar(max)", nullable: false), + TransactionDate = table.Column(type: "date", nullable: false), + TransactionDateTime = table.Column(type: "datetime2", nullable: false), + TransactionNumber = table.Column(type: "nvarchar(max)", nullable: false), + TransactionReference = table.Column(type: "nvarchar(max)", nullable: false), + TransactionTime = table.Column(type: "time", nullable: false), + TransactionSource = table.Column(type: "int", nullable: false), + TransactionType = table.Column(type: "nvarchar(max)", nullable: false), + TransactionReportingId = table.Column(type: "int", nullable: false), + TransactionAmount = table.Column(type: "decimal(18,2)", nullable: false), + Hour = table.Column(type: "int", nullable: true) + }, + constraints: table => + { + }); + + migrationBuilder.CreateTable( + name: "TransactionHistory", + columns: table => new + { + MerchantReportingId = table.Column(type: "int", nullable: false), + ContractProductReportingId = table.Column(type: "int", nullable: false), + ContractReportingId = table.Column(type: "int", nullable: false), + OperatorReportingId = table.Column(type: "int", nullable: false), + TransactionId = table.Column(type: "uniqueidentifier", nullable: false), + AuthorisationCode = table.Column(type: "nvarchar(max)", nullable: false), + DeviceIdentifier = table.Column(type: "nvarchar(max)", nullable: false), + IsAuthorised = table.Column(type: "bit", nullable: false), + IsCompleted = table.Column(type: "bit", nullable: false), + ResponseCode = table.Column(type: "nvarchar(max)", nullable: false), + ResponseMessage = table.Column(type: "nvarchar(max)", nullable: false), + TransactionDate = table.Column(type: "date", nullable: false), + TransactionDateTime = table.Column(type: "datetime2", nullable: false), + TransactionNumber = table.Column(type: "nvarchar(max)", nullable: false), + TransactionReference = table.Column(type: "nvarchar(max)", nullable: false), + TransactionTime = table.Column(type: "time", nullable: false), + TransactionSource = table.Column(type: "int", nullable: false), + TransactionType = table.Column(type: "nvarchar(max)", nullable: false), + TransactionReportingId = table.Column(type: "int", nullable: false), + TransactionAmount = table.Column(type: "decimal(18,2)", nullable: false), + Hour = table.Column(type: "int", nullable: true) + }, + constraints: table => + { + }); + + migrationBuilder.CreateIndex( + name: "IX_SettlementSummary_SettlementDate", + table: "SettlementSummary", + column: "SettlementDate") + .Annotation("SqlServer:Clustered", true); + + migrationBuilder.CreateIndex( + name: "IX_SettlementSummary_SettlementDate_MerchantReportingId_OperatorReportingId_ContractProductReportingId_IsCompleted_IsSettled", + table: "SettlementSummary", + columns: new[] { "SettlementDate", "MerchantReportingId", "OperatorReportingId", "ContractProductReportingId", "IsCompleted", "IsSettled" }, + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_TodayTransactions_TransactionDate", + table: "TodayTransactions", + column: "TransactionDate") + .Annotation("SqlServer:Clustered", true); + + migrationBuilder.CreateIndex( + name: "IX_TodayTransactions_TransactionId", + table: "TodayTransactions", + column: "TransactionId", + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_TransactionHistory_TransactionDate", + table: "TransactionHistory", + column: "TransactionDate") + .Annotation("SqlServer:Clustered", true); + + migrationBuilder.CreateIndex( + name: "IX_TransactionHistory_TransactionId", + table: "TransactionHistory", + column: "TransactionId", + unique: true); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "SettlementSummary"); + + migrationBuilder.DropTable( + name: "TodayTransactions"); + + migrationBuilder.DropTable( + name: "TransactionHistory"); + } + } +} diff --git a/TransactionProcessor.Database/Migrations/SqlServer/EstateManagementSqlServerContextModelSnapshot.cs b/TransactionProcessor.Database/Migrations/SqlServer/EstateManagementSqlServerContextModelSnapshot.cs new file mode 100644 index 00000000..0f45b6f2 --- /dev/null +++ b/TransactionProcessor.Database/Migrations/SqlServer/EstateManagementSqlServerContextModelSnapshot.cs @@ -0,0 +1,1319 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using TransactionProcessor.Database.Contexts; + +#nullable disable + +namespace EstateManagement.Database.Migrations.SqlServer +{ + [DbContext(typeof(EstateManagementSqlServerContext))] + partial class EstateManagementSqlServerContextModelSnapshot : ModelSnapshot + { + protected override void BuildModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.3") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("EstateManagement.Database.Entities.Calendar", b => + { + b.Property("Date") + .HasColumnType("datetime2"); + + b.Property("DayOfWeek") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("DayOfWeekNumber") + .HasColumnType("int"); + + b.Property("DayOfWeekShort") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("MonthNameLong") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("MonthNameShort") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("MonthNumber") + .HasColumnType("int"); + + b.Property("WeekNumber") + .HasColumnType("int"); + + b.Property("WeekNumberString") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Year") + .HasColumnType("int"); + + b.Property("YearWeekNumber") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Date"); + + b.ToTable("calendar"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Contract", b => + { + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("OperatorId") + .HasColumnType("uniqueidentifier"); + + b.Property("ContractId") + .HasColumnType("uniqueidentifier"); + + b.Property("ContractReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("ContractReportingId")); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("EstateId", "OperatorId", "ContractId"); + + b.ToTable("contract"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.ContractProduct", b => + { + b.Property("ContractProductReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("ContractProductReportingId")); + + b.Property("ContractId") + .HasColumnType("uniqueidentifier"); + + b.Property("ContractProductId") + .HasColumnType("uniqueidentifier"); + + b.Property("DisplayText") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ProductName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ProductType") + .HasColumnType("int"); + + b.Property("Value") + .HasColumnType("decimal(18,2)"); + + b.HasKey("ContractProductReportingId"); + + b.HasIndex("ContractProductId", "ContractId") + .IsUnique(); + + b.ToTable("contractproduct"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.ContractProductTransactionFee", b => + { + b.Property("ContractProductTransactionFeeReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("ContractProductTransactionFeeReportingId")); + + b.Property("CalculationType") + .HasColumnType("int"); + + b.Property("ContractProductId") + .HasColumnType("uniqueidentifier"); + + b.Property("ContractProductTransactionFeeId") + .HasColumnType("uniqueidentifier"); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("FeeType") + .HasColumnType("int"); + + b.Property("IsEnabled") + .HasColumnType("bit"); + + b.Property("Value") + .HasColumnType("decimal(18,4)"); + + b.HasKey("ContractProductTransactionFeeReportingId"); + + b.HasIndex("ContractProductTransactionFeeId", "ContractProductId") + .IsUnique(); + + b.ToTable("contractproducttransactionfee"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Estate", b => + { + b.Property("EstateReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("EstateReportingId")); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Reference") + .HasColumnType("nvarchar(max)"); + + b.HasKey("EstateReportingId"); + + b.HasIndex("EstateId") + .IsUnique(); + + b.ToTable("estate"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.EstateSecurityUser", b => + { + b.Property("SecurityUserId") + .HasColumnType("uniqueidentifier"); + + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("EmailAddress") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("SecurityUserId", "EstateId"); + + b.ToTable("estatesecurityuser"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.File", b => + { + b.Property("FileReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("FileReportingId")); + + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("FileId") + .HasColumnType("uniqueidentifier"); + + b.Property("FileImportLogId") + .HasColumnType("uniqueidentifier"); + + b.Property("FileLocation") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("FileProfileId") + .HasColumnType("uniqueidentifier"); + + b.Property("FileReceivedDate") + .HasColumnType("date"); + + b.Property("FileReceivedDateTime") + .HasColumnType("datetime2"); + + b.Property("IsCompleted") + .HasColumnType("bit"); + + b.Property("MerchantId") + .HasColumnType("uniqueidentifier"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("FileReportingId"); + + b.HasIndex("FileId") + .IsUnique(); + + b.ToTable("file"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.FileImportLog", b => + { + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("FileImportLogReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("FileImportLogReportingId")); + + b.Property("FileImportLogId") + .HasColumnType("uniqueidentifier"); + + b.Property("ImportLogDate") + .HasColumnType("date"); + + b.Property("ImportLogDateTime") + .HasColumnType("datetime2"); + + b.HasKey("EstateId", "FileImportLogReportingId"); + + b.HasIndex("EstateId", "FileImportLogId") + .IsUnique(); + + b.ToTable("fileimportlog"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.FileImportLogFile", b => + { + b.Property("FileImportLogId") + .HasColumnType("uniqueidentifier"); + + b.Property("FileId") + .HasColumnType("uniqueidentifier"); + + b.Property("FilePath") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("FileProfileId") + .HasColumnType("uniqueidentifier"); + + b.Property("FileUploadedDate") + .HasColumnType("date"); + + b.Property("FileUploadedDateTime") + .HasColumnType("datetime2"); + + b.Property("MerchantId") + .HasColumnType("uniqueidentifier"); + + b.Property("OriginalFileName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("FileImportLogId", "FileId"); + + b.ToTable("fileimportlogfile"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.FileLine", b => + { + b.Property("FileId") + .HasColumnType("uniqueidentifier"); + + b.Property("LineNumber") + .HasColumnType("int"); + + b.Property("FileLineData") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Status") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("TransactionId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("FileId", "LineNumber"); + + SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("FileId", "LineNumber")); + + b.ToTable("fileline"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Float", b => + { + b.Property("FloatId") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("ContractId") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedDate") + .HasColumnType("date"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("ProductId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("FloatId"); + + SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("FloatId"), false); + + b.HasIndex("CreatedDate"); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("CreatedDate")); + + b.ToTable("Floats"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.FloatActivity", b => + { + b.Property("EventId") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("ActivityDate") + .HasColumnType("date"); + + b.Property("ActivityDateTime") + .HasColumnType("datetime2"); + + b.Property("Amount") + .HasColumnType("decimal(18,2)"); + + b.Property("CostPrice") + .HasColumnType("decimal(18,2)"); + + b.Property("CreditOrDebit") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("FloatId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("EventId"); + + SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("EventId"), false); + + b.HasIndex("ActivityDate"); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("ActivityDate")); + + b.ToTable("FloatActivity"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Merchant", b => + { + b.Property("MerchantReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("MerchantReportingId")); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("LastSaleDate") + .HasColumnType("date"); + + b.Property("LastSaleDateTime") + .HasColumnType("datetime2"); + + b.Property("LastStatementGenerated") + .HasColumnType("datetime2"); + + b.Property("MerchantId") + .HasColumnType("uniqueidentifier"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Reference") + .HasColumnType("nvarchar(max)"); + + b.Property("SettlementSchedule") + .HasColumnType("int"); + + b.HasKey("MerchantReportingId"); + + b.HasIndex("EstateId", "MerchantId") + .IsUnique(); + + b.ToTable("merchant"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantAddress", b => + { + b.Property("MerchantId") + .HasColumnType("uniqueidentifier"); + + b.Property("AddressId") + .HasColumnType("uniqueidentifier"); + + b.Property("AddressLine1") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("AddressLine2") + .HasColumnType("nvarchar(max)"); + + b.Property("AddressLine3") + .HasColumnType("nvarchar(max)"); + + b.Property("AddressLine4") + .HasColumnType("nvarchar(max)"); + + b.Property("Country") + .HasColumnType("nvarchar(max)"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("PostalCode") + .HasColumnType("nvarchar(max)"); + + b.Property("Region") + .HasColumnType("nvarchar(max)"); + + b.Property("Town") + .HasColumnType("nvarchar(max)"); + + b.HasKey("MerchantId", "AddressId"); + + b.ToTable("merchantaddress"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantContact", b => + { + b.Property("MerchantId") + .HasColumnType("uniqueidentifier"); + + b.Property("ContactId") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("EmailAddress") + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("PhoneNumber") + .HasColumnType("nvarchar(max)"); + + b.HasKey("MerchantId", "ContactId"); + + b.ToTable("merchantcontact"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantContract", b => + { + b.Property("MerchantId") + .HasColumnType("uniqueidentifier"); + + b.Property("ContractId") + .HasColumnType("uniqueidentifier"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.HasKey("MerchantId", "ContractId"); + + b.ToTable("MerchantContracts"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantDevice", b => + { + b.Property("MerchantId") + .HasColumnType("uniqueidentifier"); + + b.Property("DeviceId") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("DeviceIdentifier") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("MerchantId", "DeviceId"); + + b.ToTable("merchantdevice"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantOperator", b => + { + b.Property("MerchantId") + .HasColumnType("uniqueidentifier"); + + b.Property("OperatorId") + .HasColumnType("uniqueidentifier"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("MerchantNumber") + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("TerminalNumber") + .HasColumnType("nvarchar(max)"); + + b.HasKey("MerchantId", "OperatorId"); + + b.ToTable("merchantoperator"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantSecurityUser", b => + { + b.Property("MerchantId") + .HasColumnType("uniqueidentifier"); + + b.Property("SecurityUserId") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("EmailAddress") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("MerchantId", "SecurityUserId"); + + b.ToTable("merchantsecurityuser"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.MerchantSettlementFee", b => + { + b.Property("SettlementId") + .HasColumnType("uniqueidentifier"); + + b.Property("TransactionId") + .HasColumnType("uniqueidentifier"); + + b.Property("ContractProductTransactionFeeId") + .HasColumnType("uniqueidentifier"); + + b.Property("CalculatedValue") + .HasColumnType("decimal(18,2)"); + + b.Property("FeeCalculatedDateTime") + .HasColumnType("datetime2"); + + b.Property("FeeValue") + .HasColumnType("decimal(18,2)"); + + b.Property("IsSettled") + .HasColumnType("bit"); + + b.Property("MerchantId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("SettlementId", "TransactionId", "ContractProductTransactionFeeId"); + + b.ToTable("merchantsettlementfee"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Operator", b => + { + b.Property("OperatorReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("OperatorReportingId")); + + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("OperatorId") + .HasColumnType("uniqueidentifier"); + + b.Property("RequireCustomMerchantNumber") + .HasColumnType("bit"); + + b.Property("RequireCustomTerminalNumber") + .HasColumnType("bit"); + + b.HasKey("OperatorReportingId"); + + b.HasIndex("OperatorId") + .IsUnique(); + + b.ToTable("operator"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Reconciliation", b => + { + b.Property("TransactionReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("TransactionReportingId")); + + b.Property("DeviceIdentifier") + .HasColumnType("nvarchar(max)"); + + b.Property("IsAuthorised") + .HasColumnType("bit"); + + b.Property("IsCompleted") + .HasColumnType("bit"); + + b.Property("MerchantId") + .HasColumnType("uniqueidentifier"); + + b.Property("ResponseCode") + .HasColumnType("nvarchar(max)"); + + b.Property("ResponseMessage") + .HasColumnType("nvarchar(max)"); + + b.Property("TransactionCount") + .HasColumnType("int"); + + b.Property("TransactionDate") + .HasColumnType("date"); + + b.Property("TransactionDateTime") + .HasColumnType("datetime2"); + + b.Property("TransactionId") + .HasColumnType("uniqueidentifier"); + + b.Property("TransactionTime") + .HasColumnType("time"); + + b.Property("TransactionValue") + .HasColumnType("decimal(18,2)"); + + b.HasKey("TransactionReportingId"); + + SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("TransactionReportingId"), false); + + b.HasIndex("TransactionDate"); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("TransactionDate")); + + b.HasIndex("TransactionId", "MerchantId") + .IsUnique(); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("TransactionId", "MerchantId"), false); + + b.ToTable("reconciliation"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.ResponseCodes", b => + { + b.Property("ResponseCode") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("ResponseCode")); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("ResponseCode"); + + b.ToTable("responsecodes"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Settlement", b => + { + b.Property("SettlementReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("SettlementReportingId")); + + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("IsCompleted") + .HasColumnType("bit"); + + b.Property("MerchantId") + .HasColumnType("uniqueidentifier"); + + b.Property("ProcessingStarted") + .HasColumnType("bit"); + + b.Property("ProcessingStartedDateTIme") + .HasColumnType("datetime2"); + + b.Property("SettlementDate") + .HasColumnType("date"); + + b.Property("SettlementId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("SettlementReportingId"); + + SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("SettlementReportingId"), false); + + b.HasIndex("SettlementDate"); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("SettlementDate")); + + b.HasIndex("EstateId", "SettlementId") + .IsUnique(); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("EstateId", "SettlementId"), false); + + b.ToTable("settlement"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.StatementHeader", b => + { + b.Property("MerchantId") + .HasColumnType("uniqueidentifier"); + + b.Property("StatementId") + .HasColumnType("uniqueidentifier"); + + b.Property("StatementCreatedDate") + .HasColumnType("date"); + + b.Property("StatementCreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("StatementGeneratedDate") + .HasColumnType("date"); + + b.Property("StatementGeneratedDateTime") + .HasColumnType("datetime2"); + + b.Property("StatementReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("StatementReportingId")); + + b.HasKey("MerchantId", "StatementId"); + + SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("MerchantId", "StatementId"), false); + + b.HasIndex("StatementGeneratedDate"); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("StatementGeneratedDate")); + + b.ToTable("statementheader"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.StatementLine", b => + { + b.Property("StatementId") + .HasColumnType("uniqueidentifier"); + + b.Property("TransactionId") + .HasColumnType("uniqueidentifier"); + + b.Property("ActivityDateTime") + .HasColumnType("datetime2"); + + b.Property("ActivityType") + .HasColumnType("int"); + + b.Property("ActivityDate") + .HasColumnType("date"); + + b.Property("ActivityDescription") + .HasColumnType("nvarchar(max)"); + + b.Property("InAmount") + .HasColumnType("decimal(18,2)"); + + b.Property("OutAmount") + .HasColumnType("decimal(18,2)"); + + b.HasKey("StatementId", "TransactionId", "ActivityDateTime", "ActivityType"); + + b.ToTable("statementline"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Summary.SettlementSummary", b => + { + b.Property("ContractProductReportingId") + .HasColumnType("int"); + + b.Property("FeeCount") + .HasColumnType("int"); + + b.Property("FeeValue") + .HasColumnType("decimal(18,2)"); + + b.Property("IsCompleted") + .HasColumnType("bit"); + + b.Property("IsSettled") + .HasColumnType("bit"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("OperatorReportingId") + .HasColumnType("int"); + + b.Property("SalesCount") + .HasColumnType("int"); + + b.Property("SalesValue") + .HasColumnType("decimal(18,2)"); + + b.Property("SettlementDate") + .HasColumnType("date"); + + b.HasIndex("SettlementDate"); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("SettlementDate")); + + b.HasIndex("SettlementDate", "MerchantReportingId", "OperatorReportingId", "ContractProductReportingId", "IsCompleted", "IsSettled") + .IsUnique(); + + b.ToTable("SettlementSummary"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Summary.TodayTransaction", b => + { + b.Property("AuthorisationCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ContractProductReportingId") + .HasColumnType("int"); + + b.Property("ContractReportingId") + .HasColumnType("int"); + + b.Property("DeviceIdentifier") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Hour") + .HasColumnType("int"); + + b.Property("IsAuthorised") + .HasColumnType("bit"); + + b.Property("IsCompleted") + .HasColumnType("bit"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("OperatorReportingId") + .HasColumnType("int"); + + b.Property("ResponseCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ResponseMessage") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("TransactionAmount") + .HasColumnType("decimal(18,2)"); + + b.Property("TransactionDate") + .HasColumnType("date"); + + b.Property("TransactionDateTime") + .HasColumnType("datetime2"); + + b.Property("TransactionId") + .HasColumnType("uniqueidentifier"); + + b.Property("TransactionNumber") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("TransactionReference") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.Property("TransactionSource") + .HasColumnType("int"); + + b.Property("TransactionTime") + .HasColumnType("time"); + + b.Property("TransactionType") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasIndex("TransactionDate"); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("TransactionDate")); + + b.HasIndex("TransactionId") + .IsUnique(); + + b.ToTable("TodayTransactions"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Summary.TransactionHistory", b => + { + b.Property("AuthorisationCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ContractProductReportingId") + .HasColumnType("int"); + + b.Property("ContractReportingId") + .HasColumnType("int"); + + b.Property("DeviceIdentifier") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Hour") + .HasColumnType("int"); + + b.Property("IsAuthorised") + .HasColumnType("bit"); + + b.Property("IsCompleted") + .HasColumnType("bit"); + + b.Property("MerchantReportingId") + .HasColumnType("int"); + + b.Property("OperatorReportingId") + .HasColumnType("int"); + + b.Property("ResponseCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ResponseMessage") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("TransactionAmount") + .HasColumnType("decimal(18,2)"); + + b.Property("TransactionDate") + .HasColumnType("date"); + + b.Property("TransactionDateTime") + .HasColumnType("datetime2"); + + b.Property("TransactionId") + .HasColumnType("uniqueidentifier"); + + b.Property("TransactionNumber") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("TransactionReference") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.Property("TransactionSource") + .HasColumnType("int"); + + b.Property("TransactionTime") + .HasColumnType("time"); + + b.Property("TransactionType") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasIndex("TransactionDate"); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("TransactionDate")); + + b.HasIndex("TransactionId") + .IsUnique(); + + b.ToTable("TransactionHistory"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Transaction", b => + { + b.Property("TransactionReportingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("TransactionReportingId")); + + b.Property("AuthorisationCode") + .HasColumnType("nvarchar(max)"); + + b.Property("ContractId") + .HasColumnType("uniqueidentifier"); + + b.Property("ContractProductId") + .HasColumnType("uniqueidentifier"); + + b.Property("DeviceIdentifier") + .HasColumnType("nvarchar(max)"); + + b.Property("IsAuthorised") + .HasColumnType("bit"); + + b.Property("IsCompleted") + .HasColumnType("bit"); + + b.Property("MerchantId") + .HasColumnType("uniqueidentifier"); + + b.Property("OperatorId") + .HasColumnType("uniqueidentifier"); + + b.Property("ResponseCode") + .HasColumnType("nvarchar(max)"); + + b.Property("ResponseMessage") + .HasColumnType("nvarchar(max)"); + + b.Property("TransactionAmount") + .HasColumnType("decimal(18,2)"); + + b.Property("TransactionDate") + .HasColumnType("date"); + + b.Property("TransactionDateTime") + .HasColumnType("datetime2"); + + b.Property("TransactionId") + .HasColumnType("uniqueidentifier"); + + b.Property("TransactionNumber") + .HasColumnType("nvarchar(max)"); + + b.Property("TransactionReference") + .HasColumnType("nvarchar(max)"); + + b.Property("TransactionSource") + .HasColumnType("int"); + + b.Property("TransactionTime") + .HasColumnType("time"); + + b.Property("TransactionType") + .HasColumnType("nvarchar(max)"); + + b.HasKey("TransactionReportingId"); + + SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("TransactionReportingId"), false); + + b.HasIndex("TransactionDate"); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("TransactionDate")); + + b.HasIndex("TransactionId") + .IsUnique(); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("TransactionId"), false); + + b.ToTable("transaction"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.TransactionAdditionalRequestData", b => + { + b.Property("TransactionId") + .HasColumnType("uniqueidentifier"); + + b.Property("Amount") + .HasColumnType("nvarchar(max)"); + + b.Property("CustomerAccountNumber") + .HasColumnType("nvarchar(max)"); + + b.HasKey("TransactionId"); + + b.ToTable("transactionadditionalrequestdata"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.TransactionAdditionalResponseData", b => + { + b.Property("TransactionId") + .HasColumnType("uniqueidentifier"); + + b.Property("TransactionReportingId") + .HasColumnType("int"); + + b.HasKey("TransactionId"); + + b.ToTable("transactionadditionalresponsedata"); + }); + + modelBuilder.Entity("EstateManagement.Database.Entities.Voucher", b => + { + b.Property("VoucherId") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("ExpiryDate") + .HasColumnType("date"); + + b.Property("ExpiryDateTime") + .HasColumnType("datetime2"); + + b.Property("GenerateDate") + .HasColumnType("date"); + + b.Property("GenerateDateTime") + .HasColumnType("datetime2"); + + b.Property("IsGenerated") + .HasColumnType("bit"); + + b.Property("IsIssued") + .HasColumnType("bit"); + + b.Property("IsRedeemed") + .HasColumnType("bit"); + + b.Property("IssuedDate") + .HasColumnType("date"); + + b.Property("IssuedDateTime") + .HasColumnType("datetime2"); + + b.Property("OperatorIdentifier") + .HasColumnType("nvarchar(max)"); + + b.Property("RecipientEmail") + .HasColumnType("nvarchar(max)"); + + b.Property("RecipientMobile") + .HasColumnType("nvarchar(max)"); + + b.Property("RedeemedDate") + .HasColumnType("datetime2"); + + b.Property("RedeemedDateTime") + .HasColumnType("datetime2"); + + b.Property("TransactionId") + .HasColumnType("uniqueidentifier"); + + b.Property("Value") + .HasColumnType("decimal(18,2)"); + + b.Property("VoucherCode") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.HasKey("VoucherId"); + + b.HasIndex("TransactionId"); + + b.HasIndex("VoucherCode"); + + b.ToTable("voucher"); + }); + + modelBuilder.Entity("EstateManagement.Database.ViewEntities.SettlementView", b => + { + b.Property("Amount") + .HasColumnType("decimal(18,2)"); + + b.Property("CalculatedValue") + .HasColumnType("decimal(18,2)"); + + b.Property("DayOfWeek") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("EstateId") + .HasColumnType("uniqueidentifier"); + + b.Property("FeeDescription") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsCompleted") + .HasColumnType("bit"); + + b.Property("IsSettled") + .HasColumnType("bit"); + + b.Property("MerchantId") + .HasColumnType("uniqueidentifier"); + + b.Property("MerchantName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Month") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("MonthNumber") + .HasColumnType("int"); + + b.Property("OperatorIdentifier") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("SettlementDate") + .HasColumnType("datetime2"); + + b.Property("SettlementId") + .HasColumnType("uniqueidentifier"); + + b.Property("TransactionId") + .HasColumnType("uniqueidentifier"); + + b.Property("WeekNumber") + .HasColumnType("int"); + + b.Property("YearNumber") + .HasColumnType("int"); + + b.ToTable((string)null); + + b.ToView("uvwSettlements", (string)null); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/TransactionProcessor.Database/SeedingScripts/CalendarSeeding.sql b/TransactionProcessor.Database/SeedingScripts/CalendarSeeding.sql new file mode 100644 index 00000000..a90c4b49 --- /dev/null +++ b/TransactionProcessor.Database/SeedingScripts/CalendarSeeding.sql @@ -0,0 +1,49 @@ +delete from calendar +declare @startdate date +declare @enddate date + +set @startdate = '2022-01-01' +set @enddate = dateadd(dd,-1,DATEADD(yy,5,@startdate)) + +set datefirst 1; + +-- Build up the dates required +WITH CTE_Calendar as +(SELECT @startdate as [date] +UNION ALL +SELECT DATEADD(dd,1,[date]) +from CTE_Calendar +WHERE DATEADD(dd,1,[date]) <= @enddate) + + --[Date] [datetime2](7) NOT NULL, + --[DayOfWeek] [nvarchar](max) NULL, + --[DayOfWeekNumber] [int] NOT NULL, + --[DayOfWeekShort] [nvarchar](max) NULL, + --[MonthNameLong] [nvarchar](max) NULL, + --[MonthNameShort] [nvarchar](max) NULL, + --[MonthNumber] [int] NOT NULL, + --[Year] [int] NOT NULL, + --[WeekNumber] [int] NULL, + --[YearWeekNumber] [nvarchar](max) NULL, + --[WeekNumberString] [nvarchar](max) NULL, + +--select [date] from CTE_Calendar + +INSERT INTO calendar(Date,DayOfWeek, DayOfWeekNumber,DayOfWeekShort,MonthNameLong,MonthNameShort,MonthNumber,Year,WeekNumber,YearWeekNumber,WeekNumberString) +SELECT + [date] as date, + DATENAME(WEEKDAY,[date]) as DayOfWeek, + DATEPART(WEEKDAY,[date]) as DayOfWeekNumber, + SUBSTRING( DATENAME(WEEKDAY,[date]), 1, 3) as DayOfWeekShort, + DATENAME(Month,[date]) as MonthNameLong, + SUBSTRING( DATENAME(Month,[date]),1,3) as MonthNameShort, + Month([date]) as MonthNumber, + YEAR([date]) as Year, + datepart(week, [date]) as WeekNumber, + cast(YEAR([date]) as varchar) + ''+ RIGHT('00' + cast(DATEPART(WEEK,[date]) as varchar), 2) as YearWeekNumber, + 'Week Number ' + cast(datepart(week, [date]) as varchar) as WeekNumberString +FROM CTE_Calendar + +OPTION (MAXRECURSION 10000); + +select * from calendar \ No newline at end of file diff --git a/TransactionProcessor.Database/SeedingScripts/ResponseCodeSeeding.sql b/TransactionProcessor.Database/SeedingScripts/ResponseCodeSeeding.sql new file mode 100644 index 00000000..8330388b --- /dev/null +++ b/TransactionProcessor.Database/SeedingScripts/ResponseCodeSeeding.sql @@ -0,0 +1,19 @@ +SET IDENTITY_INSERT ResponseCodes ON + +INSERT INTO ResponseCodes(ResponseCode,Description) +SELECT 0, 'Success' UNION ALL +SELECT 1000, 'Unknown Device' UNION ALL +SELECT 1001, 'Unknown Estate' UNION ALL +SELECT 1002, 'Unknown Merchant' UNION ALL +SELECT 1003, 'No Devices Configured' UNION ALL +SELECT 1004, 'No Operators Configured (Estate)' UNION ALL +SELECT 1005, 'Unkown Operator (Estate)' UNION ALL +SELECT 1006, 'No Operators Configured (Merchant)' UNION ALL +SELECT 1007, 'Unkown Operator (Merchant)' UNION ALL +SELECT 1008, 'Declined by Operator' UNION ALL +SELECT 1009, 'Insufficient Funds' UNION ALL +SELECT 1010, 'Operator Comms Error' UNION ALL +SELECT 1011, 'Invalid Amount' UNION ALL +SELECT 9999, 'Unknown Error' + +SET IDENTITY_INSERT ResponseCodes OFF \ No newline at end of file diff --git a/TransactionProcessor.Database/StoredProcedures/SqlServer/spBuildHistoricTransactions.sql b/TransactionProcessor.Database/StoredProcedures/SqlServer/spBuildHistoricTransactions.sql new file mode 100644 index 00000000..9d2207db --- /dev/null +++ b/TransactionProcessor.Database/StoredProcedures/SqlServer/spBuildHistoricTransactions.sql @@ -0,0 +1,46 @@ +CREATE OR ALTER PROCEDURE [dbo].[spBuildHistoricTransactions] @date date +AS + +insert into TransactionHistory(MerchantReportingId, ContractProductReportingId,ContractReportingId,OperatorReportingId, +TransactionId, +AuthorisationCode, +DeviceIdentifier, +IsAuthorised, +IsCompleted, +ResponseCode, +ResponseMessage, +TransactionDate, +TransactionDateTime, +TransactionNumber, +TransactionReference, +TransactionTime, +TransactionSource, +TransactionType, +TransactionReportingId, +TransactionAmount, +Hour) +select t.MerchantReportingId, +t.ContractProductReportingId, +t.ContractReportingId, +t.OperatorReportingId, +t.TransactionId, +t.AuthorisationCode, +t.DeviceIdentifier, +t.IsAuthorised, +t.IsCompleted, +t.ResponseCode, +t.ResponseMessage, +t.TransactionDate, +t.TransactionDateTime, +t.TransactionNumber, +t.TransactionReference, +t.TransactionTime, +t.TransactionSource, +t.TransactionType, +t.TransactionReportingId, +t.TransactionAmount, +t.Hour +from TodayTransactions t +where t.TransactionDate = @date + +delete from TodayTransactions where TransactionDate = @date \ No newline at end of file diff --git a/TransactionProcessor.Database/StoredProcedures/SqlServer/spBuildSettlementSummary.sql b/TransactionProcessor.Database/StoredProcedures/SqlServer/spBuildSettlementSummary.sql new file mode 100644 index 00000000..dc95932c --- /dev/null +++ b/TransactionProcessor.Database/StoredProcedures/SqlServer/spBuildSettlementSummary.sql @@ -0,0 +1,30 @@ +CREATE OR ALTER PROCEDURE [dbo].[spBuildSettlementSummary] @date date +AS + +declare @weekNumber int +declare @yearnumber int +declare @startDate date +declare @enddate date + +SELECT @weekNumber = WeekNumber, @yearnumber = year from calendar where date = @date + +SELECT @startDate = min(date), @enddate = max(date) from calendar where WeekNumber = @weekNumber and Year = @yearnumber and date < convert(date,getdate()) + +delete from settlementsummary where settlementdate BETWEEN @startDate and @enddate + +insert into settlementsummary(IsCompleted, IsSettled, SettlementDate, merchantreportingid, operatorreportingid, contractproductreportingid, +salesvalue,feevalue, salescount, feecount) +select settlement.IsCompleted, IsSettled, SettlementDate, merchant.merchantreportingid, operator.operatorreportingid, contractproduct.contractproductreportingid, +sum([transaction].TransactionAmount) as salesvalue,sum(merchantsettlementfee.CalculatedValue) as feevalue, +count([transaction].TransactionAmount) as salescount, count(merchantsettlementfee.CalculatedValue) as feecount +from settlement +inner join merchantsettlementfee on merchantsettlementfee.SettlementId = settlement.SettlementId +inner join [transaction] on [transaction].TransactionId = merchantsettlementfee.TransactionId +inner join contractproducttransactionfee on contractproducttransactionfee.ContractProductTransactionFeeId = merchantsettlementfee.ContractProductTransactionFeeId +inner join contractproduct on contractproducttransactionfee.ContractProductId = contractproduct.ContractProductId +inner join contract on contract.ContractId = contractproduct.ContractId +inner join merchant on merchant.MerchantId = merchantsettlementfee.MerchantId +inner join estate on estate.EstateId = merchant.EstateId +inner join operator on operator.OperatorId = contract.OperatorId +where settlementdate BETWEEN @startDate and @enddate +group by settlement.IsCompleted, IsSettled, SettlementDate, merchant.merchantreportingid, operator.operatorreportingid, contractproduct.contractproductreportingid \ No newline at end of file diff --git a/TransactionProcessor.Database/StoredProcedures/SqlServer/spBuildTodaysTransactions.sql b/TransactionProcessor.Database/StoredProcedures/SqlServer/spBuildTodaysTransactions.sql new file mode 100644 index 00000000..18eb53a5 --- /dev/null +++ b/TransactionProcessor.Database/StoredProcedures/SqlServer/spBuildTodaysTransactions.sql @@ -0,0 +1,49 @@ +CREATE OR ALTER PROCEDURE [dbo].[spBuildTodaysTransactions] @date date +AS + +insert into TodayTransactions(MerchantReportingId, ContractProductReportingId,ContractReportingId,OperatorReportingId, +TransactionId, +AuthorisationCode, +DeviceIdentifier, +IsAuthorised, +IsCompleted, +ResponseCode, +ResponseMessage, +TransactionDate, +TransactionDateTime, +TransactionNumber, +TransactionReference, +TransactionTime, +TransactionSource, +TransactionType, +TransactionReportingId, +TransactionAmount, +Hour) +select merchant.MerchantReportingId, +ISNULL(contractproduct.ContractProductReportingId,0) as ContractProductReportingId, +ISNULL(contract.ContractReportingId,0) as ContractReportingId, +ISNULL(operator.OperatorReportingId,0) as OperatorReportingId, +t.TransactionId, +ISNULL(t.AuthorisationCode,'') as AuthorisationCode, +t.DeviceIdentifier, +t.IsAuthorised, +t.IsCompleted, +t.ResponseCode, +t.ResponseMessage, +t.TransactionDate, +t.TransactionDateTime, +t.TransactionNumber, +t.TransactionReference, +t.TransactionTime, +t.TransactionSource, +t.TransactionType, +t.TransactionReportingId, +t.TransactionAmount, +DATEPART(HH, t.transactiondatetime) as Hour +from [transaction] t +inner join merchant on merchant.MerchantId = t.MerchantId +left outer join contractproduct on contractproduct.ContractProductId = t.ContractProductId +left outer join contract on contract.ContractId = t.ContractId +left outer join operator on operator.OperatorId= t.OperatorId +where transactiondate = @date +and TransactionReportingId not in (select distinct TransactionReportingId from TodayTransactions) \ No newline at end of file diff --git a/TransactionProcessor.Database/TransactionProcessor.Database.csproj b/TransactionProcessor.Database/TransactionProcessor.Database.csproj new file mode 100644 index 00000000..ebce4b7d --- /dev/null +++ b/TransactionProcessor.Database/TransactionProcessor.Database.csproj @@ -0,0 +1,56 @@ + + + + net8.0 + enable + enable + + + + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + + + + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + + + + + + + + diff --git a/TransactionProcessor.Database/ViewEntities/SettlementView.cs b/TransactionProcessor.Database/ViewEntities/SettlementView.cs new file mode 100644 index 00000000..9bc59a21 --- /dev/null +++ b/TransactionProcessor.Database/ViewEntities/SettlementView.cs @@ -0,0 +1,97 @@ +namespace TransactionProcessor.Database.ViewEntities +{ + public class SettlementView + { + #region Properties + + /// + /// Gets or sets the amount. + /// + /// + /// The amount. + /// + public Decimal Amount { get; set; } + + public Decimal CalculatedValue { get; set; } + + /// + /// Gets or sets the day of week. + /// + /// + /// The day of week. + /// + public String DayOfWeek { get; set; } + + /// + /// Gets or sets the estate identifier. + /// + /// + /// The estate identifier. + /// + public Guid EstateId { get; set; } + + public String FeeDescription { get; set; } + + public Boolean IsCompleted { get; set; } + + public Boolean IsSettled { get; set; } + + /// + /// Gets or sets the merchant identifier. + /// + /// + /// The merchant identifier. + /// + public Guid MerchantId { get; set; } + + public String MerchantName { get; set; } + + /// + /// Gets or sets the month. + /// + /// + /// The month. + /// + public String Month { get; set; } + + /// + /// Gets or sets the month number. + /// + /// + /// The month number. + /// + public Int32 MonthNumber { get; set; } + + /// + /// Gets or sets the operator identifier. + /// + /// + /// The operator identifier. + /// + public String OperatorIdentifier { get; set; } + + public DateTime SettlementDate { get; set; } + + public Guid SettlementId { get; set; } + + public Guid TransactionId { get; set; } + + /// + /// Gets or sets the week number. + /// + /// + /// The week number. + /// + public Int32 WeekNumber { get; set; } + + /// + /// Gets or sets the year number. + /// + /// + /// The year number. + /// + public Int32 YearNumber { get; set; } + + #endregion + } +} \ No newline at end of file diff --git a/TransactionProcessor.Database/Views/MySql/Priority1/uvwSettlements.View.sql b/TransactionProcessor.Database/Views/MySql/Priority1/uvwSettlements.View.sql new file mode 100644 index 00000000..06e36d51 --- /dev/null +++ b/TransactionProcessor.Database/Views/MySql/Priority1/uvwSettlements.View.sql @@ -0,0 +1,29 @@ +CREATE OR REPLACE VIEW uvwSettlements +AS +SELECT + s.SettlementId, + s.SettlementDate, + s.IsCompleted, + FORMAT(s.SettlementDate, 'dddd') as DayOfWeek, + DATEPART(wk, s.SettlementDate) as WeekNumber, + FORMAT(s.SettlementDate, 'MMMM') as Month, + DATEPART(MM, s.SettlementDate) as MonthNumber, + YEAR(s.SettlementDate) as YearNumber, + f.CalculatedValue, + t.TransactionId, + e.EstateId, + m.MerchantId, + m.Name as MerchantName, + cptf.Description as FeeDescription, + o.Name as OperatorIdentifier, + CAST(ISNULL(tar.Amount,0) as decimal) as Amount, + f.IsSettled +from settlement s +inner join merchantsettlementfee f on s.SettlementReportingId = f.SettlementReportingId +inner join [transaction] t on t.TransactionReportingId = f.TransactionReportingId +inner join [merchant] m on t.MerchantReportingId = m.MerchantReportingId +inner join [estate] e on e.EstateReportingId = m.EstateReportingId +left outer join contractproducttransactionfee cptf on f.TransactionFeeReportingId = cptf.TransactionFeeReportingId +left outer join transactionadditionalrequestdata tar on tar.TransactionReportingId = t.TransactionReportingId +inner join contract c on c.ContractReportingId = t.ContractReportingId +inner join operator o on o.OperatorId = c.operatorid diff --git a/TransactionProcessor.Database/Views/SqlServer/Priority1/uvwSettlements.View.sql b/TransactionProcessor.Database/Views/SqlServer/Priority1/uvwSettlements.View.sql new file mode 100644 index 00000000..3be73366 --- /dev/null +++ b/TransactionProcessor.Database/Views/SqlServer/Priority1/uvwSettlements.View.sql @@ -0,0 +1,30 @@ +CREATE OR ALTER VIEW uvwSettlements +AS + +SELECT + s.SettlementId, + s.SettlementDate, + s.IsCompleted, + DATENAME(WEEKDAY, s.SettlementDate) as DayOfWeek, + DATEPART(wk, s.SettlementDate) as WeekNumber, + DATENAME(MONTH, s.SettlementDate) as Month, + DATEPART(MM, s.SettlementDate) as MonthNumber, + YEAR(s.SettlementDate) as YearNumber, + f.CalculatedValue, + t.TransactionId, + e.EstateId, + m.MerchantId, + m.Name as MerchantName, + cptf.Description as FeeDescription, + o.Name as OperatorIdentifier, + CAST(ISNULL(tar.Amount,0) as decimal) as Amount, + f.IsSettled +from settlement s +inner join merchantsettlementfee f on s.SettlementId = f.SettlementId +inner join [transaction] t on t.TransactionId = f.TransactionId +inner join [merchant] m on t.MerchantId = m.MerchantId +inner join [estate] e on e.EstateId = m.EstateId +left outer join contractproducttransactionfee cptf on f.ContractProductTransactionFeeId = cptf.ContractProductTransactionFeeId +left outer join transactionadditionalrequestdata tar on tar.TransactionId = t.TransactionId +inner join contract c on c.ContractId = t.ContractId +inner join operator o on o.OperatorId = c.operatorid \ No newline at end of file diff --git a/TransactionProcessor.Estate.DomainEvents/EstateDomainEvents.cs b/TransactionProcessor.Estate.DomainEvents/EstateDomainEvents.cs new file mode 100644 index 00000000..e9b9758e --- /dev/null +++ b/TransactionProcessor.Estate.DomainEvents/EstateDomainEvents.cs @@ -0,0 +1,18 @@ +using Shared.DomainDrivenDesign.EventSourcing; + +namespace TransactionProcessor.Estate.DomainEvents{ + public record EstateCreatedEvent(Guid EstateId, + String EstateName) : DomainEvent(EstateId, Guid.NewGuid()); + + public record EstateReferenceAllocatedEvent(Guid EstateId, String EstateReference) : DomainEvent(EstateId, Guid.NewGuid()); + + public record OperatorAddedToEstateEvent(Guid EstateId, + Guid OperatorId) : DomainEvent(EstateId, Guid.NewGuid()); + + public record OperatorRemovedFromEstateEvent(Guid EstateId, + Guid OperatorId) : DomainEvent(EstateId, Guid.NewGuid()); + + public record SecurityUserAddedToEstateEvent(Guid EstateId, + Guid SecurityUserId, + String EmailAddress) : DomainEvent(EstateId, Guid.NewGuid()); +} \ No newline at end of file diff --git a/TransactionProcessor.Estate.DomainEvents/TransactionProcessor.Estate.DomainEvents.csproj b/TransactionProcessor.Estate.DomainEvents/TransactionProcessor.Estate.DomainEvents.csproj new file mode 100644 index 00000000..dab92493 --- /dev/null +++ b/TransactionProcessor.Estate.DomainEvents/TransactionProcessor.Estate.DomainEvents.csproj @@ -0,0 +1,13 @@ + + + + net8.0 + enable + enable + + + + + + + diff --git a/TransactionProcessor.FloatAggregate/FloatActivityAggregate.cs b/TransactionProcessor.FloatAggregate/FloatActivityAggregate.cs deleted file mode 100644 index c33b9a3b..00000000 --- a/TransactionProcessor.FloatAggregate/FloatActivityAggregate.cs +++ /dev/null @@ -1,87 +0,0 @@ -using System.Diagnostics.CodeAnalysis; -using System.Runtime.CompilerServices; -using Shared.DomainDrivenDesign.EventSourcing; -using Shared.EventStore.Aggregate; -using Shared.General; -using TransactionProcessor.Float.DomainEvents; - -namespace TransactionProcessor.FloatAggregate; - -public static class FloatActivityAggregateExtensions { - - public static void PlayEvent(this FloatActivityAggregate aggregate, - FloatAggregateCreditedEvent domainEvent) { - aggregate.CreditCount++; - aggregate.Credits.Add(domainEvent.CreditId); - } - - public static void PlayEvent(this FloatActivityAggregate aggregate, - FloatAggregateDebitedEvent domainEvent) { - aggregate.DebitCount++; - aggregate.Debits.Add(domainEvent.DebitId); - } - - public static void RecordCreditPurchase(this FloatActivityAggregate aggregate, - Guid estateId, - DateTime activityDateTime, - Decimal creditAmount, - Guid creditId) { - - if (aggregate.Credits.Any(c => c == creditId)) - return; - - FloatAggregateCreditedEvent floatAggregateCreditedEvent = new(aggregate.AggregateId, estateId, activityDateTime, creditAmount, creditId); - aggregate.ApplyAndAppend(floatAggregateCreditedEvent); - } - - public static void RecordTransactionAgainstFloat(this FloatActivityAggregate aggregate, - Guid estateId, - DateTime activityDateTime, - Decimal transactionAmount, - Guid transactionId) { - if (aggregate.Debits.Any(c => c == transactionId)) - return; - - FloatAggregateDebitedEvent floatAggregateCreditedEvent = new(aggregate.AggregateId, estateId, activityDateTime, transactionAmount, transactionId); - aggregate.ApplyAndAppend(floatAggregateCreditedEvent); - } -} - -public record FloatActivityAggregate : Aggregate { - public override void PlayEvent(IDomainEvent domainEvent) => FloatActivityAggregateExtensions.PlayEvent(this, (dynamic)domainEvent); - - public Int32 CreditCount { get; internal set; } - public Int32 DebitCount { get; internal set; } - public List Credits { get; internal set; } - public List Debits { get; internal set; } - [ExcludeFromCodeCoverage] - protected override Object GetMetadata() - { - return new - { - - }; - } - - - [ExcludeFromCodeCoverage] - public FloatActivityAggregate() - { - this.Credits = new List(); - this.Debits = new List(); - } - - private FloatActivityAggregate(Guid aggregateId) - { - Guard.ThrowIfInvalidGuid(aggregateId, "Aggregate Id cannot be an Empty Guid"); - - this.AggregateId = aggregateId; - this.Credits = new List(); - this.Debits = new List(); - } - - public static FloatActivityAggregate Create(Guid aggregateId) - { - return new FloatActivityAggregate(aggregateId); - } -} \ No newline at end of file diff --git a/TransactionProcessor.FloatAggregate/TransactionProcessor.FloatAggregate.csproj b/TransactionProcessor.FloatAggregate/TransactionProcessor.FloatAggregate.csproj deleted file mode 100644 index 45da79c4..00000000 --- a/TransactionProcessor.FloatAggregate/TransactionProcessor.FloatAggregate.csproj +++ /dev/null @@ -1,17 +0,0 @@ - - - - net8.0 - enable - enable - - - - - - - - - - - diff --git a/TransactionProcessor.IntegrationTesting.Helpers/EstateDetails.cs b/TransactionProcessor.IntegrationTesting.Helpers/EstateDetails.cs new file mode 100644 index 00000000..533cfe23 --- /dev/null +++ b/TransactionProcessor.IntegrationTesting.Helpers/EstateDetails.cs @@ -0,0 +1,308 @@ +using TransactionProcessor.DataTransferObjects.Responses.Contract; + +namespace TransactionProcessor.IntegrationTesting.Helpers +{ + using System; + using System.Collections.Generic; + using System.Diagnostics; + using System.Linq; + using TransactionProcessor.DataTransferObjects; + + public class EstateDetails + { + private EstateDetails(Guid estateId, String estateName, String estateReference) + { + this.EstateId = estateId; + this.EstateName = estateName; + this.EstateReference = estateReference; + this.Merchants = new List(); + this.Operators=new Dictionary(); + this.AssignedOperators = new List(); + this.MerchantUsers = new Dictionary>(); + this.Contracts = new List(); + this.TransactionResponses = new Dictionary<(Guid merchantId, String transactionNumber), String>(); + } + + private Dictionary<(Guid merchantId, String transactionNumber), String> TransactionResponses { get; } + + public Guid GetMerchantId(String merchantName) + { + if (merchantName == "InvalidMerchant") + { + return Guid.Parse("D59320FA-4C3E-4900-A999-483F6A10C69A"); + } + + return this.Merchants.Single(m => m.MerchantName == merchantName).MerchantId; + } + + public void AddTransactionResponse(Guid merchantId, + String transactionNumber, + String transactionResponse) + { + this.TransactionResponses.Add((merchantId, transactionNumber), transactionResponse); + } + + public String EstateUser { get; private set; } + public String EstatePassword { get; private set; } + + public String AccessToken { get; private set; } + + public static EstateDetails Create(Guid estateId, + String estateName, + String estateReference) + { + return new EstateDetails(estateId,estateName, estateReference); + } + + public String GetTransactionResponse(Guid merchantId, + String transactionNumber) + { + KeyValuePair<(Guid merchantId, String transactionNumber), String> transactionResponse = + this.TransactionResponses.SingleOrDefault(t => t.Key.merchantId == merchantId && t.Key.transactionNumber == transactionNumber); + + return transactionResponse.Value; + } + + public void AddOperator(Guid operatorId, + String operatorName) + { + this.Operators.Add(operatorName,operatorId); + } + + public void UpdateOperator(Guid operatorId, + String newOperatorName) + { + KeyValuePair originalOperator = this.Operators.SingleOrDefault(o => o.Value == operatorId); + + this.Operators.Remove(originalOperator.Key); + this.Operators.Add(newOperatorName, operatorId); + } + + public void AddAssignedOperator(Guid operatorId) + { + this.AssignedOperators.Add(operatorId); + } + + public void AddContract(Guid contractId, + String contractName, + Guid operatorId) + { + this.Contracts.Add(new Contract + { + ContractId = contractId, + Description = contractName, + OperatorId = operatorId, + }); + } + + public void AddMerchant(TransactionProcessor.DataTransferObjects.Responses.Merchant.MerchantResponse merchant) + { + this.Merchants.Add(merchant); + } + + public Contract GetContract(String contractName) + { + return this.Contracts.Single(c => c.Description == contractName); + } + public Contract GetContract(Guid contractId) + { + return this.Contracts.Single(c => c.ContractId == contractId); + } + + public TransactionProcessor.DataTransferObjects.Responses.Merchant.MerchantResponse GetMerchant(String merchantName) + { + return this.Merchants.SingleOrDefault(m => m.MerchantName == merchantName); + } + + public List GetMerchants() + { + return this.Merchants; + } + + public Guid GetOperatorId(String operatorName) + { + return this.Operators.Single(o => o.Key == operatorName).Value; + } + + public void SetEstateUser(String userName, + String password) + { + this.EstateUser = userName; + this.EstatePassword = password; + } + + public void AddMerchantUser(String merchantName, + String userName, + String password) + { + if (this.MerchantUsers.ContainsKey(merchantName)) + { + Dictionary merchantUsersList = this.MerchantUsers[merchantName]; + if (merchantUsersList.ContainsKey(userName) == false) + { + merchantUsersList.Add(userName,password); + } + } + else + { + Dictionary merchantUsersList = new Dictionary(); + merchantUsersList.Add(userName,password); + this.MerchantUsers.Add(merchantName,merchantUsersList); + } + } + + public void AddMerchantUserToken(String merchantName, + String userName, + String token) + { + if (this.MerchantUsersTokens.ContainsKey(merchantName)) + { + Dictionary merchantUsersList = this.MerchantUsersTokens[merchantName]; + if (merchantUsersList.ContainsKey(userName) == false) + { + merchantUsersList.Add(userName, token); + } + } + else + { + Dictionary merchantUsersList = new Dictionary(); + merchantUsersList.Add(userName, token); + this.MerchantUsersTokens.Add(merchantName, merchantUsersList); + } + } + + public void SetEstateUserToken(String accessToken) + { + this.AccessToken = accessToken; + } + + public Guid EstateId { get; private set; } + public String EstateName { get; private set; } + public String EstateReference { get; private set; } + private Dictionary Operators; + + private List AssignedOperators; + + private List Merchants; + + private Dictionary> MerchantUsers; + private Dictionary> MerchantUsersTokens; + + private List Contracts; + } + + public class Contract + { + public Guid ContractId { get; set; } + + public Guid OperatorId { get; set; } + + public String Description { get; set; } + + public List Products { get; set; } + + public void AddProduct(Guid productId, + String name, + String displayText, + Decimal? value = null) + { + Product product = new Product + { + ProductId = productId, + DisplayText = displayText, + Name = name, + Value = value + }; + + if (this.Products == null) + { + this.Products = new List(); + } + this.Products.Add(product); + } + + public Product GetProduct(Guid productId) + { + return this.Products.SingleOrDefault(p => p.ProductId == productId); + } + + public Product GetProduct(String name) + { + return this.Products.SingleOrDefault(p => p.Name == name); + } + } + + public class Product + { + public Guid ProductId { get; set; } + + public String Name { get; set; } + public String DisplayText { get; set; } + + public Decimal? Value { get; set; } + + public List TransactionFees { get; set; } + + public void AddTransactionFee(Guid transactionFeeId, + CalculationType calculationType, + FeeType feeType, + String description, + Decimal value) + { + TransactionFee transactionFee = new TransactionFee + { + TransactionFeeId = transactionFeeId, + CalculationType = calculationType, + FeeType = feeType, + Description = description, + Value = value + }; + + if (this.TransactionFees == null) + { + this.TransactionFees = new List(); + } + this.TransactionFees.Add(transactionFee); + } + + public TransactionFee GetTransactionFee(Guid transactionFeeId) + { + return this.TransactionFees.SingleOrDefault(t => t.TransactionFeeId== transactionFeeId); + } + + public TransactionFee GetTransactionFee(String description) + { + return this.TransactionFees.SingleOrDefault(t => t.Description == description); + } + } + + public class TransactionFee + { + public Guid TransactionFeeId { get; set; } + + public CalculationType CalculationType { get; set; } + public FeeType FeeType { get; set; } + + public String Description { get; set; } + + public Decimal Value { get; set; } + } + + public class CreateNewUserRequest + { + public String EmailAddress { get; set; } + + public String Password { get; set; } + + public String GivenName { get; set; } + + public String MiddleName { get; set; } + + public String FamilyName { get; set; } + + public Int32 UserType {get; set; } + public Guid? EstateId { get; set; } + public Guid? MerchantId { get; set; } + public String MerchantName { get; set; } + } +} diff --git a/TransactionProcessor.IntegrationTesting.Helpers/SpecflowExtensions.cs b/TransactionProcessor.IntegrationTesting.Helpers/SpecflowExtensions.cs index e77f2ab3..2a7ec1c7 100644 --- a/TransactionProcessor.IntegrationTesting.Helpers/SpecflowExtensions.cs +++ b/TransactionProcessor.IntegrationTesting.Helpers/SpecflowExtensions.cs @@ -1,12 +1,18 @@ -namespace TransactionProcessor.IntegrationTesting.Helpers; +using Shouldly; +using TransactionProcessor.DataTransferObjects.Requests.Contract; +using TransactionProcessor.DataTransferObjects.Requests.Estate; +using TransactionProcessor.DataTransferObjects.Requests.Merchant; +using TransactionProcessor.DataTransferObjects.Requests.Operator; +using TransactionProcessor.DataTransferObjects.Responses.Contract; +using TransactionProcessor.DataTransferObjects.Responses.Merchant; + +namespace TransactionProcessor.IntegrationTesting.Helpers; using DataTransferObjects; -using EstateManagement.DataTransferObjects.Responses; -using EstateManagement.IntegrationTesting.Helpers; using Newtonsoft.Json; using Reqnroll; -using Shared.IntegrationTesting; -using Shouldly; +using AssignOperatorToMerchantRequest = DataTransferObjects.Requests.Merchant.AssignOperatorRequest; +using AssignOperatorToEstateRequest = DataTransferObjects.Requests.Estate.AssignOperatorRequest; public static class ReqnrollTableHelper { @@ -160,8 +166,8 @@ public static class ReqnrollExtensions{ Guid contractId = Guid.Empty; Guid productId = Guid.Empty; - EstateManagement.IntegrationTesting.Helpers.Contract contract = null; - EstateManagement.IntegrationTesting.Helpers.Product product = null; + Contract contract = null; + Product product = null; try{ contract = estateDetails.GetContract(contractDescription); } @@ -278,7 +284,7 @@ private static EstateDetails GetEstateDetails(List estateDetailsL if (estateDetails == null && estateName == "InvalidEstate"){ estateDetails = EstateDetails.Create(Guid.Parse("79902550-64DF-4491-B0C1-4E78943928A3"), estateName, "EstateRef1"); - EstateManagement.DataTransferObjects.Responses.Merchant.MerchantResponse response = new() { + DataTransferObjects.Responses.Merchant.MerchantResponse response = new() { MerchantId = Guid.Parse("36AA0109-E2E3-4049-9575-F507A887BB1F"), MerchantName = "Test Merchant 1" }; @@ -542,4 +548,405 @@ public static (EstateDetails, SaleTransactionResponse) GetVoucherByTransactionNu }); return (estateDetails, transactionResponse); } + + public static List ToCreateEstateRequests(this DataTableRows tableRows) + { + List requests = new List(); + foreach (DataTableRow tableRow in tableRows) + { + CreateEstateRequest createEstateRequest = new CreateEstateRequest + { + EstateId = Guid.NewGuid(), + EstateName = ReqnrollTableHelper.GetStringRowValue(tableRow, "EstateName") + }; + requests.Add(createEstateRequest); + } + + return requests; + } + + public static List<(EstateDetails, Guid, AssignOperatorToMerchantRequest)> ToAssignOperatorRequests(this DataTableRows tableRows, List estateDetailsList) + { + List<(EstateDetails, Guid, AssignOperatorToMerchantRequest)> requests = new(); + + foreach (DataTableRow tableRow in tableRows) + { + String estateName = ReqnrollTableHelper.GetStringRowValue(tableRow, "EstateName"); + EstateDetails estateDetails = estateDetailsList.SingleOrDefault(e => e.EstateName == estateName); + estateDetails.ShouldNotBeNull(); + + // Lookup the merchant id + String merchantName = ReqnrollTableHelper.GetStringRowValue(tableRow, "MerchantName"); + Guid merchantId = estateDetails.GetMerchantId(merchantName); + + String operatorName = ReqnrollTableHelper.GetStringRowValue(tableRow, "OperatorName"); + Guid operatorId = estateDetails.GetOperatorId(operatorName); + AssignOperatorToMerchantRequest assignOperatorRequest = new AssignOperatorToMerchantRequest + { + OperatorId = operatorId, + MerchantNumber = + ReqnrollTableHelper.GetStringRowValue(tableRow, "MerchantNumber"), + TerminalNumber = + ReqnrollTableHelper.GetStringRowValue(tableRow, "TerminalNumber"), + }; + + requests.Add((estateDetails, merchantId, assignOperatorRequest)); + } + + return requests; + } + + public static List<(EstateDetails estate, CreateOperatorRequest request)> ToCreateOperatorRequests(this DataTableRows tableRows, List estateDetailsList) + { + List<(EstateDetails estate, CreateOperatorRequest request)> requests = new(); + + foreach (DataTableRow tableRow in tableRows) + { + String estateName = ReqnrollTableHelper.GetStringRowValue(tableRow, "EstateName"); + + EstateDetails estateDetails = estateDetailsList.SingleOrDefault(e => e.EstateName == estateName); + estateDetails.ShouldNotBeNull(); + + Guid operatorId = Guid.NewGuid(); + String operatorName = ReqnrollTableHelper.GetStringRowValue(tableRow, "OperatorName"); + Boolean requireCustomMerchantNumber = ReqnrollTableHelper.GetBooleanValue(tableRow, "RequireCustomMerchantNumber"); + Boolean requireCustomTerminalNumber = ReqnrollTableHelper.GetBooleanValue(tableRow, "RequireCustomTerminalNumber"); + + CreateOperatorRequest createOperatorRequest = new CreateOperatorRequest + { + OperatorId = operatorId, + Name = operatorName, + RequireCustomMerchantNumber = requireCustomMerchantNumber, + RequireCustomTerminalNumber = requireCustomTerminalNumber + }; + requests.Add((estateDetails, createOperatorRequest)); + } + + return requests; + } + + public static List<(EstateDetails estate, AssignOperatorToEstateRequest request)> ToAssignOperatorToEstateRequests(this DataTableRows tableRows, List estateDetailsList) + { + List<(EstateDetails estate, AssignOperatorToEstateRequest request)> requests = new(); + + foreach (DataTableRow tableRow in tableRows) + { + String estateName = ReqnrollTableHelper.GetStringRowValue(tableRow, "EstateName"); + + EstateDetails estateDetails = estateDetailsList.SingleOrDefault(e => e.EstateName == estateName); + estateDetails.ShouldNotBeNull(); + + + String operatorName = ReqnrollTableHelper.GetStringRowValue(tableRow, "OperatorName"); + Guid operatorId = estateDetails.GetOperatorId(operatorName); + + AssignOperatorToEstateRequest assignOperatorRequest = new AssignOperatorToEstateRequest() + { + OperatorId = operatorId + }; + requests.Add((estateDetails, assignOperatorRequest)); + } + + return requests; + } + + public static List<(EstateDetails estate, CreateMerchantRequest)> ToCreateMerchantRequests(this DataTableRows tableRows, List estateDetailsList) + { + List<(EstateDetails estate, CreateMerchantRequest)> requests = new(); + foreach (DataTableRow tableRow in tableRows) + { + String estateName = ReqnrollTableHelper.GetStringRowValue(tableRow, "EstateName"); + EstateDetails estateDetails = estateDetailsList.SingleOrDefault(e => e.EstateName == estateName); + estateDetails.ShouldNotBeNull(); + String settlementSchedule = ReqnrollTableHelper.GetStringRowValue(tableRow, "SettlementSchedule"); + + SettlementSchedule schedule = SettlementSchedule.Immediate; + if (String.IsNullOrEmpty(settlementSchedule) == false) + { + schedule = Enum.Parse(settlementSchedule); + } + + CreateMerchantRequest createMerchantRequest = new CreateMerchantRequest + { + Name = ReqnrollTableHelper.GetStringRowValue(tableRow, "MerchantName"), + Contact = new Contact + { + ContactName = + ReqnrollTableHelper.GetStringRowValue(tableRow, + "ContactName"), + EmailAddress = + ReqnrollTableHelper.GetStringRowValue(tableRow, + "EmailAddress") + }, + Address = new Address + { + AddressLine1 = + ReqnrollTableHelper.GetStringRowValue(tableRow, + "AddressLine1"), + Town = + ReqnrollTableHelper.GetStringRowValue(tableRow, "Town"), + Region = + ReqnrollTableHelper.GetStringRowValue(tableRow, + "Region"), + Country = + ReqnrollTableHelper.GetStringRowValue(tableRow, + "Country") + }, + SettlementSchedule = schedule, + MerchantId = Guid.NewGuid() + }; + requests.Add((estateDetails, createMerchantRequest)); + } + + return requests; + } + + public static List ToEstateDetails(this DataTableRows tableRows) + { + List results = new List(); + foreach (DataTableRow tableRow in tableRows) + { + String estateName = ReqnrollTableHelper.GetStringRowValue(tableRow, "EstateName"); + results.Add(estateName); + } + + return results; + } + + public static List<(EstateDetails, CreateContractRequest)> ToCreateContractRequests(this DataTableRows tableRows, List estateDetailsList) + { + List<(EstateDetails, CreateContractRequest)> result = new(); + + foreach (DataTableRow tableRow in tableRows) + { + String estateName = ReqnrollTableHelper.GetStringRowValue(tableRow, "EstateName"); + EstateDetails estateDetails = estateDetailsList.SingleOrDefault(e => e.EstateName == estateName); + estateDetails.ShouldNotBeNull(); + + String operatorName = ReqnrollTableHelper.GetStringRowValue(tableRow, "OperatorName"); + Guid operatorId = estateDetails.GetOperatorId(operatorName); + + CreateContractRequest createContractRequest = new CreateContractRequest + { + OperatorId = operatorId, + Description = ReqnrollTableHelper.GetStringRowValue(tableRow, "ContractDescription") + }; + result.Add((estateDetails, createContractRequest)); + } + + return result; + } + + public static List<(EstateDetails, Contract, AddProductToContractRequest)> ToAddProductToContractRequest(this DataTableRows tableRows, List estateDetailsList) + { + List<(EstateDetails, Contract, AddProductToContractRequest)> result = new List<(EstateDetails, Contract, AddProductToContractRequest)>(); + foreach (DataTableRow tableRow in tableRows) + { + String estateName = ReqnrollTableHelper.GetStringRowValue(tableRow, "EstateName"); + EstateDetails estateDetails = estateDetailsList.SingleOrDefault(e => e.EstateName == estateName); + estateDetails.ShouldNotBeNull(); + + String contractName = ReqnrollTableHelper.GetStringRowValue(tableRow, "ContractDescription"); + Contract contract = estateDetails.GetContract(contractName); + + String productValue = ReqnrollTableHelper.GetStringRowValue(tableRow, "Value"); + + var productTypeString = ReqnrollTableHelper.GetStringRowValue(tableRow, "ProductType"); + var productType = Enum.Parse(productTypeString, true); + AddProductToContractRequest addProductToContractRequest = new AddProductToContractRequest + { + ProductName = + ReqnrollTableHelper.GetStringRowValue(tableRow, + "ProductName"), + DisplayText = + ReqnrollTableHelper.GetStringRowValue(tableRow, + "DisplayText"), + Value = null, + ProductType = productType + }; + + if (String.IsNullOrEmpty(productValue) == false) + { + addProductToContractRequest.Value = Decimal.Parse(productValue); + } + + result.Add((estateDetails, contract, addProductToContractRequest)); + } + + return result; + } + + public static List<(EstateDetails, Contract, Product, AddTransactionFeeForProductToContractRequest)> ToAddTransactionFeeForProductToContractRequests(this DataTableRows tableRows, List estateDetailsList) + { + List<(EstateDetails, Contract, Product, AddTransactionFeeForProductToContractRequest)> result = new(); + foreach (DataTableRow tableRow in tableRows) + { + String estateName = ReqnrollTableHelper.GetStringRowValue(tableRow, "EstateName"); + EstateDetails estateDetails = estateDetailsList.SingleOrDefault(e => e.EstateName == estateName); + estateDetails.ShouldNotBeNull(); + + String contractName = ReqnrollTableHelper.GetStringRowValue(tableRow, "ContractDescription"); + Contract contract = estateDetails.GetContract(contractName); + + String productName = ReqnrollTableHelper.GetStringRowValue(tableRow, "ProductName"); + Product product = contract.GetProduct(productName); + + var calculationTypeString = ReqnrollTableHelper.GetStringRowValue(tableRow, "CalculationType"); + var calculationType = Enum.Parse(calculationTypeString, true); + AddTransactionFeeForProductToContractRequest addTransactionFeeForProductToContractRequest = new AddTransactionFeeForProductToContractRequest + { + Value = + ReqnrollTableHelper.GetDecimalValue(tableRow, + "Value"), + Description = + ReqnrollTableHelper.GetStringRowValue(tableRow, + "FeeDescription"), + CalculationType = calculationType + }; + result.Add((estateDetails, contract, product, addTransactionFeeForProductToContractRequest)); + } + + return result; + } + + public static List<(EstateDetails, Guid, AddMerchantDeviceRequest)> ToAddMerchantDeviceRequests(this DataTableRows tableRows, List estateDetailsList) + { + List<(EstateDetails, Guid, AddMerchantDeviceRequest)> result = new List<(EstateDetails, Guid, AddMerchantDeviceRequest)>(); + + foreach (DataTableRow tableRow in tableRows) + { + String estateName = ReqnrollTableHelper.GetStringRowValue(tableRow, "EstateName"); + EstateDetails estateDetails = estateDetailsList.SingleOrDefault(e => e.EstateName == estateName); + estateDetails.ShouldNotBeNull(); + + String merchantName = ReqnrollTableHelper.GetStringRowValue(tableRow, "MerchantName"); + Guid merchantId = estateDetails.GetMerchantId(merchantName); + + String deviceIdentifier = ReqnrollTableHelper.GetStringRowValue(tableRow, "DeviceIdentifier"); + + AddMerchantDeviceRequest addMerchantDeviceRequest = new AddMerchantDeviceRequest + { + DeviceIdentifier = deviceIdentifier + }; + + result.Add((estateDetails, merchantId, addMerchantDeviceRequest)); + } + + return result; + } + + public static List<(EstateDetails, Guid, Guid)> ToAddContractToMerchantRequests(this DataTableRows tableRows, List estateDetailsList) + { + List<(EstateDetails, Guid, Guid)> result = new List<(EstateDetails, Guid, Guid)>(); + + foreach (DataTableRow tableRow in tableRows) + { + String estateName = ReqnrollTableHelper.GetStringRowValue(tableRow, "EstateName"); + EstateDetails estateDetails = estateDetailsList.SingleOrDefault(e => e.EstateName == estateName); + estateDetails.ShouldNotBeNull(); + + String? merchantName = ReqnrollTableHelper.GetStringRowValue(tableRow, "MerchantName"); + Guid merchantId = estateDetails.GetMerchantId(merchantName); + + String contractName = ReqnrollTableHelper.GetStringRowValue(tableRow, "ContractDescription"); + Contract contract = estateDetails.GetContract(contractName); + result.Add((estateDetails, merchantId, contract.ContractId)); + } + + return result; + } + + public static List<(EstateDetails, Guid, MakeMerchantDepositRequest)> ToMakeMerchantDepositRequest(this DataTableRows tableRows, List estateDetailsList) + { + List<(EstateDetails, Guid, MakeMerchantDepositRequest)> result = new List<(EstateDetails, Guid, MakeMerchantDepositRequest)>(); + + foreach (DataTableRow tableRow in tableRows) + { + String estateName = ReqnrollTableHelper.GetStringRowValue(tableRow, "EstateName"); + EstateDetails estateDetails = estateDetailsList.SingleOrDefault(e => e.EstateName == estateName); + estateDetails.ShouldNotBeNull(); + + String merchantName = ReqnrollTableHelper.GetStringRowValue(tableRow, "MerchantName"); + Guid merchantId = estateDetails.GetMerchantId(merchantName); + + MakeMerchantDepositRequest makeMerchantDepositRequest = new MakeMerchantDepositRequest + { + DepositDateTime = ReqnrollTableHelper.GetDateForDateString(ReqnrollTableHelper.GetStringRowValue(tableRow, "DateTime"), DateTime.UtcNow), + Reference = ReqnrollTableHelper.GetStringRowValue(tableRow, "Reference"), + Amount = ReqnrollTableHelper.GetDecimalValue(tableRow, "Amount") + }; + + result.Add((estateDetails, merchantId, makeMerchantDepositRequest)); + } + + return result; + } + + public static List ToCreateNewUserRequests(this DataTableRows tableRows, List estateDetailsList) + { + List createUserRequests = new List(); + foreach (DataTableRow tableRow in tableRows) + { + Int32 userType = tableRow.ContainsKey("MerchantName") switch + { + true => 2, + _ => 1 + }; + + String estateName = ReqnrollTableHelper.GetStringRowValue(tableRow, "EstateName"); + EstateDetails estateDetails = estateDetailsList.SingleOrDefault(e => e.EstateName == estateName); + estateDetails.ShouldNotBeNull(); + String merchantName = null; + Guid? merchantId = null; + if (userType == 2) + { + merchantName = ReqnrollTableHelper.GetStringRowValue(tableRow, "MerchantName"); + merchantId = estateDetails.GetMerchant(merchantName).MerchantId; + } + + CreateNewUserRequest createUserRequest = new CreateNewUserRequest + { + EmailAddress = + ReqnrollTableHelper.GetStringRowValue(tableRow, "EmailAddress"), + FamilyName = + ReqnrollTableHelper.GetStringRowValue(tableRow, "FamilyName"), + GivenName = + ReqnrollTableHelper.GetStringRowValue(tableRow, "GivenName"), + MiddleName = + ReqnrollTableHelper.GetStringRowValue(tableRow, "MiddleName"), + Password = + ReqnrollTableHelper.GetStringRowValue(tableRow, "Password"), + UserType = userType, + EstateId = estateDetails.EstateId, + MerchantId = merchantId, + MerchantName = merchantName + }; + createUserRequests.Add(createUserRequest); + } + return createUserRequests; + } + + public static List ToOperatorDetails(this DataTableRows tableRows) + { + List results = new List(); + foreach (DataTableRow tableRow in tableRows) + { + String operatorName = ReqnrollTableHelper.GetStringRowValue(tableRow, "OperatorName"); + results.Add(operatorName); + } + + return results; + } + + public static List ToSecurityUsersDetails(this DataTableRows tableRows) + { + List results = new List(); + foreach (DataTableRow tableRow in tableRows) + { + String emailAddress = ReqnrollTableHelper.GetStringRowValue(tableRow, "EmailAddress"); + results.Add(emailAddress); + } + + return results; + } } \ No newline at end of file diff --git a/TransactionProcessor.IntegrationTesting.Helpers/SubscriptionsHelper.cs b/TransactionProcessor.IntegrationTesting.Helpers/SubscriptionsHelper.cs index 3daa36fa..8106dcb5 100644 --- a/TransactionProcessor.IntegrationTesting.Helpers/SubscriptionsHelper.cs +++ b/TransactionProcessor.IntegrationTesting.Helpers/SubscriptionsHelper.cs @@ -5,6 +5,7 @@ public static class SubscriptionsHelper public static List<(String streamName, String groupName, Int32 maxRetries)> GetSubscriptions() { List<(String streamName, String groupName, Int32 maxRetries)> subscriptions = new(){ + ("$ce-EstateAggregate", "Transaction Processor", 2), ("$ce-EstateAggregate", "Transaction Processor - Ordered", 2), ("$ce-MerchantAggregate", "Transaction Processor - Ordered", 2), ("$ce-MerchantDepositListAggregate", "Transaction Processor - Ordered", 2), @@ -12,7 +13,22 @@ public static class SubscriptionsHelper ("$ce-TransactionAggregate", "Transaction Processor", 0), ("$ce-TransactionAggregate", "Transaction Processor - Ordered", 2), ("$ce-VoucherAggregate", "Transaction Processor", 0), - ("$ce-VoucherAggregate", "Transaction Processor - Ordered", 2) + ("$ce-VoucherAggregate", "Transaction Processor - Ordered", 2), + + ("$ce-CallbackMessageAggregate", "Estate Management", 0), + ("$ce-ContractAggregate", "Estate Management", 0), + ("$ce-FileAggregate", "Estate Management", 0), + ("$ce-FloatAggregate", "Estate Management", 0), + ("$ce-MerchantAggregate", "Estate Management", 0), + ("$ce-MerchantStatementAggregate", "Estate Management", 0), + ("$ce-MerchantStatementAggregate", "Estate Management - Ordered", 0), + ("$ce-ReconciliationAggregate", "Estate Management", 0), + ("$ce-SettlementAggregate", "Estate Management", 0), + ("$ce-TransactionAggregate", "Estate Management", 0), + ("$ce-TransactionAggregate", "Estate Management - Ordered", 0), + ("$ce-VoucherAggregate", "Estate Management", 0), + ("$ce-OperatorAggregate", "Estate Management", 0), + }; return subscriptions; diff --git a/TransactionProcessor.IntegrationTesting.Helpers/TransactionProcessor.IntegrationTesting.Helpers.csproj b/TransactionProcessor.IntegrationTesting.Helpers/TransactionProcessor.IntegrationTesting.Helpers.csproj index d81a1a9e..ccfa6289 100644 --- a/TransactionProcessor.IntegrationTesting.Helpers/TransactionProcessor.IntegrationTesting.Helpers.csproj +++ b/TransactionProcessor.IntegrationTesting.Helpers/TransactionProcessor.IntegrationTesting.Helpers.csproj @@ -9,8 +9,8 @@ - + diff --git a/TransactionProcessor.IntegrationTesting.Helpers/TransactionProcessorSteps.cs b/TransactionProcessor.IntegrationTesting.Helpers/TransactionProcessorSteps.cs index d2434037..ff4f7c5d 100644 --- a/TransactionProcessor.IntegrationTesting.Helpers/TransactionProcessorSteps.cs +++ b/TransactionProcessor.IntegrationTesting.Helpers/TransactionProcessorSteps.cs @@ -1,4 +1,12 @@ using EventStore.Client; +using SimpleResults; +using TransactionProcessor.DataTransferObjects.Requests.Contract; +using TransactionProcessor.DataTransferObjects.Requests.Estate; +using TransactionProcessor.DataTransferObjects.Requests.Merchant; +using TransactionProcessor.DataTransferObjects.Requests.Operator; +using TransactionProcessor.DataTransferObjects.Responses.Contract; +using TransactionProcessor.DataTransferObjects.Responses.Estate; +using TransactionProcessor.DataTransferObjects.Responses.Operator; namespace TransactionProcessor.IntegrationTesting.Helpers; @@ -8,10 +16,10 @@ namespace TransactionProcessor.IntegrationTesting.Helpers; using System.Text.Json; using Client; using DataTransferObjects; -using EstateManagement.IntegrationTesting.Helpers; using Newtonsoft.Json; using Shared.IntegrationTesting; using Shouldly; +using TransactionProcessor.DataTransferObjects.Responses.Merchant; public class TransactionProcessorSteps { @@ -39,26 +47,51 @@ public async Task WhenIPerformTheFollowingTransactions(String accessToken, List< } } - public async Task WhenICreateTheFollowingMerchants(String accessToken, Guid estateId, Guid merchantId){ - await Retry.For(async () => { + public async Task> WhenICreateTheFollowingMerchants(string accessToken, List<(EstateDetails estate, CreateMerchantRequest request)> requests) + { + List responses = new List(); + + List<(Guid, Guid, String)> merchants = new List<(Guid, Guid, String)>(); + + foreach ((EstateDetails estate, CreateMerchantRequest request) request in requests) + { + + Result? result = await this.TransactionProcessorClient + .CreateMerchant(accessToken, request.estate.EstateId, request.request, CancellationToken.None) + .ConfigureAwait(false); + + result.IsSuccess.ShouldBeTrue(); + + merchants.Add((request.estate.EstateId, request.request.MerchantId.Value, request.request.Name)); + } + + foreach ((Guid, Guid, String) m in merchants) + { + await Retry.For(async () => { + MerchantResponse merchant = await this.TransactionProcessorClient + .GetMerchant(accessToken, m.Item1, m.Item2, CancellationToken.None) + .ConfigureAwait(false); + responses.Add(merchant); + string projectionName = "MerchantBalanceProjection"; - String partitionId = $"MerchantBalance-{merchantId:N}"; + String partitionId = $"MerchantBalance-{m.Item2:N}"; - dynamic gg = await this.ProjectionManagementClient.GetStateAsync( - projectionName, partitionId); - JsonElement x = (JsonElement)gg; + dynamic gg = await this.ProjectionManagementClient.GetStateAsync( + projectionName, partitionId); + JsonElement x = (JsonElement)gg; - MerchantBalanceResponse response = await this.TransactionProcessorClient.GetMerchantBalance(accessToken, estateId, merchantId, CancellationToken.None); + MerchantBalanceResponse response = await this.TransactionProcessorClient.GetMerchantBalance(accessToken, m.Item1, m.Item2, CancellationToken.None); - response.ShouldNotBeNull(); - - // Force a read model database hit - MerchantBalanceResponse response2 = await this.TransactionProcessorClient.GetMerchantBalance(accessToken, estateId, merchantId, CancellationToken.None, liveBalance:false); + response.ShouldNotBeNull(); - response2.ShouldNotBeNull(); - }, - TimeSpan.FromMinutes(2), - TimeSpan.FromSeconds(30)); + // Force a read model database hit + MerchantBalanceResponse response2 = await this.TransactionProcessorClient.GetMerchantBalance(accessToken, m.Item1, m.Item2, CancellationToken.None, liveBalance: false); + + response2.ShouldNotBeNull(); + }); + } + + return responses; } public void ValidateTransactions(List<(SerialisedMessage, String, String, String)> transactions) @@ -273,4 +306,422 @@ await this.TransactionProcessorClient.GetSettlementByDate(accessToken, TimeSpan.FromMinutes(3)); } } + + public async Task> WhenICreateTheFollowingEstatesX(String accessToken, List requests) + { + foreach (CreateEstateRequest createEstateRequest in requests) + { + Result? result = await this.TransactionProcessorClient + .CreateEstate(accessToken, createEstateRequest, CancellationToken.None) + .ConfigureAwait(false); + + result.IsSuccess.ShouldBeTrue(); + } + + List results = new List(); + foreach (CreateEstateRequest createEstateRequest in requests) + { + EstateResponse estate = null; + await Retry.For(async () => { + List? estates = await this.TransactionProcessorClient + .GetEstates(accessToken, createEstateRequest.EstateId, CancellationToken.None).ConfigureAwait(false); + estates.ShouldNotBeNull(); + estates.Count.ShouldBe(1); + estate = estates.Single(); + }, + retryFor: TimeSpan.FromSeconds(180)).ConfigureAwait(false); + + estate.EstateName.ShouldBe(createEstateRequest.EstateName); + results.Add(estate); + } + + return results; + } + + public async Task> WhenIAssignTheFollowingOperatorToTheMerchants(string accessToken, List<(EstateDetails estate, Guid merchantId, DataTransferObjects.Requests.Merchant.AssignOperatorRequest request)> requests) + { + + List<(EstateDetails, MerchantOperatorResponse)> result = new(); + + List<(EstateDetails estate, Guid merchantId, Guid operatorId)> merchantOperators = new(); + foreach ((EstateDetails estate, Guid merchantId, DataTransferObjects.Requests.Merchant.AssignOperatorRequest request) request in requests) + { + await this.TransactionProcessorClient.AssignOperatorToMerchant(accessToken, + request.estate.EstateId, + request.merchantId, + request.request, + CancellationToken.None).ConfigureAwait(false); + + merchantOperators.Add((request.estate, request.merchantId, request.request.OperatorId)); + } + + foreach (var m in merchantOperators) + { + await Retry.For(async () => { + MerchantResponse merchant = await this.TransactionProcessorClient + .GetMerchant(accessToken, m.estate.EstateId, m.merchantId, CancellationToken.None) + .ConfigureAwait(false); + MerchantOperatorResponse op = merchant.Operators.SingleOrDefault(o => o.OperatorId == m.operatorId); + op.ShouldNotBeNull(); + result.Add((m.estate, op)); + }); + } + + return result; + } + + public async Task> WhenICreateTheFollowingOperators(String accessToken, List<(EstateDetails estate, CreateOperatorRequest request)> requests) + { + List<(Guid, EstateOperatorResponse)> results = new List<(Guid, EstateOperatorResponse)>(); + foreach ((EstateDetails estate, CreateOperatorRequest request) request in requests) + { + Result? result = await this.TransactionProcessorClient + .CreateOperator(accessToken, + request.estate.EstateId, + request.request, + CancellationToken.None).ConfigureAwait(false); + + result.IsSuccess.ShouldBeTrue(); + } + + foreach ((EstateDetails estate, CreateOperatorRequest request) request in requests) + { + await Retry.For(async () => { + Result>? operators = await this.TransactionProcessorClient + .GetOperators(accessToken, request.estate.EstateId, CancellationToken.None).ConfigureAwait(false); + operators.IsSuccess.ShouldBeTrue(); + var @operator = operators.Data.SingleOrDefault(o => o.Name == request.request.Name); + @operator.ShouldNotBeNull(); + request.estate.AddOperator(@operator.OperatorId, request.request.Name); + results.Add((request.estate.EstateId, + new EstateOperatorResponse + { + OperatorId = @operator.OperatorId, + Name = request.request.Name, + RequireCustomMerchantNumber = request.request.RequireCustomMerchantNumber.GetValueOrDefault(), + RequireCustomTerminalNumber = request.request.RequireCustomTerminalNumber.GetValueOrDefault() + })); + }); + } + + return results; + } + + public async Task GivenIHaveAssignedTheFollowingOperatorsToTheEstates(String accessToken, List<(EstateDetails estate, DataTransferObjects.Requests.Estate.AssignOperatorRequest request)> requests) + { + List<(Guid, EstateOperatorResponse)> results = new List<(Guid, EstateOperatorResponse)>(); + foreach ((EstateDetails estate, DataTransferObjects.Requests.Estate.AssignOperatorRequest request) request in requests) + { + await this.TransactionProcessorClient.AssignOperatorToEstate(accessToken, request.estate.EstateId, request.request, CancellationToken.None); + } + + // verify at the read model + foreach (var request in requests) + { + await Retry.For(async () => { + EstateResponse e = await this.TransactionProcessorClient.GetEstate(accessToken, + request.estate.EstateId, + CancellationToken.None); + EstateOperatorResponse operatorResponse = e.Operators.SingleOrDefault(o => o.OperatorId == request.request.OperatorId); + operatorResponse.ShouldNotBeNull(); + results.Add((request.estate.EstateId, operatorResponse)); + + request.estate.AddAssignedOperator(operatorResponse.OperatorId); + }, + retryFor: TimeSpan.FromSeconds(180)).ConfigureAwait(false); + } + } + + public async Task> GivenICreateAContractWithTheFollowingValues(string accessToken, List<(EstateDetails, CreateContractRequest)> requests) + { + List contractList = new List(); + + foreach ((EstateDetails, CreateContractRequest) request in requests) + { + Result? result = await this.TransactionProcessorClient.CreateContract(accessToken, request.Item1.EstateId, request.Item2, + CancellationToken.None); + result.IsSuccess.ShouldBeTrue(); + } + + foreach ((EstateDetails, CreateContractRequest) request in requests) + { + + await Retry.For(async () => { + Result> getContractsResult = await this.TransactionProcessorClient.GetContracts(accessToken, request.Item1.EstateId, CancellationToken.None).ConfigureAwait(false); + getContractsResult.Data.ShouldNotBeNull(); + ContractResponse contract = getContractsResult.Data.Single(c => c.Description == request.Item2.Description); + contractList.Add(contract); + }); + } + + return contractList; + } + + public async Task WhenICreateTheFollowingProducts(String accessToken, List<(EstateDetails, Contract, AddProductToContractRequest)> requests) + { + List<(EstateDetails, Contract, AddProductToContractRequest)> estateContractProducts = new(); + foreach ((EstateDetails, Contract, AddProductToContractRequest) request in requests) + { + var result = await this.TransactionProcessorClient.AddProductToContract(accessToken, + request.Item1.EstateId, + request.Item2.ContractId, + request.Item3, + CancellationToken.None); + estateContractProducts.Add((request.Item1, request.Item2, request.Item3)); + } + + foreach ((EstateDetails, Contract, AddProductToContractRequest) estateContractProduct in estateContractProducts) + { + + await Retry.For(async () => { + ContractResponse contract = await this.TransactionProcessorClient.GetContract(accessToken, estateContractProduct.Item1.EstateId, estateContractProduct.Item2.ContractId, CancellationToken.None).ConfigureAwait(false); + contract.ShouldNotBeNull(); + + ContractProduct product = contract.Products.SingleOrDefault(c => c.Name == estateContractProduct.Item3.ProductName); + product.ShouldNotBeNull(); + + estateContractProduct.Item2.AddProduct(product.ProductId, + estateContractProduct.Item3.ProductName, + estateContractProduct.Item3.DisplayText, + estateContractProduct.Item3.Value); + }); + } + } + + public async Task WhenIAddTheFollowingTransactionFees(String accessToken, List<(EstateDetails, Contract, Product, AddTransactionFeeForProductToContractRequest)> requests) + { + List<(EstateDetails, Contract, Product, AddTransactionFeeForProductToContractRequest)> estateContractProductsFees = new(); + foreach ((EstateDetails, Contract, Product, AddTransactionFeeForProductToContractRequest) request in requests) + { + var result = await this.TransactionProcessorClient.AddTransactionFeeForProductToContract(accessToken, + request.Item1.EstateId, + request.Item2.ContractId, + request.Item3.ProductId, + request.Item4, + CancellationToken.None); + } + + foreach ((EstateDetails, Contract, Product, AddTransactionFeeForProductToContractRequest) estateContractProductsFee in estateContractProductsFees) + { + await Retry.For(async () => { + ContractResponse contract = await this.TransactionProcessorClient.GetContract(accessToken, estateContractProductsFee.Item1.EstateId, estateContractProductsFee.Item2.ContractId, CancellationToken.None).ConfigureAwait(false); + contract.ShouldNotBeNull(); + + ContractProduct product = contract.Products.SingleOrDefault(c => c.ProductId == estateContractProductsFee.Item3.ProductId); + product.ShouldNotBeNull(); + + var transactionFee = product.TransactionFees.SingleOrDefault(f => f.Description == estateContractProductsFee.Item4.Description); + transactionFee.ShouldNotBeNull(); + + estateContractProductsFee.Item3.AddTransactionFee(transactionFee.TransactionFeeId, + estateContractProductsFee.Item4.CalculationType, + estateContractProductsFee.Item4.FeeType, + estateContractProductsFee.Item4.Description, + estateContractProductsFee.Item4.Value); + + List? fees = await this.TransactionProcessorClient.GetTransactionFeesForProduct(accessToken, + estateContractProductsFee.Item1.EstateId, + estateContractProductsFee.Item1.GetMerchants().First().MerchantId, + contract.ContractId, + product.ProductId, + CancellationToken.None); + var fee = fees.SingleOrDefault(f => f.TransactionFeeId == transactionFee.TransactionFeeId); + fee.ShouldNotBeNull(); + }); + } + } + + public async Task> GivenIHaveAssignedTheFollowingDevicesToTheMerchants(string accessToken, List<(EstateDetails, Guid, AddMerchantDeviceRequest)> requests) + { + List<(EstateDetails, MerchantResponse, String)> result = new(); + List<(EstateDetails estate, Guid merchantId, Guid deviceId)> merchantDevices = new(); + foreach ((EstateDetails, Guid, AddMerchantDeviceRequest) request in requests) + { + await this.TransactionProcessorClient.AddDeviceToMerchant(accessToken, request.Item1.EstateId, request.Item2, request.Item3, CancellationToken.None).ConfigureAwait(false); + } + + foreach (var m in merchantDevices) + { + await Retry.For(async () => { + MerchantResponse merchant = await this.TransactionProcessorClient + .GetMerchant(accessToken, m.estate.EstateId, m.merchantId, CancellationToken.None) + .ConfigureAwait(false); + var device = merchant.Devices.SingleOrDefault(o => o.Key == m.deviceId); + device.Value.ShouldNotBeNull(); + result.Add((m.estate, merchant, device.Value)); + }); + } + + return result; + } + + public async Task WhenIAddTheFollowingContractsToTheFollowingMerchants(String accessToken, List<(EstateDetails, Guid, Guid)> requests) + { + foreach ((EstateDetails, Guid, Guid) request in requests) + { + AddMerchantContractRequest addMerchantContractRequest = new AddMerchantContractRequest + { + ContractId = request.Item3 + }; + await this.TransactionProcessorClient.AddContractToMerchant(accessToken, request.Item1.EstateId, request.Item2, addMerchantContractRequest, CancellationToken.None); + } + } + + public async Task GivenIMakeTheFollowingManualMerchantDeposits(String accessToken, (EstateDetails, Guid, MakeMerchantDepositRequest) request) + { + var result = await this.TransactionProcessorClient.MakeMerchantDeposit(accessToken, request.Item1.EstateId, request.Item2, request.Item3, CancellationToken.None).ConfigureAwait(false); + result.IsSuccess.ShouldBeTrue(); + } + + public async Task WhenICreateTheFollowingSecurityUsers(String accessToken, List requests, List estateDetailsList) + { + foreach (CreateNewUserRequest createNewUserRequest in requests) + { + var estateDetails = estateDetailsList.SingleOrDefault(e => e.EstateId == createNewUserRequest.EstateId.GetValueOrDefault()); + estateDetails.ShouldNotBeNull(); + + + if (createNewUserRequest.UserType == 1) + { + CreateEstateUserRequest request = new CreateEstateUserRequest + { + EmailAddress = createNewUserRequest.EmailAddress, + FamilyName = createNewUserRequest.FamilyName, + GivenName = createNewUserRequest.GivenName, + MiddleName = createNewUserRequest.MiddleName, + Password = createNewUserRequest.Password + }; + await this.TransactionProcessorClient.CreateEstateUser(accessToken, + estateDetails.EstateId, + request, + CancellationToken.None); + + estateDetails.SetEstateUser(request.EmailAddress, request.Password); + } + else + { + // Creating a merchant user + String token = accessToken; + if (String.IsNullOrEmpty(estateDetails.AccessToken) == false) + { + token = estateDetails.AccessToken; + } + + CreateMerchantUserRequest createMerchantUserRequest = new CreateMerchantUserRequest + { + EmailAddress = createNewUserRequest.EmailAddress, + FamilyName = createNewUserRequest.FamilyName, + GivenName = createNewUserRequest.GivenName, + MiddleName = createNewUserRequest.MiddleName, + Password = createNewUserRequest.Password + }; + + await this.TransactionProcessorClient.CreateMerchantUser(token, + estateDetails.EstateId, + createNewUserRequest.MerchantId.Value, + createMerchantUserRequest, + CancellationToken.None); + + estateDetails.AddMerchantUser(createNewUserRequest.MerchantName, createMerchantUserRequest.EmailAddress, createMerchantUserRequest.Password); + } + } + } + + public async Task WhenIGetTheEstateTheEstateDetailsAreReturnedAsFollows(String accessToken, String estateName, List estateDetailsList, List expectedEstateDetails) + { + Guid estateId = Guid.NewGuid(); + EstateDetails estateDetails = estateDetailsList.SingleOrDefault(e => e.EstateName == estateName); + estateDetails.ShouldNotBeNull(); + + String token = accessToken; + if (estateDetails != null) + { + estateId = estateDetails.EstateId; + if (String.IsNullOrEmpty(estateDetails.AccessToken) == false) + { + token = estateDetails.AccessToken; + } + } + + EstateResponse estate = await this.TransactionProcessorClient.GetEstate(token, estateId, CancellationToken.None).ConfigureAwait(false); + estate.EstateName.ShouldBe(expectedEstateDetails.Single()); + } + + public async Task WhenIGetTheEstateTheEstateOperatorDetailsAreReturnedAsFollows(String accessToken, String estateName, List estateDetailsList, List expectedOperators) + { + Guid estateId = Guid.NewGuid(); + EstateDetails estateDetails = estateDetailsList.SingleOrDefault(e => e.EstateName == estateName); + estateDetails.ShouldNotBeNull(); + + String token = accessToken; + if (estateDetails != null) + { + estateId = estateDetails.EstateId; + if (String.IsNullOrEmpty(estateDetails.AccessToken) == false) + { + token = estateDetails.AccessToken; + } + } + + Result>? getEstatesResult = await this.TransactionProcessorClient.GetEstates(token, estateId, CancellationToken.None).ConfigureAwait(false); + getEstatesResult.IsSuccess.ShouldBeTrue(); + getEstatesResult.Data.ShouldNotBeEmpty(); + var estate = getEstatesResult.Data.Single(); + foreach (String expectedOperator in expectedOperators) + { + EstateOperatorResponse? op = estate.Operators.SingleOrDefault(o => o.Name == expectedOperator); + op.ShouldNotBeNull(); + } + } + + public async Task WhenIGetTheEstateTheEstateSecurityUserDetailsAreReturnedAsFollows(String accessToken, String estateName, List estateDetailsList, List expectedSecurityUsers) + { + Guid estateId = Guid.NewGuid(); + EstateDetails estateDetails = estateDetailsList.SingleOrDefault(e => e.EstateName == estateName); + estateDetails.ShouldNotBeNull(); + + String token = accessToken; + if (estateDetails != null) + { + estateId = estateDetails.EstateId; + if (String.IsNullOrEmpty(estateDetails.AccessToken) == false) + { + token = estateDetails.AccessToken; + } + } + + EstateResponse? estate = await this.TransactionProcessorClient.GetEstate(token, estateId, CancellationToken.None).ConfigureAwait(false); + estate.ShouldNotBeNull(); + foreach (String expectedSecurityUser in expectedSecurityUsers) + { + var user = estate.SecurityUsers.SingleOrDefault(o => o.EmailAddress == expectedSecurityUser); + user.ShouldNotBeNull(); + } + } + + public async Task WhenIGetTheEstateAnErrorIsReturned(String accessToken, String estateName, List estateDetailsList) + { + Guid estateId = Guid.NewGuid(); + var result = await this.TransactionProcessorClient.GetEstate(accessToken, estateId, CancellationToken.None).ConfigureAwait(false); + result.IsSuccess.ShouldBeFalse(); + result.Status.ShouldBe(ResultStatus.NotFound); + } + + public async Task WhenIRemoveTheOperatorFromEstateTheOperatorIsRemoved(String accessToken, List estateDetailsList, String estateName, String operatorName) + { + EstateDetails estateDetails = estateDetailsList.SingleOrDefault(e => e.EstateName == estateName); + estateDetails.ShouldNotBeNull(); + Guid operatorId = estateDetails.GetOperatorId(operatorName); + + await this.TransactionProcessorClient.RemoveOperatorFromEstate(accessToken, estateDetails.EstateId, operatorId, CancellationToken.None); + + await Retry.For(async () => { + EstateResponse? estateResponse = await this.TransactionProcessorClient.GetEstate(accessToken, estateDetails.EstateId, CancellationToken.None); + estateResponse.ShouldNotBeNull(); + + EstateOperatorResponse? operatorResponse = estateResponse.Operators.SingleOrDefault(c => c.OperatorId == operatorId); + operatorResponse.ShouldNotBeNull(); + operatorResponse.IsDeleted.ShouldBeTrue(); + }); + } } \ No newline at end of file diff --git a/TransactionProcessor.IntegrationTests/Common/DockerHelper.cs b/TransactionProcessor.IntegrationTests/Common/DockerHelper.cs index 66c1c90c..2def058c 100644 --- a/TransactionProcessor.IntegrationTests/Common/DockerHelper.cs +++ b/TransactionProcessor.IntegrationTests/Common/DockerHelper.cs @@ -1,4 +1,5 @@ using TransactionProcessor.BusinessLogic.Common; +using TransactionProcessor.Database.Contexts; namespace TransactionProcessor.IntegrationTests.Common { @@ -13,7 +14,6 @@ namespace TransactionProcessor.IntegrationTests.Common using Client; using Ductus.FluentDocker.Builders; using EstateManagement.Client; - using EstateManagement.Database.Contexts; using EventStore.Client; using global::Shared.IntegrationTesting; using SecurityService.Client; @@ -31,7 +31,7 @@ public class DockerHelper : global::Shared.IntegrationTesting.DockerHelper /// /// The estate client /// - public IIntermediateEstateClient EstateClient; + //public IIntermediateEstateClient EstateClient; public HttpClient TestHostHttpClient; @@ -81,7 +81,8 @@ public override ContainerBuilder SetupTransactionProcessorContainer(){ public override async Task CreateSubscriptions(){ List<(String streamName, String groupName, Int32 maxRetries)> subscriptions = new(); subscriptions.AddRange(MessagingService.IntegrationTesting.Helpers.SubscriptionsHelper.GetSubscriptions()); - subscriptions.AddRange(EstateManagement.IntegrationTesting.Helpers.SubscriptionsHelper.GetSubscriptions()); + //var estateSubscriptions = EstateManagement.IntegrationTesting.Helpers.SubscriptionsHelper.GetSubscriptions(); + //subscriptions.AddRange(estateSubscriptions.Where(e => e.streamName != "$ce-EstateAggregate")); subscriptions.AddRange(TransactionProcessor.IntegrationTesting.Helpers.SubscriptionsHelper.GetSubscriptions()); foreach ((String streamName, String groupName, Int32 maxRetries) subscription in subscriptions) @@ -116,7 +117,7 @@ public override async Task StartContainersForScenarioRun(String scenarioName, Do } }; HttpClient httpClient = new HttpClient(clientHandler); - this.EstateClient = new IntermediateEstateClient(new EstateClient(EstateManagementBaseAddressResolver, httpClient,2)); + //this.EstateClient = new IntermediateEstateClient(new EstateClient(EstateManagementBaseAddressResolver, httpClient,2)); this.SecurityServiceClient = new SecurityServiceClient(SecurityServiceBaseAddressResolver, httpClient); this.TransactionProcessorClient = new TransactionProcessorClient(TransactionProcessorBaseAddressResolver, httpClient); this.TestHostHttpClient= new HttpClient(clientHandler); diff --git a/TransactionProcessor.IntegrationTests/Common/EstateDetails.cs b/TransactionProcessor.IntegrationTests/Common/EstateDetails.cs index 1f00b9d4..15105c86 100644 --- a/TransactionProcessor.IntegrationTests/Common/EstateDetails.cs +++ b/TransactionProcessor.IntegrationTests/Common/EstateDetails.cs @@ -1,4 +1,4 @@ -namespace TransactionProcessor.IntegrationTests.Common +/*namespace TransactionProcessor.IntegrationTests.Common { using System; using System.Collections.Generic; @@ -9,7 +9,7 @@ /// /// /// - public class EstateDetails1 + public class EstateDetails { #region Fields @@ -47,7 +47,7 @@ public class EstateDetails1 /// /// The estate identifier. /// Name of the estate. - private EstateDetails1(Guid estateId, + private EstateDetails(Guid estateId, String estateName) { this.EstateId = estateId; @@ -241,10 +241,10 @@ public void AddReconciliationResponse(Guid merchantId, /// The estate identifier. /// Name of the estate. /// - public static EstateDetails1 Create(Guid estateId, + public static EstateDetails Create(Guid estateId, String estateName) { - return new EstateDetails1(estateId, estateName); + return new EstateDetails(estateId, estateName); } /// @@ -358,4 +358,4 @@ public void SetEstateUserToken(String accessToken) #endregion } -} \ No newline at end of file +}*/ \ No newline at end of file diff --git a/TransactionProcessor.IntegrationTests/Common/TestingContext.cs b/TransactionProcessor.IntegrationTests/Common/TestingContext.cs index 562a8c49..75c1163c 100644 --- a/TransactionProcessor.IntegrationTests/Common/TestingContext.cs +++ b/TransactionProcessor.IntegrationTests/Common/TestingContext.cs @@ -1,4 +1,7 @@ -namespace TransactionProcessor.IntegrationTests.Common +using TransactionProcessor.DataTransferObjects.Responses.Merchant; +using TransactionProcessor.IntegrationTesting.Helpers; + +namespace TransactionProcessor.IntegrationTests.Common { using System; using System.Collections.Generic; @@ -6,9 +9,6 @@ using System.Threading; using System.Threading.Tasks; using DataTransferObjects; - using EstateManagement.DataTransferObjects.Responses; - using EstateManagement.DataTransferObjects.Responses.Merchant; - using EstateManagement.IntegrationTesting.Helpers; using global::Shared.IntegrationTesting; using global::Shared.Logger; using Newtonsoft.Json; diff --git a/TransactionProcessor.IntegrationTests/Features/Estate.feature b/TransactionProcessor.IntegrationTests/Features/Estate.feature new file mode 100644 index 00000000..d802eb3c --- /dev/null +++ b/TransactionProcessor.IntegrationTests/Features/Estate.feature @@ -0,0 +1,84 @@ +@base @shared +Feature: Estate + +Background: + Given the following security roles exist + | Role Name | + | Estate | + + Given I create the following api scopes + | Name | DisplayName | Description | + | estateManagement | Estate Managememt REST Scope | A scope for Estate Managememt REST | + + Given the following api resources exist + | Name | DisplayName | Secret | Scopes | UserClaims | + | estateManagement | Estate Managememt REST | Secret1 | estateManagement | merchantId, estateId, role | + + Given the following clients exist + | ClientId | ClientName | Secret | Scopes | GrantTypes | + | serviceClient | Service Client | Secret1 | estateManagement | client_credentials | + | estateClient | Estate Client | Secret1 | estateManagement | password | + + Given I have a token to access the estate management resource + | ClientId | + | serviceClient | + +Scenario: Get Estate + Given I have created the following estates + | EstateName | + | Test Estate 1 | + And I have created the following operators + | EstateName | OperatorName | RequireCustomMerchantNumber | RequireCustomTerminalNumber | + | Test Estate 1 | Test Operator 1 | True | True | + | Test Estate 1 | Test Operator 2 | True | True | + And I have assigned the following operators to the estates + | EstateName | OperatorName | + | Test Estate 1 | Test Operator 1 | + | Test Estate 1 | Test Operator 2 | + And I have created the following security users + | EmailAddress | Password | GivenName | FamilyName | EstateName | + | estateuser1@testestate1.co.uk | 123456 | TestEstate | User1 | Test Estate 1 | + | estateuser2@testestate1.co.uk | 123456 | TestEstate | User2 | Test Estate 1 | + When I get the estate "Test Estate 1" the estate details are returned as follows + | EstateName | + | Test Estate 1 | + When I get the estate "Test Estate 1" the estate operator details are returned as follows + | OperatorName | + | Test Operator 1 | + | Test Operator 2 | + When I get the estate "Test Estate 1" the estate security user details are returned as follows + | EmailAddress | + | estateuser1@testestate1.co.uk | + | estateuser2@testestate1.co.uk | + When I get the estate "Test Estate 2" an error is returned + Given I am logged in as "estateuser1@testestate1.co.uk" with password "123456" for Estate "Test Estate 1" with client "estateClient" + When I get the estate "Test Estate 1" the estate details are returned as follows + | EstateName | + | Test Estate 1 | + When I get the estate "Test Estate 1" the estate operator details are returned as follows + | OperatorName | + | Test Operator 1 | + | Test Operator 2 | + When I get the estate "Test Estate 1" the estate security user details are returned as follows + | EmailAddress | + | estateuser1@testestate1.co.uk | + | estateuser2@testestate1.co.uk | + When I get the estate "Test Estate 2" an error is returned + +Scenario: Update Estate + Given I have created the following estates + | EstateName | + | Test Estate 1 | + And I have created the following operators + | EstateName | OperatorName | RequireCustomMerchantNumber | RequireCustomTerminalNumber | + | Test Estate 1 | Test Operator 1 | True | True | + | Test Estate 1 | Test Operator 2 | True | True | + And I have assigned the following operators to the estates + | EstateName | OperatorName | + | Test Estate 1 | Test Operator 1 | + | Test Estate 1 | Test Operator 2 | + And I have created the following security users + | EmailAddress | Password | GivenName | FamilyName | EstateName | + | estateuser1@testestate1.co.uk | 123456 | TestEstate | User1 | Test Estate 1 | + | estateuser2@testestate1.co.uk | 123456 | TestEstate | User2 | Test Estate 1 | + When I remove the operator 'Test Operator 1' from estate 'Test Estate 1' the operator is removed \ No newline at end of file diff --git a/TransactionProcessor.IntegrationTests/Features/Estate.feature.cs b/TransactionProcessor.IntegrationTests/Features/Estate.feature.cs new file mode 100644 index 00000000..8f8fa3c2 --- /dev/null +++ b/TransactionProcessor.IntegrationTests/Features/Estate.feature.cs @@ -0,0 +1,381 @@ +// ------------------------------------------------------------------------------ +// +// This code was generated by Reqnroll (https://www.reqnroll.net/). +// Reqnroll Version:1.0.0.0 +// Reqnroll Generator Version:1.0.0.0 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +// ------------------------------------------------------------------------------ +#region Designer generated code +#pragma warning disable +namespace TransactionProcessor.IntegrationTests.Features +{ + using Reqnroll; + using System; + using System.Linq; + + + [System.CodeDom.Compiler.GeneratedCodeAttribute("Reqnroll", "1.0.0.0")] + [System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [NUnit.Framework.TestFixtureAttribute()] + [NUnit.Framework.DescriptionAttribute("Estate")] + [NUnit.Framework.CategoryAttribute("base")] + [NUnit.Framework.CategoryAttribute("shared")] + public partial class EstateFeature + { + + private Reqnroll.ITestRunner testRunner; + + private static string[] featureTags = new string[] { + "base", + "shared"}; + +#line 1 "Estate.feature" +#line hidden + + [NUnit.Framework.OneTimeSetUpAttribute()] + public virtual async System.Threading.Tasks.Task FeatureSetupAsync() + { + testRunner = Reqnroll.TestRunnerManager.GetTestRunnerForAssembly(null, NUnit.Framework.TestContext.CurrentContext.WorkerId); + Reqnroll.FeatureInfo featureInfo = new Reqnroll.FeatureInfo(new System.Globalization.CultureInfo("en-US"), "Features", "Estate", null, ProgrammingLanguage.CSharp, featureTags); + await testRunner.OnFeatureStartAsync(featureInfo); + } + + [NUnit.Framework.OneTimeTearDownAttribute()] + public virtual async System.Threading.Tasks.Task FeatureTearDownAsync() + { + await testRunner.OnFeatureEndAsync(); + testRunner = null; + } + + [NUnit.Framework.SetUpAttribute()] + public async System.Threading.Tasks.Task TestInitializeAsync() + { + } + + [NUnit.Framework.TearDownAttribute()] + public async System.Threading.Tasks.Task TestTearDownAsync() + { + await testRunner.OnScenarioEndAsync(); + } + + public void ScenarioInitialize(Reqnroll.ScenarioInfo scenarioInfo) + { + testRunner.OnScenarioInitialize(scenarioInfo); + testRunner.ScenarioContext.ScenarioContainer.RegisterInstanceAs(NUnit.Framework.TestContext.CurrentContext); + } + + public async System.Threading.Tasks.Task ScenarioStartAsync() + { + await testRunner.OnScenarioStartAsync(); + } + + public async System.Threading.Tasks.Task ScenarioCleanupAsync() + { + await testRunner.CollectScenarioErrorsAsync(); + } + + public virtual async System.Threading.Tasks.Task FeatureBackgroundAsync() + { +#line 4 +#line hidden + Reqnroll.Table table1 = new Reqnroll.Table(new string[] { + "Role Name"}); + table1.AddRow(new string[] { + "Estate"}); +#line 5 + await testRunner.GivenAsync("the following security roles exist", ((string)(null)), table1, "Given "); +#line hidden + Reqnroll.Table table2 = new Reqnroll.Table(new string[] { + "Name", + "DisplayName", + "Description"}); + table2.AddRow(new string[] { + "estateManagement", + "Estate Managememt REST Scope", + "A scope for Estate Managememt REST"}); +#line 9 + await testRunner.GivenAsync("I create the following api scopes", ((string)(null)), table2, "Given "); +#line hidden + Reqnroll.Table table3 = new Reqnroll.Table(new string[] { + "Name", + "DisplayName", + "Secret", + "Scopes", + "UserClaims"}); + table3.AddRow(new string[] { + "estateManagement", + "Estate Managememt REST", + "Secret1", + "estateManagement", + "merchantId, estateId, role"}); +#line 13 + await testRunner.GivenAsync("the following api resources exist", ((string)(null)), table3, "Given "); +#line hidden + Reqnroll.Table table4 = new Reqnroll.Table(new string[] { + "ClientId", + "ClientName", + "Secret", + "Scopes", + "GrantTypes"}); + table4.AddRow(new string[] { + "serviceClient", + "Service Client", + "Secret1", + "estateManagement", + "client_credentials"}); + table4.AddRow(new string[] { + "estateClient", + "Estate Client", + "Secret1", + "estateManagement", + "password"}); +#line 17 + await testRunner.GivenAsync("the following clients exist", ((string)(null)), table4, "Given "); +#line hidden + Reqnroll.Table table5 = new Reqnroll.Table(new string[] { + "ClientId"}); + table5.AddRow(new string[] { + "serviceClient"}); +#line 22 + await testRunner.GivenAsync("I have a token to access the estate management resource", ((string)(null)), table5, "Given "); +#line hidden + } + + [NUnit.Framework.TestAttribute()] + [NUnit.Framework.DescriptionAttribute("Get Estate")] + public async System.Threading.Tasks.Task GetEstate() + { + string[] tagsOfScenario = ((string[])(null)); + System.Collections.Specialized.OrderedDictionary argumentsOfScenario = new System.Collections.Specialized.OrderedDictionary(); + Reqnroll.ScenarioInfo scenarioInfo = new Reqnroll.ScenarioInfo("Get Estate", null, tagsOfScenario, argumentsOfScenario, featureTags); +#line 26 +this.ScenarioInitialize(scenarioInfo); +#line hidden + if ((TagHelper.ContainsIgnoreTag(tagsOfScenario) || TagHelper.ContainsIgnoreTag(featureTags))) + { + testRunner.SkipScenario(); + } + else + { + await this.ScenarioStartAsync(); +#line 4 +await this.FeatureBackgroundAsync(); +#line hidden + Reqnroll.Table table6 = new Reqnroll.Table(new string[] { + "EstateName"}); + table6.AddRow(new string[] { + "Test Estate 1"}); +#line 27 + await testRunner.GivenAsync("I have created the following estates", ((string)(null)), table6, "Given "); +#line hidden + Reqnroll.Table table7 = new Reqnroll.Table(new string[] { + "EstateName", + "OperatorName", + "RequireCustomMerchantNumber", + "RequireCustomTerminalNumber"}); + table7.AddRow(new string[] { + "Test Estate 1", + "Test Operator 1", + "True", + "True"}); + table7.AddRow(new string[] { + "Test Estate 1", + "Test Operator 2", + "True", + "True"}); +#line 30 + await testRunner.AndAsync("I have created the following operators", ((string)(null)), table7, "And "); +#line hidden + Reqnroll.Table table8 = new Reqnroll.Table(new string[] { + "EstateName", + "OperatorName"}); + table8.AddRow(new string[] { + "Test Estate 1", + "Test Operator 1"}); + table8.AddRow(new string[] { + "Test Estate 1", + "Test Operator 2"}); +#line 34 + await testRunner.AndAsync("I have assigned the following operators to the estates", ((string)(null)), table8, "And "); +#line hidden + Reqnroll.Table table9 = new Reqnroll.Table(new string[] { + "EmailAddress", + "Password", + "GivenName", + "FamilyName", + "EstateName"}); + table9.AddRow(new string[] { + "estateuser1@testestate1.co.uk", + "123456", + "TestEstate", + "User1", + "Test Estate 1"}); + table9.AddRow(new string[] { + "estateuser2@testestate1.co.uk", + "123456", + "TestEstate", + "User2", + "Test Estate 1"}); +#line 38 + await testRunner.AndAsync("I have created the following security users", ((string)(null)), table9, "And "); +#line hidden + Reqnroll.Table table10 = new Reqnroll.Table(new string[] { + "EstateName"}); + table10.AddRow(new string[] { + "Test Estate 1"}); +#line 42 + await testRunner.WhenAsync("I get the estate \"Test Estate 1\" the estate details are returned as follows", ((string)(null)), table10, "When "); +#line hidden + Reqnroll.Table table11 = new Reqnroll.Table(new string[] { + "OperatorName"}); + table11.AddRow(new string[] { + "Test Operator 1"}); + table11.AddRow(new string[] { + "Test Operator 2"}); +#line 45 + await testRunner.WhenAsync("I get the estate \"Test Estate 1\" the estate operator details are returned as foll" + + "ows", ((string)(null)), table11, "When "); +#line hidden + Reqnroll.Table table12 = new Reqnroll.Table(new string[] { + "EmailAddress"}); + table12.AddRow(new string[] { + "estateuser1@testestate1.co.uk"}); + table12.AddRow(new string[] { + "estateuser2@testestate1.co.uk"}); +#line 49 + await testRunner.WhenAsync("I get the estate \"Test Estate 1\" the estate security user details are returned as" + + " follows", ((string)(null)), table12, "When "); +#line hidden +#line 53 + await testRunner.WhenAsync("I get the estate \"Test Estate 2\" an error is returned", ((string)(null)), ((Reqnroll.Table)(null)), "When "); +#line hidden +#line 54 + await testRunner.GivenAsync("I am logged in as \"estateuser1@testestate1.co.uk\" with password \"123456\" for Esta" + + "te \"Test Estate 1\" with client \"estateClient\"", ((string)(null)), ((Reqnroll.Table)(null)), "Given "); +#line hidden + Reqnroll.Table table13 = new Reqnroll.Table(new string[] { + "EstateName"}); + table13.AddRow(new string[] { + "Test Estate 1"}); +#line 55 + await testRunner.WhenAsync("I get the estate \"Test Estate 1\" the estate details are returned as follows", ((string)(null)), table13, "When "); +#line hidden + Reqnroll.Table table14 = new Reqnroll.Table(new string[] { + "OperatorName"}); + table14.AddRow(new string[] { + "Test Operator 1"}); + table14.AddRow(new string[] { + "Test Operator 2"}); +#line 58 + await testRunner.WhenAsync("I get the estate \"Test Estate 1\" the estate operator details are returned as foll" + + "ows", ((string)(null)), table14, "When "); +#line hidden + Reqnroll.Table table15 = new Reqnroll.Table(new string[] { + "EmailAddress"}); + table15.AddRow(new string[] { + "estateuser1@testestate1.co.uk"}); + table15.AddRow(new string[] { + "estateuser2@testestate1.co.uk"}); +#line 62 + await testRunner.WhenAsync("I get the estate \"Test Estate 1\" the estate security user details are returned as" + + " follows", ((string)(null)), table15, "When "); +#line hidden +#line 66 + await testRunner.WhenAsync("I get the estate \"Test Estate 2\" an error is returned", ((string)(null)), ((Reqnroll.Table)(null)), "When "); +#line hidden + } + await this.ScenarioCleanupAsync(); + } + + [NUnit.Framework.TestAttribute()] + [NUnit.Framework.DescriptionAttribute("Update Estate")] + public async System.Threading.Tasks.Task UpdateEstate() + { + string[] tagsOfScenario = ((string[])(null)); + System.Collections.Specialized.OrderedDictionary argumentsOfScenario = new System.Collections.Specialized.OrderedDictionary(); + Reqnroll.ScenarioInfo scenarioInfo = new Reqnroll.ScenarioInfo("Update Estate", null, tagsOfScenario, argumentsOfScenario, featureTags); +#line 68 +this.ScenarioInitialize(scenarioInfo); +#line hidden + if ((TagHelper.ContainsIgnoreTag(tagsOfScenario) || TagHelper.ContainsIgnoreTag(featureTags))) + { + testRunner.SkipScenario(); + } + else + { + await this.ScenarioStartAsync(); +#line 4 +await this.FeatureBackgroundAsync(); +#line hidden + Reqnroll.Table table16 = new Reqnroll.Table(new string[] { + "EstateName"}); + table16.AddRow(new string[] { + "Test Estate 1"}); +#line 69 + await testRunner.GivenAsync("I have created the following estates", ((string)(null)), table16, "Given "); +#line hidden + Reqnroll.Table table17 = new Reqnroll.Table(new string[] { + "EstateName", + "OperatorName", + "RequireCustomMerchantNumber", + "RequireCustomTerminalNumber"}); + table17.AddRow(new string[] { + "Test Estate 1", + "Test Operator 1", + "True", + "True"}); + table17.AddRow(new string[] { + "Test Estate 1", + "Test Operator 2", + "True", + "True"}); +#line 72 + await testRunner.AndAsync("I have created the following operators", ((string)(null)), table17, "And "); +#line hidden + Reqnroll.Table table18 = new Reqnroll.Table(new string[] { + "EstateName", + "OperatorName"}); + table18.AddRow(new string[] { + "Test Estate 1", + "Test Operator 1"}); + table18.AddRow(new string[] { + "Test Estate 1", + "Test Operator 2"}); +#line 76 + await testRunner.AndAsync("I have assigned the following operators to the estates", ((string)(null)), table18, "And "); +#line hidden + Reqnroll.Table table19 = new Reqnroll.Table(new string[] { + "EmailAddress", + "Password", + "GivenName", + "FamilyName", + "EstateName"}); + table19.AddRow(new string[] { + "estateuser1@testestate1.co.uk", + "123456", + "TestEstate", + "User1", + "Test Estate 1"}); + table19.AddRow(new string[] { + "estateuser2@testestate1.co.uk", + "123456", + "TestEstate", + "User2", + "Test Estate 1"}); +#line 80 + await testRunner.AndAsync("I have created the following security users", ((string)(null)), table19, "And "); +#line hidden +#line 84 + await testRunner.WhenAsync("I remove the operator \'Test Operator 1\' from estate \'Test Estate 1\' the operator " + + "is removed", ((string)(null)), ((Reqnroll.Table)(null)), "When "); +#line hidden + } + await this.ScenarioCleanupAsync(); + } + } +} +#pragma warning restore +#endregion diff --git a/TransactionProcessor.IntegrationTests/Features/LogonTransaction.feature.cs b/TransactionProcessor.IntegrationTests/Features/LogonTransaction.feature.cs index eecb407b..736b067e 100644 --- a/TransactionProcessor.IntegrationTests/Features/LogonTransaction.feature.cs +++ b/TransactionProcessor.IntegrationTests/Features/LogonTransaction.feature.cs @@ -81,95 +81,95 @@ public virtual async System.Threading.Tasks.Task FeatureBackgroundAsync() { #line 4 #line hidden - Reqnroll.Table table1 = new Reqnroll.Table(new string[] { + Reqnroll.Table table20 = new Reqnroll.Table(new string[] { "Name", "DisplayName", "Description"}); - table1.AddRow(new string[] { + table20.AddRow(new string[] { "estateManagement", "Estate Managememt REST Scope", "A scope for Estate Managememt REST"}); - table1.AddRow(new string[] { + table20.AddRow(new string[] { "transactionProcessor", "Transaction Processor REST Scope", "A scope for Transaction Processor REST"}); #line 6 - await testRunner.GivenAsync("I create the following api scopes", ((string)(null)), table1, "Given "); + await testRunner.GivenAsync("I create the following api scopes", ((string)(null)), table20, "Given "); #line hidden - Reqnroll.Table table2 = new Reqnroll.Table(new string[] { + Reqnroll.Table table21 = new Reqnroll.Table(new string[] { "Name", "DisplayName", "Secret", "Scopes", "UserClaims"}); - table2.AddRow(new string[] { + table21.AddRow(new string[] { "estateManagement", "Estate Managememt REST", "Secret1", "estateManagement", "MerchantId, EstateId, role"}); - table2.AddRow(new string[] { + table21.AddRow(new string[] { "transactionProcessor", "Transaction Processor REST", "Secret1", "transactionProcessor", ""}); #line 11 - await testRunner.GivenAsync("the following api resources exist", ((string)(null)), table2, "Given "); + await testRunner.GivenAsync("the following api resources exist", ((string)(null)), table21, "Given "); #line hidden - Reqnroll.Table table3 = new Reqnroll.Table(new string[] { + Reqnroll.Table table22 = new Reqnroll.Table(new string[] { "ClientId", "ClientName", "Secret", "Scopes", "GrantTypes"}); - table3.AddRow(new string[] { + table22.AddRow(new string[] { "serviceClient", "Service Client", "Secret1", "estateManagement,transactionProcessor", "client_credentials"}); #line 16 - await testRunner.GivenAsync("the following clients exist", ((string)(null)), table3, "Given "); + await testRunner.GivenAsync("the following clients exist", ((string)(null)), table22, "Given "); #line hidden - Reqnroll.Table table4 = new Reqnroll.Table(new string[] { + Reqnroll.Table table23 = new Reqnroll.Table(new string[] { "ClientId"}); - table4.AddRow(new string[] { + table23.AddRow(new string[] { "serviceClient"}); #line 20 await testRunner.GivenAsync("I have a token to access the estate management and transaction processor resource" + - "s", ((string)(null)), table4, "Given "); + "s", ((string)(null)), table23, "Given "); #line hidden - Reqnroll.Table table5 = new Reqnroll.Table(new string[] { + Reqnroll.Table table24 = new Reqnroll.Table(new string[] { "EstateName"}); - table5.AddRow(new string[] { + table24.AddRow(new string[] { "Test Estate 1"}); #line 24 - await testRunner.GivenAsync("I have created the following estates", ((string)(null)), table5, "Given "); + await testRunner.GivenAsync("I have created the following estates", ((string)(null)), table24, "Given "); #line hidden - Reqnroll.Table table6 = new Reqnroll.Table(new string[] { + Reqnroll.Table table25 = new Reqnroll.Table(new string[] { "EstateName", "OperatorName", "RequireCustomMerchantNumber", "RequireCustomTerminalNumber"}); - table6.AddRow(new string[] { + table25.AddRow(new string[] { "Test Estate 1", "Test Operator 1", "True", "True"}); #line 28 - await testRunner.GivenAsync("I have created the following operators", ((string)(null)), table6, "Given "); + await testRunner.GivenAsync("I have created the following operators", ((string)(null)), table25, "Given "); #line hidden - Reqnroll.Table table7 = new Reqnroll.Table(new string[] { + Reqnroll.Table table26 = new Reqnroll.Table(new string[] { "EstateName", "OperatorName"}); - table7.AddRow(new string[] { + table26.AddRow(new string[] { "Test Estate 1", "Test Operator 1"}); #line 32 - await testRunner.AndAsync("I have assigned the following operators to the estates", ((string)(null)), table7, "And "); + await testRunner.AndAsync("I have assigned the following operators to the estates", ((string)(null)), table26, "And "); #line hidden - Reqnroll.Table table8 = new Reqnroll.Table(new string[] { + Reqnroll.Table table27 = new Reqnroll.Table(new string[] { "MerchantName", "AddressLine1", "Town", @@ -178,7 +178,7 @@ await testRunner.GivenAsync("I have a token to access the estate management and "ContactName", "EmailAddress", "EstateName"}); - table8.AddRow(new string[] { + table27.AddRow(new string[] { "Test Merchant 1", "Address Line 1", "TestTown", @@ -187,7 +187,7 @@ await testRunner.GivenAsync("I have a token to access the estate management and "Test Contact 1", "testcontact1@merchant1.co.uk", "Test Estate 1"}); - table8.AddRow(new string[] { + table27.AddRow(new string[] { "Test Merchant 2", "Address Line 1", "TestTown", @@ -196,7 +196,7 @@ await testRunner.GivenAsync("I have a token to access the estate management and "Test Contact 2", "testcontact2@merchant2.co.uk", "Test Estate 1"}); - table8.AddRow(new string[] { + table27.AddRow(new string[] { "Test Merchant 3", "Address Line 1", "TestTown", @@ -205,7 +205,7 @@ await testRunner.GivenAsync("I have a token to access the estate management and "Test Contact 3", "testcontact3@merchant2.co.uk", "Test Estate 1"}); - table8.AddRow(new string[] { + table27.AddRow(new string[] { "Test Merchant 4", "Address Line 1", "TestTown", @@ -214,7 +214,7 @@ await testRunner.GivenAsync("I have a token to access the estate management and "Test Contact 4", "testcontact4@merchant2.co.uk", "Test Estate 1"}); - table8.AddRow(new string[] { + table27.AddRow(new string[] { "Test Merchant 5", "Address Line 1", "TestTown", @@ -223,7 +223,7 @@ await testRunner.GivenAsync("I have a token to access the estate management and "Test Contact 5", "testcontact5@merchant2.co.uk", "Test Estate 1"}); - table8.AddRow(new string[] { + table27.AddRow(new string[] { "Test Merchant 6", "Address Line 1", "TestTown", @@ -232,7 +232,7 @@ await testRunner.GivenAsync("I have a token to access the estate management and "Test Contact 6", "testcontact6@merchant2.co.uk", "Test Estate 1"}); - table8.AddRow(new string[] { + table27.AddRow(new string[] { "Test Merchant 7", "Address Line 1", "TestTown", @@ -242,58 +242,58 @@ await testRunner.GivenAsync("I have a token to access the estate management and "testcontact7@merchant2.co.uk", "Test Estate 1"}); #line 36 - await testRunner.GivenAsync("I create the following merchants", ((string)(null)), table8, "Given "); + await testRunner.GivenAsync("I create the following merchants", ((string)(null)), table27, "Given "); #line hidden - Reqnroll.Table table9 = new Reqnroll.Table(new string[] { + Reqnroll.Table table28 = new Reqnroll.Table(new string[] { "OperatorName", "MerchantName", "MerchantNumber", "TerminalNumber", "EstateName"}); - table9.AddRow(new string[] { + table28.AddRow(new string[] { "Test Operator 1", "Test Merchant 1", "00000001", "10000001", "Test Estate 1"}); - table9.AddRow(new string[] { + table28.AddRow(new string[] { "Test Operator 1", "Test Merchant 2", "00000001", "10000001", "Test Estate 1"}); - table9.AddRow(new string[] { + table28.AddRow(new string[] { "Test Operator 1", "Test Merchant 3", "00000001", "10000001", "Test Estate 1"}); - table9.AddRow(new string[] { + table28.AddRow(new string[] { "Test Operator 1", "Test Merchant 4", "00000001", "10000001", "Test Estate 1"}); - table9.AddRow(new string[] { + table28.AddRow(new string[] { "Test Operator 1", "Test Merchant 5", "00000001", "10000001", "Test Estate 1"}); - table9.AddRow(new string[] { + table28.AddRow(new string[] { "Test Operator 1", "Test Merchant 6", "00000001", "10000001", "Test Estate 1"}); - table9.AddRow(new string[] { + table28.AddRow(new string[] { "Test Operator 1", "Test Merchant 7", "00000001", "10000001", "Test Estate 1"}); #line 46 - await testRunner.GivenAsync("I have assigned the following operator to the merchants", ((string)(null)), table9, "Given "); + await testRunner.GivenAsync("I have assigned the following operator to the merchants", ((string)(null)), table28, "Given "); #line hidden } @@ -319,28 +319,28 @@ public async System.Threading.Tasks.Task LogonTransactions() #line 4 await this.FeatureBackgroundAsync(); #line hidden - Reqnroll.Table table10 = new Reqnroll.Table(new string[] { + Reqnroll.Table table29 = new Reqnroll.Table(new string[] { "DateTime", "TransactionNumber", "TransactionType", "MerchantName", "DeviceIdentifier", "EstateName"}); - table10.AddRow(new string[] { + table29.AddRow(new string[] { "Today", "1", "Logon", "Test Merchant 1", "123456780", "Test Estate 1"}); - table10.AddRow(new string[] { + table29.AddRow(new string[] { "Today", "2", "Logon", "Test Merchant 2", "123456781", "Test Estate 1"}); - table10.AddRow(new string[] { + table29.AddRow(new string[] { "Today", "3", "Logon", @@ -348,56 +348,56 @@ public async System.Threading.Tasks.Task LogonTransactions() "123456782", "Test Estate 1"}); #line 59 - await testRunner.WhenAsync("I perform the following transactions", ((string)(null)), table10, "When "); + await testRunner.WhenAsync("I perform the following transactions", ((string)(null)), table29, "When "); #line hidden - Reqnroll.Table table11 = new Reqnroll.Table(new string[] { + Reqnroll.Table table30 = new Reqnroll.Table(new string[] { "EstateName", "MerchantName", "TransactionNumber", "ResponseCode", "ResponseMessage"}); - table11.AddRow(new string[] { + table30.AddRow(new string[] { "Test Estate 1", "Test Merchant 1", "1", "0001", "SUCCESS"}); - table11.AddRow(new string[] { + table30.AddRow(new string[] { "Test Estate 1", "Test Merchant 2", "2", "0001", "SUCCESS"}); - table11.AddRow(new string[] { + table30.AddRow(new string[] { "Test Estate 1", "Test Merchant 3", "3", "0001", "SUCCESS"}); #line 65 - await testRunner.ThenAsync("transaction response should contain the following information", ((string)(null)), table11, "Then "); + await testRunner.ThenAsync("transaction response should contain the following information", ((string)(null)), table30, "Then "); #line hidden - Reqnroll.Table table12 = new Reqnroll.Table(new string[] { + Reqnroll.Table table31 = new Reqnroll.Table(new string[] { "DeviceIdentifier", "MerchantName", "MerchantNumber", "EstateName"}); - table12.AddRow(new string[] { + table31.AddRow(new string[] { "123456783", "Test Merchant 4", "00000001", "Test Estate 1"}); #line 71 - await testRunner.GivenAsync("I have assigned the following devices to the merchants", ((string)(null)), table12, "Given "); + await testRunner.GivenAsync("I have assigned the following devices to the merchants", ((string)(null)), table31, "Given "); #line hidden - Reqnroll.Table table13 = new Reqnroll.Table(new string[] { + Reqnroll.Table table32 = new Reqnroll.Table(new string[] { "DateTime", "TransactionNumber", "TransactionType", "MerchantName", "DeviceIdentifier", "EstateName"}); - table13.AddRow(new string[] { + table32.AddRow(new string[] { "Today", "4", "Logon", @@ -405,31 +405,31 @@ public async System.Threading.Tasks.Task LogonTransactions() "123456783", "Test Estate 1"}); #line 75 - await testRunner.WhenAsync("I perform the following transactions", ((string)(null)), table13, "When "); + await testRunner.WhenAsync("I perform the following transactions", ((string)(null)), table32, "When "); #line hidden - Reqnroll.Table table14 = new Reqnroll.Table(new string[] { + Reqnroll.Table table33 = new Reqnroll.Table(new string[] { "EstateName", "MerchantName", "TransactionNumber", "ResponseCode", "ResponseMessage"}); - table14.AddRow(new string[] { + table33.AddRow(new string[] { "Test Estate 1", "Test Merchant 4", "4", "0000", "SUCCESS"}); #line 79 - await testRunner.ThenAsync("transaction response should contain the following information", ((string)(null)), table14, "Then "); + await testRunner.ThenAsync("transaction response should contain the following information", ((string)(null)), table33, "Then "); #line hidden - Reqnroll.Table table15 = new Reqnroll.Table(new string[] { + Reqnroll.Table table34 = new Reqnroll.Table(new string[] { "DateTime", "TransactionNumber", "TransactionType", "MerchantName", "DeviceIdentifier", "EstateName"}); - table15.AddRow(new string[] { + table34.AddRow(new string[] { "Today", "5", "Logon", @@ -437,31 +437,31 @@ public async System.Threading.Tasks.Task LogonTransactions() "13579135", "Test Estate 1"}); #line 83 - await testRunner.WhenAsync("I perform the following transactions", ((string)(null)), table15, "When "); + await testRunner.WhenAsync("I perform the following transactions", ((string)(null)), table34, "When "); #line hidden - Reqnroll.Table table16 = new Reqnroll.Table(new string[] { + Reqnroll.Table table35 = new Reqnroll.Table(new string[] { "EstateName", "MerchantName", "TransactionNumber", "ResponseCode", "ResponseMessage"}); - table16.AddRow(new string[] { + table35.AddRow(new string[] { "Test Estate 1", "Test Merchant 1", "5", "1000", "Device Identifier 13579135 not valid for Merchant Test Merchant 1"}); #line 87 - await testRunner.ThenAsync("transaction response should contain the following information", ((string)(null)), table16, "Then "); + await testRunner.ThenAsync("transaction response should contain the following information", ((string)(null)), table35, "Then "); #line hidden - Reqnroll.Table table17 = new Reqnroll.Table(new string[] { + Reqnroll.Table table36 = new Reqnroll.Table(new string[] { "DateTime", "TransactionNumber", "TransactionType", "MerchantName", "DeviceIdentifier", "EstateName"}); - table17.AddRow(new string[] { + table36.AddRow(new string[] { "Today", "6", "Logon", @@ -469,31 +469,31 @@ public async System.Threading.Tasks.Task LogonTransactions() "123456785", "InvalidEstate"}); #line 91 - await testRunner.WhenAsync("I perform the following transactions", ((string)(null)), table17, "When "); + await testRunner.WhenAsync("I perform the following transactions", ((string)(null)), table36, "When "); #line hidden - Reqnroll.Table table18 = new Reqnroll.Table(new string[] { + Reqnroll.Table table37 = new Reqnroll.Table(new string[] { "EstateName", "MerchantName", "TransactionNumber", "ResponseCode", "ResponseMessage"}); - table18.AddRow(new string[] { + table37.AddRow(new string[] { "InvalidEstate", "Test Merchant 1", "6", "1001", "Estate Id [79902550-64df-4491-b0c1-4e78943928a3] is not a valid estate"}); #line 95 - await testRunner.ThenAsync("transaction response should contain the following information", ((string)(null)), table18, "Then "); + await testRunner.ThenAsync("transaction response should contain the following information", ((string)(null)), table37, "Then "); #line hidden - Reqnroll.Table table19 = new Reqnroll.Table(new string[] { + Reqnroll.Table table38 = new Reqnroll.Table(new string[] { "DateTime", "TransactionNumber", "TransactionType", "MerchantName", "DeviceIdentifier", "EstateName"}); - table19.AddRow(new string[] { + table38.AddRow(new string[] { "Today", "7", "Logon", @@ -501,15 +501,15 @@ public async System.Threading.Tasks.Task LogonTransactions() "123456786", "Test Estate 1"}); #line 99 - await testRunner.WhenAsync("I perform the following transactions", ((string)(null)), table19, "When "); + await testRunner.WhenAsync("I perform the following transactions", ((string)(null)), table38, "When "); #line hidden - Reqnroll.Table table20 = new Reqnroll.Table(new string[] { + Reqnroll.Table table39 = new Reqnroll.Table(new string[] { "EstateName", "MerchantName", "TransactionNumber", "ResponseCode", "ResponseMessage"}); - table20.AddRow(new string[] { + table39.AddRow(new string[] { "Test Estate 1", "InvalidMerchant", "7", @@ -517,7 +517,7 @@ public async System.Threading.Tasks.Task LogonTransactions() "Merchant Id [d59320fa-4c3e-4900-a999-483f6a10c69a] is not a valid merchant for es" + "tate [Test Estate 1]"}); #line 103 - await testRunner.ThenAsync("transaction response should contain the following information", ((string)(null)), table20, "Then "); + await testRunner.ThenAsync("transaction response should contain the following information", ((string)(null)), table39, "Then "); #line hidden } await this.ScenarioCleanupAsync(); diff --git a/TransactionProcessor.IntegrationTests/Features/ReconciliationFeature.feature.cs b/TransactionProcessor.IntegrationTests/Features/ReconciliationFeature.feature.cs index e5082386..d7199c79 100644 --- a/TransactionProcessor.IntegrationTests/Features/ReconciliationFeature.feature.cs +++ b/TransactionProcessor.IntegrationTests/Features/ReconciliationFeature.feature.cs @@ -81,120 +81,120 @@ public virtual async System.Threading.Tasks.Task FeatureBackgroundAsync() { #line 4 #line hidden - Reqnroll.Table table21 = new Reqnroll.Table(new string[] { + Reqnroll.Table table40 = new Reqnroll.Table(new string[] { "Name", "DisplayName", "Description"}); - table21.AddRow(new string[] { + table40.AddRow(new string[] { "estateManagement", "Estate Managememt REST Scope", "A scope for Estate Managememt REST"}); - table21.AddRow(new string[] { + table40.AddRow(new string[] { "transactionProcessor", "Transaction Processor REST Scope", "A scope for Transaction Processor REST"}); #line 6 - await testRunner.GivenAsync("I create the following api scopes", ((string)(null)), table21, "Given "); + await testRunner.GivenAsync("I create the following api scopes", ((string)(null)), table40, "Given "); #line hidden - Reqnroll.Table table22 = new Reqnroll.Table(new string[] { + Reqnroll.Table table41 = new Reqnroll.Table(new string[] { "Name", "DisplayName", "Secret", "Scopes", "UserClaims"}); - table22.AddRow(new string[] { + table41.AddRow(new string[] { "estateManagement", "Estate Managememt REST", "Secret1", "estateManagement", "MerchantId, EstateId, role"}); - table22.AddRow(new string[] { + table41.AddRow(new string[] { "transactionProcessor", "Transaction Processor REST", "Secret1", "transactionProcessor", ""}); #line 11 - await testRunner.GivenAsync("the following api resources exist", ((string)(null)), table22, "Given "); + await testRunner.GivenAsync("the following api resources exist", ((string)(null)), table41, "Given "); #line hidden - Reqnroll.Table table23 = new Reqnroll.Table(new string[] { + Reqnroll.Table table42 = new Reqnroll.Table(new string[] { "ClientId", "ClientName", "Secret", "Scopes", "GrantTypes"}); - table23.AddRow(new string[] { + table42.AddRow(new string[] { "serviceClient", "Service Client", "Secret1", "estateManagement,transactionProcessor", "client_credentials"}); #line 16 - await testRunner.GivenAsync("the following clients exist", ((string)(null)), table23, "Given "); + await testRunner.GivenAsync("the following clients exist", ((string)(null)), table42, "Given "); #line hidden - Reqnroll.Table table24 = new Reqnroll.Table(new string[] { + Reqnroll.Table table43 = new Reqnroll.Table(new string[] { "ClientId"}); - table24.AddRow(new string[] { + table43.AddRow(new string[] { "serviceClient"}); #line 20 await testRunner.GivenAsync("I have a token to access the estate management and transaction processor resource" + - "s", ((string)(null)), table24, "Given "); + "s", ((string)(null)), table43, "Given "); #line hidden - Reqnroll.Table table25 = new Reqnroll.Table(new string[] { + Reqnroll.Table table44 = new Reqnroll.Table(new string[] { "EstateName"}); - table25.AddRow(new string[] { + table44.AddRow(new string[] { "Test Estate 1"}); - table25.AddRow(new string[] { + table44.AddRow(new string[] { "Test Estate 2"}); #line 24 - await testRunner.GivenAsync("I have created the following estates", ((string)(null)), table25, "Given "); + await testRunner.GivenAsync("I have created the following estates", ((string)(null)), table44, "Given "); #line hidden - Reqnroll.Table table26 = new Reqnroll.Table(new string[] { + Reqnroll.Table table45 = new Reqnroll.Table(new string[] { "EstateName", "OperatorName", "RequireCustomMerchantNumber", "RequireCustomTerminalNumber"}); - table26.AddRow(new string[] { + table45.AddRow(new string[] { "Test Estate 1", "Safaricom", "True", "True"}); - table26.AddRow(new string[] { + table45.AddRow(new string[] { "Test Estate 2", "Safaricom", "True", "True"}); #line 29 - await testRunner.GivenAsync("I have created the following operators", ((string)(null)), table26, "Given "); + await testRunner.GivenAsync("I have created the following operators", ((string)(null)), table45, "Given "); #line hidden - Reqnroll.Table table27 = new Reqnroll.Table(new string[] { + Reqnroll.Table table46 = new Reqnroll.Table(new string[] { "EstateName", "OperatorName"}); - table27.AddRow(new string[] { + table46.AddRow(new string[] { "Test Estate 1", "Safaricom"}); - table27.AddRow(new string[] { + table46.AddRow(new string[] { "Test Estate 2", "Safaricom"}); #line 34 - await testRunner.AndAsync("I have assigned the following operators to the estates", ((string)(null)), table27, "And "); + await testRunner.AndAsync("I have assigned the following operators to the estates", ((string)(null)), table46, "And "); #line hidden - Reqnroll.Table table28 = new Reqnroll.Table(new string[] { + Reqnroll.Table table47 = new Reqnroll.Table(new string[] { "EstateName", "OperatorName", "ContractDescription"}); - table28.AddRow(new string[] { + table47.AddRow(new string[] { "Test Estate 1", "Safaricom", "Safaricom Contract"}); - table28.AddRow(new string[] { + table47.AddRow(new string[] { "Test Estate 2", "Safaricom", "Safaricom Contract"}); #line 39 - await testRunner.GivenAsync("I create a contract with the following values", ((string)(null)), table28, "Given "); + await testRunner.GivenAsync("I create a contract with the following values", ((string)(null)), table47, "Given "); #line hidden - Reqnroll.Table table29 = new Reqnroll.Table(new string[] { + Reqnroll.Table table48 = new Reqnroll.Table(new string[] { "EstateName", "OperatorName", "ContractDescription", @@ -202,7 +202,7 @@ await testRunner.GivenAsync("I have a token to access the estate management and "DisplayText", "Value", "ProductType"}); - table29.AddRow(new string[] { + table48.AddRow(new string[] { "Test Estate 1", "Safaricom", "Safaricom Contract", @@ -210,7 +210,7 @@ await testRunner.GivenAsync("I have a token to access the estate management and "Custom", "", "MobileTopup"}); - table29.AddRow(new string[] { + table48.AddRow(new string[] { "Test Estate 2", "Safaricom", "Safaricom Contract", @@ -219,9 +219,9 @@ await testRunner.GivenAsync("I have a token to access the estate management and "", "MobileTopup"}); #line 44 - await testRunner.WhenAsync("I create the following Products", ((string)(null)), table29, "When "); + await testRunner.WhenAsync("I create the following Products", ((string)(null)), table48, "When "); #line hidden - Reqnroll.Table table30 = new Reqnroll.Table(new string[] { + Reqnroll.Table table49 = new Reqnroll.Table(new string[] { "EstateName", "OperatorName", "ContractDescription", @@ -229,7 +229,7 @@ await testRunner.GivenAsync("I have a token to access the estate management and "CalculationType", "FeeDescription", "Value"}); - table30.AddRow(new string[] { + table49.AddRow(new string[] { "Test Estate 1", "Safaricom", "Safaricom Contract", @@ -237,7 +237,7 @@ await testRunner.GivenAsync("I have a token to access the estate management and "Fixed", "Merchant Commission", "2.50"}); - table30.AddRow(new string[] { + table49.AddRow(new string[] { "Test Estate 2", "Safaricom", "Safaricom Contract", @@ -246,9 +246,9 @@ await testRunner.GivenAsync("I have a token to access the estate management and "Merchant Commission", "0.85"}); #line 49 - await testRunner.WhenAsync("I add the following Transaction Fees", ((string)(null)), table30, "When "); + await testRunner.WhenAsync("I add the following Transaction Fees", ((string)(null)), table49, "When "); #line hidden - Reqnroll.Table table31 = new Reqnroll.Table(new string[] { + Reqnroll.Table table50 = new Reqnroll.Table(new string[] { "MerchantName", "AddressLine1", "Town", @@ -257,7 +257,7 @@ await testRunner.GivenAsync("I have a token to access the estate management and "ContactName", "EmailAddress", "EstateName"}); - table31.AddRow(new string[] { + table50.AddRow(new string[] { "Test Merchant 1", "Address Line 1", "TestTown", @@ -266,7 +266,7 @@ await testRunner.GivenAsync("I have a token to access the estate management and "Test Contact 1", "testcontact1@merchant1.co.uk", "Test Estate 1"}); - table31.AddRow(new string[] { + table50.AddRow(new string[] { "Test Merchant 2", "Address Line 1", "TestTown", @@ -275,7 +275,7 @@ await testRunner.GivenAsync("I have a token to access the estate management and "Test Contact 2", "testcontact2@merchant2.co.uk", "Test Estate 1"}); - table31.AddRow(new string[] { + table50.AddRow(new string[] { "Test Merchant 3", "Address Line 1", "TestTown", @@ -285,80 +285,80 @@ await testRunner.GivenAsync("I have a token to access the estate management and "testcontact3@merchant2.co.uk", "Test Estate 2"}); #line 54 - await testRunner.GivenAsync("I create the following merchants", ((string)(null)), table31, "Given "); + await testRunner.GivenAsync("I create the following merchants", ((string)(null)), table50, "Given "); #line hidden - Reqnroll.Table table32 = new Reqnroll.Table(new string[] { + Reqnroll.Table table51 = new Reqnroll.Table(new string[] { "OperatorName", "MerchantName", "MerchantNumber", "TerminalNumber", "EstateName"}); - table32.AddRow(new string[] { + table51.AddRow(new string[] { "Safaricom", "Test Merchant 1", "00000001", "10000001", "Test Estate 1"}); - table32.AddRow(new string[] { + table51.AddRow(new string[] { "Safaricom", "Test Merchant 2", "00000002", "10000002", "Test Estate 1"}); - table32.AddRow(new string[] { + table51.AddRow(new string[] { "Safaricom", "Test Merchant 3", "00000003", "10000003", "Test Estate 2"}); #line 60 - await testRunner.GivenAsync("I have assigned the following operator to the merchants", ((string)(null)), table32, "Given "); + await testRunner.GivenAsync("I have assigned the following operator to the merchants", ((string)(null)), table51, "Given "); #line hidden - Reqnroll.Table table33 = new Reqnroll.Table(new string[] { + Reqnroll.Table table52 = new Reqnroll.Table(new string[] { "DeviceIdentifier", "MerchantName", "EstateName"}); - table33.AddRow(new string[] { + table52.AddRow(new string[] { "123456780", "Test Merchant 1", "Test Estate 1"}); - table33.AddRow(new string[] { + table52.AddRow(new string[] { "123456781", "Test Merchant 2", "Test Estate 1"}); - table33.AddRow(new string[] { + table52.AddRow(new string[] { "123456782", "Test Merchant 3", "Test Estate 2"}); #line 66 - await testRunner.GivenAsync("I have assigned the following devices to the merchants", ((string)(null)), table33, "Given "); + await testRunner.GivenAsync("I have assigned the following devices to the merchants", ((string)(null)), table52, "Given "); #line hidden - Reqnroll.Table table34 = new Reqnroll.Table(new string[] { + Reqnroll.Table table53 = new Reqnroll.Table(new string[] { "Reference", "Amount", "DateTime", "MerchantName", "EstateName"}); - table34.AddRow(new string[] { + table53.AddRow(new string[] { "Deposit1", "200.00", "Today", "Test Merchant 1", "Test Estate 1"}); - table34.AddRow(new string[] { + table53.AddRow(new string[] { "Deposit1", "100.00", "Today", "Test Merchant 2", "Test Estate 1"}); - table34.AddRow(new string[] { + table53.AddRow(new string[] { "Deposit1", "100.00", "Today", "Test Merchant 3", "Test Estate 2"}); #line 72 - await testRunner.GivenAsync("I make the following manual merchant deposits", ((string)(null)), table34, "Given "); + await testRunner.GivenAsync("I make the following manual merchant deposits", ((string)(null)), table53, "Given "); #line hidden } @@ -384,7 +384,7 @@ public async System.Threading.Tasks.Task ReconciliationTransactions() #line 4 await this.FeatureBackgroundAsync(); #line hidden - Reqnroll.Table table35 = new Reqnroll.Table(new string[] { + Reqnroll.Table table54 = new Reqnroll.Table(new string[] { "DateTime", "MerchantName", "DeviceIdentifier", @@ -392,7 +392,7 @@ public async System.Threading.Tasks.Task ReconciliationTransactions() "TransactionCount", "TransactionValue", "TransactionType"}); - table35.AddRow(new string[] { + table54.AddRow(new string[] { "Today", "Test Merchant 1", "123456780", @@ -400,7 +400,7 @@ public async System.Threading.Tasks.Task ReconciliationTransactions() "1", "100.00", "Reconciliation"}); - table35.AddRow(new string[] { + table54.AddRow(new string[] { "Today", "Test Merchant 2", "123456781", @@ -408,7 +408,7 @@ public async System.Threading.Tasks.Task ReconciliationTransactions() "2", "200.00", "Reconciliation"}); - table35.AddRow(new string[] { + table54.AddRow(new string[] { "Today", "Test Merchant 3", "123456782", @@ -417,30 +417,30 @@ public async System.Threading.Tasks.Task ReconciliationTransactions() "300.00", "Reconciliation"}); #line 81 - await testRunner.WhenAsync("I perform the following reconciliations", ((string)(null)), table35, "When "); + await testRunner.WhenAsync("I perform the following reconciliations", ((string)(null)), table54, "When "); #line hidden - Reqnroll.Table table36 = new Reqnroll.Table(new string[] { + Reqnroll.Table table55 = new Reqnroll.Table(new string[] { "EstateName", "MerchantName", "ResponseCode", "ResponseMessage"}); - table36.AddRow(new string[] { + table55.AddRow(new string[] { "Test Estate 1", "Test Merchant 1", "0000", "SUCCESS"}); - table36.AddRow(new string[] { + table55.AddRow(new string[] { "Test Estate 1", "Test Merchant 2", "0000", "SUCCESS"}); - table36.AddRow(new string[] { + table55.AddRow(new string[] { "Test Estate 2", "Test Merchant 3", "0000", "SUCCESS"}); #line 87 - await testRunner.ThenAsync("reconciliation response should contain the following information", ((string)(null)), table36, "Then "); + await testRunner.ThenAsync("reconciliation response should contain the following information", ((string)(null)), table55, "Then "); #line hidden } await this.ScenarioCleanupAsync(); diff --git a/TransactionProcessor.IntegrationTests/Features/RedeemVoucher.feature.cs b/TransactionProcessor.IntegrationTests/Features/RedeemVoucher.feature.cs index a83dbe61..f79673f8 100644 --- a/TransactionProcessor.IntegrationTests/Features/RedeemVoucher.feature.cs +++ b/TransactionProcessor.IntegrationTests/Features/RedeemVoucher.feature.cs @@ -81,108 +81,108 @@ public virtual async System.Threading.Tasks.Task FeatureBackgroundAsync() { #line 5 #line hidden - Reqnroll.Table table37 = new Reqnroll.Table(new string[] { + Reqnroll.Table table56 = new Reqnroll.Table(new string[] { "Name", "DisplayName", "Description"}); - table37.AddRow(new string[] { + table56.AddRow(new string[] { "estateManagement", "Estate Managememt REST Scope", "A scope for Estate Managememt REST"}); - table37.AddRow(new string[] { + table56.AddRow(new string[] { "voucherManagement", "Voucher Management REST Scope", "A scope for Voucher Management REST"}); #line 7 - await testRunner.GivenAsync("I create the following api scopes", ((string)(null)), table37, "Given "); + await testRunner.GivenAsync("I create the following api scopes", ((string)(null)), table56, "Given "); #line hidden - Reqnroll.Table table38 = new Reqnroll.Table(new string[] { + Reqnroll.Table table57 = new Reqnroll.Table(new string[] { "Name", "DisplayName", "Secret", "Scopes", "UserClaims"}); - table38.AddRow(new string[] { + table57.AddRow(new string[] { "estateManagement", "Estate Managememt REST", "Secret1", "estateManagement", "MerchantId, EstateId, role"}); - table38.AddRow(new string[] { + table57.AddRow(new string[] { "voucherManagement", "Voucher Management REST", "Secret1", "voucherManagement", ""}); #line 12 - await testRunner.GivenAsync("the following api resources exist", ((string)(null)), table38, "Given "); + await testRunner.GivenAsync("the following api resources exist", ((string)(null)), table57, "Given "); #line hidden - Reqnroll.Table table39 = new Reqnroll.Table(new string[] { + Reqnroll.Table table58 = new Reqnroll.Table(new string[] { "ClientId", "ClientName", "Secret", "Scopes", "GrantTypes"}); - table39.AddRow(new string[] { + table58.AddRow(new string[] { "serviceClient", "Service Client", "Secret1", "estateManagement,voucherManagement", "client_credentials"}); #line 17 - await testRunner.GivenAsync("the following clients exist", ((string)(null)), table39, "Given "); + await testRunner.GivenAsync("the following clients exist", ((string)(null)), table58, "Given "); #line hidden - Reqnroll.Table table40 = new Reqnroll.Table(new string[] { + Reqnroll.Table table59 = new Reqnroll.Table(new string[] { "ClientId"}); - table40.AddRow(new string[] { + table59.AddRow(new string[] { "serviceClient"}); #line 21 await testRunner.GivenAsync("I have a token to access the estate management and transaction processor resource" + - "s", ((string)(null)), table40, "Given "); + "s", ((string)(null)), table59, "Given "); #line hidden - Reqnroll.Table table41 = new Reqnroll.Table(new string[] { + Reqnroll.Table table60 = new Reqnroll.Table(new string[] { "EstateName"}); - table41.AddRow(new string[] { + table60.AddRow(new string[] { "Test Estate 1"}); - table41.AddRow(new string[] { + table60.AddRow(new string[] { "Test Estate 2"}); #line 25 - await testRunner.GivenAsync("I have created the following estates", ((string)(null)), table41, "Given "); + await testRunner.GivenAsync("I have created the following estates", ((string)(null)), table60, "Given "); #line hidden - Reqnroll.Table table42 = new Reqnroll.Table(new string[] { + Reqnroll.Table table61 = new Reqnroll.Table(new string[] { "EstateName", "OperatorName", "RequireCustomMerchantNumber", "RequireCustomTerminalNumber"}); - table42.AddRow(new string[] { + table61.AddRow(new string[] { "Test Estate 1", "Voucher", "True", "True"}); #line 30 - await testRunner.GivenAsync("I have created the following operators", ((string)(null)), table42, "Given "); + await testRunner.GivenAsync("I have created the following operators", ((string)(null)), table61, "Given "); #line hidden - Reqnroll.Table table43 = new Reqnroll.Table(new string[] { + Reqnroll.Table table62 = new Reqnroll.Table(new string[] { "EstateName", "OperatorName"}); - table43.AddRow(new string[] { + table62.AddRow(new string[] { "Test Estate 1", "Voucher"}); #line 34 - await testRunner.AndAsync("I have assigned the following operators to the estates", ((string)(null)), table43, "And "); + await testRunner.AndAsync("I have assigned the following operators to the estates", ((string)(null)), table62, "And "); #line hidden - Reqnroll.Table table44 = new Reqnroll.Table(new string[] { + Reqnroll.Table table63 = new Reqnroll.Table(new string[] { "EstateName", "OperatorName", "ContractDescription"}); - table44.AddRow(new string[] { + table63.AddRow(new string[] { "Test Estate 1", "Voucher", "Hospital 1 Contract"}); #line 38 - await testRunner.GivenAsync("I create a contract with the following values", ((string)(null)), table44, "Given "); + await testRunner.GivenAsync("I create a contract with the following values", ((string)(null)), table63, "Given "); #line hidden - Reqnroll.Table table45 = new Reqnroll.Table(new string[] { + Reqnroll.Table table64 = new Reqnroll.Table(new string[] { "EstateName", "OperatorName", "ContractDescription", @@ -190,7 +190,7 @@ await testRunner.GivenAsync("I have a token to access the estate management and "DisplayText", "Value", "ProductType"}); - table45.AddRow(new string[] { + table64.AddRow(new string[] { "Test Estate 1", "Voucher", "Hospital 1 Contract", @@ -199,9 +199,9 @@ await testRunner.GivenAsync("I have a token to access the estate management and "", "Voucher"}); #line 42 - await testRunner.WhenAsync("I create the following Products", ((string)(null)), table45, "When "); + await testRunner.WhenAsync("I create the following Products", ((string)(null)), table64, "When "); #line hidden - Reqnroll.Table table46 = new Reqnroll.Table(new string[] { + Reqnroll.Table table65 = new Reqnroll.Table(new string[] { "MerchantName", "AddressLine1", "Town", @@ -210,7 +210,7 @@ await testRunner.GivenAsync("I have a token to access the estate management and "ContactName", "EmailAddress", "EstateName"}); - table46.AddRow(new string[] { + table65.AddRow(new string[] { "Test Merchant 1", "Address Line 1", "TestTown", @@ -220,61 +220,61 @@ await testRunner.GivenAsync("I have a token to access the estate management and "testcontact1@merchant1.co.uk", "Test Estate 1"}); #line 46 - await testRunner.GivenAsync("I create the following merchants", ((string)(null)), table46, "Given "); + await testRunner.GivenAsync("I create the following merchants", ((string)(null)), table65, "Given "); #line hidden - Reqnroll.Table table47 = new Reqnroll.Table(new string[] { + Reqnroll.Table table66 = new Reqnroll.Table(new string[] { "OperatorName", "MerchantName", "MerchantNumber", "TerminalNumber", "EstateName"}); - table47.AddRow(new string[] { + table66.AddRow(new string[] { "Voucher", "Test Merchant 1", "00000001", "10000001", "Test Estate 1"}); #line 50 - await testRunner.GivenAsync("I have assigned the following operator to the merchants", ((string)(null)), table47, "Given "); + await testRunner.GivenAsync("I have assigned the following operator to the merchants", ((string)(null)), table66, "Given "); #line hidden - Reqnroll.Table table48 = new Reqnroll.Table(new string[] { + Reqnroll.Table table67 = new Reqnroll.Table(new string[] { "DeviceIdentifier", "MerchantName", "EstateName"}); - table48.AddRow(new string[] { + table67.AddRow(new string[] { "123456780", "Test Merchant 1", "Test Estate 1"}); #line 54 - await testRunner.GivenAsync("I have assigned the following devices to the merchants", ((string)(null)), table48, "Given "); + await testRunner.GivenAsync("I have assigned the following devices to the merchants", ((string)(null)), table67, "Given "); #line hidden - Reqnroll.Table table49 = new Reqnroll.Table(new string[] { + Reqnroll.Table table68 = new Reqnroll.Table(new string[] { "Reference", "Amount", "DateTime", "MerchantName", "EstateName"}); - table49.AddRow(new string[] { + table68.AddRow(new string[] { "Deposit1", "20.00", "Today", "Test Merchant 1", "Test Estate 1"}); #line 58 - await testRunner.GivenAsync("I make the following manual merchant deposits", ((string)(null)), table49, "Given "); + await testRunner.GivenAsync("I make the following manual merchant deposits", ((string)(null)), table68, "Given "); #line hidden - Reqnroll.Table table50 = new Reqnroll.Table(new string[] { + Reqnroll.Table table69 = new Reqnroll.Table(new string[] { "EstateName", "MerchantName", "ContractDescription"}); - table50.AddRow(new string[] { + table69.AddRow(new string[] { "Test Estate 1", "Test Merchant 1", "Hospital 1 Contract"}); #line 62 - await testRunner.WhenAsync("I add the following contracts to the following merchants", ((string)(null)), table50, "When "); + await testRunner.WhenAsync("I add the following contracts to the following merchants", ((string)(null)), table69, "When "); #line hidden - Reqnroll.Table table51 = new Reqnroll.Table(new string[] { + Reqnroll.Table table70 = new Reqnroll.Table(new string[] { "DateTime", "TransactionNumber", "TransactionType", @@ -293,7 +293,7 @@ await testRunner.GivenAsync("I have a token to access the estate management and "MessageType", "AccountNumber", "CustomerName"}); - table51.AddRow(new string[] { + table70.AddRow(new string[] { "Today", "1", "Sale", @@ -313,7 +313,7 @@ await testRunner.GivenAsync("I have a token to access the estate management and "", ""}); #line 66 - await testRunner.WhenAsync("I perform the following transactions", ((string)(null)), table51, "When "); + await testRunner.WhenAsync("I perform the following transactions", ((string)(null)), table70, "When "); #line hidden } diff --git a/TransactionProcessor.IntegrationTests/Features/SaleTransactionFeature.feature.cs b/TransactionProcessor.IntegrationTests/Features/SaleTransactionFeature.feature.cs index 0fbc5bcc..7382faae 100644 --- a/TransactionProcessor.IntegrationTests/Features/SaleTransactionFeature.feature.cs +++ b/TransactionProcessor.IntegrationTests/Features/SaleTransactionFeature.feature.cs @@ -81,199 +81,199 @@ public virtual async System.Threading.Tasks.Task FeatureBackgroundAsync() { #line 4 #line hidden - Reqnroll.Table table52 = new Reqnroll.Table(new string[] { + Reqnroll.Table table71 = new Reqnroll.Table(new string[] { "Name", "DisplayName", "Description"}); - table52.AddRow(new string[] { + table71.AddRow(new string[] { "estateManagement", "Estate Managememt REST Scope", "A scope for Estate Managememt REST"}); - table52.AddRow(new string[] { + table71.AddRow(new string[] { "transactionProcessor", "Transaction Processor REST Scope", "A scope for Transaction Processor REST"}); - table52.AddRow(new string[] { + table71.AddRow(new string[] { "voucherManagement", "Voucher Management REST Scope", "A scope for Voucher Management REST"}); - table52.AddRow(new string[] { + table71.AddRow(new string[] { "messagingService", "Scope for Messaging REST", "Scope for Messaging REST"}); #line 6 - await testRunner.GivenAsync("I create the following api scopes", ((string)(null)), table52, "Given "); + await testRunner.GivenAsync("I create the following api scopes", ((string)(null)), table71, "Given "); #line hidden - Reqnroll.Table table53 = new Reqnroll.Table(new string[] { + Reqnroll.Table table72 = new Reqnroll.Table(new string[] { "Name", "DisplayName", "Secret", "Scopes", "UserClaims"}); - table53.AddRow(new string[] { + table72.AddRow(new string[] { "estateManagement", "Estate Managememt REST", "Secret1", "estateManagement", "MerchantId, EstateId, role"}); - table53.AddRow(new string[] { + table72.AddRow(new string[] { "transactionProcessor", "Transaction Processor REST", "Secret1", "transactionProcessor", ""}); - table53.AddRow(new string[] { + table72.AddRow(new string[] { "voucherManagement", "Voucher Management REST", "Secret1", "voucherManagement", ""}); - table53.AddRow(new string[] { + table72.AddRow(new string[] { "messagingService", "Messaging REST", "Secret", "messagingService", ""}); #line 13 - await testRunner.GivenAsync("the following api resources exist", ((string)(null)), table53, "Given "); + await testRunner.GivenAsync("the following api resources exist", ((string)(null)), table72, "Given "); #line hidden - Reqnroll.Table table54 = new Reqnroll.Table(new string[] { + Reqnroll.Table table73 = new Reqnroll.Table(new string[] { "ClientId", "ClientName", "Secret", "Scopes", "GrantTypes"}); - table54.AddRow(new string[] { + table73.AddRow(new string[] { "serviceClient", "Service Client", "Secret1", "estateManagement,transactionProcessor,voucherManagement,messagingService", "client_credentials"}); #line 20 - await testRunner.GivenAsync("the following clients exist", ((string)(null)), table54, "Given "); + await testRunner.GivenAsync("the following clients exist", ((string)(null)), table73, "Given "); #line hidden - Reqnroll.Table table55 = new Reqnroll.Table(new string[] { + Reqnroll.Table table74 = new Reqnroll.Table(new string[] { "ClientId"}); - table55.AddRow(new string[] { + table74.AddRow(new string[] { "serviceClient"}); #line 24 await testRunner.GivenAsync("I have a token to access the estate management and transaction processor resource" + - "s", ((string)(null)), table55, "Given "); + "s", ((string)(null)), table74, "Given "); #line hidden - Reqnroll.Table table56 = new Reqnroll.Table(new string[] { + Reqnroll.Table table75 = new Reqnroll.Table(new string[] { "AccountNumber", "AccountName", "DueDate", "Amount"}); - table56.AddRow(new string[] { + table75.AddRow(new string[] { "12345678", "Test Account 1", "Today", "100.00"}); #line 28 - await testRunner.GivenAsync("the following bills are available at the PataPawa PostPaid Host", ((string)(null)), table56, "Given "); + await testRunner.GivenAsync("the following bills are available at the PataPawa PostPaid Host", ((string)(null)), table75, "Given "); #line hidden - Reqnroll.Table table57 = new Reqnroll.Table(new string[] { + Reqnroll.Table table76 = new Reqnroll.Table(new string[] { "Username", "Password"}); - table57.AddRow(new string[] { + table76.AddRow(new string[] { "operatora", "1234567898"}); #line 32 - await testRunner.GivenAsync("the following users are available at the PataPawa PrePay Host", ((string)(null)), table57, "Given "); + await testRunner.GivenAsync("the following users are available at the PataPawa PrePay Host", ((string)(null)), table76, "Given "); #line hidden - Reqnroll.Table table58 = new Reqnroll.Table(new string[] { + Reqnroll.Table table77 = new Reqnroll.Table(new string[] { "MeterNumber", "CustomerName"}); - table58.AddRow(new string[] { + table77.AddRow(new string[] { "00000001", "Customer 1"}); - table58.AddRow(new string[] { + table77.AddRow(new string[] { "00000002", "Customer 2"}); - table58.AddRow(new string[] { + table77.AddRow(new string[] { "00000003", "Customer 3"}); #line 36 - await testRunner.GivenAsync("the following meters are available at the PataPawa PrePay Host", ((string)(null)), table58, "Given "); + await testRunner.GivenAsync("the following meters are available at the PataPawa PrePay Host", ((string)(null)), table77, "Given "); #line hidden - Reqnroll.Table table59 = new Reqnroll.Table(new string[] { + Reqnroll.Table table78 = new Reqnroll.Table(new string[] { "EstateName"}); - table59.AddRow(new string[] { + table78.AddRow(new string[] { "Test Estate 1"}); #line 42 - await testRunner.GivenAsync("I have created the following estates", ((string)(null)), table59, "Given "); + await testRunner.GivenAsync("I have created the following estates", ((string)(null)), table78, "Given "); #line hidden - Reqnroll.Table table60 = new Reqnroll.Table(new string[] { + Reqnroll.Table table79 = new Reqnroll.Table(new string[] { "EstateName", "OperatorName", "RequireCustomMerchantNumber", "RequireCustomTerminalNumber"}); - table60.AddRow(new string[] { + table79.AddRow(new string[] { "Test Estate 1", "Safaricom", "True", "True"}); - table60.AddRow(new string[] { + table79.AddRow(new string[] { "Test Estate 1", "Voucher", "True", "True"}); - table60.AddRow(new string[] { + table79.AddRow(new string[] { "Test Estate 1", "PataPawa PostPay", "True", "True"}); - table60.AddRow(new string[] { + table79.AddRow(new string[] { "Test Estate 1", "PataPawa PrePay", "True", "True"}); #line 46 - await testRunner.GivenAsync("I have created the following operators", ((string)(null)), table60, "Given "); + await testRunner.GivenAsync("I have created the following operators", ((string)(null)), table79, "Given "); #line hidden - Reqnroll.Table table61 = new Reqnroll.Table(new string[] { + Reqnroll.Table table80 = new Reqnroll.Table(new string[] { "EstateName", "OperatorName"}); - table61.AddRow(new string[] { + table80.AddRow(new string[] { "Test Estate 1", "Safaricom"}); - table61.AddRow(new string[] { + table80.AddRow(new string[] { "Test Estate 1", "Voucher"}); - table61.AddRow(new string[] { + table80.AddRow(new string[] { "Test Estate 1", "PataPawa PostPay"}); - table61.AddRow(new string[] { + table80.AddRow(new string[] { "Test Estate 1", "PataPawa PrePay"}); #line 53 - await testRunner.AndAsync("I have assigned the following operators to the estates", ((string)(null)), table61, "And "); + await testRunner.AndAsync("I have assigned the following operators to the estates", ((string)(null)), table80, "And "); #line hidden - Reqnroll.Table table62 = new Reqnroll.Table(new string[] { + Reqnroll.Table table81 = new Reqnroll.Table(new string[] { "EstateName", "OperatorName", "ContractDescription"}); - table62.AddRow(new string[] { + table81.AddRow(new string[] { "Test Estate 1", "Safaricom", "Safaricom Contract"}); - table62.AddRow(new string[] { + table81.AddRow(new string[] { "Test Estate 1", "Voucher", "Hospital 1 Contract"}); - table62.AddRow(new string[] { + table81.AddRow(new string[] { "Test Estate 1", "PataPawa PostPay", "PataPawa PostPay Contract"}); - table62.AddRow(new string[] { + table81.AddRow(new string[] { "Test Estate 1", "PataPawa PrePay", "PataPawa PrePay Contract"}); #line 60 - await testRunner.GivenAsync("I create a contract with the following values", ((string)(null)), table62, "Given "); + await testRunner.GivenAsync("I create a contract with the following values", ((string)(null)), table81, "Given "); #line hidden - Reqnroll.Table table63 = new Reqnroll.Table(new string[] { + Reqnroll.Table table82 = new Reqnroll.Table(new string[] { "EstateName", "OperatorName", "ContractDescription", @@ -281,7 +281,7 @@ await testRunner.GivenAsync("I have a token to access the estate management and "DisplayText", "Value", "ProductType"}); - table63.AddRow(new string[] { + table82.AddRow(new string[] { "Test Estate 1", "Safaricom", "Safaricom Contract", @@ -289,7 +289,7 @@ await testRunner.GivenAsync("I have a token to access the estate management and "Custom", "", "MobileTopup"}); - table63.AddRow(new string[] { + table82.AddRow(new string[] { "Test Estate 1", "Voucher", "Hospital 1 Contract", @@ -297,7 +297,7 @@ await testRunner.GivenAsync("I have a token to access the estate management and "10 KES", "", "Voucher"}); - table63.AddRow(new string[] { + table82.AddRow(new string[] { "Test Estate 1", "PataPawa PostPay", "PataPawa PostPay Contract", @@ -305,7 +305,7 @@ await testRunner.GivenAsync("I have a token to access the estate management and "Bill Pay (Post)", "", "BillPayment"}); - table63.AddRow(new string[] { + table82.AddRow(new string[] { "Test Estate 1", "PataPawa PrePay", "PataPawa PrePay Contract", @@ -314,9 +314,9 @@ await testRunner.GivenAsync("I have a token to access the estate management and "", "BillPayment"}); #line 67 - await testRunner.WhenAsync("I create the following Products", ((string)(null)), table63, "When "); + await testRunner.WhenAsync("I create the following Products", ((string)(null)), table82, "When "); #line hidden - Reqnroll.Table table64 = new Reqnroll.Table(new string[] { + Reqnroll.Table table83 = new Reqnroll.Table(new string[] { "EstateName", "OperatorName", "ContractDescription", @@ -324,7 +324,7 @@ await testRunner.GivenAsync("I have a token to access the estate management and "CalculationType", "FeeDescription", "Value"}); - table64.AddRow(new string[] { + table83.AddRow(new string[] { "Test Estate 1", "Safaricom", "Safaricom Contract", @@ -332,7 +332,7 @@ await testRunner.GivenAsync("I have a token to access the estate management and "Percentage", "Merchant Commission", "0.50"}); - table64.AddRow(new string[] { + table83.AddRow(new string[] { "Test Estate 1", "PataPawa PostPay", "PataPawa PostPay Contract", @@ -340,7 +340,7 @@ await testRunner.GivenAsync("I have a token to access the estate management and "Percentage", "Merchant Commission", "0.50"}); - table64.AddRow(new string[] { + table83.AddRow(new string[] { "Test Estate 1", "PataPawa PrePay", "PataPawa PrePay Contract", @@ -349,9 +349,9 @@ await testRunner.GivenAsync("I have a token to access the estate management and "Merchant Commission", "0.50"}); #line 74 - await testRunner.WhenAsync("I add the following Transaction Fees", ((string)(null)), table64, "When "); + await testRunner.WhenAsync("I add the following Transaction Fees", ((string)(null)), table83, "When "); #line hidden - Reqnroll.Table table65 = new Reqnroll.Table(new string[] { + Reqnroll.Table table84 = new Reqnroll.Table(new string[] { "MerchantName", "AddressLine1", "Town", @@ -360,7 +360,7 @@ await testRunner.GivenAsync("I have a token to access the estate management and "ContactName", "EmailAddress", "EstateName"}); - table65.AddRow(new string[] { + table84.AddRow(new string[] { "Test Merchant 1", "Address Line 1", "TestTown", @@ -369,7 +369,7 @@ await testRunner.GivenAsync("I have a token to access the estate management and "Test Contact 1", "testcontact1@merchant1.co.uk", "Test Estate 1"}); - table65.AddRow(new string[] { + table84.AddRow(new string[] { "Test Merchant 2", "Address Line 1", "TestTown", @@ -378,7 +378,7 @@ await testRunner.GivenAsync("I have a token to access the estate management and "Test Contact 2", "testcontact2@merchant2.co.uk", "Test Estate 1"}); - table65.AddRow(new string[] { + table84.AddRow(new string[] { "Test Merchant 3", "Address Line 1", "TestTown", @@ -387,7 +387,7 @@ await testRunner.GivenAsync("I have a token to access the estate management and "Test Contact 3", "testcontact3@merchant3.co.uk", "Test Estate 1"}); - table65.AddRow(new string[] { + table84.AddRow(new string[] { "Test Merchant 4", "Address Line 1", "TestTown", @@ -397,239 +397,239 @@ await testRunner.GivenAsync("I have a token to access the estate management and "testcontact4@merchant4.co.uk", "Test Estate 1"}); #line 80 - await testRunner.GivenAsync("I create the following merchants", ((string)(null)), table65, "Given "); + await testRunner.GivenAsync("I create the following merchants", ((string)(null)), table84, "Given "); #line hidden - Reqnroll.Table table66 = new Reqnroll.Table(new string[] { + Reqnroll.Table table85 = new Reqnroll.Table(new string[] { "OperatorName", "MerchantName", "MerchantNumber", "TerminalNumber", "EstateName"}); - table66.AddRow(new string[] { + table85.AddRow(new string[] { "Safaricom", "Test Merchant 1", "00000001", "10000001", "Test Estate 1"}); - table66.AddRow(new string[] { + table85.AddRow(new string[] { "Voucher", "Test Merchant 1", "00000001", "10000001", "Test Estate 1"}); - table66.AddRow(new string[] { + table85.AddRow(new string[] { "PataPawa PostPay", "Test Merchant 1", "00000001", "10000001", "Test Estate 1"}); - table66.AddRow(new string[] { + table85.AddRow(new string[] { "PataPawa PrePay", "Test Merchant 1", "00000001", "10000001", "Test Estate 1"}); - table66.AddRow(new string[] { + table85.AddRow(new string[] { "Safaricom", "Test Merchant 2", "00000002", "10000002", "Test Estate 1"}); - table66.AddRow(new string[] { + table85.AddRow(new string[] { "Voucher", "Test Merchant 2", "00000002", "10000002", "Test Estate 1"}); - table66.AddRow(new string[] { + table85.AddRow(new string[] { "PataPawa PostPay", "Test Merchant 2", "00000002", "10000002", "Test Estate 1"}); - table66.AddRow(new string[] { + table85.AddRow(new string[] { "PataPawa PrePay", "Test Merchant 2", "00000001", "10000001", "Test Estate 1"}); - table66.AddRow(new string[] { + table85.AddRow(new string[] { "Safaricom", "Test Merchant 3", "00000003", "10000003", "Test Estate 1"}); - table66.AddRow(new string[] { + table85.AddRow(new string[] { "Voucher", "Test Merchant 3", "00000003", "10000003", "Test Estate 1"}); - table66.AddRow(new string[] { + table85.AddRow(new string[] { "PataPawa PostPay", "Test Merchant 3", "00000003", "10000003", "Test Estate 1"}); - table66.AddRow(new string[] { + table85.AddRow(new string[] { "PataPawa PrePay", "Test Merchant 3", "00000001", "10000001", "Test Estate 1"}); - table66.AddRow(new string[] { + table85.AddRow(new string[] { "Safaricom", "Test Merchant 4", "00000004", "10000004", "Test Estate 1"}); - table66.AddRow(new string[] { + table85.AddRow(new string[] { "Voucher", "Test Merchant 4", "00000004", "10000004", "Test Estate 1"}); - table66.AddRow(new string[] { + table85.AddRow(new string[] { "PataPawa PostPay", "Test Merchant 4", "00000004", "10000004", "Test Estate 1"}); - table66.AddRow(new string[] { + table85.AddRow(new string[] { "PataPawa PrePay", "Test Merchant 4", "00000001", "10000001", "Test Estate 1"}); #line 87 - await testRunner.GivenAsync("I have assigned the following operator to the merchants", ((string)(null)), table66, "Given "); + await testRunner.GivenAsync("I have assigned the following operator to the merchants", ((string)(null)), table85, "Given "); #line hidden - Reqnroll.Table table67 = new Reqnroll.Table(new string[] { + Reqnroll.Table table86 = new Reqnroll.Table(new string[] { "DeviceIdentifier", "MerchantName", "EstateName"}); - table67.AddRow(new string[] { + table86.AddRow(new string[] { "123456780", "Test Merchant 1", "Test Estate 1"}); - table67.AddRow(new string[] { + table86.AddRow(new string[] { "123456781", "Test Merchant 2", "Test Estate 1"}); - table67.AddRow(new string[] { + table86.AddRow(new string[] { "123456782", "Test Merchant 3", "Test Estate 1"}); - table67.AddRow(new string[] { + table86.AddRow(new string[] { "123456783", "Test Merchant 4", "Test Estate 1"}); #line 106 - await testRunner.GivenAsync("I have assigned the following devices to the merchants", ((string)(null)), table67, "Given "); + await testRunner.GivenAsync("I have assigned the following devices to the merchants", ((string)(null)), table86, "Given "); #line hidden - Reqnroll.Table table68 = new Reqnroll.Table(new string[] { + Reqnroll.Table table87 = new Reqnroll.Table(new string[] { "Reference", "Amount", "DateTime", "MerchantName", "EstateName"}); - table68.AddRow(new string[] { + table87.AddRow(new string[] { "Deposit1", "265.00", "Today", "Test Merchant 1", "Test Estate 1"}); - table68.AddRow(new string[] { + table87.AddRow(new string[] { "Deposit1", "110.00", "Today", "Test Merchant 2", "Test Estate 1"}); - table68.AddRow(new string[] { + table87.AddRow(new string[] { "Deposit1", "110.00", "Today", "Test Merchant 3", "Test Estate 1"}); - table68.AddRow(new string[] { + table87.AddRow(new string[] { "Deposit1", "100.00", "Today", "Test Merchant 4", "Test Estate 1"}); #line 113 - await testRunner.GivenAsync("I make the following manual merchant deposits", ((string)(null)), table68, "Given "); + await testRunner.GivenAsync("I make the following manual merchant deposits", ((string)(null)), table87, "Given "); #line hidden - Reqnroll.Table table69 = new Reqnroll.Table(new string[] { + Reqnroll.Table table88 = new Reqnroll.Table(new string[] { "EstateName", "MerchantName", "ContractDescription"}); - table69.AddRow(new string[] { + table88.AddRow(new string[] { "Test Estate 1", "Test Merchant 1", "Safaricom Contract"}); - table69.AddRow(new string[] { + table88.AddRow(new string[] { "Test Estate 1", "Test Merchant 1", "Hospital 1 Contract"}); - table69.AddRow(new string[] { + table88.AddRow(new string[] { "Test Estate 1", "Test Merchant 1", "PataPawa PostPay Contract"}); - table69.AddRow(new string[] { + table88.AddRow(new string[] { "Test Estate 1", "Test Merchant 1", "PataPawa PrePay Contract"}); - table69.AddRow(new string[] { + table88.AddRow(new string[] { "Test Estate 1", "Test Merchant 2", "Safaricom Contract"}); - table69.AddRow(new string[] { + table88.AddRow(new string[] { "Test Estate 1", "Test Merchant 2", "Hospital 1 Contract"}); - table69.AddRow(new string[] { + table88.AddRow(new string[] { "Test Estate 1", "Test Merchant 2", "PataPawa PostPay Contract"}); - table69.AddRow(new string[] { + table88.AddRow(new string[] { "Test Estate 1", "Test Merchant 2", "PataPawa PrePay Contract"}); - table69.AddRow(new string[] { + table88.AddRow(new string[] { "Test Estate 1", "Test Merchant 3", "Safaricom Contract"}); - table69.AddRow(new string[] { + table88.AddRow(new string[] { "Test Estate 1", "Test Merchant 3", "Hospital 1 Contract"}); - table69.AddRow(new string[] { + table88.AddRow(new string[] { "Test Estate 1", "Test Merchant 3", "PataPawa PostPay Contract"}); - table69.AddRow(new string[] { + table88.AddRow(new string[] { "Test Estate 1", "Test Merchant 3", "PataPawa PrePay Contract"}); - table69.AddRow(new string[] { + table88.AddRow(new string[] { "Test Estate 1", "Test Merchant 4", "Safaricom Contract"}); - table69.AddRow(new string[] { + table88.AddRow(new string[] { "Test Estate 1", "Test Merchant 4", "Hospital 1 Contract"}); - table69.AddRow(new string[] { + table88.AddRow(new string[] { "Test Estate 1", "Test Merchant 4", "PataPawa PostPay Contract"}); - table69.AddRow(new string[] { + table88.AddRow(new string[] { "Test Estate 1", "Test Merchant 4", "PataPawa PrePay Contract"}); #line 120 - await testRunner.WhenAsync("I add the following contracts to the following merchants", ((string)(null)), table69, "When "); + await testRunner.WhenAsync("I add the following contracts to the following merchants", ((string)(null)), table88, "When "); #line hidden } @@ -655,7 +655,7 @@ public async System.Threading.Tasks.Task SaleTransactions() #line 4 await this.FeatureBackgroundAsync(); #line hidden - Reqnroll.Table table70 = new Reqnroll.Table(new string[] { + Reqnroll.Table table89 = new Reqnroll.Table(new string[] { "DateTime", "TransactionNumber", "TransactionType", @@ -675,7 +675,7 @@ public async System.Threading.Tasks.Task SaleTransactions() "AccountNumber", "CustomerName", "MeterNumber"}); - table70.AddRow(new string[] { + table89.AddRow(new string[] { "Today", "1", "Sale", @@ -695,7 +695,7 @@ public async System.Threading.Tasks.Task SaleTransactions() "", "", ""}); - table70.AddRow(new string[] { + table89.AddRow(new string[] { "Today", "2", "Sale", @@ -715,7 +715,7 @@ public async System.Threading.Tasks.Task SaleTransactions() "", "", ""}); - table70.AddRow(new string[] { + table89.AddRow(new string[] { "Today", "3", "Sale", @@ -735,7 +735,7 @@ public async System.Threading.Tasks.Task SaleTransactions() "", "", ""}); - table70.AddRow(new string[] { + table89.AddRow(new string[] { "Today", "4", "Sale", @@ -755,7 +755,7 @@ public async System.Threading.Tasks.Task SaleTransactions() "", "", ""}); - table70.AddRow(new string[] { + table89.AddRow(new string[] { "Today", "5", "Sale", @@ -775,7 +775,7 @@ public async System.Threading.Tasks.Task SaleTransactions() "", "", ""}); - table70.AddRow(new string[] { + table89.AddRow(new string[] { "Today", "6", "Sale", @@ -795,7 +795,7 @@ public async System.Threading.Tasks.Task SaleTransactions() "", "", ""}); - table70.AddRow(new string[] { + table89.AddRow(new string[] { "Today", "7", "Sale", @@ -815,7 +815,7 @@ public async System.Threading.Tasks.Task SaleTransactions() "", "", ""}); - table70.AddRow(new string[] { + table89.AddRow(new string[] { "Today", "8", "Sale", @@ -835,7 +835,7 @@ public async System.Threading.Tasks.Task SaleTransactions() "12345678", "", ""}); - table70.AddRow(new string[] { + table89.AddRow(new string[] { "Today", "9", "Sale", @@ -855,7 +855,7 @@ public async System.Threading.Tasks.Task SaleTransactions() "12345678", "Mr Test Customer", ""}); - table70.AddRow(new string[] { + table89.AddRow(new string[] { "Today", "10", "Sale", @@ -875,7 +875,7 @@ public async System.Threading.Tasks.Task SaleTransactions() "", "", "00000001"}); - table70.AddRow(new string[] { + table89.AddRow(new string[] { "Today", "11", "Sale", @@ -896,84 +896,84 @@ public async System.Threading.Tasks.Task SaleTransactions() "Customer 1", "00000001"}); #line 142 - await testRunner.WhenAsync("I perform the following transactions", ((string)(null)), table70, "When "); + await testRunner.WhenAsync("I perform the following transactions", ((string)(null)), table89, "When "); #line hidden - Reqnroll.Table table71 = new Reqnroll.Table(new string[] { + Reqnroll.Table table90 = new Reqnroll.Table(new string[] { "EstateName", "MerchantName", "TransactionNumber", "ResponseCode", "ResponseMessage"}); - table71.AddRow(new string[] { + table90.AddRow(new string[] { "Test Estate 1", "Test Merchant 1", "1", "0000", "SUCCESS"}); - table71.AddRow(new string[] { + table90.AddRow(new string[] { "Test Estate 1", "Test Merchant 2", "2", "0000", "SUCCESS"}); - table71.AddRow(new string[] { + table90.AddRow(new string[] { "Test Estate 1", "Test Merchant 3", "3", "0000", "SUCCESS"}); - table71.AddRow(new string[] { + table90.AddRow(new string[] { "Test Estate 1", "Test Merchant 1", "4", "0000", "SUCCESS"}); - table71.AddRow(new string[] { + table90.AddRow(new string[] { "Test Estate 1", "Test Merchant 1", "5", "0000", "SUCCESS"}); - table71.AddRow(new string[] { + table90.AddRow(new string[] { "Test Estate 1", "Test Merchant 2", "6", "0000", "SUCCESS"}); - table71.AddRow(new string[] { + table90.AddRow(new string[] { "Test Estate 1", "Test Merchant 3", "7", "0000", "SUCCESS"}); - table71.AddRow(new string[] { + table90.AddRow(new string[] { "Test Estate 1", "Test Merchant 1", "8", "0000", "SUCCESS"}); - table71.AddRow(new string[] { + table90.AddRow(new string[] { "Test Estate 1", "Test Merchant 1", "9", "0000", "SUCCESS"}); - table71.AddRow(new string[] { + table90.AddRow(new string[] { "Test Estate 1", "Test Merchant 1", "10", "0000", "SUCCESS"}); - table71.AddRow(new string[] { + table90.AddRow(new string[] { "Test Estate 1", "Test Merchant 1", "11", "0000", "SUCCESS"}); #line 156 - await testRunner.ThenAsync("transaction response should contain the following information", ((string)(null)), table71, "Then "); + await testRunner.ThenAsync("transaction response should contain the following information", ((string)(null)), table90, "Then "); #line hidden - Reqnroll.Table table72 = new Reqnroll.Table(new string[] { + Reqnroll.Table table91 = new Reqnroll.Table(new string[] { "DateTime", "Reference", "EntryType", @@ -981,7 +981,7 @@ public async System.Threading.Tasks.Task SaleTransactions() "Out", "ChangeAmount", "Balance"}); - table72.AddRow(new string[] { + table91.AddRow(new string[] { "Today", "Merchant Deposit", "C", @@ -989,7 +989,7 @@ public async System.Threading.Tasks.Task SaleTransactions() "0.00", "265.00", "230.00"}); - table72.AddRow(new string[] { + table91.AddRow(new string[] { "Today", "Transaction Completed", "D", @@ -997,7 +997,7 @@ public async System.Threading.Tasks.Task SaleTransactions() "110.00", "110.00", "130.00"}); - table72.AddRow(new string[] { + table91.AddRow(new string[] { "Today", "Transaction Completed", "D", @@ -1005,7 +1005,7 @@ public async System.Threading.Tasks.Task SaleTransactions() "90.00", "90.00", "30.00"}); - table72.AddRow(new string[] { + table91.AddRow(new string[] { "Today", "Transaction Completed", "D", @@ -1013,7 +1013,7 @@ public async System.Threading.Tasks.Task SaleTransactions() "10.00", "10.00", "20.00"}); - table72.AddRow(new string[] { + table91.AddRow(new string[] { "Today", "Transaction Completed", "D", @@ -1021,7 +1021,7 @@ public async System.Threading.Tasks.Task SaleTransactions() "20.00", "20.00", "20.00"}); - table72.AddRow(new string[] { + table91.AddRow(new string[] { "Today", "Transaction Completed", "D", @@ -1029,7 +1029,7 @@ public async System.Threading.Tasks.Task SaleTransactions() "20.00", "25.00", "20.00"}); - table72.AddRow(new string[] { + table91.AddRow(new string[] { "Today", "Transaction Fee Processed", "C", @@ -1037,7 +1037,7 @@ public async System.Threading.Tasks.Task SaleTransactions() "0.55", "0.55", "20.00"}); - table72.AddRow(new string[] { + table91.AddRow(new string[] { "Today", "Transaction Fee Processed", "C", @@ -1045,7 +1045,7 @@ public async System.Threading.Tasks.Task SaleTransactions() "0.45", "0.45", "20.00"}); - table72.AddRow(new string[] { + table91.AddRow(new string[] { "Today", "Transaction Fee Processed", "C", @@ -1053,7 +1053,7 @@ public async System.Threading.Tasks.Task SaleTransactions() "0.01", "0.10", "20.00"}); - table72.AddRow(new string[] { + table91.AddRow(new string[] { "Today", "Transaction Fee Processed", "C", @@ -1061,7 +1061,7 @@ public async System.Threading.Tasks.Task SaleTransactions() "0.01", "0.10", "20.00"}); - table72.AddRow(new string[] { + table91.AddRow(new string[] { "Today", "Opening Balance", "C", @@ -1071,9 +1071,9 @@ public async System.Threading.Tasks.Task SaleTransactions() "20.00"}); #line 170 await testRunner.ThenAsync("the following entries appear in the merchants balance history for estate \'Test Es" + - "tate 1\' and merchant \'Test Merchant 1\'", ((string)(null)), table72, "Then "); + "tate 1\' and merchant \'Test Merchant 1\'", ((string)(null)), table91, "Then "); #line hidden - Reqnroll.Table table73 = new Reqnroll.Table(new string[] { + Reqnroll.Table table92 = new Reqnroll.Table(new string[] { "DateTime", "Reference", "EntryType", @@ -1081,7 +1081,7 @@ public async System.Threading.Tasks.Task SaleTransactions() "Out", "ChangeAmount", "Balance"}); - table73.AddRow(new string[] { + table92.AddRow(new string[] { "Today", "Merchant Deposit", "C", @@ -1089,7 +1089,7 @@ public async System.Threading.Tasks.Task SaleTransactions() "0.00", "110.00", "230.00"}); - table73.AddRow(new string[] { + table92.AddRow(new string[] { "Today", "Transaction Completed", "D", @@ -1097,7 +1097,7 @@ public async System.Threading.Tasks.Task SaleTransactions() "100.00", "100.00", "130.00"}); - table73.AddRow(new string[] { + table92.AddRow(new string[] { "Today", "Transaction Completed", "D", @@ -1105,7 +1105,7 @@ public async System.Threading.Tasks.Task SaleTransactions() "10.00", "10.00", "30.00"}); - table73.AddRow(new string[] { + table92.AddRow(new string[] { "Today", "Transaction Fee Processed", "C", @@ -1113,7 +1113,7 @@ public async System.Threading.Tasks.Task SaleTransactions() "0.50", "0.50", "20.00"}); - table73.AddRow(new string[] { + table92.AddRow(new string[] { "Today", "Opening Balance", "C", @@ -1123,9 +1123,9 @@ public async System.Threading.Tasks.Task SaleTransactions() "20.00"}); #line 184 await testRunner.ThenAsync("the following entries appear in the merchants balance history for estate \'Test Es" + - "tate 1\' and merchant \'Test Merchant 2\'", ((string)(null)), table73, "Then "); + "tate 1\' and merchant \'Test Merchant 2\'", ((string)(null)), table92, "Then "); #line hidden - Reqnroll.Table table74 = new Reqnroll.Table(new string[] { + Reqnroll.Table table93 = new Reqnroll.Table(new string[] { "DateTime", "Reference", "EntryType", @@ -1133,7 +1133,7 @@ public async System.Threading.Tasks.Task SaleTransactions() "Out", "ChangeAmount", "Balance"}); - table74.AddRow(new string[] { + table93.AddRow(new string[] { "Today", "Merchant Deposit", "C", @@ -1141,7 +1141,7 @@ public async System.Threading.Tasks.Task SaleTransactions() "0.00", "110.00", "230.00"}); - table74.AddRow(new string[] { + table93.AddRow(new string[] { "Today", "Transaction Completed", "D", @@ -1149,7 +1149,7 @@ public async System.Threading.Tasks.Task SaleTransactions() "100.00", "100.00", "130.00"}); - table74.AddRow(new string[] { + table93.AddRow(new string[] { "Today", "Transaction Completed", "D", @@ -1157,7 +1157,7 @@ public async System.Threading.Tasks.Task SaleTransactions() "10.00", "10.00", "30.00"}); - table74.AddRow(new string[] { + table93.AddRow(new string[] { "Today", "Transaction Fee Processed", "C", @@ -1165,7 +1165,7 @@ public async System.Threading.Tasks.Task SaleTransactions() "0.85", "0.50", "20.00"}); - table74.AddRow(new string[] { + table93.AddRow(new string[] { "Today", "Opening Balance", "C", @@ -1175,20 +1175,20 @@ public async System.Threading.Tasks.Task SaleTransactions() "20.00"}); #line 192 await testRunner.ThenAsync("the following entries appear in the merchants balance history for estate \'Test Es" + - "tate 1\' and merchant \'Test Merchant 3\'", ((string)(null)), table74, "Then "); + "tate 1\' and merchant \'Test Merchant 3\'", ((string)(null)), table93, "Then "); #line hidden - Reqnroll.Table table75 = new Reqnroll.Table(new string[] { + Reqnroll.Table table94 = new Reqnroll.Table(new string[] { "EstateName", "MerchantName", "TransactionNumber"}); - table75.AddRow(new string[] { + table94.AddRow(new string[] { "Test Estate 1", "Test Merchant 1", "1"}); #line 200 - await testRunner.WhenAsync("I request the receipt is resent", ((string)(null)), table75, "When "); + await testRunner.WhenAsync("I request the receipt is resent", ((string)(null)), table94, "When "); #line hidden - Reqnroll.Table table76 = new Reqnroll.Table(new string[] { + Reqnroll.Table table95 = new Reqnroll.Table(new string[] { "DateTime", "TransactionNumber", "TransactionType", @@ -1202,7 +1202,7 @@ public async System.Threading.Tasks.Task SaleTransactions() "CustomerEmailAddress", "ContractDescription", "ProductName"}); - table76.AddRow(new string[] { + table95.AddRow(new string[] { "Today", "12", "Sale", @@ -1217,24 +1217,24 @@ public async System.Threading.Tasks.Task SaleTransactions() "Safaricom Contract", "Variable Topup"}); #line 204 - await testRunner.WhenAsync("I perform the following transactions", ((string)(null)), table76, "When "); + await testRunner.WhenAsync("I perform the following transactions", ((string)(null)), table95, "When "); #line hidden - Reqnroll.Table table77 = new Reqnroll.Table(new string[] { + Reqnroll.Table table96 = new Reqnroll.Table(new string[] { "EstateName", "MerchantName", "TransactionNumber", "ResponseCode", "ResponseMessage"}); - table77.AddRow(new string[] { + table96.AddRow(new string[] { "Test Estate 1", "Test Merchant 1", "12", "1000", "Device Identifier 123456781 not valid for Merchant Test Merchant 1"}); #line 208 - await testRunner.ThenAsync("transaction response should contain the following information", ((string)(null)), table77, "Then "); + await testRunner.ThenAsync("transaction response should contain the following information", ((string)(null)), table96, "Then "); #line hidden - Reqnroll.Table table78 = new Reqnroll.Table(new string[] { + Reqnroll.Table table97 = new Reqnroll.Table(new string[] { "DateTime", "TransactionNumber", "TransactionType", @@ -1248,7 +1248,7 @@ public async System.Threading.Tasks.Task SaleTransactions() "CustomerEmailAddress", "ContractDescription", "ProductName"}); - table78.AddRow(new string[] { + table97.AddRow(new string[] { "Today", "13", "Sale", @@ -1263,24 +1263,24 @@ public async System.Threading.Tasks.Task SaleTransactions() "Safaricom Contract", "Variable Topup"}); #line 212 - await testRunner.WhenAsync("I perform the following transactions", ((string)(null)), table78, "When "); + await testRunner.WhenAsync("I perform the following transactions", ((string)(null)), table97, "When "); #line hidden - Reqnroll.Table table79 = new Reqnroll.Table(new string[] { + Reqnroll.Table table98 = new Reqnroll.Table(new string[] { "EstateName", "MerchantName", "TransactionNumber", "ResponseCode", "ResponseMessage"}); - table79.AddRow(new string[] { + table98.AddRow(new string[] { "InvalidEstate", "Test Merchant 1", "13", "1001", "Estate Id [79902550-64df-4491-b0c1-4e78943928a3] is not a valid estate"}); #line 216 - await testRunner.ThenAsync("transaction response should contain the following information", ((string)(null)), table79, "Then "); + await testRunner.ThenAsync("transaction response should contain the following information", ((string)(null)), table98, "Then "); #line hidden - Reqnroll.Table table80 = new Reqnroll.Table(new string[] { + Reqnroll.Table table99 = new Reqnroll.Table(new string[] { "DateTime", "TransactionNumber", "TransactionType", @@ -1294,7 +1294,7 @@ public async System.Threading.Tasks.Task SaleTransactions() "CustomerEmailAddress", "ContractDescription", "ProductName"}); - table80.AddRow(new string[] { + table99.AddRow(new string[] { "Today", "14", "Sale", @@ -1309,15 +1309,15 @@ public async System.Threading.Tasks.Task SaleTransactions() "Safaricom Contract", "Variable Topup"}); #line 220 - await testRunner.WhenAsync("I perform the following transactions", ((string)(null)), table80, "When "); + await testRunner.WhenAsync("I perform the following transactions", ((string)(null)), table99, "When "); #line hidden - Reqnroll.Table table81 = new Reqnroll.Table(new string[] { + Reqnroll.Table table100 = new Reqnroll.Table(new string[] { "EstateName", "MerchantName", "TransactionNumber", "ResponseCode", "ResponseMessage"}); - table81.AddRow(new string[] { + table100.AddRow(new string[] { "Test Estate 1", "InvalidMerchant", "14", @@ -1325,9 +1325,9 @@ public async System.Threading.Tasks.Task SaleTransactions() "Merchant Id [d59320fa-4c3e-4900-a999-483f6a10c69a] is not a valid merchant for es" + "tate [Test Estate 1]"}); #line 224 - await testRunner.ThenAsync("transaction response should contain the following information", ((string)(null)), table81, "Then "); + await testRunner.ThenAsync("transaction response should contain the following information", ((string)(null)), table100, "Then "); #line hidden - Reqnroll.Table table82 = new Reqnroll.Table(new string[] { + Reqnroll.Table table101 = new Reqnroll.Table(new string[] { "DateTime", "TransactionNumber", "TransactionType", @@ -1341,7 +1341,7 @@ public async System.Threading.Tasks.Task SaleTransactions() "CustomerEmailAddress", "ContractDescription", "ProductName"}); - table82.AddRow(new string[] { + table101.AddRow(new string[] { "Today", "15", "Sale", @@ -1356,15 +1356,15 @@ public async System.Threading.Tasks.Task SaleTransactions() "EmptyContract", "Variable Topup"}); #line 228 - await testRunner.WhenAsync("I perform the following transactions", ((string)(null)), table82, "When "); + await testRunner.WhenAsync("I perform the following transactions", ((string)(null)), table101, "When "); #line hidden - Reqnroll.Table table83 = new Reqnroll.Table(new string[] { + Reqnroll.Table table102 = new Reqnroll.Table(new string[] { "EstateName", "MerchantName", "TransactionNumber", "ResponseCode", "ResponseMessage"}); - table83.AddRow(new string[] { + table102.AddRow(new string[] { "Test Estate 1", "Test Merchant 1", "15", @@ -1372,9 +1372,9 @@ public async System.Threading.Tasks.Task SaleTransactions() "Contract Id [00000000-0000-0000-0000-000000000000] must be set for a sale transac" + "tion"}); #line 232 - await testRunner.ThenAsync("transaction response should contain the following information", ((string)(null)), table83, "Then "); + await testRunner.ThenAsync("transaction response should contain the following information", ((string)(null)), table102, "Then "); #line hidden - Reqnroll.Table table84 = new Reqnroll.Table(new string[] { + Reqnroll.Table table103 = new Reqnroll.Table(new string[] { "DateTime", "TransactionNumber", "TransactionType", @@ -1388,7 +1388,7 @@ public async System.Threading.Tasks.Task SaleTransactions() "CustomerEmailAddress", "ContractDescription", "ProductName"}); - table84.AddRow(new string[] { + table103.AddRow(new string[] { "Today", "16", "Sale", @@ -1403,15 +1403,15 @@ public async System.Threading.Tasks.Task SaleTransactions() "InvalidContract", "Variable Topup"}); #line 236 - await testRunner.WhenAsync("I perform the following transactions", ((string)(null)), table84, "When "); + await testRunner.WhenAsync("I perform the following transactions", ((string)(null)), table103, "When "); #line hidden - Reqnroll.Table table85 = new Reqnroll.Table(new string[] { + Reqnroll.Table table104 = new Reqnroll.Table(new string[] { "EstateName", "MerchantName", "TransactionNumber", "ResponseCode", "ResponseMessage"}); - table85.AddRow(new string[] { + table104.AddRow(new string[] { "Test Estate 1", "Test Merchant 1", "16", @@ -1419,9 +1419,9 @@ public async System.Threading.Tasks.Task SaleTransactions() "Contract Id [934d8164-f36a-448e-b27b-4d671d41d180] not valid for Merchant [Test M" + "erchant 1]"}); #line 240 - await testRunner.ThenAsync("transaction response should contain the following information", ((string)(null)), table85, "Then "); + await testRunner.ThenAsync("transaction response should contain the following information", ((string)(null)), table104, "Then "); #line hidden - Reqnroll.Table table86 = new Reqnroll.Table(new string[] { + Reqnroll.Table table105 = new Reqnroll.Table(new string[] { "DateTime", "TransactionNumber", "TransactionType", @@ -1435,7 +1435,7 @@ public async System.Threading.Tasks.Task SaleTransactions() "CustomerEmailAddress", "ContractDescription", "ProductName"}); - table86.AddRow(new string[] { + table105.AddRow(new string[] { "Today", "17", "Sale", @@ -1450,15 +1450,15 @@ public async System.Threading.Tasks.Task SaleTransactions() "Safaricom Contract", "EmptyProduct"}); #line 244 - await testRunner.WhenAsync("I perform the following transactions", ((string)(null)), table86, "When "); + await testRunner.WhenAsync("I perform the following transactions", ((string)(null)), table105, "When "); #line hidden - Reqnroll.Table table87 = new Reqnroll.Table(new string[] { + Reqnroll.Table table106 = new Reqnroll.Table(new string[] { "EstateName", "MerchantName", "TransactionNumber", "ResponseCode", "ResponseMessage"}); - table87.AddRow(new string[] { + table106.AddRow(new string[] { "Test Estate 1", "Test Merchant 1", "17", @@ -1466,9 +1466,9 @@ public async System.Threading.Tasks.Task SaleTransactions() "Product Id [00000000-0000-0000-0000-000000000000] must be set for a sale transact" + "ion"}); #line 248 - await testRunner.ThenAsync("transaction response should contain the following information", ((string)(null)), table87, "Then "); + await testRunner.ThenAsync("transaction response should contain the following information", ((string)(null)), table106, "Then "); #line hidden - Reqnroll.Table table88 = new Reqnroll.Table(new string[] { + Reqnroll.Table table107 = new Reqnroll.Table(new string[] { "DateTime", "TransactionNumber", "TransactionType", @@ -1482,7 +1482,7 @@ public async System.Threading.Tasks.Task SaleTransactions() "CustomerEmailAddress", "ContractDescription", "ProductName"}); - table88.AddRow(new string[] { + table107.AddRow(new string[] { "Today", "18", "Sale", @@ -1497,15 +1497,15 @@ public async System.Threading.Tasks.Task SaleTransactions() "Safaricom Contract", "InvalidProduct"}); #line 252 - await testRunner.WhenAsync("I perform the following transactions", ((string)(null)), table88, "When "); + await testRunner.WhenAsync("I perform the following transactions", ((string)(null)), table107, "When "); #line hidden - Reqnroll.Table table89 = new Reqnroll.Table(new string[] { + Reqnroll.Table table108 = new Reqnroll.Table(new string[] { "EstateName", "MerchantName", "TransactionNumber", "ResponseCode", "ResponseMessage"}); - table89.AddRow(new string[] { + table108.AddRow(new string[] { "Test Estate 1", "Test Merchant 1", "18", @@ -1513,9 +1513,9 @@ public async System.Threading.Tasks.Task SaleTransactions() "Product Id [934d8164-f36a-448e-b27b-4d671d41d180] not valid for Merchant [Test Me" + "rchant 1]"}); #line 256 - await testRunner.ThenAsync("transaction response should contain the following information", ((string)(null)), table89, "Then "); + await testRunner.ThenAsync("transaction response should contain the following information", ((string)(null)), table108, "Then "); #line hidden - Reqnroll.Table table90 = new Reqnroll.Table(new string[] { + Reqnroll.Table table109 = new Reqnroll.Table(new string[] { "DateTime", "TransactionNumber", "TransactionType", @@ -1529,7 +1529,7 @@ public async System.Threading.Tasks.Task SaleTransactions() "CustomerEmailAddress", "ContractDescription", "ProductName"}); - table90.AddRow(new string[] { + table109.AddRow(new string[] { "Today", "19", "Sale", @@ -1544,15 +1544,15 @@ public async System.Threading.Tasks.Task SaleTransactions() "Safaricom Contract", "Variable Topup"}); #line 260 - await testRunner.WhenAsync("I perform the following transactions", ((string)(null)), table90, "When "); + await testRunner.WhenAsync("I perform the following transactions", ((string)(null)), table109, "When "); #line hidden - Reqnroll.Table table91 = new Reqnroll.Table(new string[] { + Reqnroll.Table table110 = new Reqnroll.Table(new string[] { "EstateName", "MerchantName", "TransactionNumber", "ResponseCode", "ResponseMessage"}); - table91.AddRow(new string[] { + table110.AddRow(new string[] { "Test Estate 1", "Test Merchant 4", "19", @@ -1560,7 +1560,7 @@ public async System.Threading.Tasks.Task SaleTransactions() "Merchant [Test Merchant 4] does not have enough credit available [100.00] to perf" + "orm transaction amount [300.00]"}); #line 264 - await testRunner.ThenAsync("transaction response should contain the following information", ((string)(null)), table91, "Then "); + await testRunner.ThenAsync("transaction response should contain the following information", ((string)(null)), table110, "Then "); #line hidden } await this.ScenarioCleanupAsync(); diff --git a/TransactionProcessor.IntegrationTests/Features/Settlement.feature.cs b/TransactionProcessor.IntegrationTests/Features/Settlement.feature.cs index 4c13b2ab..6b432020 100644 --- a/TransactionProcessor.IntegrationTests/Features/Settlement.feature.cs +++ b/TransactionProcessor.IntegrationTests/Features/Settlement.feature.cs @@ -81,128 +81,128 @@ public virtual async System.Threading.Tasks.Task FeatureBackgroundAsync() { #line 4 #line hidden - Reqnroll.Table table92 = new Reqnroll.Table(new string[] { + Reqnroll.Table table111 = new Reqnroll.Table(new string[] { "Name", "DisplayName", "Description"}); - table92.AddRow(new string[] { + table111.AddRow(new string[] { "estateManagement", "Estate Managememt REST Scope", "A scope for Estate Managememt REST"}); - table92.AddRow(new string[] { + table111.AddRow(new string[] { "transactionProcessor", "Transaction Processor REST Scope", "A scope for Transaction Processor REST"}); - table92.AddRow(new string[] { + table111.AddRow(new string[] { "voucherManagement", "Voucher Management REST Scope", "A scope for Voucher Management REST"}); #line 6 - await testRunner.GivenAsync("I create the following api scopes", ((string)(null)), table92, "Given "); + await testRunner.GivenAsync("I create the following api scopes", ((string)(null)), table111, "Given "); #line hidden - Reqnroll.Table table93 = new Reqnroll.Table(new string[] { + Reqnroll.Table table112 = new Reqnroll.Table(new string[] { "Name", "DisplayName", "Secret", "Scopes", "UserClaims"}); - table93.AddRow(new string[] { + table112.AddRow(new string[] { "estateManagement", "Estate Managememt REST", "Secret1", "estateManagement", "MerchantId, EstateId, role"}); - table93.AddRow(new string[] { + table112.AddRow(new string[] { "transactionProcessor", "Transaction Processor REST", "Secret1", "transactionProcessor", ""}); - table93.AddRow(new string[] { + table112.AddRow(new string[] { "voucherManagement", "Voucher Management REST", "Secret1", "voucherManagement", ""}); #line 12 - await testRunner.GivenAsync("the following api resources exist", ((string)(null)), table93, "Given "); + await testRunner.GivenAsync("the following api resources exist", ((string)(null)), table112, "Given "); #line hidden - Reqnroll.Table table94 = new Reqnroll.Table(new string[] { + Reqnroll.Table table113 = new Reqnroll.Table(new string[] { "ClientId", "ClientName", "Secret", "Scopes", "GrantTypes"}); - table94.AddRow(new string[] { + table113.AddRow(new string[] { "serviceClient", "Service Client", "Secret1", "estateManagement,transactionProcessor,voucherManagement", "client_credentials"}); #line 18 - await testRunner.GivenAsync("the following clients exist", ((string)(null)), table94, "Given "); + await testRunner.GivenAsync("the following clients exist", ((string)(null)), table113, "Given "); #line hidden - Reqnroll.Table table95 = new Reqnroll.Table(new string[] { + Reqnroll.Table table114 = new Reqnroll.Table(new string[] { "ClientId"}); - table95.AddRow(new string[] { + table114.AddRow(new string[] { "serviceClient"}); #line 22 await testRunner.GivenAsync("I have a token to access the estate management and transaction processor resource" + - "s", ((string)(null)), table95, "Given "); + "s", ((string)(null)), table114, "Given "); #line hidden - Reqnroll.Table table96 = new Reqnroll.Table(new string[] { + Reqnroll.Table table115 = new Reqnroll.Table(new string[] { "EstateName"}); - table96.AddRow(new string[] { + table115.AddRow(new string[] { "Test Estate 1"}); #line 26 - await testRunner.GivenAsync("I have created the following estates", ((string)(null)), table96, "Given "); + await testRunner.GivenAsync("I have created the following estates", ((string)(null)), table115, "Given "); #line hidden - Reqnroll.Table table97 = new Reqnroll.Table(new string[] { + Reqnroll.Table table116 = new Reqnroll.Table(new string[] { "EstateName", "OperatorName", "RequireCustomMerchantNumber", "RequireCustomTerminalNumber"}); - table97.AddRow(new string[] { + table116.AddRow(new string[] { "Test Estate 1", "Safaricom", "True", "True"}); - table97.AddRow(new string[] { + table116.AddRow(new string[] { "Test Estate 1", "Voucher", "True", "True"}); #line 30 - await testRunner.GivenAsync("I have created the following operators", ((string)(null)), table97, "Given "); + await testRunner.GivenAsync("I have created the following operators", ((string)(null)), table116, "Given "); #line hidden - Reqnroll.Table table98 = new Reqnroll.Table(new string[] { + Reqnroll.Table table117 = new Reqnroll.Table(new string[] { "EstateName", "OperatorName"}); - table98.AddRow(new string[] { + table117.AddRow(new string[] { "Test Estate 1", "Safaricom"}); - table98.AddRow(new string[] { + table117.AddRow(new string[] { "Test Estate 1", "Voucher"}); #line 35 - await testRunner.AndAsync("I have assigned the following operators to the estates", ((string)(null)), table98, "And "); + await testRunner.AndAsync("I have assigned the following operators to the estates", ((string)(null)), table117, "And "); #line hidden - Reqnroll.Table table99 = new Reqnroll.Table(new string[] { + Reqnroll.Table table118 = new Reqnroll.Table(new string[] { "EstateName", "OperatorName", "ContractDescription"}); - table99.AddRow(new string[] { + table118.AddRow(new string[] { "Test Estate 1", "Safaricom", "Safaricom Contract"}); - table99.AddRow(new string[] { + table118.AddRow(new string[] { "Test Estate 1", "Voucher", "Hospital 1 Contract"}); #line 40 - await testRunner.GivenAsync("I create a contract with the following values", ((string)(null)), table99, "Given "); + await testRunner.GivenAsync("I create a contract with the following values", ((string)(null)), table118, "Given "); #line hidden - Reqnroll.Table table100 = new Reqnroll.Table(new string[] { + Reqnroll.Table table119 = new Reqnroll.Table(new string[] { "EstateName", "OperatorName", "ContractDescription", @@ -210,7 +210,7 @@ await testRunner.GivenAsync("I have a token to access the estate management and "DisplayText", "Value", "ProductType"}); - table100.AddRow(new string[] { + table119.AddRow(new string[] { "Test Estate 1", "Safaricom", "Safaricom Contract", @@ -218,7 +218,7 @@ await testRunner.GivenAsync("I have a token to access the estate management and "Custom", "", "MobileTopup"}); - table100.AddRow(new string[] { + table119.AddRow(new string[] { "Test Estate 1", "Voucher", "Hospital 1 Contract", @@ -227,9 +227,9 @@ await testRunner.GivenAsync("I have a token to access the estate management and "", "Voucher"}); #line 45 - await testRunner.WhenAsync("I create the following Products", ((string)(null)), table100, "When "); + await testRunner.WhenAsync("I create the following Products", ((string)(null)), table119, "When "); #line hidden - Reqnroll.Table table101 = new Reqnroll.Table(new string[] { + Reqnroll.Table table120 = new Reqnroll.Table(new string[] { "EstateName", "OperatorName", "ContractDescription", @@ -237,7 +237,7 @@ await testRunner.GivenAsync("I have a token to access the estate management and "CalculationType", "FeeDescription", "Value"}); - table101.AddRow(new string[] { + table120.AddRow(new string[] { "Test Estate 1", "Safaricom", "Safaricom Contract", @@ -246,7 +246,7 @@ await testRunner.GivenAsync("I have a token to access the estate management and "Merchant Commission", "2.50"}); #line 50 - await testRunner.WhenAsync("I add the following Transaction Fees", ((string)(null)), table101, "When "); + await testRunner.WhenAsync("I add the following Transaction Fees", ((string)(null)), table120, "When "); #line hidden } @@ -270,7 +270,7 @@ public async System.Threading.Tasks.Task GetPendingSettlement() #line 4 await this.FeatureBackgroundAsync(); #line hidden - Reqnroll.Table table102 = new Reqnroll.Table(new string[] { + Reqnroll.Table table121 = new Reqnroll.Table(new string[] { "MerchantName", "AddressLine1", "Town", @@ -280,7 +280,7 @@ public async System.Threading.Tasks.Task GetPendingSettlement() "EmailAddress", "EstateName", "SettlementSchedule"}); - table102.AddRow(new string[] { + table121.AddRow(new string[] { "Test Merchant 1", "Address Line 1", "TestTown", @@ -290,7 +290,7 @@ public async System.Threading.Tasks.Task GetPendingSettlement() "testcontact1@merchant1.co.uk", "Test Estate 1", "Immediate"}); - table102.AddRow(new string[] { + table121.AddRow(new string[] { "Test Merchant 2", "Address Line 1", "TestTown", @@ -300,7 +300,7 @@ public async System.Threading.Tasks.Task GetPendingSettlement() "testcontact2@merchant2.co.uk", "Test Estate 1", "Weekly"}); - table102.AddRow(new string[] { + table121.AddRow(new string[] { "Test Merchant 3", "Address Line 1", "TestTown", @@ -311,131 +311,131 @@ public async System.Threading.Tasks.Task GetPendingSettlement() "Test Estate 1", "Monthly"}); #line 55 - await testRunner.GivenAsync("I create the following merchants", ((string)(null)), table102, "Given "); + await testRunner.GivenAsync("I create the following merchants", ((string)(null)), table121, "Given "); #line hidden - Reqnroll.Table table103 = new Reqnroll.Table(new string[] { + Reqnroll.Table table122 = new Reqnroll.Table(new string[] { "OperatorName", "MerchantName", "MerchantNumber", "TerminalNumber", "EstateName"}); - table103.AddRow(new string[] { + table122.AddRow(new string[] { "Safaricom", "Test Merchant 1", "00000001", "10000001", "Test Estate 1"}); - table103.AddRow(new string[] { + table122.AddRow(new string[] { "Voucher", "Test Merchant 1", "00000001", "10000001", "Test Estate 1"}); - table103.AddRow(new string[] { + table122.AddRow(new string[] { "Safaricom", "Test Merchant 2", "00000002", "10000002", "Test Estate 1"}); - table103.AddRow(new string[] { + table122.AddRow(new string[] { "Voucher", "Test Merchant 2", "00000002", "10000002", "Test Estate 1"}); - table103.AddRow(new string[] { + table122.AddRow(new string[] { "Safaricom", "Test Merchant 3", "00000003", "10000003", "Test Estate 1"}); - table103.AddRow(new string[] { + table122.AddRow(new string[] { "Voucher", "Test Merchant 3", "00000003", "10000003", "Test Estate 1"}); #line 61 - await testRunner.GivenAsync("I have assigned the following operator to the merchants", ((string)(null)), table103, "Given "); + await testRunner.GivenAsync("I have assigned the following operator to the merchants", ((string)(null)), table122, "Given "); #line hidden - Reqnroll.Table table104 = new Reqnroll.Table(new string[] { + Reqnroll.Table table123 = new Reqnroll.Table(new string[] { "DeviceIdentifier", "MerchantName", "EstateName"}); - table104.AddRow(new string[] { + table123.AddRow(new string[] { "123456780", "Test Merchant 1", "Test Estate 1"}); - table104.AddRow(new string[] { + table123.AddRow(new string[] { "123456781", "Test Merchant 2", "Test Estate 1"}); - table104.AddRow(new string[] { + table123.AddRow(new string[] { "123456782", "Test Merchant 3", "Test Estate 1"}); #line 70 - await testRunner.GivenAsync("I have assigned the following devices to the merchants", ((string)(null)), table104, "Given "); + await testRunner.GivenAsync("I have assigned the following devices to the merchants", ((string)(null)), table123, "Given "); #line hidden - Reqnroll.Table table105 = new Reqnroll.Table(new string[] { + Reqnroll.Table table124 = new Reqnroll.Table(new string[] { "Reference", "Amount", "DateTime", "MerchantName", "EstateName"}); - table105.AddRow(new string[] { + table124.AddRow(new string[] { "Deposit1", "210.00", "Today", "Test Merchant 1", "Test Estate 1"}); - table105.AddRow(new string[] { + table124.AddRow(new string[] { "Deposit1", "110.00", "Today", "Test Merchant 2", "Test Estate 1"}); - table105.AddRow(new string[] { + table124.AddRow(new string[] { "Deposit1", "120.00", "Today", "Test Merchant 3", "Test Estate 1"}); #line 76 - await testRunner.GivenAsync("I make the following manual merchant deposits", ((string)(null)), table105, "Given "); + await testRunner.GivenAsync("I make the following manual merchant deposits", ((string)(null)), table124, "Given "); #line hidden - Reqnroll.Table table106 = new Reqnroll.Table(new string[] { + Reqnroll.Table table125 = new Reqnroll.Table(new string[] { "EstateName", "MerchantName", "ContractDescription"}); - table106.AddRow(new string[] { + table125.AddRow(new string[] { "Test Estate 1", "Test Merchant 1", "Safaricom Contract"}); - table106.AddRow(new string[] { + table125.AddRow(new string[] { "Test Estate 1", "Test Merchant 1", "Hospital 1 Contract"}); - table106.AddRow(new string[] { + table125.AddRow(new string[] { "Test Estate 1", "Test Merchant 2", "Safaricom Contract"}); - table106.AddRow(new string[] { + table125.AddRow(new string[] { "Test Estate 1", "Test Merchant 2", "Hospital 1 Contract"}); - table106.AddRow(new string[] { + table125.AddRow(new string[] { "Test Estate 1", "Test Merchant 3", "Safaricom Contract"}); - table106.AddRow(new string[] { + table125.AddRow(new string[] { "Test Estate 1", "Test Merchant 3", "Hospital 1 Contract"}); #line 82 - await testRunner.WhenAsync("I add the following contracts to the following merchants", ((string)(null)), table106, "When "); + await testRunner.WhenAsync("I add the following contracts to the following merchants", ((string)(null)), table125, "When "); #line hidden - Reqnroll.Table table107 = new Reqnroll.Table(new string[] { + Reqnroll.Table table126 = new Reqnroll.Table(new string[] { "DateTime", "TransactionNumber", "TransactionType", @@ -451,7 +451,7 @@ public async System.Threading.Tasks.Task GetPendingSettlement() "ProductName", "RecipientEmail", "RecipientMobile"}); - table107.AddRow(new string[] { + table126.AddRow(new string[] { "2022-01-06", "1", "Sale", @@ -467,7 +467,7 @@ public async System.Threading.Tasks.Task GetPendingSettlement() "Variable Topup", "", ""}); - table107.AddRow(new string[] { + table126.AddRow(new string[] { "2022-01-06", "2", "Sale", @@ -483,7 +483,7 @@ public async System.Threading.Tasks.Task GetPendingSettlement() "Variable Topup", "", ""}); - table107.AddRow(new string[] { + table126.AddRow(new string[] { "2022-01-06", "3", "Sale", @@ -499,7 +499,7 @@ public async System.Threading.Tasks.Task GetPendingSettlement() "Variable Topup", "", ""}); - table107.AddRow(new string[] { + table126.AddRow(new string[] { "2022-01-06", "4", "Sale", @@ -515,7 +515,7 @@ public async System.Threading.Tasks.Task GetPendingSettlement() "Variable Topup", "", ""}); - table107.AddRow(new string[] { + table126.AddRow(new string[] { "2022-01-06", "5", "Sale", @@ -531,7 +531,7 @@ public async System.Threading.Tasks.Task GetPendingSettlement() "10 KES", "test@recipient.co.uk", ""}); - table107.AddRow(new string[] { + table126.AddRow(new string[] { "2022-01-06", "6", "Sale", @@ -547,7 +547,7 @@ public async System.Threading.Tasks.Task GetPendingSettlement() "10 KES", "", "123456789"}); - table107.AddRow(new string[] { + table126.AddRow(new string[] { "2022-01-06", "7", "Sale", @@ -563,7 +563,7 @@ public async System.Threading.Tasks.Task GetPendingSettlement() "10 KES", "test@recipient.co.uk", ""}); - table107.AddRow(new string[] { + table126.AddRow(new string[] { "2022-01-06", "8", "Sale", @@ -580,95 +580,95 @@ public async System.Threading.Tasks.Task GetPendingSettlement() "test@recipient.co.uk", ""}); #line 91 - await testRunner.WhenAsync("I perform the following transactions", ((string)(null)), table107, "When "); + await testRunner.WhenAsync("I perform the following transactions", ((string)(null)), table126, "When "); #line hidden - Reqnroll.Table table108 = new Reqnroll.Table(new string[] { + Reqnroll.Table table127 = new Reqnroll.Table(new string[] { "EstateName", "MerchantName", "TransactionNumber", "ResponseCode", "ResponseMessage"}); - table108.AddRow(new string[] { + table127.AddRow(new string[] { "Test Estate 1", "Test Merchant 1", "1", "0000", "SUCCESS"}); - table108.AddRow(new string[] { + table127.AddRow(new string[] { "Test Estate 1", "Test Merchant 2", "2", "0000", "SUCCESS"}); - table108.AddRow(new string[] { + table127.AddRow(new string[] { "Test Estate 1", "Test Merchant 3", "3", "0000", "SUCCESS"}); - table108.AddRow(new string[] { + table127.AddRow(new string[] { "Test Estate 1", "Test Merchant 1", "4", "0000", "SUCCESS"}); - table108.AddRow(new string[] { + table127.AddRow(new string[] { "Test Estate 1", "Test Merchant 1", "5", "0000", "SUCCESS"}); - table108.AddRow(new string[] { + table127.AddRow(new string[] { "Test Estate 1", "Test Merchant 2", "6", "0000", "SUCCESS"}); - table108.AddRow(new string[] { + table127.AddRow(new string[] { "Test Estate 1", "Test Merchant 3", "7", "0000", "SUCCESS"}); - table108.AddRow(new string[] { + table127.AddRow(new string[] { "Test Estate 1", "Test Merchant 3", "8", "0000", "SUCCESS"}); #line 102 - await testRunner.ThenAsync("transaction response should contain the following information", ((string)(null)), table108, "Then "); + await testRunner.ThenAsync("transaction response should contain the following information", ((string)(null)), table127, "Then "); #line hidden - Reqnroll.Table table109 = new Reqnroll.Table(new string[] { + Reqnroll.Table table128 = new Reqnroll.Table(new string[] { "SettlementDate", "EstateName", "MerchantName", "NumberOfFees"}); - table109.AddRow(new string[] { + table128.AddRow(new string[] { "2022-01-13", "Test Estate 1", "Test Merchant 2", "1"}); - table109.AddRow(new string[] { + table128.AddRow(new string[] { "2022-02-06", "Test Estate 1", "Test Merchant 3", "1"}); #line 113 - await testRunner.WhenAsync("I get the pending settlements the following information should be returned", ((string)(null)), table109, "When "); + await testRunner.WhenAsync("I get the pending settlements the following information should be returned", ((string)(null)), table128, "When "); #line hidden - Reqnroll.Table table110 = new Reqnroll.Table(new string[] { + Reqnroll.Table table129 = new Reqnroll.Table(new string[] { "SettlementDate", "EstateName", "MerchantName", "NumberOfFees"}); - table110.AddRow(new string[] { + table129.AddRow(new string[] { "2022-01-06", "Test Estate 1", "Test Merchant 1", "2"}); #line 118 - await testRunner.WhenAsync("I get the completed settlements the following information should be returned", ((string)(null)), table110, "When "); + await testRunner.WhenAsync("I get the completed settlements the following information should be returned", ((string)(null)), table129, "When "); #line hidden } await this.ScenarioCleanupAsync(); @@ -696,7 +696,7 @@ public async System.Threading.Tasks.Task ProcessSettlement() #line 4 await this.FeatureBackgroundAsync(); #line hidden - Reqnroll.Table table111 = new Reqnroll.Table(new string[] { + Reqnroll.Table table130 = new Reqnroll.Table(new string[] { "MerchantName", "AddressLine1", "Town", @@ -706,7 +706,7 @@ public async System.Threading.Tasks.Task ProcessSettlement() "EmailAddress", "EstateName", "SettlementSchedule"}); - table111.AddRow(new string[] { + table130.AddRow(new string[] { "Test Merchant 1", "Address Line 1", "TestTown", @@ -716,7 +716,7 @@ public async System.Threading.Tasks.Task ProcessSettlement() "testcontact1@merchant1.co.uk", "Test Estate 1", "Immediate"}); - table111.AddRow(new string[] { + table130.AddRow(new string[] { "Test Merchant 2", "Address Line 1", "TestTown", @@ -727,101 +727,101 @@ public async System.Threading.Tasks.Task ProcessSettlement() "Test Estate 1", "Weekly"}); #line 124 - await testRunner.GivenAsync("I create the following merchants", ((string)(null)), table111, "Given "); + await testRunner.GivenAsync("I create the following merchants", ((string)(null)), table130, "Given "); #line hidden - Reqnroll.Table table112 = new Reqnroll.Table(new string[] { + Reqnroll.Table table131 = new Reqnroll.Table(new string[] { "OperatorName", "MerchantName", "MerchantNumber", "TerminalNumber", "EstateName"}); - table112.AddRow(new string[] { + table131.AddRow(new string[] { "Safaricom", "Test Merchant 1", "00000001", "10000001", "Test Estate 1"}); - table112.AddRow(new string[] { + table131.AddRow(new string[] { "Voucher", "Test Merchant 1", "00000001", "10000001", "Test Estate 1"}); - table112.AddRow(new string[] { + table131.AddRow(new string[] { "Safaricom", "Test Merchant 2", "00000002", "10000002", "Test Estate 1"}); - table112.AddRow(new string[] { + table131.AddRow(new string[] { "Voucher", "Test Merchant 2", "00000002", "10000002", "Test Estate 1"}); #line 129 - await testRunner.GivenAsync("I have assigned the following operator to the merchants", ((string)(null)), table112, "Given "); + await testRunner.GivenAsync("I have assigned the following operator to the merchants", ((string)(null)), table131, "Given "); #line hidden - Reqnroll.Table table113 = new Reqnroll.Table(new string[] { + Reqnroll.Table table132 = new Reqnroll.Table(new string[] { "DeviceIdentifier", "MerchantName", "EstateName"}); - table113.AddRow(new string[] { + table132.AddRow(new string[] { "123456780", "Test Merchant 1", "Test Estate 1"}); - table113.AddRow(new string[] { + table132.AddRow(new string[] { "123456781", "Test Merchant 2", "Test Estate 1"}); #line 136 - await testRunner.GivenAsync("I have assigned the following devices to the merchants", ((string)(null)), table113, "Given "); + await testRunner.GivenAsync("I have assigned the following devices to the merchants", ((string)(null)), table132, "Given "); #line hidden - Reqnroll.Table table114 = new Reqnroll.Table(new string[] { + Reqnroll.Table table133 = new Reqnroll.Table(new string[] { "EstateName", "MerchantName", "ContractDescription"}); - table114.AddRow(new string[] { + table133.AddRow(new string[] { "Test Estate 1", "Test Merchant 1", "Safaricom Contract"}); - table114.AddRow(new string[] { + table133.AddRow(new string[] { "Test Estate 1", "Test Merchant 1", "Hospital 1 Contract"}); - table114.AddRow(new string[] { + table133.AddRow(new string[] { "Test Estate 1", "Test Merchant 2", "Safaricom Contract"}); - table114.AddRow(new string[] { + table133.AddRow(new string[] { "Test Estate 1", "Test Merchant 2", "Hospital 1 Contract"}); #line 141 - await testRunner.WhenAsync("I add the following contracts to the following merchants", ((string)(null)), table114, "When "); + await testRunner.WhenAsync("I add the following contracts to the following merchants", ((string)(null)), table133, "When "); #line hidden - Reqnroll.Table table115 = new Reqnroll.Table(new string[] { + Reqnroll.Table table134 = new Reqnroll.Table(new string[] { "Reference", "Amount", "DateTime", "MerchantName", "EstateName"}); - table115.AddRow(new string[] { + table134.AddRow(new string[] { "Deposit1", "210.00", "Today", "Test Merchant 1", "Test Estate 1"}); - table115.AddRow(new string[] { + table134.AddRow(new string[] { "Deposit1", "110.00", "Today", "Test Merchant 2", "Test Estate 1"}); #line 148 - await testRunner.GivenAsync("I make the following manual merchant deposits", ((string)(null)), table115, "Given "); + await testRunner.GivenAsync("I make the following manual merchant deposits", ((string)(null)), table134, "Given "); #line hidden - Reqnroll.Table table116 = new Reqnroll.Table(new string[] { + Reqnroll.Table table135 = new Reqnroll.Table(new string[] { "DateTime", "TransactionNumber", "TransactionType", @@ -837,7 +837,7 @@ public async System.Threading.Tasks.Task ProcessSettlement() "ProductName", "RecipientEmail", "RecipientMobile"}); - table116.AddRow(new string[] { + table135.AddRow(new string[] { "2022-01-06", "1", "Sale", @@ -853,7 +853,7 @@ public async System.Threading.Tasks.Task ProcessSettlement() "Variable Topup", "", ""}); - table116.AddRow(new string[] { + table135.AddRow(new string[] { "2022-01-06", "2", "Sale", @@ -869,7 +869,7 @@ public async System.Threading.Tasks.Task ProcessSettlement() "Variable Topup", "", ""}); - table116.AddRow(new string[] { + table135.AddRow(new string[] { "2022-01-06", "4", "Sale", @@ -885,7 +885,7 @@ public async System.Threading.Tasks.Task ProcessSettlement() "Variable Topup", "", ""}); - table116.AddRow(new string[] { + table135.AddRow(new string[] { "2022-01-06", "5", "Sale", @@ -901,7 +901,7 @@ public async System.Threading.Tasks.Task ProcessSettlement() "10 KES", "test@recipient.co.uk", ""}); - table116.AddRow(new string[] { + table135.AddRow(new string[] { "2022-01-06", "6", "Sale", @@ -918,59 +918,59 @@ public async System.Threading.Tasks.Task ProcessSettlement() "", "123456789"}); #line 153 - await testRunner.WhenAsync("I perform the following transactions", ((string)(null)), table116, "When "); + await testRunner.WhenAsync("I perform the following transactions", ((string)(null)), table135, "When "); #line hidden - Reqnroll.Table table117 = new Reqnroll.Table(new string[] { + Reqnroll.Table table136 = new Reqnroll.Table(new string[] { "EstateName", "MerchantName", "TransactionNumber", "ResponseCode", "ResponseMessage"}); - table117.AddRow(new string[] { + table136.AddRow(new string[] { "Test Estate 1", "Test Merchant 1", "1", "0000", "SUCCESS"}); - table117.AddRow(new string[] { + table136.AddRow(new string[] { "Test Estate 1", "Test Merchant 2", "2", "0000", "SUCCESS"}); - table117.AddRow(new string[] { + table136.AddRow(new string[] { "Test Estate 1", "Test Merchant 1", "4", "0000", "SUCCESS"}); - table117.AddRow(new string[] { + table136.AddRow(new string[] { "Test Estate 1", "Test Merchant 1", "5", "0000", "SUCCESS"}); - table117.AddRow(new string[] { + table136.AddRow(new string[] { "Test Estate 1", "Test Merchant 2", "6", "0000", "SUCCESS"}); #line 161 - await testRunner.ThenAsync("transaction response should contain the following information", ((string)(null)), table117, "Then "); + await testRunner.ThenAsync("transaction response should contain the following information", ((string)(null)), table136, "Then "); #line hidden - Reqnroll.Table table118 = new Reqnroll.Table(new string[] { + Reqnroll.Table table137 = new Reqnroll.Table(new string[] { "SettlementDate", "EstateName", "MerchantName", "NumberOfFees"}); - table118.AddRow(new string[] { + table137.AddRow(new string[] { "2022-01-13", "Test Estate 1", "Test Merchant 2", "1"}); #line 169 - await testRunner.WhenAsync("I get the pending settlements the following information should be returned", ((string)(null)), table118, "When "); + await testRunner.WhenAsync("I get the pending settlements the following information should be returned", ((string)(null)), table137, "When "); #line hidden #line 173 await testRunner.WhenAsync("I process the settlement for \'2022-01-13\' on Estate \'Test Estate 1\' for Merchant " + diff --git a/TransactionProcessor.IntegrationTests/Shared/SharedSteps.cs b/TransactionProcessor.IntegrationTests/Shared/SharedSteps.cs index 7f59aa28..70974480 100644 --- a/TransactionProcessor.IntegrationTests/Shared/SharedSteps.cs +++ b/TransactionProcessor.IntegrationTests/Shared/SharedSteps.cs @@ -1,5 +1,8 @@ using System; using System.Collections.Generic; +using TransactionProcessor.DataTransferObjects.Requests.Contract; +using TransactionProcessor.DataTransferObjects.Requests.Merchant; +using TransactionProcessor.DataTransferObjects.Responses.Contract; namespace TransactionProcessor.IntegrationTests.Shared { @@ -9,22 +12,13 @@ namespace TransactionProcessor.IntegrationTests.Shared using System.Threading.Tasks; using Common; using DataTransferObjects; - using EstateManagement.DataTransferObjects.Requests; - using EstateManagement.DataTransferObjects.Requests.Contract; - using EstateManagement.DataTransferObjects.Requests.Estate; - using EstateManagement.DataTransferObjects.Requests.Merchant; - using EstateManagement.DataTransferObjects.Requests.Operator; - using EstateManagement.DataTransferObjects.Responses; - using EstateManagement.DataTransferObjects.Responses.Contract; - using EstateManagement.DataTransferObjects.Responses.Estate; - using EstateManagement.IntegrationTesting.Helpers; using IntegrationTesting.Helpers; using Newtonsoft.Json.Linq; using Reqnroll; using SecurityService.DataTransferObjects.Requests; using SecurityService.IntegrationTesting.Helpers; using Shouldly; - using AssignOperatorRequest = EstateManagement.DataTransferObjects.Requests.Estate.AssignOperatorRequest; + using AssignOperatorRequest = DataTransferObjects.Requests.Estate.AssignOperatorRequest; using ClientDetails = Common.ClientDetails; using Contract = Common.Contract; using MerchantBalanceResponse = DataTransferObjects.MerchantBalanceResponse; @@ -42,7 +36,7 @@ public partial class SharedSteps private readonly SecurityServiceSteps SecurityServiceSteps; - private readonly EstateManagementSteps EstateManagementSteps; + //private readonly EstateManagementSteps EstateManagementSteps; private readonly TransactionProcessorSteps TransactionProcessorSteps; public SharedSteps(ScenarioContext scenarioContext, @@ -50,20 +44,20 @@ public SharedSteps(ScenarioContext scenarioContext, this.ScenarioContext = scenarioContext; this.TestingContext = testingContext; this.SecurityServiceSteps = new SecurityServiceSteps(testingContext.DockerHelper.SecurityServiceClient); - this.EstateManagementSteps = new EstateManagementSteps(testingContext.DockerHelper.EstateClient.EstateClient, testingContext.DockerHelper.TestHostHttpClient); + //this.EstateManagementSteps = new EstateManagementSteps(testingContext.DockerHelper.EstateClient.EstateClient, testingContext.DockerHelper.TestHostHttpClient); this.TransactionProcessorSteps = new TransactionProcessorSteps(testingContext.DockerHelper.TransactionProcessorClient, testingContext.DockerHelper.TestHostHttpClient, testingContext.DockerHelper.ProjectionManagementClient); } - [Given(@"I have a token to access the estate management and transaction processor resources")] - public async Task GivenIHaveATokenToAccessTheEstateManagementAndTransactionProcessorResources(DataTable table) - { - DataTableRow firstRow = table.Rows.First(); - String clientId = ReqnrollTableHelper.GetStringRowValue(firstRow, "ClientId"); - ClientDetails clientDetails = this.TestingContext.GetClientDetails(clientId); - - this.TestingContext.AccessToken = await this.SecurityServiceSteps.GetClientToken(clientDetails.ClientId, clientDetails.ClientSecret, CancellationToken.None); - } + //[Given(@"I have a token to access the estate management and transaction processor resources")] + //public async Task GivenIHaveATokenToAccessTheEstateManagementAndTransactionProcessorResources(DataTable table) + //{ + // DataTableRow firstRow = table.Rows.First(); + // String clientId = ReqnrollTableHelper.GetStringRowValue(firstRow, "ClientId"); + // ClientDetails clientDetails = this.TestingContext.GetClientDetails(clientId); + + // this.TestingContext.AccessToken = await this.SecurityServiceSteps.GetClientToken(clientDetails.ClientId, clientDetails.ClientSecret, CancellationToken.None); + //} } @@ -132,11 +126,11 @@ public async Task GivenTheFollowingMetersAreAvailableAtThePataPawaPrePayHost(Dat [When(@"I create the following estates")] public async Task WhenICreateTheFollowingEstates(DataTable table) { - List requests = table.Rows.ToCreateEstateRequests(); + List requests = table.Rows.ToCreateEstateRequests(); - List verifiedEstates = await this.EstateManagementSteps.WhenICreateTheFollowingEstates(this.TestingContext.AccessToken, requests); + List verifiedEstates = await this.TransactionProcessorSteps.WhenICreateTheFollowingEstatesX(this.TestingContext.AccessToken, requests); - foreach (EstateResponse verifiedEstate in verifiedEstates) + foreach (DataTransferObjects.Responses.Estate.EstateResponse verifiedEstate in verifiedEstates) { this.TestingContext.AddEstateDetails(verifiedEstate.EstateId, verifiedEstate.EstateName, verifiedEstate.EstateReference); this.TestingContext.Logger.LogInformation($"Estate {verifiedEstate.EstateName} created with Id {verifiedEstate.EstateId}"); @@ -154,11 +148,11 @@ public async Task GivenICreateTheFollowingApiScopes(DataTable table) [When(@"I assign the following operator to the merchants")] public async Task WhenIAssignTheFollowingOperatorToTheMerchants(DataTable table) { - List<(EstateDetails, Guid, EstateManagement.DataTransferObjects.Requests.Merchant.AssignOperatorRequest)> requests = table.Rows.ToAssignOperatorRequests(this.TestingContext.Estates); + List<(EstateDetails, Guid, DataTransferObjects.Requests.Merchant.AssignOperatorRequest)> requests = table.Rows.ToAssignOperatorRequests(this.TestingContext.Estates); - List<(EstateDetails, EstateManagement.DataTransferObjects.Responses.Merchant.MerchantOperatorResponse)> results = await this.EstateManagementSteps.WhenIAssignTheFollowingOperatorToTheMerchants(this.TestingContext.AccessToken, requests); + List<(EstateDetails, DataTransferObjects.Responses.Merchant.MerchantOperatorResponse)> results = await this.TransactionProcessorSteps.WhenIAssignTheFollowingOperatorToTheMerchants(this.TestingContext.AccessToken, requests); - foreach ((EstateDetails, MerchantOperatorResponse) result in results) + foreach ((EstateDetails, DataTransferObjects.Responses.Merchant.MerchantOperatorResponse) result in results) { this.TestingContext.Logger.LogInformation($"Operator {result.Item2.Name} assigned to Estate {result.Item1.EstateName}"); } @@ -170,11 +164,11 @@ public async Task WhenIAssignTheFollowingOperatorToTheMerchants(DataTable table) public async Task WhenICreateTheFollowingOperators(DataTable table) { - List<(EstateDetails estate, CreateOperatorRequest request)> requests = table.Rows.ToCreateOperatorRequests(this.TestingContext.Estates); + List<(EstateDetails estate, DataTransferObjects.Requests.Operator.CreateOperatorRequest request)> requests = table.Rows.ToCreateOperatorRequests(this.TestingContext.Estates); - List<(Guid, EstateOperatorResponse)> results = await this.EstateManagementSteps.WhenICreateTheFollowingOperators(this.TestingContext.AccessToken, requests); + List<(Guid, DataTransferObjects.Responses.Estate.EstateOperatorResponse)> results = await this.TransactionProcessorSteps.WhenICreateTheFollowingOperators(this.TestingContext.AccessToken, requests); - foreach ((Guid, EstateOperatorResponse) result in results) + foreach ((Guid, DataTransferObjects.Responses.Estate.EstateOperatorResponse) result in results) { this.TestingContext.Logger.LogInformation($"Operator {result.Item2.Name} created with Id {result.Item2.OperatorId} for Estate {result.Item1}"); } @@ -185,7 +179,7 @@ public async Task GivenIHaveAssignedTheFollowingOperatorsToTheEstates(DataTable { List<(EstateDetails estate, AssignOperatorRequest request)> requests = dataTable.Rows.ToAssignOperatorToEstateRequests(this.TestingContext.Estates); - await this.EstateManagementSteps.GivenIHaveAssignedTheFollowingOperatorsToTheEstates(this.TestingContext.AccessToken, requests); + await this.TransactionProcessorSteps.GivenIHaveAssignedTheFollowingOperatorsToTheEstates(this.TestingContext.AccessToken, requests); // TODO Verify } @@ -196,10 +190,10 @@ public async Task WhenICreateTheFollowingMerchants(DataTable table) { List<(EstateDetails estate, CreateMerchantRequest)> requests = table.Rows.ToCreateMerchantRequests(this.TestingContext.Estates); - List verifiedMerchants = await this.EstateManagementSteps.WhenICreateTheFollowingMerchants(this.TestingContext.AccessToken, requests); + List verifiedMerchants = await this.TransactionProcessorSteps.WhenICreateTheFollowingMerchants(this.TestingContext.AccessToken, requests); - foreach (EstateManagement.DataTransferObjects.Responses.Merchant.MerchantResponse verifiedMerchant in verifiedMerchants){ - await this.TransactionProcessorSteps.WhenICreateTheFollowingMerchants(this.TestingContext.AccessToken, verifiedMerchant.EstateId, verifiedMerchant.MerchantId); + foreach (DataTransferObjects.Responses.Merchant.MerchantResponse verifiedMerchant in verifiedMerchants){ + //await this.TransactionProcessorSteps.WhenICreateTheFollowingMerchants(this.TestingContext.AccessToken, verifiedMerchant.EstateId, verifiedMerchant.MerchantId); EstateDetails estateDetails = this.TestingContext.GetEstateDetails(verifiedMerchant.EstateId); estateDetails.AddMerchant(verifiedMerchant); @@ -220,7 +214,7 @@ public async Task GivenICreateAContractWithTheFollowingValues(DataTable table) { List<(EstateDetails, CreateContractRequest)> requests = table.Rows.ToCreateContractRequests(this.TestingContext.Estates); - List responses = await this.EstateManagementSteps.GivenICreateAContractWithTheFollowingValues(this.TestingContext.AccessToken, requests); + List responses = await this.TransactionProcessorSteps.GivenICreateAContractWithTheFollowingValues(this.TestingContext.AccessToken, requests); foreach (ContractResponse contractResponse in responses) { EstateDetails estate = this.TestingContext.Estates.Single(e => e.EstateId == contractResponse.EstateId); estate.AddContract(contractResponse.ContractId, contractResponse.Description, contractResponse.OperatorId); @@ -230,15 +224,15 @@ public async Task GivenICreateAContractWithTheFollowingValues(DataTable table) [When(@"I create the following Products")] public async Task WhenICreateTheFollowingProducts(DataTable table) { - List<(EstateDetails, EstateManagement.IntegrationTesting.Helpers.Contract, AddProductToContractRequest)> requests = table.Rows.ToAddProductToContractRequest(this.TestingContext.Estates); - await this.EstateManagementSteps.WhenICreateTheFollowingProducts(this.TestingContext.AccessToken, requests); + List<(EstateDetails, TransactionProcessor.IntegrationTesting.Helpers.Contract, AddProductToContractRequest)> requests = table.Rows.ToAddProductToContractRequest(this.TestingContext.Estates); + await this.TransactionProcessorSteps.WhenICreateTheFollowingProducts(this.TestingContext.AccessToken, requests); } [When(@"I add the following Transaction Fees")] public async Task WhenIAddTheFollowingTransactionFees(DataTable table) { - List<(EstateDetails, EstateManagement.IntegrationTesting.Helpers.Contract, EstateManagement.IntegrationTesting.Helpers.Product, AddTransactionFeeForProductToContractRequest)> requests = table.Rows.ToAddTransactionFeeForProductToContractRequests(this.TestingContext.Estates); - await this.EstateManagementSteps.WhenIAddTheFollowingTransactionFees(this.TestingContext.AccessToken, requests); + List<(EstateDetails, TransactionProcessor.IntegrationTesting.Helpers.Contract, TransactionProcessor.IntegrationTesting.Helpers.Product, AddTransactionFeeForProductToContractRequest)> requests = table.Rows.ToAddTransactionFeeForProductToContractRequests(this.TestingContext.Estates); + await this.TransactionProcessorSteps.WhenIAddTheFollowingTransactionFees(this.TestingContext.AccessToken, requests); } [Then(@"transaction response should contain the following information")] @@ -279,8 +273,8 @@ public async Task GivenIHaveAssignedTheFollowingDevicesToTheMerchants(DataTable List<(EstateDetails, Guid, AddMerchantDeviceRequest)> requests = table.Rows.ToAddMerchantDeviceRequests(this.TestingContext.Estates); - List<(EstateDetails, EstateManagement.DataTransferObjects.Responses.Merchant.MerchantResponse, String)> results = await this.EstateManagementSteps.GivenIHaveAssignedTheFollowingDevicesToTheMerchants(this.TestingContext.AccessToken, requests); - foreach ((EstateDetails, MerchantResponse, String) result in results) + List<(EstateDetails, DataTransferObjects.Responses.Merchant.MerchantResponse, String)> results = await this.TransactionProcessorSteps.GivenIHaveAssignedTheFollowingDevicesToTheMerchants(this.TestingContext.AccessToken, requests); + foreach ((EstateDetails, DataTransferObjects.Responses.Merchant.MerchantResponse, String) result in results) { this.TestingContext.Logger.LogInformation($"Device {result.Item3} assigned to Merchant {result.Item2.MerchantName} Estate {result.Item1.EstateName}"); } @@ -290,7 +284,7 @@ public async Task GivenIHaveAssignedTheFollowingDevicesToTheMerchants(DataTable public async Task WhenIAddTheFollowingContractsToTheFollowingMerchants(DataTable table) { List<(EstateDetails, Guid, Guid)> requests = table.Rows.ToAddContractToMerchantRequests(this.TestingContext.Estates); - await this.EstateManagementSteps.WhenIAddTheFollowingContractsToTheFollowingMerchants(this.TestingContext.AccessToken, requests); + await this.TransactionProcessorSteps.WhenIAddTheFollowingContractsToTheFollowingMerchants(this.TestingContext.AccessToken, requests); } private async Task GetMerchantBalance(Guid merchantId) @@ -310,7 +304,7 @@ public async Task GivenIMakeTheFollowingManualMerchantDeposits(DataTable table) { Decimal previousMerchantBalance = await this.GetMerchantBalance(request.Item2); - await this.EstateManagementSteps.GivenIMakeTheFollowingManualMerchantDeposits(this.TestingContext.AccessToken, request); + await this.TransactionProcessorSteps.GivenIMakeTheFollowingManualMerchantDeposits(this.TestingContext.AccessToken, request); await Retry.For(async () => { Decimal currentMerchantBalance = await this.GetMerchantBalance(request.Item2); @@ -349,5 +343,87 @@ await this.TransactionProcessorSteps.ThenTheFollowingEntriesAppearInTheMerchants endDate, balanceEntries); } + + [Given(@"the following security roles exist")] + public async Task GivenTheFollowingSecurityRolesExist(DataTable table) + { + List requests = table.Rows.ToCreateRoleRequests(); + List<(String, Guid)> responses = await this.SecurityServiceSteps.GivenICreateTheFollowingRoles(requests, CancellationToken.None); + } + + [Given(@"I have a token to access the estate management resource")] + [Given(@"I have a token to access the estate management and transaction processor resources")] + public async Task GivenIHaveATokenToAccessTheEstateManagementResource(DataTable table) + { + DataTableRow firstRow = table.Rows.First(); + String clientId = ReqnrollTableHelper.GetStringRowValue(firstRow, "ClientId"); + ClientDetails clientDetails = this.TestingContext.GetClientDetails(clientId); + + this.TestingContext.AccessToken = await this.SecurityServiceSteps.GetClientToken(clientDetails.ClientId, clientDetails.ClientSecret, CancellationToken.None); + } + + [When(@"I create the following security users")] + [Given("I have created the following security users")] + public async Task WhenICreateTheFollowingSecurityUsers(DataTable table) + { + List createUserRequests = table.Rows.ToCreateNewUserRequests(this.TestingContext.Estates); + await this.TransactionProcessorSteps.WhenICreateTheFollowingSecurityUsers(this.TestingContext.AccessToken, createUserRequests, this.TestingContext.Estates); + } + + [When(@"I get the estate ""(.*)"" the estate details are returned as follows")] + public async Task WhenIGetTheEstateTheEstateDetailsAreReturnedAsFollows(String estateName, + DataTable table) + { + List estateDetails = table.Rows.ToEstateDetails(); + + await this.TransactionProcessorSteps.WhenIGetTheEstateTheEstateDetailsAreReturnedAsFollows(this.TestingContext.AccessToken, estateName, this.TestingContext.Estates, estateDetails); + } + + [When(@"I get the estate ""(.*)"" the estate operator details are returned as follows")] + public async Task WhenIGetTheEstateTheEstateOperatorDetailsAreReturnedAsFollows(String estateName, + DataTable table) + { + List operators = table.Rows.ToOperatorDetails(); + await this.TransactionProcessorSteps.WhenIGetTheEstateTheEstateOperatorDetailsAreReturnedAsFollows(this.TestingContext.AccessToken, estateName, this.TestingContext.Estates, operators); + } + + [When(@"I get the estate ""(.*)"" the estate security user details are returned as follows")] + public async Task WhenIGetTheEstateTheEstateSecurityUserDetailsAreReturnedAsFollows(String estateName, + DataTable table) + { + + List securityUsers = table.Rows.ToSecurityUsersDetails(); + await this.TransactionProcessorSteps.WhenIGetTheEstateTheEstateSecurityUserDetailsAreReturnedAsFollows(this.TestingContext.AccessToken, estateName, this.TestingContext.Estates, securityUsers); + } + + [When(@"I get the estate ""(.*)"" an error is returned")] + public async Task WhenIGetTheEstateAnErrorIsReturned(String estateName) + { + await this.TransactionProcessorSteps.WhenIGetTheEstateAnErrorIsReturned(this.TestingContext.AccessToken, estateName, this.TestingContext.Estates); + } + + [Given(@"I am logged in as ""(.*)"" with password ""(.*)"" for Estate ""(.*)"" with client ""(.*)""")] + public async Task GivenIAmLoggedInAsWithPasswordForEstate(String username, + String password, + String estateName, + String clientId) + { + EstateDetails estateDetails = this.TestingContext.GetEstateDetails(estateName); + ClientDetails clientDetails = this.TestingContext.GetClientDetails(clientId); + + String tokenResponse = await this.SecurityServiceSteps + .GetPasswordToken(clientId, clientDetails.ClientSecret, username, password, CancellationToken.None).ConfigureAwait(false); + + estateDetails.SetEstateUserToken(tokenResponse); + } + + [When("I remove the operator {string} from estate {string} the operator is removed")] + public async Task WhenIRemoveTheOperatorFromEstateTheOperatorIsRemoved(string operatorName, string estateName) + { + await this.TransactionProcessorSteps.WhenIRemoveTheOperatorFromEstateTheOperatorIsRemoved(this.TestingContext.AccessToken, + this.TestingContext.Estates, + estateName, + operatorName); + } } } diff --git a/TransactionProcessor.IntegrationTests/TransactionProcessor.IntegrationTests.csproj b/TransactionProcessor.IntegrationTests/TransactionProcessor.IntegrationTests.csproj index a2ddd3a9..e4dfa1bf 100644 --- a/TransactionProcessor.IntegrationTests/TransactionProcessor.IntegrationTests.csproj +++ b/TransactionProcessor.IntegrationTests/TransactionProcessor.IntegrationTests.csproj @@ -10,7 +10,7 @@ - + diff --git a/TransactionProcessor.Models/Estate.cs b/TransactionProcessor.Models/Estate.cs new file mode 100644 index 00000000..e1bbaace --- /dev/null +++ b/TransactionProcessor.Models/Estate.cs @@ -0,0 +1,29 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; + +namespace TransactionProcessor.Models +{ + /// + /// + /// + [ExcludeFromCodeCoverage] + public class Estate + { + #region Properties + + public Int32 EstateReportingId { get; set; } + + public Guid EstateId { get; set; } + + public String Name { get; set; } + + public String Reference { get; set; } + + public List Operators { get; set; } + + public List SecurityUsers { get; set; } + + #endregion + } +} \ No newline at end of file diff --git a/TransactionProcessor.Models/Operator.cs b/TransactionProcessor.Models/Operator.cs new file mode 100644 index 00000000..e1cd7398 --- /dev/null +++ b/TransactionProcessor.Models/Operator.cs @@ -0,0 +1,23 @@ +using System; +using System.Diagnostics.CodeAnalysis; + +namespace TransactionProcessor.Models +{ + [ExcludeFromCodeCoverage] + public class EstateOperator + { + #region Properties + + /// + /// Gets the operator identifier. + /// + /// + /// The operator identifier. + /// + public Guid OperatorId { get; set; } + public Boolean IsDeleted { get; set; } + public String Name{ get; set; } + + #endregion + } +} diff --git a/TransactionProcessor.Models/SecurityUser.cs b/TransactionProcessor.Models/SecurityUser.cs new file mode 100644 index 00000000..d131f37d --- /dev/null +++ b/TransactionProcessor.Models/SecurityUser.cs @@ -0,0 +1,29 @@ +using System; +using System.Diagnostics.CodeAnalysis; + +namespace TransactionProcessor.Models +{ + [ExcludeFromCodeCoverage] + public class SecurityUser + { + #region Properties + + /// + /// Gets or sets the email address. + /// + /// + /// The email address. + /// + public String EmailAddress { get; set; } + + /// + /// Gets or sets the security user identifier. + /// + /// + /// The security user identifier. + /// + public Guid SecurityUserId { get; set; } + + #endregion + } +} \ No newline at end of file diff --git a/TransactionProcessor.ProjectionEngine/EventHandling/StateProjectionEventHandlers.cs b/TransactionProcessor.ProjectionEngine/EventHandling/StateProjectionEventHandlers.cs index 204f4db3..732d5ec2 100644 --- a/TransactionProcessor.ProjectionEngine/EventHandling/StateProjectionEventHandlers.cs +++ b/TransactionProcessor.ProjectionEngine/EventHandling/StateProjectionEventHandlers.cs @@ -1,6 +1,7 @@ using Shared.Exceptions; using Shared.Logger; using SimpleResults; +using TransactionProcessor.Estate.DomainEvents; namespace TransactionProcessor.ProjectionEngine.EventHandling; @@ -8,7 +9,6 @@ namespace TransactionProcessor.ProjectionEngine.EventHandling; using System.Diagnostics.CodeAnalysis; using Database; using Database.Database; -using EstateManagement.Estate.DomainEvents; using ProjectionHandler; using Shared.DomainDrivenDesign.EventSourcing; using Shared.EntityFramework; @@ -46,7 +46,7 @@ public async Task Handle(IDomainEvent domainEvent, Logger.LogWarning($"|{domainEvent.EventId}|State Projection Domain Event Handler - Inside Handle {domainEvent.EventType}"); Stopwatch sw = Stopwatch.StartNew(); - var result = await this.ProjectionHandler.Handle(domainEvent, cancellationToken); + Result result = await this.ProjectionHandler.Handle(domainEvent, cancellationToken); sw.Stop(); Logger.LogWarning($"|{domainEvent.EventId}|State Projection Event Handler - after Handle {domainEvent.EventType} time {sw.ElapsedMilliseconds}ms"); diff --git a/TransactionProcessor.ProjectionEngine/TransactionProcessor.ProjectionEngine.csproj b/TransactionProcessor.ProjectionEngine/TransactionProcessor.ProjectionEngine.csproj index a3e33552..7dc68925 100644 --- a/TransactionProcessor.ProjectionEngine/TransactionProcessor.ProjectionEngine.csproj +++ b/TransactionProcessor.ProjectionEngine/TransactionProcessor.ProjectionEngine.csproj @@ -7,7 +7,6 @@ - @@ -17,6 +16,7 @@ + diff --git a/TransactionProcessor.ReconciliationAggregate.Tests/TransactionProcessor.ReconciliationAggregate.Tests.csproj b/TransactionProcessor.ReconciliationAggregate.Tests/TransactionProcessor.ReconciliationAggregate.Tests.csproj deleted file mode 100644 index 9a817721..00000000 --- a/TransactionProcessor.ReconciliationAggregate.Tests/TransactionProcessor.ReconciliationAggregate.Tests.csproj +++ /dev/null @@ -1,31 +0,0 @@ - - - - net8.0 - None - false - - - - - - - - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - - - - - - - diff --git a/TransactionProcessor.ReconciliationAggregate/TransactionProcessor.ReconciliationAggregate.csproj b/TransactionProcessor.ReconciliationAggregate/TransactionProcessor.ReconciliationAggregate.csproj deleted file mode 100644 index 3b452a2b..00000000 --- a/TransactionProcessor.ReconciliationAggregate/TransactionProcessor.ReconciliationAggregate.csproj +++ /dev/null @@ -1,16 +0,0 @@ - - - - net8.0 - - - - - - - - - - - - diff --git a/TransactionProcessor.Repository/ITransactionProcessorReadModelRepository.cs b/TransactionProcessor.Repository/ITransactionProcessorReadModelRepository.cs new file mode 100644 index 00000000..47ede255 --- /dev/null +++ b/TransactionProcessor.Repository/ITransactionProcessorReadModelRepository.cs @@ -0,0 +1,891 @@ +using Shared.DomainDrivenDesign.EventSourcing; +using SimpleResults; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Shared.EntityFramework; +using Shared.Logger; +using TransactionProcessor.Database.Contexts; +using TransactionProcessor.Estate.DomainEvents; +using TransactionProcessor.Float.DomainEvents; +using TransactionProcessor.Reconciliation.DomainEvents; +using TransactionProcessor.Settlement.DomainEvents; +using TransactionProcessor.Transaction.DomainEvents; +using TransactionProcessor.Voucher.DomainEvents; +using TransactionProcessor.Database.Entities; +using Shared.Results; +using Microsoft.EntityFrameworkCore; +using System.Reflection; + +namespace TransactionProcessor.Repository { + public interface ITransactionProcessorReadModelRepository { + + //Task UpdateOperator(OperatorNameUpdatedEvent domainEvent, + // CancellationToken cancellationToken); + + //Task UpdateOperator(OperatorRequireCustomMerchantNumberChangedEvent domainEvent, + // CancellationToken cancellationToken); + + //Task UpdateOperator(OperatorRequireCustomTerminalNumberChangedEvent domainEvent, + // CancellationToken cancellationToken); + + //Task AddOperator(OperatorCreatedEvent domainEvent, + // CancellationToken cancellationToken); + + //Task AddContract(ContractCreatedEvent domainEvent, + // CancellationToken cancellationToken); + + //Task AddContractProduct(VariableValueProductAddedToContractEvent domainEvent, + // CancellationToken cancellationToken); + + //Task AddContractProduct(FixedValueProductAddedToContractEvent domainEvent, + // CancellationToken cancellationToken); + + //Task AddContractProductTransactionFee(TransactionFeeForProductAddedToContractEvent domainEvent, + // CancellationToken cancellationToken); + + //Task AddContractToMerchant(ContractAddedToMerchantEvent domainEvent, + // CancellationToken cancellationToken); + + Task AddEstate(EstateCreatedEvent domainEvent, + CancellationToken cancellationToken); + + Task AddEstateSecurityUser(SecurityUserAddedToEstateEvent domainEvent, + CancellationToken cancellationToken); + + //Task AddFile(FileCreatedEvent domainEvent, + // CancellationToken cancellationToken); + + //Task AddFileImportLog(ImportLogCreatedEvent domainEvent, + // CancellationToken cancellationToken); + + //Task AddFileLineToFile(FileLineAddedEvent domainEvent, + // CancellationToken cancellationToken); + + //Task AddFileToImportLog(FileAddedToImportLogEvent domainEvent, + // CancellationToken cancellationToken); + + //Task AddGeneratedVoucher(VoucherGeneratedEvent domainEvent, + // CancellationToken cancellationToken); + + //Task AddMerchant(MerchantCreatedEvent domainEvent, + // CancellationToken cancellationToken); + + //Task UpdateMerchant(MerchantNameUpdatedEvent domainEvent, + // CancellationToken cancellationToken); + + //Task AddMerchantAddress(AddressAddedEvent domainEvent, + // CancellationToken cancellationToken); + + //Task AddMerchantContact(ContactAddedEvent domainEvent, + // CancellationToken cancellationToken); + + //Task AddMerchantDevice(DeviceAddedToMerchantEvent domainEvent, + // CancellationToken cancellationToken); + + //Task SwapMerchantDevice(DeviceSwappedForMerchantEvent domainEvent, + // CancellationToken cancellationToken); + + //Task AddMerchantOperator(OperatorAssignedToMerchantEvent domainEvent, + // CancellationToken cancellationToken); + + //Task AddMerchantSecurityUser(SecurityUserAddedToMerchantEvent domainEvent, + // CancellationToken cancellationToken); + + //Task AddPendingMerchantFeeToSettlement(MerchantFeeAddedPendingSettlementEvent domainEvent, + // CancellationToken cancellationToken); + + Task AddProductDetailsToTransaction(ProductDetailsAddedToTransactionEvent domainEvent, + CancellationToken cancellationToken); + + //Task AddSettledFeeToStatement(SettledFeeAddedToStatementEvent domainEvent, + // CancellationToken cancellationToken); + + Task AddSettledMerchantFeeToSettlement(SettledMerchantFeeAddedToTransactionEvent domainEvent, + CancellationToken cancellationToken); + + Task AddSourceDetailsToTransaction(TransactionSourceAddedToTransactionEvent domainEvent, + CancellationToken cancellationToken); + + //Task AddTransactionToStatement(TransactionAddedToStatementEvent domainEvent, + // CancellationToken cancellationToken); + + Task CompleteReconciliation(ReconciliationHasCompletedEvent domainEvent, + CancellationToken cancellationToken); + + Task CompleteTransaction(TransactionHasBeenCompletedEvent domainEvent, + CancellationToken cancellationToken); + + Task CreateFloat(FloatCreatedForContractProductEvent domainEvent, + CancellationToken cancellationToken); + + Task CreateFloatActivity(FloatCreditPurchasedEvent domainEvent, + CancellationToken cancellationToken); + + Task CreateFloatActivity(FloatDecreasedByTransactionEvent domainEvent, + CancellationToken cancellationToken); + + Task CreateReadModel(EstateCreatedEvent domainEvent, + CancellationToken cancellationToken); + + Task CreateSettlement(SettlementCreatedForDateEvent domainEvent, + CancellationToken cancellationToken); + + //Task CreateStatement(StatementCreatedEvent domainEvent, + // CancellationToken cancellationToken); + + //Task DisableContractProductTransactionFee(TransactionFeeForProductDisabledEvent domainEvent, + // CancellationToken cancellationToken); + + Task MarkMerchantFeeAsSettled(MerchantFeeSettledEvent domainEvent, + CancellationToken cancellationToken); + + Task MarkSettlementAsCompleted(SettlementCompletedEvent domainEvent, + CancellationToken cancellationToken); + + Task MarkSettlementAsProcessingStarted(SettlementProcessingStartedEvent domainEvent, + CancellationToken cancellationToken); + + //Task MarkStatementAsGenerated(StatementGeneratedEvent domainEvent, + // CancellationToken cancellationToken); + + Task RecordTransactionAdditionalRequestData(AdditionalRequestDataRecordedEvent domainEvent, + CancellationToken cancellationToken); + + Task RecordTransactionAdditionalResponseData(AdditionalResponseDataRecordedEvent domainEvent, + CancellationToken cancellationToken); + + Task SetTransactionAmount(AdditionalRequestDataRecordedEvent domainEvent, + CancellationToken cancellationToken); + + Task StartReconciliation(ReconciliationHasStartedEvent domainEvent, + CancellationToken cancellationToken); + + Task StartTransaction(TransactionHasStartedEvent domainEvent, + CancellationToken cancellationToken); + + Task UpdateEstate(EstateReferenceAllocatedEvent domainEvent, + CancellationToken cancellationToken); + + //Task UpdateFileAsComplete(FileProcessingCompletedEvent domainEvent, + // CancellationToken cancellationToken); + + //Task UpdateFileLine(FileLineProcessingSuccessfulEvent domainEvent, + // CancellationToken cancellationToken); + + //Task UpdateFileLine(FileLineProcessingFailedEvent domainEvent, + // CancellationToken cancellationToken); + + //Task UpdateFileLine(FileLineProcessingIgnoredEvent domainEvent, + // CancellationToken cancellationToken); + + //Task UpdateMerchant(MerchantReferenceAllocatedEvent domainEvent, + // CancellationToken cancellationToken); + + //Task UpdateMerchant(StatementGeneratedEvent domainEvent, + // CancellationToken cancellationToken); + + //Task UpdateMerchant(SettlementScheduleChangedEvent domainEvent, + // CancellationToken cancellationToken); + + Task UpdateMerchant(TransactionHasBeenCompletedEvent domainEvent, + CancellationToken cancellationToken); + + Task UpdateReconciliationOverallTotals(OverallTotalsRecordedEvent domainEvent, + CancellationToken cancellationToken); + + Task UpdateReconciliationStatus(ReconciliationHasBeenLocallyAuthorisedEvent domainEvent, + CancellationToken cancellationToken); + + Task UpdateReconciliationStatus(ReconciliationHasBeenLocallyDeclinedEvent domainEvent, + CancellationToken cancellationToken); + + Task UpdateTransactionAuthorisation(TransactionHasBeenLocallyAuthorisedEvent domainEvent, + CancellationToken cancellationToken); + + Task UpdateTransactionAuthorisation(TransactionHasBeenLocallyDeclinedEvent domainEvent, + CancellationToken cancellationToken); + + Task UpdateTransactionAuthorisation(TransactionAuthorisedByOperatorEvent domainEvent, + CancellationToken cancellationToken); + + Task UpdateTransactionAuthorisation(TransactionDeclinedByOperatorEvent domainEvent, + CancellationToken cancellationToken); + + Task UpdateVoucherIssueDetails(VoucherIssuedEvent domainEvent, + CancellationToken cancellationToken); + + Task UpdateVoucherRedemptionDetails(VoucherFullyRedeemedEvent domainEvent, + CancellationToken cancellationToken); + + //Task RemoveOperatorFromMerchant(OperatorRemovedFromMerchantEvent domainEvent, + // CancellationToken cancellationToken); + + //Task RemoveContractFromMerchant(ContractRemovedFromMerchantEvent domainEvent, + // CancellationToken cancellationToken); + + //Task UpdateMerchantAddress(MerchantAddressLine1UpdatedEvent domainEvent, + // CancellationToken cancellationToken); + + //Task UpdateMerchantAddress(MerchantAddressLine2UpdatedEvent domainEvent, + // CancellationToken cancellationToken); + + //Task UpdateMerchantAddress(MerchantAddressLine3UpdatedEvent domainEvent, + // CancellationToken cancellationToken); + + //Task UpdateMerchantAddress(MerchantAddressLine4UpdatedEvent domainEvent, + // CancellationToken cancellationToken); + + //Task UpdateMerchantAddress(MerchantCountyUpdatedEvent domainEvent, + // CancellationToken cancellationToken); + + //Task UpdateMerchantAddress(MerchantRegionUpdatedEvent domainEvent, + // CancellationToken cancellationToken); + + //Task UpdateMerchantAddress(MerchantTownUpdatedEvent domainEvent, + // CancellationToken cancellationToken); + + //Task UpdateMerchantAddress(MerchantPostalCodeUpdatedEvent domainEvent, + // CancellationToken cancellationToken); + + //Task UpdateMerchantContact(MerchantContactNameUpdatedEvent domainEvent, + // CancellationToken cancellationToken); + + //Task UpdateMerchantContact(MerchantContactEmailAddressUpdatedEvent domainEvent, + // CancellationToken cancellationToken); + + //Task UpdateMerchantContact(MerchantContactPhoneNumberUpdatedEvent domainEvent, + // CancellationToken cancellationToken); + + Task> GetEstate(Guid estateId, + CancellationToken cancellationToken); + } + + public class TransactionProcessorReadModelRepository : ITransactionProcessorReadModelRepository { + private readonly Shared.EntityFramework.IDbContextFactory DbContextFactory; + + private const String ConnectionStringIdentifier = "EstateReportingReadModel"; + + public TransactionProcessorReadModelRepository(Shared.EntityFramework.IDbContextFactory dbContextFactory) { + this.DbContextFactory = dbContextFactory; + + } + + public async Task> GetEstate(Guid estateId, + CancellationToken cancellationToken) + { + EstateManagementGenericContext context = await this.DbContextFactory.GetContext(estateId, ConnectionStringIdentifier, cancellationToken); + + Database.Entities.Estate? estate = await context.Estates.SingleOrDefaultAsync(e => e.EstateId == estateId, cancellationToken); + + if (estate == null) + { + return Result.NotFound($"No estate found in read model with Id [{estateId}]"); + } + + List estateSecurityUsers = await context.EstateSecurityUsers.Where(esu => esu.EstateId == estate.EstateId).ToListAsync(cancellationToken); + List operators = await context.Operators.Where(eo => eo.EstateId == estate.EstateId).ToListAsync(cancellationToken); + + return Result.Success(ModelFactory.ConvertFrom(estate, estateSecurityUsers, operators)); + } + + private async Task GetContextFromDomainEvent(IDomainEvent domainEvent, CancellationToken cancellationToken) + { + Guid estateId = Database.Contexts.DomainEventHelper.GetEstateId(domainEvent); + if (estateId == Guid.Empty) + { + throw new Exception($"Unable to resolve context for Domain Event {domainEvent.GetType()}"); + } + + return await this.DbContextFactory.GetContext(estateId, ConnectionStringIdentifier, cancellationToken); + } + + public async Task AddEstate(EstateCreatedEvent domainEvent, + CancellationToken cancellationToken) { + EstateManagementGenericContext context = await this.GetContextFromDomainEvent(domainEvent, cancellationToken); + + // Add the estate to the read model + Database.Entities.Estate estate = new Database.Entities.Estate + { + EstateId = domainEvent.EstateId, + Name = domainEvent.EstateName, + Reference = String.Empty + }; + await context.Estates.AddAsync(estate, cancellationToken); + + return await context.SaveChangesAsync(cancellationToken); + } + + public async Task AddEstateSecurityUser(SecurityUserAddedToEstateEvent domainEvent, + CancellationToken cancellationToken) { + EstateManagementGenericContext context = await this.GetContextFromDomainEvent(domainEvent, cancellationToken); + + EstateSecurityUser estateSecurityUser = new EstateSecurityUser + { + EstateId = domainEvent.EstateId, + EmailAddress = domainEvent.EmailAddress, + SecurityUserId = domainEvent.SecurityUserId, + CreatedDateTime = domainEvent.EventTimestamp.DateTime + }; + + await context.EstateSecurityUsers.AddAsync(estateSecurityUser, cancellationToken); + + return await context.SaveChangesAsync(cancellationToken); + } + + public async Task AddProductDetailsToTransaction(ProductDetailsAddedToTransactionEvent domainEvent, + CancellationToken cancellationToken) { + EstateManagementGenericContext context = await this.GetContextFromDomainEvent(domainEvent, cancellationToken); + + var getTransactionResult = await context.LoadTransaction(domainEvent, cancellationToken); + if (getTransactionResult.IsFailed) + return ResultHelpers.CreateFailure(getTransactionResult); + var getContractResult = await context.LoadContract(domainEvent, cancellationToken); + if (getContractResult.IsFailed) + return ResultHelpers.CreateFailure(getContractResult); + + var transaction = getTransactionResult.Data; + var contract = getContractResult.Data; + + transaction.ContractId = domainEvent.ContractId; + transaction.ContractProductId = domainEvent.ProductId; + transaction.OperatorId = contract.OperatorId; + + return await context.SaveChangesAsync(cancellationToken); + } + + public async Task AddSettledMerchantFeeToSettlement(SettledMerchantFeeAddedToTransactionEvent domainEvent, + CancellationToken cancellationToken) { + EstateManagementGenericContext context = await this.GetContextFromDomainEvent(domainEvent, cancellationToken); + + MerchantSettlementFee merchantSettlementFee = new MerchantSettlementFee + { + SettlementId = domainEvent.SettlementId, + CalculatedValue = domainEvent.CalculatedValue, + FeeCalculatedDateTime = domainEvent.FeeCalculatedDateTime, + ContractProductTransactionFeeId = domainEvent.FeeId, + FeeValue = domainEvent.FeeValue, + IsSettled = true, + MerchantId = domainEvent.MerchantId, + TransactionId = domainEvent.TransactionId + }; + await context.MerchantSettlementFees.AddAsync(merchantSettlementFee, cancellationToken); + + return await context.SaveChangesWithDuplicateHandling(cancellationToken); + } + + public async Task AddSourceDetailsToTransaction(TransactionSourceAddedToTransactionEvent domainEvent, + CancellationToken cancellationToken) { + EstateManagementGenericContext context = await this.GetContextFromDomainEvent(domainEvent, cancellationToken); + + var getTransactionResult = await context.LoadTransaction(domainEvent, cancellationToken); + if (getTransactionResult.IsFailed) + return ResultHelpers.CreateFailure(getTransactionResult); + var transaction = getTransactionResult.Data; + + transaction.TransactionSource = domainEvent.TransactionSource; + + return await context.SaveChangesAsync(cancellationToken); + } + + public async Task CompleteReconciliation(ReconciliationHasCompletedEvent domainEvent, + CancellationToken cancellationToken) { + EstateManagementGenericContext context = await this.GetContextFromDomainEvent(domainEvent, cancellationToken); + + var getReconcilationResult = await context.LoadReconcilation(domainEvent, cancellationToken); + if (getReconcilationResult.IsFailed) + return ResultHelpers.CreateFailure(getReconcilationResult); + var reconciliation = getReconcilationResult.Data; + + reconciliation.IsCompleted = true; + + return await context.SaveChangesAsync(cancellationToken); + } + + public async Task CompleteTransaction(TransactionHasBeenCompletedEvent domainEvent, + CancellationToken cancellationToken) { + EstateManagementGenericContext context = await this.GetContextFromDomainEvent(domainEvent, cancellationToken); + + var getTransactionResult = await context.LoadTransaction(domainEvent, cancellationToken); + if (getTransactionResult.IsFailed) + return ResultHelpers.CreateFailure(getTransactionResult); + var transaction = getTransactionResult.Data; + + transaction.IsCompleted = true; + + return await context.SaveChangesAsync(cancellationToken); + } + + public async Task CreateFloat(FloatCreatedForContractProductEvent domainEvent, + CancellationToken cancellationToken) { + EstateManagementGenericContext context = await this.GetContextFromDomainEvent(domainEvent, cancellationToken); + + Database.Entities.Float floatRecord = new Database.Entities.Float + { + CreatedDate = domainEvent.CreatedDateTime.Date, + CreatedDateTime = domainEvent.CreatedDateTime, + ContractId = domainEvent.ContractId, + EstateId = domainEvent.EstateId, + FloatId = domainEvent.FloatId, + ProductId = domainEvent.ProductId + }; + await context.Floats.AddAsync(floatRecord, cancellationToken); + return await context.SaveChangesAsync(cancellationToken); + } + + public async Task CreateFloatActivity(FloatCreditPurchasedEvent domainEvent, + CancellationToken cancellationToken) { + EstateManagementGenericContext context = await this.GetContextFromDomainEvent(domainEvent, cancellationToken); + + FloatActivity floatActivity = new FloatActivity + { + ActivityDate = domainEvent.CreditPurchasedDateTime.Date, + ActivityDateTime = domainEvent.CreditPurchasedDateTime, + Amount = domainEvent.Amount, + CostPrice = domainEvent.CostPrice, + CreditOrDebit = "C", + EventId = domainEvent.EventId, + FloatId = domainEvent.FloatId + }; + await context.FloatActivity.AddAsync(floatActivity, cancellationToken); + return await context.SaveChangesAsync(cancellationToken); + } + + public async Task CreateFloatActivity(FloatDecreasedByTransactionEvent domainEvent, + CancellationToken cancellationToken) { + EstateManagementGenericContext context = await this.GetContextFromDomainEvent(domainEvent, cancellationToken); + + var getTransactionResult = await context.LoadTransaction(domainEvent, cancellationToken); + if (getTransactionResult.IsFailed) + return ResultHelpers.CreateFailure(getTransactionResult); + var transaction = getTransactionResult.Data; + + FloatActivity floatActivity = new FloatActivity + { + ActivityDate = transaction.TransactionDate, + ActivityDateTime = transaction.TransactionDateTime, + Amount = domainEvent.Amount, + CostPrice = 0, + CreditOrDebit = "D", + EventId = domainEvent.EventId, + FloatId = domainEvent.FloatId + }; + await context.FloatActivity.AddAsync(floatActivity, cancellationToken); + return await context.SaveChangesAsync(cancellationToken); + } + + public async Task CreateReadModel(EstateCreatedEvent domainEvent, + CancellationToken cancellationToken) { + EstateManagementGenericContext context = await this.GetContextFromDomainEvent(domainEvent, cancellationToken); + + Logger.LogInformation($"About to run migrations on Read Model database for estate [{domainEvent.EstateId}]"); + + // Ensure the db is at the latest version + await context.MigrateAsync(cancellationToken); + + Logger.LogWarning($"Read Model database for estate [{domainEvent.EstateId}] migrated to latest version"); + return Result.Success(); + } + + public async Task CreateSettlement(SettlementCreatedForDateEvent domainEvent, + CancellationToken cancellationToken) { + EstateManagementGenericContext context = await this.GetContextFromDomainEvent(domainEvent, cancellationToken); + + Database.Entities.Settlement settlement = new Database.Entities.Settlement + { + EstateId = domainEvent.EstateId, + MerchantId = domainEvent.MerchantId, + IsCompleted = false, + SettlementDate = domainEvent.SettlementDate.Date, + SettlementId = domainEvent.SettlementId + }; + + await context.Settlements.AddAsync(settlement, cancellationToken); + + return await context.SaveChangesAsync(cancellationToken); + } + + public async Task MarkMerchantFeeAsSettled(MerchantFeeSettledEvent domainEvent, + CancellationToken cancellationToken) { + EstateManagementGenericContext context = await this.GetContextFromDomainEvent(domainEvent, cancellationToken); + + // TODO: LoadMerchantSettlementFee + MerchantSettlementFee merchantFee = await context.MerchantSettlementFees.Where(m => + m.MerchantId == domainEvent.MerchantId && + m.TransactionId == domainEvent.TransactionId && + m.SettlementId == domainEvent.SettlementId && + m.ContractProductTransactionFeeId == domainEvent.FeeId) + .SingleOrDefaultAsync(cancellationToken); + + if (merchantFee == null) + { + return Result.NotFound("Merchant Fee not found to update as settled"); + } + + merchantFee.IsSettled = true; + return await context.SaveChangesAsync(cancellationToken); + } + + public async Task MarkSettlementAsCompleted(SettlementCompletedEvent domainEvent, + CancellationToken cancellationToken) { + EstateManagementGenericContext context = await this.GetContextFromDomainEvent(domainEvent, cancellationToken); + + var getSettlementResult = await context.LoadSettlement(domainEvent, cancellationToken); + if (getSettlementResult.IsFailed) + return ResultHelpers.CreateFailure(getSettlementResult); + var settlement = getSettlementResult.Data; + + settlement.IsCompleted = true; + return await context.SaveChangesAsync(cancellationToken); + } + + public async Task MarkSettlementAsProcessingStarted(SettlementProcessingStartedEvent domainEvent, + CancellationToken cancellationToken) { + EstateManagementGenericContext context = await this.GetContextFromDomainEvent(domainEvent, cancellationToken); + + var getSettlementResult = await context.LoadSettlement(domainEvent, cancellationToken); + if (getSettlementResult.IsFailed) + return ResultHelpers.CreateFailure(getSettlementResult); + var settlement = getSettlementResult.Data; + settlement.ProcessingStarted = true; + settlement.ProcessingStartedDateTIme = domainEvent.ProcessingStartedDateTime; + + return await context.SaveChangesAsync(cancellationToken); + } + + private readonly List AdditionalRequestFields = new List{ + "Amount", + "CustomerAccountNumber" + }; + + + private readonly List AdditionalResponseFields = new List(); + + public async Task RecordTransactionAdditionalRequestData(AdditionalRequestDataRecordedEvent domainEvent, + CancellationToken cancellationToken) { + EstateManagementGenericContext context = await this.GetContextFromDomainEvent(domainEvent, cancellationToken); + + TransactionAdditionalRequestData additionalRequestData = new TransactionAdditionalRequestData + { + TransactionId = domainEvent.TransactionId + }; + + foreach (String additionalRequestField in this.AdditionalRequestFields) + { + Logger.LogDebug($"Field to look for [{additionalRequestField}]"); + } + + foreach (KeyValuePair additionalRequestField in domainEvent.AdditionalTransactionRequestMetadata) + { + Logger.LogDebug($"Key: [{additionalRequestField.Key}] Value: [{additionalRequestField.Value}]"); + } + + foreach (String additionalRequestField in this.AdditionalRequestFields) + { + if (domainEvent.AdditionalTransactionRequestMetadata.Any(m => m.Key.ToLower() == additionalRequestField.ToLower())) + { + Type dbTableType = additionalRequestData.GetType(); + PropertyInfo propertyInfo = dbTableType.GetProperty(additionalRequestField); + + if (propertyInfo != null) + { + String value = domainEvent.AdditionalTransactionRequestMetadata.Single(m => m.Key.ToLower() == additionalRequestField.ToLower()).Value; + propertyInfo.SetValue(additionalRequestData, value); + } + else + { + Logger.LogInformation("propertyInfo == null"); + } + } + } + + await context.TransactionsAdditionalRequestData.AddAsync(additionalRequestData, cancellationToken); + + return await context.SaveChangesAsync(cancellationToken); + } + + public async Task RecordTransactionAdditionalResponseData(AdditionalResponseDataRecordedEvent domainEvent, + CancellationToken cancellationToken) { + EstateManagementGenericContext context = await this.GetContextFromDomainEvent(domainEvent, cancellationToken); + + TransactionAdditionalResponseData additionalResponseData = new TransactionAdditionalResponseData + { + TransactionId = domainEvent.TransactionId + }; + + foreach (String additionalResponseField in this.AdditionalResponseFields) + { + if (domainEvent.AdditionalTransactionResponseMetadata.Any(m => m.Key.ToLower() == additionalResponseField.ToLower())) + { + Type dbTableType = additionalResponseData.GetType(); + PropertyInfo propertyInfo = dbTableType.GetProperty(additionalResponseField); + + if (propertyInfo != null) + { + propertyInfo.SetValue(additionalResponseData, + domainEvent.AdditionalTransactionResponseMetadata.Single(m => m.Key.ToLower() == additionalResponseField.ToLower()).Value); + } + } + } + + await context.TransactionsAdditionalResponseData.AddAsync(additionalResponseData, cancellationToken); + + return await context.SaveChangesAsync(cancellationToken); + } + + public async Task SetTransactionAmount(AdditionalRequestDataRecordedEvent domainEvent, + CancellationToken cancellationToken) { + EstateManagementGenericContext context = await this.GetContextFromDomainEvent(domainEvent, cancellationToken); + + var getTransactionResult = await context.LoadTransaction(domainEvent, cancellationToken); + if (getTransactionResult.IsFailed) + return ResultHelpers.CreateFailure(getTransactionResult); + var transaction = getTransactionResult.Data; + + foreach (String additionalRequestField in this.AdditionalRequestFields) + { + if (domainEvent.AdditionalTransactionRequestMetadata.Any(m => m.Key.ToLower() == additionalRequestField.ToLower())) + { + if (additionalRequestField == "Amount") + { + String value = domainEvent.AdditionalTransactionRequestMetadata.Single(m => m.Key.ToLower() == additionalRequestField.ToLower()).Value; + // Load this value to the transaction as well + transaction.TransactionAmount = Decimal.Parse(value); + break; + } + } + } + + context.Transactions.Entry(transaction).State = EntityState.Modified; + return await context.SaveChangesAsync(cancellationToken); + } + + public async Task StartReconciliation(ReconciliationHasStartedEvent domainEvent, + CancellationToken cancellationToken) { + EstateManagementGenericContext context = await this.GetContextFromDomainEvent(domainEvent, cancellationToken); + + Database.Entities.Reconciliation reconciliation = new Database.Entities.Reconciliation + { + MerchantId = domainEvent.MerchantId, + TransactionDate = domainEvent.TransactionDateTime.Date, + TransactionDateTime = domainEvent.TransactionDateTime, + TransactionTime = domainEvent.TransactionDateTime.TimeOfDay, + TransactionId = domainEvent.TransactionId, + }; + + await context.Reconciliations.AddAsync(reconciliation, cancellationToken); + + return await context.SaveChangesAsync(cancellationToken); ; + } + + public async Task StartTransaction(TransactionHasStartedEvent domainEvent, + CancellationToken cancellationToken) { + EstateManagementGenericContext context = await this.GetContextFromDomainEvent(domainEvent, cancellationToken); + + Database.Entities.Transaction t = new Database.Entities.Transaction + { + MerchantId = domainEvent.MerchantId, + TransactionDate = domainEvent.TransactionDateTime.Date, + TransactionDateTime = domainEvent.TransactionDateTime, + TransactionTime = domainEvent.TransactionDateTime.TimeOfDay, + TransactionId = domainEvent.TransactionId, + TransactionNumber = domainEvent.TransactionNumber, + TransactionReference = domainEvent.TransactionReference, + TransactionType = domainEvent.TransactionType, + DeviceIdentifier = domainEvent.DeviceIdentifier + }; + + if (domainEvent.TransactionAmount.HasValue) + { + t.TransactionAmount = domainEvent.TransactionAmount.Value; + } + + await context.AddAsync(t, cancellationToken); + + Logger.LogDebug($"Transaction Loaded with Id [{domainEvent.TransactionId}]"); + return await context.SaveChangesAsync(cancellationToken); + } + + public async Task UpdateEstate(EstateReferenceAllocatedEvent domainEvent, + CancellationToken cancellationToken) { + EstateManagementGenericContext context = await this.GetContextFromDomainEvent(domainEvent, cancellationToken); + + var getEstateResult = await context.LoadEstate(domainEvent, cancellationToken); + if (getEstateResult.IsFailed) + return ResultHelpers.CreateFailure(getEstateResult); + + var estate = getEstateResult.Data; + estate.Reference = domainEvent.EstateReference; + + return await context.SaveChangesAsync(cancellationToken); + } + + public async Task UpdateMerchant(TransactionHasBeenCompletedEvent domainEvent, + CancellationToken cancellationToken) { + EstateManagementGenericContext context = await this.GetContextFromDomainEvent(domainEvent, cancellationToken); + + Result merchantResult = await context.LoadMerchant(domainEvent, cancellationToken); + if (merchantResult.IsFailed) + return ResultHelpers.CreateFailure(merchantResult); + var merchant = merchantResult.Data; + + if (domainEvent.CompletedDateTime > merchant.LastSaleDateTime) + { + merchant.LastSaleDate = domainEvent.CompletedDateTime.Date; + merchant.LastSaleDateTime = domainEvent.CompletedDateTime; + } + + return await context.SaveChangesAsync(cancellationToken); + } + + public async Task UpdateReconciliationOverallTotals(OverallTotalsRecordedEvent domainEvent, + CancellationToken cancellationToken) { + Guid estateId = domainEvent.EstateId; + + EstateManagementGenericContext context = await this.DbContextFactory.GetContext(estateId, ConnectionStringIdentifier, cancellationToken); + + var getReconcilationResult = await context.LoadReconcilation(domainEvent, cancellationToken); + if (getReconcilationResult.IsFailed) + return ResultHelpers.CreateFailure(getReconcilationResult); + var reconciliation = getReconcilationResult.Data; + + reconciliation.TransactionCount = domainEvent.TransactionCount; + reconciliation.TransactionValue = domainEvent.TransactionValue; + + return await context.SaveChangesAsync(cancellationToken); + } + + public async Task UpdateReconciliationStatus(ReconciliationHasBeenLocallyAuthorisedEvent domainEvent, + CancellationToken cancellationToken) { + EstateManagementGenericContext context = await this.GetContextFromDomainEvent(domainEvent, cancellationToken); + + var getReconcilationResult = await context.LoadReconcilation(domainEvent, cancellationToken); + if (getReconcilationResult.IsFailed) + return ResultHelpers.CreateFailure(getReconcilationResult); + var reconciliation = getReconcilationResult.Data; + + reconciliation.IsAuthorised = true; + reconciliation.ResponseCode = domainEvent.ResponseCode; + reconciliation.ResponseMessage = domainEvent.ResponseMessage; + + return await context.SaveChangesAsync(cancellationToken); + } + + public async Task UpdateReconciliationStatus(ReconciliationHasBeenLocallyDeclinedEvent domainEvent, + CancellationToken cancellationToken) { + EstateManagementGenericContext context = await this.GetContextFromDomainEvent(domainEvent, cancellationToken); + + var getReconcilationResult = await context.LoadReconcilation(domainEvent, cancellationToken); + if (getReconcilationResult.IsFailed) + return ResultHelpers.CreateFailure(getReconcilationResult); + var reconciliation = getReconcilationResult.Data; + + reconciliation.IsAuthorised = false; + reconciliation.ResponseCode = domainEvent.ResponseCode; + reconciliation.ResponseMessage = domainEvent.ResponseMessage; + + return await context.SaveChangesAsync(cancellationToken); + } + + public async Task UpdateTransactionAuthorisation(TransactionHasBeenLocallyAuthorisedEvent domainEvent, + CancellationToken cancellationToken) { + EstateManagementGenericContext context = await this.GetContextFromDomainEvent(domainEvent, cancellationToken); + + var getTransactionResult = await context.LoadTransaction(domainEvent, cancellationToken); + if (getTransactionResult.IsFailed) + return ResultHelpers.CreateFailure(getTransactionResult); + var transaction = getTransactionResult.Data; + + transaction.IsAuthorised = true; + transaction.ResponseCode = domainEvent.ResponseCode; + transaction.AuthorisationCode = domainEvent.AuthorisationCode; + transaction.ResponseMessage = domainEvent.ResponseMessage; + + return await context.SaveChangesAsync(cancellationToken); + } + + public async Task UpdateTransactionAuthorisation(TransactionHasBeenLocallyDeclinedEvent domainEvent, + CancellationToken cancellationToken) { + EstateManagementGenericContext context = await this.GetContextFromDomainEvent(domainEvent, cancellationToken); + + var getTransactionResult = await context.LoadTransaction(domainEvent, cancellationToken); + if (getTransactionResult.IsFailed) + return ResultHelpers.CreateFailure(getTransactionResult); + var transaction = getTransactionResult.Data; + + transaction.IsAuthorised = false; + transaction.ResponseCode = domainEvent.ResponseCode; + transaction.ResponseMessage = domainEvent.ResponseMessage; + + return await context.SaveChangesAsync(cancellationToken); + } + + public async Task UpdateTransactionAuthorisation(TransactionAuthorisedByOperatorEvent domainEvent, + CancellationToken cancellationToken) { + EstateManagementGenericContext context = await this.GetContextFromDomainEvent(domainEvent, cancellationToken); + + var getTransactionResult = await context.LoadTransaction(domainEvent, cancellationToken); + if (getTransactionResult.IsFailed) + return ResultHelpers.CreateFailure(getTransactionResult); + var transaction = getTransactionResult.Data; + + transaction.IsAuthorised = true; + transaction.ResponseCode = domainEvent.ResponseCode; + transaction.AuthorisationCode = domainEvent.AuthorisationCode; + transaction.ResponseMessage = domainEvent.ResponseMessage; + + return await context.SaveChangesAsync(cancellationToken); + } + + public async Task UpdateTransactionAuthorisation(TransactionDeclinedByOperatorEvent domainEvent, + CancellationToken cancellationToken) { + EstateManagementGenericContext context = await this.GetContextFromDomainEvent(domainEvent, cancellationToken); + + var getTransactionResult = await context.LoadTransaction(domainEvent, cancellationToken); + if (getTransactionResult.IsFailed) + return ResultHelpers.CreateFailure(getTransactionResult); + var transaction = getTransactionResult.Data; + + transaction.IsAuthorised = false; + transaction.ResponseCode = domainEvent.ResponseCode; + transaction.ResponseMessage = domainEvent.ResponseMessage; + + return await context.SaveChangesAsync(cancellationToken); ; + } + + public async Task UpdateVoucherIssueDetails(VoucherIssuedEvent domainEvent, + CancellationToken cancellationToken) { + EstateManagementGenericContext context = await this.GetContextFromDomainEvent(domainEvent, cancellationToken); + + var getVoucherResult = await context.LoadVoucher(domainEvent, cancellationToken); + if (getVoucherResult.IsFailed) + return ResultHelpers.CreateFailure(getVoucherResult); + var voucher = getVoucherResult.Data; + voucher.IsIssued = true; + voucher.RecipientEmail = domainEvent.RecipientEmail; + voucher.RecipientMobile = domainEvent.RecipientMobile; + voucher.IssuedDateTime = domainEvent.IssuedDateTime; + voucher.IssuedDate = domainEvent.IssuedDateTime.Date; + + return await context.SaveChangesAsync(cancellationToken); + } + + public async Task UpdateVoucherRedemptionDetails(VoucherFullyRedeemedEvent domainEvent, + CancellationToken cancellationToken) { + EstateManagementGenericContext context = await this.GetContextFromDomainEvent(domainEvent, cancellationToken); + + var getVoucherResult = await context.LoadVoucher(domainEvent, cancellationToken); + if (getVoucherResult.IsFailed) + return ResultHelpers.CreateFailure(getVoucherResult); + var voucher = getVoucherResult.Data; + + voucher.IsRedeemed = true; + voucher.RedeemedDateTime = domainEvent.RedeemedDateTime; + voucher.RedeemedDate = domainEvent.RedeemedDateTime.Date; + + return await context.SaveChangesAsync(cancellationToken); + } + } +} diff --git a/TransactionProcessor.Repository/ModelFactory.cs b/TransactionProcessor.Repository/ModelFactory.cs new file mode 100644 index 00000000..ea1a120c --- /dev/null +++ b/TransactionProcessor.Repository/ModelFactory.cs @@ -0,0 +1,50 @@ +using TransactionProcessor.Models; + +namespace TransactionProcessor.Repository +{ + using EstateModel = Models.Estate; + using EstateEntity = Database.Entities.Estate; + using EstateSecurityUserEntity = Database.Entities.EstateSecurityUser; + using EstateOperatorModel = Models.EstateOperator; + using SecurityUserModel = SecurityUser; + using OperatorEntity = Database.Entities.Operator; + + public static class ModelFactory + { + public static EstateModel ConvertFrom(EstateEntity estate, + List estateSecurityUsers, + List operators) + { + EstateModel estateModel = new EstateModel(); + estateModel.EstateId = estate.EstateId; + estateModel.EstateReportingId = estate.EstateReportingId; + estateModel.Name = estate.Name; + estateModel.Reference = estate.Reference; + + if (operators != null && operators.Any()) + { + estateModel.Operators = new List(); + foreach (OperatorEntity @operator in operators) + { + estateModel.Operators.Add(new EstateOperatorModel + { + OperatorId = @operator.OperatorId, + Name = @operator.Name + }); + } + } + + if (estateSecurityUsers != null && estateSecurityUsers.Any()) + { + estateModel.SecurityUsers = new List(); + estateSecurityUsers.ForEach(esu => estateModel.SecurityUsers.Add(new SecurityUserModel + { + SecurityUserId = esu.SecurityUserId, + EmailAddress = esu.EmailAddress + })); + } + + return estateModel; + } + } +} diff --git a/TransactionProcessor.Repository/TransactionProcessor.Repository.csproj b/TransactionProcessor.Repository/TransactionProcessor.Repository.csproj new file mode 100644 index 00000000..2b3ddb4b --- /dev/null +++ b/TransactionProcessor.Repository/TransactionProcessor.Repository.csproj @@ -0,0 +1,28 @@ + + + + net8.0 + enable + enable + + + + + + + + + + + + + + + + + + + + + + diff --git a/TransactionProcessor.SettlementAggregates.Tests/TransactionProcessor.SettlementAggregates.Tests.csproj b/TransactionProcessor.SettlementAggregates.Tests/TransactionProcessor.SettlementAggregates.Tests.csproj deleted file mode 100644 index 9d29a244..00000000 --- a/TransactionProcessor.SettlementAggregates.Tests/TransactionProcessor.SettlementAggregates.Tests.csproj +++ /dev/null @@ -1,30 +0,0 @@ - - - - net8.0 - None - false - - - - - - - - - - runtime; build; native; contentfiles; analyzers; buildtransitive - all - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - - - - - - - diff --git a/TransactionProcessor.SettlementAggregates/TransactionProcessor.SettlementAggregates.csproj b/TransactionProcessor.SettlementAggregates/TransactionProcessor.SettlementAggregates.csproj deleted file mode 100644 index dad338e3..00000000 --- a/TransactionProcessor.SettlementAggregates/TransactionProcessor.SettlementAggregates.csproj +++ /dev/null @@ -1,17 +0,0 @@ - - - - net8.0 - - - - - - - - - - - - - diff --git a/TransactionProcessor.Testing/TestData.cs b/TransactionProcessor.Testing/TestData.cs index 202bf5cf..1b6d3075 100644 --- a/TransactionProcessor.Testing/TestData.cs +++ b/TransactionProcessor.Testing/TestData.cs @@ -1,4 +1,7 @@ -namespace TransactionProcessor.Testing +using TransactionProcessor.Aggregates; +using TransactionProcessor.Database.Entities; + +namespace TransactionProcessor.Testing { using System; using System.Collections.Generic; @@ -11,20 +14,16 @@ using EstateManagement.DataTransferObjects.Responses.Merchant; using EstateManagement.DataTransferObjects.Responses.Contract; using EstateManagement.DataTransferObjects.Responses.Estate; - using FloatAggregate; using Models; using PataPawaPostPay; using ProjectionEngine.State; - using ReconciliationAggregate; using SecurityService.DataTransferObjects.Responses; - using SettlementAggregates; using Shared.DomainDrivenDesign.EventSourcing; using Transaction.DomainEvents; - using TransactionAggregate; using TransactionProcessor.Voucher.DomainEvents; - using VoucherAggregate; using CalculationType = Models.CalculationType; using FeeType = Models.FeeType; + using EstateManagement.DataTransferObjects.Requests.Estate; public class TestData { @@ -55,8 +54,7 @@ public class TestData public static String DeviceIdentifier1 = "1234567891"; - public static Guid EstateId = Guid.Parse("A522FA27-F9D0-470A-A88D-325DED3B62EE"); - + public static Guid EstateId = Guid.Parse("488AAFDE-D1DF-4CE0-A0F7-819E42C4885C"); public static Guid ContractId = Guid.Parse("97A9ED00-E522-428C-B3C3-5931092DBDCE"); public static Guid ContractId1 = Guid.Parse("9314DD8B-42A6-4C24-87FE-53CDC70BA48F"); @@ -77,12 +75,11 @@ public class TestData public static Guid OperatorId = Guid.Parse("804E9D8D-C6FE-4A46-9E55-6A04EA3E1AE5"); public static Guid OperatorId2 = Guid.Parse("C2A216E8-345F-4E45-B564-16821FFC524F"); - public static String CustomerEmailAddress = "testcustomer1@customer.co.uk"; - - //public static Guid OperatorIdentifier1 = Guid.Parse("590C07CF-500C-4F85-A5D4-A90A8021D0A1"); - - //public static String OperatorIdentifier2 = "NotSupported"; + public static String OperatorName = "Test Operator 1"; + public static String OperatorName2 = "Test Operator Name 2"; + public static String CustomerEmailAddress = "testcustomer1@customer.co.uk"; + public static Boolean RequireCustomMerchantNumber = true; public static Boolean RequireCustomTerminalNumber = true; @@ -1506,7 +1503,143 @@ public static VoucherAggregate GetVoucherAggregateWithRecipientMobile() return aggregate; } - + + public static String EstateReference = "C6634DE3"; + + public static Guid EstateSecurityUserId = Guid.Parse("CBEE25E6-1B08-4023-B20C-CFE0AD746808"); + public static String EstateUserEmailAddress = "testestateuser@estate1.co.uk"; + public static Guid SecurityUserId = Guid.Parse("45B74A2E-BF92-44E9-A300-08E5CDEACFE3"); + + public static CreateEstateRequest CreateEstateRequest => + new CreateEstateRequest + { + EstateId = TestData.EstateId, + EstateName = TestData.EstateName, + }; + public static CreateEstateUserRequest CreateEstateUserRequest => + new CreateEstateUserRequest + { + EmailAddress = TestData.EstateUserEmailAddress, + FamilyName = TestData.EstateUserFamilyName, + GivenName = TestData.EstateUserGivenName, + MiddleName = TestData.EstateUserMiddleName, + Password = TestData.EstateUserPassword + }; + + public static AssignOperatorRequest AssignOperatorRequestToEstate => + new() + { + OperatorId = TestData.OperatorId + }; + + public static String EstateUserFamilyName = "Estate"; + + public static String EstateUserGivenName = "Test"; + + public static String EstateUserMiddleName = "Middle"; + + public static String EstateUserPassword = "123456"; + + public static Models.Estate EstateModel => + new Models.Estate + { + EstateId = TestData.EstateId, + Name = TestData.EstateName, + Operators = null, + SecurityUsers = null + }; + + public static Models.Estate EstateModelWithOperators => + new Models.Estate + { + EstateId = TestData.EstateId, + Name = TestData.EstateName, + Operators = new List{ + new EstateOperator{ + OperatorId = TestData.OperatorId + } + }, + SecurityUsers = null + }; + + public static Models.Estate EstateModelWithOperatorsAndSecurityUsers => + new Models.Estate + { + EstateId = TestData.EstateId, + Name = TestData.EstateName, + Operators = new List{ + new EstateOperator{ + OperatorId = TestData.OperatorId + } + }, + SecurityUsers = new List{ + new SecurityUser{ + EmailAddress = TestData.EstateUserEmailAddress, + SecurityUserId = TestData.SecurityUserId + } + } + }; + + public static Models.Estate EstateModelWithSecurityUsers => + new Models.Estate + { + EstateId = TestData.EstateId, + Name = TestData.EstateName, + Operators = null, + SecurityUsers = new List{ + new SecurityUser{ + EmailAddress = TestData.EstateUserEmailAddress, + SecurityUserId = TestData.SecurityUserId + } + } + }; + #endregion + + public static class Commands { + public static EstateCommands.CreateEstateUserCommand CreateEstateUserCommand => new EstateCommands.CreateEstateUserCommand(TestData.EstateId, TestData.CreateEstateUserRequest); + public static EstateCommands.AddOperatorToEstateCommand AddOperatorToEstateCommand => new EstateCommands.AddOperatorToEstateCommand(TestData.EstateId, TestData.AssignOperatorRequestToEstate); + public static EstateCommands.CreateEstateCommand CreateEstateCommand => new EstateCommands.CreateEstateCommand(TestData.CreateEstateRequest); + public static EstateCommands.RemoveOperatorFromEstateCommand RemoveOperatorFromEstateCommand => new(TestData.EstateId, TestData.OperatorId); + } + + public static class Queries { + public static EstateQueries.GetEstateQuery GetEstateQuery => new(TestData.EstateId); + public static EstateQueries.GetEstatesQuery GetEstatesQuery => new(TestData.EstateId); + } + + public static class Aggregates { + public static EstateAggregate EmptyEstateAggregate = EstateAggregate.Create(TestData.EstateId); + + public static EstateAggregate CreatedEstateAggregate() { + EstateAggregate estateAggregate = EstateAggregate.Create(TestData.EstateId); + + estateAggregate.Create(TestData.EstateName); + + return estateAggregate; + } + + public static EstateAggregate EstateAggregateWithOperator() { + EstateAggregate estateAggregate = EstateAggregate.Create(TestData.EstateId); + + estateAggregate.Create(TestData.EstateName); + estateAggregate.AddOperator(TestData.OperatorId); + + return estateAggregate; + } + + public static EstateAggregate EstateAggregateWithOperatorDeleted() + { + EstateAggregate estateAggregate = EstateAggregate.Create(TestData.EstateId); + + estateAggregate.Create(TestData.EstateName); + estateAggregate.AddOperator(TestData.OperatorId); + estateAggregate.RemoveOperator(TestData.OperatorId); + + return estateAggregate; + } + } } + + } \ No newline at end of file diff --git a/TransactionProcessor.Testing/TransactionProcessor.Testing.csproj b/TransactionProcessor.Testing/TransactionProcessor.Testing.csproj index 1e52d91f..c09ed71e 100644 --- a/TransactionProcessor.Testing/TransactionProcessor.Testing.csproj +++ b/TransactionProcessor.Testing/TransactionProcessor.Testing.csproj @@ -13,7 +13,6 @@ - diff --git a/TransactionProcessor.Tests/Factories/ModelFactoryTests.cs b/TransactionProcessor.Tests/Factories/ModelFactoryTests.cs index d503609c..a72c890f 100644 --- a/TransactionProcessor.Tests/Factories/ModelFactoryTests.cs +++ b/TransactionProcessor.Tests/Factories/ModelFactoryTests.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Text; +using TransactionProcessor.Aggregates; namespace TransactionProcessor.Tests.Factories { @@ -9,7 +10,6 @@ namespace TransactionProcessor.Tests.Factories using Shouldly; using Testing; using TransactionProcessor.Factories; - using VoucherAggregate; using Xunit; using IssueVoucherResponse = Models.IssueVoucherResponse; using RedeemVoucherResponse = Models.RedeemVoucherResponse; @@ -21,9 +21,7 @@ public void ModelFactory_ProcessLogonTransactionResponseModel_IsConverted() { ProcessLogonTransactionResponse processLogonTransactionResponseModel = TestData.ProcessLogonTransactionResponseModel; - ModelFactory modelFactory = new ModelFactory(); - - SerialisedMessage logonTransactionResponse = modelFactory.ConvertFrom(processLogonTransactionResponseModel); + SerialisedMessage logonTransactionResponse = ModelFactory.ConvertFrom(processLogonTransactionResponseModel); logonTransactionResponse.ShouldNotBeNull(); logonTransactionResponse.Metadata.ShouldContainKey(MetadataContants.KeyNameEstateId); @@ -39,9 +37,7 @@ public void ModelFactory_ProcessLogonTransactionResponseModel_NullInput_IsConver { ProcessLogonTransactionResponse processLogonTransactionResponseModel = null; - ModelFactory modelFactory = new ModelFactory(); - - SerialisedMessage logonTransactionResponse = modelFactory.ConvertFrom(processLogonTransactionResponseModel); + SerialisedMessage logonTransactionResponse = ModelFactory.ConvertFrom(processLogonTransactionResponseModel); logonTransactionResponse.ShouldBeNull(); } @@ -51,9 +47,7 @@ public void ModelFactory_ProcessSaleTransactionResponseModel_IsConverted() { ProcessSaleTransactionResponse processSaleTransactionResponseModel = TestData.ProcessSaleTransactionResponseModel; - ModelFactory modelFactory = new ModelFactory(); - - SerialisedMessage saleTransactionResponse = modelFactory.ConvertFrom(processSaleTransactionResponseModel); + SerialisedMessage saleTransactionResponse = ModelFactory.ConvertFrom(processSaleTransactionResponseModel); saleTransactionResponse.ShouldNotBeNull(); saleTransactionResponse.Metadata.ShouldContainKey(MetadataContants.KeyNameEstateId); @@ -69,9 +63,7 @@ public void ModelFactory_ProcessSaleTransactionResponseModel_NullInput_IsConvert { ProcessSaleTransactionResponse processSaleTransactionResponseModel = null; - ModelFactory modelFactory = new ModelFactory(); - - SerialisedMessage saleTransactionResponse = modelFactory.ConvertFrom(processSaleTransactionResponseModel); + SerialisedMessage saleTransactionResponse = ModelFactory.ConvertFrom(processSaleTransactionResponseModel); saleTransactionResponse.ShouldBeNull(); } @@ -81,9 +73,7 @@ public void ModelFactory_ProcessReconciliationTransactionResponse_IsConverted() { ProcessReconciliationTransactionResponse processReconciliationTransactionResponseModel = TestData.ProcessReconciliationTransactionResponseModel; - ModelFactory modelFactory = new ModelFactory(); - - SerialisedMessage processReconciliationTransactionResponse = modelFactory.ConvertFrom(processReconciliationTransactionResponseModel); + SerialisedMessage processReconciliationTransactionResponse = ModelFactory.ConvertFrom(processReconciliationTransactionResponseModel); processReconciliationTransactionResponse.ShouldNotBeNull(); processReconciliationTransactionResponse.Metadata.ShouldContainKey(MetadataContants.KeyNameEstateId); @@ -98,10 +88,8 @@ public void ModelFactory_ProcessReconciliationTransactionResponse_IsConverted() public void ModelFactory_ProcessReconciliationTransactionResponse_NullInput_IsConverted() { ProcessReconciliationTransactionResponse processReconciliationTransactionResponseModel = null; - - ModelFactory modelFactory = new ModelFactory(); - - SerialisedMessage processReconciliationTransactionResponse = modelFactory.ConvertFrom(processReconciliationTransactionResponseModel); + + SerialisedMessage processReconciliationTransactionResponse = ModelFactory.ConvertFrom(processReconciliationTransactionResponseModel); processReconciliationTransactionResponse.ShouldBeNull(); } @@ -109,9 +97,8 @@ public void ModelFactory_ProcessReconciliationTransactionResponse_NullInput_IsCo [Fact] public void ModelFactory_ConvertFrom_IssueVoucherResponse_IsConverted() { - ModelFactory modelFactory = new ModelFactory(); IssueVoucherResponse model = TestData.IssueVoucherResponse; - DataTransferObjects.IssueVoucherResponse dto = modelFactory.ConvertFrom(model); + DataTransferObjects.IssueVoucherResponse dto = ModelFactory.ConvertFrom(model); dto.ShouldNotBeNull(); dto.ExpiryDate.ShouldBe(model.ExpiryDate); @@ -123,9 +110,8 @@ public void ModelFactory_ConvertFrom_IssueVoucherResponse_IsConverted() [Fact] public void ModelFactory_ConvertFrom_IssueVoucherResponse_NullInput_IsConverted() { - ModelFactory modelFactory = new ModelFactory(); IssueVoucherResponse model = null; - DataTransferObjects.IssueVoucherResponse dto = modelFactory.ConvertFrom(model); + DataTransferObjects.IssueVoucherResponse dto = ModelFactory.ConvertFrom(model); dto.ShouldBeNull(); } @@ -133,10 +119,9 @@ public void ModelFactory_ConvertFrom_IssueVoucherResponse_NullInput_IsConverted( [Fact] public void ModelFactory_ConvertFrom_VoucherModel_IsConverted() { - ModelFactory modelFactory = new ModelFactory(); Voucher model = TestData.GetVoucherAggregateWithRecipientMobile().GetVoucher(); - GetVoucherResponse dto = modelFactory.ConvertFrom(model); + GetVoucherResponse dto = ModelFactory.ConvertFrom(model); dto.ShouldNotBeNull(); dto.TransactionId.ShouldBe(model.TransactionId); dto.IssuedDateTime.ShouldBe(model.IssuedDateTime); @@ -156,9 +141,8 @@ public void ModelFactory_ConvertFrom_VoucherModel_IsConverted() [Fact] public void ModelFactory_ConvertFrom_VoucherModel_NullInput_IsConverted() { - ModelFactory modelFactory = new ModelFactory(); Voucher model = null; - GetVoucherResponse dto = modelFactory.ConvertFrom(model); + GetVoucherResponse dto = ModelFactory.ConvertFrom(model); dto.ShouldBeNull(); } @@ -166,9 +150,8 @@ public void ModelFactory_ConvertFrom_VoucherModel_NullInput_IsConverted() [Fact] public void ModelFactory_ConvertFrom_RedeemVoucherResponse_IsConverted() { - ModelFactory modelFactory = new ModelFactory(); RedeemVoucherResponse model = TestData.RedeemVoucherResponse; - DataTransferObjects.RedeemVoucherResponse dto = modelFactory.ConvertFrom(model); + DataTransferObjects.RedeemVoucherResponse dto = ModelFactory.ConvertFrom(model); dto.ShouldNotBeNull(); dto.ExpiryDate.ShouldBe(model.ExpiryDate); @@ -179,9 +162,8 @@ public void ModelFactory_ConvertFrom_RedeemVoucherResponse_IsConverted() [Fact] public void ModelFactory_ConvertFrom_RedeemVoucherResponse_NullInput_IsConverted() { - ModelFactory modelFactory = new ModelFactory(); RedeemVoucherResponse model = null; - DataTransferObjects.RedeemVoucherResponse dto = modelFactory.ConvertFrom(model); + DataTransferObjects.RedeemVoucherResponse dto = ModelFactory.ConvertFrom(model); dto.ShouldBeNull(); } diff --git a/TransactionProcessor.TransactionAggregate.Tests/TransactionProcessor.TransactionAggregate.Tests.csproj b/TransactionProcessor.TransactionAggregate.Tests/TransactionProcessor.TransactionAggregate.Tests.csproj deleted file mode 100644 index ceedf937..00000000 --- a/TransactionProcessor.TransactionAggregate.Tests/TransactionProcessor.TransactionAggregate.Tests.csproj +++ /dev/null @@ -1,30 +0,0 @@ - - - - net8.0 - None - false - - - - - - - - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - - - - - - diff --git a/TransactionProcessor.TransactionAgrgegate/TransactionProcessor.TransactionAggregate.csproj b/TransactionProcessor.TransactionAgrgegate/TransactionProcessor.TransactionAggregate.csproj deleted file mode 100644 index a1b15159..00000000 --- a/TransactionProcessor.TransactionAgrgegate/TransactionProcessor.TransactionAggregate.csproj +++ /dev/null @@ -1,17 +0,0 @@ - - - - net8.0 - - - - - - - - - - - - - diff --git a/TransactionProcessor.VoucherAggregate.Tests/TransactionProcessor.VoucherAggregate.Tests.csproj b/TransactionProcessor.VoucherAggregate.Tests/TransactionProcessor.VoucherAggregate.Tests.csproj deleted file mode 100644 index 60afdde5..00000000 --- a/TransactionProcessor.VoucherAggregate.Tests/TransactionProcessor.VoucherAggregate.Tests.csproj +++ /dev/null @@ -1,32 +0,0 @@ - - - - net8.0 - enable - enable - None - false - - - - - - - - - - runtime; build; native; contentfiles; analyzers; buildtransitive - all - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - - - - - - - diff --git a/TransactionProcessor.VoucherAggregate/TransactionProcessor.VoucherAggregate.csproj b/TransactionProcessor.VoucherAggregate/TransactionProcessor.VoucherAggregate.csproj deleted file mode 100644 index 7748cd2e..00000000 --- a/TransactionProcessor.VoucherAggregate/TransactionProcessor.VoucherAggregate.csproj +++ /dev/null @@ -1,19 +0,0 @@ - - - - net8.0 - enable - enable - - - - - - - - - - - - - diff --git a/TransactionProcessor.sln b/TransactionProcessor.sln index 871d8224..b7cd544b 100644 --- a/TransactionProcessor.sln +++ b/TransactionProcessor.sln @@ -21,26 +21,14 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TransactionProcessor.Testin EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TransactionProcessor.BusinessLogic.Tests", "TransactionProcessor.BusinessLogic.Tests\TransactionProcessor.BusinessLogic.Tests.csproj", "{8EAA1681-4095-473B-900B-C09FA823ACD7}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TransactionProcessor.TransactionAggregate", "TransactionProcessor.TransactionAgrgegate\TransactionProcessor.TransactionAggregate.csproj", "{BE2AF4BD-AED2-4723-AC25-3051C870CAC2}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TransactionProcessor.Transaction.DomainEvents", "TransactionProcessor.Transaction.DomainEvents\TransactionProcessor.Transaction.DomainEvents.csproj", "{AC0E260E-47CC-4DA7-BE62-0714F9266AEA}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TransactionProcessor.TransactionAggregate.Tests", "TransactionProcessor.TransactionAggregate.Tests\TransactionProcessor.TransactionAggregate.Tests.csproj", "{69BE1042-5AB9-420B-9A27-E2F1ADFC4E65}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TransactionProcessor.IntegrationTests", "TransactionProcessor.IntegrationTests\TransactionProcessor.IntegrationTests.csproj", "{3C40D27B-66B6-4C4A-839C-1E2BD7B4994C}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TransactionProcessor.Client", "TransactionProcessor.Client\TransactionProcessor.Client.csproj", "{DAF20F25-8BD1-4FA5-ADAD-71B068CDF393}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TransactionProcessor.ReconciliationAggregate", "TransactionProcessor.ReconciliationAggregate\TransactionProcessor.ReconciliationAggregate.csproj", "{74CA5F89-A99B-49AE-B690-376900DF488E}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TransactionProcessor.Reconciliation.DomainEvents", "TransactionProcessor.Reconciliation.DomainEvents\TransactionProcessor.Reconciliation.DomainEvents.csproj", "{E079DF81-BA19-4F71-85D6-AE36463F2B7F}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TransactionProcessor.ReconciliationAggregate.Tests", "TransactionProcessor.ReconciliationAggregate.Tests\TransactionProcessor.ReconciliationAggregate.Tests.csproj", "{E71A7E6D-B320-40A1-BF86-C2857B472313}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TransactionProcessor.SettlementAggregates", "TransactionProcessor.SettlementAggregates\TransactionProcessor.SettlementAggregates.csproj", "{2FF2AE7B-21F8-4EEF-9B47-3FCDAA39885B}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TransactionProcessor.SettlementAggregates.Tests", "TransactionProcessor.SettlementAggregates.Tests\TransactionProcessor.SettlementAggregates.Tests.csproj", "{1FF2753E-6F90-400D-9A98-E5FE3F79518E}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TransactionProcessor.Settlement.DomainEvents", "TransactionProcessor.Settlement.DomainEvents\TransactionProcessor.Settlement.DomainEvents.csproj", "{1D6CF3B6-41D3-46B8-BD6B-03FD32483763}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TransactionProcessor.ProjectionEngine", "TransactionProcessor.ProjectionEngine\TransactionProcessor.ProjectionEngine.csproj", "{6AE953A8-6400-456B-858A-454F78A28436}" @@ -49,19 +37,21 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TransactionProcessor.Projec EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TransactionProcessor.Voucher.DomainEvents", "TransactionProcessor.Voucher.DomainEvents\TransactionProcessor.Voucher.DomainEvents.csproj", "{185ABA5B-8917-44F3-8078-FB7246DE5E21}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TransactionProcessor.VoucherAggregate", "TransactionProcessor.VoucherAggregate\TransactionProcessor.VoucherAggregate.csproj", "{2491108E-FF42-4A01-A9AE-07DD6D710345}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TransactionProcessor.ProjectionEngine.Database", "TransactionProcessor.ProjectionEngine.Database\TransactionProcessor.ProjectionEngine.Database.csproj", "{410F1B15-7932-41E9-847E-0476EFCDB0F3}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TransactionProcessor.VoucherAggregate.Tests", "TransactionProcessor.VoucherAggregate.Tests\TransactionProcessor.VoucherAggregate.Tests.csproj", "{7A31BE33-D9CC-41C7-837E-72FC14333212}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TransactionProcessor.Float.DomainEvents", "TransactionProcessor.Float.DomainEvents\TransactionProcessor.Float.DomainEvents.csproj", "{6AE1D95B-4CBA-40F8-8414-3A2E15DFA729}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TransactionProcessor.ProjectionEngine.Database", "TransactionProcessor.ProjectionEngine.Database\TransactionProcessor.ProjectionEngine.Database.csproj", "{410F1B15-7932-41E9-847E-0476EFCDB0F3}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TransactionProcessor.IntegrationTesting.Helpers", "TransactionProcessor.IntegrationTesting.Helpers\TransactionProcessor.IntegrationTesting.Helpers.csproj", "{128605FE-2953-4FF5-8AE1-E2D83F6F8548}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TransactionProcessor.FloatAggregate", "TransactionProcessor.FloatAggregate\TransactionProcessor.FloatAggregate.csproj", "{9741A43E-B4EC-4EB7-B8E8-3820EF61977D}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TransactionProcessor.Aggregates", "TransactionProcessor.Aggregates\TransactionProcessor.Aggregates.csproj", "{7CA3DF65-5E3C-4839-A0DB-8A757F267CF5}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TransactionProcessor.Float.DomainEvents", "TransactionProcessor.Float.DomainEvents\TransactionProcessor.Float.DomainEvents.csproj", "{6AE1D95B-4CBA-40F8-8414-3A2E15DFA729}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TransactionProcessor.Estate.DomainEvents", "TransactionProcessor.Estate.DomainEvents\TransactionProcessor.Estate.DomainEvents.csproj", "{445B9ADB-86FA-4226-8EAF-F3A874BD96DF}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TransactionProcessor.FloatAggregate.Tests", "TransactionProcessor.FloatAggregate.Tests\TransactionProcessor.FloatAggregate.Tests.csproj", "{F486A766-A35D-4795-AC97-0A728AEFDBB9}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TransactionProcessor.Aggregates.Tests", "TransactionProcessor.Aggregates.Tests\TransactionProcessor.Aggregates.Tests.csproj", "{5A4FD1FE-2D82-4D9A-A498-8047F0E05E23}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TransactionProcessor.IntegrationTesting.Helpers", "TransactionProcessor.IntegrationTesting.Helpers\TransactionProcessor.IntegrationTesting.Helpers.csproj", "{128605FE-2953-4FF5-8AE1-E2D83F6F8548}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TransactionProcessor.Database", "TransactionProcessor.Database\TransactionProcessor.Database.csproj", "{812BE19F-0494-43C3-95CE-4684ECAC3CB3}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TransactionProcessor.Repository", "TransactionProcessor.Repository\TransactionProcessor.Repository.csproj", "{0696B63D-2807-40F9-BEEA-87D0415EC929}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -97,18 +87,10 @@ Global {8EAA1681-4095-473B-900B-C09FA823ACD7}.Debug|Any CPU.Build.0 = Debug|Any CPU {8EAA1681-4095-473B-900B-C09FA823ACD7}.Release|Any CPU.ActiveCfg = Release|Any CPU {8EAA1681-4095-473B-900B-C09FA823ACD7}.Release|Any CPU.Build.0 = Release|Any CPU - {BE2AF4BD-AED2-4723-AC25-3051C870CAC2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {BE2AF4BD-AED2-4723-AC25-3051C870CAC2}.Debug|Any CPU.Build.0 = Debug|Any CPU - {BE2AF4BD-AED2-4723-AC25-3051C870CAC2}.Release|Any CPU.ActiveCfg = Release|Any CPU - {BE2AF4BD-AED2-4723-AC25-3051C870CAC2}.Release|Any CPU.Build.0 = Release|Any CPU {AC0E260E-47CC-4DA7-BE62-0714F9266AEA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {AC0E260E-47CC-4DA7-BE62-0714F9266AEA}.Debug|Any CPU.Build.0 = Debug|Any CPU {AC0E260E-47CC-4DA7-BE62-0714F9266AEA}.Release|Any CPU.ActiveCfg = Release|Any CPU {AC0E260E-47CC-4DA7-BE62-0714F9266AEA}.Release|Any CPU.Build.0 = Release|Any CPU - {69BE1042-5AB9-420B-9A27-E2F1ADFC4E65}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {69BE1042-5AB9-420B-9A27-E2F1ADFC4E65}.Debug|Any CPU.Build.0 = Debug|Any CPU - {69BE1042-5AB9-420B-9A27-E2F1ADFC4E65}.Release|Any CPU.ActiveCfg = Release|Any CPU - {69BE1042-5AB9-420B-9A27-E2F1ADFC4E65}.Release|Any CPU.Build.0 = Release|Any CPU {3C40D27B-66B6-4C4A-839C-1E2BD7B4994C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {3C40D27B-66B6-4C4A-839C-1E2BD7B4994C}.Debug|Any CPU.Build.0 = Debug|Any CPU {3C40D27B-66B6-4C4A-839C-1E2BD7B4994C}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -117,26 +99,10 @@ Global {DAF20F25-8BD1-4FA5-ADAD-71B068CDF393}.Debug|Any CPU.Build.0 = Debug|Any CPU {DAF20F25-8BD1-4FA5-ADAD-71B068CDF393}.Release|Any CPU.ActiveCfg = Release|Any CPU {DAF20F25-8BD1-4FA5-ADAD-71B068CDF393}.Release|Any CPU.Build.0 = Release|Any CPU - {74CA5F89-A99B-49AE-B690-376900DF488E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {74CA5F89-A99B-49AE-B690-376900DF488E}.Debug|Any CPU.Build.0 = Debug|Any CPU - {74CA5F89-A99B-49AE-B690-376900DF488E}.Release|Any CPU.ActiveCfg = Release|Any CPU - {74CA5F89-A99B-49AE-B690-376900DF488E}.Release|Any CPU.Build.0 = Release|Any CPU {E079DF81-BA19-4F71-85D6-AE36463F2B7F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {E079DF81-BA19-4F71-85D6-AE36463F2B7F}.Debug|Any CPU.Build.0 = Debug|Any CPU {E079DF81-BA19-4F71-85D6-AE36463F2B7F}.Release|Any CPU.ActiveCfg = Release|Any CPU {E079DF81-BA19-4F71-85D6-AE36463F2B7F}.Release|Any CPU.Build.0 = Release|Any CPU - {E71A7E6D-B320-40A1-BF86-C2857B472313}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {E71A7E6D-B320-40A1-BF86-C2857B472313}.Debug|Any CPU.Build.0 = Debug|Any CPU - {E71A7E6D-B320-40A1-BF86-C2857B472313}.Release|Any CPU.ActiveCfg = Release|Any CPU - {E71A7E6D-B320-40A1-BF86-C2857B472313}.Release|Any CPU.Build.0 = Release|Any CPU - {2FF2AE7B-21F8-4EEF-9B47-3FCDAA39885B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {2FF2AE7B-21F8-4EEF-9B47-3FCDAA39885B}.Debug|Any CPU.Build.0 = Debug|Any CPU - {2FF2AE7B-21F8-4EEF-9B47-3FCDAA39885B}.Release|Any CPU.ActiveCfg = Release|Any CPU - {2FF2AE7B-21F8-4EEF-9B47-3FCDAA39885B}.Release|Any CPU.Build.0 = Release|Any CPU - {1FF2753E-6F90-400D-9A98-E5FE3F79518E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {1FF2753E-6F90-400D-9A98-E5FE3F79518E}.Debug|Any CPU.Build.0 = Debug|Any CPU - {1FF2753E-6F90-400D-9A98-E5FE3F79518E}.Release|Any CPU.ActiveCfg = Release|Any CPU - {1FF2753E-6F90-400D-9A98-E5FE3F79518E}.Release|Any CPU.Build.0 = Release|Any CPU {1D6CF3B6-41D3-46B8-BD6B-03FD32483763}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {1D6CF3B6-41D3-46B8-BD6B-03FD32483763}.Debug|Any CPU.Build.0 = Debug|Any CPU {1D6CF3B6-41D3-46B8-BD6B-03FD32483763}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -153,34 +119,38 @@ Global {185ABA5B-8917-44F3-8078-FB7246DE5E21}.Debug|Any CPU.Build.0 = Debug|Any CPU {185ABA5B-8917-44F3-8078-FB7246DE5E21}.Release|Any CPU.ActiveCfg = Release|Any CPU {185ABA5B-8917-44F3-8078-FB7246DE5E21}.Release|Any CPU.Build.0 = Release|Any CPU - {2491108E-FF42-4A01-A9AE-07DD6D710345}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {2491108E-FF42-4A01-A9AE-07DD6D710345}.Debug|Any CPU.Build.0 = Debug|Any CPU - {2491108E-FF42-4A01-A9AE-07DD6D710345}.Release|Any CPU.ActiveCfg = Release|Any CPU - {2491108E-FF42-4A01-A9AE-07DD6D710345}.Release|Any CPU.Build.0 = Release|Any CPU - {7A31BE33-D9CC-41C7-837E-72FC14333212}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {7A31BE33-D9CC-41C7-837E-72FC14333212}.Debug|Any CPU.Build.0 = Debug|Any CPU - {7A31BE33-D9CC-41C7-837E-72FC14333212}.Release|Any CPU.ActiveCfg = Release|Any CPU - {7A31BE33-D9CC-41C7-837E-72FC14333212}.Release|Any CPU.Build.0 = Release|Any CPU {410F1B15-7932-41E9-847E-0476EFCDB0F3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {410F1B15-7932-41E9-847E-0476EFCDB0F3}.Debug|Any CPU.Build.0 = Debug|Any CPU {410F1B15-7932-41E9-847E-0476EFCDB0F3}.Release|Any CPU.ActiveCfg = Release|Any CPU {410F1B15-7932-41E9-847E-0476EFCDB0F3}.Release|Any CPU.Build.0 = Release|Any CPU - {9741A43E-B4EC-4EB7-B8E8-3820EF61977D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {9741A43E-B4EC-4EB7-B8E8-3820EF61977D}.Debug|Any CPU.Build.0 = Debug|Any CPU - {9741A43E-B4EC-4EB7-B8E8-3820EF61977D}.Release|Any CPU.ActiveCfg = Release|Any CPU - {9741A43E-B4EC-4EB7-B8E8-3820EF61977D}.Release|Any CPU.Build.0 = Release|Any CPU {6AE1D95B-4CBA-40F8-8414-3A2E15DFA729}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {6AE1D95B-4CBA-40F8-8414-3A2E15DFA729}.Debug|Any CPU.Build.0 = Debug|Any CPU {6AE1D95B-4CBA-40F8-8414-3A2E15DFA729}.Release|Any CPU.ActiveCfg = Release|Any CPU {6AE1D95B-4CBA-40F8-8414-3A2E15DFA729}.Release|Any CPU.Build.0 = Release|Any CPU - {F486A766-A35D-4795-AC97-0A728AEFDBB9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {F486A766-A35D-4795-AC97-0A728AEFDBB9}.Debug|Any CPU.Build.0 = Debug|Any CPU - {F486A766-A35D-4795-AC97-0A728AEFDBB9}.Release|Any CPU.ActiveCfg = Release|Any CPU - {F486A766-A35D-4795-AC97-0A728AEFDBB9}.Release|Any CPU.Build.0 = Release|Any CPU {128605FE-2953-4FF5-8AE1-E2D83F6F8548}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {128605FE-2953-4FF5-8AE1-E2D83F6F8548}.Debug|Any CPU.Build.0 = Debug|Any CPU {128605FE-2953-4FF5-8AE1-E2D83F6F8548}.Release|Any CPU.ActiveCfg = Release|Any CPU {128605FE-2953-4FF5-8AE1-E2D83F6F8548}.Release|Any CPU.Build.0 = Release|Any CPU + {7CA3DF65-5E3C-4839-A0DB-8A757F267CF5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {7CA3DF65-5E3C-4839-A0DB-8A757F267CF5}.Debug|Any CPU.Build.0 = Debug|Any CPU + {7CA3DF65-5E3C-4839-A0DB-8A757F267CF5}.Release|Any CPU.ActiveCfg = Release|Any CPU + {7CA3DF65-5E3C-4839-A0DB-8A757F267CF5}.Release|Any CPU.Build.0 = Release|Any CPU + {445B9ADB-86FA-4226-8EAF-F3A874BD96DF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {445B9ADB-86FA-4226-8EAF-F3A874BD96DF}.Debug|Any CPU.Build.0 = Debug|Any CPU + {445B9ADB-86FA-4226-8EAF-F3A874BD96DF}.Release|Any CPU.ActiveCfg = Release|Any CPU + {445B9ADB-86FA-4226-8EAF-F3A874BD96DF}.Release|Any CPU.Build.0 = Release|Any CPU + {5A4FD1FE-2D82-4D9A-A498-8047F0E05E23}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {5A4FD1FE-2D82-4D9A-A498-8047F0E05E23}.Debug|Any CPU.Build.0 = Debug|Any CPU + {5A4FD1FE-2D82-4D9A-A498-8047F0E05E23}.Release|Any CPU.ActiveCfg = Release|Any CPU + {5A4FD1FE-2D82-4D9A-A498-8047F0E05E23}.Release|Any CPU.Build.0 = Release|Any CPU + {812BE19F-0494-43C3-95CE-4684ECAC3CB3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {812BE19F-0494-43C3-95CE-4684ECAC3CB3}.Debug|Any CPU.Build.0 = Debug|Any CPU + {812BE19F-0494-43C3-95CE-4684ECAC3CB3}.Release|Any CPU.ActiveCfg = Release|Any CPU + {812BE19F-0494-43C3-95CE-4684ECAC3CB3}.Release|Any CPU.Build.0 = Release|Any CPU + {0696B63D-2807-40F9-BEEA-87D0415EC929}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {0696B63D-2807-40F9-BEEA-87D0415EC929}.Debug|Any CPU.Build.0 = Debug|Any CPU + {0696B63D-2807-40F9-BEEA-87D0415EC929}.Release|Any CPU.ActiveCfg = Release|Any CPU + {0696B63D-2807-40F9-BEEA-87D0415EC929}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -193,27 +163,22 @@ Global {99D19D28-C5ED-409B-9A34-DCCBCD8A9532} = {71B30DC4-AB27-4D30-8481-B4C326D074CB} {7BDDFAA7-0391-4672-94F1-6817E55020FD} = {71B30DC4-AB27-4D30-8481-B4C326D074CB} {8EAA1681-4095-473B-900B-C09FA823ACD7} = {71B30DC4-AB27-4D30-8481-B4C326D074CB} - {BE2AF4BD-AED2-4723-AC25-3051C870CAC2} = {749ADE74-A6F0-4469-A638-8FD7E82A8667} {AC0E260E-47CC-4DA7-BE62-0714F9266AEA} = {749ADE74-A6F0-4469-A638-8FD7E82A8667} - {69BE1042-5AB9-420B-9A27-E2F1ADFC4E65} = {71B30DC4-AB27-4D30-8481-B4C326D074CB} {3C40D27B-66B6-4C4A-839C-1E2BD7B4994C} = {71B30DC4-AB27-4D30-8481-B4C326D074CB} {DAF20F25-8BD1-4FA5-ADAD-71B068CDF393} = {749ADE74-A6F0-4469-A638-8FD7E82A8667} - {74CA5F89-A99B-49AE-B690-376900DF488E} = {749ADE74-A6F0-4469-A638-8FD7E82A8667} {E079DF81-BA19-4F71-85D6-AE36463F2B7F} = {749ADE74-A6F0-4469-A638-8FD7E82A8667} - {E71A7E6D-B320-40A1-BF86-C2857B472313} = {71B30DC4-AB27-4D30-8481-B4C326D074CB} - {2FF2AE7B-21F8-4EEF-9B47-3FCDAA39885B} = {749ADE74-A6F0-4469-A638-8FD7E82A8667} - {1FF2753E-6F90-400D-9A98-E5FE3F79518E} = {71B30DC4-AB27-4D30-8481-B4C326D074CB} {1D6CF3B6-41D3-46B8-BD6B-03FD32483763} = {749ADE74-A6F0-4469-A638-8FD7E82A8667} {6AE953A8-6400-456B-858A-454F78A28436} = {749ADE74-A6F0-4469-A638-8FD7E82A8667} {7E770B14-0BF6-40B7-A36C-7AF403CE3C60} = {71B30DC4-AB27-4D30-8481-B4C326D074CB} {185ABA5B-8917-44F3-8078-FB7246DE5E21} = {749ADE74-A6F0-4469-A638-8FD7E82A8667} - {2491108E-FF42-4A01-A9AE-07DD6D710345} = {749ADE74-A6F0-4469-A638-8FD7E82A8667} - {7A31BE33-D9CC-41C7-837E-72FC14333212} = {71B30DC4-AB27-4D30-8481-B4C326D074CB} {410F1B15-7932-41E9-847E-0476EFCDB0F3} = {749ADE74-A6F0-4469-A638-8FD7E82A8667} - {9741A43E-B4EC-4EB7-B8E8-3820EF61977D} = {749ADE74-A6F0-4469-A638-8FD7E82A8667} {6AE1D95B-4CBA-40F8-8414-3A2E15DFA729} = {749ADE74-A6F0-4469-A638-8FD7E82A8667} - {F486A766-A35D-4795-AC97-0A728AEFDBB9} = {71B30DC4-AB27-4D30-8481-B4C326D074CB} {128605FE-2953-4FF5-8AE1-E2D83F6F8548} = {71B30DC4-AB27-4D30-8481-B4C326D074CB} + {7CA3DF65-5E3C-4839-A0DB-8A757F267CF5} = {749ADE74-A6F0-4469-A638-8FD7E82A8667} + {445B9ADB-86FA-4226-8EAF-F3A874BD96DF} = {749ADE74-A6F0-4469-A638-8FD7E82A8667} + {5A4FD1FE-2D82-4D9A-A498-8047F0E05E23} = {71B30DC4-AB27-4D30-8481-B4C326D074CB} + {812BE19F-0494-43C3-95CE-4684ECAC3CB3} = {749ADE74-A6F0-4469-A638-8FD7E82A8667} + {0696B63D-2807-40F9-BEEA-87D0415EC929} = {749ADE74-A6F0-4469-A638-8FD7E82A8667} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {193D13DE-424B-4D50-B674-01F9E4CC2CA9} diff --git a/TransactionProcessor/Bootstrapper/DomainEventHandlerRegistry.cs b/TransactionProcessor/Bootstrapper/DomainEventHandlerRegistry.cs index 94bb7f77..70a37b5c 100644 --- a/TransactionProcessor/Bootstrapper/DomainEventHandlerRegistry.cs +++ b/TransactionProcessor/Bootstrapper/DomainEventHandlerRegistry.cs @@ -75,6 +75,7 @@ public DomainEventHandlerRegistry() this.AddSingleton(); this.AddSingleton(); this.AddSingleton(); + this.AddSingleton(); this.AddSingleton>(); this.AddSingleton>(); diff --git a/TransactionProcessor/Bootstrapper/DomainServiceRegistry.cs b/TransactionProcessor/Bootstrapper/DomainServiceRegistry.cs index c322eb5c..31777be1 100644 --- a/TransactionProcessor/Bootstrapper/DomainServiceRegistry.cs +++ b/TransactionProcessor/Bootstrapper/DomainServiceRegistry.cs @@ -24,6 +24,7 @@ public DomainServiceRegistry() this.AddSingleton(); this.AddSingleton(); this.AddSingleton(); + this.AddSingleton(); } #endregion diff --git a/TransactionProcessor/Bootstrapper/MediatorRegistry.cs b/TransactionProcessor/Bootstrapper/MediatorRegistry.cs index 00e6fa09..eabbf54e 100644 --- a/TransactionProcessor/Bootstrapper/MediatorRegistry.cs +++ b/TransactionProcessor/Bootstrapper/MediatorRegistry.cs @@ -1,5 +1,6 @@ using System; using SimpleResults; +using TransactionProcessor.Aggregates; using TransactionProcessor.DataTransferObjects; using TransactionProcessor.ProjectionEngine.Models; @@ -14,7 +15,6 @@ namespace TransactionProcessor.Bootstrapper using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using TransactionProcessor.ProjectionEngine.State; - using TransactionProcessor.SettlementAggregates; /// /// @@ -33,34 +33,59 @@ public MediatorRegistry() this.AddTransient(); // request & notification handlers + this.RegisterMerchantRequestHandler(); + this.RegisterFloatRequestHandler(); + this.RegisterVoucherManagementRequestHandler(); + this.RegisterTransactionRequestHandler(); + this.RegisterSettlementRequestHandler(); + this.RegisterEstateRequestHandler(); + } - this.AddSingleton>, TransactionRequestHandler>(); - this.AddSingleton>, TransactionRequestHandler>(); - this.AddSingleton>, TransactionRequestHandler>(); - this.AddSingleton, TransactionRequestHandler>(); - this.AddSingleton, TransactionRequestHandler>(); - this.AddSingleton, TransactionRequestHandler>(); + #endregion - this.AddSingleton>, SettlementRequestHandler>(); - this.AddSingleton, SettlementRequestHandler>(); - this.AddSingleton, SettlementRequestHandler>(); - this.AddSingleton>, SettlementRequestHandler>(); + private void RegisterMerchantRequestHandler() { + this.AddSingleton>, MerchantRequestHandler>(); + this.AddSingleton>, MerchantRequestHandler>(); + this.AddSingleton>>, MerchantRequestHandler>(); + } + + private void RegisterFloatRequestHandler() { + this.AddSingleton, FloatRequestHandler>(); + this.AddSingleton, FloatRequestHandler>(); + this.AddSingleton, FloatRequestHandler>(); + this.AddSingleton, FloatRequestHandler>(); + } + private void RegisterVoucherManagementRequestHandler() { this.AddSingleton>, VoucherManagementRequestHandler>(); this.AddSingleton>, VoucherManagementRequestHandler>(); this.AddSingleton>, VoucherManagementRequestHandler>(); this.AddSingleton>, VoucherManagementRequestHandler>(); + } - this.AddSingleton, FloatRequestHandler>(); - this.AddSingleton, FloatRequestHandler>(); - this.AddSingleton, FloatRequestHandler>(); - this.AddSingleton, FloatRequestHandler>(); + private void RegisterEstateRequestHandler() { + this.AddSingleton, EstateRequestHandler>(); + this.AddSingleton, EstateRequestHandler>(); + this.AddSingleton, EstateRequestHandler>(); + this.AddSingleton, EstateRequestHandler>(); + this.AddSingleton>, EstateRequestHandler>(); + this.AddSingleton>>, EstateRequestHandler>(); + } - this.AddSingleton>, MerchantRequestHandler>(); - this.AddSingleton>, MerchantRequestHandler>(); - this.AddSingleton>>, MerchantRequestHandler>(); + private void RegisterSettlementRequestHandler() { + this.AddSingleton>, SettlementRequestHandler>(); + this.AddSingleton, SettlementRequestHandler>(); + this.AddSingleton, SettlementRequestHandler>(); + this.AddSingleton>, SettlementRequestHandler>(); } - #endregion + private void RegisterTransactionRequestHandler() { + this.AddSingleton>, TransactionRequestHandler>(); + this.AddSingleton>, TransactionRequestHandler>(); + this.AddSingleton>, TransactionRequestHandler>(); + this.AddSingleton, TransactionRequestHandler>(); + this.AddSingleton, TransactionRequestHandler>(); + this.AddSingleton, TransactionRequestHandler>(); + } } } \ No newline at end of file diff --git a/TransactionProcessor/Bootstrapper/MiscRegistry.cs b/TransactionProcessor/Bootstrapper/MiscRegistry.cs index 5788b83d..db8fd3fc 100644 --- a/TransactionProcessor/Bootstrapper/MiscRegistry.cs +++ b/TransactionProcessor/Bootstrapper/MiscRegistry.cs @@ -30,11 +30,11 @@ public class MiscRegistry : ServiceRegistry /// public MiscRegistry() { - this.AddSingleton(); this.AddSingleton(); this.AddSingleton(); this.AddSingleton(); this.AddSingleton(); + this.AddSingleton(); this.AddSingleton(); bool logRequests = ConfigurationReader.GetValueOrDefault("MiddlewareLogging", "LogRequests", true); diff --git a/TransactionProcessor/Bootstrapper/RepositoryRegistry.cs b/TransactionProcessor/Bootstrapper/RepositoryRegistry.cs index 2d30b9a8..8d4b8fb4 100644 --- a/TransactionProcessor/Bootstrapper/RepositoryRegistry.cs +++ b/TransactionProcessor/Bootstrapper/RepositoryRegistry.cs @@ -1,37 +1,27 @@ -using TransactionProcessor.FloatAggregate; +using TransactionProcessor.Aggregates; +using TransactionProcessor.Database.Contexts; +using TransactionProcessor.Repository; namespace TransactionProcessor.Bootstrapper { using System; using System.Data.Common; using System.Diagnostics.CodeAnalysis; - using System.Net.Http; - using System.Net.Security; using System.Threading.Tasks; using System.Threading; - using BusinessLogic.Services; using Lamar; using Microsoft.Data.SqlClient; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using MySqlConnector; - using ProjectionEngine; - using ProjectionEngine.Database; - using ProjectionEngine.Dispatchers; using ProjectionEngine.Projections; - using ReconciliationAggregate; - using SettlementAggregates; using Shared.DomainDrivenDesign.EventSourcing; using Shared.EntityFramework; using Shared.EntityFramework.ConnectionStringConfiguration; using Shared.EventStore.Aggregate; using Shared.EventStore.EventStore; - using Shared.EventStore.Extensions; using Shared.General; using Shared.Repositories; - using TransactionAggregate; - using ConnectionStringType = Shared.Repositories.ConnectionStringType; - using EstateManagement.Database.Contexts; using ProjectionEngine.Database.Database; using ProjectionEngine.Repository; using ProjectionEngine.State; @@ -81,14 +71,15 @@ public RepositoryRegistry() AggregateRepository>(); this.AddSingleton, AggregateRepository>(); - this.AddSingleton, AggregateRepository>(); - this.AddSingleton, AggregateRepository>(); + this.AddSingleton, AggregateRepository>(); + this.AddSingleton, AggregateRepository>(); this.AddSingleton, AggregateRepository>(); - - + this.AddSingleton, AggregateRepository>(); + this.AddSingleton, MerchantBalanceStateRepository>(); this.AddSingleton, VoucherStateRepository>(); this.AddSingleton(); + this.AddSingleton(); this.AddSingleton, MerchantBalanceProjection>(); this.AddSingleton, DbContextFactory>(); diff --git a/TransactionProcessor/Controllers/ContractController.cs b/TransactionProcessor/Controllers/ContractController.cs new file mode 100644 index 00000000..42be03f4 --- /dev/null +++ b/TransactionProcessor/Controllers/ContractController.cs @@ -0,0 +1,467 @@ +using MediatR; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using Shared.General; +using SimpleResults; +using Swashbuckle.AspNetCore.Annotations; +using Swashbuckle.AspNetCore.Filters; +using System.Collections.Generic; +using System.Security.Claims; +using System.Threading.Tasks; +using System.Threading; +using System; +using EstateManagement.Client; +using SecurityService.Client; +using SecurityService.DataTransferObjects.Responses; +using Shared.Results; +using TransactionProcessor.BusinessLogic.Common; +using TransactionProcessor.DataTransferObjects.Responses.Contract; +using TransactionProcessor.Factories; +using ContractProduct = TransactionProcessor.DataTransferObjects.Responses.Contract.ContractProduct; +using ContractProductTransactionFee = TransactionProcessor.DataTransferObjects.Responses.Contract.ContractProductTransactionFee; +using ContractResponse = EstateManagement.DataTransferObjects.Responses.Contract.ContractResponse; +using ProductType = TransactionProcessor.DataTransferObjects.Responses.Contract.ProductType; +using Azure; +using TransactionProcessor.DataTransferObjects.Requests.Contract; +using EstateManagement.DataTransferObjects.Requests.Contract; +using AddProductToContractRequest = TransactionProcessor.DataTransferObjects.Requests.Contract.AddProductToContractRequest; +using AddTransactionFeeForProductToContractRequest = TransactionProcessor.DataTransferObjects.Requests.Contract.AddTransactionFeeForProductToContractRequest; +using CreateContractRequest = TransactionProcessor.DataTransferObjects.Requests.Contract.CreateContractRequest; +using Microsoft.AspNetCore.Authorization; +using System.Diagnostics.CodeAnalysis; +using EstateManagement.DataTransferObjects.Responses.Operator; +using TransactionProcessor.BusinessLogic.Manager; +using TransactionProcessor.BusinessLogic.Requests; +using TransactionProcessor.Database.Entities; +using TransactionProcessor.DataTransferObjects.Requests.Operator; +using Microsoft.CodeAnalysis.Editing; + +namespace TransactionProcessor.Controllers { + [ExcludeFromCodeCoverage] + [Route(ControllerRoute)] + [ApiController] + [Authorize] + public class ContractController : ControllerBase { + private readonly IEstateClient EstateClient; + private readonly ISecurityServiceClient SecurityServiceClient; + + private ClaimsPrincipal UserOverride; + private TokenResponse TokenResponse; + + internal void SetContextOverride(HttpContext ctx) { + UserOverride = ctx.User; + } + + #region Constructors + + public ContractController(IEstateClient estateClient, + ISecurityServiceClient securityServiceClient) { + this.EstateClient = estateClient; + this.SecurityServiceClient = securityServiceClient; + } + + #endregion + + internal ClaimsPrincipal GetUser() { + return UserOverride switch { + null => HttpContext.User, + _ => UserOverride + }; + } + + #region Methods + + private Result StandardSecurityChecks(Guid estateId) { + // Get the Estate Id claim from the user + Claim estateIdClaim = ClaimsHelper.GetUserClaim(GetUser(), "EstateId", estateId.ToString()); + + string estateRoleName = Environment.GetEnvironmentVariable("EstateRoleName"); + if (ClaimsHelper.IsUserRolesValid(GetUser(), new[] { string.IsNullOrEmpty(estateRoleName) ? "Estate" : estateRoleName }) == false) { + return Result.Forbidden("User role is not valid"); + } + + if (ClaimsHelper.ValidateRouteParameter(estateId, estateIdClaim) == false) { + return Result.Forbidden("User estate id claim is not valid"); + } + + return Result.Success(); + } + + /// + /// Gets the contract. + /// + /// The estate identifier. + /// The contract identifier. + /// if set to true [include products]. + /// if set to true [include products with fees]. + /// The cancellation token. + /// + [HttpGet] + [Route("{contractId}")] + public async Task GetContract([FromRoute] Guid estateId, + [FromRoute] Guid contractId, + CancellationToken cancellationToken) { + Result securityChecksResult = StandardSecurityChecks(estateId); + if (securityChecksResult.IsFailed) + return securityChecksResult.ToActionResultX(); + + this.TokenResponse = await Helpers.GetToken(this.TokenResponse, this.SecurityServiceClient, cancellationToken); + + Result contractResponse = await this.EstateClient.GetContract(this.TokenResponse.AccessToken, estateId, contractId, cancellationToken); + if (contractResponse.IsFailed) { + var x = contractResponse.ToActionResultX(); + return x; + } + + DataTransferObjects.Responses.Contract.ContractResponse response = ConvertContract(contractResponse.Data); + + var result = Result.Success(response); + + return result.ToActionResultX(); + } + + private TransactionProcessor.DataTransferObjects.Responses.Contract.ContractResponse ConvertContract(ContractResponse contractResponse) { + TransactionProcessor.DataTransferObjects.Responses.Contract.ContractResponse response = new() { + ContractId = contractResponse.ContractId, + ContractReportingId = contractResponse.ContractReportingId, + Description = contractResponse.Description, + EstateId = contractResponse.EstateId, + EstateReportingId = contractResponse.EstateReportingId, + OperatorId = contractResponse.OperatorId, + OperatorName = contractResponse.OperatorName, + Products = new List() + }; + if (contractResponse.Products != null) { + foreach (EstateManagement.DataTransferObjects.Responses.Contract.ContractProduct contractProduct in contractResponse.Products) { + var product = new ContractProduct { + Name = contractProduct.Name, + ProductId = contractProduct.ProductId, + DisplayText = contractProduct.DisplayText, + ProductReportingId = contractProduct.ProductReportingId, + ProductType = (ProductType)contractProduct.ProductType, + Value = contractProduct.Value, + TransactionFees = new List() + }; + + if (contractProduct.TransactionFees != null) { + foreach (EstateManagement.DataTransferObjects.Responses.Contract.ContractProductTransactionFee contractProductTransactionFee in contractProduct.TransactionFees) { + var transactionFee = new ContractProductTransactionFee { + Description = contractProductTransactionFee.Description, + FeeType = (FeeType)contractProductTransactionFee.FeeType, + TransactionFeeId = contractProductTransactionFee.TransactionFeeId, + Value = contractProductTransactionFee.Value, + CalculationType = (CalculationType)contractProductTransactionFee.CalculationType, + TransactionFeeReportingId = contractProductTransactionFee.TransactionFeeReportingId + }; + product.TransactionFees.Add(transactionFee); + } + } + + response.Products.Add(product); + } + } + + return response; + } + + + /// + /// Gets the contracts. + /// + /// The estate identifier. + /// The cancellation token. + /// + [HttpGet] + [Route("")] + public async Task GetContracts([FromRoute] Guid estateId, + CancellationToken cancellationToken) { + Result securityChecksResult = StandardSecurityChecks(estateId); + if (securityChecksResult.IsFailed) + return securityChecksResult.ToActionResultX(); + + this.TokenResponse = await Helpers.GetToken(this.TokenResponse, this.SecurityServiceClient, cancellationToken); + + var contractsResponse = await this.EstateClient.GetContracts(this.TokenResponse.AccessToken, estateId, cancellationToken); + if (contractsResponse.IsFailed) { + var x = contractsResponse.ToActionResultX(); + return x; + } + + List responses = new(); + foreach (ContractResponse contractResponse in contractsResponse.Data) { + var response = ConvertContract(contractResponse); + responses.Add(response); + } + + var result = Result.Success(responses); + + return result.ToActionResultX(); + + } + + /// + /// Adds the product to contract. + /// + /// The estate identifier. + /// The contract identifier. + /// The add product to contract request. + /// The cancellation token. + /// + [HttpPatch] + [Route("{contractId}/products")] + public async Task AddProductToContract([FromRoute] Guid estateId, + [FromRoute] Guid contractId, + [FromBody] AddProductToContractRequest addProductToContractRequest, + CancellationToken cancellationToken) { + Result securityChecksResult = StandardSecurityChecks(estateId); + if (securityChecksResult.IsFailed) + return securityChecksResult.ToActionResultX(); + + Guid productId = Guid.NewGuid(); + + this.TokenResponse = await Helpers.GetToken(this.TokenResponse, this.SecurityServiceClient, cancellationToken); + + var estateClientRequest = new EstateManagement.DataTransferObjects.Requests.Contract.AddProductToContractRequest() { ProductType = (EstateManagement.DataTransferObjects.Responses.Contract.ProductType)addProductToContractRequest.ProductType, DisplayText = addProductToContractRequest.DisplayText, Value = addProductToContractRequest.Value, ProductName = addProductToContractRequest.ProductName }; + + var result = await this.EstateClient.AddProductToContract(this.TokenResponse.AccessToken, estateId, contractId, estateClientRequest, cancellationToken); + return result.ToActionResultX(); + } + + + /// + /// Adds the transaction fee for product to contract. + /// + /// The estate identifier. + /// The contract identifier. + /// The product identifier. + /// The add transaction fee for product to contract request. + /// The cancellation token. + /// + [HttpPatch] + [Route("{contractId}/products/{productId}/transactionFees")] + public async Task AddTransactionFeeForProductToContract([FromRoute] Guid estateId, + [FromRoute] Guid contractId, + [FromRoute] Guid productId, + [FromBody] AddTransactionFeeForProductToContractRequest addTransactionFeeForProductToContractRequest, + CancellationToken cancellationToken) { + Result securityChecksResult = StandardSecurityChecks(estateId); + if (securityChecksResult.IsFailed) + return securityChecksResult.ToActionResultX(); + this.TokenResponse = await Helpers.GetToken(this.TokenResponse, this.SecurityServiceClient, cancellationToken); + var estateClientRequest = new EstateManagement.DataTransferObjects.Requests.Contract.AddTransactionFeeForProductToContractRequest() { Value = addTransactionFeeForProductToContractRequest.Value, CalculationType = (EstateManagement.DataTransferObjects.Responses.Contract.CalculationType)addTransactionFeeForProductToContractRequest.CalculationType, FeeType = (EstateManagement.DataTransferObjects.Responses.Contract.FeeType)addTransactionFeeForProductToContractRequest.FeeType, Description = addTransactionFeeForProductToContractRequest.Description }; + var result = await this.EstateClient.AddTransactionFeeForProductToContract(this.TokenResponse.AccessToken, estateId, contractId, productId, estateClientRequest, cancellationToken); + return result.ToActionResultX(); + } + + /// + /// Disables the transaction fee for product. + /// + /// The estate identifier. + /// The contract identifier. + /// The product identifier. + /// The transaction fee identifier. + /// The cancellation token. + /// + [HttpDelete] + [Route("{contractId}/products/{productId}/transactionFees/{transactionFeeId}")] + public async Task DisableTransactionFeeForProduct([FromRoute] Guid estateId, + [FromRoute] Guid contractId, + [FromRoute] Guid productId, + [FromRoute] Guid transactionFeeId, + CancellationToken cancellationToken) { + Result securityChecksResult = StandardSecurityChecks(estateId); + if (securityChecksResult.IsFailed) + return securityChecksResult.ToActionResultX(); + this.TokenResponse = await Helpers.GetToken(this.TokenResponse, this.SecurityServiceClient, cancellationToken); + // Route the command + Result result = await this.EstateClient.DisableTransactionFeeForProduct(this.TokenResponse.AccessToken, estateId, contractId, productId, transactionFeeId, cancellationToken); + + // return the result + return result.ToActionResultX(); + } + + + /// + /// Creates the contract. + /// + /// The estate identifier. + /// The create contract request. + /// The cancellation token. + /// + [HttpPost] + [Route("")] + public async Task CreateContract([FromRoute] Guid estateId, + [FromBody] CreateContractRequest createContractRequest, + CancellationToken cancellationToken) { + Result securityChecksResult = StandardSecurityChecks(estateId); + if (securityChecksResult.IsFailed) + return securityChecksResult.ToActionResultX(); + this.TokenResponse = await Helpers.GetToken(this.TokenResponse, this.SecurityServiceClient, cancellationToken); + EstateManagement.DataTransferObjects.Requests.Contract.CreateContractRequest estateClientRequest = new EstateManagement.DataTransferObjects.Requests.Contract.CreateContractRequest() { Description = createContractRequest.Description, OperatorId = createContractRequest.OperatorId, }; + + Result result = await this.EstateClient.CreateContract(this.TokenResponse.AccessToken, estateId, estateClientRequest, cancellationToken); + + // return the result + return result.ToActionResultX(); + } + + #endregion + + #region Others + + /// + /// The controller name + /// + public const string ControllerName = "contracts"; + + /// + /// The controller route + /// + private const string ControllerRoute = "api/estates/{estateid}/" + ControllerName; + + #endregion + } + + [ExcludeFromCodeCoverage] + [Route(ControllerRoute)] + [ApiController] + public class OperatorController : ControllerBase + { + private readonly IEstateClient EstateClient; + private readonly ISecurityServiceClient SecurityServiceClient; + + /// + /// The mediator + /// + private readonly IMediator Mediator; + + /// + /// Initializes a new instance of the class. + /// + /// The mediator. + public OperatorController(IEstateClient estateClient, ISecurityServiceClient securityServiceClient) { + this.EstateClient = estateClient; + this.SecurityServiceClient = securityServiceClient; + } + private TokenResponse TokenResponse; + private ClaimsPrincipal UserOverride; + internal void SetContextOverride(HttpContext ctx) + { + UserOverride = ctx.User; + } + + internal ClaimsPrincipal GetUser() + { + return UserOverride switch + { + null => HttpContext.User, + _ => UserOverride + }; + } + + /// + /// Creates the operator. + /// + /// The estate identifier. + /// The create operator request. + /// The cancellation token. + /// + [HttpPost] + [Route("")] + public async Task CreateOperator([FromRoute] Guid estateId, [FromBody] CreateOperatorRequest createOperatorRequest, CancellationToken cancellationToken) + { + this.TokenResponse = await Helpers.GetToken(this.TokenResponse, this.SecurityServiceClient, cancellationToken); + + var estateClientRequest = new EstateManagement.DataTransferObjects.Requests.Operator.CreateOperatorRequest() { + Name = createOperatorRequest.Name, + OperatorId = createOperatorRequest.OperatorId, + RequireCustomMerchantNumber = createOperatorRequest.RequireCustomMerchantNumber, + RequireCustomTerminalNumber = createOperatorRequest.RequireCustomTerminalNumber + }; + + var result = await this.EstateClient.CreateOperator(this.TokenResponse.AccessToken, estateId, estateClientRequest, cancellationToken); + + // return the result + return result.ToActionResultX(); + } + + [HttpPost] + [Route("{operatorId}")] + [SwaggerResponse(200, "OK")] + public async Task UpdateOperator([FromRoute] Guid estateId, [FromRoute] Guid operatorId, [FromBody] UpdateOperatorRequest updateOperatorRequest, CancellationToken cancellationToken) + { + this.TokenResponse = await Helpers.GetToken(this.TokenResponse, this.SecurityServiceClient, cancellationToken); + + var estateClientRequest = new EstateManagement.DataTransferObjects.Requests.Operator.UpdateOperatorRequest() + { + Name = updateOperatorRequest.Name, + RequireCustomMerchantNumber = updateOperatorRequest.RequireCustomMerchantNumber, + RequireCustomTerminalNumber = updateOperatorRequest.RequireCustomTerminalNumber + }; + + var result = await this.EstateClient.UpdateOperator(this.TokenResponse.AccessToken, estateId, operatorId, estateClientRequest, cancellationToken); + + // return the result + return result.ToActionResultX(); + } + + + [HttpGet] + [Route("{operatorId}")] + public async Task GetOperator([FromRoute] Guid estateId, + [FromRoute] Guid operatorId, + CancellationToken cancellationToken) + { + this.TokenResponse = await Helpers.GetToken(this.TokenResponse, this.SecurityServiceClient, cancellationToken); + + var result = await this.EstateClient.GetOperator(this.TokenResponse.AccessToken, estateId, operatorId, cancellationToken); + + if (result.IsFailed) + { + return result.ToActionResultX(); + } + + DataTransferObjects.Responses.Operator.OperatorResponse response = new() { OperatorId = result.Data.OperatorId, Name = result.Data.Name, RequireCustomMerchantNumber = result.Data.RequireCustomMerchantNumber, RequireCustomTerminalNumber = result.Data.RequireCustomTerminalNumber }; + + return Result.Success(response).ToActionResultX(); + } + + [HttpGet] + [Route("")] + public async Task GetOperators([FromRoute] Guid estateId, + CancellationToken cancellationToken) + { + this.TokenResponse = await Helpers.GetToken(this.TokenResponse, this.SecurityServiceClient, cancellationToken); + + var result = await this.EstateClient.GetOperators(this.TokenResponse.AccessToken, estateId, cancellationToken); + + if (result.IsFailed) + { + return result.ToActionResultX(); + } + + List responses = new(); + foreach (OperatorResponse operatorResponse in result.Data) { + + + responses.Add(new() { OperatorId = operatorResponse.OperatorId, Name = operatorResponse.Name, RequireCustomMerchantNumber = operatorResponse.RequireCustomMerchantNumber, RequireCustomTerminalNumber = operatorResponse.RequireCustomTerminalNumber }); + } + + return Result.Success(responses).ToActionResultX(); + } + + #region Others + + /// + /// The controller name + /// + public const string ControllerName = "operators"; + + /// + /// The controller route + /// + private const string ControllerRoute = "api/estates/{estateid}/" + ControllerName; + + #endregion + } +} diff --git a/TransactionProcessor/Controllers/EstateController.cs b/TransactionProcessor/Controllers/EstateController.cs new file mode 100644 index 00000000..6fe5321f --- /dev/null +++ b/TransactionProcessor/Controllers/EstateController.cs @@ -0,0 +1,243 @@ +using EstateManagement.DataTransferObjects.Requests.Estate; +using EstateManagement.DataTransferObjects.Responses.Estate; +using MediatR; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using Shared.Exceptions; +using Shared.General; +using SimpleResults; +using Swashbuckle.AspNetCore.Annotations; +using Swashbuckle.AspNetCore.Filters; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Security.Claims; +using System.Threading.Tasks; +using System.Threading; +using System; +using Shared.Results; +using TransactionProcessor.BusinessLogic.Requests; +using TransactionProcessor.Factories; + +namespace TransactionProcessor.Controllers +{ + [ExcludeFromCodeCoverage] + [Route(ControllerRoute)] + [ApiController] + [Authorize] + public class EstateController : ControllerBase + { + #region Fields + + /// + /// The mediator + /// + private readonly IMediator Mediator; + + #endregion + + #region Constructors + + public EstateController(IMediator mediator) + { + Mediator = mediator; + } + + private ClaimsPrincipal UserOverride; + internal void SetContextOverride(HttpContext ctx) + { + UserOverride = ctx.User; + } + + internal ClaimsPrincipal GetUser() + { + return UserOverride switch + { + null => HttpContext.User, + _ => UserOverride + }; + } + + #endregion + + #region Methods + + /// + /// Creates the estate. + /// + /// The create estate request. + /// The cancellation token. + /// + [HttpPost] + [Route("")] + public async Task CreateEstate([FromBody] CreateEstateRequest createEstateRequest, + CancellationToken cancellationToken) + { + // Reject password tokens + if (ClaimsHelper.IsPasswordToken(GetUser())) + { + return Forbid(); + } + + // Create the command + EstateCommands.CreateEstateCommand command = new(createEstateRequest); + + // Route the command + Result result = await Mediator.Send(command, cancellationToken); + + return result.ToActionResultX(); + } + + /// + /// Gets the estate. + /// + /// The estate identifier. + /// The cancellation token. + /// + /// Estate not found with estate Id {estateId} + [HttpGet] + [Route("{estateId}")] + public async Task GetEstate([FromRoute] Guid estateId, + CancellationToken cancellationToken) + { + // Get the Estate Id claim from the user + Claim estateIdClaim = ClaimsHelper.GetUserClaim(GetUser(), "EstateId", estateId.ToString()); + + string estateRoleName = Environment.GetEnvironmentVariable("EstateRoleName"); + if (ClaimsHelper.IsUserRolesValid(GetUser(), new[] { string.IsNullOrEmpty(estateRoleName) ? "Estate" : estateRoleName }) == false) + { + return Forbid(); + } + + if (ClaimsHelper.ValidateRouteParameter(estateId, estateIdClaim) == false) + { + return Forbid(); + } + + EstateQueries.GetEstateQuery query = new(estateId); + + Result result = await Mediator.Send(query, cancellationToken); + if (result.IsFailed) + { + return result.ToActionResultX(); + } + + return ModelFactory.ConvertFrom(result.Data).ToActionResultX(); + } + + [HttpGet] + [Route("{estateId}/all")] + public async Task GetEstates([FromRoute] Guid estateId, + CancellationToken cancellationToken) + { + // Get the Estate Id claim from the user + Claim estateIdClaim = ClaimsHelper.GetUserClaim(GetUser(), "EstateId", estateId.ToString()); + + string estateRoleName = Environment.GetEnvironmentVariable("EstateRoleName"); + if (ClaimsHelper.IsUserRolesValid(GetUser(), new[] { string.IsNullOrEmpty(estateRoleName) ? "Estate" : estateRoleName }) == false) + { + return Forbid(); + } + + if (ClaimsHelper.ValidateRouteParameter(estateId, estateIdClaim) == false) + { + return Forbid(); + } + + EstateQueries.GetEstatesQuery query = new(estateId); + + Result> result = await Mediator.Send(query, cancellationToken); + if (result.IsFailed) + { + return result.ToActionResultX(); + } + + return ModelFactory.ConvertFrom(result.Data).ToActionResultX(); + } + + /// + /// Creates the estate user. + /// + /// The estate identifier. + /// The create estate user request. + /// The cancellation token./// + [HttpPatch] + [Route("{estateId}/users")] + public async Task CreateEstateUser([FromRoute] Guid estateId, + [FromBody] CreateEstateUserRequest createEstateUserRequest, + CancellationToken cancellationToken) + { + // Reject password tokens + if (ClaimsHelper.IsPasswordToken(GetUser())) + { + return Forbid(); + } + + // Create the command + EstateCommands.CreateEstateUserCommand command = new(estateId, createEstateUserRequest); + + // Route the command + Result result = await Mediator.Send(command, cancellationToken); + + // return the result + return result.ToActionResultX(); + } + + [HttpPatch] + [Route("{estateId}/operators")] + public async Task AssignOperator([FromRoute] Guid estateId, [FromBody] AssignOperatorRequest assignOperatorRequest, CancellationToken cancellationToken) + { + // Reject password tokens + if (ClaimsHelper.IsPasswordToken(GetUser())) + { + return Forbid(); + } + + // Create the command + EstateCommands.AddOperatorToEstateCommand command = new(estateId, assignOperatorRequest); + + // Route the command + Result result = await Mediator.Send(command, cancellationToken); + + // return the result + return result.ToActionResultX(); + } + + [HttpDelete] + [Route("{estateId}/operators/{operatorId}")] + public async Task RemoveOperator([FromRoute] Guid estateId, + [FromRoute] Guid operatorId, + CancellationToken cancellationToken) + { + // Reject password tokens + if (ClaimsHelper.IsPasswordToken(GetUser())) + { + return Forbid(); + } + + EstateCommands.RemoveOperatorFromEstateCommand command = new(estateId, operatorId); + + // Route the command + Result result = await Mediator.Send(command, cancellationToken); + + // return the result + return result.ToActionResultX(); + } + + #endregion + + #region Others + + /// + /// The controller name + /// + public const string ControllerName = "estates"; + + /// + /// The controller route + /// + private const string ControllerRoute = "api/" + ControllerName; + + #endregion + } +} diff --git a/TransactionProcessor/Controllers/MerchantController.cs b/TransactionProcessor/Controllers/MerchantController.cs index 77759718..43161e98 100644 --- a/TransactionProcessor/Controllers/MerchantController.cs +++ b/TransactionProcessor/Controllers/MerchantController.cs @@ -1,8 +1,20 @@ -using MediatR; +using EstateManagement.Client; +using EstateManagement.DataTransferObjects.Responses.Contract; +using EstateManagement.DataTransferObjects.Responses.Merchant; +using MediatR; using Microsoft.CodeAnalysis.Elfie.Diagnostics; +using SecurityService.Client; +using SecurityService.DataTransferObjects.Responses; using Shared.Results; using SimpleResults; +using TransactionProcessor.BusinessLogic.Common; using TransactionProcessor.BusinessLogic.Requests; +using TransactionProcessor.DataTransferObjects.Requests.Merchant; +using Address = EstateManagement.DataTransferObjects.Requests.Merchant.Address; +using CalculationType = TransactionProcessor.DataTransferObjects.Responses.Contract.CalculationType; +using Contact = EstateManagement.DataTransferObjects.Requests.Merchant.Contact; +using FeeType = TransactionProcessor.DataTransferObjects.Responses.Contract.FeeType; +using ProductType = TransactionProcessor.DataTransferObjects.Responses.Contract.ProductType; namespace TransactionProcessor.Controllers; @@ -14,9 +26,9 @@ namespace TransactionProcessor.Controllers; using System.Threading.Tasks; using Common; using DataTransferObjects; -using EstateManagement.Database.Entities; using EventStore.Client; using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; using Newtonsoft.Json; using ProjectionEngine.Models; @@ -26,6 +38,7 @@ namespace TransactionProcessor.Controllers; using Shared.Exceptions; using Shared.General; using Swashbuckle.AspNetCore.Annotations; +using TransactionProcessor.Database.Entities; [ExcludeFromCodeCoverage] [Route(MerchantController.ControllerRoute)] @@ -37,17 +50,23 @@ public class MerchantController : ControllerBase private readonly IEventStoreContext EventStoreContext; private readonly IMediator Mediator; + private readonly IEstateClient EstateClient; + private readonly ISecurityServiceClient SecurityServiceClient; private readonly ITransactionProcessorReadRepository TransactionProcessorReadRepository; public MerchantController(IProjectionStateRepository merchantBalanceStateRepository, ITransactionProcessorReadRepository transactionProcessorReadRepository, IEventStoreContext eventStoreContext, - IMediator mediator) { + IMediator mediator, + IEstateClient estateClient, + ISecurityServiceClient securityServiceClient) { this.MerchantBalanceStateRepository = merchantBalanceStateRepository; this.TransactionProcessorReadRepository = transactionProcessorReadRepository; this.EventStoreContext = eventStoreContext; this.Mediator = mediator; + this.EstateClient = estateClient; + this.SecurityServiceClient = securityServiceClient; } #region Others @@ -215,4 +234,718 @@ public async Task GetMerchantBalanceHistory([FromRoute] Guid esta return result.ToActionResultX(); } + + private ClaimsPrincipal UserOverride; + internal void SetContextOverride(HttpContext ctx) + { + UserOverride = ctx.User; + } + + internal ClaimsPrincipal GetUser() + { + return UserOverride switch + { + null => HttpContext.User, + _ => UserOverride + }; + } + + private bool PerformStandardChecks(Guid estateId) + { + // Get the Estate Id claim from the user + Claim estateIdClaim = ClaimsHelper.GetUserClaim(GetUser(), "EstateId", estateId.ToString()); + + string estateRoleName = Environment.GetEnvironmentVariable("EstateRoleName"); + if (ClaimsHelper.IsUserRolesValid(GetUser(), new[] { string.IsNullOrEmpty(estateRoleName) ? "Estate" : estateRoleName }) == false) + { + return false; + } + + if (ClaimsHelper.ValidateRouteParameter(estateId, estateIdClaim) == false) + { + return false; + } + + return true; + } + private TokenResponse TokenResponse; + [HttpPost] + [Route("")] + public async Task CreateMerchant([FromRoute] Guid estateId, + [FromBody] CreateMerchantRequest createMerchantRequest, + CancellationToken cancellationToken) + { + + bool isRequestAllowed = PerformStandardChecks(estateId); + if (isRequestAllowed == false) + { + return Forbid(); + } + + this.TokenResponse = await Helpers.GetToken(this.TokenResponse, this.SecurityServiceClient, cancellationToken); + + var estateClientRequest = new EstateManagement.DataTransferObjects.Requests.Merchant.CreateMerchantRequest { + Name = createMerchantRequest.Name, + Address = new Address { + AddressLine1 = createMerchantRequest.Address.AddressLine1, + AddressLine2 = createMerchantRequest.Address.AddressLine2, + AddressLine3 = createMerchantRequest.Address.AddressLine3, + AddressLine4 = createMerchantRequest.Address.AddressLine4, + Country = createMerchantRequest.Address.Country, + PostalCode = createMerchantRequest.Address.PostalCode, + Region = createMerchantRequest.Address.Region, + Town = createMerchantRequest.Address.Town + }, + Contact = new Contact { ContactName = createMerchantRequest.Contact.ContactName, EmailAddress = createMerchantRequest.Contact.EmailAddress, PhoneNumber = createMerchantRequest.Contact.PhoneNumber }, + CreatedDateTime = createMerchantRequest.CreatedDateTime, + MerchantId = createMerchantRequest.MerchantId, + SettlementSchedule = (SettlementSchedule)createMerchantRequest.SettlementSchedule + }; + var result = await this.EstateClient.CreateMerchant(this.TokenResponse.AccessToken, estateId, estateClientRequest, cancellationToken); + + // return the result + return result.ToActionResultX(); + + } + + [HttpPatch] + [Route("{merchantId}/operators")] + [ProducesResponseType(typeof(AssignOperatorResponse), 201)] + public async Task AssignOperator([FromRoute] Guid estateId, + [FromRoute] Guid merchantId, + AssignOperatorRequest assignOperatorRequest, + CancellationToken cancellationToken) + { + bool isRequestAllowed = PerformStandardChecks(estateId); + if (isRequestAllowed == false) + { + return Forbid(); + } + + this.TokenResponse = await Helpers.GetToken(this.TokenResponse, this.SecurityServiceClient, cancellationToken); + + var estateClientRequest = new EstateManagement.DataTransferObjects.Requests.Merchant.AssignOperatorRequest + { + OperatorId = assignOperatorRequest.OperatorId, + MerchantNumber = assignOperatorRequest.MerchantNumber, + TerminalNumber = assignOperatorRequest.TerminalNumber + }; + var result = await this.EstateClient.AssignOperatorToMerchant(this.TokenResponse.AccessToken, estateId, merchantId, estateClientRequest, cancellationToken); + + // return the result + return result.ToActionResultX(); + } + + [HttpDelete] + [Route("{merchantId}/operators/{operatorId}")] + public async Task RemoveOperator([FromRoute] Guid estateId, + [FromRoute] Guid merchantId, + [FromRoute] Guid operatorId, + CancellationToken cancellationToken) + { + bool isRequestAllowed = PerformStandardChecks(estateId); + if (isRequestAllowed == false) + { + return Forbid(); + } + + this.TokenResponse = await Helpers.GetToken(this.TokenResponse, this.SecurityServiceClient, cancellationToken); + + var result = await this.EstateClient.RemoveOperatorFromMerchant(this.TokenResponse.AccessToken, estateId, merchantId, operatorId, cancellationToken); + + // return the result + return result.ToActionResultX(); + } + + [HttpPatch] + [Route("{merchantId}/devices")] + public async Task AddDevice([FromRoute] Guid estateId, + [FromRoute] Guid merchantId, + [FromBody] AddMerchantDeviceRequest addMerchantDeviceRequest, + CancellationToken cancellationToken) + { + bool isRequestAllowed = PerformStandardChecks(estateId); + if (isRequestAllowed == false) + { + return Forbid(); + } + + this.TokenResponse = await Helpers.GetToken(this.TokenResponse, this.SecurityServiceClient, cancellationToken); + + var estateClientRequest = new EstateManagement.DataTransferObjects.Requests.Merchant.AddMerchantDeviceRequest + { + DeviceIdentifier = addMerchantDeviceRequest.DeviceIdentifier + }; + + var result = await this.EstateClient.AddDeviceToMerchant(this.TokenResponse.AccessToken, estateId, merchantId, estateClientRequest, cancellationToken); + + + // return the result + return result.ToActionResultX(); + } + + [HttpPatch] + [Route("{merchantId}/contracts")] + public async Task AddContract([FromRoute] Guid estateId, + [FromRoute] Guid merchantId, + [FromBody] AddMerchantContractRequest addMerchantContractRequest, + CancellationToken cancellationToken) + { + bool isRequestAllowed = PerformStandardChecks(estateId); + if (isRequestAllowed == false) + { + return Forbid(); + } + + this.TokenResponse = await Helpers.GetToken(this.TokenResponse, this.SecurityServiceClient, cancellationToken); + + var estateClientRequest = new EstateManagement.DataTransferObjects.Requests.Merchant.AddMerchantContractRequest + { + ContractId = addMerchantContractRequest.ContractId + }; + var result = await this.EstateClient.AddContractToMerchant(this.TokenResponse.AccessToken, estateId, merchantId, estateClientRequest, cancellationToken); + + // return the result + return result.ToActionResultX(); + } + + [HttpDelete] + [Route("{merchantId}/contracts/{contractId}")] + public async Task RemoveContract([FromRoute] Guid estateId, + [FromRoute] Guid merchantId, + [FromRoute] Guid contractId, + CancellationToken cancellationToken) + { + bool isRequestAllowed = PerformStandardChecks(estateId); + if (isRequestAllowed == false) + { + return Forbid(); + } + + this.TokenResponse = await Helpers.GetToken(this.TokenResponse, this.SecurityServiceClient, cancellationToken); + + var result = await this.EstateClient.RemoveContractFromMerchant(this.TokenResponse.AccessToken, estateId, merchantId, contractId, cancellationToken); + + // return the result + return result.ToActionResultX(); + } + + [HttpPatch] + [Route("{merchantId}/users")] + public async Task CreateMerchantUser([FromRoute] Guid estateId, + [FromRoute] Guid merchantId, + [FromBody] CreateMerchantUserRequest createMerchantUserRequest, + CancellationToken cancellationToken) + { + bool isRequestAllowed = PerformStandardChecks(estateId); + if (isRequestAllowed == false) + { + return Forbid(); + } + + var estateClientRequest = new EstateManagement.DataTransferObjects.Requests.Merchant.CreateMerchantUserRequest + { + EmailAddress = createMerchantUserRequest.EmailAddress, + FamilyName = createMerchantUserRequest.FamilyName, + GivenName = createMerchantUserRequest.GivenName, + Password = createMerchantUserRequest.Password, + MiddleName = createMerchantUserRequest.MiddleName, + }; + + var result = await this.EstateClient.CreateMerchantUser(this.TokenResponse.AccessToken, estateId, merchantId, estateClientRequest, cancellationToken); + + // return the result + return result.ToActionResultX(); + } + + [HttpPost] + [Route("{merchantId}/deposits")] + public async Task MakeDeposit([FromRoute] Guid estateId, + [FromRoute] Guid merchantId, + [FromBody] MakeMerchantDepositRequest makeMerchantDepositRequest, + CancellationToken cancellationToken) + { + bool isRequestAllowed = PerformStandardChecks(estateId); + if (isRequestAllowed == false) + { + return Forbid(); + } + + this.TokenResponse = await Helpers.GetToken(this.TokenResponse, this.SecurityServiceClient, cancellationToken); + + var estateClientRequest = new EstateManagement.DataTransferObjects.Requests.Merchant.MakeMerchantDepositRequest + { + Amount = makeMerchantDepositRequest.Amount, + DepositDateTime = makeMerchantDepositRequest.DepositDateTime, + Reference = makeMerchantDepositRequest.Reference + }; + + var result = await this.EstateClient.MakeMerchantDeposit(this.TokenResponse.AccessToken, estateId, merchantId, estateClientRequest, cancellationToken); + + + // return the result + return result.ToActionResultX(); + } + + [HttpPost] + [Route("{merchantId}/withdrawals")] + //[SwaggerResponse(201, "Created", typeof(MakeMerchantDepositResponse))] + //[SwaggerResponseExample(201, typeof(MakeMerchantDepositResponseExample))] + public async Task MakeWithdrawal([FromRoute] Guid estateId, + [FromRoute] Guid merchantId, + [FromBody] MakeMerchantWithdrawalRequest makeMerchantWithdrawalRequest, + CancellationToken cancellationToken) + { + bool isRequestAllowed = PerformStandardChecks(estateId); + if (isRequestAllowed == false) + { + return Forbid(); + } + + this.TokenResponse = await Helpers.GetToken(this.TokenResponse, this.SecurityServiceClient, cancellationToken); + + var estateClientRequest= new EstateManagement.DataTransferObjects.Requests.Merchant.MakeMerchantWithdrawalRequest + { + Amount = makeMerchantWithdrawalRequest.Amount, + Reference = makeMerchantWithdrawalRequest.Reference, + WithdrawalDateTime = makeMerchantWithdrawalRequest.WithdrawalDateTime + }; + + var result = await this.EstateClient.MakeMerchantWithdrawal(this.TokenResponse.AccessToken, estateId, merchantId, estateClientRequest, cancellationToken); + + // return the result + return result.ToActionResultX(); + } + + [HttpPatch] + [Route("{merchantId}/devices/{deviceIdentifier}")] + public async Task SwapMerchantDevice([FromRoute] Guid estateId, + [FromRoute] Guid merchantId, + [FromRoute] string deviceIdentifier, + [FromBody] SwapMerchantDeviceRequest swapMerchantDeviceRequest, + CancellationToken cancellationToken) + { + bool isRequestAllowed = PerformStandardChecks(estateId); + if (isRequestAllowed == false) + { + return Forbid(); + } + + this.TokenResponse = await Helpers.GetToken(this.TokenResponse, this.SecurityServiceClient, cancellationToken); + + var estateClientRequest = new EstateManagement.DataTransferObjects.Requests.Merchant.SwapMerchantDeviceRequest + { + NewDeviceIdentifier = swapMerchantDeviceRequest.NewDeviceIdentifier + }; + var result = await this.EstateClient.SwapDeviceForMerchant(this.TokenResponse.AccessToken, estateId, merchantId, deviceIdentifier, estateClientRequest, cancellationToken); + + + // return the result + return result.ToActionResultX(); + } + + private bool PerformMerchantUserChecks(Guid estateId, Guid merchantId) + { + + if (PerformStandardChecks(estateId) == false) + { + return false; + } + + string merchantRoleName = string.IsNullOrEmpty(Environment.GetEnvironmentVariable("MerchantRoleName")) + ? "Merchant" + : Environment.GetEnvironmentVariable("MerchantRoleName"); + + if (GetUser().IsInRole(merchantRoleName) == false) + return true; + + if (ClaimsHelper.IsUserRolesValid(GetUser(), new[] { merchantRoleName }) == false) + { + return false; + } + + Claim merchantIdClaim = ClaimsHelper.GetUserClaim(GetUser(), "MerchantId"); + + if (ClaimsHelper.ValidateRouteParameter(merchantId, merchantIdClaim) == false) + { + return false; + } + + return true; + } + + [HttpGet] + [Route("{merchantId}")] + public async Task GetMerchant([FromRoute] Guid estateId, + [FromRoute] Guid merchantId, + CancellationToken cancellationToken) + { + bool isRequestAllowed = PerformMerchantUserChecks(estateId, merchantId); + if (isRequestAllowed == false) + { + return Forbid(); + } + + this.TokenResponse = await Helpers.GetToken(this.TokenResponse, this.SecurityServiceClient, cancellationToken); + + Result result = await this.EstateClient.GetMerchant(this.TokenResponse.AccessToken, estateId, merchantId, cancellationToken); + + if (result.IsFailed) + return result.ToActionResultX(); + + var m = ConvertMerchant(result.Data); + + return Result.Success(m).ToActionResultX(); + } + + private static DataTransferObjects.Responses.Merchant.MerchantResponse ConvertMerchant(MerchantResponse merchant) { + var m = new DataTransferObjects.Responses.Merchant.MerchantResponse() + { + Operators = new List(), + MerchantId = merchant.MerchantId, + SettlementSchedule = (DataTransferObjects.Responses.Merchant.SettlementSchedule)merchant.SettlementSchedule, + EstateId = merchant.EstateId, + EstateReportingId = merchant.EstateReportingId, + Addresses = new(), + Contacts = new(), + Contracts = new(), + Devices = new Dictionary(), + MerchantName = merchant.MerchantName, + MerchantReference = merchant.MerchantReference, + MerchantReportingId = merchant.MerchantReportingId, + NextStatementDate = merchant.NextStatementDate + }; + + if (merchant.Addresses != null) { + foreach (AddressResponse addressResponse in merchant.Addresses) { + m.Addresses.Add(new DataTransferObjects.Responses.Merchant.AddressResponse { + AddressLine3 = addressResponse.AddressLine3, + AddressLine4 = addressResponse.AddressLine4, + AddressLine2 = addressResponse.AddressLine2, + Country = addressResponse.Country, + PostalCode = addressResponse.PostalCode, + Region = addressResponse.Region, + Town = addressResponse.Town, + AddressLine1 = addressResponse.AddressLine1, + AddressId = addressResponse.AddressId + }); + } + } + + if (merchant.Contacts != null) + { + foreach (ContactResponse contactResponse in merchant.Contacts) + { + m.Contacts.Add(new DataTransferObjects.Responses.Contract.ContactResponse + { + ContactId = contactResponse.ContactId, + ContactName = contactResponse.ContactName, + ContactEmailAddress = contactResponse.ContactEmailAddress, + ContactPhoneNumber = contactResponse.ContactPhoneNumber + }); + } + } + + if (merchant.Contracts != null) { + foreach (MerchantContractResponse merchantContractResponse in merchant.Contracts) { + var mcr = new DataTransferObjects.Responses.Merchant.MerchantContractResponse { ContractId = merchantContractResponse.ContractId, ContractProducts = new List(), IsDeleted = merchantContractResponse.IsDeleted, }; + foreach (Guid contractProduct in merchantContractResponse.ContractProducts) { + mcr.ContractProducts.Add(contractProduct); + } + + m.Contracts.Add(mcr); + } + } + + if (merchant.Devices != null) { + foreach (KeyValuePair keyValuePair in merchant.Devices) { + m.Devices.Add(keyValuePair.Key, keyValuePair.Value); + } + } + + if (merchant.Operators != null) { + foreach (MerchantOperatorResponse merchantOperatorResponse in merchant.Operators) { + m.Operators.Add(new() { OperatorId = merchantOperatorResponse.OperatorId, MerchantNumber = merchantOperatorResponse.MerchantNumber, TerminalNumber = merchantOperatorResponse.TerminalNumber }); + } + } + + return m; + } + + [Route("{merchantId}/contracts")] + [HttpGet] + public async Task GetMerchantContracts([FromRoute] Guid estateId, + [FromRoute] Guid merchantId, + CancellationToken cancellationToken) + { + bool isRequestAllowed = PerformMerchantUserChecks(estateId, merchantId); + if (isRequestAllowed == false) + { + return Forbid(); + } + + this.TokenResponse = await Helpers.GetToken(this.TokenResponse, this.SecurityServiceClient, cancellationToken); + + Result> result = await this.EstateClient.GetMerchantContracts(this.TokenResponse.AccessToken, estateId, merchantId, cancellationToken); + + if (result.IsFailed) + return result.ToActionResultX(); + + List responses = new(); + + foreach (ContractResponse contractResponse in result.Data) { + var cr = new DataTransferObjects.Responses.Contract.ContractResponse { + Description = contractResponse.Description, + EstateId = contractResponse.EstateId, + EstateReportingId = contractResponse.EstateReportingId, + ContractId = contractResponse.ContractId, + Products = new(), + ContractReportingId = contractResponse.ContractReportingId, + OperatorId = contractResponse.OperatorId, + OperatorName = contractResponse.OperatorName + }; + + foreach (EstateManagement.DataTransferObjects.Responses.Contract.ContractProduct contractResponseProduct in contractResponse.Products) { + var p = new DataTransferObjects.Responses.Contract.ContractProduct + { + ProductId = contractResponseProduct.ProductId, + Value = contractResponseProduct.Value, + ProductType = (ProductType)contractResponseProduct.ProductType, + DisplayText = contractResponseProduct.DisplayText, + Name = contractResponseProduct.Name, + ProductReportingId = contractResponseProduct.ProductReportingId, + TransactionFees = new() + }; + foreach (EstateManagement.DataTransferObjects.Responses.Contract.ContractProductTransactionFee contractProductTransactionFee in contractResponseProduct.TransactionFees) { + p.TransactionFees.Add(new DataTransferObjects.Responses.Contract.ContractProductTransactionFee + { + FeeType = (DataTransferObjects.Responses.Contract.FeeType)contractProductTransactionFee.FeeType, + CalculationType = (DataTransferObjects.Responses.Contract.CalculationType)contractProductTransactionFee.CalculationType, + Value = contractProductTransactionFee.Value, + Description = contractProductTransactionFee.Description, + TransactionFeeReportingId = contractProductTransactionFee.TransactionFeeReportingId, + TransactionFeeId = contractProductTransactionFee.TransactionFeeId + }); + } + cr.Products.Add(p); + + } + + responses.Add(cr); + } + + return Result.Success(responses).ToActionResultX(); + } + + [HttpGet] + [Route("")] + public async Task GetMerchants([FromRoute] Guid estateId, + CancellationToken cancellationToken) + { + bool isRequestAllowed = PerformStandardChecks(estateId); + if (isRequestAllowed == false) + { + return Forbid(); + } + + this.TokenResponse = await Helpers.GetToken(this.TokenResponse, this.SecurityServiceClient, cancellationToken); + + var result = await this.EstateClient.GetMerchants(this.TokenResponse.AccessToken, estateId, cancellationToken); + + if (result.IsFailed) + return result.ToActionResultX(); + List responses = new(); + foreach (MerchantResponse merchantResponse in result.Data) { + responses.Add(ConvertMerchant(merchantResponse)); + } + + return Result.Success(responses).ToActionResultX(); + } + + [Route("{merchantId}/contracts/{contractId}/products/{productId}/transactionFees")] + [HttpGet] + public async Task GetTransactionFeesForProduct([FromRoute] Guid estateId, + [FromRoute] Guid merchantId, + [FromRoute] Guid contractId, + [FromRoute] Guid productId, + CancellationToken cancellationToken) + { + bool isRequestAllowed = PerformMerchantUserChecks(estateId, merchantId); + if (isRequestAllowed == false) + { + return Forbid(); + } + + this.TokenResponse = await Helpers.GetToken(this.TokenResponse, this.SecurityServiceClient, cancellationToken); + + var result = await this.EstateClient.GetTransactionFeesForProduct(this.TokenResponse.AccessToken, estateId, merchantId, contractId, productId, cancellationToken); + + if (result.IsFailed) + return result.ToActionResultX(); + + List responses = new(); + + foreach (EstateManagement.DataTransferObjects.Responses.Contract.ContractProductTransactionFee contractProductTransactionFee in result.Data) { + responses.Add(new DataTransferObjects.Responses.Contract.ContractProductTransactionFee { + CalculationType = (CalculationType)contractProductTransactionFee.CalculationType, + Value = contractProductTransactionFee.Value, + Description = contractProductTransactionFee.Description, + FeeType = (FeeType)contractProductTransactionFee.FeeType, + TransactionFeeReportingId = contractProductTransactionFee.TransactionFeeReportingId, + TransactionFeeId = contractProductTransactionFee.TransactionFeeId + }); + } + + return Result.Success(responses).ToActionResultX(); + } + + [HttpPatch] + [Route("{merchantId}")] + public async Task UpdateMerchant([FromRoute] Guid estateId, + [FromRoute] Guid merchantId, + [FromBody] UpdateMerchantRequest updateMerchantRequest, + CancellationToken cancellationToken) + { + + bool isRequestAllowed = PerformStandardChecks(estateId); + if (isRequestAllowed == false) + { + return Forbid(); + } + + this.TokenResponse = await Helpers.GetToken(this.TokenResponse, this.SecurityServiceClient, cancellationToken); + + var estateClientRequest = new EstateManagement.DataTransferObjects.Requests.Merchant.UpdateMerchantRequest + { + Name = updateMerchantRequest.Name, + SettlementSchedule = (SettlementSchedule)updateMerchantRequest.SettlementSchedule + }; + + var result = await this.EstateClient.UpdateMerchant(this.TokenResponse.AccessToken, estateId, merchantId, estateClientRequest, cancellationToken); + + // return the result + return result.ToActionResultX(); + } + + [Route("{merchantId}/addresses")] + [HttpPatch] + public async Task AddMerchantAddress([FromRoute] Guid estateId, + [FromRoute] Guid merchantId, + [FromBody] DataTransferObjects.Requests.Merchant.Address addAddressRequest, + CancellationToken cancellationToken) + { + bool isRequestAllowed = PerformStandardChecks(estateId); + if (isRequestAllowed == false) + { + return Forbid(); + } + + var estateClientRequest = new EstateManagement.DataTransferObjects.Requests.Merchant.Address + { + AddressLine1 = addAddressRequest.AddressLine1, + AddressLine2 = addAddressRequest.AddressLine2, + AddressLine3 = addAddressRequest.AddressLine3, + AddressLine4 = addAddressRequest.AddressLine4, + Country = addAddressRequest.Country, + PostalCode = addAddressRequest.PostalCode, + Region = addAddressRequest.Region, + Town = addAddressRequest.Town + }; + + this.TokenResponse = await Helpers.GetToken(this.TokenResponse, this.SecurityServiceClient, cancellationToken); + + var result = await this.EstateClient.AddMerchantAddress(this.TokenResponse.AccessToken, estateId, merchantId, estateClientRequest, cancellationToken); + + // return the result + return result.ToActionResultX(); + } + + [Route("{merchantId}/addresses/{addressId}")] + [HttpPatch] + public async Task UpdateMerchantAddress([FromRoute] Guid estateId, + [FromRoute] Guid merchantId, + [FromRoute] Guid addressId, + [FromBody] DataTransferObjects.Requests.Merchant.Address updateAddressRequest, + CancellationToken cancellationToken) + { + bool isRequestAllowed = PerformStandardChecks(estateId); + if (isRequestAllowed == false) + { + return Forbid(); + } + + var estateClientRequest = new EstateManagement.DataTransferObjects.Requests.Merchant.Address + { + AddressLine1 = updateAddressRequest.AddressLine1, + AddressLine2 = updateAddressRequest.AddressLine2, + AddressLine3 = updateAddressRequest.AddressLine3, + AddressLine4 = updateAddressRequest.AddressLine4, + Country = updateAddressRequest.Country, + PostalCode = updateAddressRequest.PostalCode, + Region = updateAddressRequest.Region, + Town = updateAddressRequest.Town + }; + + this.TokenResponse = await Helpers.GetToken(this.TokenResponse, this.SecurityServiceClient, cancellationToken); + + var result = await this.EstateClient.UpdateMerchantAddress(this.TokenResponse.AccessToken, estateId, merchantId,addressId, estateClientRequest, cancellationToken); + + // return the result + return result.ToActionResultX(); + } + + [Route("{merchantId}/contacts")] + [HttpPatch] + public async Task AddMerchantContact([FromRoute] Guid estateId, + [FromRoute] Guid merchantId, + [FromBody] DataTransferObjects.Requests.Merchant.Contact addContactRequest, + CancellationToken cancellationToken) + { + bool isRequestAllowed = PerformStandardChecks(estateId); + if (isRequestAllowed == false) + { + return Forbid(); + } + + this.TokenResponse = await Helpers.GetToken(this.TokenResponse, this.SecurityServiceClient, cancellationToken); + var estateClientRequest = new EstateManagement.DataTransferObjects.Requests.Merchant.Contact + { + ContactName = addContactRequest.ContactName, + EmailAddress = addContactRequest.EmailAddress, + PhoneNumber = addContactRequest.PhoneNumber + }; + + var result = await this.EstateClient.AddMerchantContact(this.TokenResponse.AccessToken, estateId, merchantId, estateClientRequest, cancellationToken); + + // return the result + return result.ToActionResultX(); + } + + [Route("{merchantId}/contacts/{contactId}")] + [HttpPatch] + public async Task UpdateMerchantContact([FromRoute] Guid estateId, + [FromRoute] Guid merchantId, + [FromRoute] Guid contactId, + [FromBody] DataTransferObjects.Requests.Merchant.Contact updateContactRequest, + CancellationToken cancellationToken) + { + bool isRequestAllowed = PerformStandardChecks(estateId); + if (isRequestAllowed == false) + { + return Forbid(); + } + + this.TokenResponse = await Helpers.GetToken(this.TokenResponse, this.SecurityServiceClient, cancellationToken); + var estateClientRequest = new EstateManagement.DataTransferObjects.Requests.Merchant.Contact + { + ContactName = updateContactRequest.ContactName, + EmailAddress = updateContactRequest.EmailAddress, + PhoneNumber = updateContactRequest.PhoneNumber + }; + + var result = await this.EstateClient.UpdateMerchantContact(this.TokenResponse.AccessToken, estateId, merchantId, contactId,estateClientRequest, cancellationToken); + + // return the result + return result.ToActionResultX(); + } } \ No newline at end of file diff --git a/TransactionProcessor/Controllers/SettlementController.cs b/TransactionProcessor/Controllers/SettlementController.cs index b4e9c3f8..4f5e8339 100644 --- a/TransactionProcessor/Controllers/SettlementController.cs +++ b/TransactionProcessor/Controllers/SettlementController.cs @@ -1,11 +1,17 @@ -using Microsoft.AspNetCore.Http; +using EstateManagement.Client; +using EstateManagement.DataTransferObjects.Responses.Settlement; +using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; +using SecurityService.Client; +using SecurityService.DataTransferObjects.Responses; using Shared.Results; using SimpleResults; +using TransactionProcessor.Aggregates; namespace TransactionProcessor.Controllers { using System; + using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using System.Threading; using System.Threading.Tasks; @@ -16,10 +22,10 @@ namespace TransactionProcessor.Controllers using MediatR; using Microsoft.AspNetCore.Authorization; using Models; - using SettlementAggregates; using Shared.DomainDrivenDesign.EventSourcing; using Shared.EventStore.Aggregate; using Shared.Logger; + using TransactionProcessor.Database.Entities; [ExcludeFromCodeCoverage] [Route(SettlementController.ControllerRoute)] @@ -30,8 +36,8 @@ public class SettlementController : ControllerBase private readonly IAggregateRepository SettlmentAggregateRepository; private readonly IMediator Mediator; - - private readonly IModelFactory ModelFactory; + private readonly IEstateClient EstateClient; + private readonly ISecurityServiceClient SecurityServiceClient; #region Others @@ -45,13 +51,15 @@ public class SettlementController : ControllerBase /// private const String ControllerRoute = "api/" + SettlementController.ControllerName; - public SettlementController(IAggregateRepository settlmentAggregateRepository, + public SettlementController(IAggregateRepository settlementAggregateRepository, IMediator mediator, - IModelFactory modelFactory) + IEstateClient estateClient, + ISecurityServiceClient securityServiceClient) { - this.SettlmentAggregateRepository = settlmentAggregateRepository; + this.SettlmentAggregateRepository = settlementAggregateRepository; this.Mediator = mediator; - this.ModelFactory = modelFactory; + this.EstateClient = estateClient; + this.SecurityServiceClient = securityServiceClient; } [HttpGet] @@ -105,6 +113,93 @@ public async Task ProcessSettlement([FromRoute] DateTime settleme return result.ToActionResultX(); } + private TokenResponse TokenResponse; + + [Route("{settlementId}")] + [HttpGet] + public async Task GetSettlement([FromRoute] Guid estateId, + [FromQuery] Guid merchantId, + [FromRoute] Guid settlementId, + CancellationToken cancellationToken) + { + this.TokenResponse = await Helpers.GetToken(this.TokenResponse, this.SecurityServiceClient, cancellationToken); + + var result = await this.EstateClient.GetSettlement(this.TokenResponse.AccessToken, estateId, merchantId, settlementId, cancellationToken); + + DataTransferObjects.Responses.Settlement.SettlementResponse settlementResponse = new DataTransferObjects.Responses.Settlement.SettlementResponse { + IsCompleted = result.Data.IsCompleted, + NumberOfFeesSettled = result.Data.NumberOfFeesSettled, + SettlementDate = result.Data.SettlementDate, + SettlementFees = new(), + SettlementId = result.Data.SettlementId, + ValueOfFeesSettled = result.Data.ValueOfFeesSettled + }; + + foreach (SettlementFeeResponse settlementFeeResponse in result.Data.SettlementFees) { + settlementResponse.SettlementFees.Add(new() + { + TransactionId = settlementFeeResponse.TransactionId, + MerchantId = settlementFeeResponse.MerchantId, + MerchantName = settlementFeeResponse.MerchantName, + SettlementDate = settlementFeeResponse.SettlementDate, + SettlementId = settlementFeeResponse.SettlementId, + CalculatedValue = settlementFeeResponse.CalculatedValue, + FeeDescription = settlementFeeResponse.FeeDescription, + IsSettled = settlementFeeResponse.IsSettled, + OperatorIdentifier = settlementFeeResponse.OperatorIdentifier + }); + } + + return Result.Success(settlementResponse).ToActionResultX(); + } + + [Route("")] + [HttpGet] + public async Task GetSettlements([FromRoute] Guid estateId, + [FromQuery] Guid? merchantId, + [FromQuery(Name = "start_date")] string startDate, + [FromQuery(Name = "end_date")] string endDate, + CancellationToken cancellationToken) + { + this.TokenResponse = await Helpers.GetToken(this.TokenResponse, this.SecurityServiceClient, cancellationToken); + + var result = await this.EstateClient.GetSettlements(this.TokenResponse.AccessToken, estateId, merchantId, startDate, endDate, cancellationToken); + if (result.IsFailed) + return result.ToActionResultX(); + + var responses = new List(); + foreach (EstateManagement.DataTransferObjects.Responses.Settlement.SettlementResponse settlementResponses in result.Data) { + DataTransferObjects.Responses.Settlement.SettlementResponse sr = new DataTransferObjects.Responses.Settlement.SettlementResponse + { + IsCompleted = settlementResponses.IsCompleted, + NumberOfFeesSettled = settlementResponses.NumberOfFeesSettled, + SettlementDate = settlementResponses.SettlementDate, + SettlementFees = new(), + SettlementId = settlementResponses.SettlementId, + ValueOfFeesSettled = settlementResponses.ValueOfFeesSettled + }; + + foreach (SettlementFeeResponse settlementFeeResponse in settlementResponses.SettlementFees) + { + sr.SettlementFees.Add(new() + { + TransactionId = settlementFeeResponse.TransactionId, + MerchantId = settlementFeeResponse.MerchantId, + MerchantName = settlementFeeResponse.MerchantName, + SettlementDate = settlementFeeResponse.SettlementDate, + SettlementId = settlementFeeResponse.SettlementId, + CalculatedValue = settlementFeeResponse.CalculatedValue, + FeeDescription = settlementFeeResponse.FeeDescription, + IsSettled = settlementFeeResponse.IsSettled, + OperatorIdentifier = settlementFeeResponse.OperatorIdentifier + }); + } + responses.Add(sr); + } + + + return Result.Success(responses).ToActionResultX(); + } #endregion diff --git a/TransactionProcessor/Controllers/TransactionController.cs b/TransactionProcessor/Controllers/TransactionController.cs index 8891cb1e..70c98998 100644 --- a/TransactionProcessor/Controllers/TransactionController.cs +++ b/TransactionProcessor/Controllers/TransactionController.cs @@ -38,16 +38,8 @@ public class TransactionController : ControllerBase { #region Fields - /// - /// The mediator - /// private readonly IMediator Mediator; - /// - /// The model factory - /// - private readonly IModelFactory ModelFactory; - #endregion #region Constructors @@ -57,11 +49,9 @@ public class TransactionController : ControllerBase /// /// The mediator. /// The model factory. - public TransactionController(IMediator mediator, - IModelFactory modelFactory) + public TransactionController(IMediator mediator) { this.Mediator = mediator; - this.ModelFactory = modelFactory; } #endregion @@ -150,7 +140,7 @@ private async Task> ProcessSpecificMessage(LogonTransa if (result.IsFailed) return ResultHelpers.CreateFailure(result); - return this.ModelFactory.ConvertFrom(result.Data); + return ModelFactory.ConvertFrom(result.Data); } /// @@ -183,7 +173,7 @@ private async Task> ProcessSpecificMessage(SaleTransac if (result.IsFailed) return ResultHelpers.CreateFailure(result); - return this.ModelFactory.ConvertFrom(result.Data); + return ModelFactory.ConvertFrom(result.Data); } private async Task> ProcessSpecificMessage(ReconciliationRequest reconciliationRequest, @@ -204,7 +194,7 @@ private async Task> ProcessSpecificMessage(Reconciliat if (result.IsFailed) return ResultHelpers.CreateFailure(result); - return this.ModelFactory.ConvertFrom(result.Data); + return ModelFactory.ConvertFrom(result.Data); } #endregion diff --git a/TransactionProcessor/Controllers/VoucherController.cs b/TransactionProcessor/Controllers/VoucherController.cs index c083a14e..595cfa4a 100644 --- a/TransactionProcessor/Controllers/VoucherController.cs +++ b/TransactionProcessor/Controllers/VoucherController.cs @@ -35,20 +35,16 @@ public class VoucherController : ControllerBase private readonly IMediator Mediator; private readonly IVoucherManagementManager VoucherManagementManager; - - private readonly IModelFactory ModelFactory; - + #endregion #region Constructors public VoucherController(IMediator mediator, - IVoucherManagementManager voucherManagementManager, - IModelFactory modelFactory) + IVoucherManagementManager voucherManagementManager) { this.Mediator = mediator; this.VoucherManagementManager = voucherManagementManager; - this.ModelFactory = modelFactory; } #endregion @@ -80,7 +76,7 @@ public async Task RedeemVoucher(RedeemVoucherRequest redeemVouche if (result.IsFailed) ResultHelpers.CreateFailure(result).ToActionResultX(); - return this.ModelFactory.ConvertFrom(result.Data).ToActionResultX(); + return ModelFactory.ConvertFrom(result.Data).ToActionResultX(); } /// @@ -109,7 +105,7 @@ public async Task GetVoucher([FromQuery] Guid estateId, if (getVoucherByCodeResult.IsFailed) ResultHelpers.CreateFailure(getVoucherByCodeResult).ToActionResultX(); - return this.ModelFactory.ConvertFrom(getVoucherByCodeResult.Data).ToActionResultX(); + return ModelFactory.ConvertFrom(getVoucherByCodeResult.Data).ToActionResultX(); } if (transactionId != Guid.Empty) { @@ -119,7 +115,7 @@ public async Task GetVoucher([FromQuery] Guid estateId, if (getVoucherByTransactionIdResult.IsFailed) ResultHelpers.CreateFailure(getVoucherByTransactionIdResult).ToActionResultX(); - return this.ModelFactory.ConvertFrom(getVoucherByTransactionIdResult.Data).ToActionResultX(); + return ModelFactory.ConvertFrom(getVoucherByTransactionIdResult.Data).ToActionResultX(); } return Result.Invalid().ToActionResultX(); diff --git a/TransactionProcessor/Factories/IModelFactory.cs b/TransactionProcessor/Factories/IModelFactory.cs deleted file mode 100644 index be3e0905..00000000 --- a/TransactionProcessor/Factories/IModelFactory.cs +++ /dev/null @@ -1,32 +0,0 @@ -using SimpleResults; - -namespace TransactionProcessor.Factories -{ - using BusinessLogic.Requests; - using DataTransferObjects; - using Models; - using IssueVoucherResponse = DataTransferObjects.IssueVoucherResponse; - using RedeemVoucherResponse = DataTransferObjects.RedeemVoucherResponse; - - /// - /// - /// - public interface IModelFactory - { - #region Methods - - Result ConvertFrom(ProcessLogonTransactionResponse processLogonTransactionResponse); - - Result ConvertFrom(ProcessSaleTransactionResponse processSaleTransactionResponse); - - Result ConvertFrom(ProcessReconciliationTransactionResponse processReconciliationTransactionResponse); - - IssueVoucherResponse ConvertFrom(Models.IssueVoucherResponse issueVoucherResponse); - - Result ConvertFrom(Models.Voucher voucherModel); - - Result ConvertFrom(Models.RedeemVoucherResponse redeemVoucherResponse); - - #endregion - } -} \ No newline at end of file diff --git a/TransactionProcessor/Factories/ModelFactory.cs b/TransactionProcessor/Factories/ModelFactory.cs index a317eb3f..500b779d 100644 --- a/TransactionProcessor/Factories/ModelFactory.cs +++ b/TransactionProcessor/Factories/ModelFactory.cs @@ -1,4 +1,6 @@ -using SimpleResults; +using System.Linq; +using EstateManagement.DataTransferObjects.Responses.Contract; +using SimpleResults; namespace TransactionProcessor.Factories { @@ -6,6 +8,7 @@ namespace TransactionProcessor.Factories using System.Collections.Generic; using BusinessLogic.Requests; using DataTransferObjects; + using EstateManagement.DataTransferObjects.Responses.Estate; using Models; using Newtonsoft.Json; using IssueVoucherResponse = DataTransferObjects.IssueVoucherResponse; @@ -15,11 +18,11 @@ namespace TransactionProcessor.Factories /// /// /// - public class ModelFactory : IModelFactory + public static class ModelFactory { #region Methods - public Result ConvertFrom(ProcessLogonTransactionResponse processLogonTransactionResponse) + public static Result ConvertFrom(ProcessLogonTransactionResponse processLogonTransactionResponse) { if (processLogonTransactionResponse == null) { @@ -49,7 +52,7 @@ public Result ConvertFrom(ProcessLogonTransactionResponse pro }); } - public Result ConvertFrom(ProcessSaleTransactionResponse processSaleTransactionResponse) + public static Result ConvertFrom(ProcessSaleTransactionResponse processSaleTransactionResponse) { if (processSaleTransactionResponse == null) { @@ -80,7 +83,7 @@ public Result ConvertFrom(ProcessSaleTransactionResponse proc }); } - public Result ConvertFrom(ProcessReconciliationTransactionResponse processReconciliationTransactionResponse) + public static Result ConvertFrom(ProcessReconciliationTransactionResponse processReconciliationTransactionResponse) { if (processReconciliationTransactionResponse == null) { @@ -110,7 +113,7 @@ public Result ConvertFrom(ProcessReconciliationTransactionRes }); } - public IssueVoucherResponse ConvertFrom(Models.IssueVoucherResponse issueVoucherResponse) + public static IssueVoucherResponse ConvertFrom(Models.IssueVoucherResponse issueVoucherResponse) { if (issueVoucherResponse == null) { @@ -127,7 +130,7 @@ public IssueVoucherResponse ConvertFrom(Models.IssueVoucherResponse issueVoucher return response; } - public Result ConvertFrom(Voucher voucherModel) + public static Result ConvertFrom(Voucher voucherModel) { if (voucherModel == null) { @@ -152,7 +155,7 @@ public Result ConvertFrom(Voucher voucherModel) return Result.Success(response); } - public Result ConvertFrom(Models.RedeemVoucherResponse redeemVoucherResponse) + public static Result ConvertFrom(Models.RedeemVoucherResponse redeemVoucherResponse) { if (redeemVoucherResponse == null) { @@ -169,6 +172,64 @@ public Result ConvertFrom(Models.RedeemVoucherResponse re return Result.Success(response); } + public static Result> ConvertFrom(List estates) + { + List> result = new(); + + estates.ForEach(c => result.Add(ModelFactory.ConvertFrom(c))); + + if (result.Any(c => c.IsFailed)) + return Result.Failure("Failed converting estates"); + + return Result.Success(result.Select(r => r.Data).ToList()); + + } + + public static Result ConvertFrom(Models.Estate estate) + { + if (estate == null) + { + return Result.Invalid("estate cannot be null"); + } + + DataTransferObjects.Responses.Estate.EstateResponse estateResponse = new() + { + EstateName = estate.Name, + EstateId = estate.EstateId, + EstateReportingId = estate.EstateReportingId, + EstateReference = estate.Reference, + Operators = new List(), + SecurityUsers = new List() + }; + + if (estate.Operators != null && estate.Operators.Any()) + { + estate.Operators.ForEach(o => estateResponse.Operators.Add(new DataTransferObjects.Responses.Estate.EstateOperatorResponse + { + OperatorId = o.OperatorId, + //RequireCustomTerminalNumber = o.RequireCustomTerminalNumber, + //RequireCustomMerchantNumber = o.RequireCustomMerchantNumber, + Name = o.Name, + IsDeleted = o.IsDeleted + })); + } + + if (estate.SecurityUsers != null && estate.SecurityUsers.Any()) + { + estate.SecurityUsers.ForEach(s => estateResponse.SecurityUsers.Add(new DataTransferObjects.Responses.Estate.SecurityUserResponse + { + EmailAddress = s.EmailAddress, + SecurityUserId = s.SecurityUserId + })); + } + + return Result.Success(estateResponse); + } + #endregion + + public static Object ConvertFrom(ContractResponse processReconciliationTransactionResponse) { + throw new NotImplementedException(); + } } } \ No newline at end of file diff --git a/TransactionProcessor/appsettings.json b/TransactionProcessor/appsettings.json index aa48fed0..d8b4ab30 100644 --- a/TransactionProcessor/appsettings.json +++ b/TransactionProcessor/appsettings.json @@ -7,6 +7,7 @@ //"SecurityService": "https://127.0.0.1:5001", "ProjectionTraceThresholdInSeconds": 1, "EventHandlerConfiguration": { + // Transaction Event Handler "TransactionHasBeenCompletedEvent": [ "TransactionProcessor.BusinessLogic.EventHandling.TransactionDomainEventHandler,TransactionProcessor.BusinessLogic" ], @@ -30,6 +31,16 @@ ], "FloatCreditPurchasedEvent": [ "TransactionProcessor.BusinessLogic.EventHandling.TransactionDomainEventHandler, TransactionProcessor.BusinessLogic" + ], + // Estate Domain Event Handler + "EstateCreatedEvent": [ + "TransactionProcessor.BusinessLogic.EventHandling.EstateDomainEventHandler, TransactionProcessor.BusinessLogic" + ], + "SecurityUserAddedToEstateEvent": [ + "TransactionProcessor.BusinessLogic.EventHandling.EstateDomainEventHandler, TransactionProcessor.BusinessLogic" + ], + "EstateReferenceAllocatedEvent": [ + "TransactionProcessor.BusinessLogic.EventHandling.EstateDomainEventHandler, TransactionProcessor.BusinessLogic" ] }, "EventHandlerConfigurationOrdered": { From 031670f058c33db7dded7903cbd930e5ee0cc7b2 Mon Sep 17 00:00:00 2001 From: Stuart Ferguson Date: Tue, 28 Jan 2025 12:41:22 +0000 Subject: [PATCH 2/3] Add TransactionProcessor.Aggregates.Tests to CI workflows This commit updates the unit testing steps in `createrelease.yml`, `nightlybuild.yml`, and `pullrequest.yml` to include the new test project, `TransactionProcessor.Aggregates.Tests`. The coverage report uploads in `nightlybuild.yml` have also been adjusted to reflect this addition, with some existing coverage report files removed. The overall structure of the unit test commands remains unchanged. --- .github/workflows/createrelease.yml | 7 ++----- .github/workflows/nightlybuild.yml | 11 ++++------- .github/workflows/pullrequest.yml | 5 +---- 3 files changed, 7 insertions(+), 16 deletions(-) diff --git a/.github/workflows/createrelease.yml b/.github/workflows/createrelease.yml index 9045fdcb..30f79e07 100644 --- a/.github/workflows/createrelease.yml +++ b/.github/workflows/createrelease.yml @@ -30,11 +30,8 @@ jobs: echo "ASPNETCORE_ENVIRONMENT are > ${ASPNETCORE_ENVIRONMENT}" dotnet test "TransactionProcessor.BusinessLogic.Tests\TransactionProcessor.BusinessLogic.Tests.csproj" dotnet test "TransactionProcessor.ProjectionEngine.Tests\TransactionProcessor.ProjectionEngine.Tests.csproj" - dotnet test "TransactionProcessor.ReconciliationAggregate.Tests\TransactionProcessor.ReconciliationAggregate.Tests.csproj" - dotnet test "TransactionProcessor.SettlementAggregates.Tests\TransactionProcessor.SettlementAggregates.Tests.csproj" - dotnet test "TransactionProcessor.Tests\TransactionProcessor.Tests.csproj" - dotnet test "TransactionProcessor.TransactionAggregate.Tests\TransactionProcessor.TransactionAggregate.Tests.csproj" - dotnet test "TransactionProcessor.VoucherAggregate.Tests\TransactionProcessor.VoucherAggregate.Tests.csproj" + dotnet test "TransactionProcessor.Aggregates.Tests\TransactionProcessor.Aggregates.Tests.csproj" + dotnet test "TransactionProcessor.Tests\TransactionProcessor.Tests.csproj" - name: Publish Images to Docker Hub - Pre Release if: ${{ github.event.release.prerelease == true }} diff --git a/.github/workflows/nightlybuild.yml b/.github/workflows/nightlybuild.yml index f0c9ec9a..e9224b2b 100644 --- a/.github/workflows/nightlybuild.yml +++ b/.github/workflows/nightlybuild.yml @@ -30,17 +30,14 @@ jobs: echo "ASPNETCORE_ENVIRONMENT are > ${ASPNETCORE_ENVIRONMENT}" dotnet test "TransactionProcessor.BusinessLogic.Tests\TransactionProcessor.BusinessLogic.Tests.csproj" /p:CollectCoverage=true /p:Exclude="[xunit*]*" /p:ExcludeByAttribute="Obsolete" /p:ExcludeByAttribute="GeneratedCodeAttribute" /p:ExcludeByAttribute="CompilerGeneratedAttribute" /p:ExcludeByAttribute="ExcludeFromCodeCoverageAttribute" /p:CoverletOutput="../lcov1.info" /maxcpucount:1 /p:CoverletOutputFormat="lcov" dotnet test "TransactionProcessor.ProjectionEngine.Tests\TransactionProcessor.ProjectionEngine.Tests.csproj" /p:CollectCoverage=true /p:Exclude="[xunit*]*" /p:ExcludeByAttribute="Obsolete" /p:ExcludeByAttribute="GeneratedCodeAttribute" /p:ExcludeByAttribute="CompilerGeneratedAttribute" /p:ExcludeByAttribute="ExcludeFromCodeCoverageAttribute" /p:CoverletOutput="../lcov2.info" /maxcpucount:1 /p:CoverletOutputFormat="lcov" - dotnet test "TransactionProcessor.ReconciliationAggregate.Tests\TransactionProcessor.ReconciliationAggregate.Tests.csproj" /p:CollectCoverage=true /p:Exclude="[xunit*]*" /p:ExcludeByAttribute="Obsolete" /p:ExcludeByAttribute="GeneratedCodeAttribute" /p:ExcludeByAttribute="CompilerGeneratedAttribute" /p:ExcludeByAttribute="ExcludeFromCodeCoverageAttribute" /p:CoverletOutput="../lcov3.info" /maxcpucount:1 /p:CoverletOutputFormat="lcov" - dotnet test "TransactionProcessor.SettlementAggregates.Tests\TransactionProcessor.SettlementAggregates.Tests.csproj" /p:CollectCoverage=true /p:Exclude="[xunit*]*" /p:ExcludeByAttribute="Obsolete" /p:ExcludeByAttribute="GeneratedCodeAttribute" /p:ExcludeByAttribute="CompilerGeneratedAttribute" /p:ExcludeByAttribute="ExcludeFromCodeCoverageAttribute" /p:CoverletOutput="../lcov4.info" /maxcpucount:1 /p:CoverletOutputFormat="lcov" - dotnet test "TransactionProcessor.Tests\TransactionProcessor.Tests.csproj" /p:CollectCoverage=true /p:Exclude="[xunit*]*" /p:ExcludeByAttribute="Obsolete" /p:ExcludeByAttribute="GeneratedCodeAttribute" /p:ExcludeByAttribute="CompilerGeneratedAttribute" /p:ExcludeByAttribute="ExcludeFromCodeCoverageAttribute" /p:CoverletOutput="../lcov5.info" /maxcpucount:1 /p:CoverletOutputFormat="lcov" - dotnet test "TransactionProcessor.TransactionAggregate.Tests\TransactionProcessor.TransactionAggregate.Tests.csproj" /p:CollectCoverage=true /p:Exclude="[xunit*]*" /p:ExcludeByAttribute="Obsolete" /p:ExcludeByAttribute="GeneratedCodeAttribute" /p:ExcludeByAttribute="CompilerGeneratedAttribute" /p:ExcludeByAttribute="ExcludeFromCodeCoverageAttribute" /p:CoverletOutput="../lcov6.info" /maxcpucount:1 /p:CoverletOutputFormat="lcov" - dotnet test "TransactionProcessor.VoucherAggregate.Tests\TransactionProcessor.VoucherAggregate.Tests.csproj" /p:CollectCoverage=true /p:Exclude="[xunit*]*" /p:ExcludeByAttribute="Obsolete" /p:ExcludeByAttribute="GeneratedCodeAttribute" /p:ExcludeByAttribute="CompilerGeneratedAttribute" /p:ExcludeByAttribute="ExcludeFromCodeCoverageAttribute" /p:CoverletOutput="../lcov7.info" /maxcpucount:1 /p:CoverletOutputFormat="lcov" - + dotnet test "TransactionProcessor.Aggregates.Tests\TransactionProcessor.Aggregates.Tests.csproj" /p:CollectCoverage=true /p:Exclude="[xunit*]*" /p:ExcludeByAttribute="Obsolete" /p:ExcludeByAttribute="GeneratedCodeAttribute" /p:ExcludeByAttribute="CompilerGeneratedAttribute" /p:ExcludeByAttribute="ExcludeFromCodeCoverageAttribute" /p:CoverletOutput="../lcov3.info" /maxcpucount:1 /p:CoverletOutputFormat="lcov" + dotnet test "TransactionProcessor.Tests\TransactionProcessor.Tests.csproj" /p:CollectCoverage=true /p:Exclude="[xunit*]*" /p:ExcludeByAttribute="Obsolete" /p:ExcludeByAttribute="GeneratedCodeAttribute" /p:ExcludeByAttribute="CompilerGeneratedAttribute" /p:ExcludeByAttribute="ExcludeFromCodeCoverageAttribute" /p:CoverletOutput="../lcov4.info" /maxcpucount:1 /p:CoverletOutputFormat="lcov" + - name: Upload coverage reports to Codecov uses: codecov/codecov-action@v3 with: token: ${{ secrets.CODECOV_TOKEN }} - files: ./lcov1.info,./lcov2.info,./lcov3.info,./lcov4.info,./lcov5.info,./lcov6.info,./lcov7.info + files: ./lcov1.info,./lcov2.info,./lcov3.info,./lcov4.info - name: Build Docker Image run: docker build . --file TransactionProcessor/Dockerfile --tag transactionprocessor:latest diff --git a/.github/workflows/pullrequest.yml b/.github/workflows/pullrequest.yml index eee49d4b..1c75104d 100644 --- a/.github/workflows/pullrequest.yml +++ b/.github/workflows/pullrequest.yml @@ -27,11 +27,8 @@ jobs: echo "ASPNETCORE_ENVIRONMENT are > ${ASPNETCORE_ENVIRONMENT}" dotnet test "TransactionProcessor.BusinessLogic.Tests\TransactionProcessor.BusinessLogic.Tests.csproj" dotnet test "TransactionProcessor.ProjectionEngine.Tests\TransactionProcessor.ProjectionEngine.Tests.csproj" - dotnet test "TransactionProcessor.ReconciliationAggregate.Tests\TransactionProcessor.ReconciliationAggregate.Tests.csproj" - dotnet test "TransactionProcessor.SettlementAggregates.Tests\TransactionProcessor.SettlementAggregates.Tests.csproj" + dotnet test "TransactionProcessor.Aggregates.Tests\TransactionProcessor.Aggregates.Tests.csproj" dotnet test "TransactionProcessor.Tests\TransactionProcessor.Tests.csproj" - dotnet test "TransactionProcessor.TransactionAggregate.Tests\TransactionProcessor.TransactionAggregate.Tests.csproj" - dotnet test "TransactionProcessor.VoucherAggregate.Tests\TransactionProcessor.VoucherAggregate.Tests.csproj" - name: Build Docker Image run: docker build . --file TransactionProcessor/Dockerfile --tag transactionprocessor:latest From 82a74546f9b6329fd3b8e1b7b6cc2c64b69f82d7 Mon Sep 17 00:00:00 2001 From: Stuart Ferguson Date: Tue, 28 Jan 2025 18:56:39 +0000 Subject: [PATCH 3/3] added some debug --- .../TransactionProcessorSteps.cs | 10 ++++++++++ TransactionProcessor/Controllers/MerchantController.cs | 9 ++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/TransactionProcessor.IntegrationTesting.Helpers/TransactionProcessorSteps.cs b/TransactionProcessor.IntegrationTesting.Helpers/TransactionProcessorSteps.cs index ff4f7c5d..1c1706c8 100644 --- a/TransactionProcessor.IntegrationTesting.Helpers/TransactionProcessorSteps.cs +++ b/TransactionProcessor.IntegrationTesting.Helpers/TransactionProcessorSteps.cs @@ -361,6 +361,16 @@ await Retry.For(async () => { MerchantResponse merchant = await this.TransactionProcessorClient .GetMerchant(accessToken, m.estate.EstateId, m.merchantId, CancellationToken.None) .ConfigureAwait(false); + + if (merchant.Operators == null) + { + Console.WriteLine($"Merchant {merchant.MerchantName} has null operators"); + } + + foreach (MerchantOperatorResponse merchantOperatorResponse in merchant.Operators) { + Console.WriteLine($"Operator Id {merchantOperatorResponse.OperatorId} Name {merchantOperatorResponse.Name}"); + } + MerchantOperatorResponse op = merchant.Operators.SingleOrDefault(o => o.OperatorId == m.operatorId); op.ShouldNotBeNull(); result.Add((m.estate, op)); diff --git a/TransactionProcessor/Controllers/MerchantController.cs b/TransactionProcessor/Controllers/MerchantController.cs index 43161e98..0111e47d 100644 --- a/TransactionProcessor/Controllers/MerchantController.cs +++ b/TransactionProcessor/Controllers/MerchantController.cs @@ -665,7 +665,14 @@ private static DataTransferObjects.Responses.Merchant.MerchantResponse ConvertMe if (merchant.Operators != null) { foreach (MerchantOperatorResponse merchantOperatorResponse in merchant.Operators) { - m.Operators.Add(new() { OperatorId = merchantOperatorResponse.OperatorId, MerchantNumber = merchantOperatorResponse.MerchantNumber, TerminalNumber = merchantOperatorResponse.TerminalNumber }); + m.Operators.Add(new() { + OperatorId = merchantOperatorResponse.OperatorId, + MerchantNumber = merchantOperatorResponse.MerchantNumber, + TerminalNumber = merchantOperatorResponse.TerminalNumber, + IsDeleted = merchantOperatorResponse.IsDeleted, + Name = merchantOperatorResponse.Name + + }); } }