PHPackages                             sp4tz/abacus-xml-exporter - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Parsing &amp; Serialization](/categories/parsing)
4. /
5. sp4tz/abacus-xml-exporter

ActiveLibrary[Parsing &amp; Serialization](/categories/parsing)

sp4tz/abacus-xml-exporter
=========================

PHP library to export timesheet entries to Abacus XML.

2.0.0(1mo ago)04MITPHP ^8.2

Since May 5Compare

[ Source](https://github.com/Sp4tz7/abacus-xml-exporter)[ Packagist](https://packagist.org/packages/sp4tz/abacus-xml-exporter)[ RSS](/packages/sp4tz-abacus-xml-exporter/feed)WikiDiscussions Synced 3w ago

READMEChangelogDependenciesVersions (4)Used By (0)

Abacus XML Exporter (PHP)
=========================

[](#abacus-xml-exporter-php)

Librairie PHP pour convertir des entrées de feuille de temps en XML Abacus LOHN `FlatPreEntry`.

Prérequis
---------

[](#prérequis)

- PHP 8.2+
- Composer

Installation
------------

[](#installation)

Dans un projet PHP classique ou Symfony:

```
composer require sp4tz/abacus-xml-exporter
```

En développement local:

```
composer dump-autoload
```

Compatibilité Abacus
--------------------

[](#compatibilité-abacus)

Ce package cible **Abacus LOHN FlatPreEntry 2020.00**.

Documentation officielle Abacus:

[https://downloads.abacus.ch/fileadmin/ablage/abaconnect/htmlfiles/lohn/LOHN\_\_FlatPreEntry\_2020.00\_AbaDefault\_FR.html](https://downloads.abacus.ch/fileadmin/ablage/abaconnect/htmlfiles/lohn/LOHN__FlatPreEntry_2020.00_AbaDefault_FR.html)

Configuration obligatoire
-------------------------

[](#configuration-obligatoire)

Avant le premier export, configurez les données de la société dans `src/Abacus/Export/AbacusXmlExportConfig.php`.

Champs principaux à renseigner :

- `mandant`

Options utiles:

- `validateEntries` : active ou désactive la validation avant export
- `prettyPrint` : XML lisible (dev) ou compact (prod)

Exemple:

```
$config = new AbacusXmlExportConfig(
    mandant: '123456',
);
```

Exemples d'utilisation
----------------------

[](#exemples-dutilisation)

### 1) Usage PHP simple hors Symfony

[](#1-usage-php-simple-hors-symfony)

Lancez directement l'exemple autonome :

```
php examples/plain-php.php
```

Cet exemple montre le flux complet :

- tableaux bruts `ligne1..ligne8`
- `ArrayTimesheetEntryMapper`
- export XML en string
- export XML dans `exportedEntries.xml`

### 2) Usage avec un DTO metier / Symfony

[](#2-usage-avec-un-dto-metier--symfony)

La librairie expose un contrat de mapping via `AbaConnect\Abacus\Mapper\TimesheetEntryMapperInterface`.

Exemple:

```
use AbaConnect\Abacus\Mapper\TimesheetEntryMapperInterface;
use AbaConnect\Abacus\Mapper\ArrayTimesheetEntryMapper;

/** @var TimesheetEntryMapperInterface $mapper */
$mapper = new ArrayTimesheetEntryMapper();
```

Classes principales
-------------------

[](#classes-principales)

- `src/Abacus/Dto/TimesheetEntry.php`
- `src/Abacus/Export/AbacusXmlExporter.php`
- `src/Abacus/Export/AbacusXmlExportConfig.php`
- `src/Abacus/Exception/AbacusXmlExportException.php`
- `src/Abacus/Mapper/TimesheetEntryMapperInterface.php`
- `src/Abacus/Mapper/ArrayTimesheetEntryMapper.php`
- `src/Abacus/Mapper/ExampleTimesheetEntryMapper.php`

Contraintes `TimesheetEntry`
----------------------------

[](#contraintes-timesheetentry)

- Obligatoires: `employeeNumber` (int), `periodDate` (DateTimeInterface), `periodNumber` (int), `payrollType` (int)
- Optionnels: `amount` (?float), `factor` (?float), `costCentre1` (?int), `textPayrollType` (?string)
- Validation export:
    - `amount` / `factor`: max 10 caracteres, separateur decimal `.` requis, max 6 decimales
    - `costCentre1`: max 12 caracteres
    - `textPayrollType`: max 100 caracteres

Namespaces utilises:

- `AbaConnect\Abacus\Dto`
- `AbaConnect\Abacus\Export`
- `AbaConnect\Abacus\Exception`
- `AbaConnect\Abacus\Mapper`

Exemple minimal
---------------

[](#exemple-minimal)

```
