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

handle the param_detail type Account_Tva The t_id gives the type of total More...

Inheritance diagram for Rapav_dd_Account_Tva:
Inheritance graph
Collaboration diagram for Rapav_dd_Account_Tva:
Collaboration graph

Public Member Functions

 compute ($p_start, $p_end)
 Compute the amount of TVA or Account, call internally private functions. 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...
 

Private Member Functions

 compute_tva ($p_start, $p_end)
 compute the amount of tva using the given account in either the ledger ACH or VEN following the $this->form->jrn_def_type. More...
 
 compute_amount ($p_start, $p_end)
 compute the amount of account using the given tva_id in either the ledger ACH or VEN following the $this->form->jrn_def_type. More...
 

Detailed Description

handle the param_detail type Account_Tva The t_id gives the type of total

See Also
RAPAV_Account_Tva

Definition at line 989 of file class_rapav_declaration.php.

Member Function Documentation

Rapav_dd_Account_Tva::compute (   $p_start,
  $p_end 
)

Compute the amount of TVA or Account, call internally private functions.

See Also
Rapav_dd_Account_Tva::computa_amount Rapav_dd_Account_Tva::compute_tva
Parameters
$p_startstart date
$p_endend date
Returns
amount computed
Exceptions
Exception

Definition at line 1097 of file class_rapav_declaration.php.

References $amount, compute_amount(), and compute_tva().

1098  {
1099  bcscale(2);
1100  // Retrieve the account for the tva_id, we need the DEB for VEN and CRED for ACH
1101  //
1102  // tt_id gives the type of total
1103  // - 0 TVA + Account
1104  // - 1 TVA
1105  // - 2 Account
1106  switch ($this->form->tt_id)
1107  {
1108  case 0:
1109  $t1_amount = $this->compute_amount($p_start, $p_end);
1110  $t2_amount = $this->compute_tva($p_start, $p_end);
1111  $amount = bcadd($t1_amount, $t2_amount);
1112  break;
1113  case 1:
1114  $amount = $this->compute_tva($p_start, $p_end);
1115  $amount = bcadd($amount, 0);
1116  break;
1117 
1118  case 2:
1119  $amount = $this->compute_amount($p_start, $p_end);
1120  $amount = bcadd($amount, 0);
1121  break;
1122 
1123  default:
1124  throw new Exception('Type de total invalide');
1125  break;
1126  }
1127  return $amount;
1128  }
compute_tva($p_start, $p_end)
compute the amount of tva using the given account in either the ledger ACH or VEN following the $this...
compute_amount($p_start, $p_end)
compute the amount of account using the given tva_id in either the ledger ACH or VEN following the $t...
Rapav_dd_Account_Tva::compute_amount (   $p_start,
  $p_end 
)
private

compute the amount of account using the given tva_id in either the ledger ACH or VEN following the $this->form->jrn_def_type.

Set the $this->errcode if something wrong has happened

Parameters
$p_startstart date
$p_endend date
Returns
amount
Parameters
type$p_start
type$p_end
Returns
|int

Definition at line 1052 of file class_rapav_declaration.php.

References $amount, $sql, and RAPAV\get_sql_date().

Referenced by compute().

1053  {
1054  $filter_ledger = "";
1055  if ($this->form->jrn_def_id != "")
1056  {
1057  $filter_ledger = " and j_jrn_def = " . sql_string($this->form->jrn_def_id);
1058  }
1059  $sql_date=RAPAV::get_sql_date($this->form->date_paid );
1060 
1061  if ($this->form->jrn_def_type == 'ACH')
1062  {
1063  $sql = "select coalesce(sum(qp_price),0) as amount from quant_purchase join jrnx as jrn1 using (j_id)
1064  where qp_vat_code=$1 $sql_date
1065  and j_poste::text like ($4) $filter_ledger";
1066 
1067  $amount = $this->cn->get_value($sql, array($this->form->tva_id,
1068  $p_start,
1069  $p_end,
1070  $this->form->tmp_val));
1071  return $amount;
1072  }
1073  if ($this->form->jrn_def_type == 'VEN')
1074  {
1075  $sql = "select coalesce(sum(qs_price),0) as amount from quant_sold
1076  join jrnx as jrn1 using (j_id)
1077  where qs_vat_code=$1 $sql_date
1078  and j_poste::text like ($4) $filter_ledger";
1079  $amount = $this->cn->get_value($sql, array($this->form->tva_id,
1080  $p_start,
1081  $p_end,
1082  $this->form->tmp_val));
1083  return $amount;
1084  }
1085  $this->errcode = 'Erreur dans le journal';
1086  return 0;
1087  }
static get_sql_date($p_date, $p_prefix="")
Compute the SQL for the date.
Definition: class_rapav.php:84
$sql
Rapav_dd_Account_Tva::compute_tva (   $p_start,
  $p_end 
)
private

compute the amount of tva using the given account in either the ledger ACH or VEN following the $this->form->jrn_def_type.

set the $this->errcode if something wrong has happened

Parameters
$p_startstart date
$p_endend date
Returns
amount

Definition at line 1000 of file class_rapav_declaration.php.

References $amount, $sql, and RAPAV\get_sql_date().

Referenced by compute().

1001  {
1002  $filter_ledger = "";
1003  if ($this->form->jrn_def_id != "")
1004  {
1005  $filter_ledger = " and j_jrn_def = " . sql_string($this->form->jrn_def_id);
1006  }
1007  $sql_date=RAPAV::get_sql_date($this->form->date_paid );
1008 
1009  if ($this->form->jrn_def_type == 'ACH')
1010  {
1011 
1012  $sql = "select coalesce(sum(qp_vat),0) as amount
1013  from quant_purchase join jrnx as jrn1 using (j_id)
1014  where qp_vat_code=$1
1015  $sql_date
1016  and j_poste::text like ($4) $filter_ledger";
1017  $amount = $this->cn->get_value($sql, array($this->form->tva_id,
1018  $p_start,
1019  $p_end,
1020  $this->form->tmp_val));
1021  return $amount;
1022  }
1023  if ($this->form->jrn_def_type == 'VEN')
1024  {
1025  $sql = "select coalesce(sum(qs_vat),0) as amount
1026  from quant_sold join jrnx as jrn1 using (j_id)
1027  where qs_vat_code=$1
1028  $sql_date
1029  and j_poste::text like ($4) $filter_ledger";
1030 
1031  $amount = $this->cn->get_value($sql, array($this->form->tva_id,
1032  $p_start,
1033  $p_end,
1034  $this->form->tmp_val));
1035  return $amount;
1036  }
1037  $this->errcode = 'Erreur dans le journal';
1038  return 0;
1039  }
static get_sql_date($p_date, $p_prefix="")
Compute the SQL for the date.
Definition: class_rapav.php:84
$sql
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: