52 $this->family =
"financial";
53 $this->module_position =
'51';
55 $this->
name = preg_replace(
'/^mod/i',
'', get_class($this));
56 $this->
description =
"Gestion des comptes financiers de type Comptes bancaires ou postaux";
59 $this->version =
'dolibarr';
61 $this->const_name =
'MAIN_MODULE_'.strtoupper($this->
name);
62 $this->picto =
'account';
65 $this->dirs = array(
"/bank/temp");
69 $this->config_page_url = array(
"bank.php");
72 $this->depends = array();
73 $this->requiredby = array(
"modComptabilite",
"modAccounting",
"modPrelevement");
74 $this->conflictwith = array();
75 $this->langfiles = array(
"banks",
"compta",
"bills",
"companies",
"accounting");
78 $this->
const = array();
81 $this->boxes = array(0=>array(
'file'=>
'box_comptes.php',
'enabledbydefaulton'=>
'Home'));
84 $this->rights = array();
85 $this->rights_class =
'banque';
89 $this->rights[$r][0] = 111;
90 $this->rights[$r][1] =
'Read bank account and transactions';
91 $this->rights[$r][2] =
'r';
92 $this->rights[$r][3] = 0;
93 $this->rights[$r][4] =
'lire';
96 $this->rights[$r][0] = 112;
97 $this->rights[$r][1] =
'Creer/modifier montant/supprimer ecriture bancaire';
98 $this->rights[$r][2] =
'w';
99 $this->rights[$r][3] = 0;
100 $this->rights[$r][4] =
'modifier';
103 $this->rights[$r][0] = 113;
104 $this->rights[$r][1] =
'Configurer les comptes bancaires (creer, gerer categories)';
105 $this->rights[$r][2] =
'a';
106 $this->rights[$r][3] = 0;
107 $this->rights[$r][4] =
'configurer';
110 $this->rights[$r][0] = 114;
111 $this->rights[$r][1] =
'Rapprocher les ecritures bancaires';
112 $this->rights[$r][2] =
'w';
113 $this->rights[$r][3] = 0;
114 $this->rights[$r][4] =
'consolidate';
117 $this->rights[$r][0] = 115;
118 $this->rights[$r][1] =
'Exporter transactions et releves';
119 $this->rights[$r][2] =
'r';
120 $this->rights[$r][3] = 0;
121 $this->rights[$r][4] =
'export';
124 $this->rights[$r][0] = 116;
125 $this->rights[$r][1] =
'Virements entre comptes';
126 $this->rights[$r][2] =
'w';
127 $this->rights[$r][3] = 0;
128 $this->rights[$r][4] =
'transfer';
131 $this->rights[$r][0] = 117;
132 $this->rights[$r][1] =
'Gerer les envois de cheques';
133 $this->rights[$r][2] =
'w';
134 $this->rights[$r][3] = 0;
135 $this->rights[$r][4] =
'cheque';
149 $this->export_code[$r] = $this->rights_class.
'_'.$r;
150 $this->export_label[$r] =
'Ecritures bancaires et releves';
151 $this->export_permission[$r] = array(array(
"banque",
"export"));
152 $this->export_fields_array[$r] = array(
153 'b.rowid'=>
'IdTransaction',
'ba.ref'=>
'AccountRef',
'ba.label'=>
'AccountLabel',
'b.datev'=>
'DateValue',
'b.dateo'=>
'DateOperation',
'b.label'=>
'Label',
154 'b.num_chq'=>
'ChequeOrTransferNumber',
'b.fk_bordereau'=>
'ChequeBordereau',
'-b.amount'=>
'Debit',
'b.amount'=>
'Credit',
155 'b.num_releve'=>
'AccountStatement',
'b.rappro'=>
'BankLineReconciled',
'b.datec'=>
"DateCreation",
"bu.url_id"=>
"IdThirdParty",
156 "s.nom"=>
"ThirdParty",
"s.code_compta"=>
"CustomerAccountancyCode",
"s.code_compta_fournisseur"=>
"SupplierAccountancyCode"
158 $this->export_TypeFields_array[$r] = array(
'ba.ref'=>
'Text',
'ba.label'=>
'Text',
'b.datev'=>
'Date',
'b.dateo'=>
'Date',
'b.label'=>
'Text',
'b.num_chq'=>
'Text',
'b.fk_bordereau'=>
'Text',
'-b.amount'=>
'Numeric',
'b.amount'=>
'Numeric',
'b.num_releve'=>
'Text',
'b.rappro'=>
'Boolean',
'b.datec'=>
"Date",
"bu.url_id"=>
"Text",
"s.nom"=>
"Text",
"s.code_compta"=>
"Text",
"s.code_compta_fournisseur"=>
"Text");
159 $this->export_entities_array[$r] = array(
160 'b.rowid'=>
'account',
'ba.ref'=>
'account',
'ba.label'=>
'account',
'b.datev'=>
'account',
'b.dateo'=>
'account',
'b.label'=>
'account',
161 'b.num_chq'=>
'account',
'b.fk_bordereau'=>
'account',
'-b.amount'=>
'account',
'b.amount'=>
'account',
162 'b.num_releve'=>
'account',
'b.rappro'=>
'account',
'b.datec'=>
"account",
"bu.url_id"=>
"company",
163 "s.nom"=>
"company",
"s.code_compta"=>
"company",
"s.code_compta_fournisseur"=>
"company"
165 $this->export_special_array[$r] = array(
'-b.amount'=>
'NULLIFNEG',
'b.amount'=>
'NULLIFNEG');
167 unset($this->export_fields_array[$r][
's.code_compta_fournisseur']);
168 unset($this->export_entities_array[$r][
's.code_compta_fournisseur']);
170 $this->export_sql_start[$r] =
'SELECT DISTINCT ';
171 $this->export_sql_end[$r] =
' FROM ('.MAIN_DB_PREFIX.
'bank_account as ba, '.MAIN_DB_PREFIX.
'bank as b)';
172 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
"bank_url as bu ON (bu.fk_bank = b.rowid AND bu.type = 'company')";
173 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'societe as s ON bu.url_id = s.rowid';
174 $this->export_sql_end[$r] .=
' WHERE ba.rowid = b.fk_account';
175 $this->export_sql_end[$r] .=
' AND ba.entity IN ('.getEntity(
'bank_account').
')';
176 $this->export_sql_order[$r] =
' ORDER BY b.datev, b.num_releve';
180 $this->export_code[$r] = $this->rights_class.
'_'.$r;
181 $this->export_label[$r] =
'Bordereaux remise Chq/Fact';
182 $this->export_permission[$r] = array(array(
"banque",
"export"));
183 $this->export_fields_array[$r] = array(
"bch.rowid"=>
"DepositId",
"bch.ref"=>
"Numero",
"bch.ref_ext"=>
"RefExt",
'ba.ref'=>
'AccountRef',
'ba.label'=>
'AccountLabel',
'b.datev'=>
'DateValue',
'b.num_chq'=>
'ChequeOrTransferNumber',
'b.amount'=>
'Credit',
'b.num_releve'=>
'AccountStatement',
'b.datec'=>
"DateCreation",
184 "bch.date_bordereau"=>
"Date",
"bch.amount"=>
"Total",
"bch.nbcheque"=>
"NbCheque",
"bu.url_id"=>
"IdThirdParty",
"s.nom"=>
"ThirdParty",
"s.code_compta"=>
"CustomerAccountancyCode",
"f.ref"=>
"InvoiceRef"
186 $this->export_TypeFields_array[$r] = array(
'ba.ref'=>
'Text',
'ba.label'=>
'Text',
'b.datev'=>
'Date',
'b.num_chq'=>
'Text',
'b.amount'=>
'Numeric',
'b.num_releve'=>
'Text',
'b.datec'=>
"Date",
187 "bch.date_bordereau"=>
"Date",
"bch.rowid"=>
"Numeric",
"bch.ref"=>
"Numeric",
"bch.ref_ext"=>
"Text",
"bch.amount"=>
"Numeric",
"bch.nbcheque"=>
"Numeric",
"bu.url_id"=>
"Text",
"s.nom"=>
"Text",
"s.code_compta"=>
"Text",
"f.ref"=>
"Text"
189 $this->export_entities_array[$r] = array(
'ba.ref'=>
'account',
'ba.label'=>
'account',
'b.datev'=>
'account',
'b.num_chq'=>
'account',
'b.amount'=>
'account',
'b.num_releve'=>
'account',
'b.datec'=>
"account",
190 "bu.url_id"=>
"company",
"s.nom"=>
"company",
"s.code_compta"=>
"company",
"s.code_compta_fournisseur"=>
"company",
"f.ref"=>
"invoice");
191 $this->export_special_array[$r] = array(
'b.amount'=>
'NULLIFNEG');
193 $this->export_sql_start[$r] =
'SELECT DISTINCT ';
194 $this->export_sql_end[$r] =
' FROM ('.MAIN_DB_PREFIX.
'bordereau_cheque as bch, '.MAIN_DB_PREFIX.
'bank_account as ba, '.MAIN_DB_PREFIX.
'bank as b)';
195 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
"bank_url as bu ON (bu.fk_bank = b.rowid AND bu.type = 'company')";
196 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'paiement as p ON b.rowid = p.fk_bank';
197 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'paiement_facture as pf ON p.rowid = pf.fk_paiement';
198 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'facture as f ON f.rowid = pf.fk_facture';
199 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'societe as s ON f.fk_soc = s.rowid';
200 $this->export_sql_end[$r] .=
' WHERE ba.rowid = b.fk_account AND bch.rowid = b.fk_bordereau and bch.fk_bank_account=ba.rowid';
201 $this->export_sql_end[$r] .=
" AND b.fk_type = 'CHQ'";
202 $this->export_sql_end[$r] .=
' AND p.fk_paiement = 7';
203 $this->export_sql_end[$r] .=
' AND ba.entity IN ('.getEntity(
'bank_account').
')';
204 $this->export_sql_order[$r] =
' ORDER BY b.datev, b.num_releve';
208 $this->export_code[$r] = $this->rights_class.
'_'.$r;
209 $this->export_label[$r] =
'VariousPayment';
210 $this->export_permission[$r] = array(array(
"banque",
"export"));
211 $this->export_fields_array[$r] = array(
212 'v.rowid'=>
'VariousPaymentId',
'v.label'=>
'VariousPaymentLabel',
'v.datev'=>
'DateValue',
'v.datep'=>
'DateOperation',
213 'v.num_payment'=>
'ChequeOrTransferNumber',
'v.amount'=>
'Amount',
'v.sens'=>
'Sens',
214 'cp.id'=>
"PaymentMode",
215 'v.accountancy_code'=>
'AccountAccounting',
'v.subledger_account'=>
'SubledgerAccount',
216 'v.note'=>
'Note',
'v.datec'=>
'DateCreation',
217 'p.ref'=>
'ProjectRef',
'p.title'=>
'ProjectLabel'
219 $this->export_TypeFields_array[$r] = array(
220 'v.rowid'=>
'Text',
'v.label'=>
'Text',
'v.datep'=>
'Date',
'v.datev'=>
'Date',
221 'v.num_payment'=>
'Text',
'v.amount'=>
'Numeric',
'v.sens'=>
'Numeric',
222 'cp.id'=>
'List:c_paiement:code:id:code',
223 "v.accountancy_code"=>
"Text",
"v.subledger_account"=>
"Text",
224 "v.note"=>
"Text",
'v.datec'=>
"Date",
225 "p.ref"=>
"Text",
"p.title"=>
"Text"
227 $this->export_entities_array[$r] = array(
228 'v.rowid'=>
'payment',
'v.label'=>
'payment',
'v.datev'=>
'payment',
'v.datep'=>
'payment',
229 'v.num_payment'=>
'payment',
'v.amount'=>
'payment',
'v.sens'=>
'payment',
231 'v.accountancy_code'=>
'payment',
'v.subledger_account'=>
"payment",
232 'v.note'=>
"payment",
'v.datec'=>
"payment",
233 "p.ref"=>
"project",
"p.title"=>
"project"
236 $keyforselect =
'payment_various';
237 $keyforelement =
'payment';
238 $keyforaliasextra =
'extra';
239 include DOL_DOCUMENT_ROOT.
'/core/extrafieldsinexport.inc.php';
240 $this->export_sql_start[$r] =
'SELECT ';
241 $this->export_sql_end[$r] =
' FROM '.MAIN_DB_PREFIX.
'payment_various as v';
242 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
"projet as p ON v.fk_projet = p.rowid";
243 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
"c_paiement as cp ON v.fk_typepayment = cp.id";
244 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'payment_various_extrafields as extra ON v.rowid = extra.fk_object';
245 $this->export_sql_end[$r] .=
' WHERE v.entity IN ('.getEntity(
'payment_various').
')';
246 $this->export_sql_order[$r] =
' ORDER BY v.datep';