public void TestMissingHeaderFooter() { // Initialise PSB with some records, but not the header / footer NPOI.HSSF.Record.Record[] recs = { new HCenterRecord(), new VCenterRecord(), }; RecordStream rs = new RecordStream(Arrays.AsList(recs), 0); PageSettingsBlock psb = new PageSettingsBlock(rs); // serialize the PSB to see what records come out RecordInspector.RecordCollector rc = new RecordInspector.RecordCollector(); psb.VisitContainedRecords(rc); NPOI.HSSF.Record.Record[] outRecs = rc.Records; if (outRecs.Length == 2) { throw new AssertionException("PageSettingsBlock didn't add missing header/footer records"); } Assert.AreEqual(4, outRecs.Length); Assert.AreEqual(typeof(HeaderRecord), outRecs[0].GetType()); Assert.AreEqual(typeof(FooterRecord), outRecs[1].GetType()); Assert.AreEqual(typeof(HCenterRecord), outRecs[2].GetType()); Assert.AreEqual(typeof(VCenterRecord), outRecs[3].GetType()); // make sure the Added header / footer records are empty HeaderRecord hr = (HeaderRecord)outRecs[0]; Assert.AreEqual("", hr.Text); FooterRecord fr = (FooterRecord)outRecs[1]; Assert.AreEqual("", fr.Text); }
/** * Creates the Footer Record and sets it to nothing/0 length */ private static FooterRecord CreateFooter() { FooterRecord retval = new FooterRecord(); retval.FooterLength = ((byte)0); retval.Footer = (null); return(retval); }
private void AddAmountsAndCountToFooterRecord(FooterRecord footerRecord, IEnumerable <SupplyRecord> purchaseRecords) { foreach (var purchaseRecord in purchaseRecords) { footerRecord.SupplyRecordsCount++; footerRecord.SupplyAmountSum += purchaseRecord.Amount; footerRecord.SupplyGSTAmountSum += purchaseRecord.GSTAmount; } }
private void AddAmountsAndCountToFooterRecord(FooterRecord footerRecord, IEnumerable <LedgerRecord> ledgerRecords) { foreach (var ledgerRecord in ledgerRecords) { footerRecord.LedgerRecordsCount++; footerRecord.DebitSum += ledgerRecord.DebitAmount; footerRecord.CreditSum += ledgerRecord.CreditAmount; footerRecord.BalanceSum += ledgerRecord.BalanceAmount; } }
/** * Creates a PageSettingsBlock with default settings */ public PageSettingsBlock() { _plsRecords = new List <PLSAggregate>(); _rowBreaksRecord = new HorizontalPageBreakRecord(); _columnBreaksRecord = new VerticalPageBreakRecord(); header = new HeaderRecord(string.Empty); footer = new FooterRecord(string.Empty); _hCenter = CreateHCenter(); _vCenter = CreateVCenter(); printSetup = CreatePrintSetup(); }
/** * Creates a PageSettingsBlock with default settings */ public PageSettingsBlock() { _rowBreaksRecord = new HorizontalPageBreakRecord(); _columnBreaksRecord = new VerticalPageBreakRecord(); _rowRecords = new ArrayList(); header = CreateHeader(); footer = CreateFooter(); _hCenter = CreateHCenter(); _vCenter = CreateVCenter(); printSetup = CreatePrintSetup(); }
protected override void SetHeaderFooterText(string text) { FooterRecord hfr = _psb.Footer; if (hfr == null) { hfr = new FooterRecord(text); _psb.Footer=(hfr); } else { hfr.Text=(text); } }
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); }
public override void Dispose() { _rowBreaksRecord = null; _columnBreaksRecord = null; header = null; footer = null; _hCenter = null; _vCenter = null; _leftMargin = null; _rightMargin = null; _topMargin = null; _bottomMargin = null; _pls = null; printSetup = null; _bitmap = null; }
public void WriteFooterRecord(FooterRecord aggregationFooterRecord, StringBuilder stringBuilder) { Write(stringBuilder, "F"); Write(stringBuilder, aggregationFooterRecord.PurchaseRecordsCount); Write(stringBuilder, RoundAmount(aggregationFooterRecord.PurchaseAmountSum)); Write(stringBuilder, RoundAmount(aggregationFooterRecord.PurchaseGSTAmountSum)); Write(stringBuilder, aggregationFooterRecord.SupplyRecordsCount); Write(stringBuilder, RoundAmount(aggregationFooterRecord.SupplyAmountSum)); Write(stringBuilder, RoundAmount(aggregationFooterRecord.SupplyGSTAmountSum)); Write(stringBuilder, aggregationFooterRecord.LedgerRecordsCount); Write(stringBuilder, RoundAmount(aggregationFooterRecord.DebitSum)); Write(stringBuilder, RoundAmount(aggregationFooterRecord.CreditSum)); WriteLast(stringBuilder, RoundAmount(aggregationFooterRecord.BalanceSum)); }
private static FooterRecord CreateFooterRecord() { FooterRecord retval = new FooterRecord(string.Empty); return(retval); }
public InternalChart(RecordStream rs) { _plsRecords = new List <PLSAggregate>(); records = new List <RecordBase>(128); if (rs.PeekNextSid() != BOFRecord.sid) { throw new Exception("BOF record expected"); } BOFRecord bof = (BOFRecord)rs.GetNext(); if (bof.Type != BOFRecordType.Chart) { throw new RuntimeException("Bad BOF record type"); } records.Add(bof); while (rs.HasNext()) { int recSid = rs.PeekNextSid(); Record.Record rec = rs.GetNext(); if (recSid == EOFRecord.sid) { records.Add(rec); break; } if (recSid == ChartRecord.sid) { continue; } if (recSid == ChartFRTInfoRecord.sid) { _chartFrtInfo = (ChartFRTInfoRecord)rec; } else if (recSid == HeaderRecord.sid) { header = (HeaderRecord)rec; } else if (recSid == FooterRecord.sid) { footer = (FooterRecord)rec; } else if (recSid == HCenterRecord.sid) { _hCenter = (HCenterRecord)rec; } else if (recSid == VCenterRecord.sid) { _vCenter = (VCenterRecord)rec; } else if (recSid == LeftMarginRecord.sid) { _leftMargin = (LeftMarginRecord)rec; } else if (recSid == RightMarginRecord.sid) { _rightMargin = (RightMarginRecord)rec; } else if (recSid == TopMarginRecord.sid) { _topMargin = (TopMarginRecord)rec; } else if (recSid == BottomMarginRecord.sid) { _bottomMargin = (BottomMarginRecord)rec; } else if (recSid == UnknownRecord.PLS_004D) // PLS { PLSAggregate pls = new PLSAggregate(rs); PLSAggregateVisitor rv = new PLSAggregateVisitor(records); pls.VisitContainedRecords(rv); _plsRecords.Add(pls); continue; } else if (recSid == PrintSetupRecord.sid) { printSetup = (PrintSetupRecord)rec; } else if (recSid == PrintSizeRecord.sid) { _printSize = (PrintSizeRecord)rec; } else if (recSid == HeaderFooterRecord.sid) { HeaderFooterRecord hf = (HeaderFooterRecord)rec; if (hf.IsCurrentSheet) { _headerFooter = hf; } else { _sviewHeaderFooters.Add(hf); } } else if (recSid == ProtectRecord.sid) { _protect = (ProtectRecord)rec; } records.Add(rec); } }
private bool ReadARecord(RecordStream rs) { switch (rs.PeekNextSid()) { case HorizontalPageBreakRecord.sid: CheckNotPresent(_rowBreaksRecord); _rowBreaksRecord = (PageBreakRecord)rs.GetNext(); break; case VerticalPageBreakRecord.sid: CheckNotPresent(_columnBreaksRecord); _columnBreaksRecord = (PageBreakRecord)rs.GetNext(); break; case HeaderRecord.sid: CheckNotPresent(header); header = (HeaderRecord)rs.GetNext(); break; case FooterRecord.sid: CheckNotPresent(footer); footer = (FooterRecord)rs.GetNext(); break; case HCenterRecord.sid: CheckNotPresent(_hCenter); _hCenter = (HCenterRecord)rs.GetNext(); break; case VCenterRecord.sid: CheckNotPresent(_vCenter); _vCenter = (VCenterRecord)rs.GetNext(); break; case LeftMarginRecord.sid: CheckNotPresent(_leftMargin); _leftMargin = (LeftMarginRecord)rs.GetNext(); break; case RightMarginRecord.sid: CheckNotPresent(_rightMargin); _rightMargin = (RightMarginRecord)rs.GetNext(); break; case TopMarginRecord.sid: CheckNotPresent(_topMargin); _topMargin = (TopMarginRecord)rs.GetNext(); break; case BottomMarginRecord.sid: CheckNotPresent(_bottomMargin); _bottomMargin = (BottomMarginRecord)rs.GetNext(); break; case UnknownRecord.PLS_004D: // PLS _plsRecords.Add(new PLSAggregate(rs)); break; case PrintSetupRecord.sid: CheckNotPresent(printSetup); printSetup = (PrintSetupRecord)rs.GetNext(); break; case UnknownRecord.BITMAP_00E9: // BITMAP CheckNotPresent(_bitmap); _bitmap = rs.GetNext(); break; case UnknownRecord.PRINTSIZE_0033: CheckNotPresent(_printSize); _printSize = rs.GetNext(); break; case HeaderFooterRecord.sid: HeaderFooterRecord hf = (HeaderFooterRecord)rs.GetNext(); if (hf.IsCurrentSheet) { _headerFooter = hf; } else { _sviewHeaderFooters.Add(hf); } break; default: // all other record types are not part of the PageSettingsBlock return(false); } return(true); }
/// <summary> /// Creates GST File data. /// </summary> public GSTAuditFile Create(GAFPeriod gafPeriod, DateTime creationDate) { if (gafPeriod == null) { throw new ArgumentNullException(nameof(gafPeriod)); } var validationResult = _gafValidator.ValidateTaxYearStructure(_gafRepository.GetTaxPeriodByKey(gafPeriod.BranchID, gafPeriod.TaxAgencyID, gafPeriod.TaxPeriodID)); validationResult.RaiseIfHasError(); var documentIds = _gafRepository.GetReportedDocuments(gafPeriod.BranchID, gafPeriod.TaxAgencyID, gafPeriod.TaxPeriodID) .ToArray(); if (!documentIds.Any()) { return(null); } #region Initialization var glDocumentIds = documentIds.Where(documentId => _glTaxDocumentTypes.Contains(documentId.DocType)) .ToArray(); var documentGroups = SplitToDocumentGroups(documentIds.Except(glDocumentIds)); if (glDocumentIds.Any()) { var glDocumentGroup = BuildGLDocumentGroup(glDocumentIds); documentGroups.Add(glDocumentGroup); } var documentProcessingQueue = new GAFDocumentProcessingQueue(documentGroups); var gafDataStringBuilder = new StringBuilder(); _purchaseGAFDataStringBuilder = new StringBuilder(); _supplyGAFDataStringBuilder = new StringBuilder(); var footerRecord = new FooterRecord(); var gstAuditFile = new GSTAuditFile(); #endregion #region Processing SetGAFVersion(gstAuditFile, gafPeriod); var companyRecord = CreateCompanyRecord(gafPeriod, gstAuditFile, creationDate); _gafRecordWriter.WriteCompanyRecord(companyRecord, gafDataStringBuilder); #region Documents var documentGroup = documentProcessingQueue.GetNextDocumentGroup(); while (documentGroup != null) { CreateGAFDataByDocumentGroup(documentGroup, gafPeriod, footerRecord); _gafRepository.ClearCaches(); documentGroup = documentProcessingQueue.GetNextDocumentGroup(); } gafDataStringBuilder.Append(_purchaseGAFDataStringBuilder); gafDataStringBuilder.Append(_supplyGAFDataStringBuilder); #endregion #region Ledger var ledgerRecords = _glgafLedgerRecordsCreator.CreateLedgerRecords(gafPeriod); AddAmountsAndCountToFooterRecord(footerRecord, ledgerRecords); foreach (var ledgerRecord in ledgerRecords) { _gafRecordWriter.WriteLedgerRecord(ledgerRecord, gafDataStringBuilder); } #endregion _gafRecordWriter.WriteFooterRecord(footerRecord, gafDataStringBuilder); #endregion gstAuditFile.Data = gafDataStringBuilder.ToString(); var branch = _gafRepository.GetBranchByID(gafPeriod.BranchID); gstAuditFile.FileName = string.Concat(branch.BranchCD.Trim(), "_", string.Format(GafVersionTemplate, gstAuditFile.MajorVersion, GafVersionDelimiterForFileName, gstAuditFile.MinorVersion), ".txt"); return(gstAuditFile); }
private bool ReadARecord(RecordStream rs) { switch (rs.PeekNextSid()) { case HorizontalPageBreakRecord.sid: _rowBreaksRecord = (PageBreakRecord)rs.GetNext(); _rowRecords.Add(_rowBreaksRecord); break; case VerticalPageBreakRecord.sid: _columnBreaksRecord = (PageBreakRecord)rs.GetNext(); _rowRecords.Add(_columnBreaksRecord); break; case HeaderRecord.sid: header = (HeaderRecord)rs.GetNext(); _rowRecords.Add(header); break; case FooterRecord.sid: footer = (FooterRecord)rs.GetNext(); _rowRecords.Add(footer); break; case HCenterRecord.sid: _hCenter = (HCenterRecord)rs.GetNext(); _rowRecords.Add(_hCenter); break; case VCenterRecord.sid: _vCenter = (VCenterRecord)rs.GetNext(); _rowRecords.Add(_vCenter); break; case LeftMarginRecord.sid: _leftMargin = (LeftMarginRecord)rs.GetNext(); _rowRecords.Add(_leftMargin); break; case RightMarginRecord.sid: _rightMargin = (RightMarginRecord)rs.GetNext(); _rowRecords.Add(_rightMargin); break; case TopMarginRecord.sid: _topMargin = (TopMarginRecord)rs.GetNext(); _rowRecords.Add(_topMargin); break; case BottomMarginRecord.sid: _bottomMargin = (BottomMarginRecord)rs.GetNext(); _rowRecords.Add(_bottomMargin); break; case 0x004D: // PLS _pls = rs.GetNext(); _rowRecords.Add(_pls); break; case PrintSetupRecord.sid: printSetup = (PrintSetupRecord)rs.GetNext(); _rowRecords.Add(printSetup); break; case 0x00E9: // BITMAP _bitmap = rs.GetNext(); _rowRecords.Add(_bitmap); break; default: // all other record types are not part of the PageSettingsBlock return(false); } return(true); }
/// <summary> /// Initializes a new instance of the <see cref="HSSFFooter"/> class. /// </summary> /// <param name="footerRecord">Footer record to Create the footer with</param> public HSSFFooter(FooterRecord footerRecord) : base(footerRecord.Footer) { this.footerRecord = footerRecord; }