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

handle the param_detail type Account The type_sum_account gives the type of total More...

Inheritance diagram for Rapav_dd_Reconcile:
Inheritance graph
Collaboration diagram for Rapav_dd_Reconcile:
Collaboration graph

Public Member Functions

 compute ($p_start, $p_end)
 
 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

handle the param_detail type Account The type_sum_account gives the type of total

Definition at line 1265 of file class_rapav_declaration.php.

Member Function Documentation

Rapav_dd_Reconcile::compute (   $p_start,
  $p_end 
)

Definition at line 1268 of file class_rapav_declaration.php.

References $amount, $cn, and $sql.

1269  {
1270  global $cn;
1271  bcscale(2);
1272  $filter_ledger = "";
1273  if ($this->form->jrn_def_id != "")
1274  {
1275  $filter_ledger = " and jrn1.j_jrn_def = " . sql_string($this->form->jrn_def_id);
1276  }
1277  switch ($this->form->type_sum_account)
1278  {
1279  // Saldo
1280  case 1:
1281  case 2:
1282  // Compute D-C
1283  $sql = "
1284  select sum(tv_amount.jrnx_amount)
1285  from (
1286  select distinct jrn1.j_id,j1.jr_id,
1287  case when jrn1.j_debit = 't' then jrn1.j_montant else jrn1.j_montant*(-1) end as jrnx_amount
1288  from jrnx as jrn1
1289  join jrnx as jrn2 on (jrn1.j_grpt=jrn2.j_grpt)
1290  join jrn as j1 on (jrn1.j_grpt=j1.jr_grpt_id)
1291  where
1292  jrn1.j_poste like $1
1293  and jrn2.j_poste like $2
1294  $filter_ledger
1295  ) as tv_amount
1296  join jrn_rapt as rap1 on (rap1.jr_id=tv_amount.jr_id or rap1.jra_concerned=tv_amount.jr_id)
1297  join (select distinct jrn3.j_id,j2.jr_id
1298  from jrnx as jrn3
1299  join jrn as j2 on (j2.jr_grpt_id=jrn3.j_grpt)
1300  where
1301  (jrn3.j_date >= to_date($3,'DD.MM.YYYY') and jrn3.j_date <= to_date($4,'DD.MM.YYYY')) and
1302  jrn3.j_poste like $5) as reconc on (rap1.jr_id=reconc.jr_id or rap1.jra_concerned=reconc.jr_id)
1303 
1304  ";
1305  $amount = $cn->get_value($sql, array(
1306  $this->form->tmp_val,
1307  $this->form->with_tmp_val,
1308  $p_start,
1309  $p_end,
1310  $this->form->operation_pcm_val
1311  ));
1312  // if C-D is asked then reverse the result
1313  if ($this->form->type_sum_account == 2)
1314  $amount = bcmul($amount, -1);
1315  break;
1316  // Only DEBIT
1317  case 3:
1318  $sql = "
1319  select sum(tv_amount.jrnx_amount)
1320  from (
1321  select distinct jrn1.j_id,j1.jr_id,
1322  jrn1.j_montant as jrnx_amount
1323  from jrnx as jrn1
1324  join jrnx as jrn2 on (jrn1.j_grpt=jrn2.j_grpt)
1325  join jrn as j1 on (jrn1.j_grpt=j1.jr_grpt_id)
1326  where
1327  jrn1.j_poste like $1
1328  and jrn2.j_poste like $2
1329  and jrn1.j_debit='t'
1330  $filter_ledger
1331  ) as tv_amount
1332  join jrn_rapt as rap1 on (rap1.jr_id=tv_amount.jr_id or rap1.jra_concerned=tv_amount.jr_id)
1333  join (select distinct jrn3.j_id,j2.jr_id
1334  from jrnx as jrn3
1335  join jrn as j2 on (j2.jr_grpt_id=jrn3.j_grpt)
1336  where
1337  (jrn3.j_date >= to_date($3,'DD.MM.YYYY') and jrn3.j_date <= to_date($4,'DD.MM.YYYY')) and
1338  jrn3.j_poste like $5) as reconc on (rap1.jr_id=reconc.jr_id or rap1.jra_concerned=reconc.jr_id)
1339 
1340  ";
1341  $amount = $cn->get_value($sql, array(
1342  $this->form->tmp_val,
1343  $this->form->with_tmp_val,
1344  $p_start,
1345  $p_end,
1346  $this->form->operation_pcm_val
1347  ));
1348  break;
1349  // Only CREDIT
1350  case 4:
1351  $sql = "
1352  select sum(tv_amount.jrnx_amount)
1353  from (
1354  select distinct jrn1.j_id,j1.jr_id,
1355  jrn1.j_montant as jrnx_amount
1356  from jrnx as jrn1
1357  join jrnx as jrn2 on (jrn1.j_grpt=jrn2.j_grpt)
1358  join jrn as j1 on (jrn1.j_grpt=j1.jr_grpt_id)
1359  where
1360  jrn1.j_poste like $1
1361  and jrn2.j_poste like $2
1362  and jrn1.j_debit='f'
1363  $filter_ledger
1364  ) as tv_amount
1365  join jrn_rapt as rap1 on (rap1.jr_id=tv_amount.jr_id or rap1.jra_concerned=tv_amount.jr_id)
1366  join (select distinct jrn3.j_id,j2.jr_id
1367  from jrnx as jrn3
1368  join jrn as j2 on (j2.jr_grpt_id=jrn3.j_grpt)
1369  where
1370  (jrn3.j_date >= to_date($3,'DD.MM.YYYY') and jrn3.j_date <= to_date($4,'DD.MM.YYYY')) and
1371  jrn3.j_poste like $5) as reconc on (rap1.jr_id=reconc.jr_id or rap1.jra_concerned=reconc.jr_id)
1372 
1373  ";
1374  $amount = $cn->get_value($sql, array(
1375  $this->form->tmp_val,
1376  $this->form->with_tmp_val,
1377  $p_start,
1378  $p_end,
1379  $this->form->operation_pcm_val
1380  ));
1381  break;
1382 
1383  default:
1384  if (DEBUG)
1385  var_dump($this);
1386  die(__FILE__ . ":" . __LINE__ . " UNKNOW SUM TYPE");
1387  break;
1388  }
1389  /*
1390  * 4 possibilities with type_sum_account
1391  */
1392  return $amount;
1393  }
$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: