Пример #1
0
        public void Test_CreateGAFRecordsForDocumentGroup_When_Document_Is_In_Base_Cury(string docType)
        {
            //Arrange
            TaxDataBuilderBase taxDataBuilder = null;

            taxDataBuilder = docType == TaxAdjustmentType.AdjustOutput
                                                                ? (TaxDataBuilderBase)GetService <ARTaxDataBuilder>()
                                                                : GetService <APTaxDataBuilder>();

            var taxData = taxDataBuilder.CreateTaxDataItems(TaxDataContext.VatTax.TaxID.SingleToArray())
                          .Single();

            const string docDesc = "doc1 desc";

            var taxAdjustment = new TX.TaxAdjustment()
            {
                DocType = docType,
                RefNbr  = DocumentDataContext.RefNbr,
                DocDate = DocumentDataContext.DocDate,
                CuryID  = CompanyDataContext.Company.BaseCuryID,
                DocDesc = docDesc
            };

            const decimal taxableAmt     = 100;
            const decimal taxAmt         = 7;
            const decimal curyTaxableAmt = 200;
            const decimal curyTaxAmt     = 14;

            var taxTran = new TaxTran()
            {
                RefNbr         = DocumentDataContext.RefNbr,
                TaxID          = taxData.TaxID,
                TaxableAmt     = taxableAmt,
                TaxAmt         = taxAmt,
                CuryTaxableAmt = curyTaxableAmt,
                CuryTaxAmt     = curyTaxAmt,
                TaxType        = taxData.TranTaxType
            };

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

            SetupRepositoryMethods(taxAdjustment.SingleToArray(), taxTran.SingleToArray(), documentIDGroup, TaxPeriodID);

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

            var gafRecord = taxAdjustment.DocType == TaxAdjustmentType.AdjustOutput
                                ? (GAFRecordBase)recordsAggr.SupplyRecords.Single()
                                : (GAFRecordBase)recordsAggr.PurchaseRecords.Single();

            //Assert
            Assert.Equal(taxableAmt, gafRecord.Amount);
            Assert.Equal(taxAmt, gafRecord.GSTAmount);
            Assert.Equal(ForeignCurrencyCodeForDocumentInBaseCury, gafRecord.ForeignCurrencyCode);
            Assert.Equal(0, gafRecord.ForeignCurrencyAmount);
            Assert.Equal(0, gafRecord.ForeignCurrencyAmountGST);
        }
Пример #2
0
        public void Test_CreateGAFRecordsForDocumentGroup_That_SupplyRecords_Are_Generated(string docType, string taxID)
        {
            //Arrange
            TaxDataBuilderBase taxDataBuilder = null;

            taxDataBuilder = docType == TaxAdjustmentType.AdjustOutput
                                                                ? (TaxDataBuilderBase)GetService <ARTaxDataBuilder>()
                                                                : GetService <APTaxDataBuilder>();

            var taxData = taxDataBuilder.CreateTaxDataItems(taxID.SingleToArray())
                          .Single();

            const string docDesc = "doc1 desc";

            var taxAdjustment = new TX.TaxAdjustment()
            {
                DocType = docType,
                RefNbr  = DocumentDataContext.RefNbr,
                DocDate = DocumentDataContext.DocDate,
                CuryID  = DocumentDataContext.CuryIDGBP,
                DocDesc = docDesc
            };

            const decimal taxableAmt     = 100;
            decimal       taxAmt         = taxableAmt / taxData.Rate;
            const decimal curyTaxableAmt = 200;
            decimal       curyTaxAmt     = curyTaxableAmt / taxData.Rate;

            var taxTran = new TaxTran()
            {
                RefNbr         = DocumentDataContext.RefNbr,
                TaxID          = taxData.TaxID,
                TaxableAmt     = taxableAmt,
                TaxAmt         = taxAmt,
                CuryTaxableAmt = curyTaxableAmt,
                CuryTaxAmt     = curyTaxAmt,
                TaxType        = taxData.TranTaxType
            };

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

            SetupRepositoryMethods(taxAdjustment.SingleToArray(), taxTran.SingleToArray(), documentIDGroup, TaxPeriodID);

            //Action
            var recordsAggr  = _taxAdjustmentGAFRecordsCreator.CreateGAFRecordsForDocumentGroup(documentIDGroup, BranchID, TaxPeriodID);
            var supplyRecord = recordsAggr.SupplyRecords.Single();

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

            Assert.Null(supplyRecord.CustomerName);
            Assert.Null(supplyRecord.CustomerBRN);
            Assert.Null(supplyRecord.Country);
            Assert.Equal(DocumentDataContext.DocDate, supplyRecord.InvoiceDate);
            Assert.Equal(DocumentDataContext.RefNbr, supplyRecord.InvoiceNumber);
            Assert.Equal(1, supplyRecord.LineNumber);
            Assert.Equal(docDesc, supplyRecord.ProductDescription);
            Assert.Equal(taxID, supplyRecord.TaxCode);
            Assert.Equal(DocumentDataContext.CuryIDGBP, supplyRecord.ForeignCurrencyCode);
            Assert.Equal(taxableAmt, supplyRecord.Amount);
            Assert.Equal(taxAmt, supplyRecord.GSTAmount);
            Assert.Equal(curyTaxableAmt, supplyRecord.ForeignCurrencyAmount);
            Assert.Equal(curyTaxAmt, supplyRecord.ForeignCurrencyAmountGST);
        }