Commit fbc722cc059655284cf17282035a303b13d6abc0

Authored by Florian HENRY
1 parent 6522c1f7
Exists in 3.5 and in 1 other branch 3.6

Fix bug on auto ventil (take care of base account charset)

add option to display product label or accountancy code label in jounaux
accountingex/admin/journaux.php
... ... @@ -80,6 +80,17 @@ if ($action == 'update') {
80 80 } else {
81 81 setEventMessage($langs->trans("Error"), 'errors');
82 82 }
  83 +}elseif($action=='setgroupbyaccount') {
  84 + $constvalue=GETPOST('value');
  85 + $error = 0;
  86 +
  87 + $result=dolibarr_set_const($db, 'ACCOUNTINGEX_GROUPBYACCOUNT', $constvalue, 'chaine', 0, '', $conf->entity);
  88 +
  89 + if ($result<0) {
  90 + setEventMessage($langs->trans("Error"), 'errors');
  91 + } else {
  92 + setEventMessage($langs->trans("SetupSaved"));
  93 + }
83 94 }
84 95  
85 96 /*
... ... @@ -120,8 +131,21 @@ foreach ( $list as $key ) {
120 131 print '</td></tr>';
121 132 }
122 133  
123   -print '</form>';
  134 +$var=!$var;
  135 +print "<tr " . $bc[$var] . ">";
  136 +print '<td>' . $langs->trans("GroupByAccount") . '</td>';
  137 +if (! empty($conf->global->ACCOUNTINGEX_GROUPBYACCOUNT)) {
  138 + print '<td><a href="' . $_SERVER['PHP_SELF'] . '?action=setgroupbyaccount&value=0">';
  139 + print img_picto($langs->trans("Activated"), 'switch_on');
  140 + print '</a></td>';
  141 +} else {
  142 + print '<td><a href="' . $_SERVER['PHP_SELF'] . '?action=setgroupbyaccount&value=1">';
  143 + print img_picto($langs->trans("Disabled"), 'switch_off');
  144 + print '</a></td>';
  145 +}
  146 +print '</tr>';
124 147 print "</table>\n";
  148 +print '</form>';
125 149  
126 150 print '<br /><div style="text-align:center"><input type="submit" class="button" value="' . $langs->trans('Modify') . '" name="button"></div>';
127 151  
... ...
accountingex/core/modules/modAccountingExpert.class.php
... ... @@ -164,6 +164,11 @@ class modAccountingExpert extends DolibarrModules {
164 164 "yesno",
165 165 "1"
166 166 );
  167 + $this->const[17] = array (
  168 + "ACCOUNTINGEX_GROUPBYACCOUNT",
  169 + "yesno",
  170 + "1"
  171 + );
167 172  
168 173 // Css
169 174 $this->module_parts = array (
... ...
accountingex/customer/liste.php
... ... @@ -120,8 +120,9 @@ $sql .= &quot; FROM &quot; . MAIN_DB_PREFIX . &quot;facture as f&quot;;
120 120 $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "facturedet as l ON f.rowid = l.fk_facture";
121 121 $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product as p ON p.rowid = l.fk_product";
122 122 $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accountingaccount as aa ON p.accountancy_code_sell = aa.account_number";
  123 +$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_system as accsys ON accsys.pcg_version = aa.fk_pcg_version";
123 124 $sql .= " WHERE f.fk_statut > 0 AND fk_code_ventilation = 0";
124   -
  125 +$sql .= " AND (accsys.rowid='2' OR p.accountancy_code_sell IS NULL)";
125 126 if (! empty($conf->multicompany->enabled)) {
126 127 $sql .= " AND f.entity = '" . $conf->entity . "'";
127 128 }
... ... @@ -227,7 +228,7 @@ if ($result) {
227 228  
228 229 // Colonne choix ligne a ventiler
229 230 print '<td align="center">';
230   - print '<input type="checkbox" name="mesCasesCochees[]" value="' . $objp->rowid . "_" . $i . '"' . ($objp->code_sell ? "checked" : "") . '/>';
  231 + print '<input type="checkbox" name="mesCasesCochees[]" value="' . $objp->rowid . "_" . $i . '"' . ($objp->aarowid ? "checked" : "") . '/>';
231 232 print '</td>';
232 233  
233 234 print '</tr>';
... ...
accountingex/journal/purchasesjournal.php
... ... @@ -146,7 +146,12 @@ if ($result) {
146 146 $tabfac[$obj->rowid]["date"] = $obj->df;
147 147 $tabfac[$obj->rowid]["ref"] = $obj->ref;
148 148 $tabfac[$obj->rowid]["type"] = $obj->type;
149   - $tabfac[$obj->rowid]["description"] = $obj->description;
  149 + if (!empty($conf->global->ACCOUNTINGEX_GROUPBYACCOUNT)) {
  150 + $tabfac[$obj->rowid]["description"] = $obj->label_compte;
  151 + } else {
  152 + $tabfac[$obj->rowid]["description"] = $obj->description;
  153 + }
  154 + //$tabfac[$obj->rowid]["description"] = $obj->description;
150 155 $tabfac[$obj->rowid]["fk_facturefourndet"] = $obj->fdid;
151 156 $tabttc[$obj->rowid][$compta_soc] += $obj->total_ttc;
152 157 $tabht[$obj->rowid][$compta_prod] += $obj->total_ht;
... ...
accountingex/journal/sellsjournal.php
... ... @@ -151,16 +151,39 @@ if ($result) {
151 151 $tabfac[$obj->rowid]["date"] = $obj->df;
152 152 $tabfac[$obj->rowid]["ref"] = $obj->facnumber;
153 153 $tabfac[$obj->rowid]["type"] = $obj->type;
154   - $tabfac[$obj->rowid]["description"] = $obj->description;
  154 + if (!empty($conf->global->ACCOUNTINGEX_GROUPBYACCOUNT)) {
  155 + $tabfac[$obj->rowid]["description"] = $obj->label_compte;
  156 + } else {
  157 + $tabfac[$obj->rowid]["description"] = $obj->description;
  158 + }
155 159 $tabfac[$obj->rowid]["fk_facturedet"] = $obj->fdid;
156 160 if (! isset($tabttc[$obj->rowid][$compta_soc]))
157 161 $tabttc[$obj->rowid][$compta_soc] = 0;
158   - if (! isset($tabht[$obj->rowid][$compta_prod]))
  162 +
  163 + /*if (empty($conf->global->ACCOUNTINGEX_GROUPBYACCOUNT)) {
  164 + if (! isset($tabht[$obj->rowid][$compta_prod])) {
  165 + $tabht[$obj->rowid][$compta_prod] = 0;
  166 + }
  167 + } else {
  168 + if (! isset($tabht[$obj->rowid][$compta_prod])) {
  169 + $tabht[$obj->rowid][$compta_prod] = 0;
  170 + }
  171 + }*/
  172 + if (! isset($tabht[$obj->rowid][$compta_prod])) {
159 173 $tabht[$obj->rowid][$compta_prod] = 0;
  174 + }
  175 +
