コード例 #1
0
        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);
        }