Example #1
0
        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);
        }
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);
        }