public void Test_CreateLedgerRecords_GLTran_Record_Creation(string module, int?contragentID, string expectedContragentName)
        {
            //Arrange
            const decimal accountBegBalance = 5;

            SetupAccountsWithGLHistory(accountBegBalance, _finPeriodDataContext.FinPeriod201503.FinPeriodID);

            var glTran = new GLTran()
            {
                DebitAmt    = 5,
                CreditAmt   = 1,
                TranDesc    = "TranDesc",
                TranDate    = new DateTime(2015, 1, 3),
                BatchNbr    = "BN0001",
                RefNbr      = "REF0001",
                Module      = module,
                ReferenceID = contragentID
            };

            GAFRepositoryMock.Setup(repo => repo.GetPostedGLTrans(_branchDataContext.Branch.BranchID,
                                                                  _branchDataContext.Branch.LedgerID,
                                                                  _accountDataContext.AssetAccount.AccountID,
                                                                  _finPeriodDataContext.FinPeriod201503.FinPeriodID))
            .Returns(glTran.SingleToArray());

            //Action
            var ledgerRecord = _glgafLedgerRecordsCreator.CreateLedgerRecords(_gafPeriodDataContext.GAFPeriod)
                               .Last();

            //Assert
            Assert.Equal(glTran.TranDate, ledgerRecord.TransactionDate);
            Assert.Equal(_accountDataContext.AssetAccount.AccountCD, ledgerRecord.AccountID);
            Assert.Equal(_accountDataContext.AssetAccount.Description, ledgerRecord.AccountName);
            Assert.Equal(glTran.TranDesc, ledgerRecord.TransactionDescription);
            Assert.Equal(expectedContragentName, ledgerRecord.Name);
            Assert.Equal(glTran.BatchNbr, ledgerRecord.TransactionID);
            Assert.Equal(glTran.RefNbr, ledgerRecord.SourceDocumentID);
            Assert.Equal(glTran.Module, ledgerRecord.SourceType);

            Assert.Equal(glTran.DebitAmt, ledgerRecord.DebitAmount);
            Assert.Equal(glTran.CreditAmt, ledgerRecord.CreditAmount);
            Assert.Equal(accountBegBalance + (ledgerRecord.DebitAmount - ledgerRecord.CreditAmount), ledgerRecord.BalanceAmount);
        }
Example #2
0
        public void Test_CreateGAFRecordsForDocumentGroup_That_PurchaseRecords_Are_Generated(string tranTaxType, string taxID)
        {
            //Arrange
            var rate = _taxRevDataContext.TaxRevs.Single(taxRev => taxRev.TaxID == taxID).TaxRate.Value;

            var taxableGLTran = new GLTran()
            {
                TranDate      = TranDate,
                TranDesc      = TranDesc,
                BatchNbr      = BatchNbr,
                RefNbr        = RefNbr,
                TaxCategoryID = TaxCategoryID,
                BranchID      = BranchID
            };

            var curyInfo = new CurrencyInfo()
            {
                CuryID = CuryIDEUR
            };
            var taxCategoryDetail = new TaxCategoryDet()
            {
                TaxID = taxID, TaxCategoryID = TaxCategoryID
            };

            const decimal taxableAmt     = 100;
            decimal       taxAmt         = taxableAmt / rate;
            const decimal curyTaxableAmt = 200;
            decimal       curyTaxAmt     = curyTaxableAmt / rate;

            var taxTran = new TaxTran()
            {
                Module         = BatchModule.GL,
                TranType       = TaxTran.tranType.TranForward,
                RefNbr         = BatchNbr,
                TaxID          = taxID,
                TaxableAmt     = taxableAmt,
                TaxAmt         = taxAmt,
                CuryTaxableAmt = curyTaxableAmt,
                CuryTaxAmt     = curyTaxAmt,
                TaxType        = tranTaxType,
                LineRefNbr     = RefNbr,
                BranchID       = BranchID
            };

            var documentIDGroup = new DocumentIDGroup()
            {
                Module  = BatchModule.GL,
                RefNbrs = taxTran.RefNbr.SingleToList()
            };

            SetupRepositoryMethods(taxableGLTran.SingleToArray(), curyInfo, taxTran.SingleToArray(), documentIDGroup, BranchID,
                                   TaxPeriodID, taxID.SingleToArray(), taxCategoryDetail);

            //Action
            var recordsAggr    = _glDocumentGAFRecordsCreator.CreateGAFRecordsForDocumentGroup(documentIDGroup, BranchID, TaxPeriodID);
            var purchaseRecord = recordsAggr.PurchaseRecords.Single();

            //Assert
            Assert.Empty(recordsAggr.SupplyRecords);
            Assert.NotEmpty(recordsAggr.PurchaseRecords);

            Assert.Null(purchaseRecord.SupplierName);
            Assert.Null(purchaseRecord.SupplierBRN);
            Assert.Null(purchaseRecord.ImportDeclarationNumber);
            Assert.Equal(TranDate, purchaseRecord.InvoiceDate);
            Assert.Equal(string.Concat(BatchNbr, RefNbr), purchaseRecord.InvoiceNumber);
            Assert.Equal(1, purchaseRecord.LineNumber);
            Assert.Equal(TranDesc, purchaseRecord.ProductDescription);
            Assert.Equal(taxID, purchaseRecord.TaxCode);
            Assert.Equal(CuryIDEUR, purchaseRecord.ForeignCurrencyCode);
            Assert.Equal(taxableAmt, purchaseRecord.Amount);
            Assert.Equal(taxAmt, purchaseRecord.GSTAmount);
            Assert.Equal(curyTaxableAmt, purchaseRecord.ForeignCurrencyAmount);
            Assert.Equal(curyTaxAmt, purchaseRecord.ForeignCurrencyAmountGST);
        }
