Plugins  LAST
 All Data Structures Files Functions Variables Pages
Public Member Functions | Static Public Member Functions
Rapav_dd_Formula Class Reference

compute a formula More...

Inheritance diagram for Rapav_dd_Formula:
Inheritance graph
Collaboration diagram for Rapav_dd_Formula:
Collaboration graph

Public Member Functions

 compute ($p_start, $p_end)
 compute the amount for one detail of type formula rapport_advanced.formulaire_param_detail type $cn database connexion More...
 
 from_array ($p_array)
 the p_array contains a row from formulaire_param_detail it will be copied into this->form. More...
 

Static Public Member Functions

static factory ($p_array)
 create an object RAPAV_dd_Formula, RAPAV_dd_Account_Tva or Rapav_dd_compute following the idx type_detail More...
 

Detailed Description

compute a formula

See Also
Impress::parse_formula RAPAV_Formula

Definition at line 896 of file class_rapav_declaration.php.

Member Function Documentation

Rapav_dd_Formula::compute (   $p_start,
  $p_end 
)

compute the amount for one detail of type formula rapport_advanced.formulaire_param_detail type $cn database connexion

Parameters
$p_start(date) : computed start date
$p_end(date) computed start date
Returns
numeric amount computed

Definition at line 907 of file class_rapav_declaration.php.

References $amount, $cn, and $sql.

908  {
909  global $cn;
910  $sql = "";
911  if ($this->form->jrn_def_id != null)
912  {
913  $sql = ' and j_jrn_def =' . $this->form->jrn_def_id;
914  }
915  if ($this->form->date_paid == 1)
916  {
917  $sql.=sprintf(" and j_id in ( select j_id from jrnx join jrn on (j_grpt=jr_grpt_id) where jr_date_paid >= to_date('%s','DD.MM.YYYY') and jr_date_paid <= to_date ('%s','DD.MM.YYYY'))", $p_start, $p_end);
918  $p_start = '01.01.1900';
919  $p_end = '01.01.2100';
920  }
921  if ($this->form->date_paid == 2)
922  {
923  $sql.=sprintf(" and j_id in ( select j_id from jrnx join jrn on (j_grpt=jr_grpt_id) where jr_ech >= to_date('%s','DD.MM.YYYY') and jr_ech <= to_date ('%s','DD.MM.YYYY'))", $p_start, $p_end);
924  $p_start = '01.01.1900';
925  $p_end = '01.01.2100';
926  }
927  $amount = Impress::parse_formula($cn, "", $this->form->fp_formula, $p_start, $p_end, true, 1, $sql);
928  return $amount['montant'];
929  }
$sql
global $cn
static Rapav_Declaration_Detail::factory (   $p_array)
staticinherited

create an object RAPAV_dd_Formula, RAPAV_dd_Account_Tva or Rapav_dd_compute following the idx type_detail

Parameters
type$p_array
Returns
object RAPAV_dd_Formula, RAPAV_dd_Account_Tva or Rapav_dd_compute
Exceptions
ifthe type is not known

Definition at line 843 of file class_rapav_declaration.php.

References $ret.

Referenced by Rapav_Declaration_Param\compute(), and Rapav_Declaration_Param\compute_child().

844  {
845  switch ($p_array['type_detail'])
846  {
847  case '1':
848  $ret = new Rapav_dd_Formula();
849  break;
850  case '2':
851  $ret = new Rapav_dd_Account_Tva();
852  break;
853  case '3':
854  $ret = new Rapav_dd_Compute();
855  break;
856  case '4':
857  $ret = new Rapav_dd_Account();
858  break;
859  case '5':
860  $ret = new Rapav_dd_Reconcile();
861  break;
862  case '6' :
863  // For each child we have a Rapav_dd_Account
864  $ret = new Rapav_dd_Account();
865  break;
866  default:
867  throw new Exception("Type inconnu");
868  }
869 
870  $ret->from_array($p_array);
871  $ret->ddr_amount = 0; // cannot be null
872  return $ret;
873  }
$ret
handle the param_detail type Compute
handle the param_detail type Account The type_sum_account gives the type of total ...
handle the param_detail type Account The type_sum_account gives the type of total ...
handle the param_detail type Account_Tva The t_id gives the type of total
Rapav_Declaration_Detail::from_array (   $p_array)
inherited

the p_array contains a row from formulaire_param_detail it will be copied into this->form.

Parameters
type$p_arraymatch formulaire_param_detail table structure

Definition at line 880 of file class_rapav_declaration.php.

881  {
882  $this->form = new Formulaire_Param_Detail();
883  $attribute = explode(',', 'fp_id,p_id,tmp_val,tva_id,fp_formula,fp_signed,jrn_def_type,tt_id,type_detail,with_tmp_val,type_sum_account,operation_pcm_val,jrn_def_id,date_paid');
884  foreach ($attribute as $e)
885  {
886  $this->form->$e = $p_array[$e];
887  }
888  }

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