From 0e3685a4ab253bb1ea3ada1aff8897ca61cecb70 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Tue, 2 May 2023 06:15:05 +0200 Subject: [PATCH] FIX: Accountancy - Update Cogilog export --- .../class/accountancyexport.class.php | 28 +++++++++++++++++-- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/htdocs/accountancy/class/accountancyexport.class.php b/htdocs/accountancy/class/accountancyexport.class.php index 77a902684b0..a4d787f4386 100644 --- a/htdocs/accountancy/class/accountancyexport.class.php +++ b/htdocs/accountancy/class/accountancyexport.class.php @@ -611,6 +611,7 @@ class AccountancyExport /** * Export format : COGILOG + * Last review for this format : 2022-07-12 Alexandre Spangaro (aspangaro@open-dsi.fr) * * @param array $objectLines data * @param resource $exportFile [=null] File resource to export or print if null @@ -618,18 +619,39 @@ class AccountancyExport */ public function exportCogilog($objectLines, $exportFile = null) { - $separator = ";"; + $separator = "\t"; $end_line = "\n"; foreach ($objectLines as $line) { $date_document = dol_print_date($line->doc_date, '%d%m%Y'); + $refInvoice = ''; + if ($line->doc_type == 'customer_invoice') { + // Customer invoice + require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php'; + $invoice = new Facture($this->db); + $invoice->fetch($line->fk_doc); + + $refInvoice = $invoice->ref; + } elseif ($line->doc_type == 'supplier_invoice') { + // Supplier invoice + require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.facture.class.php'; + $invoice = new FactureFournisseur($this->db); + $invoice->fetch($line->fk_doc); + + $refInvoice = $invoice->ref_supplier; + } + $tab = array(); $tab[] = $line->code_journal; $tab[] = $date_document; - $tab[] = $line->piece_num; - $tab[] = length_accountg($line->numero_compte); + $tab[] = $refInvoice; + if (empty($line->subledger_account)) { + $tab[] = length_accountg($line->numero_compte); + } else { + $tab[] = length_accounta($line->subledger_account); + } $tab[] = ""; $tab[] = $line->label_operation; $tab[] = $date_document;