/* Print-only PDF document.
*
* Always rendered in the DOM but hidden via CSS until print media. The browser's
* native print dialog (window.print()) becomes the PDF generator — "Save as PDF"
* gives a clean, branded, A4 report.
*/
function PrintDoc({ result }) {
const f = window.fmt;
const fuel = window.SicosaEngine.FUELS[result.inputs.fuelType];
const today = f.date();
const i = result.inputs;
const printDocStyles = {
fontFamily: "var(--font-sans)",
fontSize: 11,
color: "#1d1e1d",
padding: 0,
margin: 0,
};
return (
Internal margin analysis
{fuel.label} · {f.amd(i.batchTons, 2)} t batch
{i.fuelType === "diesel" ? "DT" : i.fuelType === "lpg" ? "LPG" : i.fuelType === "gasoline-92" ? "92" : "95"}
{/* Headline trio — Cost per liter respects the fixed-costs toggle */}
Inputs
| Fuel type | {fuel.label} |
| Batch volume | {f.amd(i.batchTons, 2)} t |
| Exchange rate | {f.amd(i.fxRate, 2)} AMD/USD |
| Density | {f.density(i.density)} kg/L |
| Purchase price (incl. delivery) | ${f.usd(i.purchasePriceUsd, 2)} /t |
| Selling price (incl. VAT) | {f.amdL(i.sellingPriceAmd)} AMD/L |
| Fixed costs included | {i.includeFixedCosts ? "Yes (260 000 AMD)" : "No"} |
Per ton — AMD
| Cost per ton | {f.amd(result.totalCostAmdPerTon)} |
| VAT amount | {f.amd(result.vatAmdPerTon)} |
| Excise amount | {f.amd(result.exciseAmdPerTon)} |
{result.customsAmdPerTon > 0 ? (
| Customs duty | {f.amd(result.customsAmdPerTon)} |
) : null}
| Eco tax amount | {f.amd(result.ecoTaxAmdPerTon, 2)} |
| Liters per ton | {f.amd(result.litersPerTon, 2)} L |
Per batch — AMD
| Total batch liters | {f.amd(result.totalBatchLiters, 1)} L |
| Total batch cost | {f.amd(result.totalCostAmdPerBatch)} |
| Batch revenue | {f.amd(result.batchRevenueAmd)} |
| Margin per liter | = 0 ? "pos" : "neg")}>{f.amdL(result.marginPerLiterAmd)} |
| Margin % | = 0 ? "pos" : "neg")}>{(result.marginPct * 100).toFixed(2)}% |
| Profit per ton | = 0 ? "pos" : "neg")}>{f.amd(result.profitPerTonAmd)} |
| Profit per batch{i.includeFixedCosts ? " (incl. fixed)" : ""} | = 0 ? "pos" : "neg")}>{f.amd(i.includeFixedCosts ? result.profitPerBatchWithFixedAmd : result.profitPerBatchAmd)} |
VAT overpayment · analytical
| Overpaid VAT per liter | {f.amdL(result.vatOverpaymentPerLiterAmd)} |
| Overpaid VAT per ton | {f.amd(result.vatOverpaymentPerTonAmd)} |
| Profit after VAT overpayment | = 0 ? "pos" : "neg")}>{f.amd(result.profitAfterVatOverpaymentAmd)} |
| Net profit (18% profit tax) | = 0 ? "pos" : "neg")}>{f.amd(result.netProfitAfter18TaxAmd)} |
);
}
function HeroStat({ label, val, unit, sub }) {
return (
{label}
{val}
{unit}
{sub}
);
}
const printDocCss = `
.pd-header {
display: flex; justify-content: space-between; align-items: flex-start;
padding-bottom: 14px; border-bottom: 2px solid #142031; margin-bottom: 22px;
}
.pd-brand { display: flex; align-items: center; gap: 12px; }
.pd-mark { width: 38px; height: 38px; border-radius: 999px; }
.pd-brand-name { font-family: 'Manrope', sans-serif; font-weight: 700; font-size: 16px; color: #142031; letter-spacing: -0.02em; }
.pd-brand-sub { font-family: 'JetBrains Mono', monospace; font-size: 9.5px; color: #525352; letter-spacing: 0.08em; text-transform: uppercase; margin-top: 2px; }
.pd-doc-meta { text-align: right; }
.pd-doc-id { font-family: 'JetBrains Mono', monospace; font-size: 10px; letter-spacing: 0.14em; color: #2a88c1; font-weight: 600; }
.pd-doc-date { font-family: 'JetBrains Mono', monospace; font-size: 10px; color: #525352; margin-top: 4px; letter-spacing: 0.06em; }
.pd-title-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.pd-eyebrow { font-family: 'JetBrains Mono', monospace; font-size: 10px; letter-spacing: 0.16em; color: #2a88c1; text-transform: uppercase; margin-bottom: 4px; }
.pd-title { font-family: 'Manrope', sans-serif; font-size: 22px; font-weight: 700; letter-spacing: -0.025em; color: #142031; margin: 0; }
.pd-fuel-chip {
color: #fff; padding: 8px 14px; border-radius: 8px;
font-family: 'JetBrains Mono', monospace; font-weight: 600; font-size: 13px; letter-spacing: 0.06em;
}
.pd-hero {
display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px;
margin-bottom: 22px;
}
.pd-hero-stat {
background: #142031; color: #fff; padding: 14px 16px; border-radius: 10px;
}
.pd-hero-label { font-family: 'JetBrains Mono', monospace; font-size: 8.5px; letter-spacing: 0.16em; text-transform: uppercase; color: rgba(255,255,255,0.6); }
.pd-hero-line { display: flex; align-items: baseline; gap: 6px; margin-top: 6px; }
.pd-hero-val { font-family: 'JetBrains Mono', monospace; font-size: 22px; font-weight: 500; letter-spacing: -0.01em; }
.pd-hero-unit { font-family: 'JetBrains Mono', monospace; font-size: 10px; color: rgba(255,255,255,0.7); letter-spacing: 0.06em; }
.pd-hero-sub { font-family: 'JetBrains Mono', monospace; font-size: 9px; color: rgba(255,255,255,0.7); margin-top: 4px; letter-spacing: 0.04em; }
.pd-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px 22px; }
.pd-section { break-inside: avoid; }
.pd-h { font-family: 'JetBrains Mono', monospace; font-size: 9.5px; letter-spacing: 0.16em; text-transform: uppercase; color: #525352; font-weight: 600; margin: 0 0 8px; padding-bottom: 6px; border-bottom: 1px solid rgba(20, 32, 49, 0.14); }
.pd-table { width: 100%; border-collapse: collapse; }
.pd-table td { padding: 5px 0; font-size: 10.5px; border-bottom: 1px dotted rgba(20, 32, 49, 0.08); color: #1d1e1d; }
.pd-table td.r { text-align: right; }
.pd-table td.mono { font-family: 'JetBrains Mono', monospace; font-size: 10.5px; letter-spacing: 0.02em; color: #142031; }
.pd-table td.strong { font-weight: 700; }
.pd-table td.pos { color: #2f7d4f; }
.pd-table td.neg { color: #b3422f; }
.pd-table tr.hi td { background: #eef2f9; padding: 8px 6px; border-bottom: none; border-radius: 4px; }
`;
function exportPDF() {
// Tiny pre-print hook for filename: change document title temporarily
const prev = document.title;
document.title = "Sicosa-Fuel-Cost-Report";
window.print();
setTimeout(() => { document.title = prev; }, 100);
}
window.PrintDoc = PrintDoc;
window.exportPDF = exportPDF;