Skip to content

A Swift package that enables the data-driven creation of common business documents.

License

Notifications You must be signed in to change notification settings

coenttb/swift-document-templates

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Swift Document Templates

Swift Document Templates is a Swift package that enables the data-driven creation of common business documents. Designed for ease of use and automation, it leverages Swift's powerful type system and modern syntax to ensure accuracy and consistency. Whether you're generating an invoice, an agenda, or a letter, Swift Document Templates has you covered.

Features

  • Invoice: Generate detailed invoices with automatic calculations and custom metadata.
  • Letter: Draft formal letters with consistent formatting and customizable content.
  • Agenda: Create structured agendas for meetings, outlining topics, speakers, and timings. (Under Construction)
  • Attendance List: Maintain a record of attendees for meetings, events, or training sessions. (Under Construction)
  • Invitation: Send professional invitations for events, meetings, or conferences. (Under Construction)

Installation

To install Swift Document Templates, add the following line to your Package.swift file:

dependencies: [
    .package(url: "https://github.com/coenttb/swift-document-templates.git", from: "0.1.0")
]

You can then make Swift Document Templates available to your package's target by including DocumentTemplates in the dependencies of any target in your package, as follows:

targets: [
    .target(
        name: "TheNameOfYourTarget",
        dependencies: [
            .product(name: "DocumentTemplates", package: "swift-document-templates")
        ]
    )
]

Finally, import DocumentTemplates in your .swift file(s), as follows:

import DocumentTemplates

...your swift code...

Usage

Invoice

Generate an invoice with line items:

import DocumentTemplates

let invoice = Invoice(
    sender: .init(name: "Your Company", address: ["123 Main St", "City", "Country"], phone: "123-456-7890", email: "[email protected]", website: "www.company.com", kvk: "12345678", btw: "NL123456789B01", iban: "NL00BANK1234567890"),
    client: .init(id: "CUST001", name: "Client Name", address: ["789 Maple St", "City", "Country"]),
    invoiceNumber: "INV001",
    invoiceDate: Date.now,
    expiryDate: (Date.now + 30.days),
    metadata: [:],
    rows: [
        .service(.init(amountOfHours: 160, hourlyRate: 140.00, vat: 21%, description: "Consulting services"))
    ]
)

Invoice

Letter

Draft a formal letter:

import DocumentTemplates

let sender: Letter.Sender = .init(
    name: "Your Company",
    address: ["123 Main St", "City", "Country"],
    phone: "123-456-7890",
    email: "[email protected]",
    website: "www.company.com"
)
let recipient: Letter.Recipient = .init(
    name: "Recipient Name",
    address: ["456 Elm St", "City", "Country"]
)

let letter = Letter(
    sender: sender,
    recipient: recipient,
    location: "Utrecht",
    date: (sending: Date.now, signature: nil),
    subject: "Subject of the Letter"
) {
    "Dear \(recipient.name),"
    p { "I hope this finds you well." }
    p { "Best regards," }
    p { "coenttb" }
}

Letter

Under Construction

The following features are currently under development and will be available in future updates:

  • Agenda: Create structured agendas for meetings, outlining topics, speakers, and timings.
  • Attendance List: Maintain a record of attendees for meetings, events, or training sessions.
  • Invitation: Send professional invitations for events, meetings, or conferences.

Contributing

We welcome contributions to Swift Document Templates. If you find a bug or have a feature request, please open an issue on GitHub. For major changes, please open a discussion first to ensure your work aligns with the project's direction.

License

Swift Document Templates is available under the LICENSE.

Contact

For questions or feedback, you can reach me at [email protected].

About

A Swift package that enables the data-driven creation of common business documents.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages