KScript documentación
ES

Idioma

Traducido automáticamente del inglés, que es la versión original.

Documentos: KScript.Document

Cartas y facturas

Letter organiza una carta alrededor de los párrafos que contiene. En las direcciones, \n inicia una nueva línea:

<KScript.Document template="letter" to="'letter.pdf'">
  <Letter from="{'Life Lab\n12 Grid Street\nCambridge'}" to="{'Dr Ada Lovelace\nExample University'}" subject="Invitation to speak" opening="Dear Dr Lovelace," closing="Yours sincerely," signature="Alan Turing">
    <Paragraph>We would be delighted if you would give the opening talk.</Paragraph>
  </Letter>
</KScript.Document>
import KScript.Document

Document(template: letter, to: 'letter.pdf') {
  Letter(from: 'Life Lab\n12 Grid Street\nCambridge', to: 'Dr Ada Lovelace\nExample University', subject: 'Invitation to speak', opening: 'Dear Dr Lovelace,', closing: 'Yours sincerely,', signature: 'Alan Turing') {
    Paragraph "We would be delighted if you would give the opening talk."
  }
}

Invoice genera la factura completa a partir de una lista de artículos. Cada artículo tiene una description, una quantity (por defecto 1) y un price, o un amount. El subtotal, el impuesto y el total se calculan por ti:

<let name="items" value="[{ description: 'Consulting', quantity: 3, price: 450 }, { description: 'Travel', price: 64.2 }]" />

<import package="KScript.Document" />

<Document template="invoice" to="'invoice.pdf'">
  <Invoice number="INV-042" from="{'Life Lab Ltd\n12 Grid Street'}" to="Example University" due="20 December 2026" items="$items" currency="GBP" tax="20" notes="Please pay within 30 days." />
</Document>
$items = [{ description: 'Consulting', quantity: 3, price: 450 }, { description: 'Travel', price: 64.2 }]

import KScript.Document

Document(template: invoice, to: 'invoice.pdf') {
  Invoice(number: 'INV-042', from: 'Life Lab Ltd\n12 Grid Street', to: 'Example University', due: '20 December 2026', items: $items, currency: 'GBP', tax: 20, notes: 'Please pay within 30 days.')
}

currency: es un código como GBP, USD, EUR o JPY, o cualquier símbolo. tax: es un porcentaje, tax_name: es cómo se llama (IVA predeterminado), y paid: es un importe ya pagado, que genera un saldo pendiente.