Repository Public
1// ORIX Docs2// File: Packages/ORIXDocsKit/Sources/DocTemplates/Templates+Business.swift3// Description: Proposal, financial report, project report, invoice and meeting minutes templates.4//5// Author: Simon-Pierre Boucher6// Contact: contact@spboucher.ai7import Foundation8import DocModel910extension TemplateLibrary {11 /// "Label <tab> value" lines with a hanging indent, used for the fact blocks of the minutes, the project report and the invoice.12 private static func factStyle(_ b: inout TemplateBuilder, labelWidth: Points) {13 b.define("FactLine", b.t("Fact Line", "Ligne de renseignement"), next: "FactLine",14 para: ParaProps(indentLeft: labelWidth, firstLineIndent: -labelWidth, spaceAfter: 2, lineSpacing: .multiple(1.2), tabs: [TabStop(position: labelWidth)]))15 }1617 private static func fact(_ b: inout TemplateBuilder, _ label: String, _ value: [Run]) {18 b.p("FactLine", [strong(label), tab] + value)19 }2021 /// Two signature lines side by side, drawn with line-leader tab stops.22 private static func signatureStyles(_ b: inout TemplateBuilder) {23 let w = b.width24 let half = ((w - 30) / 2).rounded()25 let stops = [TabStop(position: half, kind: .left, leader: .line), TabStop(position: half + 30, kind: .left), TabStop(position: w, kind: .left, leader: .line)]26 b.define("SignatureLine", b.t("Signature Line", "Ligne de signature"), next: "SignatureCaption",27 para: ParaProps(spaceBefore: 40, spaceAfter: 2, keepWithNext: true, tabs: stops))28 b.define("SignatureCaption", b.t("Signature Caption", "Mention sous la signature"), next: StyleID.normal,29 char: CharProps(fontSize: b.theme.bodySize - 2, color: b.muted),30 para: ParaProps(spaceAfter: 0, tabs: [TabStop(position: half + 30, kind: .left)]))31 }3233 // MARK: Proposal3435 static func proposal(_ c: TemplateContext) -> DocumentModel {36 var b = TemplateBuilder(c, theme: .orix, margins: Insets(top: 80, left: 76, bottom: 76, right: 76))37 let t = b.t38 coverStyles(&b)39 signatureStyles(&b)40 let title = t("[Project Name]", "[Nom du projet]")41 b.setup.differentFirstPage = true42 b.setup.header = HeaderFooter(default: [b.header([field(.title), tab, tab, r(t("Proposal", "Proposition"))])])43 b.setup.footer = HeaderFooter(default: [b.footer([r(b.organization), tab, tab] + b.pageOfTotal)])44 let scheduleID = DocID.make(), budgetID = DocID.make()4546 b.p("CoverKicker", t("Proposal", "Proposition"))47 b.p("CoverTitle", title)48 b.p("CoverSubtitle", t("[One sentence: what you propose and the benefit for the client]", "[Une phrase : ce que vous proposez et l'avantage pour le client]"))49 b.p("CoverMeta", [r(t("Prepared for ", "Préparée pour ")), r(t("[Client name]", "[Nom du client]"))])50 b.p("CoverMeta", [r(t("Prepared by ", "Préparée par ")), b.authorRun, r(", " + b.organization)])51 b.p("CoverMeta", b.dateText)52 b.p("CoverMeta", t("Valid until [date]", "Valide jusqu'au [date]"))53 b.pageBreak()5455 b.heading(1, t("Summary", "Sommaire"))56 b.body(t("[In one paragraph: the client's need, your solution, the price and the date of delivery.] A decision maker should be able to stop reading here.",57 "[En un paragraphe : le besoin du client, votre solution, le prix et la date de livraison.] Un décideur devrait pouvoir arrêter sa lecture ici."))5859 b.heading(1, t("Understanding of Your Needs", "Compréhension de vos besoins"))60 b.body(t("[Restate the situation in the client's own words and name the result they are after.]", "[Reformulez la situation dans les mots du client et nommez le résultat qu'il recherche.]"))61 b.bullets([t("[Need 1]", "[Besoin 1]"), t("[Need 2]", "[Besoin 2]"), t("[Constraint: budget, deadline, standard]", "[Contrainte : budget, échéance, norme]")])6263 b.heading(1, t("Proposed Approach", "Démarche proposée"))64 b.body([r(t("[Describe how you will work, phase by phase.] The schedule is given in ", "[Décrivez votre façon de travailler, étape par étape.] L'échéancier figure au "))]65 + b.ref(scheduleID, .table) + [r(".")])66 b.heading(2, t("Phases", "Étapes"))67 b.numbered([t("[Phase 1 – Analysis: what is done and what the client receives]", "[Étape 1 – Analyse : ce qui est fait et ce que le client reçoit]"),68 t("[Phase 2 – Delivery]", "[Étape 2 – Réalisation]"), t("[Phase 3 – Handover and follow-up]", "[Étape 3 – Livraison et suivi]")])69 b.heading(2, t("Deliverables and Schedule", "Livrables et échéancier"))70 b.caption(.table, t("Deliverables and schedule", "Livrables et échéancier"), id: scheduleID)71 b.table([1, 2.6, 1.2],72 header: [th(t("Phase", "Étape")), th(t("Deliverable", "Livrable")), th(t("Date", "Date"))],73 rows: (1...3).map { [cell(t("[Phase \($0)]", "[Étape \($0)]")), cell(t("[Deliverable]", "[Livrable]")), cell(t("[Date]", "[Date]"))] }, style: b.bandedTable)7475 b.heading(1, t("Budget", "Budget"))76 b.body([r(t("[Explain what the price includes and what it excludes.] The amounts in ", "[Précisez ce que le prix comprend et ce qu'il exclut.] Les montants du "))]77 + b.ref(budgetID, .table) + [r(t(" are samples; the total is computed from the lines above it.", " sont des exemples ; le total est calculé à partir des lignes qui le précèdent."))])78 let lines: [(String, Double)] = [(t("[Phase 1 – Analysis]", "[Étape 1 – Analyse]"), 4_000), (t("[Phase 2 – Delivery]", "[Étape 2 – Réalisation]"), 12_000),79 (t("[Phase 3 – Handover and follow-up]", "[Étape 3 – Livraison et suivi]"), 2_500)]80 b.caption(.table, t("Budget (sample amounts, before taxes)", "Budget (montants fictifs, avant taxes)"), id: budgetID)81 b.table([3, 1.2],82 header: [th(t("Item", "Poste")), thNum(t("Amount", "Montant"))],83 rows: lines.map { [cell($0.0), num(t.money($0.1))] }84 + [[total(t("Total", "Total")), totalNum(t.money(lines.reduce(0) { $0 + $1.1 }), formula: "=SUM(ABOVE)")]])8586 b.heading(1, t("Team", "Équipe"))87 b.bullets([[strong(t("[Name], [role]", "[Nom], [rôle]")), r(t(" – [relevant experience in one line]", " – [expérience pertinente en une ligne]"))],88 [strong(t("[Name], [role]", "[Nom], [rôle]")), r(t(" – [relevant experience in one line]", " – [expérience pertinente en une ligne]"))]])8990 b.heading(1, t("Terms and Acceptance", "Modalités et acceptation"))91 b.body(t("[Payment schedule, validity of the offer, intellectual property, confidentiality.]", "[Calendrier de paiement, validité de l'offre, propriété intellectuelle, confidentialité.]"))92 b.p("SignatureLine", [tab, tab, tab])93 b.p("SignatureCaption", [r(t("[Client name], [title] – Date", "[Nom du client], [titre] – Date")), tab, r(b.author + t(", [title] – Date", ", [titre] – Date"))])94 return b.build(title: title)95 }9697 // MARK: Financial report9899 static func financialReport(_ c: TemplateContext) -> DocumentModel {100 var b = TemplateBuilder(c, theme: .modern, margins: Insets(top: 80, left: 72, bottom: 76, right: 72))101 let t = b.t102 let muted = b.muted, tint = b.tint, accent = b.theme.accent103 coverStyles(&b)104 b.define("Highlight", t("Highlight", "Fait saillant"), next: StyleID.normal,105 para: ParaProps(indentLeft: 12, indentRight: 12, spaceBefore: 6, spaceAfter: 12, keepLinesTogether: true, shading: tint, borderLeft: BorderLine(width: 3, color: accent)))106 b.define("TableNote", t("Table Note", "Note de tableau"), basedOn: StyleID.caption, next: StyleID.normal, char: CharProps(italic: true, color: muted),107 para: ParaProps(alignment: .left, spaceBefore: 3, spaceAfter: 14))108 b.define("Disclaimer", t("Disclaimer", "Avertissement"), next: StyleID.normal, char: CharProps(fontSize: b.theme.bodySize - 2, color: muted),109 para: ParaProps(spaceBefore: 16, lineSpacing: .multiple(1.15), borderTop: b.hair))110111 let year = Int(t.year(c.date)) ?? 2026112 let title = t("[Financial Report – Fiscal Year \(year)]", "[Rapport financier – Exercice \(year)]")113 let unit = t("in thousands of dollars; sample figures", "en milliers de dollars ; données fictives")114 b.setup.differentFirstPage = true115 b.setup.header = HeaderFooter(default: [b.header([r(b.organization), tab, tab, field(.title)])])116 b.setup.footer = HeaderFooter(default: [b.footer([r(t("Sample figures – replace before distribution", "Données fictives – à remplacer avant diffusion")), tab, tab] + b.pageOfTotal)])117 let segID = DocID.make(), opexID = DocID.make(), quarterID = DocID.make(), notesID = DocID.make()118119 b.p("CoverKicker", b.organization)120 b.p("CoverTitle", title)121 b.p("CoverSubtitle", t("[Period covered: from … to …]", "[Période visée : du … au …]"))122 b.p("CoverMeta", [r(t("Prepared by ", "Préparé par ")), b.authorRun])123 b.p("CoverMeta", b.dateText)124 b.p("CoverMeta", t("[Audited / Unaudited] · [Currency]", "[Audité / Non audité] · [Monnaie]"))125 b.pageBreak()126 b.toc(.contents, maxLevel: 2)127 b.pageBreak()128129 // Sample data: every total below is computed here and repeated by the cell formula.130 let segments: [(String, Double, Double)] = [(t("[Products]", "[Produits]"), 3_200, 2_900), (t("[Services]", "[Services]"), 1_875, 1_650), (t("[Licences]", "[Licences]"), 500, 450)]131 let expenses: [(String, Double, Double)] = [(t("Salaries and benefits", "Salaires et avantages sociaux"), 1_290, 1_180), (t("Marketing", "Marketing"), 345, 320),132 (t("Research and development", "Recherche et développement"), 310, 270), (t("General and administrative", "Frais généraux et administratifs"), 210, 200)]133 func change(_ now: Double, _ before: Double) -> String { t.percent((now - before) / before * 100) }134 let revenue = segments.reduce(0) { $0 + $1.1 }, revenuePrior = segments.reduce(0) { $0 + $1.2 }135 let opex = expenses.reduce(0) { $0 + $1.1 }, opexPrior = expenses.reduce(0) { $0 + $1.2 }136137 b.heading(1, t("Highlights", "Faits saillants"))138 b.p("Highlight", [strong(t("[Headline of the year in one sentence.] ", "[Le fait marquant de l'exercice en une phrase.] ")),139 r(t("Revenue of \(t.number(revenue)) (sample), up \(change(revenue, revenuePrior)) from the previous year.",140 "Produits de \(t.number(revenue)) (exemple), en hausse de \(change(revenue, revenuePrior)) par rapport à l'exercice précédent."))])141 b.bullets([t("[Highlight 1: figure, comparison, cause]", "[Fait saillant 1 : chiffre, comparaison, cause]"), t("[Highlight 2]", "[Fait saillant 2]"), t("[Highlight 3]", "[Fait saillant 3]")])142143 b.heading(1, t("Management Discussion", "Analyse de la direction"))144 b.heading(2, t("Revenue", "Produits"))145 b.body([r(t("[Explain what drove revenue: volume, price, mix.] The breakdown by segment is shown in ", "[Expliquez l'évolution des produits : volume, prix, composition.] La ventilation par secteur figure au "))]146 + b.ref(segID, .table) + [r(".")])147 let headers = [th(""), thNum(String(year)), thNum(String(year - 1)), thNum(t("Change", "Variation"))]148 b.caption(.table, t("Revenue by segment", "Produits par secteur") + " (\(unit))", id: segID)149 b.table([2.6, 1, 1, 1], header: headers,150 rows: segments.map { [cell($0.0), num(t.number($0.1)), num(t.number($0.2)), num(change($0.1, $0.2))] }151 + [[total(t("Total revenue", "Total des produits")), totalNum(t.number(revenue), formula: "=SUM(ABOVE)"),152 totalNum(t.number(revenuePrior), formula: "=SUM(ABOVE)"), totalNum(change(revenue, revenuePrior), formula: "=(B5-C5)/C5*100")]])153 b.heading(2, t("Operating Expenses", "Charges d'exploitation"))154 let fn = b.footnote(t("[Describe any reclassification made to the comparative figures.]", "[Décrivez tout reclassement apporté aux chiffres comparatifs.]"))155 b.body([r(t("[Explain the main variances.] Operating expenses are detailed in ", "[Expliquez les principaux écarts.] Les charges d'exploitation sont détaillées au "))]156 + b.ref(opexID, .table) + [r("."), fn])157 b.caption(.table, t("Operating expenses", "Charges d'exploitation") + " (\(unit))", id: opexID)158 b.table([2.6, 1, 1, 1], header: headers,159 rows: expenses.map { [cell($0.0), num(t.number($0.1)), num(t.number($0.2)), num(change($0.1, $0.2))] }160 + [[total(t("Total operating expenses", "Total des charges d'exploitation")), totalNum(t.number(opex), formula: "=SUM(ABOVE)"),161 totalNum(t.number(opexPrior), formula: "=SUM(ABOVE)"), totalNum(change(opex, opexPrior), formula: "=(B6-C6)/C6*100")]])162163 // The quarterly table is wide: it gets a landscape section of its own.164 let portrait = b.current165 var landscape = portrait166 landscape.landscape = true167 let wide = landscape.contentWidth168 b.section(.nextPage) { s in169 s.landscape = true170 s.differentFirstPage = false171 s.header = TemplateBuilder.retab(s.header, width: wide)172 s.footer = TemplateBuilder.retab(s.footer, width: wide)173 }174 b.heading(1, t("Quarterly Results", "Résultats trimestriels"))175 b.body([r(t("[Comment on seasonality and on the quarter that stands out.] In ", "[Commentez la saisonnalité et le trimestre qui se démarque.] Au "))] + b.ref(quarterID, .table)176 + [r(t(", the year column and the profit lines are formulas.", ", la colonne de l'exercice et les lignes de résultat sont des formules."))])177 let q: [[Double]] = [[1_200, 1_350, 1_425, 1_600], [480, 540, 570, 640], [510, 525, 540, 580]]178 func quarterRow(_ label: String, _ v: [Double], row: Int) -> [CellSpec] {179 [cell(label)] + v.map { num(t.number($0)) } + [num(t.number(v.reduce(0, +)), formula: "=SUM(LEFT)")]180 }181 func computedRow(_ label: String, _ v: [Double], minuend: Int, subtrahend: Int) -> [CellSpec] {182 let cols = ["B", "C", "D", "E"]183 return [total(label)] + v.enumerated().map { totalNum(t.number($0.element), formula: "=\(cols[$0.offset])\(minuend)-\(cols[$0.offset])\(subtrahend)") }184 + [totalNum(t.number(v.reduce(0, +)), formula: "=SUM(LEFT)")]185 }186 let gross = zip(q[0], q[1]).map { $0 - $1 }187 let operating = zip(gross, q[2]).map { $0 - $1 }188 b.caption(.table, t("Quarterly results", "Résultats trimestriels") + " (\(unit))", id: quarterID)189 b.table([2.4, 1, 1, 1, 1, 1.1],190 header: [th("")] + (1...4).map { thNum(t("Q\($0)", "T\($0)")) } + [thNum(t("Year", "Exercice"))],191 rows: [quarterRow(t("Revenue", "Produits"), q[0], row: 2), quarterRow(t("Cost of sales", "Coût des ventes"), q[1], row: 3),192 computedRow(t("Gross profit", "Marge brute"), gross, minuend: 2, subtrahend: 3),193 quarterRow(t("Operating expenses", "Charges d'exploitation"), q[2], row: 5),194 computedRow(t("Operating income", "Résultat d'exploitation"), operating, minuend: 4, subtrahend: 5)],195 style: b.bandedTable)196 b.p("TableNote", t("Q = quarter. Gross profit = revenue − cost of sales; operating income = gross profit − operating expenses.",197 "T = trimestre. Marge brute = produits − coût des ventes ; résultat d'exploitation = marge brute − charges d'exploitation."))198199 b.section(.nextPage) { s in200 s.landscape = false201 s.header = TemplateBuilder.fresh(portrait.header)202 s.footer = TemplateBuilder.fresh(portrait.footer)203 }204 b.heading(1, t("Outlook", "Perspectives"))205 b.body([r(t("[State the expectations for the coming year and the assumptions behind them; see ", "[Présentez les attentes pour le prochain exercice et les hypothèses qui les sous-tendent ; voir "))]206 + [xref(notesID, .text), r(".]")])207 b.heading(1, t("Notes", "Notes complémentaires"), id: notesID)208 b.numbered([t("[Basis of preparation and accounting framework]", "[Mode de préparation et référentiel comptable]"),209 t("[Significant accounting policies]", "[Principales méthodes comptables]"), t("[Subsequent events]", "[Événements postérieurs à la date de clôture]")])210 b.p("Disclaimer", t("[Forward-looking statements are subject to risks and uncertainties. Add the disclaimer your organization requires.]",211 "[Les énoncés prospectifs comportent des risques et des incertitudes. Ajoutez l'avertissement exigé par votre organisation.]"))212 return b.build(title: title)213 }214215 // MARK: Project report216217 static func projectReport(_ c: TemplateContext) -> DocumentModel {218 var b = TemplateBuilder(c, theme: .technical, margins: Insets(top: 76, left: 68, bottom: 72, right: 68))219 let t = b.t220 let muted = b.muted221 factStyle(&b, labelWidth: t.french ? 150 : 130)222 b.adjust(StyleID.title) { $0.para.spaceAfter = 2 }223 b.adjust(StyleID.subtitle) { $0.para.spaceAfter = 14 }224 b.define("FactBlockEnd", t("Fact Line (last)", "Ligne de renseignement (dernière)"), basedOn: "FactLine", next: StyleID.normal, para: ParaProps(spaceAfter: 14, borderBottom: b.hair))225 b.define("Status", t("Status", "État"), basedOn: StyleID.tableText, char: CharProps(bold: true, color: muted))226227 let title = t("[Project Name]", "[Nom du projet]")228 b.setup.header = HeaderFooter(default: [b.header([field(.title), tab, tab, r(t("Printed ", "Imprimé le ")), field(.date(format: t.dateFormat))])])229 b.setup.footer = HeaderFooter(default: [b.footer([r(b.organization), tab, tab] + b.pageOfTotal)])230 let milestoneID = DocID.make(), budgetID = DocID.make(), riskID = DocID.make()231232 b.p(StyleID.title, title)233 b.p(StyleID.subtitle, t("Status report – [reporting period]", "Rapport d'étape – [période visée]"))234 fact(&b, t("Project manager", "Chargé de projet"), [b.authorRun])235 fact(&b, t("Sponsor", "Promoteur"), [r(t("[Name, title]", "[Nom, titre]"))])236 fact(&b, t("Organization", "Organisation"), [r(b.organization)])237 fact(&b, t("Report date", "Date du rapport"), [r(b.dateText)])238 b.p("FactBlockEnd", [strong(t("Overall status", "État général")), tab, r(t("[On track / At risk / Off track] – [reason in a few words]", "[En bonne voie / À risque / En difficulté] – [raison en quelques mots]"))])239240 b.heading(1, t("Summary", "Sommaire"))241 b.body(t("[Three or four sentences: what was accomplished during the period, what is late and what needs a decision.]",242 "[Trois ou quatre phrases : ce qui a été accompli durant la période, ce qui est en retard et ce qui demande une décision.]"))243244 b.heading(1, t("Schedule", "Échéancier"))245 b.body([r(t("[Comment on the milestones that moved.] Dates are listed in ", "[Commentez les jalons qui ont bougé.] Les dates figurent au "))] + b.ref(milestoneID, .table) + [r(".")])246 b.caption(.table, t("Milestones", "Jalons"), id: milestoneID)247 b.table([2.4, 1, 1, 1.1],248 header: [th(t("Milestone", "Jalon")), th(t("Planned", "Prévu")), th(t("Forecast", "Révisé")), th(t("Status", "État"))],249 rows: (1...3).map { [cell(t("[Milestone \($0)]", "[Jalon \($0)]")), cell("[date]"), cell("[date]"), cell(t("[Done / In progress / Late]", "[Terminé / En cours / En retard]"), style: "Status")] })250251 b.heading(1, t("Budget", "Budget"))252 let budget: [(String, Double, Double)] = [(t("[Labour]", "[Main-d'œuvre]"), 80_000, 62_500), (t("[Equipment]", "[Équipement]"), 25_000, 27_400), (t("[Services]", "[Services]"), 15_000, 9_800)]253 b.body([r(t("[Explain the variances and the forecast at completion.] The amounts in ", "[Expliquez les écarts et la prévision à l'achèvement.] Les montants du "))] + b.ref(budgetID, .table)254 + [r(t(" are samples; variances and totals are formulas.", " sont des exemples ; les écarts et les totaux sont des formules."))])255 b.caption(.table, t("Budget to date (sample amounts)", "Budget à ce jour (montants fictifs)"), id: budgetID)256 b.table([2.2, 1, 1, 1],257 header: [th(t("Category", "Catégorie")), thNum(t("Budget", "Budget")), thNum(t("Actual", "Réel")), thNum(t("Remaining", "Solde"))],258 rows: budget.enumerated().map { i, l in [cell(l.0), num(t.money(l.1, decimals: 0)), num(t.money(l.2, decimals: 0)), num(t.money(l.1 - l.2, decimals: 0), formula: "=B\(i + 2)-C\(i + 2)")] }259 + [[total(t("Total", "Total")), totalNum(t.money(budget.reduce(0) { $0 + $1.1 }, decimals: 0), formula: "=SUM(ABOVE)"),260 totalNum(t.money(budget.reduce(0) { $0 + $1.2 }, decimals: 0), formula: "=SUM(ABOVE)"),261 totalNum(t.money(budget.reduce(0) { $0 + $1.1 - $1.2 }, decimals: 0), formula: "=B5-C5")]])262263 b.heading(1, t("Risks and Issues", "Risques et enjeux"))264 b.body([r(t("[Keep only the risks that need attention.] They are ranked in ", "[Ne conservez que les risques qui exigent une attention.] Ils sont classés au "))] + b.ref(riskID, .table) + [r(".")])265 b.caption(.table, t("Risk register", "Registre des risques"), id: riskID)266 b.table([2, 0.9, 0.9, 2, 1],267 header: [th(t("Risk", "Risque")), th(t("Likelihood", "Probabilité")), th(t("Impact", "Incidence")), th(t("Mitigation", "Atténuation")), th(t("Owner", "Responsable"))],268 rows: (1...2).map { [cell(t("[Risk \($0)]", "[Risque \($0)]")), cell(t("[Low / Medium / High]", "[Faible / Moyenne / Élevée]")), cell(t("[Low / Medium / High]", "[Faible / Moyenne / Élevée]")),269 cell(t("[Action taken or planned]", "[Mesure prise ou prévue]")), cell(t("[Name]", "[Nom]"))] })270271 b.heading(1, t("Next Steps", "Prochaines étapes"))272 b.bullets([t("[Activity planned for the next period – owner – date]", "[Activité prévue pour la prochaine période – responsable – date]"),273 t("[Activity – owner – date]", "[Activité – responsable – date]")])274 b.heading(1, t("Decisions Required", "Décisions requises"))275 b.numbered([t("[Decision requested from the sponsor or the steering committee, with the deadline]", "[Décision attendue du promoteur ou du comité directeur, avec l'échéance]")])276 return b.build(title: title)277 }278279 // MARK: Invoice280281 static func invoice(_ c: TemplateContext) -> DocumentModel {282 var b = TemplateBuilder(c, theme: .modern, margins: Insets(top: 60, left: 64, bottom: 64, right: 64))283 let t = b.t284 let w = b.width285 let muted = b.muted, accent = b.theme.accent286 factStyle(&b, labelWidth: t.french ? 120 : 110)287 b.define("Letterhead", t("Letterhead", "En-tête"), next: "LetterheadDetails",288 char: CharProps(fontFamily: b.theme.headingFont, fontSize: 18, bold: true), para: ParaProps(spaceAfter: 2, keepWithNext: true, tabs: [TabStop(position: w, kind: .right)]))289 b.define("LetterheadDetails", t("Letterhead Details", "Coordonnées de l'en-tête"), next: StyleID.normal, char: CharProps(fontSize: b.theme.bodySize - 2, color: muted),290 para: ParaProps(spaceAfter: 20, lineSpacing: .multiple(1.15), borderBottom: BorderLine(width: 1.5, color: accent)))291 b.styles.upsert(Style(id: "InvoiceLabel", name: t("Invoice Label", "Mention « Facture »"), kind: .character,292 char: CharProps(fontSize: 22, weight: 300, color: accent, tracking: 2, allCaps: true)))293 b.define("BillToHeading", t("Bill-To Heading", "Titre « Facturé à »"), next: "BillTo",294 char: CharProps(fontSize: b.theme.bodySize - 2, bold: true, color: muted, tracking: 1, allCaps: true), para: ParaProps(spaceBefore: 14, spaceAfter: 2, keepWithNext: true))295 b.define("BillTo", t("Bill To", "Facturé à"), next: "BillTo", para: ParaProps(spaceAfter: 0, lineSpacing: .multiple(1.15)))296 b.define("InvoiceTotal", t("Invoice Total", "Total de la facture"), basedOn: TStyle.tableTotalNumber, char: CharProps(fontSize: b.theme.bodySize + 2, color: accent))297 b.define("InvoiceTotalLabel", t("Invoice Total Label", "Libellé du total de la facture"), basedOn: TStyle.tableTotal, char: CharProps(fontSize: b.theme.bodySize + 2, color: accent))298 b.define("Terms", t("Payment Terms", "Modalités de paiement"), next: "Terms", char: CharProps(fontSize: b.theme.bodySize - 1), para: ParaProps(spaceAfter: 4))299300 b.setup.footer = HeaderFooter(default: [b.footer([r(b.organization + " · " + t("[Tax registration numbers]", "[Numéros d'inscription aux taxes]")), tab, tab] + b.pageOfTotal)])301302 b.p("Letterhead", [r(b.organization), tab, Run(t("Invoice", "Facture"), charStyle: "InvoiceLabel")])303 b.p("LetterheadDetails", t("[Street address] · [City, Province] [Postal code] · [Telephone] · [E-mail]", "[Adresse municipale] · [Ville (Province)] [Code postal] · [Téléphone] · [Courriel]"))304 fact(&b, t("Invoice no.", "Facture n°"), [r(t("[0001]", "[0001]"))])305 fact(&b, t("Date", "Date"), [r(b.dateText)])306 fact(&b, t("Due date", "Échéance"), [r(t("[Date – for example, 30 days after the invoice date]", "[Date – par exemple, 30 jours après la date de facturation]"))])307 fact(&b, t("Reference", "Référence"), [r(t("[Purchase order or project]", "[Bon de commande ou projet]"))])308 fact(&b, t("Contact", "Personne-ressource"), [b.authorRun])309 b.p("BillToHeading", t("Bill to", "Facturé à"))310 for l in [t("[Client name]", "[Nom du client]"), t("[Organization]", "[Organisation]"), t("[Street address]", "[Adresse municipale]")] { b.p("BillTo", l) }311 b.p("BillTo", [r(t("[City, Province] [Postal code]", "[Ville (Province)] [Code postal]"))], props: ParaProps(spaceAfter: 18))312313 // Sample lines. Amount = quantity × unit price; the cell text carries the value the formula yields.314 let items: [(String, Double, Double)] = [(t("[Service or product 1 – short description]", "[Service ou produit 1 – courte description]"), 10, 120),315 (t("[Service or product 2]", "[Service ou produit 2]"), 1, 450), (t("[Service or product 3]", "[Service ou produit 3]"), 3, 85)]316 let subtotal = items.reduce(0) { $0 + $1.1 * $1.2 }317 let subRow = items.count + 2318 var rows: [[CellSpec]] = items.enumerated().map { i, it in319 [cell(it.0), num(t.number(it.1)), num(t.money(it.2)), num(t.money(it.1 * it.2), formula: "=B\(i + 2)*C\(i + 2)")]320 }321 rows.append([cell(""), cell(""), total(t("Subtotal", "Sous-total")), totalNum(t.money(subtotal), formula: "=SUM(ABOVE)")])322 // Canadian French: GST and QST. English: one generic sales-tax line.323 let taxes: [(String, Double)] = t.french ? [(t("", "TPS (5 %)"), 0.05), (t("", "TVQ (9,975 %)"), 0.09975)] : [("[Sales tax] (5%)", 0.05)]324 var totalDue = subtotal325 var totalFormula = "=D\(subRow)"326 for (i, tax) in taxes.enumerated() {327 let amount = (subtotal * tax.1 * 100).rounded() / 100328 totalDue += amount329 totalFormula += "+D\(subRow + 1 + i)"330 rows.append([cell(""), cell(""), cell(tax.0), num(t.money(amount), formula: "=D\(subRow)*\(tax.1)")])331 }332 rows.append([cell(""), cell(""), cell(t("Total due", "Total à payer"), style: "InvoiceTotalLabel"), totalNum(t.money(totalDue), formula: totalFormula, style: "InvoiceTotal")])333 b.table([3.2, 0.8, 1.6, 1.4],334 header: [th(t("Description", "Description")), thNum(t("Qty", "Qté")), thNum(t("Unit price", "Prix unitaire")), thNum(t("Amount", "Montant"))],335 rows: rows)336337 b.p("BillToHeading", [r(t("Payment terms", "Modalités de paiement"))], props: ParaProps(spaceBefore: 22))338 b.p("Terms", t("[Payment due within 30 days.] [Accepted methods: transfer, cheque, card.] [Bank details or payment link.]",339 "[Paiement exigible dans les 30 jours.] [Modes acceptés : virement, chèque, carte.] [Coordonnées bancaires ou lien de paiement.]"))340 b.p("Terms", t("[Interest on overdue amounts, if any.] The amounts above are samples: replace quantities and prices, then recalculate the table.",341 "[Intérêts sur les sommes en souffrance, s'il y a lieu.] Les montants ci-dessus sont des exemples : remplacez les quantités et les prix, puis recalculez le tableau."))342 b.p(StyleID.normal, [r(t("Thank you for your business.", "Merci de votre confiance."))], props: ParaProps(spaceBefore: 14))343 return b.build(title: t("Invoice [0001]", "Facture [0001]"))344 }345346 // MARK: Meeting minutes347348 static func meetingMinutes(_ c: TemplateContext) -> DocumentModel {349 var b = TemplateBuilder(c, theme: .technical, margins: Insets(top: 72, left: 68, bottom: 72, right: 68))350 let t = b.t351 let tint = b.tint, accent = b.theme.accent352 factStyle(&b, labelWidth: t.french ? 150 : 110)353 signatureStyles(&b)354 b.adjust(StyleID.title) { $0.para.spaceAfter = 2 }355 b.adjust(StyleID.subtitle) { $0.para.spaceAfter = 14 }356 b.define("Decision", t("Decision", "Décision"), next: StyleID.normal,357 para: ParaProps(indentLeft: 10, indentRight: 10, spaceBefore: 4, spaceAfter: 10, keepLinesTogether: true, shading: tint, borderLeft: BorderLine(width: 3, color: accent)))358359 let title = t("Meeting Minutes", "Procès-verbal de réunion")360 b.setup.differentFirstPage = true361 b.setup.header = HeaderFooter(default: [b.header([r(title + " – " + t("[Committee or team]", "[Comité ou équipe]")), tab, tab, r(b.dateText)])])362 b.setup.footer = HeaderFooter(default: [b.footer([r(b.organization), tab, tab] + b.pageOfTotal)], first: [b.footer([r(b.organization), tab, tab] + b.pageOfTotal)])363364 b.p(StyleID.title, title)365 b.p(StyleID.subtitle, t("[Committee or team] – [regular / special meeting]", "[Comité ou équipe] – [réunion ordinaire / extraordinaire]"))366 fact(&b, t("Date", "Date"), [r(b.dateText)])367 fact(&b, t("Time", "Heure"), [r(t("[Start] – [End]", "[Début] – [Fin]"))])368 fact(&b, t("Location", "Lieu"), [r(t("[Room or video-conference link]", "[Salle ou lien de visioconférence]"))])369 fact(&b, t("Chair", "Présidence"), [r(t("[Name]", "[Nom]"))])370 fact(&b, t("Minutes taken by", "Secrétaire de réunion"), [b.authorRun])371372 b.heading(1, t("Attendance", "Présences"))373 fact(&b, t("Present", "Présents"), [r(t("[Name], [Name], [Name]", "[Nom], [Nom], [Nom]"))])374 fact(&b, t("Regrets", "Absents"), [r(t("[Name]", "[Nom]"))])375 fact(&b, t("Guests", "Invités"), [r(t("[Name, organization]", "[Nom, organisation]"))])376377 b.heading(1, t("Agenda", "Ordre du jour"))378 b.numbered([t("Call to order and adoption of the agenda", "Ouverture de la réunion et adoption de l'ordre du jour"),379 t("Approval of the minutes of the previous meeting", "Approbation du procès-verbal de la réunion précédente"),380 t("[Agenda item]", "[Point à l'ordre du jour]"), t("[Agenda item]", "[Point à l'ordre du jour]"),381 t("Other business", "Questions diverses"), t("Adjournment", "Levée de la réunion")])382383 b.heading(1, t("Discussion and Decisions", "Délibérations et décisions"))384 for n in 1...2 {385 b.heading(2, t("[Agenda item \(n + 2)]", "[Point \(n + 2) de l'ordre du jour]"))386 b.body(t("[Summarize the discussion in a few sentences: the facts presented and the positions expressed, without attributing every remark.]",387 "[Résumez les échanges en quelques phrases : les faits présentés et les positions exprimées, sans attribuer chaque intervention.]"))388 b.p("Decision", [strong(t("Decision: ", "Décision : ")), r(t("[Wording of the decision or resolution, moved by [Name], seconded by [Name]; carried / defeated.]",389 "[Libellé de la décision ou de la résolution, proposée par [Nom], appuyée par [Nom] ; adoptée / rejetée.]"))])390 }391392 b.heading(1, t("Action Items", "Suivis"))393 b.table([0.5, 3, 1.3, 1.1, 1.1],394 header: [thNum(t("No.", "N°")), th(t("Action", "Action")), th(t("Owner", "Responsable")), th(t("Due", "Échéance")), th(t("Status", "État"))],395 rows: (1...3).map { [num(String($0)), cell(t("[Action to take]", "[Action à réaliser]")), cell(t("[Name]", "[Nom]")), cell("[date]"), cell(t("[Open / Done]", "[En cours / Terminé]"))] },396 style: b.bandedTable)397398 b.heading(1, t("Next Meeting", "Prochaine réunion"))399 b.body(t("[Date, time and location of the next meeting.] The meeting was adjourned at [time].", "[Date, heure et lieu de la prochaine réunion.] La réunion est levée à [heure]."))400 b.p("SignatureLine", [tab, tab, tab])401 b.p("SignatureCaption", [r(t("[Name], Chair", "[Nom], présidence")), tab, r(b.author + t(", Secretary", ", secrétaire"))])402 return b.build(title: title)403 }404}405