Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
laragear-dte-build
laragear-dte-build
laragear/dte
claude-code
dte
sii
electronic-invoicing
facades
receivable
receiver-data
builders

Use this skill to create SII documents (DTE) inside business logic (buying, selling, etc). Don't use this skill for purchase history, commercial notifications, commercial acknowledgement.

Install
php artisan boost:add-skill laragear/dte

Save this content to: .claude/skills/build/SKILL.md

# Laragear Dte Build

Use the `Sii{DocumentType}` facade to create a DTE depending on the type required to legally issue. Each facade instances a custom builder for each document type:

| Builder                        | Description                          | Reason                              |
|--------------------------------|--------------------------------------|-------------------------------------|
| `SiiInvoice::class`            | Electronic invoice / exempt          | Selling B2B                         |
| `SiiReceipt::class`            | Electronic receipt (boleta)          | Selling B2C                         |
| `SiiCreditNote::class`         | Credit note                          | Anull/Amends/Discount Invoice       |
| `SiiDebitNote::class`          | Debit note                           | Anull/Amend/Charge Invoice          |
| `SiiDispatchGuide::class`      | Dispatch guide (guía de despacho)    | Moving unsold goods                 |
| `SiiInvoiceLiquidation::class` | Invoice liquidation                  | Consignment sales, Commissions      |
| `SiiPurchaseInvoice::class`    | Purchase invoice (factura de compra) | Buying from consumers/international |
| `SiiAecBuilder::class`         | AEC (Acuse Electrónico de Cargo),    | Factoring / Cession                 |

Depending on the builder, some methods will be available and others won't. You're required to check the methods available for each builder on the source code using codebase tools available, e.g. search codebase, find nodes, etc.

## Receiver

Call `receivedBy` to set in the receipt the optional person RUT and name.

```php
use Laragear\Dte\Facades\SiiReceipt;

$invoice = SiiReceipt::receivedBy('18.765.321-0', 'Jorge Pérez');
```

All other documents that are not receipts, the full Business data is required. This must be done using the `ReceiverData` object and filling all required properties.

```php
use Laragear\Dte\Data\ReceiverData;
use Laragear\Dte\Facades\SiiInvoice;

$receiver = ReceiverData::make(
    rut: '76.123.456-0',
    name: 'Ferretería Pérez Ltda.',
    activity: 'Compra venta de artículos de construcción',
    email: '[email protected]', // Optional
    address: 'Avenida Principal 48', 
    commune: 'Osorno',
    city: 'Osorno',
);

$invoice = SiiInvoice::receivedBy($receiver);
``` 

### Eloquent Model as Receiver

Implement the `Laragear\Dte\Contracts\Receivable` interface on models that can be used as valid document receivers: Business, Company, Tenant, Customer, Client, Organization, etc. Pass the model instance directly to `receivedBy()` instead of transforming it manually into a `ReceiverData`.

```php
use Illuminate\Database\Eloquent\Model;
use Laragear\Dte\Contracts\Receivable;
use Laragear\Dte\Data\ReceiverData;

class Business extends Model implements Receivable
{
    // ...

    public function toReceivable(): ReceiverData
    {
        return ReceiverData::make(
            // ... 
        );
    }
}

use Laragear\Dte\Facades\SiiInvoice;

$business = Business::find(66);

$invoice = SiiInvoice::receivedBy($business);
```

## Adding Items

Use `addItem()` to add simple description-price items. If the item should be legally exempt from taxes, use `isExempt: true`.

```php
use Laragear\Dte\Facades\SiiInvoice;

$invoice = SiiInvoice::receivedBy($business)
    ->addItem('Crema de Leche', 12_000)
    ->addItem('Clases de ordeñamiento', 56_000, isExempt: true)
    ->create();
```

For more control on the item to be added (price per unit, quantity, description, taxes, etc.), use the `ItemData` object.

