Merge pull request #16042 from aspangaro/13a29
Accountancy - Gestimum v3 / v5 Added a sort to excluse line at zero
This commit is contained in:
commit
641e2d9906
@ -57,8 +57,8 @@ class AccountancyExport
|
||||
public static $EXPORT_TYPE_OPENCONCERTO = 100;
|
||||
public static $EXPORT_TYPE_LDCOMPTA = 110;
|
||||
public static $EXPORT_TYPE_LDCOMPTA10 = 120;
|
||||
public static $EXPORT_TYPE_GESTINUMV3 = 130;
|
||||
public static $EXPORT_TYPE_GESTINUMV5 = 135;
|
||||
public static $EXPORT_TYPE_GESTIMUMV3 = 130;
|
||||
public static $EXPORT_TYPE_GESTIMUMV5 = 135;
|
||||
public static $EXPORT_TYPE_FEC = 1000;
|
||||
public static $EXPORT_TYPE_FEC2 = 1010;
|
||||
|
||||
@ -119,8 +119,8 @@ class AccountancyExport
|
||||
self::$EXPORT_TYPE_CHARLEMAGNE => $langs->trans('Modelcsv_charlemagne'),
|
||||
self::$EXPORT_TYPE_LDCOMPTA => $langs->trans('Modelcsv_LDCompta'),
|
||||
self::$EXPORT_TYPE_LDCOMPTA10 => $langs->trans('Modelcsv_LDCompta10'),
|
||||
self::$EXPORT_TYPE_GESTINUMV3 => $langs->trans('Modelcsv_Gestinum_v3'),
|
||||
self::$EXPORT_TYPE_GESTINUMV5 => $langs->trans('Modelcsv_Gestinum_v5'),
|
||||
self::$EXPORT_TYPE_GESTIMUMV3 => $langs->trans('Modelcsv_Gestinum_v3'),
|
||||
self::$EXPORT_TYPE_GESTIMUMV5 => $langs->trans('Modelcsv_Gestinum_v5'),
|
||||
self::$EXPORT_TYPE_FEC => $langs->trans('Modelcsv_FEC'),
|
||||
self::$EXPORT_TYPE_FEC2 => $langs->trans('Modelcsv_FEC2'),
|
||||
);
|
||||
@ -154,8 +154,8 @@ class AccountancyExport
|
||||
self::$EXPORT_TYPE_CHARLEMAGNE => 'charlemagne',
|
||||
self::$EXPORT_TYPE_LDCOMPTA => 'ldcompta',
|
||||
self::$EXPORT_TYPE_LDCOMPTA10 => 'ldcompta10',
|
||||
self::$EXPORT_TYPE_GESTINUMV3 => 'gestinumv3',
|
||||
self::$EXPORT_TYPE_GESTINUMV5 => 'gestinumv5',
|
||||
self::$EXPORT_TYPE_GESTIMUMV3 => 'gestimumv3',
|
||||
self::$EXPORT_TYPE_GESTIMUMV5 => 'gestimumv5',
|
||||
self::$EXPORT_TYPE_FEC => 'fec',
|
||||
self::$EXPORT_TYPE_FEC2 => 'fec2',
|
||||
);
|
||||
@ -227,11 +227,13 @@ class AccountancyExport
|
||||
self::$EXPORT_TYPE_LDCOMPTA10 => array(
|
||||
'label' => $langs->trans('Modelcsv_LDCompta10'),
|
||||
),
|
||||
self::$EXPORT_TYPE_GESTINUMV3 => array(
|
||||
self::$EXPORT_TYPE_GESTIMUMV3 => array(
|
||||
'label' => $langs->trans('Modelcsv_Gestinumv3'),
|
||||
'ACCOUNTING_EXPORT_FORMAT' => 'txt',
|
||||
),
|
||||
self::$EXPORT_TYPE_GESTINUMV5 => array(
|
||||
self::$EXPORT_TYPE_GESTIMUMV5 => array(
|
||||
'label' => $langs->trans('Modelcsv_Gestinumv5'),
|
||||
'ACCOUNTING_EXPORT_FORMAT' => 'txt',
|
||||
),
|
||||
self::$EXPORT_TYPE_FEC => array(
|
||||
'label' => $langs->trans('Modelcsv_FEC'),
|
||||
@ -320,10 +322,10 @@ class AccountancyExport
|
||||
case self::$EXPORT_TYPE_LDCOMPTA10 :
|
||||
$this->exportLDCompta10($TData);
|
||||
break;
|
||||
case self::$EXPORT_TYPE_GESTINUMV3 :
|
||||
case self::$EXPORT_TYPE_GESTIMUMV3 :
|
||||
$this->exportGestimumV3($TData);
|
||||
break;
|
||||
case self::$EXPORT_TYPE_GESTINUMV5 :
|
||||
case self::$EXPORT_TYPE_GESTIMUMV5 :
|
||||
$this->exportGestimumV5($TData);
|
||||
break;
|
||||
case self::$EXPORT_TYPE_FEC :
|
||||
@ -1628,81 +1630,85 @@ class AccountancyExport
|
||||
$invoices_infos = array();
|
||||
$supplier_invoices_infos = array();
|
||||
foreach ($objectLines as $line) {
|
||||
$date = dol_print_date($line->doc_date, '%d/%m/%Y');
|
||||
|
||||
$invoice_ref = $line->doc_ref;
|
||||
$company_name = "";
|
||||
|
||||
if (($line->doc_type == 'customer_invoice' || $line->doc_type == 'supplier_invoice') && $line->fk_doc > 0) {
|
||||
if (($line->doc_type == 'customer_invoice' && !isset($invoices_infos[$line->fk_doc])) ||
|
||||
($line->doc_type == 'supplier_invoice' && !isset($supplier_invoices_infos[$line->fk_doc]))) {
|
||||
if ($line->doc_type == 'customer_invoice') {
|
||||
// Get new customer invoice ref and company name
|
||||
$sql = 'SELECT f.ref, s.nom FROM ' . MAIN_DB_PREFIX . 'facture as f';
|
||||
$sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'societe AS s ON f.fk_soc = s.rowid';
|
||||
$sql .= ' WHERE f.rowid = ' . $line->fk_doc;
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql) {
|
||||
if ($obj = $this->db->fetch_object($resql)) {
|
||||
// Save invoice infos
|
||||
$invoices_infos[$line->fk_doc] = array('ref' => $obj->ref, 'company_name' => $obj->nom);
|
||||
$invoice_ref = $obj->ref;
|
||||
$company_name = $obj->nom;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Get new supplier invoice ref and company name
|
||||
$sql = 'SELECT ff.ref, s.nom FROM ' . MAIN_DB_PREFIX . 'facture_fourn as ff';
|
||||
$sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'societe AS s ON ff.fk_soc = s.rowid';
|
||||
$sql .= ' WHERE ff.rowid = ' . $line->fk_doc;
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql) {
|
||||
if ($obj = $this->db->fetch_object($resql)) {
|
||||
// Save invoice infos
|
||||
$supplier_invoices_infos[$line->fk_doc] = array('ref' => $obj->ref, 'company_name' => $obj->nom);
|
||||
$invoice_ref = $obj->ref;
|
||||
$company_name = $obj->nom;
|
||||
}
|
||||
}
|
||||
}
|
||||
} elseif ($line->doc_type == 'customer_invoice') {
|
||||
// Retrieve invoice infos
|
||||
$invoice_ref = $invoices_infos[$line->fk_doc]['ref'];
|
||||
$company_name = $invoices_infos[$line->fk_doc]['company_name'];
|
||||
} else {
|
||||
// Retrieve invoice infos
|
||||
$invoice_ref = $supplier_invoices_infos[$line->fk_doc]['ref'];
|
||||
$company_name = $supplier_invoices_infos[$line->fk_doc]['company_name'];
|
||||
}
|
||||
}
|
||||
|
||||
print $line->id . $this->separator;
|
||||
print $date . $this->separator;
|
||||
print substr($line->code_journal, 0, 4) . $this->separator;
|
||||
|
||||
if ((substr($line->numero_compte, 0, 3) == '411') || (substr($line->numero_compte, 0, 3) == '401')) {
|
||||
print length_accountg($line->subledger_account) . $this->separator;
|
||||
if ($line->debit == 0 && $line->credit == 0) {
|
||||
unset($array[$line]);
|
||||
} else {
|
||||
print substr(length_accountg($line->numero_compte), 0, 15) . $this->separator;
|
||||
$date = dol_print_date($line->doc_date, '%d/%m/%Y');
|
||||
|
||||
$invoice_ref = $line->doc_ref;
|
||||
$company_name = "";
|
||||
|
||||
if (($line->doc_type == 'customer_invoice' || $line->doc_type == 'supplier_invoice') && $line->fk_doc > 0) {
|
||||
if (($line->doc_type == 'customer_invoice' && !isset($invoices_infos[$line->fk_doc])) ||
|
||||
($line->doc_type == 'supplier_invoice' && !isset($supplier_invoices_infos[$line->fk_doc]))) {
|
||||
if ($line->doc_type == 'customer_invoice') {
|
||||
// Get new customer invoice ref and company name
|
||||
$sql = 'SELECT f.ref, s.nom FROM ' . MAIN_DB_PREFIX . 'facture as f';
|
||||
$sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'societe AS s ON f.fk_soc = s.rowid';
|
||||
$sql .= ' WHERE f.rowid = ' . $line->fk_doc;
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql) {
|
||||
if ($obj = $this->db->fetch_object($resql)) {
|
||||
// Save invoice infos
|
||||
$invoices_infos[$line->fk_doc] = array('ref' => $obj->ref, 'company_name' => $obj->nom);
|
||||
$invoice_ref = $obj->ref;
|
||||
$company_name = $obj->nom;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Get new supplier invoice ref and company name
|
||||
$sql = 'SELECT ff.ref, s.nom FROM ' . MAIN_DB_PREFIX . 'facture_fourn as ff';
|
||||
$sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'societe AS s ON ff.fk_soc = s.rowid';
|
||||
$sql .= ' WHERE ff.rowid = ' . $line->fk_doc;
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql) {
|
||||
if ($obj = $this->db->fetch_object($resql)) {
|
||||
// Save invoice infos
|
||||
$supplier_invoices_infos[$line->fk_doc] = array('ref' => $obj->ref, 'company_name' => $obj->nom);
|
||||
$invoice_ref = $obj->ref;
|
||||
$company_name = $obj->nom;
|
||||
}
|
||||
}
|
||||
}
|
||||
} elseif ($line->doc_type == 'customer_invoice') {
|
||||
// Retrieve invoice infos
|
||||
$invoice_ref = $invoices_infos[$line->fk_doc]['ref'];
|
||||
$company_name = $invoices_infos[$line->fk_doc]['company_name'];
|
||||
} else {
|
||||
// Retrieve invoice infos
|
||||
$invoice_ref = $supplier_invoices_infos[$line->fk_doc]['ref'];
|
||||
$company_name = $supplier_invoices_infos[$line->fk_doc]['company_name'];
|
||||
}
|
||||
}
|
||||
|
||||
print $line->id . $this->separator;
|
||||
print $date . $this->separator;
|
||||
print substr($line->code_journal, 0, 4) . $this->separator;
|
||||
|
||||
if ((substr($line->numero_compte, 0, 3) == '411') || (substr($line->numero_compte, 0, 3) == '401')) {
|
||||
print length_accountg($line->subledger_account) . $this->separator;
|
||||
} else {
|
||||
print substr(length_accountg($line->numero_compte), 0, 15) . $this->separator;
|
||||
}
|
||||
//Libellé Auto
|
||||
print $this->separator;
|
||||
//print '"'.dol_trunc(str_replace('"', '', $line->label_operation),40,'right','UTF-8',1).'"' . $this->separator;
|
||||
//Libellé manuel
|
||||
print dol_trunc(str_replace('"', '', $invoice_ref . (!empty($company_name) ? ' - ' : '') . $company_name), 40, 'right', 'UTF-8', 1) . $this->separator;
|
||||
//Numéro de pièce
|
||||
print dol_trunc(str_replace('"', '', $line->piece_num), 10, 'right', 'UTF-8', 1) . $this->separator;
|
||||
//Devise
|
||||
print 'EUR' . $this->separator;
|
||||
//Montant
|
||||
print price2num(abs($line->montant)) . $this->separator;
|
||||
//Sens
|
||||
print $line->sens . $this->separator;
|
||||
//Code lettrage
|
||||
print $this->separator;
|
||||
//Date Echéance
|
||||
print $date;
|
||||
print $this->end_line;
|
||||
}
|
||||
//Libellé Auto
|
||||
print $this->separator;
|
||||
//print '"'.dol_trunc(str_replace('"', '', $line->label_operation),40,'right','UTF-8',1).'"' . $this->separator;
|
||||
//Libellé manuel
|
||||
print dol_trunc(str_replace('"', '', $invoice_ref . (!empty($company_name) ? ' - ' : '') . $company_name), 40, 'right', 'UTF-8', 1) . $this->separator;
|
||||
//Numéro de pièce
|
||||
print dol_trunc(str_replace('"', '', $line->piece_num), 10, 'right', 'UTF-8', 1) . $this->separator;
|
||||
//Devise
|
||||
print 'EUR' . $this->separator;
|
||||
//Montant
|
||||
print price2num(abs($line->montant)) . $this->separator;
|
||||
//Sens
|
||||
print $line->sens . $this->separator;
|
||||
//Code lettrage
|
||||
print $this->separator;
|
||||
//Date Echéance
|
||||
print $date;
|
||||
print $this->end_line;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1719,27 +1725,31 @@ class AccountancyExport
|
||||
$this->separator = ',';
|
||||
|
||||
foreach ($objectLines as $line) {
|
||||
$date = dol_print_date($line->doc_date, '%d%m%Y');
|
||||
|
||||
print $line->id . $this->separator;
|
||||
print $date . $this->separator;
|
||||
print substr($line->code_journal, 0, 4) . $this->separator;
|
||||
if ((substr($line->numero_compte, 0, 3) == '411') || (substr($line->numero_compte, 0, 3) == '401')) {
|
||||
print length_accountg($line->subledger_account) . $this->separator;
|
||||
if ($line->debit == 0 && $line->credit == 0) {
|
||||
unset($array[$line]);
|
||||
} else {
|
||||
print substr(length_accountg($line->numero_compte), 0, 15) . $this->separator;
|
||||
$date = dol_print_date($line->doc_date, '%d%m%Y');
|
||||
|
||||
print $line->id . $this->separator;
|
||||
print $date . $this->separator;
|
||||
print substr($line->code_journal, 0, 4) . $this->separator;
|
||||
if ((substr($line->numero_compte, 0, 3) == '411') || (substr($line->numero_compte, 0, 3) == '401')) {
|
||||
print length_accountg($line->subledger_account) . $this->separator;
|
||||
} else {
|
||||
print substr(length_accountg($line->numero_compte), 0, 15) . $this->separator;
|
||||
}
|
||||
print $this->separator;
|
||||
//print '"'.dol_trunc(str_replace('"', '', $line->label_operation),40,'right','UTF-8',1).'"' . $this->separator;
|
||||
print '"' . dol_trunc(str_replace('"', '', $line->doc_ref), 40, 'right', 'UTF-8', 1) . '"' . $this->separator;
|
||||
print '"' . dol_trunc(str_replace('"', '', $line->piece_num), 10, 'right', 'UTF-8', 1) . '"' . $this->separator;
|
||||
print price2num($line->montant) . $this->separator;
|
||||
print $line->sens . $this->separator;
|
||||
print $date . $this->separator;
|
||||
print $this->separator;
|
||||
print $this->separator;
|
||||
print 'EUR';
|
||||
print $this->end_line;
|
||||
}
|
||||
print $this->separator;
|
||||
//print '"'.dol_trunc(str_replace('"', '', $line->label_operation),40,'right','UTF-8',1).'"' . $this->separator;
|
||||
print '"'.dol_trunc(str_replace('"', '', $line->doc_ref), 40, 'right', 'UTF-8', 1).'"' . $this->separator;
|
||||
print '"'.dol_trunc(str_replace('"', '', $line->piece_num), 10, 'right', 'UTF-8', 1).'"'.$this->separator;
|
||||
print price2num($line->montant).$this->separator;
|
||||
print $line->sens.$this->separator;
|
||||
print $date . $this->separator;
|
||||
print $this->separator;
|
||||
print $this->separator;
|
||||
print 'EUR';
|
||||
print $this->end_line;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user