Example #3
0
        public void Test_CreateGAFRecordsForDocumentGroup_That_Sign_Is_Negative_When_Have_Reversed_Type(string tranTaxType)
        {
            //Arrange
            var taxID = _taxDataContext.VatTax.TaxID;

            var rate = _taxRevDataContext.TaxRevs.Single(taxRev => taxRev.TaxID == taxID).TaxRate.Value;

            var taxableGLTran = new GLTran()
            {
                TranDate      = TranDate,
                TranDesc      = TranDesc,
                BatchNbr      = BatchNbr,
                RefNbr        = RefNbr,
                TaxCategoryID = TaxCategoryID,
                BranchID      = BranchID
            };

            var curyInfo = new CurrencyInfo()
            {
                CuryID = CuryIDEUR
            };
            var taxCategoryDetail = new TaxCategoryDet()
            {
                TaxID = taxID, TaxCategoryID = TaxCategoryID
            };

            const decimal taxableAmt     = 100;
            decimal       taxAmt         = taxableAmt / rate;
            const decimal curyTaxableAmt = 200;
            decimal       curyTaxAmt     = curyTaxableAmt / rate;

            var taxTran = new TaxTran()
            {
                RefNbr         = BatchNbr,
                TaxID          = taxID,
                TaxableAmt     = taxableAmt,
                TaxAmt         = taxAmt,
                CuryTaxableAmt = curyTaxableAmt,
                CuryTaxAmt     = curyTaxAmt,
                TaxType        = tranTaxType,
                TranType       = TaxTran.tranType.TranReversed,
                LineRefNbr     = RefNbr,
                BranchID       = BranchID
            };

            var documentIDGroup = new DocumentIDGroup()
            {
                Module  = BatchModule.GL,
                RefNbrs = taxTran.RefNbr.SingleToList()
            };

            SetupRepositoryMethods(taxableGLTran.SingleToArray(), curyInfo, taxTran.SingleToArray(), documentIDGroup, BranchID,
                                   TaxPeriodID, taxID.SingleToArray(), taxCategoryDetail);

            //Action
            var recordsAggr = _glDocumentGAFRecordsCreator.CreateGAFRecordsForDocumentGroup(documentIDGroup, BranchID, TaxPeriodID);

            var gafRecord = tranTaxType == CSTaxType.Sales
                                ? (GAFRecordBase)recordsAggr.SupplyRecords.Single()
                                : (GAFRecordBase)recordsAggr.PurchaseRecords.Single();

            //Assert
            Assert.Equal(-taxableAmt, gafRecord.Amount);
            Assert.Equal(-taxAmt, gafRecord.GSTAmount);
            Assert.Equal(-curyTaxableAmt, gafRecord.ForeignCurrencyAmount);
            Assert.Equal(-curyTaxAmt, gafRecord.ForeignCurrencyAmountGST);
        }