53 $this->family =
"financial";
54 $this->module_position =
'11';
56 $this->
name = preg_replace(
'/^mod/i',
'', get_class($this));
62 $this->const_name =
'MAIN_MODULE_'.strtoupper($this->
name);
63 $this->picto =
'bill';
66 $this->dirs = array(
"/facture/temp");
69 $this->depends = array(
'always' =>
"modSociete");
70 $this->requiredby = array(
"modComptabilite",
"modAccounting");
71 $this->conflictwith = array();
72 $this->langfiles = array(
"bills",
"companies",
"compta",
"products");
73 $this->warnings_activation = array();
74 $this->warnings_activation_ext = array();
77 $this->config_page_url = array(
"invoice.php");
85 'Name of numbering numerotation rules of invoice',
92 'Name of PDF model of invoice',
96 "FACTURE_ADDON_PDF_ODT_PATH",
98 "DOL_DATA_ROOT".($conf->entity > 1 ?
'/'.$conf->entity :
'').
"/doctemplates/invoices",
106 $this->boxes = array(
107 0 => array(
'file' =>
'box_factures_imp.php',
'enabledbydefaulton' =>
'Home'),
108 1 => array(
'file' =>
'box_factures.php',
'enabledbydefaulton' =>
'Home'),
109 2 => array(
'file' =>
'box_graph_invoices_permonth.php',
'enabledbydefaulton' =>
'Home'),
110 3 => array(
'file' =>
'box_customers_outstanding_bill_reached.php',
'enabledbydefaulton' =>
'Home'),
111 4 => array(
'file' =>
'box_invoices_dispute.php',
'enabledbydefaulton' =>
'Home')
116 $datestart =
dol_mktime(23, 0, 0, $arraydate[
'mon'], $arraydate[
'mday'], $arraydate[
'year']);
117 $this->cronjobs = array(
119 'label' =>
'RecurringInvoicesJob',
120 'jobtype' =>
'method',
121 'class' =>
'compta/facture/class/facture-rec.class.php',
122 'objectname' =>
'FactureRec',
123 'method' =>
'createRecurringInvoices',
125 'comment' =>
'Generate recurring invoices.',
127 'unitfrequency' => 3600 * 24,
130 'test' =>
'isModEnabled("invoice")',
131 'datestart' => $datestart
134 'label' =>
'SendEmailsRemindersOnInvoiceDueDate',
135 'jobtype' =>
'method',
136 'class' =>
'compta/facture/class/facture.class.php',
137 'objectname' =>
'Facture',
138 'method' =>
'sendEmailsRemindersOnInvoiceDueDate',
139 'parameters' =>
"10,all,EmailTemplateCode,duedate",
140 'comment' =>
'Send an email when we reach the invoice due date (or invoice date) - n days. First param is n, the number of days before due date (or invoice date) to send the remind (or after if value is negative), second parameter is "all" or a payment mode code, third parameter is the code of the email template to use (an email template with the EmailTemplateCode must exists. The version of the email template in the language of the thirdparty will be used in priority. Language of the thirdparty will be also used to update the PDF of the sent invoice). The fourth parameter is the string "duedate" (default) or "invoicedate" to define which date of the invoice to use.',
142 'unitfrequency' => 3600 * 24,
145 'test' =>
'isModEnabled("invoice")',
146 'datestart' => $datestart
151 $this->rights = array();
152 $this->rights_class =
'facture';
156 $this->rights[$r][0] = 11;
157 $this->rights[$r][1] =
'Read invoices';
158 $this->rights[$r][2] =
'a';
159 $this->rights[$r][3] = 0;
160 $this->rights[$r][4] =
'lire';
163 $this->rights[$r][0] = 12;
164 $this->rights[$r][1] =
'Create and update invoices';
165 $this->rights[$r][2] =
'a';
166 $this->rights[$r][3] = 0;
167 $this->rights[$r][4] =
'creer';
171 $this->rights[$r][0] = 13;
172 $this->rights[$r][1] =
'Devalidate invoices';
173 $this->rights[$r][2] =
'a';
174 $this->rights[$r][3] = 0;
175 $this->rights[$r][4] =
'invoice_advance';
176 $this->rights[$r][5] =
'unvalidate';
179 $this->rights[$r][0] = 14;
180 $this->rights[$r][1] =
'Validate invoices';
181 $this->rights[$r][2] =
'a';
182 $this->rights[$r][3] = 0;
183 $this->rights[$r][4] =
'invoice_advance';
184 $this->rights[$r][5] =
'validate';
187 $this->rights[$r][0] = 15;
188 $this->rights[$r][1] =
'Send invoices by email';
189 $this->rights[$r][2] =
'a';
190 $this->rights[$r][3] = 0;
191 $this->rights[$r][4] =
'invoice_advance';
192 $this->rights[$r][5] =
'send';
195 $this->rights[$r][0] = 16;
196 $this->rights[$r][1] =
'Issue payments on invoices';
197 $this->rights[$r][2] =
'a';
198 $this->rights[$r][3] = 0;
199 $this->rights[$r][4] =
'paiement';
202 $this->rights[$r][0] = 19;
203 $this->rights[$r][1] =
'Delete invoices';
204 $this->rights[$r][2] =
'a';
205 $this->rights[$r][3] = 0;
206 $this->rights[$r][4] =
'supprimer';
209 $this->rights[$r][0] = 1321;
210 $this->rights[$r][1] =
'Export customer invoices, attributes and payments';
211 $this->rights[$r][2] =
'r';
212 $this->rights[$r][3] = 0;
213 $this->rights[$r][4] =
'facture';
214 $this->rights[$r][5] =
'export';
217 $this->rights[$r][0] = 1322;
218 $this->rights[$r][1] =
'Re-open a fully paid invoice';
219 $this->rights[$r][2] =
'r';
220 $this->rights[$r][3] = 0;
221 $this->rights[$r][4] =
'invoice_advance';
222 $this->rights[$r][5] =
'reopen';
236 $this->import_code[$r] = $this->rights_class.
'_'.$r;
237 $this->import_label[$r] =
"Invoices";
238 $this->import_icon[$r] = $this->picto;
239 $this->import_entities_array[$r] = array();
240 $this->import_tables_array[$r] = array(
'f' => MAIN_DB_PREFIX.
'facture',
'extra' => MAIN_DB_PREFIX.
'facture_extrafields');
241 $this->import_tables_creator_array[$r] = array(
'f' =>
'fk_user_author');
242 $this->import_fields_array[$r] = array(
243 'f.ref' =>
'InvoiceRef*',
244 'f.ref_ext' =>
'ExternalRef',
245 'f.ref_client' =>
'RefCustomer',
247 'f.fk_soc' =>
'Customer*',
248 'f.datec' =>
'InvoiceDateCreation',
249 'f.datef' =>
'DateInvoice',
250 'f.date_valid' =>
'Validation Date',
251 'f.paye' =>
'InvoicePaid',
252 'f.total_tva' =>
'TotalVAT',
253 'f.total_ht' =>
'TotalHT',
254 'f.total_ttc' =>
'TotalTTC',
255 'f.fk_statut' =>
'InvoiceStatus',
256 'f.fk_user_modif' =>
'Modifier Id',
257 'f.fk_user_valid' =>
'Validator Id',
258 'f.fk_user_closing' =>
'Closer Id',
259 'f.fk_facture_source' =>
'Invoice Source Id',
260 'f.fk_projet' =>
'Project Id',
261 'f.fk_account' =>
'Bank Account',
262 'f.fk_currency' =>
'Currency*',
263 'f.fk_cond_reglement' =>
'PaymentTerm',
264 'f.fk_mode_reglement' =>
'PaymentMode',
265 'f.date_lim_reglement' =>
'DateMaxPayment',
266 'f.note_public' =>
'InvoiceNote',
267 'f.note_private' =>
'NotePrivate',
268 'f.model_pdf' =>
'Model'
271 $this->import_fields_array[$r][
'f.multicurrency_code'] =
'Currency';
272 $this->import_fields_array[$r][
'f.multicurrency_tx'] =
'CurrencyRate';
273 $this->import_fields_array[$r][
'f.multicurrency_total_ht'] =
'MulticurrencyAmountHT';
274 $this->import_fields_array[$r][
'f.multicurrency_total_tva'] =
'MulticurrencyAmountVAT';
275 $this->import_fields_array[$r][
'f.multicurrency_total_ttc'] =
'MulticurrencyAmountTTC';
278 $import_extrafield_sample = array();
279 $keyforselect =
'facture';
280 $keyforelement =
'bill';
281 $keyforaliasextra =
'extra';
282 include DOL_DOCUMENT_ROOT.
'/core/extrafieldsinimport.inc.php';
283 $this->import_fieldshidden_array[$r] = array(
'extra.fk_object' =>
'lastrowid-'.MAIN_DB_PREFIX.
'facture');
284 $this->import_regex_array[$r] = array(
'f.multicurrency_code' =>
'code@'.MAIN_DB_PREFIX.
'multicurrency');
285 $import_sample = array(
286 'f.ref' =>
'(PROV0001)',
288 'f.ref_client' =>
'',
290 'f.fk_soc' =>
'80LIMIT',
291 'f.datec' =>
'2021-11-24',
292 'f.datef' =>
'2021-11-24',
293 'f.date_valid' =>
'2021-11-24',
295 'f.total_tva' =>
'21',
296 'f.total_ht' =>
'100',
297 'f.total_ttc' =>
'121',
298 'f.fk_statut' =>
'1',
299 'f.fk_user_modif' =>
'',
300 'f.fk_user_valid' =>
'',
301 'f.fk_user_closing' =>
'',
302 'f.fk_facture_source' =>
'',
304 'f.fk_account' =>
'',
305 'f.fk_currency' =>
'EUR',
306 'f.fk_cond_reglement' =>
'30D',
307 'f.fk_mode_reglement' =>
'VIR',
308 'f.date_lim_reglement' =>
'2021-12-24',
309 'f.note_public' =>
'',
310 'f.note_private' =>
'',
311 'f.model_pdf' =>
'sponge',
312 'f.multicurrency_code' =>
'EUR',
313 'f.multicurrency_tx' =>
'1',
314 'f.multicurrency_total_ht' =>
'100',
315 'f.multicurrency_total_tva' =>
'21',
316 'f.multicurrency_total_ttc' =>
'121'
318 $this->import_examplevalues_array[$r] = array_merge($import_sample, $import_extrafield_sample);
319 $this->import_updatekeys_array[$r] = array(
'f.ref' =>
'Ref');
320 $this->import_convertvalue_array[$r] = array(
322 'rule' =>
'fetchidfromref',
323 'file' =>
'/societe/class/societe.class.php',
324 'class' =>
'Societe',
326 'element' =>
'ThirdParty'
328 'f.fk_projet' => array(
329 'rule' =>
'fetchidfromref',
330 'file' =>
'/projet/class/project.class.php',
331 'class' =>
'Project',
333 'element' =>
'facture'
335 'f.fk_cond_reglement' => array(
336 'rule' =>
'fetchidfromcodeorlabel',
337 'file' =>
'/compta/facture/class/paymentterm.class.php',
338 'class' =>
'PaymentTerm',
340 'element' =>
'c_payment_term'
346 $this->import_code[$r] = $this->rights_class.
'_'.$r;
347 $this->import_label[$r] =
"InvoiceLine";
348 $this->import_icon[$r] = $this->picto;
349 $this->import_entities_array[$r] = array();
350 $this->import_tables_array[$r] = array(
'fd' => MAIN_DB_PREFIX.
'facturedet',
'extra' => MAIN_DB_PREFIX.
'facturedet_extrafields');
351 $this->import_fields_array[$r] = array(
352 'fd.fk_facture' =>
'InvoiceRef*',
353 'fd.fk_parent_line' =>
'FacParentLine',
354 'fd.fk_product' =>
'ProductOrService',
355 'fd.label' =>
'Label',
356 'fd.description' =>
'LineDescription*',
357 'fd.vat_src_code' =>
'Vat Source Code',
358 'fd.tva_tx' =>
'LineVATRate*',
363 'fd.qty' =>
'LineQty',
364 'fd.remise_percent' =>
'Reduc. (%)',
367 'fd.subprice' =>
'UnitPriceHT',
369 'fd.total_ht' =>
'LineTotalHT',
370 'fd.total_tva' =>
'LineTotalVAT',
373 'fd.total_ttc' =>
'LineTotalTTC',
374 'fd.product_type' =>
'TypeOfLineServiceOrProduct',
375 'fd.date_start' =>
'Start Date',
376 'fd.date_end' =>
'End Date',
383 'fd.fk_unit' =>
'Unit',
392 $this->import_fields_array[$r][
'fd.multicurrency_code'] =
'Currency';
393 $this->import_fields_array[$r][
'fd.multicurrency_subprice'] =
'CurrencyRate';
394 $this->import_fields_array[$r][
'fd.multicurrency_total_ht'] =
'MulticurrencyAmountHT';
395 $this->import_fields_array[$r][
'fd.multicurrency_total_tva'] =
'MulticurrencyAmountVAT';
396 $this->import_fields_array[$r][
'fd.multicurrency_total_ttc'] =
'MulticurrencyAmountTTC';
399 $import_extrafield_sample = array();
400 $keyforselect =
'facture_det';
401 $keyforelement =
'bill';
402 $keyforaliasextra =
'extra';
403 include DOL_DOCUMENT_ROOT.
'/core/extrafieldsinimport.inc.php';
404 $this->import_fieldshidden_array[$r] = array(
'extra.fk_object' =>
'lastrowid-'.MAIN_DB_PREFIX.
'facturedet');
405 $this->import_regex_array[$r] = array(
406 'fd.multicurrency_code' =>
'code@'.MAIN_DB_PREFIX.
'multicurrency'
408 $import_sample = array(
409 'fd.fk_facture' =>
'(PROV00001)',
410 'fd.fk_parent_line' =>
'',
411 'fd.fk_product' =>
'ref:PRODUCT_REF or id:123456',
413 'fd.description' =>
'Test product',
414 'fd.vat_src_code' =>
'',
421 'fd.remise_percent' =>
'0',
424 'fd.subprice' =>
'100',
426 'fd.total_ht' =>
'100',
427 'fd.total_tva' =>
'21',
430 'fd.total_ttc' =>
'121',
431 'fd.product_type' =>
'0',
432 'fd.date_start' =>
'',
447 'fd.multicurrency_code' =>
'EUR',
448 'fd.multicurrency_tx' =>
'21',
449 'fd.multicurrency_total_ht' =>
'100',
450 'fd.multicurrency_total_tva' =>
'21',
451 'fd.multicurrency_total_ttc' =>
'121'
453 $this->import_examplevalues_array[$r] = array_merge($import_sample, $import_extrafield_sample);
454 $this->import_updatekeys_array[$r] = array(
455 'fd.rowid' =>
'Row Id',
456 'fd.fk_facture' =>
'Invoice Id',
457 'fd.fk_product' =>
'ProductRef'
459 $this->import_convertvalue_array[$r] = array(
460 'fd.fk_facture' => array(
461 'rule' =>
'fetchidfromref',
462 'file' =>
'/compta/facture/class/facture.class.php',
463 'class' =>
'Facture',
465 'element' =>
'facture'
467 'fd.fk_product' => array(
468 'rule' =>
'fetchidfromref',
469 'classfile' =>
'/product/class/product.class.php',
470 'class' =>
'Product',
472 'element' =>
'Product'
474 'fd.fk_projet' => array(
475 'rule' =>
'fetchidfromref',
476 'file' =>
'/projet/class/project.class.php',
477 'class' =>
'Project',
479 'element' =>
'facture'
485 $this->import_code[$r] = $this->rights_class.
'_'.$r;
486 $this->import_label[$r] =
"Payments";
487 $this->import_icon[$r] = $this->picto;
488 $this->import_entities_array[$r] = array();
489 $this->import_tables_array[$r] = array(
'p' => MAIN_DB_PREFIX.
'paiement',
'extra' => MAIN_DB_PREFIX.
'paiement_extrafields');
490 $this->import_tables_creator_array[$r] = array(
'p' =>
'fk_user_creat');
491 $this->import_fields_array[$r] = array(
492 'p.ref' =>
'PaymentRef*',
493 'p.ref_ext' =>
'ExternalRef',
494 'p.datec' =>
'DateCreation',
495 'p.datep' =>
'DatePayment*',
496 'p.amount' =>
'PaymentAmount*',
497 'p.fk_paiement' =>
'PaymentMode*',
498 'p.num_paiement' =>
'PaymentNumber',
500 'p.statut' =>
'Status'
503 $this->import_fields_array[$r][
'p.multicurrency_amount'] =
'MulticurrencyAmountTTC';
506 $import_extrafield_sample = array();
507 $keyforselect =
'paiement';
508 $keyforelement =
'payment';
509 $keyforaliasextra =
'extra';
510 include DOL_DOCUMENT_ROOT.
'/core/extrafieldsinimport.inc.php';
511 $this->import_fieldshidden_array[$r] = array(
'extra.fk_object' =>
'lastrowid-'.MAIN_DB_PREFIX.
'paiement');
512 $this->import_regex_array[$r] = array(
'p.fk_paiement' =>
'id@'.MAIN_DB_PREFIX.
'c_paiement');
513 $import_sample = array(
514 'p.ref' =>
'(PROV0001)',
516 'p.datec' =>
'2021-11-24',
517 'p.datep' =>
'2021-11-24',
519 'p.fk_paiement' =>
'1/2/3...matches field "id" in table "'.MAIN_DB_PREFIX.
'c_paiement"',
520 'p.num_paiement' =>
'',
525 $import_sample[
'p.multicurrency_amount'] =
'121';
527 $this->import_examplevalues_array[$r] = array_merge($import_sample, $import_extrafield_sample);
528 $this->import_updatekeys_array[$r] = array(
'p.ref' =>
'Ref');
532 $this->import_code[$r] = $this->rights_class.
'_'.$r;
533 $this->import_label[$r] =
"PaymentsLinkedInvoices";
534 $this->import_icon[$r] = $this->picto;
535 $this->import_entities_array[$r] = array();
536 $this->import_tables_array[$r] = array(
'pf' => MAIN_DB_PREFIX.
'paiement_facture');
537 $this->import_fields_array[$r] = array(
538 'pf.fk_paiement' =>
'PaymentRef*',
539 'pf.fk_facture' =>
'InvoiceRef*',
540 'pf.amount' =>
'PaymentAmount*'
543 $this->import_fields_array[$r][
'pf.multicurrency_code'] =
'Currency';
544 $this->import_fields_array[$r][
'pf.multicurrency_tx'] =
'CurrencyRate';
545 $this->import_fields_array[$r][
'pf.multicurrency_amount'] =
'MulticurrencyAmountTTC';
547 $this->import_regex_array[$r] = array();
549 $this->import_regex_array[$r][
'pf.multicurrency_code'] =
'code@'.MAIN_DB_PREFIX.
'multicurrency';
551 $import_sample = array(
552 'pf.fk_paiement' =>
'(PROV0001)',
553 'pf.fk_facture' =>
'(PROV0001)',
557 $import_sample[
'pf.multicurrency_code'] =
'EUR';
558 $import_sample[
'pf.multicurrency_tx'] =
'1';
559 $import_sample[
'pf.multicurrency_amount'] =
'121';
561 $this->import_examplevalues_array[$r] = $import_sample;
562 $this->import_updatekeys_array[$r] = array(
563 'pf.rowid' =>
'Row Id',
564 'pf.fk_paiement' =>
'PaymentRef',
565 'pf.fk_facture' =>
'InvoiceRef'
567 $this->import_convertvalue_array[$r] = array(
568 'pf.fk_paiement' => array(
569 'rule' =>
'fetchidfromref',
570 'file' =>
'/compta/paiement/class/paiement.class.php',
571 'class' =>
'Paiement',
573 'element' =>
'payment'
575 'pf.fk_facture' => array(
576 'rule' =>
'fetchidfromref',
577 'file' =>
'/compta/facture/class/facture.class.php',
578 'class' =>
'Facture',
580 'element' =>
'facture'
587 $uselocaltax1 = (is_object(
$mysoc) &&
$mysoc->localtax1_assuj) ?
$mysoc->localtax1_assuj : 0;
588 $uselocaltax2 = (is_object(
$mysoc) &&
$mysoc->localtax2_assuj) ?
$mysoc->localtax2_assuj : 0;
592 $langs->loadLangs(array(
"suppliers",
"multicurrency",
"bills"));
594 $uselocaltax1 =
$mysoc->localtax1_assuj ?? 0;
595 $uselocaltax2 =
$mysoc->localtax2_assuj ?? 0;
597 $alias_product_perentity = !
getDolGlobalString(
'MAIN_PRODUCT_PERENTITY_SHARED') ?
"p" :
"ppe";
600 $this->export_code[$r] = $this->rights_class.
'_'.$r;
601 $this->export_label[$r] =
'CustomersInvoicesAndInvoiceLines';
602 $this->export_icon[$r] =
'invoice';
603 $this->export_permission[$r] = array(array(
"facture",
"facture",
"export",
"other"));
605 $this->export_fields_array[$r] = array(
606 's.rowid' =>
"IdCompany",
's.nom' =>
'CompanyName',
's.name_alias' =>
'AliasNameShort',
'ps.nom' =>
'ParentCompany',
's.code_client' =>
'CustomerCode',
's.address' =>
'Address',
's.zip' =>
'Zip',
's.town' =>
'Town',
'c.code' =>
'CountryCode',
'cd.nom' =>
'State',
607 's.phone' =>
'Phone',
608 's.siren' =>
'ProfId1',
's.siret' =>
'ProfId2',
's.ape' =>
'ProfId3',
's.idprof4' =>
'ProfId4',
609 's.code_compta' =>
'CustomerAccountancyCode',
610 's.code_compta_fournisseur' =>
'SupplierAccountancyCode',
611 's.tva_intra' =>
'VATIntra',
612 't.libelle' =>
"ThirdPartyType",
613 'f.rowid' =>
"InvoiceId",
'f.ref' =>
"InvoiceRef",
'f.ref_client' =>
'RefCustomer',
'f.fk_facture_source' =>
'SourceInvoiceId',
614 'f.type' =>
"Type",
'f.datec' =>
"InvoiceDateCreation",
'f.datef' =>
"DateInvoice",
'f.date_lim_reglement' =>
"DateDue",
615 'f.fk_cond_reglement' =>
'IdPaymentTerm',
'f.fk_mode_reglement' =>
'IdPaymentMode',
616 'f.total_ht' =>
"TotalHT",
'f.total_ttc' =>
"TotalTTC",
'f.total_tva' =>
"TotalVAT",
617 'f.localtax1' =>
"TotalLT1",
'f.localtax2' =>
"TotalLT2",
618 'f.paye' =>
"InvoicePaidCompletely",
'f.fk_statut' =>
'InvoiceStatus',
'f.close_code' =>
'EarlyClosingReason',
'f.close_note' =>
'EarlyClosingComment',
619 'none.rest' =>
'Rest',
620 'f.note_private' =>
"NotePrivate",
'f.note_public' =>
"NotePublic"
622 if (!$uselocaltax1) {
623 unset($this->export_fields_array[$r][
'f.localtax1']);
625 if (!$uselocaltax2) {
626 unset($this->export_fields_array[$r][
'f.localtax2']);
631 $this->export_fields_array[$r][
'f.multicurrency_code'] =
'Currency';
632 $this->export_fields_array[$r][
'f.multicurrency_tx'] =
'CurrencyRate';
633 $this->export_fields_array[$r][
'f.multicurrency_total_ht'] =
'MulticurrencyAmountHT';
634 $this->export_fields_array[$r][
'f.multicurrency_total_tva'] =
'MulticurrencyAmountVAT';
635 $this->export_fields_array[$r][
'f.multicurrency_total_ttc'] =
'MulticurrencyAmountTTC';
639 $this->export_fields_array[$r][
'f.module_source'] =
'Module';
640 $this->export_fields_array[$r][
'f.pos_source'] =
'POSTerminal';
642 $this->export_fields_array[$r] += array(
643 'f.fk_user_author' =>
'CreatedById',
'uc.login' =>
'CreatedByLogin',
644 'f.fk_user_valid' =>
'ValidatedById',
'uv.login' =>
'ValidatedByLogin',
645 'pj.ref' =>
'ProjectRef',
'pj.title' =>
'ProjectLabel'
649 $nbofallowedentities = count(explode(
',',
getEntity(
'invoice')));
650 if (
isModEnabled(
'multicompany') && $nbofallowedentities > 1) {
651 $this->export_fields_array[$r][
'f.entity'] =
'Entity';
654 $this->export_fields_array[$r] += array(
655 'fd.rowid' =>
'LineId',
'fd.description' =>
"LineDescription",
656 'fd.subprice' =>
"LineUnitPrice",
'fd.qty' =>
"LineQty",
657 'fd.tva_tx' =>
"LineVATRate",
658 'fd.total_ht' =>
"LineTotalHT",
'fd.total_tva' =>
"LineTotalVAT",
'fd.total_ttc' =>
"LineTotalTTC",
659 'fd.localtax1_tx' =>
"LineLT1Rate",
'fd.localtax1_type' =>
"LineLT1Type",
'fd.total_localtax1' =>
"LineTotalLT1",
660 'fd.localtax2_tx' =>
"LineLT2Rate",
'fd.localtax2_type' =>
"LineLT2Type",
'fd.total_localtax2' =>
"LineTotalLT2",
661 'fd.buy_price_ht' =>
'BuyingPrice',
'fd.date_start' =>
"DateStart",
'fd.date_end' =>
"DateEnd",
'fd.special_code' =>
'SpecialCode',
662 'fd.product_type' =>
"TypeOfLineServiceOrProduct",
'fd.fk_product' =>
'ProductId',
'p.ref' =>
'ProductRef',
'p.label' =>
'ProductLabel',
663 $alias_product_perentity .
'.accountancy_code_sell' =>
'ProductAccountancySellCode',
664 'aa.account_number' =>
'AccountingAffectation'
666 if (!$uselocaltax1) {
667 unset($this->export_fields_array[$r][
'fd.localtax1_tx']);
668 unset($this->export_fields_array[$r][
'fd.localtax1_type']);
669 unset($this->export_fields_array[$r][
'fd.total_localtax1']);
671 if (!$uselocaltax2) {
672 unset($this->export_fields_array[$r][
'fd.localtax2_tx']);
673 unset($this->export_fields_array[$r][
'fd.localtax2_type']);
674 unset($this->export_fields_array[$r][
'fd.total_localtax2']);
677 $this->export_TypeFields_array[$r] = array(
678 's.rowid' =>
'Numeric',
's.nom' =>
'Text',
's.name_alias' =>
'Text',
'ps.nom' =>
'Text',
's.code_client' =>
'Text',
's.address' =>
'Text',
's.zip' =>
'Text',
's.town' =>
'Text',
'c.code' =>
'Text',
'cd.nom' =>
'Text',
's.phone' =>
'Text',
's.siren' =>
'Text',
679 's.siret' =>
'Text',
's.ape' =>
'Text',
's.idprof4' =>
'Text',
's.code_compta' =>
'Text',
's.code_compta_fournisseur' =>
'Text',
's.tva_intra' =>
'Text',
680 't.libelle' =>
"Text",
681 'f.rowid' =>
'Numeric',
'f.ref' =>
"Text",
'f.ref_client' =>
'Text',
'f.fk_facture_source' =>
'Numeric',
'f.type' =>
"Numeric",
'f.datec' =>
"Date",
'f.datef' =>
"Date",
'f.date_lim_reglement' =>
"Date",
682 'f.fk_cond_reglement' =>
'Numeric',
'f.fk_mode_reglement' =>
'Numeric',
683 'f.total_ht' =>
"Numeric",
'f.total_ttc' =>
"Numeric",
'f.total_tva' =>
"Numeric",
'f.localtax1' =>
'Numeric',
'f.localtax2' =>
'Numeric',
'f.paye' =>
"Boolean",
'f.fk_statut' =>
'Numeric',
'f.close_code' =>
'Text',
'f.close_note' =>
'Text',
684 'none.rest' =>
"NumericCompute",
685 'f.note_private' =>
"Text",
'f.note_public' =>
"Text",
686 'f.module_source' =>
'Text',
687 'f.pos_source' =>
'Text',
688 'f.entity' =>
'List:entity:label:rowid',
689 'f.fk_user_author' =>
'Numeric',
'uc.login' =>
'Text',
'f.fk_user_valid' =>
'Numeric',
'uv.login' =>
'Text',
690 'pj.ref' =>
'Text',
'pj.title' =>
'Text',
'fd.rowid' =>
'Numeric',
'fd.description' =>
"Text",
'fd.subprice' =>
"Numeric",
'fd.tva_tx' =>
"Numeric",
691 'fd.qty' =>
"Numeric",
'fd.buy_price_ht' =>
"Numeric",
'fd.date_start' =>
"Date",
'fd.date_end' =>
"Date",
692 'fd.total_ht' =>
"Numeric",
'fd.total_tva' =>
"Numeric",
'fd.total_ttc' =>
"Numeric",
'fd.total_localtax1' =>
"Numeric",
'fd.total_localtax2' =>
"Numeric",
693 'fd.localtax1_tx' =>
'Numeric',
'fd.localtax2_tx' =>
'Numeric',
'fd.localtax1_type' =>
'Numeric',
'fd.localtax2_type' =>
'Numeric',
694 'fd.special_code' =>
'Numeric',
'fd.product_type' =>
"Numeric",
'fd.fk_product' =>
'List:product:label',
'p.ref' =>
'Text',
'p.label' =>
'Text',
695 $alias_product_perentity .
'.accountancy_code_sell' =>
'Text',
696 'aa.account_number' =>
'Text',
697 'f.multicurrency_code' =>
'Text',
698 'f.multicurrency_tx' =>
'Number',
'f.multicurrency_total_ht' =>
'Number',
'f.multicurrency_total_tva' =>
'Number',
'f.multicurrency_total_ttc' =>
'Number'
700 $this->export_entities_array[$r] = array(
701 's.rowid' =>
"company",
's.nom' =>
'company',
's.name_alias' =>
'company',
'ps.nom' =>
'company',
's.code_client' =>
'company',
's.address' =>
'company',
's.zip' =>
'company',
's.town' =>
'company',
'c.code' =>
'company',
'cd.nom' =>
'company',
's.phone' =>
'company',
702 's.siren' =>
'company',
's.siret' =>
'company',
's.ape' =>
'company',
's.idprof4' =>
'company',
's.code_compta' =>
'company',
's.code_compta_fournisseur' =>
'company',
's.tva_intra' =>
'company',
703 't.libelle' =>
'company',
704 'pj.ref' =>
'project',
'pj.title' =>
'project',
'fd.rowid' =>
'invoice_line',
'fd.description' =>
"invoice_line",
705 'fd.subprice' =>
"invoice_line",
'fd.buy_price_ht' =>
'invoice_line',
706 'fd.total_ht' =>
"invoice_line",
'fd.total_tva' =>
"invoice_line",
'fd.total_ttc' =>
"invoice_line",
'fd.total_localtax1' =>
"invoice_line",
'fd.total_localtax2' =>
"invoice_line",
707 'fd.tva_tx' =>
"invoice_line",
'fd.localtax1_tx' =>
"invoice_line",
'fd.localtax2_tx' =>
"invoice_line",
'fd.localtax1_type' =>
"invoice_line",
'fd.localtax2_type' =>
"invoice_line",
708 'fd.qty' =>
"invoice_line",
'fd.date_start' =>
"invoice_line",
'fd.date_end' =>
"invoice_line",
'fd.special_code' =>
'invoice_line',
709 'fd.product_type' =>
'invoice_line',
'fd.fk_product' =>
'product',
'p.ref' =>
'product',
'p.label' =>
'product', $alias_product_perentity .
'.accountancy_code_sell' =>
'product',
710 'f.fk_user_author' =>
'user',
'uc.login' =>
'user',
'f.fk_user_valid' =>
'user',
'uv.login' =>
'user',
711 'aa.account_number' =>
"invoice_line",
713 $this->export_help_array[$r] = array(
'fd.buy_price_ht' =>
'CostPriceUsage');
714 $this->export_special_array[$r] = array(
'none.rest' =>
'getRemainToPay');
715 $this->export_dependencies_array[$r] = array(
'invoice_line' =>
'fd.rowid',
'product' =>
'fd.rowid',
'none.rest' => array(
'f.rowid',
'f.total_ttc',
'f.close_code'));
716 $keyforselect =
'facture';
717 $keyforelement =
'invoice';
718 $keyforaliasextra =
'extra';
719 include DOL_DOCUMENT_ROOT.
'/core/extrafieldsinexport.inc.php';
720 $keyforselect =
'facturedet';
721 $keyforelement =
'invoice_line';
722 $keyforaliasextra =
'extra2';
723 include DOL_DOCUMENT_ROOT.
'/core/extrafieldsinexport.inc.php';
724 $keyforselect =
'product';
725 $keyforelement =
'product';
726 $keyforaliasextra =
'extra3';
727 include DOL_DOCUMENT_ROOT.
'/core/extrafieldsinexport.inc.php';
728 $keyforselect =
'societe';
729 $keyforelement =
'company';
730 $keyforaliasextra =
'extra4';
731 include DOL_DOCUMENT_ROOT.
'/core/extrafieldsinexport.inc.php';
732 $this->export_sql_start[$r] =
'SELECT DISTINCT ';
733 $this->export_sql_end[$r] =
' FROM '.MAIN_DB_PREFIX.
'societe as s';
734 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'societe_extrafields as extra4 ON s.rowid = extra4.fk_object';
735 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'societe as ps ON ps.rowid = s.parent';
736 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_typent as t ON s.fk_typent = t.id';
737 if (!empty($user) && !$user->hasRight(
'societe',
'client',
'voir')) {
738 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'societe_commerciaux as sc ON sc.fk_soc = s.rowid';
740 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_country as c on s.fk_pays = c.rowid';
741 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_departements as cd on s.fk_departement = cd.rowid,';
742 $this->export_sql_end[$r] .=
' '.MAIN_DB_PREFIX.
'facture as f';
743 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'projet as pj ON f.fk_projet = pj.rowid';
744 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'user as uc ON f.fk_user_author = uc.rowid';
745 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'user as uv ON f.fk_user_valid = uv.rowid';
746 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'facture_extrafields as extra ON f.rowid = extra.fk_object';
747 $this->export_sql_end[$r] .=
' , '.MAIN_DB_PREFIX.
'facturedet as fd';
748 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'facturedet_extrafields as extra2 on fd.rowid = extra2.fk_object';
749 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'product as p on (fd.fk_product = p.rowid)';
751 $this->export_sql_end[$r] .=
" LEFT JOIN " . MAIN_DB_PREFIX .
"product_perentity as ppe ON ppe.fk_product = p.rowid AND ppe.entity = " . ((int)
$conf->entity);
753 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'product_extrafields as extra3 on p.rowid = extra3.fk_object';
754 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'accounting_account as aa on fd.fk_code_ventilation = aa.rowid';
755 $this->export_sql_end[$r] .=
' WHERE f.fk_soc = s.rowid AND f.rowid = fd.fk_facture';
756 $this->export_sql_end[$r] .=
' AND f.entity IN ('.getEntity(
'invoice').
')';
757 if (!empty($user) && !$user->hasRight(
'societe',
'client',
'voir')) {
758 $this->export_sql_end[$r] .=
' AND sc.fk_user = '.(empty($user) ? 0 : ((int) $user->id));
763 $this->export_code[$r] = $this->rights_class.
'_'.$r;
764 $this->export_label[$r] =
'CustomersInvoicesAndPayments';
765 $this->export_icon[$r] =
'invoice';
766 $this->export_permission[$r] = array(array(
"facture",
"facture",
"export"));
767 $this->export_fields_array[$r] = array(
768 's.rowid' =>
"IdCompany",
's.nom' =>
'CompanyName',
's.name_alias' =>
'AliasNameShort',
's.code_client' =>
'CustomerCode',
's.address' =>
'Address',
's.zip' =>
'Zip',
's.town' =>
'Town',
'c.code' =>
'CountryCode',
'cd.nom' =>
'State',
769 's.phone' =>
'Phone',
770 's.siren' =>
'ProfId1',
's.siret' =>
'ProfId2',
's.ape' =>
'ProfId3',
's.idprof4' =>
'ProfId4',
's.code_compta' =>
'CustomerAccountancyCode',
771 's.code_compta_fournisseur' =>
'SupplierAccountancyCode',
's.tva_intra' =>
'VATIntra',
772 'f.rowid' =>
"InvoiceId",
'f.ref' =>
"InvoiceRef",
'f.ref_client' =>
'RefCustomer',
'f.fk_facture_source' =>
'SourceInvoiceId',
773 'f.type' =>
"Type",
'f.datec' =>
"InvoiceDateCreation",
'f.datef' =>
"DateInvoice",
'f.date_lim_reglement' =>
"DateDue",
774 'f.fk_cond_reglement' =>
'IdPaymentTerm',
'f.fk_mode_reglement' =>
'IdPaymentMode',
775 'f.total_ht' =>
"TotalHT",
'f.total_ttc' =>
"TotalTTC",
'f.total_tva' =>
"TotalVAT",
'f.localtax1' =>
'LT1',
'f.localtax2' =>
'LT2',
'f.paye' =>
"InvoicePaidCompletely",
'f.fk_statut' =>
'InvoiceStatus',
'f.close_code' =>
'EarlyClosingReason',
'f.close_note' =>
'EarlyClosingComment',
776 'none.rest' =>
'Rest',
777 'f.note_private' =>
"NotePrivate",
'f.note_public' =>
"NotePublic",
'f.fk_user_author' =>
'CreatedById',
'uc.login' =>
'CreatedByLogin',
778 'f.fk_user_valid' =>
'ValidatedById',
'uv.login' =>
'ValidatedByLogin',
'pj.ref' =>
'ProjectRef',
'pj.title' =>
'ProjectLabel',
'p.rowid' =>
'PaymentId',
'p.ref' =>
'PaymentRef',
779 'p.amount' =>
'AmountPayment',
'pf.amount' =>
'AmountPaymentDistributedOnInvoice',
'p.datep' =>
'DatePayment',
'p.num_paiement' =>
'PaymentNumber',
780 'pt.code' =>
'CodePaymentMode',
'pt.libelle' =>
'LabelPaymentMode',
'p.note' =>
'PaymentNote',
'p.fk_bank' =>
'IdTransaction',
'ba.ref' =>
'AccountRef'
782 if (!$uselocaltax1) {
783 unset($this->export_fields_array[$r][
'f.localtax1']);
785 if (!$uselocaltax2) {
786 unset($this->export_fields_array[$r][
'f.localtax2']);
789 $this->export_help_array[$r] = array(
'f.paye' =>
'InvoicePaidCompletelyHelp');
791 $this->export_fields_array[$r][
'f.multicurrency_code'] =
'Currency';
792 $this->export_fields_array[$r][
'f.multicurrency_tx'] =
'CurrencyRate';
793 $this->export_fields_array[$r][
'f.multicurrency_total_ht'] =
'MulticurrencyAmountHT';
794 $this->export_fields_array[$r][
'f.multicurrency_total_tva'] =
'MulticurrencyAmountVAT';
795 $this->export_fields_array[$r][
'f.multicurrency_total_ttc'] =
'MulticurrencyAmountTTC';
796 $this->export_examplevalues_array[$r][
'f.multicurrency_code'] =
'EUR';
799 $this->export_fields_array[$r][
'f.module_source'] =
'POSModule';
800 $this->export_fields_array[$r][
'f.pos_source'] =
'POSTerminal';
802 $this->export_TypeFields_array[$r] = array(
803 's.rowid' =>
'Numeric',
's.nom' =>
'Text',
's.name_alias' =>
'Text',
's.code_client' =>
'Text',
's.address' =>
'Text',
's.zip' =>
'Text',
's.town' =>
'Text',
'c.code' =>
'Text',
'cd.nom' =>
'Text',
's.phone' =>
'Text',
's.siren' =>
'Text',
804 's.siret' =>
'Text',
's.ape' =>
'Text',
's.idprof4' =>
'Text',
's.code_compta' =>
'Text',
's.code_compta_fournisseur' =>
'Text',
's.tva_intra' =>
'Text',
805 'f.rowid' =>
"Numeric",
'f.ref' =>
"Text",
'f.ref_client' =>
'Text',
'f.fk_facture_source' =>
'Numeric',
'f.type' =>
"Numeric",
'f.datec' =>
"Date",
'f.datef' =>
"Date",
'f.date_lim_reglement' =>
"Date",
806 'f.fk_cond_reglement' =>
'Numeric',
'f.fk_mode_reglement' =>
'Numeric',
807 'f.total_ht' =>
"Numeric",
'f.total_ttc' =>
"Numeric",
'f.total_tva' =>
"Numeric",
'f.localtax1' =>
'Numeric',
'f.localtax2' =>
'Numeric',
'f.paye' =>
"Boolean",
'f.fk_statut' =>
'Status',
'f.close_code' =>
'Text',
'f.close_note' =>
'Text',
808 'none.rest' =>
'NumericCompute',
809 'f.note_private' =>
"Text",
'f.note_public' =>
"Text",
'f.fk_user_author' =>
'Numeric',
'uc.login' =>
'Text',
'f.fk_user_valid' =>
'Numeric',
'uv.login' =>
'Text',
810 'pj.ref' =>
'Text',
'pj.title' =>
'Text',
'p.amount' =>
'Numeric',
'pf.amount' =>
'Numeric',
'p.rowid' =>
'Numeric',
'p.ref' =>
'Text',
'p.title' =>
'Text',
'p.datep' =>
'Date',
'p.num_paiement' =>
'Numeric',
811 'p.fk_bank' =>
'Numeric',
'p.note' =>
'Text',
'pt.code' =>
'Text',
'pt.libelle' =>
'Text',
'ba.ref' =>
'Text'
814 $this->export_fields_array[$r][
'f.module_source'] =
'POSModule';
815 $this->export_fields_array[$r][
'f.pos_source'] =
'POSTerminal';
817 $this->export_entities_array[$r] = array(
818 's.rowid' =>
"company",
's.nom' =>
'company',
's.name_alias' =>
'company',
's.code_client' =>
'company',
's.address' =>
'company',
's.zip' =>
'company',
's.town' =>
'company',
'c.code' =>
'company',
'cd.nom' =>
'company',
's.phone' =>
'company',
819 's.siren' =>
'company',
's.siret' =>
'company',
's.ape' =>
'company',
's.idprof4' =>
'company',
's.code_compta' =>
'company',
's.code_compta_fournisseur' =>
'company',
820 's.tva_intra' =>
'company',
'pj.ref' =>
'project',
'pj.title' =>
'project',
'p.rowid' =>
'payment',
'p.ref' =>
'payment',
'p.amount' =>
'payment',
'pf.amount' =>
'payment',
'p.datep' =>
'payment',
821 'p.num_paiement' =>
'payment',
'pt.code' =>
'payment',
'pt.libelle' =>
'payment',
'p.note' =>
'payment',
'f.fk_user_author' =>
'user',
'uc.login' =>
'user',
822 'f.fk_user_valid' =>
'user',
'uv.login' =>
'user',
'p.fk_bank' =>
'account',
'ba.ref' =>
'account'
824 $this->export_special_array[$r] = array(
'none.rest' =>
'getRemainToPay');
825 $this->export_dependencies_array[$r] = array(
'payment' =>
'p.rowid',
'none.rest' => array(
'f.rowid',
'f.total_ttc',
'f.close_code'));
826 $keyforselect =
'facture';
827 $keyforelement =
'invoice';
828 $keyforaliasextra =
'extra';
829 include DOL_DOCUMENT_ROOT.
'/core/extrafieldsinexport.inc.php';
830 $this->export_sql_start[$r] =
'SELECT DISTINCT ';
831 $this->export_sql_end[$r] =
' FROM '.MAIN_DB_PREFIX.
'societe as s';
832 if (!empty($user) && !$user->hasRight(
'societe',
'client',
'voir')) {
833 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'societe_commerciaux as sc ON sc.fk_soc = s.rowid';
835 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_country as c on s.fk_pays = c.rowid';
836 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_departements as cd on s.fk_departement = cd.rowid,';
837 $this->export_sql_end[$r] .=
' '.MAIN_DB_PREFIX.
'facture as f';
838 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'projet as pj ON f.fk_projet = pj.rowid';
839 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'user as uc ON f.fk_user_author = uc.rowid';
840 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'user as uv ON f.fk_user_valid = uv.rowid';
841 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'facture_extrafields as extra ON f.rowid = extra.fk_object';
842 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'paiement_facture as pf ON pf.fk_facture = f.rowid';
843 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'paiement as p ON pf.fk_paiement = p.rowid';
844 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_paiement as pt ON pt.id = p.fk_paiement';
845 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'bank as b ON b.rowid = p.fk_bank';
846 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'bank_account as ba ON ba.rowid = b.fk_account';
847 $this->export_sql_end[$r] .=
' WHERE f.fk_soc = s.rowid';
848 $this->export_sql_end[$r] .=
' AND f.entity IN ('.getEntity(
'invoice').
')';
849 if (!empty($user) && !$user->hasRight(
'societe',
'client',
'voir')) {
850 $this->export_sql_end[$r] .=
' AND sc.fk_user = '.(empty($user) ? 0 : ((int) $user->id));