fix: PDF-Anhänge und Bezeichnung für Lieferantenrechnungen (v4.2)
PDF-Anhänge: - ZUGFeRD-PDF wird jetzt in ECM-Datenbank registriert (llx_ecm_files) - Verhindert Verlust der PDF beim Validieren der Rechnung - Korrekte Verknüpfung über src_object_type/src_object_id Rechnungsliste: - Teuerster Artikel wird als Bezeichnung (label) der Rechnung gesetzt - Erleichtert schnelle Identifikation in der Lieferantenrechnungsliste Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
c8e6d2f394
commit
650c42b8f0
4 changed files with 57 additions and 14 deletions
|
|
@ -9,12 +9,9 @@
|
||||||
"Bash(cut:*)",
|
"Bash(cut:*)",
|
||||||
"Bash(grep:*)",
|
"Bash(grep:*)",
|
||||||
"Bash(mysql:*)",
|
"Bash(mysql:*)",
|
||||||
|
"Bash(mariadb:*)",
|
||||||
"Bash(ls:*)",
|
"Bash(ls:*)",
|
||||||
"Bash(php:*)",
|
"Bash(php:*)",
|
||||||
<<<<<<< HEAD
|
|
||||||
"Bash(for module in /srv/http/dolibarr/custom/*/core/modules/mod*.php)",
|
|
||||||
"Bash(do echo \"=== $module ===\" grep -A5 \"''js''\" \"$module\")",
|
|
||||||
"Bash(done)",
|
|
||||||
"Bash(find:*)",
|
"Bash(find:*)",
|
||||||
"Bash(chown:*)",
|
"Bash(chown:*)",
|
||||||
"Bash(sudo chown:*)",
|
"Bash(sudo chown:*)",
|
||||||
|
|
@ -35,13 +32,9 @@
|
||||||
"Bash(git tag:*)",
|
"Bash(git tag:*)",
|
||||||
"Bash(git push:*)",
|
"Bash(git push:*)",
|
||||||
"Bash(git pull:*)",
|
"Bash(git pull:*)",
|
||||||
"Bash(git stash:*)"
|
"Bash(git stash:*)",
|
||||||
=======
|
"Bash(1 <<'EOF'\nSELECT \n i.rowid as import_id,\n i.ref as import_ref,\n i.invoice_number,\n i.status,\n i.fk_facture_fourn,\n DATE\\(i.date_creation\\) as datum\nFROM llx_importzugferd_import i\nWHERE i.status = 'processed'\nORDER BY i.date_creation DESC\nLIMIT 10;\nEOF)",
|
||||||
"Bash(mariadb:*)",
|
"Bash(git commit -m \"$\\(cat <<''EOF''\nfix: PDF-Anhänge und Bezeichnung für Lieferantenrechnungen \\(v4.2\\)\n\nPDF-Anhänge:\n- ZUGFeRD-PDF wird jetzt in ECM-Datenbank registriert \\(llx_ecm_files\\)\n- Verhindert Verlust der PDF beim Validieren der Rechnung\n- Korrekte Verknüpfung über src_object_type/src_object_id\n\nRechnungsliste:\n- Teuerster Artikel wird als Bezeichnung \\(label\\) der Rechnung gesetzt\n- Erleichtert schnelle Identifikation in der Lieferantenrechnungsliste\n\nCo-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>\nEOF\n\\)\")"
|
||||||
"Bash(git add:*)",
|
|
||||||
"Bash(git commit -m \"$\\(cat <<''EOF''\nVersion 3.2: Cross-Katalog-Suche und Multi-Lieferanten-Preise\n\n- Cross-Katalog-Suche: Artikel werden via EAN/Hersteller-Art.Nr. in allen Katalogen gefunden\n- Multi-Lieferanten-Anzeige mit Preisvergleich \\(Prozent guenstiger/teurer\\)\n- Fehlende Lieferantenpreise werden bei zugeordneten Produkten angeboten\n- Fix: Kluxen-Datanorm Preise im A-Record \\(Cent -> Euro Umrechnung\\)\n- Neue Uebersetzungen fuer Lieferanten-Alternativen\n\nCo-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>\nEOF\n\\)\")",
|
|
||||||
"Bash(git push:*)"
|
|
||||||
>>>>>>> 8521c7f (Version 3.3)
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
13
CHANGELOG.md
13
CHANGELOG.md
|
|
@ -2,6 +2,19 @@
|
||||||
|
|
||||||
Alle wesentlichen Änderungen an diesem Projekt werden in dieser Datei dokumentiert.
|
Alle wesentlichen Änderungen an diesem Projekt werden in dieser Datei dokumentiert.
|
||||||
|
|
||||||
|
## [4.2] - 2026-03-02
|
||||||
|
|
||||||
|
### Behoben
|
||||||
|
- **PDF-Anhänge**: ZUGFeRD-PDFs werden jetzt korrekt an Lieferantenrechnungen angehängt
|
||||||
|
- Problem: PDF wurde nur ins Dateisystem kopiert, nicht in ECM-Datenbank registriert
|
||||||
|
- Lösung: `EcmFiles`-Eintrag wird erstellt für korrekte Verknüpfung mit Rechnung
|
||||||
|
- Wichtig: Bei Rechnungsvalidierung wird PDF automatisch mitverschoben
|
||||||
|
|
||||||
|
### Hinzugefügt
|
||||||
|
- **Bezeichnung in Rechnungsliste**: Teuerster Artikel wird als Bezeichnung der Lieferantenrechnung gesetzt
|
||||||
|
- Erleichtert schnelle Identifikation in der Rechnungsliste
|
||||||
|
- Spalte "Bezeichnung" muss in Liste aktiviert sein
|
||||||
|
|
||||||
## [4.0] - 2026-03-01
|
## [4.0] - 2026-03-01
|
||||||
|
|
||||||
### Behoben
|
### Behoben
|
||||||
|
|
|
||||||
|
|
@ -76,7 +76,7 @@ class modImportZugferd extends DolibarrModules
|
||||||
$this->editor_squarred_logo = ''; // Must be image filename into the module/img directory followed with @modulename. Example: 'myimage.png@importzugferd'
|
$this->editor_squarred_logo = ''; // Must be image filename into the module/img directory followed with @modulename. Example: 'myimage.png@importzugferd'
|
||||||
|
|
||||||
// Possible values for version are: 'development', 'experimental', 'dolibarr', 'dolibarr_deprecated', 'experimental_deprecated' or a version string like 'x.y.z'
|
// Possible values for version are: 'development', 'experimental', 'dolibarr', 'dolibarr_deprecated', 'experimental_deprecated' or a version string like 'x.y.z'
|
||||||
$this->version = '4.1';
|
$this->version = '4.2';
|
||||||
// Url to the file with your last numberversion of this module
|
// Url to the file with your last numberversion of this module
|
||||||
//$this->url_last_version = 'http://www.example.com/versionmodule.txt';
|
//$this->url_last_version = 'http://www.example.com/versionmodule.txt';
|
||||||
|
|
||||||
|
|
|
||||||
41
import.php
41
import.php
|
|
@ -1981,6 +1981,21 @@ if ($action == 'createinvoice' && $id > 0) {
|
||||||
$invoice->date = $import->invoice_date;
|
$invoice->date = $import->invoice_date;
|
||||||
$invoice->note_private = $langs->trans('ImportedFromZugferd').' ('.$import->ref.')';
|
$invoice->note_private = $langs->trans('ImportedFromZugferd').' ('.$import->ref.')';
|
||||||
|
|
||||||
|
// Set label to most expensive item (for list display)
|
||||||
|
$maxTotal = 0;
|
||||||
|
$mostExpensiveLabel = '';
|
||||||
|
foreach ($lines as $line) {
|
||||||
|
$lineTotal = $line->quantity * $line->unit_price;
|
||||||
|
if ($lineTotal > $maxTotal) {
|
||||||
|
$maxTotal = $lineTotal;
|
||||||
|
$mostExpensiveLabel = $line->product_name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!empty($mostExpensiveLabel)) {
|
||||||
|
// Truncate to 255 chars (database field limit)
|
||||||
|
$invoice->label = dol_trunc($mostExpensiveLabel, 255);
|
||||||
|
}
|
||||||
|
|
||||||
// Use supplier default values for payment
|
// Use supplier default values for payment
|
||||||
$invoice->cond_reglement_id = $supplier->cond_reglement_supplier_id ?: 1;
|
$invoice->cond_reglement_id = $supplier->cond_reglement_supplier_id ?: 1;
|
||||||
$invoice->mode_reglement_id = $supplier->mode_reglement_supplier_id ?: 0;
|
$invoice->mode_reglement_id = $supplier->mode_reglement_supplier_id ?: 0;
|
||||||
|
|
@ -2025,14 +2040,36 @@ if ($action == 'createinvoice' && $id > 0) {
|
||||||
if (!$error) {
|
if (!$error) {
|
||||||
// Invoice stays as draft - user can validate manually
|
// Invoice stays as draft - user can validate manually
|
||||||
|
|
||||||
// Copy PDF to invoice
|
// Copy PDF to invoice and register in ECM
|
||||||
$source_pdf = $conf->importzugferd->dir_output.'/imports/'.$import->id.'/'.$import->pdf_filename;
|
$source_pdf = $conf->importzugferd->dir_output.'/imports/'.$import->id.'/'.$import->pdf_filename;
|
||||||
if (file_exists($source_pdf)) {
|
if (file_exists($source_pdf)) {
|
||||||
|
// Relativer Pfad für ECM (ohne DOL_DATA_ROOT Prefix)
|
||||||
|
$rel_dir = 'fournisseur/facture/'.get_exdir($invoice->id, 2, 0, 0, $invoice, 'invoice_supplier').$invoice->ref;
|
||||||
$dest_dir = $conf->fournisseur->facture->dir_output.'/'.get_exdir($invoice->id, 2, 0, 0, $invoice, 'invoice_supplier').$invoice->ref;
|
$dest_dir = $conf->fournisseur->facture->dir_output.'/'.get_exdir($invoice->id, 2, 0, 0, $invoice, 'invoice_supplier').$invoice->ref;
|
||||||
|
|
||||||
if (!is_dir($dest_dir)) {
|
if (!is_dir($dest_dir)) {
|
||||||
dol_mkdir($dest_dir);
|
dol_mkdir($dest_dir);
|
||||||
}
|
}
|
||||||
if (!@copy($source_pdf, $dest_dir.'/'.$import->pdf_filename)) {
|
|
||||||
|
$dest_file = $dest_dir.'/'.$import->pdf_filename;
|
||||||
|
if (@copy($source_pdf, $dest_file)) {
|
||||||
|
// In ECM-Datenbank registrieren für korrekte Verknüpfung
|
||||||
|
require_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php';
|
||||||
|
$ecmfile = new EcmFiles($db);
|
||||||
|
$ecmfile->filepath = $rel_dir;
|
||||||
|
$ecmfile->filename = $import->pdf_filename;
|
||||||
|
$ecmfile->label = md5_file(dol_osencode($dest_file));
|
||||||
|
$ecmfile->fullpath_orig = $dest_file;
|
||||||
|
$ecmfile->gen_or_uploaded = 'uploaded';
|
||||||
|
$ecmfile->description = 'ZUGFeRD Import - '.$import->invoice_number;
|
||||||
|
$ecmfile->src_object_type = 'supplier_invoice';
|
||||||
|
$ecmfile->src_object_id = $invoice->id;
|
||||||
|
$ecmfile->entity = $conf->entity;
|
||||||
|
$result = $ecmfile->create($user);
|
||||||
|
if ($result < 0) {
|
||||||
|
dol_syslog('ImportZugferd: Fehler beim ECM-Eintrag: '.implode(',', $ecmfile->errors), LOG_ERR);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
dol_syslog('ImportZugferd: Fehler beim Kopieren der PDF nach '.$dest_dir, LOG_ERR);
|
dol_syslog('ImportZugferd: Fehler beim Kopieren der PDF nach '.$dest_dir, LOG_ERR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue