예제 #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);
        }
예제 #2
0
        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));
        }