Merge pull request #5412 from atm-florian/dev_compta

Dev compta
This commit is contained in:
Laurent Destailleur 2016-06-30 21:58:45 +02:00 committed by GitHub
commit f3821c30f3
12 changed files with 732 additions and 572 deletions

View File

@ -16,9 +16,9 @@
*/
/**
* \file htdocs/accountancy/admin/categories.php
* \ingroup Advanced accountancy
* \brief Page to assign mass categories to accounts
* \file htdocs/accountancy/admin/categories.php
* \ingroup Advanced accountancy
* \brief Page to assign mass categories to accounts
*/
require '../../main.inc.php';
@ -36,11 +36,11 @@ $langs->load("accountancy");
$mesg = '';
$action = GETPOST('action');
$cat_id = GETPOST('account_category');
$selectcpt = GETPOST('cpt_bk');
$selectcpt = GETPOST('cpt_bk', 'array');
$cpt_id = GETPOST('cptid');
if($cat_id == 0){
$cat_id = null;
if ($cat_id == 0) {
$cat_id = null;
}
$id = GETPOST('id', 'int');
@ -54,31 +54,30 @@ if (! $user->admin)
$AccCat = new AccountancyCategory($db);
// si ajout de comptes
if(!empty($selectcpt)){
$cpts = array();
$i = 0;
foreach ($selectcpt as $selectedOption){
$cpts[$i] = "'".$selectedOption."'";
$i++;
if (! empty($selectcpt)) {
$cpts = array ();
foreach ( $selectcpt as $selectedOption ) {
if (! array_key_exists($selectedOption, $cpts))
$cpts[$selectedOption] = "'" . $selectedOption . "'";
}
if($AccCat->updateAccAcc($cat_id, $cpts)){
$return= $AccCat->updateAccAcc($cat_id, $cpts);
if ($return<0) {
setEventMessages($langs->trans('errors'), $AccCat->errors, 'errors');
} else {
setEventMessages($langs->trans('Saved'), null, 'mesgs');
}else{
setEventMessages($langs->trans('errors'), null, 'errors');
}
}
if ($action == 'delete') {
if($cpt_id){
if($AccCat->deleteCptCat($cpt_id)){
if ($cpt_id) {
if ($AccCat->deleteCptCat($cpt_id)) {
setEventMessages($langs->trans('Deleted'), null, 'mesgs');
}else{
} else {
setEventMessages($langs->trans('errors'), null, 'errors');
}
}
}
}
/*
* View
@ -88,65 +87,69 @@ llxheader('', $langs->trans('AccountAccounting'));
$formaccounting = new FormAccounting($db);
$form = new Form($db);
print load_fiche_titre($langs->trans('Categories'));
print load_fiche_titre($langs->trans('Categories'));
print '<form name="add" action="' . $_SERVER["PHP_SELF"] . '" method="POST">' . "\n";
print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
print '<input type="hidden" name="action" value="display">';
print '<form name="add" action="' . $_SERVER["PHP_SELF"] . '" method="POST">' . "\n";
print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
print '<input type="hidden" name="action" value="display">';
dol_fiche_head();
dol_fiche_head();
print '<table class="border" width="100%">';
// Category
print '<tr><td>' . $langs->trans("AccountingCategory") . '</td>';
print '<td>';
$formaccounting->select_accounting_category($cat_id, 'account_category', 1);
print '<input class="button" type="submit" value="' . $langs->trans("Display") . '">';
print '</td></tr>';
print '<table class="border" width="100%">';
// Category
print '<tr><td>' . $langs->trans("AccountingCategory") . '</td>';
print '<td>';
$formaccounting->select_accounting_category($cat_id, 'account_category', 1);
print '<input class="button" type="submit" value="' . $langs->trans("Display") . '">';
print '</td></tr>';
if(!empty($cat_id)){
$obj = $AccCat->getCptBK($cat_id);
print '<tr><td>' . $langs->trans("AddCompteFromBK") . '</td>';
print '<td>';
if(!empty($obj)){
print '<select size="'.count($obj).'" name="cpt_bk[]" multiple>';
foreach ( $obj as $cpt ) {
print '<option value="'.length_accountg($cpt->numero_compte).'">' . length_accountg($cpt->numero_compte) . ' ('.$cpt->label_compte.' '.$cpt->doc_ref.')</option>';
}
print '</select> - <input class="button" type="submit" id="" class="action-delete" value="' . $langs->trans("add") . '"> ';
}
print '</td></tr>';
if (! empty($cat_id)) {
$return = $AccCat->getCptBK($cat_id);
if ($return < 0) {
setEventMessages(null, $AccCat->errors, 'errors');
}
print '</table>';
print '<tr><td>' . $langs->trans("AddCompteFromBK") . '</td>';
print '<td>';
if (is_array($AccCat->lines_cptbk) && count($AccCat->lines_cptbk) > 0) {
print '<select size="' . count($obj) . '" name="cpt_bk[]" multiple>';
foreach ( $AccCat->lines_cptbk as $cpt ) {
print '<option value="' . length_accountg($cpt->numero_compte) . '">' . length_accountg($cpt->numero_compte) . ' (' . $cpt->label_compte . ' ' . $cpt->doc_ref . ')</option>';
}
print '</select> - <input class="button" type="submit" id="" class="action-delete" value="' . $langs->trans("add") . '"> ';
}
print '</td></tr>';
}
dol_fiche_end();
print '</table>';
print '</form>';
dol_fiche_end();
print '</form>';
if ($action == 'display' || $action == 'delete') {
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre"><th class="liste_titre">'.$langs->trans("Numerocompte").'</th><th class="liste_titre">'.$langs->trans("Description").'</th><th class="liste_titre" width="60" align="center">Action</th></tr>';
print '<tr class="liste_titre"><th class="liste_titre">' . $langs->trans("Numerocompte") . '</th><th class="liste_titre">' . $langs->trans("Description") . '</th><th class="liste_titre" width="60" align="center">Action</th></tr>';
if(!empty($cat_id)){
$obj = $AccCat->display($cat_id);
$j=1;
if(!empty($obj)){
foreach ( $obj as $cpt ) {
if (! empty($cat_id)) {
$return = $AccCat->display($cat_id);
if ($return < 0) {
setEventMessages(null, $AccCat->errors, 'errors');
}
$j = 1;
if (is_array($AccCat->lines_display) && count($AccCat->lines_display) > 0) {
foreach ( $AccCat->lines_display as $cpt ) {
$var = ! $var;
print '<tr'. $bc[$var].'>';
print '<tr' . $bc[$var] . '>';
print '<td>' . length_accountg($cpt->account_number) . '</td>';
print '<td>' . $cpt->label . '</td>';
print $form->formconfirm($_SERVER["PHP_SELF"]."?account_category=$cat_id&cptid=".$cpt->rowid, $langs->trans("DeleteCptCategory"), $langs->trans("ConfirmDeleteCptCategory"), "delete", '', 0, "action-delete".$j);
print '<td><input class="button" type="button" id="action-delete'.$j.'" value="' . $langs->trans("Delete") . '"></td>';
print $form->formconfirm($_SERVER["PHP_SELF"] . "?account_category=$cat_id&cptid=" . $cpt->rowid, $langs->trans("DeleteCptCategory"), $langs->trans("ConfirmDeleteCptCategory"), "delete", '', 0, "action-delete" . $j);
print '<td><input class="button" type="button" id="action-delete' . $j . '" value="' . $langs->trans("Delete") . '"></td>';
print "</tr>\n";
$j++;
$j ++;
}
}
}
}
print "</table>";

View File

@ -18,9 +18,9 @@
*/
/**
* \file htdocs/accountancy/bookkeeping/card.php
* \ingroup Advanced accountancy
* \brief Page to show book-entry
* \file htdocs/accountancy/bookkeeping/card.php
* \ingroup Advanced accountancy
* \brief Page to show book-entry
*/
require '../../main.inc.php';
@ -62,17 +62,17 @@ if (! empty($update)) {
}
if ($action == "confirm_update") {
$error = 0;
if ((floatval($debit) != 0.0) && (floatval($credit) != 0.0)) {
setEventMessages($langs->trans('ErrorDebitCredit'), null, 'errors');
$error ++;
}
if (empty($error)) {
$book = new BookKeeping($db);
$result = $book->fetch($id);
if ($result < 0) {
setEventMessages($book->error, $book->errors, 'errors');
@ -82,7 +82,7 @@ if ($action == "confirm_update") {
$book->label_compte = $label_compte;
$book->debit = $debit;
$book->credit = $credit;
if (floatval($debit) != 0.0) {
$book->montant = $debit;
$book->sens = 'D';
@ -91,7 +91,7 @@ if ($action == "confirm_update") {
$book->montant = $credit;
$book->sens = 'C';
}
$result = $book->update($user);
if ($result < 0) {
setEventMessages($book->error, $book->errors, 'errors');
@ -101,19 +101,19 @@ if ($action == "confirm_update") {
}
}
}
}
}
else if ($action == "add") {
$error = 0;
if ((floatval($debit) != 0.0) && (floatval($credit) != 0.0)) {
setEventMessages($langs->trans('ErrorDebitCredit'), null, 'errors');
$error ++;
}
if (empty($error)) {
$book = new BookKeeping($db);
$book->numero_compte = $account_number;
$book->code_tiers = $code_tiers;
$book->label_compte = $label_compte;
@ -126,17 +126,17 @@ else if ($action == "add") {
$book->code_journal = GETPOST('code_journal');
$book->fk_doc = GETPOST('fk_doc');
$book->fk_docdet = GETPOST('fk_docdet');
if (floatval($debit) != 0.0) {
$book->montant = $debit;
$book->sens = 'D';
}
if (floatval($credit) != 0.0) {
$book->montant = $credit;
$book->sens = 'C';
}
$result = $book->createStd($user);
if ($result < 0) {
setEventMessages($book->error, $book->errors, 'errors');
@ -145,15 +145,15 @@ else if ($action == "add") {
$action = '';
}
}
}
}
else if ($action == "confirm_delete") {
$book = new BookKeeping($db);
$result = $book->fetch($id);
$piece_num = $book->piece_num;
if ($result < 0) {
setEventMessages($book->error, $book->errors, 'errors');
} else {
@ -163,11 +163,11 @@ else if ($action == "confirm_delete") {
}
}
$action = '';
}
}
else if ($action == "confirm_create") {
$book = new BookKeeping($db);
$book->label_compte = '';
$book->debit = 0;
$book->credit = 0;
@ -178,9 +178,9 @@ else if ($action == "confirm_create") {
$book->code_journal = GETPOST('code_journal');
$book->fk_doc = 0;
$book->fk_docdet = 0;
$book->montant = 0;
$result = $book->createStd($user);
if ($result < 0) {
setEventMessages($book->error, $book->errors, 'errors');
@ -209,15 +209,15 @@ if ($action == 'delete') {
if ($action == 'create') {
print load_fiche_titre($langs->trans("CreateMvts"));
$code_journal_array = array (
$conf->global->ACCOUNTING_SELL_JOURNAL => $conf->global->ACCOUNTING_SELL_JOURNAL,
$conf->global->ACCOUNTING_PURCHASE_JOURNAL => $conf->global->ACCOUNTING_PURCHASE_JOURNAL,
$conf->global->ACCOUNTING_SOCIAL_JOURNAL => $conf->global->ACCOUNTING_SOCIAL_JOURNAL,
$conf->global->ACCOUNTING_MISCELLANEOUS_JOURNAL => $conf->global->ACCOUNTING_MISCELLANEOUS_JOURNAL,
$conf->global->ACCOUNTING_EXPENSEREPORT_JOURNAL => $conf->global->ACCOUNTING_EXPENSEREPORT_JOURNAL
$conf->global->ACCOUNTING_EXPENSEREPORT_JOURNAL => $conf->global->ACCOUNTING_EXPENSEREPORT_JOURNAL
);
$sql = 'SELECT DISTINCT accountancy_journal FROM ' . MAIN_DB_PREFIX . 'bank_account WHERE clos=0';
$resql = $db->query($sql);
if (! $resql) {
@ -229,52 +229,52 @@ if ($action == 'create') {
}
}
}
$book = new BookKeeping($db);
$next_num_mvt = $book->getNextNumMvt();
print '<form action="' . $_SERVER["PHP_SELF"] . '" name="create_mvt" method="POST">';
print '<input type="hidden" name="action" value="confirm_create">' . "\n";
print '<input type="hidden" name="next_num_mvt" value="' . $next_num_mvt . '">' . "\n";
dol_fiche_head();
print '<table class="border" width="100%">';
print '<tr>';
print '<td width="25%">' . $langs->trans("NumMvts") . '</td>';
print '<td>' . $next_num_mvt . '</td>';
print '</tr>';
print '<tr>';
print '<td>' . $langs->trans("Docdate") . '</td>';
print '<td>';
print $html->select_date('', 'doc_date', '', '', '', "create_mvt", 1, 1);
print '</td>';
print '</tr>';
print '<tr>';
print '<td>' . $langs->trans("Codejournal") . '</td>';
print '<td>' . $html->selectarray('code_journal', $code_journal_array) . '</td>';
print '</tr>';
print '<tr>';
print '<td>' . $langs->trans("Docref") . '</td>';
print '<td><input type="text" size="20" name="doc_ref" value=""/></td>';
print '</tr>';
print '<tr>';
print '<td>' . $langs->trans("Doctype") . '</td>';
print '<td><input type="text" size="20" name="doc_type" value=""/></td>';
print '</tr>';
print '</table>';
dol_fiche_end();
print '<div align="center"><input type="submit" class="button" value="' . $langs->trans("Create") . '">';
print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="button" value="' . $langs->trans("Cancel") . '" class="button" onclick="history.go(-1)" />';
print '</div>';
print '</form>';
} else {
$book = new BookKeeping($db);
@ -283,9 +283,9 @@ if ($action == 'create') {
setEventMessages($book->error, $book->errors, 'errors');
}
if (! empty($book->piece_num)) {
print load_fiche_titre($langs->trans("UpdateMvts"), '<a href="list.php">' . $langs->trans('BackToList') . '</a>');
print '<table class="border" width="100%">';
print '<tr class="pair">';
print '<td width="25%">' . $langs->trans("NumMvts") . '</td>';
@ -309,14 +309,14 @@ if ($action == 'create') {
print '</tr>';
print '</table>';
print '<br />';
$result = $book->fetch_all_per_mvt($piece_num);
if ($result < 0) {
setEventMessages($book->error, $book->errors, 'errors');
} else {
print load_fiche_titre($langs->trans("ListeMvts"));
print '<form action="' . $_SERVER["PHP_SELF"] . '?piece_num=' . $book->piece_num . '" method="post">';
print '<input type="hidden" name="doc_date" value="' . $book->doc_date . '">' . "\n";
print '<input type="hidden" name="doc_type" value="' . $book->doc_type . '">' . "\n";
@ -324,15 +324,15 @@ if ($action == 'create') {
print '<input type="hidden" name="code_journal" value="' . $book->code_journal . '">' . "\n";
print '<input type="hidden" name="fk_doc" value="' . $book->fk_doc . '">' . "\n";
print '<input type="hidden" name="fk_docdet" value="' . $book->fk_docdet . '">' . "\n";
print "<table class=\"noborder\" width=\"100%\">";
if (count($book->linesmvt) > 0) {
$total_debit = 0;
$total_credit = 0;
print '<tr class="liste_titre">';
print_liste_field_titre($langs->trans("AccountAccountingShort"));
print_liste_field_titre($langs->trans("Code_tiers"));
print_liste_field_titre($langs->trans("Labelcompte"));
@ -341,18 +341,18 @@ if ($action == 'create') {
print_liste_field_titre($langs->trans("Amount"), "", "", "", "", 'align="center"');
print_liste_field_titre($langs->trans("Sens"), "", "", "", "", 'align="center"');
print_liste_field_titre($langs->trans("Action"), "", "", "", "", 'width="60" align="center"');
print "</tr>\n";
foreach ( $book->linesmvt as $line ) {
$var = ! $var;
print '<tr'. $bc[$var].'>';
print '<tr' . $bc[$var] . '>';
$total_debit += $line->debit;
$total_credit += $line->credit;
if ($action == 'update' && $line->id == $id) {
print '<td>';
print $formventilation->select_account($line->numero_compte, 'account_number', 0, array (), 1, 1, '');
print '</td>';
@ -376,7 +376,7 @@ if ($action == 'create') {
print '<td align="right">' . price($line->credit) . '</td>';
print '<td align="right">' . price($line->montant) . '</td>';
print '<td align="center">' . $line->sens . '</td>';
print '<td align="center">';
print '<a href="./card.php?action=update&amp;id=' . $line->id . '&amp;piece_num=' . $line->piece_num . '">';
print img_edit();
@ -384,23 +384,21 @@ if ($action == 'create') {
print '<a href="./card.php?action=delete&amp;id=' . $line->id . '&amp;piece_num=' . $line->piece_num . '">';
print img_delete();
print '</a>';
print '</td>';
}
print "</tr>\n";
}
if ($total_debit != $total_credit) {
setEventMessages(null, array (
'MvtNotCorrectlyBalanced',
$total_credit,
$total_debit
$langs->trans('MvtNotCorrectlyBalanced', $total_credit, $total_debit)
), 'errors');
}
if ($action == "" || $action == 'add') {
$var = ! $var;
print '<tr'. $bc[$var].'>';
print '<tr' . $bc[$var] . '>';
print '<td>';
print $formventilation->select_account($account_number, 'account_number', 0, array (), 1, 1, '');
print '</td>';

View File

@ -202,14 +202,22 @@ if ($action == 'delbookkeeping') {
if ($action == 'delbookkeepingyearconfirm') {
$delyear = GETPOST('delyear', 'int');
if ($delyear==-1) {
$delyear=0;
}
$deljournal = GETPOST('deljournal','alpha');
if ($deljournal==-1) {
$deljournal=0;
}
if (! empty($delyear)) {
$result = $object->deleteByYear($delyear);
if (! empty($delyear) || ! empty($deljournal)) {
$result = $object->deleteByYearAndJournal($delyear,$deljournal);
if ($result < 0) {
setEventMessages($object->error, $object->errors, 'errors');
}
Header("Location: list.php");
exit();
exit;
}
}
if ($action == 'delmouvconfirm') {
@ -222,7 +230,7 @@ if ($action == 'delmouvconfirm') {
setEventMessages($object->error, $object->errors, 'errors');
}
Header("Location: list.php");
exit();
exit;
}
}
if ($action == 'export_csv') {
@ -276,11 +284,13 @@ if ($action == 'delbookkeepingyear') {
$form_question = array ();
$delyear = GETPOST('delyear');
$deljournal = GETPOST('deljournal');
if (empty($delyear)) {
$delyear = dol_print_date(dol_now(), '%Y');
}
$year_array = $formventilation->selectyear_accountancy_bookkepping($delyear, 'delyear', 0, 'array');
$journal_array = $formventilation->selectjournal_accountancy_bookkepping($deljournal, 'deljournal', 0, 'array');
$form_question['delyear'] = array (
'name' => 'delyear',
@ -289,6 +299,13 @@ if ($action == 'delbookkeepingyear') {
'values' => $year_array,
'default' => $delyear
);
$form_question['deljournal'] = array (
'name' => 'deljournal',
'type' => 'select',
'label' => $langs->trans('DelJournal'),
'values' => $journal_array,
'default' => $deljournal
);
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans('DeleteMvt'), $langs->trans('ConfirmDeleteMvt'), 'delbookkeepingyearconfirm', $form_question, 0, 1);
print $formconfirm;

View File

@ -17,9 +17,9 @@
*/
/**
* \file htdocs/accountancy/class/accountancycategory.class.php
* \ingroup Advanced accountancy
* \brief File of class to manage categories of an accounting category_type
* \file htdocs/accountancy/class/accountancycategory.class.php
* \ingroup Advanced accountancy
* \brief File of class to manage categories of an accounting category_type
*/
// Class
@ -32,18 +32,20 @@ class AccountancyCategory
{
private $db;
public $error;
public $errors = array();
//public $element='accounting_category';
//public $table_element='c_accounting_category';
public $errors = array ();
public $element = 'accounting_category';
public $table_element = 'c_accounting_category';
public $id;
public $lines_cptbk;
public $lines_display;
public $sdc;
/**
* Constructor
* Constructor
*
* @param DoliDB $db Database handler
* @param DoliDB $db Database handler
*/
public function __construct($db)
{
public function __construct($db) {
$this->db = $db;
return 1;
@ -52,122 +54,136 @@ class AccountancyCategory
/**
* Function to select all accounting accounts from an accounting category
*
* @param int $id Id
* @param int $id Id
*
* @return int <0 if KO, 0 if not found, >0 if OK
*/
public function display($id)
{
*/
public function display($id) {
$sql = "SELECT t.rowid, t.account_number, t.label";
$sql.= " FROM " . MAIN_DB_PREFIX . "accounting_account as t";
$sql.= " WHERE t.fk_accounting_category = " . $id;
$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_account as t";
$sql .= " WHERE t.fk_accounting_category = " . $id;
$this->lines_display = array ();
dol_syslog(__METHOD__ . " sql=" . $sql, LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql) {
$i = 0;
$obj = '';
$num = $this->db->num_rows($resql);
if ($num) {
while ( $i < $num ) {
$obj[$i] = $this->db->fetch_object($resql);
$i ++;
while ( $obj = $this->db->fetch_object($resql) ) {
$this->lines_display[] = $obj;
}
}
return $obj;
return $num;
} else {
$this->error = "Error " . $this->db->lasterror();
dol_syslog(__METHOD__ . " " . $this->error, LOG_ERR);
$this->errors[] = $this->error;
dol_syslog(__METHOD__ . " " . implode(',' . $this->errors), LOG_ERR);
return -1;
return - 1;
}
}
/**
* Function to select accountiing category of an accounting account present in chart of accounts
*
* @param int $id Id category
* @param int $id Id category
*
* @return int <0 if KO, 0 if not found, >0 if OK
*/
public function getCptBK($id)
{
public function getCptBK($id) {
global $conf;
$sql = "SELECT t.numero_compte, t.label_compte, t.doc_ref";
$sql.= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as t";
$sql.= " WHERE t.numero_compte NOT IN (";
$sql.= " SELECT t.account_number";
$sql.= " FROM " . MAIN_DB_PREFIX . "accounting_account as t";
$sql.= " WHERE t.fk_accounting_category = " . $id .")";
$sql.= " AND t.numero_compte IN (";
$sql.= " SELECT DISTINCT aa.account_number";
$sql.= " FROM " . MAIN_DB_PREFIX . "accounting_account as aa";
$sql.= " INNER JOIN " . MAIN_DB_PREFIX . "accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version";
$sql.= " AND asy.rowid = " . $conf->global->CHARTOFACCOUNTS;
$sql.= " AND aa.active = 1)";
$sql.= " GROUP BY t.numero_compte";
$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as t";
$sql .= " WHERE t.numero_compte NOT IN (";
$sql .= " SELECT t.account_number";
$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_account as t";
$sql .= " WHERE t.fk_accounting_category = " . $id . ")";
$sql .= " AND t.numero_compte IN (";
$sql .= " SELECT DISTINCT aa.account_number";
$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_account as aa";
$sql .= " INNER JOIN " . MAIN_DB_PREFIX . "accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version";
$sql .= " AND asy.rowid = " . $conf->global->CHARTOFACCOUNTS;
$sql .= " AND aa.active = 1)";
$sql .= " GROUP BY t.numero_compte, t.label_compte, t.doc_ref";
$sql .= " ORDER BY t.numero_compte";
dol_syslog(__METHOD__ . " sql=" . $sql, LOG_DEBUG);
$this->lines_CptBk = array ();
dol_syslog(__METHOD__, LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql) {
$i = 0;
$obj = '';
$num = $this->db->num_rows($resql);
if ($num) {
while ( $i < $num ) {
$obj[$i] = $this->db->fetch_object($resql);
$i ++;
while ( $obj = $this->db->fetch_object($resql) ) {
$this->lines_cptbk[] = $obj;
}
}
return $obj;
return $num;
} else {
$this->error = "Error " . $this->db->lasterror();
dol_syslog(__METHOD__ . " " . $this->error, LOG_ERR);
$this->errors[] = $this->error;
dol_syslog(__METHOD__ . " " . implode(',' . $this->errors), LOG_ERR);
return -1;
return - 1;
}
}
/**
* Function to add an accounting account in an accounting category
*
* @param int $id_cat Id category
* @param array $cpts list of accounts array
* @param int $id_cat Id category
* @param array $cpts list of accounts array
*
* @return int <0 if KO, >0 if OK
*/
public function updateAccAcc($id_cat, $cpts = array())
{
public function updateAccAcc($id_cat, $cpts = array()) {
global $conf;
$error = 0;
$sql = "UPDATE " . MAIN_DB_PREFIX . "accounting_account as aa";
$sql.= " INNER JOIN " . MAIN_DB_PREFIX . "accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version";
$sql.= " AND asy.rowid = " . $conf->global->CHARTOFACCOUNTS;
$sql.= " AND aa.active = 1";
$sql.= " SET fk_accounting_category=" . $id_cat;
$sql.= " WHERE aa.account_number IN (" . join(',',$cpts) .")";
$this->db->begin();
require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
dol_syslog(__METHOD__ . " sql=" . $sql, LOG_DEBUG);
$sql = "SELECT aa.rowid,aa.account_number ";
$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_account as aa";
$sql .= " INNER JOIN " . MAIN_DB_PREFIX . "accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version";
$sql .= " AND asy.rowid = " . $conf->global->CHARTOFACCOUNTS;
$sql .= " AND aa.active = 1";
dol_syslog(__METHOD__, LOG_DEBUG);
$resql = $this->db->query($sql);
if (! $resql) {
$error ++;
$this->errors[] = "Error " . $this->db->lasterror();
return -1;
}
$this->db->begin();
while ( $obj = $this->db->fetch_object($resql)) {
if (array_key_exists(length_accountg($obj->account_number), $cpts)) {
$sql = "UPDATE " . MAIN_DB_PREFIX . "accounting_account";
$sql .= " SET fk_accounting_category=" . $id_cat;
$sql .= " WHERE rowid=".$obj->rowid;
dol_syslog(__METHOD__, LOG_DEBUG);
$resql = $this->db->query($sql);
if (! $resql) {
$error ++;
$this->errors[] = "Error " . $this->db->lasterror();
}
}
}
// Commit or rollback
if ($error) {
foreach ($this->errors as $errmsg) {
foreach ( $this->errors as $errmsg ) {
dol_syslog(__METHOD__ . " " . $errmsg, LOG_ERR);
$this->error.=($this->error ? ', ' . $errmsg : $errmsg);
$this->error .= ($this->error ? ', ' . $errmsg : $errmsg);
}
$this->db->rollback();
return -1 * $error;
return - 1 * $error;
} else {
$this->db->commit();
@ -178,17 +194,16 @@ class AccountancyCategory
/**
* Function to delete an accounting account from an accounting category
*
* @param int $cpt_id Id of accounting account
* @param int $cpt_id Id of accounting account
*
* @return int <0 if KO, >0 if OK
*/
public function deleteCptCat($cpt_id)
{
public function deleteCptCat($cpt_id) {
$error = 0;
$sql = "UPDATE " . MAIN_DB_PREFIX . "accounting_account as aa";
$sql.= " SET fk_accounting_category= 0";
$sql.= " WHERE aa.rowid= " . $cpt_id;
$sql .= " SET fk_accounting_category= 0";
$sql .= " WHERE aa.rowid= " . $cpt_id;
$this->db->begin();
dol_syslog(__METHOD__ . " sql=" . $sql, LOG_DEBUG);
@ -200,13 +215,13 @@ class AccountancyCategory
// Commit or rollback
if ($error) {
foreach ($this->errors as $errmsg) {
foreach ( $this->errors as $errmsg ) {
dol_syslog(__METHOD__ . " " . $errmsg, LOG_ERR);
$this->error.=($this->error ? ', ' . $errmsg : $errmsg);
$this->error .= ($this->error ? ', ' . $errmsg : $errmsg);
}
$this->db->rollback();
return -1 * $error;
return - 1 * $error;
} else {
$this->db->commit();
@ -217,57 +232,51 @@ class AccountancyCategory
/**
* Function to know all category from accounting account
*
* @return array Result in table
* @return array Result in table
*/
public function getCatsCpts()
{
public function getCatsCpts() {
global $mysoc;
$sql = "";
if (empty($mysoc->country_id) && empty($mysoc->country_code))
{
dol_print_error('','Call to select_accounting_account with mysoc country not yet defined');
exit;
}
if (empty($mysoc->country_id) && empty($mysoc->country_code)) {
dol_print_error('', 'Call to select_accounting_account with mysoc country not yet defined');
exit();
}
if (! empty($mysoc->country_id))
{
$sql = "SELECT t.rowid, t.account_number, t.label as name_cpt, cat.code, cat.position, cat.label as name_cat, cat.sens ";
$sql.= " FROM " . MAIN_DB_PREFIX . "accounting_account as t, ".MAIN_DB_PREFIX."c_accounting_category as cat";
$sql.= " WHERE t.fk_accounting_category IN ( SELECT c.rowid ";
$sql.= " FROM ".MAIN_DB_PREFIX."c_accounting_category as c";
$sql.= " WHERE c.active = 1";
$sql.= " AND c.fk_country = ".$mysoc->country_id.")";
$sql.= " AND cat.rowid = t.fk_accounting_category";
$sql.= " ORDER BY cat.position ASC";
}
else
{
$sql = "SELECT c.rowid, c.code, c.label, c.category_type ";
$sql.= " FROM ".MAIN_DB_PREFIX."c_accounting_category as c, ".MAIN_DB_PREFIX."c_country as co";
$sql.= " WHERE c.active = 1 AND c.fk_country = co.rowid";
$sql.= " AND co.code = '".$mysoc->country_code."'";
$sql.= " ORDER BY c.position ASC";
}
$resql = $this->db->query($sql);
if (! empty($mysoc->country_id)) {
$sql = "SELECT t.rowid, t.account_number, t.label as name_cpt, cat.code, cat.position, cat.label as name_cat, cat.sens ";
$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_account as t, " . MAIN_DB_PREFIX . "c_accounting_category as cat";
$sql .= " WHERE t.fk_accounting_category IN ( SELECT c.rowid ";
$sql .= " FROM " . MAIN_DB_PREFIX . "c_accounting_category as c";
$sql .= " WHERE c.active = 1";
$sql .= " AND c.fk_country = " . $mysoc->country_id . ")";
$sql .= " AND cat.rowid = t.fk_accounting_category";
$sql .= " ORDER BY cat.position ASC";
} else {
$sql = "SELECT c.rowid, c.code, c.label, c.category_type ";
$sql .= " FROM " . MAIN_DB_PREFIX . "c_accounting_category as c, " . MAIN_DB_PREFIX . "c_country as co";
$sql .= " WHERE c.active = 1 AND c.fk_country = co.rowid";
$sql .= " AND co.code = '" . $mysoc->country_code . "'";
$sql .= " ORDER BY c.position ASC";
}
$resql = $this->db->query($sql);
if ($resql) {
$i = 0;
$obj = '';
$num = $this->db->num_rows($resql);
$data = array();
$data = array ();
if ($num) {
while ( $i < $num ) {
$obj = $this->db->fetch_object($resql);
while ( $obj = $this->db->fetch_object($resql) ) {
$name_cat = $obj->name_cat;
$data[$name_cat][$i] = array(
'id' => $obj->rowid,
'code' => $obj->code,
'position' => $obj->position,
'account_number' => $obj->account_number,
'name_cpt' => $obj->name_cpt,
'sens' => $obj->sens,
);
$data[$name_cat][$i] = array (
'id' => $obj->rowid,
'code' => $obj->code,
'position' => $obj->position,
'account_number' => $obj->account_number,
'name_cpt' => $obj->name_cpt,
'sens' => $obj->sens
);
$i ++;
}
}
@ -276,29 +285,28 @@ class AccountancyCategory
$this->error = "Error " . $this->db->lasterror();
dol_syslog(__METHOD__ . " " . $this->error, LOG_ERR);
return -1;
return - 1;
}
}
}
/**
* Function to show result of an accounting account from the general ledger with a sens and a period
*
* @param int $cpt Id accounting account
* @param string $month Specifig month - Can be empty
* @param string $year Specific year
* @param int $sens Sens of the account 0: credit - debit 1: debit - credit
*
* @return array Result in table
* @param int $cpt Id accounting account
* @param string $month Specifig month - Can be empty
* @param string $year Specific year
* @param int $sens Sens of the account 0: credit - debit 1: debit - credit
*
* @return array Result in table
*/
public function getResult($cpt, $month, $year, $sens)
{
$sql = "SELECT SUM(t.debit) as debit, SUM(t.credit) as credit";
$sql.= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as t";
$sql.= " WHERE t.numero_compte = " . $cpt;
$sql.= " AND YEAR(t.doc_date) = " . $year;
public function getResult($cpt, $month, $year, $sens) {
$sql = "SELECT SUM(t.debit) as debit, SUM(t.credit) as credit";
$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as t";
$sql .= " WHERE t.numero_compte = '" . $cpt."'";
$sql .= " AND YEAR(t.doc_date) = " . $year;
if(! empty($month)){
$sql.= " AND MONTH(t.doc_date) = " . $month;
if (! empty($month)) {
$sql .= " AND MONTH(t.doc_date) = " . $month;
}
dol_syslog(__METHOD__ . " sql=" . $sql, LOG_DEBUG);
@ -306,81 +314,77 @@ class AccountancyCategory
if ($resql) {
$num = $this->db->num_rows($resql);
$sdc = 0;
$this->sdc = 0;
if ($num) {
$obj = $this->db->fetch_object($resql);
if($sens == 1){
$sdc = $obj->debit - $obj->credit;
}else{
$sdc = $obj->credit - $obj->debit;
if ($sens == 1) {
$this->sdc = $obj->debit - $obj->credit;
} else {
$this->sdc = $obj->credit - $obj->debit;
}
}
return $sdc;
return $num;
} else {
$this->error = "Error " . $this->db->lasterror();
dol_syslog(__METHOD__ . " " . $this->error, LOG_ERR);
return -1;
return - 1;
}
}
/**
* Function to call category from a specific country
*
* @return array Result in table
* @return array Result in table
*/
public function getCatsCal()
{
global $db,$langs,$user,$mysoc;
public function getCatsCal() {
global $db, $langs, $user, $mysoc;
if (empty($mysoc->country_id) && empty($mysoc->country_code))
{
dol_print_error('','Call to select_accounting_account with mysoc country not yet defined');
exit;
}
if (empty($mysoc->country_id) && empty($mysoc->country_code)) {
dol_print_error('', 'Call to select_accounting_account with mysoc country not yet defined');
exit();
}
if (! empty($mysoc->country_id))
{
$sql = "SELECT c.rowid, c.code, c.label, c.formula, c.position";
$sql.= " FROM ".MAIN_DB_PREFIX."c_accounting_category as c";
$sql.= " WHERE c.active = 1 AND c.category_type = 1 ";
$sql.= " AND c.fk_country = ".$mysoc->country_id;
$sql.= " ORDER BY c.position ASC";
}
else
{
$sql = "SELECT c.rowid, c.code, c.label, c.formula, c.position";
$sql.= " FROM ".MAIN_DB_PREFIX."c_accounting_category as c, ".MAIN_DB_PREFIX."c_country as co";
$sql.= " WHERE c.active = 1 AND c.category_type = 1 AND c.fk_country = co.rowid";
$sql.= " AND co.code = '".$mysoc->country_code."'";
$sql.= " ORDER BY c.position ASC";
}
if (! empty($mysoc->country_id)) {
$sql = "SELECT c.rowid, c.code, c.label, c.formula, c.position";
$sql .= " FROM " . MAIN_DB_PREFIX . "c_accounting_category as c";
$sql .= " WHERE c.active = 1 AND c.category_type = 1 ";
$sql .= " AND c.fk_country = " . $mysoc->country_id;
$sql .= " ORDER BY c.position ASC";
} else {
$sql = "SELECT c.rowid, c.code, c.label, c.formula, c.position";
$sql .= " FROM " . MAIN_DB_PREFIX . "c_accounting_category as c, " . MAIN_DB_PREFIX . "c_country as co";
$sql .= " WHERE c.active = 1 AND c.category_type = 1 AND c.fk_country = co.rowid";
$sql .= " AND co.code = '" . $mysoc->country_code . "'";
$sql .= " ORDER BY c.position ASC";
}
dol_syslog(__METHOD__ . " sql=" . $sql, LOG_DEBUG);
dol_syslog(__METHOD__ . " sql=" . $sql, LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql) {
$i = 0;
$obj = '';
$num = $this->db->num_rows($resql);
$data = array();
$data = array ();
if ($num) {
while ( $i < $num ) {
$obj = $this->db->fetch_object($resql);
$position = $obj->position;
$data[$position] = array(
'code' => $obj->code,
'label' => $obj->label,
'formula' => $obj->formula
);
$data[$position] = array (
'code' => $obj->code,
'label' => $obj->label,
'formula' => $obj->formula
);
$i ++;
}
}
return $data;
} else {
$this->error = "Error " . $this->db->lasterror();
dol_syslog(__METHOD__ . " " . $this->error, LOG_ERR);
$this->errors[] = $this->error;
dol_syslog(__METHOD__ . " " . implode(',' . $this->errors), LOG_ERR);
return -1;
return - 1;
}
}
}

View File

@ -43,6 +43,7 @@ class AccountancyExport
public static $EXPORT_TYPE_CIEL = 5;
public static $EXPORT_TYPE_QUADRATUS = 6;
public static $EXPORT_TYPE_EBP = 7;
public static $EXPORT_TYPE_COGILOG = 8;
/**
*
@ -91,6 +92,7 @@ class AccountancyExport
self::$EXPORT_TYPE_CIEL => $langs->trans('Modelcsv_ciel'),
self::$EXPORT_TYPE_QUADRATUS => $langs->trans('Modelcsv_quadratus'),
self::$EXPORT_TYPE_EBP => $langs->trans('Modelcsv_ebp'),
self::$EXPORT_TYPE_COGILOG => $langs->trans('Modelcsv_cogilog'),
);
}
@ -137,6 +139,9 @@ class AccountancyExport
case self::$EXPORT_TYPE_EBP :
$this->exportEbp($TData);
break;
case self::$EXPORT_TYPE_COGILOG :
$this->exportCogilog($TData);
break;
default :
$this->errors[] = $langs->trans('accountancy_error_modelnotfound');
break;
@ -188,6 +193,37 @@ class AccountancyExport
}
}
/**
* Export format : COGILOG
*
* @param array $objectLines data
*
* @return void
*/
public function exportCogilog($objectLines) {
foreach ( $objectLines as $line ) {
$date = dol_print_date($line->doc_date, '%d%m%Y');
print $line->code_journal . $this->separator;
print $date . $this->separator;
print $line->piece_num . $this->separator;
print length_accountg($line->numero_compte) . $this->separator;
print '' . $this->separator;
print $line->label_compte . $this->separator;
print $date . $this->separator;
if ($line->sens=='D') {
print price($line->montant) . $this->separator;
print '' . $this->separator;
}elseif ($line->sens=='C') {
print '' . $this->separator;
print price($line->montant) . $this->separator;
}
print $line->doc_ref . $this->separator;
print $line->label_compte . $this->separator;
print $this->end_line;
}
}
/**
* Export format : COALA
*

File diff suppressed because it is too large Load Diff

View File

@ -58,7 +58,7 @@ class FormVentilation extends Form
return Form::selectarray($htmlname, $options, $selectedkey);
}
/**
* Return list of accounts with label by chart of accounts
*
@ -69,23 +69,23 @@ class FormVentilation extends Form
* @param int $select_in $selectid value is a aa.rowid (0 default) or aa.account_number (1)
* @param int $select_out set value returned by select 0=rowid (default), 1=account_number
* @param int $aabase set accounting_account base class to display empty=all or from 1 to 8 will display only account beginning by this number
*
*
* @return string String with HTML select
*/
function select_account($selectid, $htmlname = 'account', $showempty = 0, $event = array(), $select_in = 0, $select_out = 0, $aabase = '') {
global $conf;
require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
$trunclength = defined('ACCOUNTING_LENGTH_DESCRIPTION_ACCOUNT') ? $conf->global->ACCOUNTING_LENGTH_DESCRIPTION_ACCOUNT : 50;
$sql = "SELECT DISTINCT aa.account_number, aa.label, aa.rowid, aa.fk_pcg_version";
$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_account as aa";
$sql .= " INNER JOIN " . MAIN_DB_PREFIX . "accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version";
$sql .= " AND asy.rowid = " . $conf->global->CHARTOFACCOUNTS;
$sql .= " AND aa.active = 1";
$sql .= " ORDER BY aa.account_number";
dol_syslog(get_class($this) . "::select_account", LOG_DEBUG);
$resql = $this->db->query($sql);
@ -127,7 +127,7 @@ class FormVentilation extends Form
$this->db->free($resql);
return $out;
}
/**
* Return list of accounts with label by class of accounts
*
@ -135,18 +135,18 @@ class FormVentilation extends Form
* @param string $htmlname Name of field in html form
* @param int $showempty Add an empty field
* @param array $event Event options
*
*
* @return string String with HTML select
*/
function select_pcgtype($selectid, $htmlname = 'pcg_type', $showempty = 0, $event = array()) {
global $conf;
$sql = "SELECT DISTINCT pcg_type ";
$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_account as aa";
$sql .= " INNER JOIN " . MAIN_DB_PREFIX . "accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version";
$sql .= " AND asy.rowid = " . $conf->global->CHARTOFACCOUNTS;
$sql .= " ORDER BY pcg_type";
dol_syslog(get_class($this) . "::select_pcgtype", LOG_DEBUG);
$resql = $this->db->query($sql);
@ -168,7 +168,7 @@ class FormVentilation extends Form
$this->db->free($resql);
return $out;
}
/**
* Return list of accounts with label by sub_class of accounts
*
@ -176,18 +176,18 @@ class FormVentilation extends Form
* @param string $htmlname Name of field in html form
* @param int $showempty Add an empty field
* @param array $event Event options
*
*
* @return string String with HTML select
*/
function select_pcgsubtype($selectid, $htmlname = 'pcg_subtype', $showempty = 0, $event = array()) {
global $conf;
$sql = "SELECT DISTINCT pcg_subtype ";
$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_account as aa";
$sql .= " INNER JOIN " . MAIN_DB_PREFIX . "accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version";
$sql .= " AND asy.rowid = " . $conf->global->CHARTOFACCOUNTS;
$sql .= " ORDER BY pcg_subtype";
dol_syslog(get_class($this) . "::select_pcgsubtype", LOG_DEBUG);
$resql = $this->db->query($sql);
@ -209,7 +209,7 @@ class FormVentilation extends Form
$this->db->free($resql);
return $out;
}
/**
* Return list of auxilary thirdparty accounts
*
@ -217,7 +217,7 @@ class FormVentilation extends Form
* @param string $htmlname Name of field in html form
* @param int $showempty Add an empty field
* @param array $event Event options
*
*
* @return string String with HTML select
*/
function select_auxaccount($selectid, $htmlname = 'account_num_aux', $showempty = 0, $event = array()) {
@ -246,7 +246,7 @@ class FormVentilation extends Form
// Auxiliary supplier account
$sql = "SELECT DISTINCT code_compta_fournisseur, nom ";
$sql .= " FROM ".MAIN_DB_PREFIX."societe";
$sql .= " ORDER BY code_compta";
$sql .= " ORDER BY code_compta_fournisseur";
dol_syslog(get_class($this)."::select_auxaccount", LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql) {
@ -268,7 +268,7 @@ class FormVentilation extends Form
return $out;
}
/**
* Return HTML combo list of years existing into book keepping
*
@ -284,7 +284,7 @@ class FormVentilation extends Form
$sql = "SELECT DISTINCT date_format(doc_date,'%Y') as dtyear";
$sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping";
$sql .= " ORDER BY doc_date";
$sql .= " ORDER BY date_format(doc_date,'%Y')";
dol_syslog(get_class($this)."::".__METHOD__, LOG_DEBUG);
$resql = $this->db->query($sql);
@ -304,4 +304,40 @@ class FormVentilation extends Form
return $out_array;
}
}
/**
* Return HTML combo list of years existing into book keepping
*
* @param string $selected Preselected value
* @param string $htmlname Name of HTML select object
* @param int $useempty Affiche valeur vide dans liste
* @param string $output_format (html/opton (for option html only)/array (to return options arrays
* @return string/array
*/
function selectjournal_accountancy_bookkepping($selected = '', $htmlname = 'journalid', $useempty = 0, $output_format = 'html')
{
$out_array = array();
$sql = "SELECT DISTINCT code_journal";
$sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping";
$sql .= " ORDER BY code_journal";
dol_syslog(get_class($this)."::".__METHOD__, LOG_DEBUG);
$resql = $this->db->query($sql);
if (!$resql) {
$this->error = "Error ".$this->db->lasterror();
dol_syslog(get_class($this)."::".__METHOD__.$this->error, LOG_ERR);
return -1;
}
while ($obj = $this->db->fetch_object($resql)) {
$out_array[$obj->code_journal] = $obj->code_journal;
}
$this->db->free($resql);
if ($output_format == 'html') {
return Form::selectarray($htmlname, $out_array, $selected, $useempty, 0, 0, 'placeholder="aa"');
} else {
return $out_array;
}
}
}

View File

@ -138,7 +138,7 @@ if ($result) {
//Define array for display vat tx
$def_tva[$obj->rowid]=price($obj->tva_tx);
$tabfac[$obj->rowid]["date"] = $obj->df;
$tabfac[$obj->rowid]["date"] = $db->jdate($obj->df);
$tabfac[$obj->rowid]["ref"] = $obj->ref_supplier . ' (' . $obj->ref . ')';
$tabfac[$obj->rowid]["refsologest"] = $obj->ref;
$tabfac[$obj->rowid]["refsuppliersologest"] = $obj->ref_supplier;
@ -192,7 +192,7 @@ if ($action == 'writebookkeeping') {
$bookkeeping->fk_doc = $key;
$bookkeeping->fk_docdet = $val["fk_facturefourndet"];
$bookkeeping->code_tiers = $tabcompany[$key]['code_fournisseur'];
$bookkeeping->label_compte = utf8_decode(dol_trunc($companystatic->name, 16)) . ' - ' . $invoicestatic->refsupplier . ' - ' . $langs->trans("Code_tiers");
$bookkeeping->label_compte = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->refsupplier . ' - ' . $langs->trans("Code_tiers");
$bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER;
$bookkeeping->montant = $mt;
$bookkeeping->sens = ($mt >= 0) ? 'C' : 'D';
@ -224,7 +224,7 @@ if ($action == 'writebookkeeping') {
$bookkeeping->fk_doc = $key;
$bookkeeping->fk_docdet = $val["fk_facturefourndet"];
$bookkeeping->code_tiers = '';
$bookkeeping->label_compte = utf8_decode(dol_trunc($companystatic->name, 16)) . ' - ' . $invoicestatic->refsupplier . ' - ' . utf8_decode($accountingaccount->label);
$bookkeeping->label_compte = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->refsupplier . ' - ' . $accountingaccount->label;
$bookkeeping->numero_compte = $k;
$bookkeeping->montant = $mt;
$bookkeeping->sens = ($mt < 0) ? 'C' : 'D';
@ -255,7 +255,7 @@ if ($action == 'writebookkeeping') {
$bookkeeping->fk_doc = $key;
$bookkeeping->fk_docdet = $val["fk_facturefourndet"];
$bookkeeping->code_tiers = '';
$bookkeeping->label_compte = utf8_decode(dol_trunc($companystatic->name, 16)) . ' - ' . $invoicestatic->refsupplier . ' - ' . $langs->trans("VAT"). ' '.$def_tva[$key];
$bookkeeping->label_compte = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->refsupplier . ' - ' . $langs->trans("VAT"). ' '.$def_tva[$key];
$bookkeeping->numero_compte = $k;
$bookkeeping->montant = $mt;
$bookkeeping->sens = ($mt < 0) ? 'C' : 'D';
@ -296,7 +296,7 @@ if ($action == 'export_csv') {
$sep = ";";
foreach ( $tabfac as $key => $val ) {
$date = dol_print_date($db->jdate($val["date"]), '%d%m%Y');
$date = dol_print_date($val["date"], '%d%m%Y');
// Product / Service
foreach ( $tabht[$key] as $k => $mt ) {
@ -339,7 +339,7 @@ if ($action == 'export_csv') {
print length_accounta(html_entity_decode($k)) . $sep;
print ($mt < 0 ? 'D' : 'C') . $sep;
print ($mt <= 0 ? price(- $mt) : $mt) . $sep;
print utf8_decode($companystatic->name) . $sep;
print $companystatic->name . $sep;
print $val["ref"];
print "\n";
}
@ -355,7 +355,7 @@ if ($action == 'export_csv') {
$invoicestatic->type = $val["type"];
$invoicestatic->description = html_entity_decode(dol_trunc($val["description"], 32));
$date = dol_print_date($db->jdate($val["date"]), 'day');
$date = dol_print_date($val["date"], 'day');
$companystatic->id = $tabcompany[$key]['id'];
$companystatic->name = $tabcompany[$key]['name'];
@ -369,7 +369,7 @@ if ($action == 'export_csv') {
print '"' . $date . '"' . $sep;
print '"' . $val["ref"] . '"' . $sep;
print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep;
print '"' . utf8_decode(dol_trunc($companystatic->name, 16)) . ' - ' . $val["refsuppliersologest"] . ' - ' . utf8_decode(dol_trunc($accountingaccount->label, 32)) . '"' . $sep;
print '"' . dol_trunc($companystatic->name, 16) . ' - ' . $val["refsuppliersologest"] . ' - ' . dol_trunc($accountingaccount->label, 32) . '"' . $sep;
// print '"' . dol_trunc($accountingaccount->label, 32) . '"' . $sep;
print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep;
print '"' . ($mt < 0 ? price(- $mt) : '') . '"';
@ -383,7 +383,7 @@ if ($action == 'export_csv') {
print '"' . $val["ref"] . '"' . $sep;
print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep;
// print '"' . $langs->trans("VAT") . '"' . $sep;
print '"' . utf8_decode(dol_trunc($companystatic->name, 16)) . ' - ' . $val["refsuppliersologest"] . ' - ' . $langs->trans("VAT") . '"' . $sep;
print '"' . dol_trunc($companystatic->name, 16) . ' - ' . $val["refsuppliersologest"] . ' - ' . $langs->trans("VAT") . '"' . $sep;
print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep;
print '"' . ($mt < 0 ? price(- $mt) : '') . '"';
print "\n";
@ -395,8 +395,7 @@ if ($action == 'export_csv') {
print '"' . $date . '"' . $sep;
print '"' . $val["ref"] . '"' . $sep;
print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep;
// print '"' . utf8_decode($companystatic->name) . '"' . $sep;
print '"' . utf8_decode(dol_trunc($companystatic->name, 16)) . ' - ' . $val["refsuppliersologest"] . ' - ' . $langs->trans("Code_tiers") . '"' . $sep;
print '"' . dol_trunc($companystatic->name, 16) . ' - ' . $val["refsuppliersologest"] . ' - ' . $langs->trans("Code_tiers") . '"' . $sep;
print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep;
print '"' . ($mt >= 0 ? price($mt) : '') . '"';
}
@ -478,7 +477,7 @@ if ($action == 'export_csv') {
$invoicestatic->type = $val["type"];
$invoicestatic->description = html_entity_decode(dol_trunc($val["description"], 32));
$date = dol_print_date($db->jdate($val["date"]), 'day');
$date = dol_print_date($val["date"], 'day');
// Product / Service
foreach ( $tabht[$key] as $k => $mt ) {

View File

@ -161,7 +161,7 @@ if ($result) {
}
// Invoice lines
$tabfac[$obj->rowid]["date"] = $obj->df;
$tabfac[$obj->rowid]["date"] = $db->jdate($obj->df);
$tabfac[$obj->rowid]["ref"] = $obj->facnumber;
$tabfac[$obj->rowid]["type"] = $obj->type;
$tabfac[$obj->rowid]["description"] = $obj->label_compte;
@ -220,7 +220,7 @@ if ($action == 'writebookkeeping') {
$bookkeeping->code_tiers = $tabcompany[$key]['code_client'];
$bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER;
// $bookkeeping->label_compte = $tabcompany[$key]['name'];
$bookkeeping->label_compte = utf8_decode(dol_trunc($companystatic->name, 16)) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("Code_tiers");
$bookkeeping->label_compte = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("Code_tiers");
$bookkeeping->montant = $mt;
$bookkeeping->sens = ($mt >= 0) ? 'D' : 'C';
$bookkeeping->debit = ($mt >= 0) ? $mt : 0;
@ -250,7 +250,7 @@ if ($action == 'writebookkeeping') {
$bookkeeping->fk_docdet = $val["fk_facturedet"];
$bookkeeping->code_tiers = '';
$bookkeeping->numero_compte = $k;
$bookkeeping->label_compte = utf8_decode(dol_trunc($companystatic->name, 16)) . ' - ' . $invoicestatic->ref . ' - ' . utf8_decode($accountingaccount->label);
$bookkeeping->label_compte = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->ref . ' - ' . $accountingaccount->label;
$bookkeeping->montant = $mt;
$bookkeeping->sens = ($mt < 0) ? 'D' : 'C';
$bookkeeping->debit = ($mt < 0) ? $mt : 0;
@ -280,7 +280,7 @@ if ($action == 'writebookkeeping') {
$bookkeeping->fk_docdet = $val["fk_facturedet"];
$bookkeeping->code_tiers = '';
$bookkeeping->numero_compte = $k;
$bookkeeping->label_compte = utf8_decode(dol_trunc($companystatic->name, 16)) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("VAT").' '.$def_tva[$key];
$bookkeeping->label_compte = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("VAT").' '.$def_tva[$key];
$bookkeeping->montant = $mt;
$bookkeeping->sens = ($mt < 0) ? 'D' : 'C';
$bookkeeping->debit = ($mt < 0) ? $mt : 0;
@ -324,7 +324,7 @@ if ($action == 'export_csv') {
$invoicestatic->id = $key;
$invoicestatic->ref = $val["ref"];
$date = dol_print_date($db->jdate($val["date"]), '%d%m%Y');
$date = dol_print_date($val["date"], '%d%m%Y');
foreach ( $tabttc[$key] as $k => $mt ) {
print $date . $sep;
@ -333,8 +333,7 @@ if ($action == 'export_csv') {
print length_accounta(html_entity_decode($k)) . $sep;
print ($mt < 0 ? 'C' : 'D') . $sep;
print ($mt <= 0 ? price(- $mt) : $mt) . $sep;
print utf8_decode(dol_trunc($companystatic->name, 16)) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("Code_tiers") . $sep;
// print utf8_decode($companystatic->name) . $sep;
print dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("Code_tiers") . $sep;
print $val["ref"];
print "\n";
}
@ -349,8 +348,7 @@ if ($action == 'export_csv') {
print $sep;
print ($mt < 0 ? 'D' : 'C') . $sep;
print ($mt <= 0 ? price(- $mt) : $mt) . $sep;
print utf8_decode(dol_trunc($companystatic->name, 16)) . ' - ' . $invoicestatic->ref . ' - ' . utf8_decode(utf8_decode($accountingaccount_static->label)) . $sep;
// print dol_trunc($accountingaccount_static->label, 32) . $sep;
print dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->ref . ' - ' . $accountingaccount_static->label . $sep;
print $val["ref"];
print "\n";
}
@ -365,7 +363,7 @@ if ($action == 'export_csv') {
print $sep;
print ($mt < 0 ? 'D' : 'C') . $sep;
print ($mt <= 0 ? price(- $mt) : $mt) . $sep;
print utf8_decode(dol_trunc($companystatic->name, 16)) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("VAT") . $sep;
print dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("VAT") . $sep;
// print $langs->trans("VAT") . $sep;
print $val["ref"];
print "\n";
@ -382,14 +380,13 @@ if ($action == 'export_csv') {
$invoicestatic->id = $key;
$invoicestatic->ref = $val["ref"];
$date = dol_print_date($db->jdate($val["date"]), 'day');
$date = dol_print_date($val["date"], 'day');
foreach ( $tabttc[$key] as $k => $mt ) {
print '"' . $date . '"' . $sep;
print '"' . $val["ref"] . '"' . $sep;
print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep;
print '"' . utf8_decode(dol_trunc($companystatic->name, 16)) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("Code_tiers") . '"' . $sep;
// print '"' . utf8_decode($companystatic->name) . '"' . $sep;
print '"' . dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("Code_tiers") . '"' . $sep;
print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep;
print '"' . ($mt < 0 ? price(- $mt) : '') . '"';
print "\n";
@ -404,8 +401,7 @@ if ($action == 'export_csv') {
print '"' . $date . '"' . $sep;
print '"' . $val["ref"] . '"' . $sep;
print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep;
print '"' . utf8_decode(dol_trunc($companystatic->name, 16)) . ' - ' . utf8_decode(dol_trunc($accountingaccount->label, 32)) . '"' . $sep;
// print '"' . dol_trunc($accountingaccount->label, 32) . '"' . $sep;
print '"' . dol_trunc($companystatic->name, 16) . ' - ' . dol_trunc($accountingaccount->label, 32) . '"' . $sep;
print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep;
print '"' . ($mt >= 0 ? price($mt) : '') . '"';
print "\n";
@ -418,8 +414,7 @@ if ($action == 'export_csv') {
print '"' . $date . '"' . $sep;
print '"' . $val["ref"] . '"' . $sep;
print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep;
print '"' . utf8_decode(dol_trunc($companystatic->name, 16)) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("VAT") . '"' . $sep;
// print '"' . $langs->trans("VAT") . '"' . $sep;
print '"' . dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("VAT") . '"' . $sep;
print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep;
print '"' . ($mt >= 0 ? price($mt) : '') . '"';
print "\n";
@ -497,7 +492,7 @@ if ($action == 'export_csv') {
$invoicestatic->ref = $val["ref"];
$invoicestatic->type = $val["type"];
$date = dol_print_date($db->jdate($val["date"]), 'day');
$date = dol_print_date($val["date"], 'day');
// Third party
foreach ( $tabttc[$key] as $k => $mt ) {
@ -527,7 +522,7 @@ if ($action == 'export_csv') {
print "<td>" . $invoicestatic->getNomUrl(1) . "</td>";
print "<td>" . length_accountg($k) . "</td>";
// print "<td>" . $accountingaccount->label . "</td>";
print "<td>" . $companystatic->getNomUrl(0, 'customer', 16) . ' - ' . $invoicestatic->ref . ' - ' . utf8_decode(utf8_decode($accountingaccount->label)) . "</td>";
print "<td>" . $companystatic->getNomUrl(0, 'customer', 16) . ' - ' . $invoicestatic->ref . ' - ' . $accountingaccount->label . "</td>";
print "<td align='right'>" . ($mt < 0 ? price(- $mt) : '') . "</td>";
print "<td align='right'>" . ($mt >= 0 ? price($mt) : '') . "</td>";
print "</tr>";

View File

@ -53,7 +53,7 @@ if ($year == 0) {
}
if($cat_id == 0){
$cat_id = null;
$cat_id = null;
}
// Security check
@ -76,31 +76,31 @@ $textprevyear = '<a href="' . $_SERVER["PHP_SELF"] . '?year=' . ($year_current -
$textnextyear = '&nbsp;<a href="' . $_SERVER["PHP_SELF"] . '?year=' . ($year_current + 1) . '">' . img_next() . '</a>';
print load_fiche_titre($langs->trans('ReportInOut') . " " . $textprevyear . " " . $langs->trans("Year") . " " . $year_start . " " . $textnextyear);
print '<table class="border" width="100%">';
$months = array( $langs->trans("JanuaryMin"),
$langs->trans("FebruaryMin"),
$langs->trans("MarchMin"),
$langs->trans("AprilMin"),
$langs->trans("MayMin"),
$langs->trans("JuneMin"),
$langs->trans("JulyMin"),
$langs->trans("AugustMin"),
$langs->trans("SeptemberMin"),
$langs->trans("OctoberMin"),
$langs->trans("NovemberMin"),
$months = array( $langs->trans("JanuaryMin"),
$langs->trans("FebruaryMin"),
$langs->trans("MarchMin"),
$langs->trans("AprilMin"),
$langs->trans("MayMin"),
$langs->trans("JuneMin"),
$langs->trans("JulyMin"),
$langs->trans("AugustMin"),
$langs->trans("SeptemberMin"),
$langs->trans("OctoberMin"),
$langs->trans("NovemberMin"),
$langs->trans("DecemberMin"),
);
print '<tr class="liste_titre"><th class="liste_titre">'.$langs->trans("Account").'</th>';
print '<th class="liste_titre">'.$langs->trans("Description").'</th>';
print '<th class="liste_titre" align="center">N-1</th>';
print '<th class="liste_titre" align="center">N-1</th>';
print '<th class="liste_titre" align="center">'.$langs->trans("NReal").'</th>';
foreach($months as $k => $v){
print '<th class="liste_titre" align="center">'.$langs->trans($v).'</th>';
}
print '</tr>';
print '</tr>';
$cats = $AccCat->getCatsCpts();
$catsCalcule = $AccCat->getCatsCal();
@ -123,22 +123,41 @@ if(!empty($cats))
$position = $cpt['position'];
$code = $cpt['code'];
$resultNP = $AccCat->getResult($cpt['account_number'], 0, $year_current -1, $cpt['dc']);
$resultN = $AccCat->getResult($cpt['account_number'], 0, $year_current, $cpt['dc']);
$return = $AccCat->getResult($cpt['account_number'], 0, $year_current -1, $cpt['dc']);
if ($return < 0) {
setEventMessages(null, $AccCat->errors, 'errors');
$resultNP=0;
} else {
$resultNP=$AccCat->sdc;
}
$return = $AccCat->getResult($cpt['account_number'], 0, $year_current, $cpt['dc']);
if ($return < 0) {
setEventMessages(null, $AccCat->errors, 'errors');
$resultN=0;
} else {
$resultN=$AccCat->sdc;
}
$sommes[$code]['NP'] += $resultNP;
$sommes[$code]['N'] += $resultN;
$sommes[$code]['N'] += $resultN;
print '<tr'. $bc[$var].'>';
print '<td>' . $cpt['account_number'] . '</td>';
print '<td>' . $cpt['name_cpt'] . '</td>';
print '<td>' . price($resultNP) . '</td>';
print '<td>' . price($resultN) . '</td>';
foreach($months as $k => $v){
$resultM = $AccCat->getResult($cpt['account_number'], $k+1, $year_current, $cpt['dc']);
$return = $AccCat->getResult($cpt['account_number'], $k+1, $year_current, $cpt['dc']);
if ($return < 0) {
setEventMessages(null, $AccCat->errors, 'errors');
$resultM=0;
} else {
$resultM=$AccCat->sdc;
}
$sommes[$code]['M'][$k] += $resultM;
print '<td align="right">' . price($resultM) . '</td>';
}
print "</tr>\n";
}
@ -168,9 +187,9 @@ if(!empty($cats))
}
$result = strtr($formula, $vars);
eval( '$result = (' . $result . ');' );
print '<td align="right">' . price($result) . '</td>';
print '<td align="right">' . price($result) . '</td>';
$sommes[$code]['N'] += $result;
// Detail by month
foreach($months as $k => $v){
foreach($sommes as $code => $det){
@ -181,14 +200,14 @@ if(!empty($cats))
print '<td align="right">' . price($result) . '</td>';
$sommes[$code]['M'][$k] += $result;
}
//print '<td colspan="15">' . $catsCalcule[$p]['formula'] . '</td>';
print "</tr>\n";
unset($catsCalcule[$p]); // j'élimine la catégorie calculée après affichage
}
$j++;
}
// Others calculed category
foreach($catsCalcule as $p => $catc)
{
@ -215,7 +234,7 @@ if(!empty($cats))
}
$result = strtr($formula, $vars);
eval( '$result = (' . $result . ');' );
print '<td align="right">' . price($result) . '</td>';
print '<td align="right">' . price($result) . '</td>';
$sommes[$code]['N'] += $result;
// Detail by month

View File

@ -71,7 +71,7 @@ class modAccounting extends DolibarrModules
$this->requiredby = array(); // List of modules id to disable if this one is disabled
$this->conflictwith = array("modComptabilite"); // List of modules are in conflict with this module
$this->phpmin = array(5, 3); // Minimum version of PHP required by module
$this->need_dolibarr_version = array(3, 7); // Minimum version of Dolibarr required by module
$this->need_dolibarr_version = array(3, 9); // Minimum version of Dolibarr required by module
$this->langfiles = array("accountancy");
// Constants
@ -179,7 +179,7 @@ class modAccounting extends DolibarrModules
$this->const[18] = array (
"ACCOUNTING_EXPORT_GLOBAL_ACCOUNT",
"yesno",
"1"
"1"
);
$this->const[19] = array (
"ACCOUNTING_EXPORT_LABEL",
@ -189,12 +189,12 @@ class modAccounting extends DolibarrModules
$this->const[20] = array (
"ACCOUNTING_EXPORT_AMOUNT",
"yesno",
"1"
"1"
);
$this->const[21] = array (
"ACCOUNTING_EXPORT_DEVISE",
"yesno",
"1"
"1"
);
*/
$this->const[22] = array(
@ -270,7 +270,7 @@ class modAccounting extends DolibarrModules
$this->rights[$r][4] = 'fiscalyear';
$this->rights[$r][5] = '';
$r++;
$this->rights[$r][0] = 50440;
$this->rights[$r][1] = 'Manage chart of accounts';
$this->rights[$r][2] = 'r';

View File

@ -84,6 +84,11 @@ AccountingCategory=Accounting category
NotMatch=Not Set
DeleteMvt=Delete general ledger lines
DelYear=Year to delete
DelJournal=Journal to delete
ConfirmDeleteMvt=This will delete all line of of the general ledger for year and/or from a specifics journal
DelBookKeeping=Delete the records of the general ledger
DescSellsJournal=Sales journal
@ -142,6 +147,7 @@ Modelcsv_bob50=Export towards Sage BOB 50
Modelcsv_ciel=Export towards Sage Ciel Compta or Compta Evolution
Modelcsv_quadratus=Export towards Quadratus QuadraCompta
Modelcsv_ebp=Export towards EBP
Modelcsv_cogilog=Export towards Cogilog
## Tools - Init accounting account on product / service
InitAccountancy=Init accountancy
@ -160,3 +166,4 @@ Formula=Formula
## Error
ErrorNoAccountingCategoryForThisCountry=No accounting category are available for this country
ExportNotSupported=The export format setuped is not supported into this page
BookeppingLineAlreayExists=Lines already existing into bookeeping