```php
use Laragear\Dte\Data\Item;
use Laragear\Dte\Facades\SiiInvoice;

$item = Item::make(
    name: 'Crema de Leche', 
    unitPrice: 1_200,
    quantity: 10,
    discountPercentage: 0.15
);

$invoice = SiiInvoice::receivedBy('76.543.210-K', 'Helados S.A.')
    ->addItem($item)
    ->create();
```

### Eloquent Model as Item

Implement the `Laragear\Dte\Contracts\Itemable` interface on models that can be used as valid document receivers: Item, Article, Product, Service, Good, or LineItem, etc. Pass the model instance directly to `addItem()` instead of transforming it manually into a `Item`.

```php
use Illuminate\Database\Eloquent\Model;
use Laragear\Dte\Contracts\Itemable;
use Laragear\Dte\Data\Item;
use Laragear\Dte\Data\ReceiverData;
use Laragear\Dte\Facades\SiiInvoice;

class Product extends Model implements Itemable
{
    // ...

    public function toItem(): Item
    {
        return Item::make(
            // ... 
        );
    }
}

use Laragear\Dte\Facades\SiiInvoice;

$item = Product::find(4658);

$invoice = SiiInvoice::addItem($item);
```

## Persistence

Use the `create()` to persist the DTE into the database. The method returns an `Laragear\Dte\Models\SiiDte` model instance. Consider this instance as **READ-ONLY**. Use the model instance for later reference: attaching it to a purchase order, cart, internal invoicing/receipt, ERP ingress/egress registration, accounting API, etc.

```php
use Laragear\Dte\Facades\SiiInvoice;

$invoice = SiiInvoice::receivedBy($business)
    ->addItem('Crema de Leche', 12_000)
    ->create();
```

If the user requires printing a PDF immediately, use the `sync: true`. The operation will take a few seconds. The PDF will be able to be generated using `pdf()->generate()`.

```php
use Laragear\Dte\Facades\SiiInvoice;

$invoice = SiiInvoice::receivedBy($business)
    ->addItem('Crema de Leche', 12_000)
    ->create(sync: true);

$pdf = $invoice->pdf()->generate();

$disk = $pdf->disk;
$path = $pdf->path;

return Storage::disk($disk, $path);
```

Laragear Dte Build

Use the Sii{DocumentType} facade to create a DTE depending on the type required to legally issue. Each facade instances a custom builder for each document type:

Builder Description Reason
SiiInvoice::class Electronic invoice / exempt Selling B2B
SiiReceipt::class Electronic receipt (boleta) Selling B2C
SiiCreditNote::class Credit note Anull/Amends/Discount Invoice
SiiDebitNote::class Debit note Anull/Amend/Charge Invoice
SiiDispatchGuide::class Dispatch guide (guía de despacho) Moving unsold goods
SiiInvoiceLiquidation::class Invoice liquidation Consignment sales, Commissions
SiiPurchaseInvoice::class Purchase invoice (factura de compra) Buying from consumers/international
SiiAecBuilder::class AEC (Acuse Electrónico de Cargo), Factoring / Cession

Depending on the builder, some methods will be available and others won't. You're required to check the methods available for each builder on the source code using codebase tools available, e.g. search codebase, find nodes, etc.

Receiver

Call receivedBy to set in the receipt the optional person RUT and name.

use Laragear\Dte\Facades\SiiReceipt;

$invoice = SiiReceipt::receivedBy('18.765.321-0', 'Jorge Pérez');

All other documents that are not receipts, the full Business data is required. This must be done using the ReceiverData object and filling all required properties.

use Laragear\Dte\Data\ReceiverData;
use Laragear\Dte\Facades\SiiInvoice;

$receiver = ReceiverData::make(
    rut: '76.123.456-0',
    name: 'Ferretería Pérez Ltda.',
    activity: 'Compra venta de artículos de construcción',
    email: '[email protected]', // Optional
    address: 'Avenida Principal 48', 
    commune: 'Osorno',
    city: 'Osorno',
);

$invoice = SiiInvoice::receivedBy($receiver);

Eloquent Model as Receiver

