private IList <PurchaseRecord> CreatePurchaseRecordsByAPInvoices(DocumentIDGroup documentIDGroup, GAFPeriod gafPeriod) { var resultRecords = new List <PurchaseRecord>(); var apInvoices = _gafRepository.GetAPInvoicesByIDs(documentIDGroup.DocumentType, documentIDGroup.RefNbrs.ToArray()); //module of taxTran is not honest, it alwayes equals to AP for all Account Payable documents var documentGroupsByModule = apInvoices.GroupBy(apReg => apReg.OrigModule); foreach (var documentGroupByModule in documentGroupsByModule) { var documentGroup = new DocumentGroup <APInvoice>() { Module = documentGroupByModule.Key, DocumentType = documentIDGroup.DocumentType, DocumentsByRefNbr = documentGroupByModule.ToDictionary(invoice => invoice.RefNbr, invoice => invoice) }; var records = _apInvoiceGAFRecordsCreator.CreateGAFRecordsForDocumentGroup(documentGroup, gafPeriod.TaxAgencyID, gafPeriod.TaxPeriodID); resultRecords.AddRange(records); } return(resultRecords); }
public DocumentIDGroup GetNextDocumentGroup() { if (_currentDocumentGroupIndex >= _documentGroups.Count) { return(null); } var currentGroup = _documentGroups[_currentDocumentGroupIndex]; var remainingCount = currentGroup.RefNbrs.Count - _currentDocumentRefNbrIndex; var countToTake = Math.Min(remainingCount, MaxCountToTake); var documentGroup = new DocumentIDGroup() { Module = currentGroup.Module, DocumentTypes = currentGroup.DocumentTypes, RefNbrs = currentGroup.RefNbrs.GetRange(_currentDocumentRefNbrIndex, countToTake) }; _currentDocumentRefNbrIndex += countToTake; if (_currentDocumentRefNbrIndex == currentGroup.RefNbrs.Count) { _currentDocumentGroupIndex += 1; _currentDocumentRefNbrIndex = 0; } return(documentGroup); }
private void CreateGafRecordsByCADocuments(DocumentIDGroup documentIDGroup, GAFPeriod gafPeriod, out IList <PurchaseRecord> purchaseRecords, out IList <SupplyRecord> supplyRecords) { purchaseRecords = new List <PurchaseRecord>(); supplyRecords = new List <SupplyRecord>(); var caAdjs = _gafRepository.GetCAAdjsByIDs(documentIDGroup.DocumentType, documentIDGroup.RefNbrs.ToArray()); var caAdjGroupsByDrCr = caAdjs.GroupBy(caAdj => caAdj.DrCr); foreach (var caAdjGroupByDrCr in caAdjGroupsByDrCr) { var documentGroup = new DocumentGroup <CAAdj>() { Module = documentIDGroup.Module, DocumentType = documentIDGroup.DocumentType, DocumentsByRefNbr = caAdjGroupByDrCr.ToDictionary(caAdj => caAdj.AdjRefNbr, caAdj => caAdj) }; if (caAdjGroupByDrCr.Key == CADrCr.CACredit) { purchaseRecords = _caDocumentPurchaseGAFRecordsCreator.CreateGAFRecordsForDocumentGroup(documentGroup, gafPeriod.TaxAgencyID, gafPeriod.TaxPeriodID); } else { supplyRecords = _caDocumentSupplyGAFRecordsCreator.CreateGAFRecordsForDocumentGroup(documentGroup, gafPeriod.TaxAgencyID, gafPeriod.TaxPeriodID); } } }
protected override void LoadData(DocumentIDGroup documentIDGroup, int?branchID, string taxPeriodID) { base.LoadData(documentIDGroup, branchID, taxPeriodID); var refNbrs = documentIDGroup.RefNbrs.ToArray(); _taxAdjustmentsByRefNbr = GafRepository.GetTaxAdjustments(documentIDGroup.DocumentType, refNbrs) .ToDictionary(taxAdj => taxAdj.RefNbr, taxAdj => taxAdj); }
private void CreateGAFDataByDocumentGroup(DocumentIDGroup documentIDGroup, GAFPeriod gafPeriod, FooterRecord footerRecord) { IList <SupplyRecord> supplyRecords = new List <SupplyRecord>(); IList <PurchaseRecord> purchaseRecords = new List <PurchaseRecord>(); if (documentIDGroup.Module == BatchModule.AP) { if (documentIDGroup.DocumentType == APDocType.Check) { purchaseRecords = CreatePurchaseRecordsByAPPayments(documentIDGroup, gafPeriod); } else { purchaseRecords = CreatePurchaseRecordsByAPInvoices(documentIDGroup, gafPeriod); } } else if (documentIDGroup.Module == BatchModule.AR) { supplyRecords = CreateSupplyRecordsByARInvoices(documentIDGroup, gafPeriod); } else if (documentIDGroup.Module == BatchModule.CA) { CreateGafRecordsByCADocuments(documentIDGroup, gafPeriod, out purchaseRecords, out supplyRecords); } else if (documentIDGroup.Module == BatchModule.GL && (documentIDGroup.DocumentTypes.Contains(TaxAdjustmentType.AdjustInput) || documentIDGroup.DocumentTypes.Contains(TaxAdjustmentType.AdjustOutput))) { var documentRecordAggregate = _taxAdjustmentGAFRecordsCreator.CreateGAFRecordsForDocumentGroup(documentIDGroup, gafPeriod.BranchID, gafPeriod.TaxPeriodID); supplyRecords = documentRecordAggregate.SupplyRecords; purchaseRecords = documentRecordAggregate.PurchaseRecords; } else if (documentIDGroup.Module == BatchModule.GL && documentIDGroup.DocumentTypes.Intersect(_glTaxDocumentTypes).Any()) { var documentRecordAggregate = _glDocumentGAFRecordsCreator.CreateGAFRecordsForDocumentGroup(documentIDGroup, gafPeriod.BranchID, gafPeriod.TaxPeriodID); supplyRecords = documentRecordAggregate.SupplyRecords; purchaseRecords = documentRecordAggregate.PurchaseRecords; } WritePuchaseRecords(purchaseRecords); AddAmountsAndCountToFooterRecord(footerRecord, purchaseRecords); WriteSupplyRecords(supplyRecords); AddAmountsAndCountToFooterRecord(footerRecord, supplyRecords); }
protected virtual void LoadData(DocumentIDGroup documentIDGroup, int?branchID, string taxPeriodID) { var refNbrs = documentIDGroup.RefNbrs.ToArray(); TaxTransByRefNbr = GafRepository.GetTaxTransForDocuments(documentIDGroup.Module, documentIDGroup.DocumentTypes.ToArray(), refNbrs, taxPeriodID) .GroupBy(taxTran => taxTran.RefNbr) .ToDictionary(group => group.Key, group => group.ToList()); var usedTaxIDs = TaxTransByRefNbr.Values.SelectMany(taxTranList => taxTranList.Select(taxTran => taxTran.TaxID)) .Distinct() .ToArray(); Taxes = GafRepository.GetTaxesByIDs(usedTaxIDs) .ToDictionary(tax => tax.TaxID, tax => tax); }
private IList <PurchaseRecord> CreatePurchaseRecordsByAPPayments(DocumentIDGroup documentIDGroup, GAFPeriod gafPeriod) { var apRegistersByRefNbrs = _gafRepository.GetAPRegistersByIDs(documentIDGroup.DocumentType, documentIDGroup.RefNbrs.ToArray()) .ToDictionary(apReg => apReg.RefNbr, apReg => apReg); var documentGroup = new DocumentGroup <APRegister>() { Module = documentIDGroup.Module, DocumentType = documentIDGroup.DocumentType, DocumentsByRefNbr = apRegistersByRefNbrs }; var purchaseRecords = _apPaymentGAFRecordsCreator.CreateGAFRecordsForDocumentGroup(documentGroup, gafPeriod.TaxAgencyID, gafPeriod.TaxPeriodID); return(purchaseRecords); }
private void SetupRepositoryMethods(ICollection <GLTran> glTrans, CurrencyInfo curyInfo, ICollection <TaxTran> taxTrans, DocumentIDGroup documentIDGroup, int?branchID, string taxPeriodID, string[] taxIDs, TaxCategoryDet taxCategoryDet) { GAFRepositoryMock.Setup(repo => repo.GetTaxableGLTransWithCuryInfoGroupedByDocumentAttrAndTaxCategory(branchID, It.Is <string[]>(refNbrs => refNbrs.SequenceEqual(documentIDGroup.RefNbrs)))) .Returns(glTrans.Select(glTran => new PXResult <GLTran, CurrencyInfo>(glTran, curyInfo))); GAFRepositoryMock.Setup(repo => repo.GetTaxTransForDocuments(documentIDGroup.Module, It.Is <string[]>(refNbrs => refNbrs.SequenceEqual(documentIDGroup.DocumentTypes)), It.Is <string[]>(refNbrs => refNbrs.SequenceEqual(documentIDGroup.RefNbrs)), taxPeriodID)) .Returns(taxTrans); GAFRepositoryMock.Setup(repo => repo.GetTaxCategoryDetsForTaxIDs(It.Is <string[]>(pTaxIDs => pTaxIDs.SequenceEqual(taxIDs)))) .Returns(taxCategoryDet.SingleToArray()); }
private IList <SupplyRecord> CreateSupplyRecordsByARInvoices(DocumentIDGroup documentIDGroup, GAFPeriod gafPeriod) { var resultRecords = new List <SupplyRecord>(); IDocumentGafRecordCreator <ARInvoice, SupplyRecord> documentGafRecordCreator = null; var arInvoices = _gafRepository.GetARInvoicesByIDs(documentIDGroup.DocumentType, documentIDGroup.RefNbrs.ToArray()); //module of taxTran is not honest, it alwayes equals to AR for all Account Receivable documents var documentGroupsByModule = arInvoices.GroupBy(apReg => apReg.OrigModule); foreach (var documentGroupByModule in documentGroupsByModule) { var documentGroup = new DocumentGroup <ARInvoice>() { Module = documentIDGroup.Module, DocumentType = documentIDGroup.DocumentType }; if (documentGroupByModule.Key == BatchModule.SO) { documentGafRecordCreator = _arInvoiceFromSOGafRecordsCreator; } else { documentGafRecordCreator = _arInvoiceGAFRecordsCreator; } documentGroup.DocumentsByRefNbr = documentGroupByModule.ToDictionary(invoice => invoice.RefNbr, invoice => invoice); var supplyRecords = documentGafRecordCreator.CreateGAFRecordsForDocumentGroup(documentGroup, gafPeriod.TaxAgencyID, gafPeriod.TaxPeriodID); resultRecords.AddRange(supplyRecords); } return(resultRecords); }
public DocumentRecordsAggregate CreateGAFRecordsForDocumentGroup(DocumentIDGroup documentIDGroup, int?branchID, string taxPeriodID) { LoadData(documentIDGroup, branchID, taxPeriodID); var resultRecordsAggregate = new DocumentRecordsAggregate(); foreach (var refNbr in documentIDGroup.RefNbrs) { var documentId = new DocumentID() { Module = documentIDGroup.Module, RefNbr = refNbr }; var documentRecordsAggregate = CreateRecordsByDocument(documentId); resultRecordsAggregate.PurchaseRecords.AddRange(documentRecordsAggregate.PurchaseRecords); resultRecordsAggregate.SupplyRecords.AddRange(documentRecordsAggregate.SupplyRecords); } return(resultRecordsAggregate); }
protected override void LoadData(DocumentIDGroup documentIDGroup, int?branchID, string taxPeriodID) { base.LoadData(documentIDGroup, branchID, taxPeriodID); var refNbrs = documentIDGroup.RefNbrs.ToArray(); _taxableGLTransWithCuryInfo = GafRepository.GetTaxableGLTransWithCuryInfoGroupedByDocumentAttrAndTaxCategory(branchID, refNbrs) .ToDictionary(row => { var tran = (GLTran)row; return(new TaxableGLTranKey() { BranchID = tran.BranchID, RefNbr = tran.RefNbr, BatchNbr = tran.BatchNbr, TaxableCategoryID = tran.TaxCategoryID }); } ); _taxCategoryDetsByTaxID = GafRepository.GetTaxCategoryDetsForTaxIDs(Taxes.Keys.ToArray()) .GroupBy(taxCategoryDet => taxCategoryDet.TaxID, taxCategoryDet => taxCategoryDet) .ToDictionary(group => group.Key, group => group.ToArray()); }
private void SetupRepositoryMethods(ICollection <TX.TaxAdjustment> taxAdjustments, ICollection <TaxTran> taxTrans, DocumentIDGroup documentIDGroup, string taxPeriodID) { GAFRepositoryMock.Setup <IEnumerable <TX.TaxAdjustment> >(repo => repo.GetTaxAdjustments(documentIDGroup.DocumentType, It.Is <string[]>(refNbrs => refNbrs.SequenceEqual(documentIDGroup.RefNbrs)))) .Returns(taxAdjustments); GAFRepositoryMock.Setup(repo => repo.GetTaxTransForDocuments(documentIDGroup.Module, It.Is <string[]>(docTypes => docTypes.SequenceEqual(documentIDGroup.DocumentTypes)), It.Is <string[]>(refNbrs => refNbrs.SequenceEqual(documentIDGroup.RefNbrs)), taxPeriodID)) .Returns(taxTrans); }
public DocumentRecordsAggregate Test_CreateGAFRecordsForDocumentGroup_For_Many_Documents_Taxes_And_TaxTrans(string docType) { //Arrange var vatTaxID = TaxDataContext.VatTax.TaxID; var vatTaxID2 = TaxDataContext.VatTax2.TaxID; var taxDataItems = _arTaxDataBuilder.CreateTaxDataItems(new[] { vatTaxID, vatTaxID2 }); var taxAdjustments = new[] { new TX.TaxAdjustment() { DocType = docType, RefNbr = DocumentDataContext.RefNbr, DocDate = DocumentDataContext.DocDate, CuryID = DocumentDataContext.CuryIDGBP, DocDesc = "doc1 desc" }, new TX.TaxAdjustment() { DocType = docType, RefNbr = DocumentDataContext.RefNbr2, DocDate = DocumentDataContext.DocDate2, CuryID = DocumentDataContext.CuryIDEUR, DocDesc = "doc2 desc" } }; #region TaxTrans var taxTranRecordID = 1; var taxTrans = new TaxTran[] { //Tax Adjustment 1 new TaxTran() { RefNbr = DocumentDataContext.RefNbr, TaxID = vatTaxID, TaxableAmt = 100, TaxAmt = 7, CuryTaxableAmt = 200, CuryTaxAmt = 14, RecordID = taxTranRecordID++, TaxType = taxDataItems[0].TranTaxType }, new TaxTran() { RefNbr = DocumentDataContext.RefNbr, TaxID = TaxDataContext.VatTax.TaxID, TaxableAmt = 150, TaxAmt = 10.5m, CuryTaxableAmt = 300, CuryTaxAmt = 21, RecordID = taxTranRecordID++, TaxType = taxDataItems[0].TranTaxType }, new TaxTran() { RefNbr = DocumentDataContext.RefNbr, TaxID = TaxDataContext.VatTax2.TaxID, TaxableAmt = 110, TaxAmt = 11, CuryTaxableAmt = 220, CuryTaxAmt = 22, RecordID = taxTranRecordID++, TaxType = taxDataItems[1].TranTaxType }, //Tax Adjustment 2 new TaxTran() { RefNbr = DocumentDataContext.RefNbr2, TaxID = TaxDataContext.VatTax.TaxID, TaxableAmt = 400, TaxAmt = 28, CuryTaxableAmt = 800, CuryTaxAmt = 56, RecordID = taxTranRecordID++, TaxType = taxDataItems[0].TranTaxType }, new TaxTran() { RefNbr = DocumentDataContext.RefNbr2, TaxID = TaxDataContext.VatTax2.TaxID, TaxableAmt = 600, TaxAmt = 42, CuryTaxableAmt = 1200, CuryTaxAmt = 84, RecordID = taxTranRecordID++, TaxType = taxDataItems[1].TranTaxType }, new TaxTran() { RefNbr = DocumentDataContext.RefNbr2, TaxID = TaxDataContext.VatTax2.TaxID, TaxableAmt = 330, TaxAmt = 33, CuryTaxableAmt = 660, CuryTaxAmt = 66, RecordID = taxTranRecordID++, TaxType = taxDataItems[1].TranTaxType }, }; #endregion var documentIDGroup = new DocumentIDGroup() { Module = BatchModule.GL, DocumentType = docType, RefNbrs = taxAdjustments.Select(taxAdj => taxAdj.RefNbr).ToList() }; SetupRepositoryMethods(taxAdjustments, taxTrans, documentIDGroup, TaxPeriodID); //Action return(_taxAdjustmentGAFRecordsCreator.CreateGAFRecordsForDocumentGroup(documentIDGroup, BranchID, TaxPeriodID)); }
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_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); }
public void Test_CreateGAFRecordsForDocumentGroup_Batch_Contains_Two_RefNbrs() { //Arrange var taxID = _taxDataContext.VatTax.TaxID; var taxableGLTrans = new[] { new GLTran() { TranDate = TranDate, TranDesc = TranDesc, BatchNbr = BatchNbr, RefNbr = RefNbr, TaxCategoryID = TaxCategoryID, BranchID = BranchID }, new GLTran() { TranDate = TranDate2, TranDesc = TranDesc2, BatchNbr = BatchNbr, RefNbr = RefNbr2, TaxCategoryID = TaxCategoryID, BranchID = BranchID }, }; var curyInfo = new CurrencyInfo() { CuryID = CuryIDEUR }; var taxCategoryDetail = new TaxCategoryDet() { TaxID = taxID, TaxCategoryID = TaxCategoryID }; var taxTrans = new[] { new TaxTran() { Module = BatchModule.GL, TranType = TaxTran.tranType.TranForward, RefNbr = BatchNbr, TaxID = taxID, TaxableAmt = 100, TaxAmt = 7, CuryTaxableAmt = 200, CuryTaxAmt = 14, TaxType = CSTaxType.Sales, LineRefNbr = RefNbr, BranchID = BranchID }, new TaxTran() { Module = BatchModule.GL, TranType = TaxTran.tranType.TranForward, RefNbr = BatchNbr, TaxID = taxID, TaxableAmt = 300, TaxAmt = 21, CuryTaxableAmt = 600, CuryTaxAmt = 42, TaxType = CSTaxType.Sales, LineRefNbr = RefNbr2, BranchID = BranchID }, }; var documentIDGroup = new DocumentIDGroup() { Module = BatchModule.GL, RefNbrs = BatchNbr.SingleToList() }; SetupRepositoryMethods(taxableGLTrans, curyInfo, taxTrans, documentIDGroup, BranchID, TaxPeriodID, taxID.SingleToArray(), taxCategoryDetail); //Action var recordsAggr = _glDocumentGAFRecordsCreator.CreateGAFRecordsForDocumentGroup(documentIDGroup, BranchID, TaxPeriodID); //Assert Approvals.VerifyAll(recordsAggr.SupplyRecords, "supplyRecords", record => record.Dump()); }
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); }