public async Task <ReconciliationGetUnreconciledResponse> GetUnreconciled(ReconciliationGetUnreconciledArguments args, CancellationToken cancellation)
        {
            // Authorized access (Criteria are not supported here)
            var permissions = await _repo.PermissionsFromCache(VIEW, Constants.Read, cancellation);

            if (!permissions.Any())
            {
                throw new ForbiddenException();
            }

            var(
                entriesBalance,
                unreconciledEntriesBalance,
                unreconciledExternalEntriesBalance,
                unreconciledEntriesCount,
                unreconciledExternalEntriesCount,
                entries,
                externalEntries
                ) = await _repo.Reconciliation__Load_Unreconciled(
                accountId : args.AccountId,
                custodyId : args.CustodyId,
                asOfDate : args.AsOfDate,
                top : args.EntriesTop,
                skip : args.EntriesSkip,
                topExternal : args.ExternalEntriesTop,
                skipExternal : args.ExternalEntriesSkip, cancellation);

            return(new ReconciliationGetUnreconciledResponse
            {
                EntriesBalance = entriesBalance,
                UnreconciledEntriesBalance = unreconciledEntriesBalance,
                UnreconciledExternalEntriesBalance = unreconciledExternalEntriesBalance,
                UnreconciledEntriesCount = unreconciledEntriesCount,
                UnreconciledExternalEntriesCount = unreconciledExternalEntriesCount,
                Entries = entries,
                ExternalEntries = externalEntries
            });
        }
        public async Task <UnreconciledResult> GetUnreconciled(ReconciliationGetUnreconciledArguments args, CancellationToken cancellation)
        {
            await Initialize(cancellation);

            // Authorized access (Criteria are not supported here)
            var permissions = await UserPermissions(PermissionActions.Read, cancellation);

            if (!permissions.Any())
            {
                throw new ForbiddenException();
            }

            UnreconciledOutput output = await _behavior.Repository.Reconciliation__Load_Unreconciled(
                accountId : args.AccountId,
                agentId : args.AgentId,
                asOfDate : args.AsOfDate,
                top : args.EntriesTop,
                skip : args.EntriesSkip,
                topExternal : args.ExternalEntriesTop,
                skipExternal : args.ExternalEntriesSkip, cancellation);

            return(MapFromOutput(output));
        }
Example #3
0
        public async Task <ActionResult <ReconciliationGetUnreconciledResponse> > SaveAndGetUnreconciled([FromBody] ReconciliationSavePayload payload, [FromQuery] ReconciliationGetUnreconciledArguments args)
        {
            var result = await _service.SaveAndGetUnreconciled(payload, args);

            return(Ok(MapFromResult(result)));
        }
Example #4
0
        public async Task <ActionResult <ReconciliationGetUnreconciledResponse> > GetUnreconciled([FromQuery] ReconciliationGetUnreconciledArguments args, CancellationToken cancellation)
        {
            var result = await _service.GetUnreconciled(args, cancellation);

            return(Ok(MapFromResult(result)));
        }
 public async Task <ActionResult <ReconciliationGetUnreconciledResponse> > SaveAndGetUnreconciled([FromBody] ReconciliationSavePayload payload, [FromQuery] ReconciliationGetUnreconciledArguments args)
 {
     return(await ControllerUtilities.InvokeActionImpl(async() =>
     {
         var result = await _service.SaveAndGetUnreconciled(payload, args);
         return Ok(result);
     },
                                                       _logger));
 }
 public async Task <ActionResult <ReconciliationGetUnreconciledResponse> > GetUnreconciled([FromQuery] ReconciliationGetUnreconciledArguments args, CancellationToken cancellation)
 {
     return(await ControllerUtilities.InvokeActionImpl(async() =>
     {
         var result = await _service.GetUnreconciled(args, cancellation);
         return Ok(result);
     },
                                                       _logger));
 }
        public async Task <ReconciliationGetUnreconciledResponse> SaveAndGetUnreconciled(ReconciliationSavePayload payload, ReconciliationGetUnreconciledArguments args)
        {
            // Start transaction
            using var trx = ControllerUtilities.CreateTransaction();

            // Preprocess and Validate
            await PermissionsPreprocessAndValidate(args.AccountId, args.CustodyId, payload);

            // Save
            var(
                entriesBalance,
                unreconciledEntriesBalance,
                unreconciledExternalEntriesBalance,
                unreconciledEntriesCount,
                unreconciledExternalEntriesCount,
                entries,
                externalEntries
                ) = await _repo.Reconciliations__SaveAndLoad_Unreconciled(
                accountId : args.AccountId,
                custodyId : args.CustodyId,
                externalEntriesForSave : payload.ExternalEntries,
                reconciliations : payload.Reconciliations,
                deletedExternalEntryIds : payload.DeletedExternalEntryIds,
                deletedReconciliationIds : payload.DeletedReconciliationIds,
                asOfDate : args.AsOfDate,
                top : args.EntriesTop,
                skip : args.EntriesSkip,
                topExternal : args.ExternalEntriesTop,
                skipExternal : args.ExternalEntriesSkip);

            trx.Complete();

            return(new ReconciliationGetUnreconciledResponse
            {
                EntriesBalance = entriesBalance,
                UnreconciledEntriesBalance = unreconciledEntriesBalance,
                UnreconciledExternalEntriesBalance = unreconciledExternalEntriesBalance,
                UnreconciledEntriesCount = unreconciledEntriesCount,
                UnreconciledExternalEntriesCount = unreconciledExternalEntriesCount,
                Entries = entries,
                ExternalEntries = externalEntries
            });
        }
        public async Task <UnreconciledResult> SaveAndGetUnreconciled(ReconciliationSavePayload payload, ReconciliationGetUnreconciledArguments args)
        {
            await Initialize();

            // Start transaction
            using var trx = TransactionFactory.ReadCommitted();

            // Preprocess and Validate
            await PermissionsPreprocessAndValidate(args.AccountId, args.AgentId, payload);

            // Save
            UnreconciledOutput output = await _behavior.Repository.Reconciliations__SaveAndLoad_Unreconciled(
                accountId : args.AccountId,
                agentId : args.AgentId,
                externalEntriesForSave : payload.ExternalEntries,
                reconciliations : payload.Reconciliations,
                deletedExternalEntryIds : payload.DeletedExternalEntryIds,
                deletedReconciliationIds : payload.DeletedReconciliationIds,
                asOfDate : args.AsOfDate,
                top : args.EntriesTop,
                skip : args.EntriesSkip,
                topExternal : args.ExternalEntriesTop,
                skipExternal : args.ExternalEntriesSkip,
                userId : UserId);

            trx.Complete();

            return(MapFromOutput(output));
        }