Implement the Laragear\Dte\Contracts\Receivable interface on models that can be used as valid document receivers: Business, Company, Tenant, Customer, Client, Organization, etc. Pass the model instance directly to receivedBy() instead of transforming it manually into a ReceiverData.

use Illuminate\Database\Eloquent\Model;
use Laragear\Dte\Contracts\Receivable;
use Laragear\Dte\Data\ReceiverData;

class Business extends Model implements Receivable
{
    // ...

    public function toReceivable(): ReceiverData
    {
        return ReceiverData::make(
            // ... 
        );
    }
}

use Laragear\Dte\Facades\SiiInvoice;

$business = Business::find(66);

$invoice = SiiInvoice::receivedBy($business);

Adding Items

Use addItem() to add simple description-price items. If the item should be legally exempt from taxes, use isExempt: true.

use Laragear\Dte\Facades\SiiInvoice;

$invoice = SiiInvoice::receivedBy($business)
    ->addItem('Crema de Leche', 12_000)
    ->addItem('Clases de ordeñamiento', 56_000, isExempt: true)
    ->create();

For more control on the item to be added (price per unit, quantity, description, taxes, etc.), use the ItemData object.

use Laragear\Dte\Data\Item;
use Laragear\Dte\Facades\SiiInvoice;

$item = Item::make(
    name: 'Crema de Leche', 
    unitPrice: 1_200,
    quantity: 10,
    discountPercentage: 0.15
);

$invoice = SiiInvoice::receivedBy('76.543.210-K', 'Helados S.A.')
    ->addItem($item)
    ->create();

Eloquent Model as Item

Implement the Laragear\Dte\Contracts\Itemable interface on models that can be used as valid document receivers: Item, Article, Product, Service, Good, or LineItem, etc. Pass the model instance directly to addItem() instead of transforming it manually into a Item.

use Illuminate\Database\Eloquent\Model;
use Laragear\Dte\Contracts\Itemable;
use Laragear\Dte\Data\Item;
use Laragear\Dte\Data\ReceiverData;
use Laragear\Dte\Facades\SiiInvoice;

class Product extends Model implements Itemable
{
    // ...

    public function toItem(): Item
    {
        return Item::make(
            // ... 
        );
    }
}

use Laragear\Dte\Facades\SiiInvoice;

$item = Product::find(4658);

$invoice = SiiInvoice::addItem($item);

Persistence

Use the create() to persist the DTE into the database. The method returns an Laragear\Dte\Models\SiiDte model instance. Consider this instance as READ-ONLY. Use the model instance for later reference: attaching it to a purchase order, cart, internal invoicing/receipt, ERP ingress/egress registration, accounting API, etc.

use Laragear\Dte\Facades\SiiInvoice;

$invoice = SiiInvoice::receivedBy($business)
    ->addItem('Crema de Leche', 12_000)
    ->create();

If the user requires printing a PDF immediately, use the sync: true. The operation will take a few seconds. The PDF will be able to be generated using pdf()->generate().

use Laragear\Dte\Facades\SiiInvoice;

$invoice = SiiInvoice::receivedBy($business)
    ->addItem('Crema de Leche', 12_000)
    ->create(sync: true);

$pdf = $invoice->pdf()->generate();

$disk = $pdf->disk;
$path = $pdf->path;

return Storage::disk($disk, $path);
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
shitoudev/permissionmanager
johannesclimacus/laravel-tui
hocvt/seotools
vitalybaev/sypexgeo
amphibee/themosis-ignition
gito-me/fast-excel
frankyso/laravel-ipaymu
geolize-studio/laravel-chile
boomerangui/chat
jinas/dhivatar
store-doc/laravel-storage-driver
plus-it/laravel-translation-manager
diephp/perhaps
diephp/telegraph
osmaviation/spreadsheet
microsoft/fluentui-system-icons
mmccook/php-json-canonicalization-scheme
middlewares/firewall
qubiqx/montapacking
nyoncode/laravel-package-console