Skip to content

Commit

Permalink
Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into d…
Browse files Browse the repository at this point in the history
…evelop
  • Loading branch information
eldy committed Jul 30, 2019
2 parents 34f78c5 + 2a447fa commit dca7759
Show file tree
Hide file tree
Showing 7 changed files with 166 additions and 30 deletions.
112 changes: 108 additions & 4 deletions htdocs/accountancy/class/accountancyexport.class.php
Expand Up @@ -5,7 +5,7 @@
* Copyright (C) 2015 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2015 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
* Copyright (C) 2016 Pierre-Henry Favre <phf@atm-consulting.fr>
* Copyright (C) 2016-2018 Alexandre Spangaro <aspangaro@open-dsi.fr>
* Copyright (C) 2016-2019 Alexandre Spangaro <aspangaro@open-dsi.fr>
* Copyright (C) 2013-2017 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2017 Elarifr. Ari Elbaz <github@accedinfo.com>
* Copyright (C) 2017-2019 Frédéric France <frederic.france@netlogic.fr>
Expand Down Expand Up @@ -50,6 +50,7 @@ class AccountancyExport
public static $EXPORT_TYPE_SAGE50_SWISS = 45;
public static $EXPORT_TYPE_QUADRATUS = 60;
public static $EXPORT_TYPE_OPENCONCERTO = 100;
public static $EXPORT_TYPE_LDCOMPTA = 110;
public static $EXPORT_TYPE_FEC = 1000;


Expand Down Expand Up @@ -105,6 +106,7 @@ public static function getType()
self::$EXPORT_TYPE_AGIRIS => $langs->trans('Modelcsv_agiris'),
self::$EXPORT_TYPE_OPENCONCERTO => $langs->trans('Modelcsv_openconcerto'),
self::$EXPORT_TYPE_SAGE50_SWISS => $langs->trans('Modelcsv_Sage50_Swiss'),
self::$EXPORT_TYPE_LDCOMPTA => $langs->trans('Modelcsv_LDCompta'),
self::$EXPORT_TYPE_FEC => $langs->trans('Modelcsv_FEC'),
);

Expand Down Expand Up @@ -133,6 +135,7 @@ private static function getFormatCode($type)
self::$EXPORT_TYPE_AGIRIS => 'agiris',
self::$EXPORT_TYPE_OPENCONCERTO => 'openconcerto',
self::$EXPORT_TYPE_SAGE50_SWISS => 'sage50ch',
self::$EXPORT_TYPE_LDCOMPTA => 'ldcompta',
self::$EXPORT_TYPE_FEC => 'fec',
);

Expand Down Expand Up @@ -191,6 +194,10 @@ public static function getTypeConfig()
'label' => $langs->trans('Modelcsv_Sage50_Swiss'),
'ACCOUNTING_EXPORT_FORMAT' => 'csv',
),
self::$EXPORT_TYPE_LDCOMPTA => array(
'label' => $langs->trans('Modelcsv_LDCompta'),
'ACCOUNTING_EXPORT_FORMAT' => 'csv',
),
self::$EXPORT_TYPE_FEC => array(
'label' => $langs->trans('Modelcsv_FEC'),
'ACCOUNTING_EXPORT_FORMAT' => 'txt',
Expand Down Expand Up @@ -257,12 +264,15 @@ public function export(&$TData)
case self::$EXPORT_TYPE_OPENCONCERTO :
$this->exportOpenConcerto($TData);
break;
case self::$EXPORT_TYPE_FEC :
$this->exportFEC($TData);
break;
case self::$EXPORT_TYPE_SAGE50_SWISS :
$this->exportSAGE50SWISS($TData);
break;
case self::$EXPORT_TYPE_LDCOMPTA :
$this->exportLDCompta($TData);
break;
case self::$EXPORT_TYPE_FEC :
$this->exportFEC($TData);
break;
default:
$this->errors[] = $langs->trans('accountancy_error_modelnotfound');
break;
Expand Down Expand Up @@ -909,6 +919,100 @@ public function exportSAGE50SWISS($objectLines)
}
}

