89 lines
		
	
	
		
			4.6 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
		
		
			
		
	
	
			89 lines
		
	
	
		
			4.6 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
|  | using GestionIntegral.Api.Dtos.Reportes.ViewModels; | ||
|  | using QuestPDF.Fluent; | ||
|  | using QuestPDF.Helpers; | ||
|  | using QuestPDF.Infrastructure; | ||
|  | using System.Linq; | ||
|  | 
 | ||
|  | namespace GestionIntegral.Api.Controllers.Reportes.PdfTemplates | ||
|  | { | ||
|  |     public class VentaMensualSecretariaElDiaDocument : IDocument | ||
|  |     { | ||
|  |         public VentaMensualSecretariaElDiaViewModel Model { get; } | ||
|  | 
 | ||
|  |         public VentaMensualSecretariaElDiaDocument(VentaMensualSecretariaElDiaViewModel model) | ||
|  |         { | ||
|  |             Model = model; | ||
|  |         } | ||
|  | 
 | ||
|  |         public DocumentMetadata GetMetadata() => DocumentMetadata.Default; | ||
|  | 
 | ||
|  |         public void Compose(IDocumentContainer container) | ||
|  |         { | ||
|  |             container.Page(page => | ||
|  |             { | ||
|  |                 page.Margin(1, Unit.Centimetre); | ||
|  |                 page.DefaultTextStyle(x => x.FontFamily("Arial").FontSize(11)); | ||
|  |                  | ||
|  |                 page.Header().Element(ComposeHeader); | ||
|  |                 page.Content().Element(ComposeContent); | ||
|  |                 page.Footer().AlignCenter().Text(x => { x.Span("Página "); x.CurrentPageNumber(); }); | ||
|  |             }); | ||
|  |         } | ||
|  | 
 | ||
|  |         void ComposeHeader(IContainer container) | ||
|  |         { | ||
|  |             container.Column(column => | ||
|  |             { | ||
|  |                 column.Spacing(5); | ||
|  |                 column.Item().AlignCenter().Text("VENTA DIARIO EL DÍA").SemiBold().FontSize(16); | ||
|  | 
 | ||
|  |                 column.Item().AlignCenter().Text(text => | ||
|  |                 { | ||
|  |                     text.Span("Fecha Consultada: Desde ").SemiBold().FontSize(12); | ||
|  |                     text.Span(Model.FechaDesde).FontSize(12); | ||
|  |                     text.Span(" Hasta ").SemiBold().FontSize(12); | ||
|  |                     text.Span(Model.FechaHasta).FontSize(12); | ||
|  |                 }); | ||
|  |             }); | ||
|  |         } | ||
|  |          | ||
|  |         void ComposeContent(IContainer container) | ||
|  |         { | ||
|  |             container.PaddingTop(5, Unit.Millimetre).Table(table => | ||
|  |             { | ||
|  |                 table.ColumnsDefinition(columns => | ||
|  |                 { | ||
|  |                     columns.ConstantColumn(50); // Día | ||
|  |                     columns.RelativeColumn();   // Canillas | ||
|  |                     columns.RelativeColumn();   // Tirajes | ||
|  |                     columns.RelativeColumn();   // Ventas | ||
|  |                     columns.RelativeColumn();   // Accionistas | ||
|  |                     columns.RelativeColumn();   // Total Coop. | ||
|  |                     columns.RelativeColumn();   // Total Gral. | ||
|  |                 }); | ||
|  | 
 | ||
|  |                 table.Header(header => | ||
|  |                 { | ||
|  |                     header.Cell().Background(Colors.Black).Border(1).BorderColor(Colors.White).Padding(4).AlignCenter().Text(text => text.Span("DÍA").FontColor(Colors.White).SemiBold()); | ||
|  |                     header.Cell().Background(Colors.Black).Border(1).BorderColor(Colors.White).Padding(4).AlignCenter().Text(text => text.Span("CANILLAS").FontColor(Colors.White).SemiBold()); | ||
|  |                     header.Cell().Background(Colors.Black).Border(1).BorderColor(Colors.White).Padding(4).AlignCenter().Text(text => text.Span("TIRAJES").FontColor(Colors.White).SemiBold()); | ||
|  |                     header.Cell().Background(Colors.Black).Border(1).BorderColor(Colors.White).Padding(4).AlignCenter().Text(text => text.Span("VENTAS").FontColor(Colors.White).SemiBold()); | ||
|  |                     header.Cell().Background(Colors.Black).Border(1).BorderColor(Colors.White).Padding(4).AlignCenter().Text(text => text.Span("ACCIONISTAS").FontColor(Colors.White).SemiBold()); | ||
|  |                     header.Cell().Background(Colors.Black).Border(1).BorderColor(Colors.White).Padding(4).AlignCenter().Text(text => text.Span("TOTAL COOPERATIVA").FontColor(Colors.White).SemiBold()); | ||
|  |                     header.Cell().Background(Colors.Black).Border(1).BorderColor(Colors.White).Padding(4).AlignCenter().Text(text => text.Span("TOTAL").FontColor(Colors.White).SemiBold()); | ||
|  |                 }); | ||
|  | 
 | ||
|  |                 foreach (var item in Model.VentasDiarias.OrderBy(x => x.Dia)) | ||
|  |                 { | ||
|  |                     table.Cell().Border(1).Padding(4).AlignCenter().Text(item.Dia.ToString()); | ||
|  |                     table.Cell().Border(1).Padding(4).AlignCenter().Text(item.CantidadCanillas.ToString("N0")); | ||
|  |                     table.Cell().Border(1).Padding(4).AlignCenter().Text(item.Tirajes.ToString("N0")); | ||
|  |                     table.Cell().Border(1).Padding(4).AlignCenter().Text(item.Ventas.ToString("N0")); | ||
|  |                     table.Cell().Border(1).Padding(4).AlignCenter().Text(item.Accionistas.ToString("N0")); | ||
|  |                     table.Cell().Border(1).Padding(4).AlignCenter().Text(item.TotalCooperativa.ToString("N0")); | ||
|  |                     table.Cell().Border(1).Padding(4).AlignCenter().Text(t => t.Span(item.TotalGeneral.ToString("N0")).SemiBold()); | ||
|  |                 } | ||
|  |             }); | ||
|  |         } | ||
|  |     } | ||
|  | } |