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-setup
laragear-dte-setup
laragear/dte
claude-code
dte
sii
caf
certificates
artisan-commands
scheduling
resolvers

Use this skill to setup the library the first time after install; skip when the project already configured company and certificate resolvers on the `app/Providers/AppServiceProvider.php` or `bootstrap/app.php`.

Install
php artisan boost:add-skill laragear/dte

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

# Laragear Dte Setup

- **Company data:** Prioritize Eloquent Models over app configuration. If there is no model or configuration to base the company data, use hard-coded values.

To enable handling legal SII DTE (documents) in the application on development environments, prepare the library in this order:

1. Create a fake certificate: Execute the Artisan command. The certificate created uses `secret` as default password.

```shell
php artisan dte:make-fake-cert --rut="76.123.456-0" --name="My project business" 
```

2. Create a fake CAF: Execute the Artisan command. Create for Invoices (Code 33) and Receipt (Code 39).

```shell
php artisan dte:make-fake-caf --rut="76.123.456-0" --type:33
php artisan dte:make-fake-caf --rut="76.123.456-0" --type:39
```

3. Schedule commands for continuous operation. Add the following lines to the `routes/console.php` to schedule the required commands, if these are not present already.

```php
use Illuminate\Support\Facades\Schedule;

Schedule::command('dte:check-cafs')->everyTwoHours();
Schedule::command('dte:process-envelope')->everyTenMinutes();
Schedule::command('dte:fetch-mailbox')->hourly();
Schedule::command('dte:poll-track-status')->hourly();
Schedule::command('dte:reject-phantom-invoices')->twiceDaily();
```

4. Register a Company resolver, so the library knows which Company is creating DTE and sending DTE envelopes.

```php
// app/Providers/AppServiceProvider.php
use Laragear\Dte\Configuration\ConfigurationManager;
use Laragear\Dte\Data\IssuerData;

public function register()
{
    ConfigurationManager::resolveIssuerUsing(function (?Rut $rut) {
        return IssuerData::make(
            rut: '76.123.456-0',
            name: 'Mi Empresa S.A.',
            businessActivity: 'CULTIVO DE ARROZ',
            economicActivity: 'Venta de Arroz al por mayor',
            address: 'Ruta 78 Norte, Kilómetro 75.',
            commune: 'Huasco',
            city: 'Vallenar',
            resolutionDate: 0, // Default until given by SII
            resolutionNumber: null, // To be set after certification
        );
    });
}
```

5. Register a Sender Resolver, so the library can set which business is sending the DTE to SII.

```php
// app/Providers/AppServiceProvider.php
use Laragear\Dte\Configuration\ConfigurationManager;
use Laragear\Rut\Rut;

public function register()
{
    ConfigurationManager::resolveSenderUsing(function (Rut $issuerRut): Rut {
        return Rut::parse('76.123.456-0');
    });
}
```

6. Register a Certificate Resolver, so the library can sign DTE based on the issuer business. The `resolveUsingDefault()` will automatically retrieve the certificate file using the library `dte.certificate` configuration.

```php
// app/Providers/AppServiceProvider.php
use Laragear\Dte\Certificate\CertificateResolver;

public function register()
{
    CertificateResolver::resolveUsingDefaults();
}
```

If the certificate is stored elsewhere, or its password is resolved dynamically, use the `resolveUsing` with a callback that returns an instance of `DigitalCertificate`, e.g., an Eloquent Model that is an instance of `Certifiable`.

```php
// app/Providers/AppServiceProvider.php
use App\Models\Certificate;
use Laragear\Dte\Certificate\CertificateResolver;
use Laragear\Dte\Certificate\DigitalCertificate;
use Laragear\Rut\Rut;

public function register()
{
    CertificateResolver::resolveUsing(function (Rut $rut): ?DigitalCertificate {
        return Certificate::whereRut($rut)->first();
    });
}
```

Laragear Dte Setup

  • Company data: Prioritize Eloquent Models over app configuration. If there is no model or configuration to base the company data, use hard-coded values.

To enable handling legal SII DTE (documents) in the application on development environments, prepare the library in this order:

  1. Create a fake certificate: Execute the Artisan command. The certificate created uses secret as default password.
php artisan dte:make-fake-cert --rut="76.123.456-0" --name="My project business" 
  1. Create a fake CAF: Execute the Artisan command. Create for Invoices (Code 33) and Receipt (Code 39).
php artisan dte:make-fake-caf --rut="76.123.456-0" --type:33
php artisan dte:make-fake-caf --rut="76.123.456-0" --type:39
  1. Schedule commands for continuous operation. Add the following lines to the routes/console.php to schedule the required commands, if these are not present already.
use Illuminate\Support\Facades\Schedule;

Schedule::command('dte:check-cafs')->everyTwoHours();
Schedule::command('dte:process-envelope')->everyTenMinutes();
Schedule::command('dte:fetch-mailbox')->hourly();
Schedule::command('dte:poll-track-status')->hourly();
Schedule::command('dte:reject-phantom-invoices')->twiceDaily();
  1. Register a Company resolver, so the library knows which Company is creating DTE and sending DTE envelopes.
// app/Providers/AppServiceProvider.php
use Laragear\Dte\Configuration\ConfigurationManager;
use Laragear\Dte\Data\IssuerData;

public function register()
{
    ConfigurationManager::resolveIssuerUsing(function (?Rut $rut) {
        return IssuerData::make(
            rut: '76.123.456-0',
            name: 'Mi Empresa S.A.',
            businessActivity: 'CULTIVO DE ARROZ',
            economicActivity: 'Venta de Arroz al por mayor',
            address: 'Ruta 78 Norte, Kilómetro 75.',
            commune: 'Huasco',
            city: 'Vallenar',
            resolutionDate: 0, // Default until given by SII
            resolutionNumber: null, // To be set after certification
        );
    });
}
  1. Register a Sender Resolver, so the library can set which business is sending the DTE to SII.
// app/Providers/AppServiceProvider.php
use Laragear\Dte\Configuration\ConfigurationManager;
use Laragear\Rut\Rut;

public function register()
{
    ConfigurationManager::resolveSenderUsing(function (Rut $issuerRut): Rut {
        return Rut::parse('76.123.456-0');
    });
}
  1. Register a Certificate Resolver, so the library can sign DTE based on the issuer business. The resolveUsingDefault() will automatically retrieve the certificate file using the library dte.certificate configuration.
// app/Providers/AppServiceProvider.php
use Laragear\Dte\Certificate\CertificateResolver;

public function register()
{
    CertificateResolver::resolveUsingDefaults();
}

If the certificate is stored elsewhere, or its password is resolved dynamically, use the resolveUsing with a callback that returns an instance of DigitalCertificate, e.g., an Eloquent Model that is an instance of Certifiable.

// app/Providers/AppServiceProvider.php
use App\Models\Certificate;
use Laragear\Dte\Certificate\CertificateResolver;
use Laragear\Dte\Certificate\DigitalCertificate;
use Laragear\Rut\Rut;

public function register()
{
    CertificateResolver::resolveUsing(function (Rut $rut): ?DigitalCertificate {
        return Certificate::whereRut($rut)->first();
    });
}
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.
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
pnscripts/filament-broadquill-lite
pnscripts/laravel-sentfold-lite
vleap/mx-sdk-laravel-internal
twidpay/utils
htetmyathlaing/scout-elasticsearch-driver
artisan-toolbox/front-awesome
ls/client-assistant
users-au/laravel-client
cgv/localized-resource