/**
* Export format : LD Compta version 9 & higher
* http://www.ldsysteme.fr/fileadmin/telechargement/np/ldcompta/Documentation/IntCptW10.pdf
*
* @param array $objectLines data
*
* @return void
*/
public function exportLDCompta($objectLines)
{

$separator = ';';
$end_line = "\n";

foreach ($objectLines as $line) {

$date_document = dol_print_date($line->doc_date, '%Y%m%d');
$date_creation = dol_print_date($line->date_creation, '%Y%m%d');

// TYPE
$type_enregistrement = 'E'; // For write movement
print $type_enregistrement . $separator;
// JNAL
print substr($line->code_journal, 0, 2) . $separator;
// NECR
print $line->id . $separator;
// NPIE
print $line->piece_num . $separator;
// DATP
print $date_document . $separator;
// LIBE
print $line->label_operation . $separator;
// DATH
print $line->date_lim_reglement . $separator;
// CNPI
if ($line->doc_type == 'supplier_invoice') {
if ($line->montant < 0) {
$nature_piece = 'AF';
} else {
$nature_piece = 'FF';
}
} elseif ($line->doc_type == 'customer_invoice') {
if ($line->montant < 0) {
$nature_piece = 'AC';
} else {
$nature_piece = 'FC';
}
} else {
$nature_piece = '';
}
print $nature_piece . $separator;
// RACI
/*
if (! empty($line->subledger_account)) {
if ($line->doc_type == 'supplier_invoice') {
$racine_subledger_account = '40';
} elseif ($line->doc_type == 'customer_invoice') {
$racine_subledger_account = '41';
} else {
$nature_piece = '';
}
print $racine_subledger_account . $separator;
} else {
print $separator;
}
*/
// MONT
print price(abs($line->montant)) . $separator;
// CODC
print $line->sens . $separator;
// CPTG
print length_accountg($line->numero_compte) . $separator;
// DATE
print $date_creation . $separator;
// CLET
print $line->lettering_code . $separator;
// DATL
print $line->date_lettering . $separator;
// CPTA
if (! empty($line->subledger_account)) {
print length_accounta($line->subledger_account) . $separator;
}
// CNAT
if ($line->doc_type == 'supplier_invoice' && ! empty($line->subledger_account)) {
print 'F';
} elseif ($line->doc_type == 'customer_invoice' && ! empty($line->subledger_account)) {
print 'C';
} else {
print '';
}
print $end_line;
}
}

/**
* trunc
*
Expand Down
5 changes: 3 additions & 2 deletions htdocs/compta/prelevement/class/bonprelevement.class.php
Expand Up @@ -1417,7 +1417,7 @@ public function generate($format = 'ALL', $executiondate = '')

$sql = "SELECT soc.code_client as code, soc.address, soc.zip, soc.town, c.code as country_code,";
$sql.= " pl.client_nom as nom, pl.code_banque as cb, pl.code_guichet as cg, pl.number as cc, pl.amount as somme,";
$sql.= " f.ref as fac, pf.fk_facture as idfac, rib.datec, rib.iban_prefix as iban, rib.bic as bic, rib.rowid as drum, rib.rum";
$sql.= " f.ref as fac, pf.fk_facture as idfac, rib.datec, rib.iban_prefix as iban, rib.bic as bic, rib.rowid as drum, rib.rum, rib.date_rum";
$sql.= " FROM";
$sql.= " ".MAIN_DB_PREFIX."prelevement_lignes as pl,";
$sql.= " ".MAIN_DB_PREFIX."facture as f,";
Expand All @@ -1443,7 +1443,8 @@ public function generate($format = 'ALL', $executiondate = '')
while ($i < $num)
{
$obj = $this->db->fetch_object($resql);
$fileDebiteurSection .= $this->EnregDestinataireSEPA($obj->code, $obj->nom, $obj->address, $obj->zip, $obj->town, $obj->country_code, $obj->cb, $obj->cg, $obj->cc, $obj->somme, $obj->fac, $obj->idfac, $obj->iban, $obj->bic, $this->db->jdate($obj->datec), $obj->drum, $obj->rum);
$daterum = (!empty($obj->date_rum)) ? $this->db->jdate($obj->date_rum) : $this->db->jdate($obj->datec);
$fileDebiteurSection .= $this->EnregDestinataireSEPA($obj->code, $obj->nom, $obj->address, $obj->zip, $obj->town, $obj->country_code, $obj->cb, $obj->cg, $obj->cc, $obj->somme, $obj->fac, $obj->idfac, $obj->iban, $obj->bic, $daterum, $obj->drum, $obj->rum);
$this->total = $this->total + $obj->somme;
$i++;
}
Expand Down
1 change: 1 addition & 0 deletions htdocs/langs/en_US/accountancy.lang
Expand Up @@ -291,6 +291,7 @@ Modelcsv_quadratus=Export for Quadratus QuadraCompta
Modelcsv_ebp=Export for EBP
Modelcsv_cogilog=Export for Cogilog
Modelcsv_agiris=Export for Agiris
Modelcsv_LDCompta=Export for LD Compta (v9 & higher) (Test)
Modelcsv_openconcerto=Export for OpenConcerto (Test)
Modelcsv_configurable=Export CSV Configurable
Modelcsv_FEC=Export FEC
Expand Down
3 changes: 2 additions & 1 deletion htdocs/langs/en_US/withdrawals.lang
Expand Up @@ -76,7 +76,8 @@ WithdrawalFile=Withdrawal file
SetToStatusSent=Set to status "File Sent"
ThisWillAlsoAddPaymentOnInvoice=This will also record payments to invoices and will classify them as "Paid" if remain to pay is null
StatisticsByLineStatus=Statistics by status of lines
RUM=UMR
RUM=Unique Mandate Reference (UMR)
DateRUM=Mandate signature date
RUMLong=Unique Mandate Reference
RUMWillBeGenerated=If empty, a UMR (Unique Mandate Reference) will be generated once the bank account information is saved.
WithdrawMode=Direct debit mode (FRST or RECUR)
Expand Down
52 changes: 35 additions & 17 deletions htdocs/resource/element_resource.php
@@ -1,6 +1,7 @@
<?php
/* Copyright (C) 2013-2018 Jean-François Ferry <hello+jf@librethic.io>
* Copyright (C) 2016 Gilles Poirier <glgpoirier@gmail.com>
* Copyright (C) 2019 Josep Lluís Amador <joseplluis@lliuretic.cat>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -474,29 +475,46 @@

$linked_resources = $object->getElementResources($element, $element_id, $resource_obj);


// If we have a specific template we use it
if(file_exists(dol_buildpath($path.'/core/tpl/resource_'.$element_prop['element'].'_add.tpl.php')))
{
$res=include dol_buildpath($path.'/core/tpl/resource_'.$element_prop['element'].'_add.tpl.php');
}
else
// Output template part (modules that overwrite templates must declare this into descriptor)
$defaulttpldir='/core/tpl';
$dirtpls=array_merge($conf->modules_parts['tpl'], array($defaulttpldir), array($path.$defaulttpldir));

foreach($dirtpls as $module => $reldir)
{
$res=include DOL_DOCUMENT_ROOT . '/core/tpl/resource_add.tpl.php';
if(file_exists(dol_buildpath($reldir.'/resource_'.$element_prop['element'].'_add.tpl.php')))
{
$tpl = dol_buildpath($reldir.'/resource_'.$element_prop['element'].'_add.tpl.php');
}
else
{
$tpl = DOL_DOCUMENT_ROOT.$reldir.'/resource_add.tpl.php';
}
if (empty($conf->file->strict_mode)) {
$res=@include $tpl;
} else {
$res=include $tpl; // for debug
}
if ($res) break;
}

if ($mode != 'add' || $resource_obj != $resource_type)
{
//print load_fiche_titre($langs->trans(ucfirst($element_prop['element']).'Singular'));

// If we have a specific template we use it
if(file_exists(dol_buildpath($path.'/core/tpl/resource_'.$element_prop['element'].'_view.tpl.php')))
foreach($dirtpls as $module => $reldir)
{
$res=@include dol_buildpath($path.'/core/tpl/resource_'.$element_prop['element'].'_view.tpl.php');
}
else
{
$res=include DOL_DOCUMENT_ROOT . '/core/tpl/resource_view.tpl.php';
if(file_exists(dol_buildpath($reldir.'/resource_'.$element_prop['element'].'_view.tpl.php')))
{
$tpl = dol_buildpath($reldir.'/resource_'.$element_prop['element'].'_view.tpl.php');
}
else
{
$tpl = DOL_DOCUMENT_ROOT.$reldir.'/resource_view.tpl.php';
}
if (empty($conf->file->strict_mode)) {
$res=@include $tpl;
} else {
$res=include $tpl; // for debug
}
if ($res) break;
}
}
}
Expand Down
5 changes: 3 additions & 2 deletions htdocs/societe/class/companybankaccount.class.php
Expand Up @@ -46,7 +46,7 @@ class CompanyBankAccount extends Account
* @var integer
*/
public $datec;

