27require_once NOALYSS_INCLUDE.
'/lib/user_common.php';
28require_once NOALYSS_INCLUDE.
'/lib/ac_common.php';
39 parent::__construct($p_cn, $p_init);
40 $this->ledger_type =
'VEN';
53 throw new Exception (
"Array empty");
63 if (isset($mt) && $this->
db->count_sql(
'select jr_mt from jrn where jr_mt=$1', array($mt)) != 0)
64 throw new Exception(_(
'Double Encodage'), 5);
68 throw new Exception(_(
'Accès interdit'), 20);
72 throw new Exception(_(
'Vous n\'avez pas donné de client'), 11);
76 throw new Exception(_(
'Date invalide'), 2);
88 throw new Exception(_(
'Date et periode ne correspondent pas'), 6);
97 throw new Exception(_(
'Periode fermee'), 6);
105 throw new Exception(_(
'Vous utilisez le mode strict la dernière operation est date du ')
106 . $last_date . _(
' vous ne pouvez pas encoder à une date antérieure'), 13);
111 $fiche->get_by_qcode($e_client);
113 throw new Exception(_(
'La fiche ') . $e_client . _(
'n\'a pas de poste comptable'), 8);
118 if (strpos($sposte,
',') != 0) {
119 $array = explode(
',', $sposte);
122 $poste_val = $sposte;
128 if (
$poste->load() ==
false) {
129 throw new Exception(_(
'Pour la fiche ') . $e_client . _(
' le poste comptable [') .
$poste->id . _(
'] n\'existe pas'), 9);
134 $fiche->get_by_qcode($e_client,
'deb');
136 throw new Exception(_(
'La fiche ') . $e_client . _(
'n\'est pas accessible à ce journal'), 10);
143 for (
$i = 0;
$i < $nb_item;
$i++) {
147 if (
isNumber(${
'e_march' .
$i .
'_price'}) == 0)
148 throw new Exception(_(
'La fiche ') . ${
'e_march' .
$i} . _(
'a un montant invalide [') . ${
'e_march' .
$i} .
']', 6);
150 throw new Exception(_(
'La fiche ') . ${
'e_march' .
$i} . _(
'a une quantité invalide [') . ${
'e_quant' .
$i} .
']', 7);
153 $fiche->get_by_qcode(${
'e_march' .
$i});
155 throw new Exception(_(
'La fiche ') . ${
'e_march' .
$i} . _(
'n\'a pas de poste comptable'), 8);
159 if (
isNumber(${
'e_march' .
$i .
'_tva_id'}) == 0)
160 throw new Exception(_(
'La fiche ') . ${
'e_march' .
$i} . _(
'a un code tva invalide') .
' [' . ${
'e_march' .
$i .
'_tva_id'} .
']', 13);
162 $tva_rate->set_parameter(
'id', ${
'e_march' .
$i .
'_tva_id'});
164 throw new Exception(_(
'La fiche ') . ${
'e_march' .
$i} . _(
'a un code tva invalide') .
' [' . ${
'e_march' .
$i .
'_tva_id'} .
']', 13);
173 $this->
db->get_value(
'select count(*) from tmp_pcmn where pcm_val=$1', array(
$a_poste[1])) == 0)
174 throw new Exception(_(
" La TVA " .
$tva_rate->tva_label .
" utilise des postes comptables inexistants"));
180 if (strpos($sposte,
',') != 0) {
181 $array = explode(
',', $sposte);
184 $poste_val = $sposte;
187 if (
$poste->load() ==
false) {
188 throw new Exception(_(
'Pour la fiche ') . ${
'e_march' .
$i} . _(
' le poste comptable [') .
$poste->id . _(
'n\'existe pas'), 9);
192 $fiche->get_by_qcode(${
'e_march' .
$i});
194 throw new Exception(_(
'La fiche ') . ${
'e_march' .
$i} . _(
'n\'est pas accessible à ce journal'), 10);
196 if ( ${
"e_quant".$i} != 0 && trim(${
"e_quant".$i}) !=
"" ) {
$nb++;}
200 throw new Exception(_(
'Il n\'y a aucune marchandise'), 12);
217 if ( isset ($mp_date) && trim ($mp_date) !=
"" &&
isDate($mp_date) ==
null) {
218 throw new Exception(_(
'Date de paiement invalide'),13);
223 if ( isset ($mp_date) && trim ($mp_date) !=
"" &&
isDate($mp_date) == $mp_date ) {
228 throw new Exception(_(
"Période fermée").
" $mp_date ");
233 if ( isset ($e_ech) && trim ($e_ech)!=
"" &&
isDate($e_ech) ==
null )
235 throw new Exception(_(
'Date échéance invalide'),14);
239 if (
isNumber($p_currency_rate) == 0 || $p_currency_rate <=0 ) {
240 throw new Exception(_(
'Taux devise invalide'),15);
265 $group = $this->
db->get_next_seq(
"s_oa_group");
266 $seq = $this->
db->get_next_seq(
's_grpt');
269 $this->
internal = $internal;
280 $cust->get_by_qcode($e_client);
285 if (strpos($sposte,
',') != 0) {
286 $array = explode(
',', $sposte);
308 for (
$i = 0;
$i < $nb_item;
$i++) {
310 if ( empty(${
'e_march'.$i}) || empty(${
'e_quant'.$i}) )
continue;
314 $fiche->get_by_qcode(${
"e_march" .
$i});
315 $amount_currency = bcmul(${
'e_march' .
$i .
'_price'}, ${
'e_quant' .
$i});
318 $amount=bcdiv($amount_currency,$p_currency_rate);
322 if ( DEBUGNOALYSS > 1 ) { echo __LINE__.
" tot_amount $tot_amount<br>";}
324 $acc_operation->date =
$e_date;
328 if (strpos($sposte,
',') != 0) {
329 $array = explode(
',', $sposte);
332 $poste_val = $sposte;
335 $acc_operation->poste = $poste_val;
336 $acc_operation->amount =
$amount;
337 $acc_operation->grpt =
$seq;
338 $acc_operation->jrn =
$p_jrn;
339 $acc_operation->type =
'c';
340 $acc_operation->periode = $tperiode;
343 $acc_operation->desc=strip_tags(${
"e_march".$i.
"_label"});
347 $acc_operation->desc=
null;
350 $acc_operation->qcode = ${
"e_march" .
$i};
353 $tot_debit=round(bcadd($tot_debit, abs(
$amount)),2);
356 $j_id = $acc_operation->insert_jrnx();
361 $idx_tva = trim(${
'e_march' .
$i .
'_tva_id'});
362 $tva_item_currency = ${
'e_march' .
$i .
'_tva_amount'};
363 $oTva->set_parameter(
"id", $idx_tva);
366 if (trim($tva_item_currency) ==
'' || ${
'e_march'.$i.
'_tva_amount'} == 0) {
370 $tva_item_currency = bcmul(
$amount,
$l->get_parameter(
'rate'));
371 $tva_item=round($tva_item_currency,2);
373 $tva_item=bcdiv($tva_item_currency,$p_currency_rate);
374 $tva_item=round($tva_item,2);
375 if (isset($tva[$idx_tva]))
377 $tva[$idx_tva]=bcadd($tva_item,$tva[$idx_tva]);
378 $tva[$idx_tva]=round($tva[$idx_tva],2);
382 $tva[$idx_tva]=$tva_item;
384 if ($oTva->get_parameter(
"both_side") == 0) {
385 $tot_tva = bcadd($tva_item, $tot_tva);
386 $tot_tva = round($tot_tva, 2);
389 $tva_item_currency = 0;
392 $tot_debit=round(bcadd($tot_debit, abs($n_both)),2);
401 $nNeg = (${
"e_quant" .
$i} < 0) ? -1 : 1;
407 $dir=(${
'e_quant'.$i} < 0 ) ?
'd':
'c';
415 $op->set_currency_rate($p_currency_rate);
416 $op->oa_group = $group;
423 if (empty( ${
'e_march' .
$i .
'_price'} ) ) ${
'e_march' .
$i .
'_price'} = 0;
424 if (empty( ${
'e_march' .
$i } ) ) ${
'e_march' .
$i } = 0;
425 if (empty( ${
'e_quant' .
$i } ) ) ${
'e_quant' .
$i } = 0;
427 $price_euro=bcdiv(${
'e_march'.$i.
'_price'}, $p_currency_rate);
431 $r = $this->
db->exec_sql(
"select insert_quant_sold ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10)", array(
null,
443 $tva_item_currency=0;
445 $r = $this->
db->exec_sql(
"select insert_quant_sold ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10) ", array(
null,
461 $operation_currency->oc_amount=$amount_currency;
462 $operation_currency->oc_vat_amount=$tva_item_currency;
463 $operation_currency->oc_price_unit=${
'e_march'.$i.
'_price'};
464 $operation_currency->j_id=
$j_id;
465 $operation_currency->insert();
466 $tot_amount_cur=round(bcadd($tot_amount_cur,$amount_currency,4),4);
467 $tot_amount_cur=round(bcadd($tot_amount_cur,$tva_item_currency,4),4);
472 $row=$this->
db->get_row(
"select ac_id,ac_label,ac_accounting
476 if ( ! empty (
$row )) {
480 $acc_operation->poste=
$row[
'ac_accounting'];
482 $acc_operation->grpt=
$seq;
483 $acc_operation->jrn=
$p_jrn;
484 $acc_operation->type=
'c';
485 $acc_operation->periode=$tperiode;
486 $acc_operation->desc=
$row[
'ac_label'];
488 $jrn_tax_sql->j_id=$acc_operation->insert_jrnx();
489 $jrn_tax_sql->ac_id=
$row[
'ac_id'];
490 $jrn_tax_sql->pcm_val=
$row[
'ac_accounting'];
491 $jrn_tax_sql->insert();
493 if (
$p_array[
'other_tax_amount'] < 0 ) {
497 $operation_currency->oc_amount=
$p_array[
'other_tax_amount'];
498 $operation_currency->oc_vat_amount=0;
499 $operation_currency->oc_price_unit=0;
500 $operation_currency->j_id=$jrn_tax_sql->j_id;
501 $operation_currency->insert();
509 $cust_amount = round($cust_amount,2);
510 if ( DEBUGNOALYSS > 1 ) {
511 echo __LINE__.
" cust_amount $cust_amount<br>";
512 echo __LINE__.
" tot_amount $tot_amount<br>";
513 echo __LINE__.
" tot_tva $tot_tva<br>";
518 $acc_operation->date =
$e_date;
519 $acc_operation->poste =
$poste;
520 $acc_operation->amount = $cust_amount;
521 $acc_operation->grpt =
$seq;
522 $acc_operation->jrn =
$p_jrn;
523 $acc_operation->type =
'd';
524 $acc_operation->periode = $tperiode;
525 $acc_operation->qcode = ${
"e_client"};
528 $tot_debit=bcadd($tot_debit, $cust_amount);
529 $tot_debit=round($tot_debit, 2);
531 $let_tiers = $acc_operation->insert_jrnx();
535 $operation_currency->oc_amount=$tot_amount_cur;
536 $operation_currency->oc_vat_amount=0;
537 $operation_currency->oc_price_unit=0;
538 $operation_currency->j_id=$let_tiers ;
539 $operation_currency->insert();
547 if ( DEBUGNOALYSS > 1 ) {
552 $oTva->set_parameter(
'id',
$i);
555 $poste_vat = $oTva->get_side(
'c');
559 $acc_operation->date =
$e_date;
560 $acc_operation->poste = $poste_vat;
561 $acc_operation->amount =
$value;
562 $acc_operation->grpt =
$seq;
563 $acc_operation->jrn =
$p_jrn;
564 $acc_operation->type =
'c';
565 $acc_operation->periode = $tperiode;
568 $tot_debit=bcadd($tot_debit, abs(
$value));
569 $tot_debit=round($tot_debit, 2);
571 $acc_operation->insert_jrnx();
572 if ( DEBUGNOALYSS > 1 ) {
573 echo __LINE__.
" tot_tva $tot_tva<br>";
577 if ($oTva->get_parameter(
"both_side") == 1) {
578 $poste_vat = $oTva->get_side(
'd');
581 $acc_operation->date =
$e_date;
582 $acc_operation->poste = $poste_vat;
583 $acc_operation->amount =
$value;
584 $acc_operation->grpt =
$seq;
585 $acc_operation->jrn =
$p_jrn;
586 $acc_operation->type =
'd';
587 $acc_operation->periode = $tperiode;
588 $acc_operation->insert_jrnx();
589 $tot_debit = bcadd($tot_debit,
$value);
590 $tot_debit = round($tot_debit, 2);
601 if ( DEBUGNOALYSS > 1 ) { echo __LINE__.
" tot_debit ".round($tot_debit,2).
"<br>"; }
603 $acc_operation->date =
$e_date;
604 $acc_operation->echeance = $e_ech;
605 $acc_operation->amount = abs(round($tot_debit, 2));
606 $acc_operation->desc = $e_comm;
607 $acc_operation->grpt =
$seq;
608 $acc_operation->jrn =
$p_jrn;
609 $acc_operation->periode = $tperiode;
610 $acc_operation->pj = $e_pj;
611 $acc_operation->mt = $mt;
612 $acc_operation->currency_id=$p_currency_code;
613 $acc_operation->currency_rate=$p_currency_rate;
614 $acc_operation->currency_rate_ref=$currency_rate_ref->get_rate();
616 if ( ! $this->
jr_id=$acc_operation->insert_jrn() ) {
617 throw new Exception (_(
"Erreur de balance"));
620 $this->pj = $acc_operation->set_pj();
629 $this->
db->exec_sql(
"update jrn set jr_internal=$1 where jr_grpt_id = $2" ,[$internal,
$seq]);
633 $this->
db->exec_sql(
'update quant_sold set qs_internal = $1
634 where j_id in (select j_id from jrnx where j_grpt=$2)'
635 , array($internal,
$seq));
638 if (isset($_FILES[
'pj'])) {
640 $this->
db->save_receipt(
$seq);
643 if (isset(
$_POST[
'gen_invoice'])) {
655 $pay_date=($mp_date==
"")?
$e_date:$mp_date;
663 $acseq = $this->
db->get_next_seq(
's_grpt');
664 $acjrn =
new Acc_Ledger($this->
db, $mp->get_parameter(
'ledger_target'));
665 $acinternal = $acjrn->compute_internal_code($acseq);
670 if ( $acjrn->get_type()==
'FIN') {
672 $acfiche=
new Fiche($this->
db,$acjrn->get_bank());
675 $fqcode = ${
'e_mp_qcode_' . $e_mp};
676 $acfiche =
new Fiche($this->
db);
677 $acfiche->get_by_qcode($fqcode);
682 $acc_pay->date = $pay_date;
686 if (strpos($sposte,
',') != 0) {
687 $array = explode(
',', $sposte);
690 $poste_val = $sposte;
693 $acompte_eur=bcdiv(
$acompte, $p_currency_rate);
695 $famount=bcsub($cust_amount,$acompte_eur);
696 $acc_pay->poste = $poste_val;
697 $acc_pay->qcode = $fqcode;
698 $acc_pay->amount = abs(round($famount, 2));
699 $acc_pay->desc =
null;
701 $acc_pay->grpt = $acseq;
702 $acc_pay->jrn = $mp->get_parameter(
'ledger_target');
703 $acc_pay->periode = $tperiode;
704 $acc_pay->type = ($famount >= 0) ?
'd' :
'c';
705 $let_pay=$acc_pay->insert_jrnx();
709 $acc_pay->date = $pay_date;
711 $acc_pay->qcode = $e_client;
712 $acc_pay->amount = abs(round($famount, 2));
713 $acc_pay->desc =
null;
714 $acc_pay->grpt = $acseq;
715 $acc_pay->jrn = $mp->get_parameter(
'ledger_target');
716 $acc_pay->periode = $tperiode;
717 $acc_pay->type = ($famount >= 0) ?
'c' :
'd';
718 $let_other = $acc_pay->insert_jrnx();
722 $operation_currency->oc_amount=bcsub($tot_amount_cur,
$acompte);
723 $operation_currency->oc_vat_amount=0;
724 $operation_currency->oc_price_unit=0;
725 $operation_currency->j_id=$let_other;
726 $operation_currency->insert();
730 $operation_currency->oc_amount=bcsub($tot_amount_cur,
$acompte);
731 $operation_currency->oc_vat_amount=0;
732 $operation_currency->oc_price_unit=0;
733 $operation_currency->j_id=$let_pay;
734 $operation_currency->insert();
737 $acc_pay->currency_id=$p_currency_code;
738 $acc_pay->currency_rate=$p_currency_rate;
739 $acc_pay->currency_rate_ref=$currency_rate_ref->get_rate();
744 $acjrn->grpt_id = $acseq;
745 $acc_pay->desc = (!isset($e_comm_paiement) ||
noalyss_strlentrim($e_comm_paiement) == 0) ? $e_comm : $e_comm_paiement;
746 $mp_jr_id = $acc_pay->insert_jrn();
747 $acjrn->update_internal_code($acinternal);
749 if ($acjrn->get_type()==
"ODS") {
750 $acc_pay->pj=$acjrn->guess_pj();
753 $r1 = $this->
get_id($internal);
754 $r2 = $this->
get_id($acinternal);
760 $oletter->insert_couple($let_tiers, $let_other);
764 $Res = $this->
db->exec_sql(
"update jrn set jr_rapt='paid' where jr_id=$1", array($r1));
768 $rec->set_jr_id($r1);
781 if (
$prop[
'jrn_def_type'] ==
'FIN') {
782 $ledger->insert_quant_fin($acfiche->id, $mp_jr_id, $cust->id, bcmul($famount, 1),$let_other);
788 if (isset(
$p_array[
'jrn_note_input']) && !empty(
$p_array[
'jrn_note_input'])) {
790 $acc_operation_note->setNote(
$p_array[
'jrn_note_input']);
791 $acc_operation_note->setOperation_id( $this->
jr_id);
792 $acc_operation_note->save();
794 }
catch (Exception
$e) {
796 echo
'<span class="error">' .
797 'Erreur dans l\'enregistrement ' .
798 __FILE__ .
':' . __LINE__ .
' ' .
800 echo
$e->getTraceAsString();
802 $this->
db->rollback();
803 throw new Exception (
$e);
833 $client =
new Fiche($this->
db);
834 $client->get_by_qcode($e_client,
true);
836 $client_name = $client->getName() .
842 $lPeriode->p_id = $period;
844 $lPeriode->find_periode(
$e_date);
848 $r .=
'<div id="summary_op1" >';
851 $jr_id=$this->
db->get_value(
'select jr_id from jrn where jr_internal=$1',array($this->
internal));
854 $r.=_(
'Détail opération ');
857 $r.=sprintf (
'<a class="line" style="display:inline" href="javascript:modifyOperation(%d,%d)">%s</a>',
865 $r.=
'<td>' . _(
'Numéro Pièce') .$span.
'</td><td>'.
hb($e_pj) .
'</td>';
869 if ( strcmp($this->pj,$e_pj) != 0 )
871 $r.=
'<td>' . _(
'Numéro Pièce') .$span.
'</td><td>'.
hb($this->pj) .
872 '<span class="notice"> '._(
'Attention numéro pièce existante, elle a du être adaptée').
'</span></td>';
874 $r.=
'<td>' . _(
'Numéro Pièce') .$span.
'</td><td>'.
hb($this->pj) .
'</td>';
879 $r.=
'<td> ' . _(
'Date') .
'</td><td> ' .
hb(
$e_date) .
'</td>';
882 $r.=
'<td>' . _(
'Echeance') .
'</td><td> ' .
hb($e_ech) .
'</td>';
885 $r.=
'<td> ' . _(
'Période Comptable') .
'</td><td> ' .hb(
$date_limit[
'p_start'] .
'-' .
$date_limit[
'p_end']) .
'</td>';
889 $r .=
'<div id="summary_op2">';
892 $r.=
'<td> ' . _(
'Journal') .
'</td><td> ' .
hb($this->
get_name()) .
'</td>';
895 $r.=
'<td> ' . _(
'Libellé') .
'</td><td> ' .
hb($e_comm) .
'</td>';
899 $r.=
'<td> ' . _(
'Client') .
'</td><td> ' .
hb($e_client .
':' . $client_name) .
'</td>';
902 $r.=
'<pre>'._(
'Note').
' '.
h(
$p_array[
'jrn_note_input']).
'</pre>';
904 $r.=
'<div style="float:none;clear:both">';
907 $r.=
'<h2>' . _(
'Détail articles vendus') .
'</h2>';
908 $r.=
'<p class="decale">';
909 $r.=
'<table class="result" >';
911 $r.=
"<th>" . _(
'Code') .
"</th>";
912 $r.=
"<th>" . _(
'Dénomination') .
"</th>";
913 $r.=
"<th style=\"text-align:right\">" . _(
'prix') .
"</th>";
914 $r.=
"<th style=\"text-align:right\">" . _(
'quantité') .
"</th>";
918 $r.=
"<th style=\"text-align:right\">" . _(
'tva') .
"</th>";
919 $r.=
'<th style="text-align:right"> ' . _(
'Montant TVA') .
'</th>';
920 $r.=
'<th style="text-align:right">' . _(
'Montant HTVA') .
'</th>';
921 $r.=
'<th style="text-align:right">' . _(
'Montant TVAC') .
'</th>';
923 $r.=
'<th style="text-align:right">' . _(
'Montant') .
'</th>';
928 $a_anc =
$anc->get_list();
931 $r.=
'<th colspan="' . $x .
'">' . _(
'Compt. Analytique') .
'</th>';
939 for (
$i = 0;
$i < $nb_item;
$i++) {
945 $fiche->get_by_qcode(${
"e_march" .
$i});
947 $fiche_name =
h(${
"e_march" .
$i .
"_label"});
952 $idx_tva = ${
"e_march" .
$i .
"_tva_id"};
954 $oTva->set_parameter(
'id', $idx_tva);
958 $amount = bcmul(${
"e_march" .
$i .
"_price"}, ${
'e_quant' .
$i});
961 $op->set_parameter(
'amount_vat_rate', $oTva->get_parameter(
'rate'));
963 $tva_computed =
$op->get_parameter(
'amount_vat');
964 $tva_item = ${
"e_march" .
$i .
"_tva_amount"};
965 if (isset($tva[$idx_tva]))
966 $tva[$idx_tva]=bcadd($tva[$idx_tva],$tva_item,2);
968 $tva[$idx_tva] = $tva_item;
969 $tot_tva = round(bcadd($tva_item, $tot_tva), 2);
975 $r.=${
"e_march" .
$i};
977 $r.=
'<TD style="border-bottom:1px dotted grey;">';
980 $r.=
'<td class="num">';
981 $r.=
nbm(${
"e_march" .
$i .
"_price"},4);
983 $r.=
'<td class="num">';
988 $r.=
'<td class="num">';
989 $r.=$oTva->get_parameter(
'label');
991 $both_side=$oTva->get_parameter(
"both_side");
994 if (bcsub($tva_item, $tva_computed) != 0 && ! ($tva_item == 0 && $both_side == 1)) {
995 $r.=
'<td style="background-color:red" class="num">';
997 $r.=
'<a href="#" class="error" style="display:inline" title="' . _(
"Attention Différence entre TVA calculée et donnée") .
'">'
998 .
nbm($tva_item) .
'<a>';
1000 $r.=
'<td class="num">';
1004 $r.=
'<td class="num">';
1007 $tot_row = bcadd($tva_item,
$amount);
1008 $r.=
td(
nbm($tot_row),
'class="num"');
1010 $r.=
'<td class="num">';
1021 $p_mode = ($p_summary ==
false) ? 1 : 0;
1034 $decalage=(
$g_parameter->MY_TVA_USE ==
'Y')?
'<td></td><td></td><td></td><td></td>':
'<td></td>';
1036 $tot_eur=round(bcdiv(
$tot, $p_currency_rate),2);
1038 $str_tot=_(
'Totaux');
1043 if ( $p_currency_code != 0 ) {
1045 $acc_currency->set_id($p_currency_code);
1050 $tot_tva=
nbm($tot_tva);
1054 <
tr class=
"highlight">
1071 $iso_code=$sql_currency->getp(
"cr_code_iso");
1072 if ($p_currency_code !=0) {
1075 <
tr class=
"highlight">
1084 {$rate} {$p_currency_rate}
1087 {$tot_eur} {$iso_code}
1095 $iso_code=$sql_currency->getp(
"cr_code_iso");
1098 <
tr class=
"highlight">
1113 <
tr class=
"highlight">
1121 {$rate} {$p_currency_rate}
1124 {$tot_eur} {$iso_code}
1132 $r.=
'<input type="button" class="button" value="' . _(
'Vérifiez Imputation Analytique') .
'" onClick="verify_ca(\'\');">';
1133 $r.=
'<div id="total_div_id" >';
1134 $r.=
'<h2>Totaux</h2>';
1135 $other_tax_label=
"";
1138 $other_tax_label=_(
"Autre taxe");
1144 $r.=
'<tr><td>Total HTVA</td>';
1147 $oTva->set_parameter(
'id',
$i);
1150 $r.=
'<tr><td> TVA ' . $oTva->get_parameter(
'label').
'</td>';
1153 $r.=
'<tr>'.td(_(
'Total TVA')).td(
hb($tot_tva),
'class="num"');
1154 if ( ! empty($other_tax_label) ) {
1158 $r.=
'<tr>'.td(_(
'Total TVAC')).td(
hb(
$tot),
'class="num"');
1161 if ( ! empty($other_tax_label) ) {
1165 $r.=
'<br>Total '.hb(
$tot);
1175 $mt = microtime(
true);
1193 $e_mp = (isset($e_mp)) ? $e_mp : 0;
1196 if ( isset(
$repo) ) {
1210 $fname =
new Fiche($this->
db);
1211 $fname->get_by_qcode(${
'e_mp_qcode_' . $e_mp});
1212 $r.=
'<h2>' .
"Payé par " . ${
'e_mp_qcode_' . $e_mp} .
1213 " le ".${
"mp_date"}.
1214 " " . $fname->getName() .
'</h2> ' .
'<p class="decale">' . _(
'Déduction acompte ') .
h(
$acompte) .
'</p>' .
1215 _(
'Libellé :') .
h($e_comm_paiement) ;
1220 for (
$i = 0;
$i < $nb_item;
$i++) {
1222 if (isset(${
"e_march" .
$i .
"_label"}))
1235 if ( $negative !=
"") {
1236 $r.=
span($negative,
'class="warning" ');
1249 $r =
'<div id="facturation_div_id" style="height:185px;height:10rem">';
1253 $file->setAlertOnSize(
true);
1254 $r.=
'<p class="decale">';
1255 $r.=_(
"Ajoutez une pièce justificative ");
1258 if ($this->
db->count_sql(
"select md_id,md_name from document_modele where md_affect='VEN' ") > 0) {
1261 $r.=_(
'ou générer une facture') .
' <input type="checkbox" name="gen_invoice" CHECKED>';
1264 $doc_gen->name =
"gen_doc";
1265 $doc_gen->value = $this->
db->make_array(
1266 "select md_id,md_name " .
1267 " from document_modele where md_affect='VEN' order by 2");
1268 $r.=$doc_gen->input() .
'<br>';
1272 $r.=_(
'Numero de bon de commande : ') .
$obj->input(
'bon_comm') .
'<br>';
1273 $r.=_(
'Communication ou autre information : ') .
$obj->input(
'other_info') .
'<br>';
1292 $http->set_array([]);
1301 $str_add_button_tiers =
"";
1305 $str_add_button_tiers = $this->
add_card(
"deb",
"e_client");
1310 list ($l_date_start, $l_date_end) =
$oPeriode->get_date_limit(
$g_user->get_periode());
1316 $e_ech = (isset($e_ech)) ? $e_ech :
"";
1317 $e_comm = (isset($e_comm)) ? $e_comm :
"";
1320 $r.=dossier::hidden();
1321 $f_legend = _(
'Client');
1323 $Echeance =
new IDate();
1324 $Echeance->setReadOnly(
false);
1326 $Echeance->tabindex = 2;
1328 $f_echeance = $Echeance->input(
'e_ech', $e_ech, _(
'Echéance') .
$label);
1329 $Date =
new IDate();
1330 $Date->setReadOnly(
false);
1332 $f_date = $Date->input(
"e_date", $op_date);
1338 $l_user_per =
$g_user->get_periode();
1341 $period =
new IPeriod(
"period");
1344 $period->value =
$def;
1345 $period->type =
OPEN;
1347 $l_form_per = $period->input();
1348 }
catch (Exception
$e) {
1349 if (
$e->getCode() == 1) {
1350 throw new Exception( _(
"Aucune période ouverte") );
1354 $f_periode =
'<td>' . _(
"Période comptable") .
"</td> <td> $label " . $l_form_per .
'</td>';
1359 $add_js =
"update_pj();";
1362 $add_js.=
'get_last_date();';
1364 $add_js.=
'update_name();';
1365 $add_js.=
'update_pay_method();';
1366 $add_js.=
'update_row("sold_item");';
1367 $add_js.=
'update_other_tax();';
1368 $add_js.=
'update_visibility_quantity();';
1372 throw new Exception(_(
'Pas de journal disponible'));
1374 $wLedger->javascript =
"onChange='update_predef(\"ven\",\"f\",\"".$_REQUEST[
'ac'].
"\");$add_js'";
1379 $Commentaire =
new IText();
1380 $Commentaire->table = 0;
1381 $Commentaire->setReadOnly(
false);
1382 $Commentaire->size = (empty($e_comm))?60:strlen($e_comm)+5;
1383 $Commentaire->size = ($Commentaire->size<60)?60:$Commentaire->size;
1384 $Commentaire->tabindex = 3;
1388 $f_desc = $Commentaire->input(
"e_comm", $e_comm) ;
1400 $pj->setReadOnly(
true);
1407 $pj->value = (isset($e_pj)) ? $e_pj : $default_pj;
1415 $e_client = ( isset($e_client) ) ? $e_client :
"";
1416 $e_client_label =
" ";
1421 $fClient =
new Fiche($this->
db);
1422 $fClient->get_by_qcode($e_client);
1423 $e_client_label = $fClient->strAttribut(
ATTR_DEF_NAME) .
' ' .
1431 $W1->name =
"e_client";
1433 $W1->value = $e_client;
1435 $W1->set_dblclick(
"fill_ipopcard(this);");
1436 $W1->set_attribute(
'ipopup',
'ipopcard');
1439 $W1->set_attribute(
'label',
'e_client_label');
1441 $W1->set_attribute(
'typecard',
'deb');
1444 $W1->set_callback(
'filter_card');
1445 $W1->set_function(
'fill_data');
1446 $W1->javascript = sprintf(
' onchange="fill_data_onchange(\'%s\');" ', $W1->name);
1447 $f_client_qcode = $W1->input();
1448 $client_label =
new ISpan();
1449 $client_label->table = 0;
1450 $f_client = $client_label->input(
"e_client_label", $e_client_label);
1451 $f_client_bt = $W1->search();
1456 $p_article = ( isset($nb_item)) ? $nb_item : $this->
get_min_row();
1457 $r.=$Hid->input(
"nb_item", $p_article);
1461 $f_legend_detail = _(
"Détail articles vendus");
1465 for (
$i = 0;
$i < $p_article;
$i++) {
1468 $march = (isset(${
"e_march$i"})) ? ${
"e_march$i"} :
"";
1469 $march_price = (isset(${
"e_march" .
$i .
"_price"})) ? ${
"e_march" .
$i .
"_price"} :
"" ;
1470 if ($flag_tva ==
'Y') {
1471 $march_tva_id = (isset(${
"e_march$i" .
"_tva_id"})) ? ${
"e_march$i" .
"_tva_id"} :
"";
1472 $march_tva_amount = (isset(${
"e_march$i" .
"_tva_amount"})) ? ${
"e_march$i" .
"_tva_amount"} :
"";
1474 $march_label = (isset(${
"e_march" .
$i .
"_label"})) ? ${
"e_march" .
$i .
"_label"} :
"";
1479 $fMarch =
new Fiche($this->
db);
1480 $fMarch->get_by_qcode($march);
1482 if ($flag_tva ==
'Y') {
1483 if (!(isset(${
"e_march$i" .
"_tva_id"})))
1491 $W1->name =
"e_march" .
$i;
1492 $W1->value = $march;
1494 $W1->set_attribute(
'typecard',
'cred');
1495 $W1->set_dblclick(
"fill_ipopcard(this);");
1496 $W1->set_attribute(
'ipopup',
'ipopcard');
1499 $W1->set_attribute(
'label',
'e_march' .
$i .
'_label');
1501 $W1->set_attribute(
'price',
'e_march' .
$i .
'_price');
1503 $W1->set_attribute(
'tvaid',
'e_march' .
$i .
'_tva_id');
1505 $W1->set_callback(
'filter_card');
1506 $W1->set_function(
'fill_data');
1507 $W1->javascript = sprintf(
' onchange="fill_data_onchange(\'%s\');" ', $W1->name);
1509 $W1->readonly =
false;
1511 $array[
$i][
'quick_code'] = $W1->input();
1513 $array[
$i][
'card_add']=($add_card==TRUE)?$this->
add_card(
"cred", $W1->id):
"";
1516 if ($flag_tva ==
'Y')
1519 $htva =
new INum(
'htva_march' .
$i);
1520 $htva->readOnly = 1;
1522 $array[
$i][
'htva'] = $htva->input();
1525 $tvac =
new INum(
'tvac_march' .
$i);
1529 $tvac->readOnly = 1;
1531 $array[
$i][
'tvac'] = $tvac->input();
1535 $Span=
new IText(
"e_march".
$i.
"_label");
1536 $Span->style=
'class="input_text label_item"';
1539 $Span=
new ISpan(
"e_march".
$i.
"_label");
1540 $Span->extra=
'class="label_item"';
1542 $Span->value = $march_label;
1543 $Span->setReadOnly(
false);
1546 $array[
$i][
'denom'] = $Span->input(
"e_march" .
$i .
"_label", $march_label);
1548 $Price =
new INum();
1549 $Price->setReadOnly(
false);
1551 $Price->javascript =
"onblur=\"format_number(this,4);clean_tva($i);compute_ledger($i)\"";
1552 $array[
$i][
'pu'] = $Price->input(
"e_march" .
$i .
"_price", $march_price);
1556 if ($flag_tva ==
'Y') {
1560 $Tva->in_table =
true;
1561 $Tva->set_attribute(
'compute',
$i);
1562 $Tva->set_filter(
"sale");
1564 $Tva->js =
'onblur="clean_tva(' .
$i .
');compute_ledger(' .
$i .
')"';
1565 $Tva->value = $march_tva_id;
1566 $array[
$i][
'tva'] = $Tva->input(
"e_march$i" .
"_tva_id");
1569 $wTva_amount =
new INum();
1570 $wTva_amount->readOnly =
false;
1571 $wTva_amount->size = 6;
1572 $wTva_amount->javascript =
"onblur='format_number(this);compute_ledger($i)'";
1573 $array[
$i][
'amount_tva'] = $wTva_amount->input(
"e_march" .
$i .
"_tva_amount", $march_tva_amount);
1577 $quant = (isset(${
"e_quant$i"})) ? ${
"e_quant$i"} :
"1";
1578 $Quantity =
new INum();
1580 $Quantity->setReadOnly(
false);
1581 $Quantity->size = 8;
1582 $Quantity->javascript =
"onchange=\"format_number(this,2);clean_tva($i);compute_ledger($i);\"";
1583 $array[
$i][
'quantity'] = $Quantity->input(
"e_quant" .
$i, $quant);
1585 $f_type = _(
'Client');
1588 $currency_select = $this->
CurrencyInput(
"currency_code",
"p_currency_rate" ,
"p_currency_euro");
1589 $currency_select->selected=
$http->extract(
'p_currency_code',
'string',0);
1591 $currency_input=
new INum(
"p_currency_rate");
1592 $currency_input->id=
"p_currency_rate";
1593 $currency_input->prec=8;
1594 $currency_input->value=
$http->extract(
'p_currency_rate',
'string',1);
1595 $currency_input->javascript=
'onchange="format_number(this,4);CurrencyCompute(\'p_currency_rate\',\'p_currency_euro\');"';
1603 echo
'<div id="predef_form">';
1606 $op->set_jrn_type(
"VEN");
1607 $op->set_p_jrn($this->
id);
1608 $op->set_od_direct(
'f');
1609 $url=http_build_query(array(
'p_jrn_predef'=>$this->
id,
'ac'=>
$http->request(
'ac'),
1611 echo
$op->form_get(
'do.php?'.
$url);
1613 $str_op_template=ob_get_contents();
1617 require_once NOALYSS_TEMPLATE.
'/form_ledger_detail.php';
1618 $form_ledger_detail=ob_get_contents();
1621 $r.=$form_ledger_detail;
1627 $r.=
'<div id="additional_tax_div">';
1645 if ( $this->
id == 0 ) die (__FILE__.
":".__LINE__.
" Journal invalide");
1648 if (
$g_user->get_ledger_access($this->id) ==
'X' )
return null;
1650 switch ( $p_filter_operation)
1656 $sql_filter=
" and (jr_date_paid is not null or jr_rapt ='paid' ) ";
1659 $sql_filter=
" and (jr_date_paid is null and coalesce(jr_rapt,'x') <> 'paid' ) ";
1662 throw new Exception(_(
"Filtre invalide",5));
1670 and jr_date >= (select p_start from parm_periode where p_id = $2)
1672 and jr_date <= (select p_end from parm_periode where p_id = $3) "
1673 .
' order by jr_date,substring(jr_pj_number,\'[0-9]+$\')::numeric asc ';
1684 $array[
'jr_id'] = _(
'Numéro opération');
1685 $array[
'jr_date'] = _(
'Date');
1686 $array[
'jr_date_paid'] = _(
'Date paiement');
1687 $array[
'jr_ech'] = _(
'Date échéance');
1688 $array[
'jr_tech_per'] = _(
'Période');
1689 $array[
'jr_comment'] = _(
'Libellé');
1690 $array[
'jr_pj_number'] = _(
'Pièce');
1691 $array[
'jr_internal'] = _(
'Interne');
1692 $array[
'jr_def_id'] = _(
'Code journal');
1693 $array[
'j_poste'] = _(
'Poste');
1694 $array[
'j_text'] = _(
'Commentaire');
1695 $array[
'j_qcode'] = _(
'Code Item');
1696 $array[
'jr_rapt'] = _(
'Payé');
1697 $array[
'item_card'] = _(
'N° item');
1698 $array[
'item_name'] = _(
'Nom fiche');
1699 $array[
'qs_client'] = _(
'N° fiche fournisseur');
1700 $array[
'tiers_name'] = _(
'Nom fournisseur');
1701 $array[
'quick_code'] = _(
'Code fournisseur');
1702 $array[
'tva_label'] = _(
'Nom TVA');
1703 $array[
'tva_comment'] = _(
'Commentaire TVA');
1704 $array[
'tva_both_side'] = _(
'TVA annulée');
1705 $array[
'vat_sided'] = _(
'TVA Non Payé');
1706 $array[
'vat_code'] = _(
'Code TVA');
1707 $array[
'vat'] = _(
'Montant TVA');
1708 $array[
'price'] = _(
'Total HTVA');
1709 $array[
'quantity'] = _(
'quantité');
1710 $array[
'price_per_unit'] = _(
'PU');
1711 $array[
'htva'] = _(
'HTVA Opération');
1712 $array[
'tot_vat'] = _(
'TVA Opération');
1713 $array[
'tot_vat_np'] = _(
'TVA ND');
1714 $array[
'other_tax'] = _(
"Autre taxe");
1715 $array[
'oc_amount'] = _(
'Mont. Devise');
1716 $array[
'oc_vat_amount'] = _(
'Mont. TVA Devise');
1717 $array[
'cr_code_iso'] = _(
'Devise');
span($p_string, $p_extra='')
noalyss_strlentrim($p_string)
tr($p_string, $p_extra='')
record_log($p_message)
Record an error message into the log file of the server.
sql_string($p_string)
Fix the problem with the quote char for the database.
td($p_string='', $p_extra='')
surround the string with td
nbm($p_number, $p_dec=2)
format the number with a sep.
cmpDate($p_date, $p_date_oth)
Compare 2 dates.
global $g_user
if no group available , then stop
catch(Exception $exc) if(! $g_user->can_write_action($ag_id)) $r
h( $row[ 'oa_description'])
if(isset($_REQUEST['gDossier']) && $http->request("gDossier","number", 0) !=0) $repo
catch(Exception $e) $tva_rate
Manage the account from the table jrn, jrnx or tmp_pcmn.
this class aims to compute different amount
display currency , convert to euro , and save them if used.
the class Acc_Ledger_Fin inherits from Acc_Ledger, this object permit to manage the financial ledger
Handle the ledger of sold,.
confirm($p_array, $p_summary=false)
show the summary of the operation and propose to save it
get_detail_sale($p_from, $p_end, $p_filter_operation='all')
Retrieve data from the view v_detail_sale , gives all the row of an operation.
static heading_detail_sale()
compute an array with the heading cells for the details, used for the export in CSV
extra_info()
the function extra info allows to
insert($p_array=null)
insert into the database, it calls first the verify function, store the value of the inserted operati...
input($p_array=null, $p_readonly=0)
display the form for entering data for invoice,
__construct($p_cn, $p_init)
verify_operation($p_array)
verify that the data are correct before inserting or confirming
select_depot($p_readonly, $p_repo)
Let you select the repository before confirming a sale or a purchase.
CurrencyInput($p_currency_code, $p_currency_rate, $p_eur_amount)
Create a select from value for currency and add javascript to update $p_currency_rate and $p_eur_amou...
$nb
!< type of the ledger ACH ODS FIN VEN or GL
warn_manual_receipt($p_array)
warn if the suggested receipt and receipt are different , it means that the user tried to number hims...
inc_seq_pj()
increment the sequence for the pj
select_ledger($p_type="ALL", $p_access=3, $enable=TRUE)
Show a select list of the ledgers you can access in writing, reading or simply accessing.
get_name()
Return the name of a ledger.
display_negative_warning($p_amount)
If the amount is positive and the ledger expects a negative amount, il will return the saved warning.
compute_internal_code($p_grpt)
compute the internal code of the saved operation and set the $this->jr_internal to the computed value
input_additional_tax()
form : display additional tax available for this ledger and value, set 2 values : checkbox if tax app...
check_currency($p_qcode_payment, $p_currency_id)
When we write a record for the payment at the same time as a sale or a purchase, to have a bank saldo...
$row
!< database connextion
create_document($internal, $p_array)
create the invoice and saved it as attachment to the operation,
is_closed($p_periode)
check if the current ledger is closed
has_other_tax()
returns true if the ledger has an additional tax
add_card($p_filter, $p_id_update)
Return a button to create new card, depending of the ledger.
check_payment($e_mp, $e_mp_qcode)
check if the payment method is valid
get_last_date()
get the date of the last operation
check_periode()
Check if a Dossier is using the check on the periode, if true than the user has to enter the date and...
check_strict()
Check if a Dossier is using the strict mode or not.
guess_pj()
guess what the next pj should be
get_id($p_internal)
retrieve the jr_id thanks the internal code, do not change anything to the current object
check_currency_setting($p_currency_code)
Check that the currency code does exist and the setting of the folder is correct.
static build_jrn_id($p_jr_id)
this file match the tables jrn & jrnx the purpose is to remove or save accountant writing to these ta...
Handle the table payment_method.
new class for managing the reconciliation it must be used instead of the function InsertRapt,...
Acc_Tva is used for to map the table tva_rate parameter are.
this class is used to show the form for entering an operation only FOR analytic operation to save it,...
Concerns the Analytic plan (table plan_analytique)
static hidden($p_array)
return an HTML string containing hidden input type to hold the differant PA_ID
abstract of the table public.currency
define Class fiche and fiche def, those class are using class attribut. When adding or modifing new c...
Input HTML for the card show buttons, in the file, you have to add card.js How to use :
Html Input : Input a date format dd.mm.yyyy The property title should be set to indicate what it is e...
Html Input for uploading file, must be in a form with enctype="multipart/form-data".
This class handles only the numeric input, the input will call a javascript to change comma to period...
Generate the form for the periode Data Members.
Html Input , create a tag <SELECT> ... </SELECT> if readonly == true then display the label correspon...
static infobulle($p_comment)
Display a info in a bubble, text is in message_javascript.
ORM of the table public.jrn_tax.
mother class for the lettering by account and by card use the tables jnt_letter, letter_deb and lette...
ORM abstract of the table public.operation_currency.
For the periode tables parm_periode and jrn_periode.
manage the predefined operation, link to the table op_def and op_def_detail
static insert_goods(&$p_cn, $p_array)
Insert into stock_goods from ACH and VEN.
$def
show a form for quick_writing
if( $g_parameter->MY_PJ_SUGGEST=='Y') $e_date
create_script($p_string)
create the HTML for adding the script tags around of the script
check_parameter($p_array, $p_needed)
Check that all the index are in the array, used by function to check if the array contains the needed...