Update LDCompta10 Export

This commit is contained in:
Alexandre SPANGARO 2023-04-29 08:19:21 +02:00
parent cb7d59dd1a
commit 3b8a4df235

View File

@ -1852,10 +1852,10 @@ class AccountancyExport
* Help : http://www.ldsysteme.fr/fileadmin/telechargement/np/ldcompta/Documentation/IntCptW10.pdf * Help : http://www.ldsysteme.fr/fileadmin/telechargement/np/ldcompta/Documentation/IntCptW10.pdf
* *
* @param array $objectLines data * @param array $objectLines data
* * @param resource $exportFile [=null] File resource to export or print if null
* @return void * @return void
*/ */
public function exportLDCompta10($objectLines) public function exportLDCompta10($objectLines, $exportFile = null)
{ {
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
@ -1889,107 +1889,116 @@ class AccountancyExport
$address[2] = substr(str_replace(array("\t", "\r"), " ", $soc->address), 82, 40); $address[2] = substr(str_replace(array("\t", "\r"), " ", $soc->address), 82, 40);
} }
$tab = array();
$type_enregistrement = 'C'; $type_enregistrement = 'C';
//TYPE //TYPE
print $type_enregistrement.$separator; $tab[] = $type_enregistrement;
//NOCL //NOCL
print $soc->code_client.$separator; $tab[] = $soc->code_client;
//NMCM //NMCM
print $separator; $tab[] = "";
//LIBI //LIBI
print $separator; $tab[] = "";
//TITR //TITR
print $separator; $tab[] = "";
//RSSO //RSSO
print $soc->nom.$separator; $tab[] = $soc->nom;
//CAD1 //CAD1
print $address[0].$separator; $tab[] = $address[0];
//CAD2 //CAD2
print $address[1].$separator; $tab[] = $address[1];
//CAD3 //CAD3
print $address[2].$separator; $tab[] = $address[2];
//COPO //COPO
print $soc->zip.$separator; $tab[] = $soc->zip;
//BUDI //BUDI
print substr($soc->town, 0, 40).$separator; $tab[] = substr($soc->town, 0, 40);
//CPAY //CPAY
print $separator; $tab[] = "";
//PAYS //PAYS
print substr(getCountry($soc->fk_pays), 0, 40).$separator; $tab[] = substr(getCountry($soc->fk_pays), 0, 40);
//NTEL //NTEL
print $soc->phone.$separator; $tab[] = $soc->phone;
//TLEX //TLEX
print $separator; $tab[] = "";
//TLPO //TLPO
print $separator; $tab[] = "";
//TLCY //TLCY
print $separator; $tab[] = "";
//NINT //NINT
print $separator; $tab[] = "";
//COMM //COMM
print $separator; $tab[] = "";
//SIRE //SIRE
print str_replace(" ", "", $soc->siret).$separator; $tab[] = str_replace(" ", "", $soc->siret);
//RIBP //RIBP
print $separator; $tab[] = "";
//DOBQ //DOBQ
print $separator; $tab[] = "";
//IBBQ //IBBQ
print $separator; $tab[] = "";
//COBQ //COBQ
print $separator; $tab[] = "";
//GUBQ //GUBQ
print $separator; $tab[] = "";
//CPBQ //CPBQ
print $separator; $tab[] = "";
//CLBQ //CLBQ
print $separator; $tab[] = "";
//BIBQ //BIBQ
print $separator; $tab[] = "";
//MOPM //MOPM
print $separator; $tab[] = "";
//DJPM //DJPM
print $separator; $tab[] = "";
//DMPM //DMPM
print $separator; $tab[] = "";
//REFM //REFM
print $separator; $tab[] = "";
//SLVA //SLVA
print $separator; $tab[] = "";
//PLCR //PLCR
print $separator; $tab[] = "";
//ECFI //ECFI
print $separator; $tab[] = "";
//CREP //CREP
print $separator; $tab[] = "";
//NREP //NREP
print $separator; $tab[] = "";
//TREP //TREP
print $separator; $tab[] = "";
//MREP //MREP
print $separator; $tab[] = "";
//GRRE //GRRE
print $separator; $tab[] = "";
//LTTA //LTTA
print $separator; $tab[] = "";
//CACT //CACT
print $separator; $tab[] = "";
//CODV //CODV
print $separator; $tab[] = "";
//GRTR //GRTR
print $separator; $tab[] = "";
//NOFP //NOFP
print $separator; $tab[] = "";
//BQAF //BQAF
print $separator; $tab[] = "";
//BONP //BONP
print $separator; $tab[] = "";
//CESC //CESC
print $separator; $tab[] = "";
print $end_line; $output = implode($separator, $tab).$end_line;
if ($exportFile) {
fwrite($exportFile, $output);
} else {
print $output;
} }
} }
}
$tab = array();
$date_document = dol_print_date($line->doc_date, '%Y%m%d'); $date_document = dol_print_date($line->doc_date, '%Y%m%d');
$date_creation = dol_print_date($line->date_creation, '%Y%m%d'); $date_creation = dol_print_date($line->date_creation, '%Y%m%d');
@ -1997,19 +2006,19 @@ class AccountancyExport
// TYPE E // TYPE E
$type_enregistrement = 'E'; // For write movement $type_enregistrement = 'E'; // For write movement
print $type_enregistrement.$separator; $tab[] = $type_enregistrement;
// JNAL // JNAL
print substr($line->code_journal, 0, 2).$separator; $tab[] = substr($line->code_journal, 0, 2);
// NECR // NECR
print $line->id.$separator; $tab[] = $line->id;
// NPIE // NPIE
print $line->piece_num.$separator; $tab[] = $line->piece_num;
// DATP // DATP
print $date_document.$separator; $tab[] = $date_document;
// LIBE // LIBE
print dol_trunc($line->label_operation, 25, 'right', 'UTF-8', 1).$separator; $tab[] = dol_trunc($line->label_operation, 25, 'right', 'UTF-8', 1);
// DATH // DATH
print $date_lim_reglement.$separator; $tab[] = $date_lim_reglement;
// CNPI // CNPI
if ($line->doc_type == 'supplier_invoice') { if ($line->doc_type == 'supplier_invoice') {
if (($line->amount) < 0) { // Currently, only the sign of amount allows to know the type of invoice (standard or credit note). Other solution is to analyse debit/credit/role of account. TODO Add column doc_type_long or make amount mandatory with rule on sign. if (($line->amount) < 0) { // Currently, only the sign of amount allows to know the type of invoice (standard or credit note). Other solution is to analyse debit/credit/role of account. TODO Add column doc_type_long or make amount mandatory with rule on sign.
@ -2026,7 +2035,7 @@ class AccountancyExport
} else { } else {
$nature_piece = ''; $nature_piece = '';
} }
print $nature_piece.$separator; $tab[] = $nature_piece;
// RACI // RACI
// if (!empty($line->subledger_account)) { // if (!empty($line->subledger_account)) {
// if ($line->doc_type == 'supplier_invoice') { // if ($line->doc_type == 'supplier_invoice') {
@ -2040,75 +2049,80 @@ class AccountancyExport
$racine_subledger_account = ''; // for records of type E leave this field blank $racine_subledger_account = ''; // for records of type E leave this field blank
// } // }
print $racine_subledger_account.$separator; // deprecated CPTG & CPTA use instead $tab[] = $racine_subledger_account; // deprecated CPTG & CPTA use instead
// MONT // MONT
print price(abs($line->debit - $line->credit), 0, '', 1, 2).$separator; $tab[] = price(abs($line->debit - $line->credit), 0, '', 1, 2);
// CODC // CODC
print $line->sens.$separator; $tab[] = $line->sens;
// CPTG // CPTG
print length_accountg($line->numero_compte).$separator; $tab[] = length_accountg($line->numero_compte);
// DATE // DATE
print $date_document.$separator; $tab[] = $date_document;
// CLET // CLET
print $line->lettering_code.$separator; $tab[] = $line->lettering_code;
// DATL // DATL
print $line->date_lettering.$separator; $tab[] = $line->date_lettering;
// CPTA // CPTA
if (!empty($line->subledger_account)) { if (!empty($line->subledger_account)) {
print length_accounta($line->subledger_account).$separator; $tab[] = length_accounta($line->subledger_account);
} else { } else {
print $separator; $tab[] = "";
} }
// CNAT // CNAT
if ($line->doc_type == 'supplier_invoice' && !empty($line->subledger_account)) { if ($line->doc_type == 'supplier_invoice' && !empty($line->subledger_account)) {
print 'F'.$separator; $tab[] = 'F';
} elseif ($line->doc_type == 'customer_invoice' && !empty($line->subledger_account)) { } elseif ($line->doc_type == 'customer_invoice' && !empty($line->subledger_account)) {
print 'C'.$separator; $tab[] = 'C';
} else { } else {
print $separator; $tab[] = "";
} }
// CTRE // CTRE
print $separator; $tab[] = "";
// NORL // NORL
print $separator; $tab[] = "";
// DATV // DATV
print $separator; $tab[] = "";
// REFD // REFD
print $line->doc_ref.$separator; $tab[] = $line->doc_ref;
// NECA // NECA
print '0'.$separator; $tab[] = '0';
// CSEC // CSEC
print $separator; $tab[] = "";
// CAFF // CAFF
print $separator; $tab[] = "";
// CDES // CDES
print $separator; $tab[] = "";
// QTUE // QTUE
print $separator; $tab[] = "";
// MTDV // MTDV
print '0'.$separator; $tab[] = '0';
// CODV // CODV
print $separator; $tab[] = "";
// TXDV // TXDV
print '0'.$separator; $tab[] = '0';
// MOPM // MOPM
print $separator; $tab[] = "";
// BONP // BONP
print $separator; $tab[] = "";
// BQAF // BQAF
print $separator; $tab[] = "";
// ECES // ECES
print $separator; $tab[] = "";
// TXTL // TXTL
print $separator; $tab[] = "";
// ECRM // ECRM
print $separator; $tab[] = "";
// DATK // DATK
print $separator; $tab[] = "";
// HEUK // HEUK
print $separator; $tab[] = "";
print $end_line; $output = implode($separator, $tab).$end_line;
if ($exportFile) {
fwrite($exportFile, $output);
} else {
print $output;
}
$last_codeinvoice = $line->doc_ref; $last_codeinvoice = $line->doc_ref;
} }