160 176 if (! isset($tabtva[$obj->rowid][$compta_tva]))
161 177 $tabtva[$obj->rowid][$compta_tva] = 0;
162 178 $tabttc[$obj->rowid][$compta_soc] += $obj->total_ttc;
  179 +
  180 + /*if (empty($conf->global->ACCOUNTINGEX_GROUPBYACCOUNT)) {
  181 + $tabht[$obj->rowid][$compta_prod] += $obj->total_ht;
  182 + } else {
  183 + $tabht[$obj->rowid][$compta_prod] += $obj->total_ht;
  184 + }*/
163 185 $tabht[$obj->rowid][$compta_prod] += $obj->total_ht;
  186 +
164 187 $tabtva[$obj->rowid][$compta_tva] += $obj->total_tva;
165 188 $tabcompany[$obj->rowid] = array (
166 189 'id' => $obj->socid,
... ... @@ -181,7 +204,6 @@ if ($result) {
181 204 // Bookkeeping Write
182 205 if ($action == 'writebookkeeping') {
183 206 $now = dol_now();
184   -
185 207 foreach ( $tabfac as $key => $val ) {
186 208 foreach ( $tabttc[$key] as $k => $mt ) {
187 209 $bookkeeping = new BookKeeping($db);
... ... @@ -426,6 +448,7 @@ if ($action == &#39;export_csv&#39;) {
426 448 $invoicestatic->id = $key;
427 449 $invoicestatic->ref = $val["ref"];
428 450 $invoicestatic->type = $val["type"];
  451 +
429 452 $invoicestatic->description = html_entity_decode(dol_trunc($val["description"], 32));
430 453  
431 454 $date = dol_print_date($db->jdate($val["date"]), 'day');
... ...
accountingex/langs/en_US/accountingex.lang
... ... @@ -170,4 +170,5 @@ Accountancy_code_sell_suggest=Code sell suggest
170 170 CreateMvts=Create a movement
171 171  
172 172 customer_invoice=Customer invoice
173   -supplier_invoice=Supplier invoice
174 173 \ No newline at end of file
  174 +supplier_invoice=Supplier invoice
  175 +GroupByAccount=Display account number (else product label)
175 176 \ No newline at end of file
... ...
accountingex/langs/es_ES/accountingex.lang
... ... @@ -172,4 +172,5 @@ Accountancy_code_sell_suggest=Código ventas sugerido
172 172 CreateMvts=Crear movimiento
173 173  
174 174 customer_invoice=Factura a cliente
175   -supplier_invoice=Factura de proveedor
176 175 \ No newline at end of file
  176 +supplier_invoice=Factura de proveedor
  177 +GroupByAccount=Display account number (else product label)
177 178 \ No newline at end of file
... ...
accountingex/langs/fr_FR/accountingex.lang
... ... @@ -170,4 +170,5 @@ Accountancy_code_sell_suggest=Code ventes suggéré
170 170 CreateMvts=Créer un mouvement
171 171  
172 172 customer_invoice=Facture client
173   -supplier_invoice=Facture fournisseur
174 173 \ No newline at end of file
  174 +supplier_invoice=Facture fournisseur
  175 +GroupByAccount=Afficher le libélé du compte (sinon libelle produit)
175 176 \ No newline at end of file
... ...
accountingex/supplier/liste.php
... ... @@ -122,8 +122,9 @@ $sql .= &quot; FROM &quot; . MAIN_DB_PREFIX . &quot;facture_fourn as f&quot;;
122 122 $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "facture_fourn_det as l ON f.rowid = l.fk_facture_fourn";
123 123 $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product as p ON p.rowid = l.fk_product";
124 124 $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accountingaccount as aa ON p.accountancy_code_buy = aa.account_number";
  125 +$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_system as accsys ON accsys.pcg_version = aa.fk_pcg_version";
125 126 $sql .= " WHERE f.fk_statut > 0 AND fk_code_ventilation = 0";
126   -
  127 +$sql .= " AND (accsys.rowid='2' OR p.accountancy_code_sell IS NULL)";
127 128 if (! empty($conf->multicompany->enabled)) {
128 129 $sql .= " AND f.entity = '" . $conf->entity . "'";
129 130 }
... ... @@ -207,7 +208,7 @@ if ($result) {
207 208 print '</td>';
208 209 // Colonne choix ligne a ventiler
209 210 print '<td align="center">';
210   - print '<input type="checkbox" name="mesCasesCochees[]" value="' . $objp->rowid . "_" . $i . '"' . ($objp->code_buy ? "checked" : "") . '/>';
  211 + print '<input type="checkbox" name="mesCasesCochees[]" value="' . $objp->rowid . "_" . $i . '"' . ($objp->aarowid ? "checked" : "") . '/>';
211 212 print '</td>';
212 213  
213 214 print "</tr>";
... ...