/**
* Date modification record (tms)
*
Expand Down Expand Up @@ -217,7 +217,7 @@ public function fetch($id, $socid = 0, $default = 1, $type = 'ban')
if (empty($id) && empty($socid)) return -1;

$sql = "SELECT rowid, type, fk_soc, bank, number, code_banque, code_guichet, cle_rib, bic, iban_prefix as iban, domiciliation, proprio,";
$sql.= " owner_address, default_rib, label, datec, tms as datem, rum, frstrecur";
$sql.= " owner_address, default_rib, label, datec, tms as datem, rum, frstrecur, date_rum";
$sql.= " FROM ".MAIN_DB_PREFIX."societe_rib";
if ($id) $sql.= " WHERE rowid = ".$id;
if ($socid)
Expand Down Expand Up @@ -255,6 +255,7 @@ public function fetch($id, $socid = 0, $default = 1, $type = 'ban')
$this->datem = $this->db->jdate($obj->datem);
$this->rum = $obj->rum;
$this->frstrecur = $obj->frstrecur;
$this->date_rum = $this->db->jdate($obj->date_rum);
}
$this->db->free($resql);

Expand Down
18 changes: 14 additions & 4 deletions htdocs/societe/paymentmodes.php
Expand Up @@ -157,9 +157,13 @@
$companybankaccount->owner_address = GETPOST('owner_address', 'alpha');
$companybankaccount->frstrecur = GETPOST('frstrecur', 'alpha');
$companybankaccount->rum = GETPOST('rum', 'alpha');
$companybankaccount->date_rum = dol_mktime(0, 0, 0, GETPOST('date_rummonth'), GETPOST('date_rumday'), GETPOST('date_rumyear'));
if (empty($companybankaccount->rum))
{
$companybankaccount->rum = $prelevement->buildRumNumber($object->code_client, $companybankaccount->datec, $companybankaccount->id);
}
if (empty($companybankaccount->date_rum))
{
$companybankaccount->date_rum = dol_now();
}

Expand Down Expand Up @@ -268,6 +272,7 @@
$companybankaccount->owner_address = GETPOST('owner_address', 'alpha');
$companybankaccount->frstrecur = GETPOST('frstrecur');
$companybankaccount->rum = GETPOST('rum', 'alpha');
$companybankaccount->date_rum = dol_mktime(0, 0, 0, GETPOST('date_rummonth'), GETPOST('date_rumday'), GETPOST('date_rumyear'));
$companybankaccount->datec = dol_now();
$companybankaccount->status = 1;

Expand Down Expand Up @@ -1208,6 +1213,7 @@
if (! empty($conf->prelevement->enabled))
{
print_liste_field_titre("RUM");
print_liste_field_titre("DateRUM");
print_liste_field_titre("WithdrawMode");
}
print_liste_field_titre("DefaultRIB", '', '', '', '', '', '', '', 'center ');
Expand Down Expand Up @@ -1257,8 +1263,6 @@
if (! empty($rib->iban)) {
if (! checkIbanForAccount($rib)) {
print ' '.img_picto($langs->trans("IbanNotValid"), 'warning');
} else {
print ' '.img_picto($langs->trans("IbanValid"), 'info');
}
}
print '</td>';
Expand All @@ -1267,8 +1271,6 @@
if (! empty($rib->bic)) {
if (! checkSwiftForAccount($rib)) {
print ' '.img_picto($langs->trans("SwiftNotValid"), 'warning');
} else {
print ' '.img_picto($langs->trans("SwiftValid"), 'info');
}
}
print '</td>';
Expand All @@ -1279,6 +1281,8 @@
//print '<td>'.$prelevement->buildRumNumber($object->code_client, $rib->datec, $rib->id).'</td>';
print '<td>'.$rib->rum.'</td>';

print '<td>'.dol_print_date($rib->date_rum, 'day').'</td>';

// FRSTRECUR
print '<td>'.$rib->frstrecur.'</td>';
}
Expand Down Expand Up @@ -1531,6 +1535,9 @@
print '<tr><td class="titlefield">'.$langs->trans("RUM").'</td>';
print '<td><input class="minwidth300" type="text" name="rum" value="'.dol_escape_htmltag($companybankaccount->rum).'"></td></tr>';

print '<tr><td class="titlefield">'.$langs->trans("DateRUM").'</td>';
print '<td>'.$form->selectDate(GETPOST('date_rum')?GETPOST('date_rum'):$companybankaccount->date_rum, 'date_rum', 0, 0, 1, 'date_rum').'</td></tr>';

print '<tr><td>'.$langs->trans("WithdrawMode").'</td><td>';
$tblArraychoice = array("FRST" => $langs->trans("FRST"), "RECUR" => $langs->trans("RECUR"));
print $form->selectarray("frstrecur", $tblArraychoice, dol_escape_htmltag(GETPOST('frstrecur', 'alpha')?GETPOST('frstrecur', 'alpha'):$companybankaccount->frstrecur), 0);
Expand Down Expand Up @@ -1675,6 +1682,9 @@
print '<tr><td class="titlefieldcreate">'.$langs->trans("RUM").'</td>';
print '<td colspan="4"><input type="text" class="minwidth300" name="rum" value="'.GETPOST('rum', 'alpha').'"> <div class="opacitymedium">'.$langs->trans("RUMWillBeGenerated").'</div></td></tr>';

print '<tr><td class="titlefieldcreate">'.$langs->trans("DateRUM").'</td>';
print '<td colspan="4">'.$form->selectDate(GETPOST('date_rum'), 'date_rum', 0, 0, 1, 'date_rum').'</td></tr>';

print '<tr><td>'.$langs->trans("WithdrawMode").'</td><td>';
$tblArraychoice = array("FRST" => $langs->trans("FRST"), "RECUR" => $langs->trans("RECUR"));
print $form->selectarray("frstrecur", $tblArraychoice, (isset($_POST['frstrecur'])?GETPOST('frstrecur'):'FRST'), 0);
Expand Down

0 comments on commit dca7759

Please sign in to comment.