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); }
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); }
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); }
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); }