public async Task <TransactionDisbursementRelationship> Handle(CreateDisbursementsCommand request, CancellationToken cancellationToken)
            {
                if (request is null)
                {
                    throw new System.ArgumentNullException(nameof(request));
                }
                _validator.ValidateAndThrow(request);

                var disbursementsToCreate = DisbursementFactory.FromTransaction(
                    request.ActionstepMatterId,
                    request.Transaction,
                    request.TaxCodeIdWithGST,
                    request.TaxCodeIdNoGST);

                var createDisbursementsRequest = new CreateDisbursementsRequest();

                createDisbursementsRequest.Disbursements.AddRange(disbursementsToCreate);
                createDisbursementsRequest.TokenSetQuery = new TokenSetQuery(request.ActionstepUserId, request.ActionstepOrgKey);

                var createdDisbursements = await _actionstepService.Handle <ListDisbursementsResponse>(createDisbursementsRequest);

                var gstTaxableDisbursement = createdDisbursements.Disbursements.SingleOrDefault(d => d.Links.TaxCode == request.TaxCodeIdWithGST);
                var gstFreeDisbursement    = createdDisbursements.Disbursements.SingleOrDefault(d => d.Links.TaxCode == request.TaxCodeIdNoGST);

                return(new TransactionDisbursementRelationship(
                           request.Transaction.TransactionId,
                           request.ActionstepOrgKey,
                           request.ActionstepMatterId,
                           gstTaxableDisbursement?.Id,
                           gstFreeDisbursement?.Id));
            }
Exemplo n.º 2
0
        public void SimpleGstRoundedCorrectly()
        {
            // Arrange
            var         matterId = 2;
            Transaction source   = new Transaction()
            {
                TransactionId = 1,
                Matter        = matterId.ToString(CultureInfo.InvariantCulture),
                RetailPrice   = 65.35M,
                RetailGst     = 6.54M
            };

            int gstTaxCodeId    = 3;
            int nonGstTaxCodeId = 4;

            // Act
            var result = DisbursementFactory.FromTransaction(matterId, source, gstTaxCodeId, nonGstTaxCodeId);

            // Assert
            var disbursements = result.ToArray();

            var disbursementWithGst = disbursements.Single(d => d.Links.TaxCode == gstTaxCodeId);

            Assert.Equal(65.35M, disbursementWithGst.UnitPrice);
            Assert.False(disbursementWithGst.UnitPriceIncludesTax);
            Assert.Equal("GX-1-GST", disbursementWithGst.ImportExternalReference);
        }
Exemplo n.º 3
0
        public void WithoutGstCreatedCorrectly()
        {
            // Arrange
            var         matterId = 2;
            Transaction source   = new Transaction()
            {
                TransactionId = 1,
                Matter        = matterId.ToString(CultureInfo.InvariantCulture),
                RetailPrice   = 10,
                RetailGst     = 0
            };

            int gstTaxCodeId    = 3;
            int nonGstTaxCodeId = 4;

            // Act
            var result = DisbursementFactory.FromTransaction(matterId, source, gstTaxCodeId, nonGstTaxCodeId);

            // Assert
            var singleDisbursement = result.First();

            Assert.Equal(nonGstTaxCodeId, singleDisbursement.Links.TaxCode);
            Assert.Equal(10, singleDisbursement.UnitPrice);
            Assert.False(singleDisbursement.UnitPriceIncludesTax);
            Assert.Equal("GX-1-GSTFree", singleDisbursement.ImportExternalReference);
        }
Exemplo n.º 4
0
        public void SimpleTransactionToDisbursement()
        {
            var         matterId = 2;
            Transaction source   = new Transaction()
            {
                TransactionId       = 1,
                Matter              = matterId.ToString(CultureInfo.InvariantCulture),
                OrderId             = "OrderABC123",
                TransactionDateTime = new DateTimeOffset(2020, 1, 1, 1, 1, 0, TimeSpan.Zero),
                RetailPrice         = 10,
                RetailGst           = 1,
                WholesalePrice      = 10,
                WholesaleGst        = 1,
                Product             = new Product()
                {
                    ProductCode        = "ProductCode",
                    ProductDescription = "Product Description",
                    ProductSubGroup    = "Product Sub Group"
                }
            };

            int gstTaxCodeId    = 3;
            int nonGstTaxCodeId = 4;

            var result = DisbursementFactory.FromTransaction(matterId, source, gstTaxCodeId, nonGstTaxCodeId);

            var singleDisbursement = result.First();

            Assert.Equal(new LocalDate(2020, 1, 1), singleDisbursement.Date);
            Assert.Equal(2, singleDisbursement.Links.Action);
            Assert.Equal(@"GlobalX order OrderABC123, product 'Product Description', GST Taxable", singleDisbursement.Description);
            Assert.Equal(1, singleDisbursement.Quantity);
            Assert.Equal(10, singleDisbursement.UnitPrice);
            Assert.False(singleDisbursement.UnitPriceIncludesTax);
            Assert.Equal(3, singleDisbursement.Links.TaxCode);
            Assert.Equal("GX-1-GST", singleDisbursement.ImportExternalReference);
        }