123 lines
5.3 KiB
C#
123 lines
5.3 KiB
C#
using QuestPDF.Fluent;
|
|
using QuestPDF.Helpers;
|
|
using QuestPDF.Infrastructure;
|
|
using Indotalent.Features.Inventory.TransferOut.Cqrs;
|
|
|
|
namespace Indotalent.Features.Inventory.TransferOut;
|
|
|
|
public class TransferOutPdfGenerator
|
|
{
|
|
public static byte[] Generate(GetTransferOutByIdResponse data)
|
|
{
|
|
QuestPDF.Settings.License = LicenseType.Community;
|
|
|
|
var primaryBlue = "#0D47A1";
|
|
var textSlate = "#64748b";
|
|
|
|
return Document.Create(container =>
|
|
{
|
|
container.Page(page =>
|
|
{
|
|
page.Size(PageSizes.A4);
|
|
page.Margin(1.5f, Unit.Centimetre);
|
|
page.PageColor(Colors.White);
|
|
page.DefaultTextStyle(x => x.FontSize(9).FontFamily(Fonts.Verdana));
|
|
|
|
page.Header().Row(row =>
|
|
{
|
|
row.RelativeItem().Column(col =>
|
|
{
|
|
col.Item().Text("TRANSFER OUT")
|
|
.FontSize(20).ExtraBold().FontColor(primaryBlue);
|
|
col.Item().Text($"{data.AutoNumber}").FontSize(11).SemiBold();
|
|
});
|
|
|
|
row.RelativeItem().AlignRight().Column(col =>
|
|
{
|
|
col.Item().Text("STOCK RELEASE").FontSize(11).ExtraBold();
|
|
col.Item().Text($"Date: {data.TransferReleaseDate?.ToString("dd MMM yyyy")}").FontColor(textSlate);
|
|
col.Item().Text($"Status: {data.Status.ToString().ToUpper()}").FontColor(textSlate);
|
|
});
|
|
});
|
|
|
|
page.Content().PaddingVertical(20).Column(col =>
|
|
{
|
|
col.Item().Row(row =>
|
|
{
|
|
row.RelativeItem().Column(c =>
|
|
{
|
|
c.Item().BorderBottom(1).PaddingBottom(5).Text("FROM WAREHOUSE").FontSize(8).Bold().FontColor(textSlate);
|
|
c.Item().PaddingTop(5).Text(data.WarehouseFromName).Bold();
|
|
});
|
|
|
|
row.ConstantItem(40);
|
|
|
|
row.RelativeItem().Column(c =>
|
|
{
|
|
c.Item().BorderBottom(1).PaddingBottom(5).Text("TO WAREHOUSE").FontSize(8).Bold().FontColor(textSlate);
|
|
c.Item().PaddingTop(5).Text(data.WarehouseToName).Bold();
|
|
});
|
|
});
|
|
|
|
col.Item().PaddingTop(20).Table(table =>
|
|
{
|
|
table.ColumnsDefinition(columns =>
|
|
{
|
|
columns.ConstantColumn(30);
|
|
columns.RelativeColumn(6);
|
|
columns.RelativeColumn(2);
|
|
});
|
|
|
|
table.Header(header =>
|
|
{
|
|
header.Cell().Element(HeaderStyle).Text("#");
|
|
header.Cell().Element(HeaderStyle).Text("Product Name");
|
|
header.Cell().Element(HeaderStyle).AlignCenter().Text("Qty");
|
|
|
|
static IContainer HeaderStyle(IContainer container)
|
|
{
|
|
return container.DefaultTextStyle(x => x.SemiBold().FontColor(Colors.White))
|
|
.PaddingVertical(5).PaddingHorizontal(5).Background("#0D47A1");
|
|
}
|
|
});
|
|
|
|
var index = 1;
|
|
foreach (var item in data.Items)
|
|
{
|
|
table.Cell().Element(CellStyle).Text($"{index++}");
|
|
table.Cell().Element(CellStyle).Text(item.ProductName);
|
|
table.Cell().Element(CellStyle).AlignCenter().Text(item.Movement?.ToString());
|
|
|
|
static IContainer CellStyle(IContainer container)
|
|
{
|
|
return container.BorderBottom(1).BorderColor("#E2E8F0").PaddingVertical(8).PaddingHorizontal(5);
|
|
}
|
|
}
|
|
});
|
|
|
|
col.Item().PaddingTop(20).Row(row =>
|
|
{
|
|
row.RelativeItem().Column(c => {
|
|
c.Item().Text("Notes:").FontSize(8).Bold();
|
|
c.Item().Text(string.IsNullOrEmpty(data.Description) ? "-" : data.Description).FontSize(8);
|
|
});
|
|
|
|
row.ConstantItem(150).Column(c => {
|
|
c.Item().PaddingTop(10).AlignCenter().Text("Authorized By,").FontSize(8);
|
|
c.Item().PaddingTop(40).AlignCenter().Text("____________________").FontSize(8);
|
|
c.Item().AlignCenter().Text("( Warehouse Manager )").FontSize(7);
|
|
});
|
|
});
|
|
});
|
|
|
|
page.Footer().AlignCenter().Text(x =>
|
|
{
|
|
x.Span("Page ").FontSize(8);
|
|
x.CurrentPageNumber().FontSize(8);
|
|
x.Span(" of ").FontSize(8);
|
|
x.TotalPages().FontSize(8);
|
|
});
|
|
});
|
|
}).GeneratePdf();
|
|
}
|
|
} |