noalyss Version-9
Public Member Functions
Acc_Ledger_Fin Class Reference

the class Acc_Ledger_Fin inherits from Acc_Ledger, this object permit to manage the financial ledger More...

+ Inheritance diagram for Acc_Ledger_Fin:
+ Collaboration diagram for Acc_Ledger_Fin:

Public Member Functions

 __construct ($p_cn, $p_init)
 
 confirm ($p_array, $p_nothing=0)
 show the result of the array to confirm before inserting More...
 
 get_bank ()
 find and FICHE.F_ID of the bank or -1 if not found More...
 
 get_bank_name ()
 return a string with the bank account, name and quick_code More...
 
 input ($p_array=null, $notused=0)
 display a form to enter an FIN operation More...
 
 insert ($p_array=null)
 
 insert_quant_fin ($p_bankid, $p_jrid, $p_otherid, $p_amount, $p_j_id_currency)
 insert into the quant_fin table More...
 
 numb_operation ()
 return true is we numbere each operation More...
 
 verify_operation ($p_array)
 Verify that the data are correct before inserting or confirming. More...
 
- Public Member Functions inherited from Acc_Ledger
 __construct ($p_cn, $p_id)
 
 add_card ($p_filter, $p_id_update)
 Return a button to create new card, depending of the ledger. More...
 
 button_copy_operation ()
 Show a button to create an operation identical to the recorded one. More...
 
 button_new_operation ()
 Create a button to encode a new operation into the same ledger. More...
 
 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 reliable , all the bank operation must be in the same currency Operation = Currency 1 and Bank = Currency 2 then it must failed , except if currency 2 (of the bank is the default currency. More...
 
 check_currency_setting ($p_currency_code)
 Check that the currency code does exist and the setting of the folder is correct. More...
 
 check_payment ($e_mp, $e_mp_qcode)
 check if the payment method is valid More...
 
 check_periode ()
 Check if a Dossier is using the check on the periode, if true than the user has to enter the date and the periode, it is a security check. More...
 
 check_strict ()
 Check if a Dossier is using the strict mode or not. More...
 
 compute_internal_code ($p_grpt)
 compute the internal code of the saved operation and set the $this->jr_internal to the computed value More...
 
 confirm ($p_array, $p_readonly=false)
 show the result of the array to confirm before inserting More...
 
 convert_from_follow ($p_ag_id)
 
 create_document ($internal, $p_array)
 create the invoice and saved it as attachment to the operation, More...
 
 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_amount. More...
 
 delete ()
 let you delete a operation More...
 
 delete_ledger ()
 delete a ledger IF it doesn't contain anything More...
 
 display_additional_tax ($p_additional_tax, $p_amount)
 in confirm screen , display the compute value for additional tax @parameter $p_additional_tax acc_other_tax.ac_id More...
 
 display_ledger ()
 display detail of a ledger More...
 
 display_negative_warning ($p_amount)
 If the amount is positive and the ledger expects a negative amount, il will return the saved warning. More...
 
 display_warning ($pa_msg, $p_warning)
 Display warning contained in an array. More...
 
 existing_vat ()
 return the used VAT code with a rate > 0 More...
 
 get_all_fiche_def ()
 retrieve all the card for this type of ledger, make them into a string separated by comma More...
 
 get_class_def ()
 retrieve the jrn_def_class_deb and return it More...
 
 get_currency ()
 returns the code iso of the default currency for this ledger More...
 
 get_customer_late ()
 get info from customer not yet paid More...
 
 get_customer_now ()
 get info from customer to pay today More...
 
 get_default_card ($p_ledger_type, $p_side)
 Return an array of default card for the ledger type given. More...
 
 get_fiche_def ()
 retrieve the jrn_def_fiche and return them into a array index deb, cred More...
 
 get_first ($p_type, $p_access=3)
 get the first ledger More...
 
 get_id ($p_internal)
 retrieve the jr_id thanks the internal code, do not change anything to the current object More...
 
 get_is_loaded ()
 
 get_last ($p_limit)
 return the last p_limit operation into an array More...
 
 get_last_date ()
 get the date of the last operation More...
 
 get_last_pj ()
 
 get_ledger_id ()
 Set the jrn_def.jrn_def_id. More...
 
 get_min_row ()
 
 get_name ()
 Return the name of a ledger. More...
 
 get_operation ($p_from, $p_to)
 retrieve operation from jrn More...
 
 get_operation_date ($p_date, $p_ledger_type, $sql_op)
 Get operation from the ledger type before, after or with the given date . More...
 
 get_other_amount ($p_jr_id)
 get the amount of vat for a given jr_grpt_id from the table quant_purchase More...
 
 get_propertie ()
 Get the properties of a journal. More...
 
 get_rowSimple ($p_from, $p_to, $pa_ledger=[], $trunc=0, $p_limit=-1, $p_offset=-1)
 Get simplified row from ledger Call Acc_Ledger_History_Generic:get_rowSimple. More...
 
 get_solde ($p_from, $p_to)
 get the saldo of a ledger for a specific period More...
 
 get_supplier_late ()
 get info from supplier not yet paid More...
 
 get_supplier_now ()
 get info from supplier to pay today More...
 
 get_tiers ($p_jrn_type, $jr_id)
 Retrieve the third : supplier for purchase, customer for sale, bank for fin,. More...
 
 get_tiers_id ($p_jrn_type, $jr_id)
 Return the f_id of the tiers , called by get_tiers. More...
 
 get_type ()
 Return the type of a ledger (ACH,VEN,ODS or FIN) or GL. More...
 
 guess_pj ()
 guess what the next pj should be More...
 
 has_other_tax ()
 returns true if the ledger has an additional tax More...
 
 has_quantity ()
 Check if a ledger is enabled , 1 for yes and 0 if disabled. More...
 
 inc_seq_pj ()
 increment the sequence for the pj More...
 
 input ($p_array=null, $p_readonly=0)
 Show the form to encode your operation. More...
 
 input_additional_tax ()
 form : display additional tax available for this ledger and value, set 2 values : checkbox if tax applies and value More...
 
 input_extra_info ()
 
 input_new ()
 display screen to enter a new ledger More...
 
 input_paid ($p_selected, $p_amount=0, $p_date="", $p_comm="")
 Create the section payment. More...
 
 is_closed ($p_periode)
 check if the current ledger is closed More...
 
 is_enable ()
 Check if a ledger is enabled , 1 for yes and 0 if disabled. More...
 
 listing ()
 listing of all ledgers More...
 
 previous_amount ($p_to)
 retrieve amount of previous periode More...
 
 previous_other_tax ($p_to)
 retrieve the previous amount More...
 
 reverse ($p_date, $p_label)
 reverse the operation by creating the opposite one, the result is to avoid it it must be done in More...
 
 save ($p_array=null)
 save the operation into the jrnx,jrn, , CA and pre_def More...
 
 save_followup ($s_related_action)
 attach action-followups to an operation, More...
 
 save_new ($array)
 Insert a new ledger , member variable like jrn_def_id will changed. More...
 
 search_group ($p_what, $p_value)
 retreive the jr_grpt_id from a ledger More...
 
 select_default_currency ()
 create a select button to set the default currency for a ledger used only for empty financial ledger More...
 
 select_depot ($p_readonly, $p_repo)
 Let you select the repository before confirming a sale or a purchase. More...
 
 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. More...
 
 set_currency_id ()
 retrieve currency_id from database More...
 
 set_is_loaded ($is_loaded)
 
 set_ledger_id ($p_id)
 Set the jrn_def.jrn_def_id. More...
 
 set_quantity ($p_value)
 set quantity for the ledger to 1 or 0, More...
 
 update ($array=null)
 update a ledger More...
 
 update_internal_code ($p_internal)
 
 update_paid ($p_array)
 Update the paiment in the list of operation. More...
 
 use_quant_table ($p_grpt_id, $p_jrn_type)
 Check if the operation is used in the table quant*. More...
 
 vat_operation ($p_jr_id)
 get the amount of vat for a given jr_grpt_id from the table quant_purchase More...
 
 verify_ledger ($array)
 Verify before update. More...
 
 verify_operation ($p_array)
 verify that the operation can be saved More...
 

Additional Inherited Members

- Static Public Member Functions inherited from Acc_Ledger
static array_cat ()
 create an array of the existing cat, to be used in a checkbox form More...
 
static next_number ($p_cn, $p_type)
 retrieve the next number for this type of ledger More...
 
static test_me ($pCase='')
 this function is intended to test this class More...
 
- Data Fields inherited from Acc_Ledger
 $currency_id
 !< default number of rows by default 10 More...
 
 $db
 !< jrn_def.jrn_def_id More...
 
 $id
 
 $ledger_type
 !< row of the ledger More...
 
 $nb
 !< type of the ledger ACH ODS FIN VEN or GL More...
 
 $row
 !< database connextion More...
 
- Protected Member Functions inherited from Acc_Ledger
 find_label ($p_value)
 Retrieve the label of an accounting. More...
 
 verify_autonumber ($p_array)
 compare given receipt number and suggested one, if different , it means that the user enters a receipt number if e_pj or e_pj_suggest is not set or empty , or if both are equals then will return true, it returns only if they exist and are different More...
 
 warn_manual_receipt ($p_array)
 warn if the suggested receipt and receipt are different , it means that the user tried to number himself More...
 
- Protected Attributes inherited from Acc_Ledger
 $is_loaded
 !< is_loaded true the ledger definition is loaded or false, it is not More...
 

Detailed Description

the class Acc_Ledger_Fin inherits from Acc_Ledger, this object permit to manage the financial ledger

Definition at line 35 of file acc_ledger_fin.class.php.

Constructor & Destructor Documentation

◆ __construct()

Acc_Ledger_Fin::__construct (   $p_cn,
  $p_id 
)
Parameters
$p_cndatabase connexion
$p_idjrn.jrn_def_id

Reimplemented from Acc_Ledger.

Definition at line 38 of file acc_ledger_fin.class.php.

39 {
40 parent::__construct($p_cn, $p_init);
41 $this->ledger_type='FIN';
42 }

Member Function Documentation

◆ confirm()

Acc_Ledger_Fin::confirm (   $p_array,
  $p_readonly = 0 
)

show the result of the array to confirm before inserting

Parameters
$p_arrayarray from the form
Returns
HTML string

Reimplemented from Acc_Ledger.

Definition at line 456 of file acc_ledger_fin.class.php.

457 {
458 global $g_parameter, $g_user;
459 $r="";
460 if ( ! $this->get_is_loaded()) {
461 $this->load();
462 }
463 bcscale(2);
464 extract($p_array, EXTR_SKIP);
465 $pPeriode=new Periode($this->db);
466 if ($this->check_periode()==true)
467 {
468 $pPeriode->p_id=$periode;
469 }
470 else
471 {
472 if (isDate($e_date)!=null)
473 {
474 $pPeriode->find_periode($e_date);
475 }
476 else
477 {
478 $pPeriode->p_id=$g_user->get_periode();
479 }
480 }
481
482 list ($l_date_start, $l_date_end)=$pPeriode->get_date_limit();
483 $exercice=$pPeriode->get_exercice();
484 $r.='';
485 $r.='<fieldset><legend>'._("Banque, caisse").' </legend>';
486 $r.='<div id="jrn_name_div">';
487 $r.='<h1 id="jrn_name" style="display:inline">'.$this->get_name().'</h1>';
488 $r.='</div>';
489 $r.='<TABLE width="100%">';
490 // Date
491 //--
492 $r.="<tr>";
493 if ($chdate==1)
494 $r.='<td> Date : </td><td>'.$e_date;
495 // Periode
496 //--
497 $r.="<td>";
498 $r.="Période comptable </td><td>";
499 $r.=$l_date_start.' - '.$l_date_end;
500 $r.="</td>";
501 $r.="</tr>";
502 // Ledger (p_jrn)
503 //--
504 $r.='<tr>';
505 $r.='<td> Journal </td>';
506 $this->id=$p_jrn;
507 $r.='<td>';
508 $r.=h($this->get_name());
509 $r.='</td>';
510 $r.='</tr>';
511
512 //retrieve bank name
513 $bk_id=$this->get_bank();
514
515 $fBank=new Fiche($this->db, $bk_id);
516 $e_bank_account_label=$this->get_bank_name();
517
518 $filter_year=" j_tech_per in (select p_id from parm_periode where p_exercice='".$exercice."')";
519
520 $acc_account=new Acc_Account_Ledger($this->db, $fBank->strAttribut(ATTR_DEF_ACCOUNT));
521 $asolde=$acc_account->get_solde_detail($filter_year);
522 $deb=$asolde['debit'];
523 $cred=$asolde['credit'];
524 $solde=bcsub($deb, $cred);
525 $new_solde=$solde;
526
527 $r.="<TR><td colspan=\"4\"> Banque ";
528 $r.=$e_bank_account_label;
529
530 $r.="</TABLE>";
531
532 $r.='</fieldset>';
533
534 $r.='<div class="myfieldset"><h1 class="legend">'._("Extrait de compte").'</h1>';
535 //--------------------------------------------------
536 // Saldo begin end
537 //-------------------------------------------------
538 $r.='<table>';
539 $r.='<tr>';
540 // Extrait
541 //--
542 $r.=tr('<td>'._("Numéro d'extrait").' </td>'.td(h($e_pj)));
543 $r.='<tr><td >'._("Solde début extrait").' </td>';
544 $r.='<td style="num">'.nbm($first_sold).'</td></tr>';
545 $r.='<tr><td>'._("Solde fin extrait").' </td>';
546 $r.='<td style="num">'.nbm($last_sold).'</td></tr>';
547 $r.='</table>';
548
549 $r.='<h1 class="legend">Opérations financières</h1>';
550 //--------------------------------------------------
551 // financial operation
552 //-------------------------------------------------
553 $r.='<TABLE style="width:100%" id="fin_item">';
554 $r.="<TR>";
555 if ($chdate==2)
556 $r.='<th>'._("Date").'</th>';
557 $r.="<th style=\"width:auto;text-align:left\" colspan=\"2\">"._("Nom")."</th>";
558 $r.="<th style=\"text-align:left\" >"._("Commentaire")."</th>";
559 $r.="<th style=\"text-align:right\">"._("Montant")."</th>";
560 $r.='<th colspan="2">'._("Op. Concernée(s)").'</th>';
561
562 /* if we use the AC */
563 if ($g_parameter->MY_ANALYTIC!='nu')
564 {
565 $anc=new Anc_Plan($this->db);
566 $a_anc=$anc->get_list();
567 $x=count($a_anc);
568 /* set the width of the col */
569 $r.='<th colspan="'.$x.'">'._('Compt. Analytique').'</th>';
570
571 /* add hidden variables pa[] to hold the value of pa_id */
572 $r.=Anc_Plan::hidden($a_anc);
573 }
574 $r.="</TR>";
575 // Parse each " tiers"
576 $tot_amount=0;
577 //--------------------------------------------------
578 // For each items
579 //--------------------------------------------------
580 for ($i=0; $i<$nb_item; $i++)
581 {
582
583 $tiers=(isset(${"e_other".$i}))?${"e_other".$i}:""
584 ;
585
587 continue;
588 $tiers_label="";
589 $tiers_amount=round(${"e_other$i"."_amount"}, 2);
590 $tot_amount=bcadd($tot_amount, $tiers_amount);
591 $tiers_comment=h(${"e_other$i"."_comment"});
592 // If $tiers has a value
593 $fTiers=new Fiche($this->db);
594 $fTiers->get_by_qcode($tiers);
595
596 $tiers_label=$fTiers->strAttribut(ATTR_DEF_NAME);
597
598 $r.="<TR>";
599 if ($chdate==2)
600 $r.=td(${"dateop".$i});
601 $r.="<td>".${'e_other'.$i}."</TD>";
602 // label
603 $r.='<TD style="width:25%;border-bottom:1px dotted grey;">';
604 $r.=$fTiers->strAttribut(ATTR_DEF_NAME);
605 $r.='</td>';
606 // Comment
607 $r.='<td style="width:40%">'.$tiers_comment.'</td>';
608 // amount
609 $r.='<td class="num">'.nbm($tiers_amount).'</td>';
610 // concerned
611 $r.='<td style="text-align:center">';
612 if (${"e_concerned".$i}!='')
613 {
614 $jr_internal=$this->db->get_array("select jr_internal from jrn where jr_id in (".${"e_concerned".$i}.")");
615 $comma="";
616 for ($x=0; $x<count($jr_internal); $x++)
617 {
618 $r.=$comma.HtmlInput::detail_op(${"e_concerned".$i}, $jr_internal[$x]['jr_internal']);
619 $comma=" , ";
620 }
621 }
622 $r.='</td>';
623 // encode the pa
624 if ($g_parameter->MY_ANALYTIC!='nu'&&$g_parameter->match_analytic($fTiers->strAttribut(ATTR_DEF_ACCOUNT))==1) // use of AA
625 {
626 // show form
627 $anc_op=new Anc_Operation($this->db);
628 $null=($g_parameter->MY_ANALYTIC=='op')?1:0;
629 $r.='<td>';
630 $p_mode=1;
631 $p_array['pa_id']=$a_anc;
632 /* op is the operation it contains either a sequence or a jrnx.j_id */
633 $r.=HtmlInput::hidden('op[]=', $i);
634 $r.=$anc_op->display_form_plan($p_array, $null, $p_mode, $i, $tiers_amount);
635 $r.='</td>';
636 }
637
638 $r.='</TR>';
639 }
640 $r.="</TABLE>";
641 $acc_currency=$this->get_currency();
642
643 // If currency is not the default one
644 if ($acc_currency->get_id()!=0)
645 {
646
647 $solde=$fBank->get_bk_balance_currency();
648 $cur=$acc_currency->get_code();
649 $cur_rate=$acc_currency->get_rate_date($e_date);
650 $default_currency=new Acc_Currency($this->db, 0);
651 // saldo
652 $r.="<table>";
653 $r.=tr(
654 td(_("Ancien solde")).
655 td(nbm($solde).$cur, 'class="num"')
656 );
657 $new_solde=bcadd($solde??0, $tot_amount??0);
658 $r.=tr(
659 td(_("Nouveau solde")).
660 td(nbm($new_solde).$cur, ' class="num"')
661 );
662 $r.=tr(
663 td(_("Difference")).
664 td(nbm($tot_amount).$cur, ' class="num"')
665 );
666 $r.=tr(
667 td(_("Taux")).
668 td($cur_rate)
669 );
670 $r.=tr(
671 td(_("Nouveau solde")).
672 td(bcdiv($new_solde, $cur_rate).$default_currency->get_code(), ' class="num"')
673 );
674 $r.='</table>';
675 }
676 else
677 {
678
679 $cur=$acc_currency->get_code();
680 // saldo
681 $r.="<table>";
682 $r.=tr(
683 td(_("Ancien solde")).
684 td(nbm($solde).$cur, 'class="num"')
685 );
686 $new_solde=bcadd($solde, $tot_amount);
687 $r.=tr(
688 td(_("Nouveau solde")).
689 td(nbm($new_solde).$cur, ' class="num"')
690 );
691 $r.=tr(
692 td(_("Difference")).
693 td(nbm($tot_amount).$cur, ' class="num"')
694 );
695
696 $r.='</table>';
697 }
698 // check for upload piece
699 $file=new IFile();
700 $file->setAlertOnSize(true);
701 $r.="<br>"._("Ajoutez une pièce justificative")." ";
702 $r.=$file->input("pj", "");
703
704 $r.='</div>';
705 //--------------------------------------------------
706 // Hidden variables
707 //--------------------------------------------------
708 $r.=dossier::hidden();
709 $r.=HtmlInput::hidden('p_jrn', $this->id);
710 $r.=HtmlInput::hidden('nb_item', $nb_item);
711 $r.=HtmlInput::hidden('last_sold', $last_sold);
712 $r.=HtmlInput::hidden('first_sold', $first_sold);
713 $r.=HtmlInput::hidden('e_pj', $e_pj);
714 $r.=HtmlInput::hidden('e_pj_suggest', $e_pj_suggest);
715 $r.=HtmlInput::hidden('e_date', $e_date);
716 $mt=microtime(true);
717 $r.=HtmlInput::hidden('mt', $mt);
718
719 if (isset($periode))
720 $r.=HtmlInput::hidden('periode', $periode);
721 $r.=dossier::hidden();
722 $r.=HtmlInput::hidden('sa', 'n', 'chdate');
723 for ($i=0; $i<$nb_item; $i++)
724 {
725 $tiers=(isset(${"e_other".$i}))?${"e_other".$i}:"";
726 $r.=HtmlInput::hidden('e_other'.$i, $tiers);
727 $r.=HtmlInput::hidden('e_other'.$i, $tiers);
728 $r.=HtmlInput::hidden('e_other'.$i.'_comment', ${'e_other'.$i.'_comment'});
729 $r.=HtmlInput::hidden('e_other'.$i.'_amount', ${'e_other'.$i.'_amount'});
730 $r.=HtmlInput::hidden('e_concerned'.$i, ${'e_concerned'.$i});
731 $r.=HtmlInput::hidden('dateop'.$i, ${'dateop'.$i});
732 $r.=HtmlInput::hidden('chdate', $chdate);
733 }
734
735 return $r;
736 }
isDate($p_date)
Definition: ac_common.php:236
noalyss_strlentrim($p_string)
Definition: ac_common.php:1549
tr($p_string, $p_extra='')
Definition: ac_common.php:88
td($p_string='', $p_extra='')
surround the string with td
Definition: ac_common.php:83
nbm($p_number, $p_dec=2)
format the number with a sep.
Definition: ac_common.php:137
global $g_parameter
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'])
catch(Exception $e) $exercice
Manage the account from the table jrn, jrnx or tmp_pcmn.
display currency , convert to euro , and save them if used.
get_bank_name()
return a string with the bank account, name and quick_code
get_bank()
find and FICHE.F_ID of the bank or -1 if not found
get_currency()
returns the code iso of the default currency for this ledger
get_name()
Return the name of a ledger.
check_periode()
Check if a Dossier is using the check on the periode, if true than the user has to enter the date and...
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
define Class fiche and fiche def, those class are using class attribut. When adding or modifing new c...
Definition: fiche.class.php:38
static hidden($p_name, $p_value, $p_id="")
Html Input for uploading file, must be in a form with enctype="multipart/form-data".
Definition: ifile.class.php:31
For the periode tables parm_periode and jrn_periode.
if( $g_parameter->MY_PJ_SUGGEST=='Y') $e_date
const ATTR_DEF_NAME
Definition: constant.php:216
const ATTR_DEF_ACCOUNT
Definition: constant.php:215
if(sizeof($array)==0) $pPeriode
$SecUser db
for($i=0;$i< $nb_jrn;$i++) $deb

References $anc, $cred, $deb, $default_currency, $e_date, $exercice, $file, $filter_year, $g_parameter, $g_user, $i, $p_array, $p_jrn, $periode, $pPeriode, $r, $solde, $tiers, $tot_amount, ATTR_DEF_ACCOUNT, ATTR_DEF_NAME, Acc_Ledger\check_periode(), db, get_bank(), get_bank_name(), Acc_Ledger\get_currency(), Acc_Ledger\get_is_loaded(), Acc_Ledger\get_name(), h, Anc_Plan\hidden(), HtmlInput\hidden(), isDate(), nbm(), noalyss_strlentrim(), td(), and tr().

+ Here is the call graph for this function:

◆ get_bank()

Acc_Ledger_Fin::get_bank ( )

find and FICHE.F_ID of the bank or -1 if not found

Definition at line 1141 of file acc_ledger_fin.class.php.

1142 {
1143 $bank_id=$this->db->get_value('select jrn_def_bank from jrn_def where jrn_def_id=$1', array($this->id));
1144 if (empty($bank_id)) return -1;
1145 return $bank_id;
1146 }

References db.

Referenced by confirm(), insert(), and verify_operation().

◆ get_bank_name()

Acc_Ledger_Fin::get_bank_name ( )

return a string with the bank account, name and quick_code

Definition at line 1128 of file acc_ledger_fin.class.php.

1129 {
1130 $this->bank_id=$this->db->get_value('select jrn_def_bank from jrn_def where jrn_def_id=$1', array($this->id));
1131 $fBank=new Fiche($this->db, $this->bank_id);
1132 $e_bank_account=" : ".$fBank->strAttribut(ATTR_DEF_BQ_NO);
1133 $e_bank_name=" : ".$fBank->strAttribut(ATTR_DEF_NAME);
1134 $e_bank_qcode=": ".$fBank->strAttribut(ATTR_DEF_QUICKCODE);
1135 return $e_bank_qcode.$e_bank_name.$e_bank_account;
1136 }
const ATTR_DEF_BQ_NO
Definition: constant.php:217
const ATTR_DEF_QUICKCODE
Definition: constant.php:237

References ATTR_DEF_BQ_NO, ATTR_DEF_NAME, ATTR_DEF_QUICKCODE, and db.

Referenced by confirm().

◆ input()

Acc_Ledger_Fin::input (   $p_array = null,
  $notused = 0 
)

display a form to enter an FIN operation

Parameters
$p_arraycontains the value usually it is $_POST
Returns
string with html code
Note
the form tag are not set here

Reimplemented from Acc_Ledger.

Definition at line 243 of file acc_ledger_fin.class.php.

244 {
245 global $g_parameter, $g_user;
246 if ($p_array!=null)
247 extract($p_array, EXTR_SKIP);
248
249 $pview_only=false;
250
251 $min_article=$this->get_min_row();
252
253 $str_add_button_tiers="";
254 $add_card=FALSE;
255 if ($g_user->check_action(FICADD)==1)
256 {
257 $add_card=TRUE;
258 }
259
260 // The first day of the periode
261 $pPeriode=new Periode($this->db);
262 list ($l_date_start, $l_date_end)=$pPeriode->get_date_limit($g_user->get_periode());
263 if ($g_parameter->MY_DATE_SUGGEST=='Y')
264 $op_date=(!isset($e_date) )?$l_date_start:$e_date;
265 else
266 $op_date=(!isset($e_date) )?'':$e_date;
267
268 $r="";
269
270 $r.=dossier::hidden();
271 $f_legend='Banque, caisse';
272 // Date
273 //--
274 $Date=new IDate("e_date", $op_date);
275 $Date->setReadOnly($pview_only);
276 $f_date=$Date->input();
277 $f_period='';
278 if ($this->check_periode()==true)
279 {
280 // Periode
281 //--
282 $l_user_per=(isset($periode))?$periode:$g_user->get_periode();
283 $period=new IPeriod();
284 $period->cn=$this->db;
285 $period->type=OPEN;
286 $period->value=$l_user_per;
287 $period->user=$g_user;
288 $period->name='periode';
289 try
290 {
291 $l_form_per=$period->input();
292 }
293 catch (Exception $e)
294 {
295 if ($e->getCode()==1)
296 {
297 throw new Exception(_("Aucune période ouverte"));
298 }
299 }
301 $f_period="Période comptable $label".$l_form_per;
302 }
303
304 // Ledger (p_jrn)
305 //--
306 $onchange="update_bank();ajax_saldo('first_sold');update_name();update_row('fin_item');show_ledger_fin_currency();";
307
308 if ($g_parameter->MY_DATE_SUGGEST=='Y')
309 $onchange.='get_last_date();';
310 if ($g_parameter->MY_PJ_SUGGEST=='Y')
311 $onchange.='update_pj();';
312
313 $add_js='onchange="'.$onchange.'"';
314 $wLedger=$this->select_ledger('FIN', 2, FALSE);
315 if ($wLedger==null)
316 throw new Exception(_('Pas de journal disponible'));
317
318 $wLedger->javascript=$add_js;
319
320 $label_ledger=_("Journal")." ".Icon_Action::infobulle(2);
321
322 // retrieve bank name, code and account from the jrn_def.jrn_def_bank
323
324 $f_bank='<span id="bkname">'.$this->get_bank_name().'</span>';
325 if ($this->bank_id=="")
326 {
327 echo h2("Journal de banque non configuré ".$this->get_name(), ' class="error"');
328 echo '<span class="error"> vous devez donner à ce journal un compte en banque (fiche), modifiez dans CFGLED</span>';
329 alert("Journal de banque non configuré ".$this->get_name());
330 }
331
332 $f_legend_detail='Opérations financières';
333 //--------------------------------------------------
334 // Saldo begin end
335 //-------------------------------------------------
336 // Extrait
337 $default_pj='';
338 if ($g_parameter->MY_PJ_SUGGEST=='Y')
339 {
340 $default_pj=$this->guess_pj();
341 }
342 $wPJ=new IText('e_pj');
343 $wPJ->readonly=false;
344 $wPJ->size=10;
345 $wPJ->value=(isset($e_pj))?$e_pj:$default_pj;
346
347 $f_extrait=$wPJ->input().HtmlInput::hidden('e_pj_suggest', $default_pj);
349
350 $first_sold=(isset($first_sold))?$first_sold:"";
351 $wFirst=new INum('first_sold', $first_sold);
352
353 $last_sold=isset($last_sold)?$last_sold:"";
354 $wLast=new INum('last_sold', $last_sold);
355
356 $max=(isset($nb_item))?$nb_item:$min_article;
357
358 $r.=HtmlInput::hidden('nb_item', $max);
359 //--------------------------------------------------
360 // financial operation
361 //-------------------------------------------------
362
363 $array=array();
364 // Parse each " tiers"
365 for ($i=0; $i<$max; $i++)
366 {
367 $tiers=(isset(${"e_other".$i}))?${"e_other".$i}:"";
368
369 $tiers_amount=(isset(${"e_other$i"."_amount"}))?round(${"e_other$i"."_amount"}, 2):0;
370
371 $tiers_comment=(isset(${"e_other$i"."_comment"}))?${"e_other$i"."_comment"}:"";
372
373 $operation_date=new IDate("dateop".$i);
374 $operation_date->value=(isset(${'dateop'.$i}))?${'dateop'.$i}:"";
375 $array[$i]['dateop']=$operation_date->input();
376 ${"e_other$i"."_amount"}=(isset(${"e_other$i"."_amount"}))?${"e_other$i"."_amount"}:0;
377
378 $W1=new ICard();
379 $W1->label="";
380 $W1->name="e_other".$i;
381 $W1->id="e_other".$i;
382 $W1->value=$tiers;
383 $W1->extra='deb'; // credits
384 $W1->typecard='deb';
385 $W1->set_dblclick("fill_ipopcard(this);");
386 $W1->set_attribute('ipopup', 'ipopcard');
387
388 // name of the field to update with the name of the card
389 $W1->set_attribute('label', 'e_other_name'.$i);
390 // name of the field to update with the name of the card
391 $W1->set_attribute('typecard', 'filter');
392 // Add the callback function to filter the card on the jrn
393 $W1->set_callback('filter_card');
394 $W1->set_function('fill_data');
395 $W1->javascript=sprintf(' onchange="fill_data_onchange(\'%s\');" ', $W1->name);
396 $W1->readonly=$pview_only;
397 $array[$i]['qcode']=$W1->input();
398 $array[$i]['search']=$W1->search();
399 $array[$i]['card_add']=($add_card==TRUE)?$this->add_card("deb", $W1->id):"";
400 // Card name
401 //
402 $card_name="";
403 if ($tiers!="")
404 {
405 $fiche=new Fiche($this->db);
406 $fiche->get_by_qcode($tiers);
407 $card_name=$this->db->get_value("Select ad_value from fiche_detail where ad_id=$1 and f_id=$2",
408 array(ATTR_DEF_NAME, $fiche->id));
409 }
410
411 $wcard_name=new IText("e_other_name".$i, $card_name);
412 $wcard_name->id=$wcard_name->name;
413 $wcard_name->readOnly=true;
414 $array[$i]['cname']=$wcard_name->input();
415
416 // Comment
417 $wComment=new IText("e_other$i"."_comment", $tiers_comment);
418 $wComment->style='class="input_text label_item"';
419
420 $wComment->setReadOnly($pview_only);
421 $array[$i]['comment']=$wComment->input();
422 // amount
423 $wAmount=new INum("e_other$i"."_amount", $tiers_amount);
424
425 $wAmount->size=7;
426 $wAmount->setReadOnly($pview_only);
427 $array[$i]['amount']=$wAmount->input();
428 // concerned
429 ${"e_concerned".$i}=(isset(${"e_concerned".$i}))?${"e_concerned".$i}:""
430 ;
431 $wConcerned=new IConcerned("e_concerned".$i, ${"e_concerned".$i});
432 $wConcerned->tiers="e_other".$i;
433 $wConcerned->setReadOnly($pview_only);
434 $wConcerned->amount_id="e_other".$i."_amount";
435
436 $wConcerned->paid='paid';
437 $array[$i]['concerned']=$wConcerned->input();
438 }
439
440 ob_start();
441 require_once NOALYSS_TEMPLATE.'/form_ledger_fin.php';
442 $r.=ob_get_contents();
443 ob_end_clean();
444 $r.=create_script("$('".$Date->id."').focus()");
445
446 return $r;
447 }
h2($p_string, $p_class="", $raw="")
Definition: ac_common.php:68
alert($p_msg, $buffer=false)
alert in javascript
Definition: ac_common.php:738
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.
add_card($p_filter, $p_id_update)
Return a button to create new card, depending of the ledger.
$db
!< jrn_def.jrn_def_id
guess_pj()
guess what the next pj should be
setReadOnly($p_read)
Input HTML for the card show buttons, in the file, you have to add card.js How to use :
Html Input.
Html Input : Input a date format dd.mm.yyyy The property title should be set to indicate what it is e...
Definition: idate.class.php:34
This class handles only the numeric input, the input will call a javascript to change comma to period...
Definition: inum.class.php:42
Generate the form for the periode Data Members.
Html Input.
Definition: itext.class.php:30
static infobulle($p_comment)
Display a info in a bubble, text is in message_javascript.
const OPEN
Definition: constant.php:201
const FICADD
create_script($p_string)
create the HTML for adding the script tags around of the script

References $array, Acc_Ledger\$db, $e, $e_date, $fiche, $g_parameter, $g_user, $i, $label, $max, $p_array, $periode, $pPeriode, $r, $tiers, $wLedger, Acc_Ledger\add_card(), alert(), ATTR_DEF_NAME, Acc_Ledger\check_periode(), create_script(), db, FICADD, Acc_Ledger\get_min_row(), Acc_Ledger\get_name(), Acc_Ledger\guess_pj(), h2(), HtmlInput\hidden(), Icon_Action\infobulle(), OPEN, Acc_Ledger\select_ledger(), and HtmlInput\setReadOnly().

+ Here is the call graph for this function:

◆ insert()

Acc_Ledger_Fin::insert (   $p_array = null)

save also into quant_fin

Definition at line 744 of file acc_ledger_fin.class.php.

745 {
746 global $g_parameter;
747
748 if ( ! $this->get_is_loaded()) {
749 $this->load();
750 }
751 bcscale(2);
752 $internal_code="";
753 $oid=0;
754 extract($p_array, EXTR_SKIP);
755 $ret='';
756 // Debit = banque
757 $bank_id=$this->get_bank();
758 $fBank=new Fiche($this->db, $bank_id);
759 $e_bank_account=$fBank->strAttribut(ATTR_DEF_QUICKCODE);
760 // Get the saldo
761 $pPeriode=new Periode($this->db);
762 $sposte=$fBank->strAttribut(ATTR_DEF_ACCOUNT);
763 // if 2 accounts, take only the debit one for customer
764 if (strpos($sposte, ',')!=0)
765 {
766 $array=explode(',', $sposte);
767 $poste_val=$array[0];
768 }
769 else
770 {
771 $poste_val=$sposte;
772 }
773
774 $acc_account=new Acc_Account_Ledger($this->db, $poste_val);
775
776 // If date = deposit date
777 if ($chdate==1)
778 {
779 if ($this->check_periode()==true)
780 {
781 $pPeriode->p_id=$periode;
782 }
783 else
784 {
785 $pPeriode->find_periode($e_date);
786 }
787 $exercice=$pPeriode->get_exercice();
788 $filter_year=" j_tech_per in (select p_id from parm_periode where p_exercice='".$exercice."')";
789 $asolde=$acc_account->get_solde_detail($filter_year);
790 $deb=$asolde['debit'];
791 $cred=$asolde['credit'];
792 $solde=bcsub($deb, $cred);
793 $new_solde=$solde;
794 }
795
796
797
798
799 try
800 {
801 $this->db->start();
802 $amount=0.0;
803 $idx_operation=0;
804 $ret='<table class="result" >';
805 $ret.=tr(th(_('Date')).th(_('n° interne')).th(_('Quick Code'))
806 .th(_('Nom')).th(_('Libellé')).th(_('Montant'), ' style="text-align:right"'));
807 // Credit = goods
808 $get_solde=true;
809
810 $acc_currency=new Acc_Currency($this->db, $this->currency_id);
811
812 // get the currency_rate when we have one date for all the operations
813 if ($chdate!=2)
814 {
815 $currency_rate=$acc_currency->get_rate_date($e_date);
816 }
817 if (DEBUGNOALYSS>1)
818 {
819 printf("<p> currency_id %s </p>",$this->currency_id);
820 printf("<p> rate %s </p>", $currency_rate);
821 }
822 // for each item
823 for ($i=0; $i<$nb_item; $i++)
824 {
825 // insert it into the database
826 // and quit the loop ?
827 if (noalyss_strlentrim(${"e_other$i"})==0)
828 continue;
829
830 // get the currency_rate when each operation has its own date
831 if ($chdate==2)
832 {
833 $e_date=${'dateop'.$i};
834 $currency_rate=$acc_currency->get_rate_date($e_date);
835 }
836 // if date is date of operation
837 if ($chdate==2&&$get_solde)
838 {
839 $get_solde=false;
840 if ($this->check_periode()==true&&isset($p_array['periode']))
841 {
842 $pPeriode->p_id=$periode;
843 }
844 else
845 {
846 $pPeriode->find_periode($e_date);
847 }
848 $exercice=$pPeriode->get_exercice();
849 $filter_year=" j_tech_per in (select p_id from parm_periode where p_exercice='".
850 sql_string($exercice)."')";
851 $solde=$acc_account->get_solde($filter_year);
852 $new_solde=$solde;
853 }
854 $fPoste=new Fiche($this->db);
855 $fPoste->get_by_qcode(${"e_other$i"});
856
857 // convert to EUR if needed and round it
858 $amount_input=${"e_other$i"."_amount"}=round(${"e_other$i"."_amount"}, 2);
859 $amount_eur=bcdiv($amount_input, $currency_rate);
860
861 $amount=bcadd($amount, $amount_input);
862
863 // Record a line for the bank
864 // Compute the j_grpt
865 $seq=$this->db->get_next_seq('s_grpt');
866
867 $acc_operation=new Acc_Operation($this->db);
868 $acc_operation->date=$e_date;
869 $sposte=$fPoste->strAttribut(ATTR_DEF_ACCOUNT);
870 // if 2 accounts
871 if (strpos($sposte, ',')!=0)
872 {
873 $array=explode(',', $sposte);
874 if (${"e_other$i"."_amount"}<0)
875 $poste_val=$array[1];
876 else
877 $poste_val=$array[0];
878 }
879 else
880 {
881 $poste_val=$sposte;
882 }
883
884
885 $acc_operation->poste=$poste_val;
886 $acc_operation->amount=bcmul($amount_eur, -1);
887 $acc_operation->grpt=$seq;
888 $acc_operation->jrn=$p_jrn;
889 $acc_operation->type='d';
890
891 if (isset($periode))
892 $tperiode=$periode;
893 else
894 {
895 $per=new Periode($this->db);
896 $tperiode=$per->find_periode($e_date);
897 }
898 $acc_operation->periode=$tperiode;
899 $acc_operation->qcode=${"e_other".$i};
900 $j_id_currency=$acc_operation->insert_jrnx();
901
902 // -- Insert into Operation Currency
903 $operation_currency=new Operation_currency_SQL($this->db);
904 $operation_currency->oc_amount=$amount_input;
905 $operation_currency->oc_vat_amount=0;
906 $operation_currency->oc_price_unit=0;
907 $operation_currency->j_id=$j_id_currency;
908 $operation_currency->insert();
909
910 $acc_operation=new Acc_Operation($this->db);
911 $acc_operation->date=$e_date;
912 $sposte=$fBank->strAttribut(ATTR_DEF_ACCOUNT);
913
914 // if 2 accounts, use the first one if DEB otherwise the second one
915 if (strpos($sposte, ',')!=0)
916 {
917 $array=explode(',', $sposte);
918 if (${"e_other$i"."_amount"}<0)
919 $poste_val=$array[1];
920 else
921 $poste_val=$array[0];
922 }
923 else
924 {
925 $poste_val=$sposte;
926 }
927
928 $acc_operation->poste=$poste_val;
929 $acc_operation->amount=$amount_eur;
930 $acc_operation->grpt=$seq;
931 $acc_operation->jrn=$p_jrn;
932 $acc_operation->type='d';
933 $acc_operation->periode=$tperiode;
934 $acc_operation->qcode=$e_bank_account;
935 $j_id=$acc_operation->insert_jrnx();
936
937 // -- Insert into Operation Currency
938 $operation_currency=new Operation_currency_SQL($this->db);
939 $operation_currency->oc_amount=$amount_input;
940 $operation_currency->oc_vat_amount=0;
941 $operation_currency->oc_price_unit=0;
942 $operation_currency->j_id=$j_id;
943 $operation_currency->insert();
944
945 if (sql_string(${"e_other$i"."_comment"})==null)
946 {
947 // if comment is blank set a default one
948 $comment=sprintf(_(" compte : %s a %s "), $fBank->strAttribut(ATTR_DEF_NAME),
949 $fPoste->strAttribut(ATTR_DEF_NAME)
950 );
951 }
952 else
953 {
954 $comment=strip_tags(${'e_other'.$i.'_comment'});
955 }
956
957
958 $acc_operation=new Acc_Operation($this->db);
959 $acc_operation->jrn=$p_jrn;
960 $acc_operation->amount=abs($amount_eur);
961 $acc_operation->date=$e_date;
962 $acc_operation->desc=$comment;
963 $acc_operation->grpt=$seq;
964 $acc_operation->periode=$tperiode;
965 $acc_operation->mt=$mt;
966 $idx_operation++;
967 $acc_operation->pj='';
968 $acc_operation->currency_id=$this->currency_id;
969 $acc_operation->currency_rate=$currency_rate;
970 $acc_operation->currency_rate_ref=$currency_rate;
971
972 if (trim($e_pj)!=''&&$this->numb_operation()==true)
973 $acc_operation->pj=$e_pj.str_pad($idx_operation, 3, 0, STR_PAD_LEFT);
974
975 if (trim($e_pj)!=''&&$this->numb_operation()==false)
976 $acc_operation->pj=$e_pj;
977
978 $jr_id=$acc_operation->insert_jrn();
979 // $acc_operation->set_pj();
980 $this->db->exec_sql('update jrn set jr_pj_number=$1 where jr_id=$2', array($acc_operation->pj, $jr_id));
981 $internal=$this->compute_internal_code($seq);
982
983 if (trim(${"e_concerned".$i})!="")
984 {
985 if (strpos(${"e_concerned".$i}, ',')!=0)
986 {
987 $aRapt=explode(',', ${"e_concerned".$i});
988 foreach ($aRapt as $rRapt)
989 {
990 // Add a "concerned operation to bound these op.together
991 //
992 $rec=new Acc_Reconciliation($this->db);
993 $rec->set_jr_id($jr_id);
994
995 if (isNumber($rRapt)==1)
996 {
997 $rec->insert($rRapt);
998 try
999 {
1000 $oppaid=new Acc_Operation($this->db);
1001 $oppaid->set_id($rRapt);
1002 $oppaid->set_paid();
1003 }
1004 catch (Exception $ex)
1005 {
1006 record_log($ex->getTraceAsString());
1007 echo _('Attention , erreur Acc_Ledger_Fin::insert , coche paiement');
1008 }
1009 }
1010 }
1011 }
1012 else
1013 if (isNumber(${"e_concerned".$i})==1)
1014 {
1015 $rec=new Acc_Reconciliation($this->db);
1016 $rec->set_jr_id($jr_id);
1017 $rec->insert(${"e_concerned$i"});
1018 try
1019 {
1020 $oppaid=new Acc_Operation($this->db);
1021 $oppaid->set_id(${"e_concerned".$i});
1022 $conc_amount=$oppaid->get_amount();
1023 if ($conc_amount==$acc_operation->amount)
1024 {
1025 $oppaid->set_paid();
1026 }
1027 }
1028 catch (Exception $ex)
1029 {
1030 record_log($ex->getTraceAsString());
1031 echo _('Attention , erreur Acc_Ledger_Fin::insert , coche paiement');
1032 }
1033 }
1034 }
1035
1036 // Set Internal code
1037 $this->grpt_id=$seq;
1038 /**
1039 * save also into quant_fin
1040 */
1041 $this->insert_quant_fin($fBank->id, $jr_id, $fPoste->id, $amount_eur, $j_id_currency);
1042
1043 if ($g_parameter->MY_ANALYTIC!="nu")
1044 {
1045 // for each item, insert into operation_analytique */
1046 $op=new Anc_Operation($this->db);
1047 $op->set_currency_rate($currency_rate);
1048 $op->oa_group=$this->db->get_next_seq("s_oa_group"); /* for analytic */
1049 $op->j_id=$j_id_currency;
1050 $op->oa_date=$e_date;
1051 $op->oa_debit='f';
1052 $op->oa_description=sql_string($comment);
1053 $op->save_form_plan($_POST, $i, $j_id_currency);
1054 }
1055
1056
1057 $this->update_internal_code($internal);
1058
1059 $js_detail=HtmlInput::detail_op($jr_id, $internal);
1060 // Compute display
1061 $row=td($e_date)
1062 .td($js_detail)
1063 .td(${"e_other$i"})
1064 .td($fPoste->strAttribut(ATTR_DEF_NAME))
1065 .td(${"e_other".$i."_comment"})
1066 .td(nbm(${"e_other$i"."_amount"}), 'class="num"');
1067 $class=($i%2==0)?' class="even" ':' class="odd" ';
1068 $ret.=tr($row, $class);
1069
1070 if ($i==0)
1071 {
1072 // first record we upload the files and
1073 // keep variable to update other row of jrn
1074 if (isset($_FILES['pj']))
1075 $oid=$this->db->save_receipt($seq);
1076 }
1077 else
1078 {
1079 if ($oid!=0)
1080 {
1081 $this->db->exec_sql("update jrn set jr_pj=$1 , jr_pj_name=$2,
1082 jr_pj_type=$3 where jr_grpt_id=$4",
1083 array($oid, $_FILES['pj']['name'], $_FILES['pj']['type'], $seq));
1084 }
1085 }
1086 } // for nbitem
1087 // increment pj
1088 if (noalyss_strlentrim($e_pj)!=0)
1089 {
1090 $this->inc_seq_pj();
1091 }
1092 $ret.='</table>';
1093 }
1094 catch (Exception $e)
1095 {
1096 $r='<span class="error">'.
1097 'Erreur dans l\'enregistrement '.
1098 __FILE__.':'.__LINE__.' '.
1099 $e->getMessage();
1100 $this->db->rollback();
1101 record_log($e);
1102 throw new Exception($r);
1103 }
1104 $this->db->commit();
1105 if ($acc_currency->get_id()==0)
1106 {
1107 $r="";
1108 $r.=sprintf("<br>"._("Ancien solde %s %s"), nbm($solde), $acc_currency->get_code());
1109 $new_solde=bcadd($new_solde, $amount);
1110 $r.=sprintf("<br>"._("Nouveau solde %s %s"), nbm($new_solde), $acc_currency->get_code());
1111 $ret.=$r;
1112 }
1113 else
1114 {
1115 $solde_cur=$fBank->get_bk_balance_currency();
1116 $r="";
1117 $r.=sprintf("<br>"._("Ancien solde %s %s"), nbm($solde_cur), $acc_currency->get_code());
1118 $new_solde=bcadd($solde_cur, $amount);
1119 $r.=sprintf("<br>"._("Nouveau solde %s %s"), nbm($new_solde), $acc_currency->get_code());
1120 $ret.=$r;
1121 }
1122 return $ret;
1123 }
isNumber($p_int)
Definition: ac_common.php:215
th($p_string, $p_extra='', $raw='')
Definition: ac_common.php:58
record_log($p_message)
Record an error message into the log file of the server.
Definition: ac_common.php:1342
sql_string($p_string)
Fix the problem with the quote char for the database.
Definition: ac_common.php:511
$op
Definition: ajax_admin.php:38
$jr_id
Definition: ajax_ledger.php:44
$ex
Definition: balance.inc.php:45
$class
insert_quant_fin($p_bankid, $p_jrid, $p_otherid, $p_amount, $p_j_id_currency)
insert into the quant_fin table
numb_operation()
return true is we numbere each operation
$currency_id
!< default number of rows by default 10
inc_seq_pj()
increment the sequence for the pj
compute_internal_code($p_grpt)
compute the internal code of the saved operation and set the $this->jr_internal to the computed value
$row
!< database connextion
update_internal_code($p_internal)
this file match the tables jrn & jrnx the purpose is to remove or save accountant writing to these ta...
new class for managing the reconciliation it must be used instead of the function InsertRapt,...
static detail_op($p_jr_id, $p_mesg)
return a string containing the html code for calling the modifyOperation
ORM abstract of the table public.operation_currency.
$_POST['ac']
Definition: do.php:310

References $_POST, $amount, $array, $class, $cred, Acc_Ledger\$currency_id, $deb, $e, $e_date, $ex, $exercice, $filter_year, $g_parameter, $i, $j_id, $jr_id, $op, $p_array, $p_jrn, $per, $periode, $pPeriode, $r, $ret, Acc_Ledger\$row, $seq, $solde, ATTR_DEF_ACCOUNT, ATTR_DEF_NAME, ATTR_DEF_QUICKCODE, Acc_Ledger\check_periode(), Acc_Ledger\compute_internal_code(), db, HtmlInput\detail_op(), get_bank(), Acc_Ledger\get_is_loaded(), Acc_Ledger\inc_seq_pj(), insert_quant_fin(), isNumber(), nbm(), noalyss_strlentrim(), numb_operation(), record_log(), sql_string(), td(), th(), tr(), and Acc_Ledger\update_internal_code().

+ Here is the call graph for this function:

◆ insert_quant_fin()

Acc_Ledger_Fin::insert_quant_fin (   $p_bankid,
  $p_jrid,
  $p_otherid,
  $p_amount,
  $p_j_id_currency 
)

insert into the quant_fin table

Parameters
integer$bank_idis the f_id of the bank
integer$jr_idis the jrn.jr_id of the operation
integer$otheris the f_id of the benefit
integer$amountis the amount
integer$p_j_idis the j_id of the operation

Definition at line 1167 of file acc_ledger_fin.class.php.

1168 {
1169 $sql="INSERT INTO quant_fin(qf_bank, jr_id, qf_other, qf_amount,j_id)
1170 VALUES ($1, $2, $3, $4,$5);";
1171
1172 $this->db->exec_sql($sql, array($p_bankid, $p_jrid, $p_otherid, round($p_amount, 2), $p_j_id_currency));
1173 }

References $sql, and db.

Referenced by insert().

◆ numb_operation()

Acc_Ledger_Fin::numb_operation ( )

return true is we numbere each operation

Definition at line 1151 of file acc_ledger_fin.class.php.

1152 {
1153 $a=$this->db->get_value('select jrn_def_num_op from jrn_def where jrn_def_id=$1', array($this->id));
1154 if ($a==1)
1155 return true;
1156 return false;
1157 }

References $a, and db.

Referenced by insert().

◆ verify_operation()

Acc_Ledger_Fin::verify_operation (   $p_array)

Verify that the data are correct before inserting or confirming.

Parameters
anarray (usually $_POST)
Returns
String
Exceptions
Exceptionon error occurs

Reimplemented from Acc_Ledger.

Definition at line 50 of file acc_ledger_fin.class.php.

51 {
52 global $g_user;
53 if (is_array($p_array)==false||empty($p_array))
54 throw new Exception("Array empty");
55 /*
56 * Check needed value
57 */
58 check_parameter($p_array, 'p_jrn');
59
60 extract($p_array, EXTR_SKIP);
61 /* check for a double reload */
62 if (isset($mt)&&$this->db->count_sql('select jr_mt from jrn where jr_mt=$1', array($mt))!=0)
63 throw new Exception(_('Double Encodage'), 5);
64
65 /* check if we can write into this ledger */
66 if ($g_user->check_jrn($p_jrn)!='W')
67 throw new Exception(_('Accès interdit'), 20);
68
69 /* check if there is a bank account linked to the ledger */
70 $bank_id=$this->get_bank();
71
72 if ($this->db->count()==0)
73 throw new Exception("Ce journal n'a pas de compte en banque, allez dans paramètre->journal pour régler cela");
74 /* check if the accounting of the bank is correct */
75 $fBank=new Fiche($this->db, $bank_id);
76 $bank_accounting=$fBank->strAttribut(ATTR_DEF_ACCOUNT);
77 if (trim($bank_accounting)=='')
78 throw new Exception('Le poste comptable du compte en banque de ce journal est invalide');
79
80 /* check if the account exists */
81 $poste=new Acc_Account_Ledger($this->db, $bank_accounting);
82 if ($poste->load()==false)
83 throw new Exception('Le poste comptable du compte en banque de ce journal est invalide');
84 if ($chdate!=1&&$chdate!=2)
85 throw new Exception('Le choix de date est invalide');
86 if ($chdate==1)
87 {
88 /* check if the date is valid */
89 if (isDate($e_date)==null)
90 {
91 throw new Exception('Date invalide', 2);
92 }
93 $oPeriode=new Periode($this->db);
94 if ($this->check_periode()==false)
95 {
96 $periode=$oPeriode->find_periode($e_date);
97 }
98 else
99 {
100 $oPeriode->p_id=$periode;
101 list ($min, $max)=$oPeriode->get_date_limit();
102 if (cmpDate($e_date, $min)<0||
103 cmpDate($e_date, $max)>0)
104 throw new Exception(_('Date et periode ne correspondent pas'), 6);
105 }
106
107 /* check if the periode is closed */
108 if ($this->is_closed($periode)==1)
109 {
110 throw new Exception(_('Periode fermee'), 6);
111 }
112
113 /* check if we are using the strict mode */
114 if ($this->check_strict()==true)
115 {
116 /* if we use the strict mode, we get the date of the last
117 operation */
118 $last_date=$this->get_last_date();
119 if ($last_date!=null&&cmpDate($e_date, $last_date)<0)
120 throw new Exception(_('Vous utilisez le mode strict la dernière operation est à la date du ')
121 .$last_date._(' vous ne pouvez pas encoder à une date antérieure'), 15);
122 }
123 }
124
125 $acc_pay=new Acc_Operation($this->db);
126
127 $nb=0;
128 $tot_amount=0;
129 //----------------------------------------
130 // foreach item
131 //----------------------------------------
132 for ($i=0; $i<$nb_item; $i++)
133 {
134 if (noalyss_strlentrim(${'e_other'.$i})==0)
135 continue;
136 /* check if amount are numeric and */
137 if (isNumber(${'e_other'.$i.'_amount'})==0)
138 throw new Exception('La fiche '.${'e_other'.$i}.'a un montant invalide ['.${'e_other'.$i.'_amount'}.']',
139 6);
140
141 /* compute the total */
142 $tot_amount+=round(${'e_other'.$i.'_amount'}, 2);
143 /* check if all card has a ATTR_DEF_ACCOUNT */
144 $fiche=new Fiche($this->db);
145 $fiche->get_by_qcode(${'e_other'.$i});
146 if ($fiche->empty_attribute(ATTR_DEF_ACCOUNT)==true)
147 throw new Exception('La fiche '.${'e_other'.$i}.'n\'a pas de poste comptable', 8);
148
149 $sposte=$fiche->strAttribut(ATTR_DEF_ACCOUNT);
150 // if 2 accounts, take only the debit one for customer
151 if (strpos($sposte, ',')!=0)
152 {
153 $array=explode(',', $sposte);
154 $poste_val=$array[1];
155 }
156 else
157 {
158 $poste_val=$sposte;
159 }
160 /* The account exists */
161 $poste=new Acc_Account_Ledger($this->db, $poste_val);
162 if ($poste->load()==false)
163 {
164 throw new Exception('Pour la fiche '.${'e_other'.$i}.' le poste comptable ['.$poste->id.'n\'existe pas',
165 9);
166 }
167 /* Check if the card belong to the ledger */
168 $fiche=new Fiche($this->db);
169 $fiche->get_by_qcode(${'e_other'.$i});
170 if ($fiche->belong_ledger($p_jrn, 'deb')!=1)
171 throw new Exception('La fiche '.${'e_other'.$i}.'n\'est pas accessible à ce journal', 10);
172 if ($chdate==2)
173 {
174 {/* check if the date is valid */
175 if (isDate(${'dateop'.$i})==null)
176 {
177 throw new Exception('Date invalide', 2);
178 }
179 $oPeriode=new Periode($this->db);
180 if ($this->check_periode()==false)
181 {
182 $periode=$oPeriode->find_periode(${'dateop'.$i});
183 }
184 else
185 {
186 $oPeriode->p_id=$periode;
187 list ($min, $max)=$oPeriode->get_date_limit();
188 if (cmpDate(${'dateop'.$i}, $min)<0||
189 cmpDate(${'dateop'.$i}, $max)>0)
190 throw new Exception(_('Date et periode ne correspondent pas'), 6);
191 }
192
193 /* check if the periode is closed */
194 if ($this->is_closed($periode)==1)
195 {
196 throw new Exception(_('Periode fermee'), 6);
197 }
198
199 /* check if we are using the strict mode */
200 if ($this->check_strict()==true)
201 {
202 /* if we use the strict mode, we get the date of the last
203 operation */
204 $last_date=$this->get_last_date();
205 if ($last_date!=null&&cmpDate(${'dateop'.$i}, $last_date)<0)
206 throw new Exception(_('Vous utilisez le mode strict la dernière operation est à la date du ')
207 .$last_date._(' vous ne pouvez pas encoder à une date antérieure'), 15);
208 }
209 }
210 }
211 $nb++;
212 }
213 if ($nb==0)
214 throw new Exception('Il n\'y a aucune opération', 12);
215
216 /* Check if the last_saldo and first_saldo are correct */
217 if (noalyss_strlentrim($last_sold)!=0&&isNumber($last_sold)&&noalyss_strlentrim($first_sold)!=0&&isNumber($first_sold)
218 )
219 {
220 $diff=bcsub($last_sold,$first_sold,2);
221 $diff=bcsub($diff,$tot_amount,2);
222 $calc=bcadd($first_sold, $tot_amount, 2);
223 if ($first_sold!=0||$last_sold!=0)
224 {
225 if ($diff!=0)
226 {
227 throw new Exception(sprintf(_('Le montant de l\'extrait est incorrect,'.
228 " solde donné [ %s ]".
229 " solde calculé [%s] , différence de [%s]"), $last_sold, $calc,
230 $diff), 13);
231 }
232 }
233 }
234 }
cmpDate($p_date, $p_date_oth)
Compare 2 dates.
Definition: ac_common.php:188
$nb
!< type of the ledger ACH ODS FIN VEN or GL
is_closed($p_periode)
check if the current ledger is closed
get_last_date()
get the date of the last operation
check_strict()
Check if a Dossier is using the strict mode or not.
$oPeriode
Definition: do.php:154
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...

References $array, $diff, $e_date, $fiche, $g_user, $i, $max, $min, Acc_Ledger\$nb, $oPeriode, $p_array, $p_jrn, $periode, $poste, $tot_amount, ATTR_DEF_ACCOUNT, check_parameter(), Acc_Ledger\check_periode(), Acc_Ledger\check_strict(), cmpDate(), db, get_bank(), Acc_Ledger\get_last_date(), Acc_Ledger\is_closed(), isDate(), isNumber(), and noalyss_strlentrim().

+ Here is the call graph for this function:

The documentation for this class was generated from the following file: