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

For Ledger of style SALE. More...

Inheritance diagram for Impacc_Csv_Sale:
Inheritance graph
Collaboration diagram for Impacc_Csv_Sale:
Collaboration graph

Public Member Functions

 adapt ($p_row)
 Transform a group of rows to an array and set $jr_date_paid useable by Acc_Ledger_Sold::insert. More...
 
 insert ($a_group, Acc_Ledger_Sold $p_ledger)
 Transfer operation with the status correct to the accountancy . More...
 
 transform ($ledger_id, $import_id)
 Works by id_group_code : all the rows with the same id_code_group belong to the same operation The operation will be written in the right ledger Only operation with a id_status = 0 can be transferred , -1 is in error and 1 means that it has already been transferred. More...
 
 check_nb_column ()
 
 record (Impacc_Csv $p_csv, Impacc_File $p_file)
 insert file into the table import_detail More...
 

Static Public Member Functions

static check (Impacc_Import_detail_SQL $row, $p_format_date, $p_thousand, $p_decimal)
 Check if Data are valid for one row. More...
 

Private Attributes

 $jr_date_paid
 < date_paid will introduced after insert More...
 
 $suggest_pj
 

Detailed Description

For Ledger of style SALE.

Definition at line 22 of file class_impacc_csv_sale.php.

Member Function Documentation

Impacc_Csv_Sale::adapt (   $p_row)

Transform a group of rows to an array and set $jr_date_paid useable by Acc_Ledger_Sold::insert.

Definition at line 29 of file class_impacc_csv_sale.php.

References $array, $cn, $g_parameter, $nb_row, and Impacc_Tool\convert_tva().

Referenced by insert().

30  {
31  bcscale(4);
32  $cn=Dossier::connect();
33 
34  // Get the code_group
35  $code_group=$p_row;
36 
37  // get all rows from this group
39  $all_row=$t->collect_objects("where import_id=$1 and id_code_group=$2",
40  array($p_row['import_id'],$p_row['id_code_group']));
41 
42  // No block due to analytic
43  global $g_parameter;
44  $g_parameter->MY_ANALYTIC="N";
45  // Save the date of payment
46  $this->jr_date_paid=$all_row[0]->id_date_payment_conv;
47 
48  // Initialise the array
49  $array=array();
50  // Suppress payment
51  $array['e_mp']=0;
52  // The first row gives all the information , the others of the group
53  // add services
54  $array['e_client']=$all_row[0]->id_acc;
55  $array['nb_item']=count($all_row);
56  $array['e_comm']=$all_row[0]->id_label;
57  // Must be transformed into DD.MM.YYYY
58  $array['e_date']=$all_row[0]->id_date_conv;
59  $array['e_ech']=$all_row[0]->id_date_limit_conv;
60  $array['e_pj']=$all_row[0]->id_pj;
61 
62  $array['mt']=microtime();
63  $array['jrn_type']='VEN';
64  $nb_row=count($all_row);
65  for ( $i=0;$i<$nb_row;$i++)
66  {
67  $array["e_march".$i]=$all_row[$i]->id_acc_second;
68  $price=$all_row[$i]->id_amount_novat_conv;
69  $quant=($all_row[$i]->id_quant_conv<>0)?$all_row[$i]->id_quant_conv:1;
70  $pricetax=$all_row[$i]->id_amount_vat_conv;
71  $price_unit=bcdiv($price,$quant);
72  $array["e_march".$i."_price"]=$price_unit;
73  $array["e_march".$i."_label"]=$all_row[$i]->id_label;
74  $array["e_march".$i."_tva_id"]=Impacc_Tool::convert_tva($all_row[$i]->tva_code); // Find code
75  $array["e_march".$i."_tva_amount"]=bcsub($pricetax,$price);
76  $array["e_quant".$i]=$quant;
77  }
78  return $array;
79  }
static convert_tva($p_code)
Find the correct TVA from the table impacc.parameter_tva.
$nb_row
Definition: search_view.php:6
global $g_parameter
Definition: ajax.php:27
if(isset($_POST['remove'])) $array
global $cn
static Impacc_Csv_Sale_Purchase::check ( Impacc_Import_detail_SQL  $row,
  $p_format_date,
  $p_thousand,
  $p_decimal 
)
staticinherited

Check if Data are valid for one row.

Parameters
$rowis an Impacc_Import_detail_SQL object
$p_format_datecheck for date_limit and date_payment
$p_thousandseparator for thousands
$p_decimalseparator for decimal
  • Check VAT CODE
  • Check Date payment
  • Check Date limit
  • Check Amount VAT
  • Check Quantity

Definition at line 50 of file class_impacc_csv_sale_purchase.php.

References $date, Impacc_Verify\check_date(), Impacc_Verify\check_tva(), and Impacc_Tool\convert_amount().

Referenced by Impacc_CSV\check().

52  {
53  $and=($row->id_message=="")?"":",";
54  //-----------------
55  ///- Check VAT CODE
56  //-----------------
57  if (Impacc_Verify::check_tva($row->tva_code)==false)
58  {
59  $row->id_message=$and."CK_TVA_INVALID";
60  $and=",";
61  }
62  //-----------------
63  ///- Check Date payment
64  //-----------------
65  if ($row->id_date_payment!="")
66  {
67  $date=Impacc_Verify::check_date($row->id_date_payment,$p_format_date);
68  if ($date==false)
69  {
70  $row->id_message=$and."CK_FORMAT_DATE";
71  $and=",";
72  } else {
73  $row->id_date_payment_conv=$date;
74  }
75  }
76  //-----------------
77  ///- Check Date limit
78  //-----------------
79  if ($row->id_date_limit!="")
80  {
81  $date=Impacc_Verify::check_date($row->id_date_limit,$p_format_date);
82  if ($date==false)
83  {
84  $row->id_message=$and."CK_FORMAT_DATE";
85  $and=",";
86  } else {
87  $row->id_date_limit_conv=$date;
88  }
89  }
90 
91  //-----------------
92  ///- Check Amount VAT
93  //-----------------
94  $row->id_amount_vat_conv=Impacc_Tool::convert_amount($row->id_amount_vat,
95  $p_thousand, $p_decimal);
96  if (isNumber($row->id_amount_vat_conv)==0)
97  {
98  $and=($row->id_message=="")?"":",";
99  $row->id_message.=$and."CK_INVALID_AMOUNT";
100  }
101  //-----------------
102  ///- Check Quantity
103  //-----------------
104  $row->id_quant_conv=Impacc_Tool::convert_amount($row->id_quant,
105  $p_thousand, $p_decimal);
106  if (isNumber($row->id_quant_conv)==0)
107  {
108  $row->id_message.=$and."CK_INVALID_AMOUNT";
109  $and=",";
110  }
111  }
static convert_amount($p_amount, $p_thousand, $p_decimal)
convert_amount($array[$i]->id_amount_novat,$this->detail->s_thousand,$this->s_decimal); ...
static check_date($p_date, $p_format_date)
Check that the date payment has valid format . Return false or.
static check_tva($p_tva_code)
Check that TVA_CODE does exist , return true if exists otherwise false.
Impacc_Csv_Sale_Purchase::check_nb_column ( )
inherited

Definition at line 113 of file class_impacc_csv_sale_purchase.php.

114  {
115  throw new Exception("Not Yet Implemented");
116  }
Impacc_Csv_Sale::insert (   $a_group,
Acc_Ledger_Sold  $p_ledger 
)

Transfer operation with the status correct to the accountancy .

Change the status of the row (id_status to 1) after because it can transferred several rows in one operation

Definition at line 83 of file class_impacc_csv_sale.php.

References $array, $cn, and adapt().

84  {
85  $cn=Dossier::connect();
86  $nb_group=count($a_group);
87  for ( $i=0;$i< $nb_group;$i++)
88  {
89  $array=$this->adapt($a_group[$i]);
90 
91  //Complete the array
92  $array["p_jrn"]=$p_ledger->id;
93 
94  //Receipt
95  if (trim($array['e_pj'])=="") $array["e_pj"]=$p_ledger->guess_pj();
96  $array['e_pj_suggest']=$p_ledger->guess_pj();
97 
98  // Insert
99  $p_ledger->insert($array);
100 
101  // Update this group , status = 2 , jr_id
102  // and date_payment
103  $cn->exec_sql("update impacc.import_detail set jr_id=$1 , id_status=2 where id_code_group=$2",
104  array($p_ledger->jr_id,$a_group[$i]['id_code_group']));
105  $cn->exec_sql(" update public.jrn set jr_date_paid=to_date($1,'DD.MM.YYYY') where jr_id=$2",
106  array($this->jr_date_paid,$p_ledger->jr_id));
107 
108  }
109 
110  }
adapt($p_row)
Transform a group of rows to an array and set $jr_date_paid useable by Acc_Ledger_Sold::insert.
if(isset($_POST['remove'])) $array
global $cn
Impacc_Csv_Sale_Purchase::record ( Impacc_Csv  $p_csv,
Impacc_File  $p_file 
)
inherited

insert file into the table import_detail

Definition at line 121 of file class_impacc_csv_sale_purchase.php.

References $aseparator, $cn, $error, $nb_row, and $row.

122  {
123  global $aseparator;
124  // Open the CSV file
125  $hFile=fopen($p_file->import_file->i_tmpname, "r");
126  $error=0;
127  $cn=Dossier::connect();
128  $delimiter=$aseparator[$p_csv->detail->s_delimiter-1]['label'];
129  if ($p_csv->detail->s_surround==""){
130  $p_csv->detail->s_surround='"';
131  }
132  //---- For each row ---
133  while ($row=fgetcsv($hFile, 0, $delimiter, $p_csv->detail->s_surround))
134  {
135  $nb_row=count($row);
136  $insert=new Impacc_Import_detail_SQL($cn);
137  $insert->import_id=$p_file->import_file->id;
138  if ($nb_row<9)
139  {
140  $insert->id_status=-1;
141  $insert->id_message=join($row, $delimiter);
142  }
143  else
144  {
145 
146  $insert->id_date=$row[0];
147  $insert->id_code_group=$row[1];
148  $insert->id_acc=$row[2];
149  $insert->id_pj=$row[3];
150  $insert->id_label=$row[4];
151  $insert->id_acc_second=$row[5];
152  $insert->id_quant=$row[6];
153  $insert->id_amount_novat=$row[7];
154  $insert->tva_code=$row[8];
155  $insert->id_amount_vat=$row[9];
156  $date_limit=(isset($row[10]))?$row[10]:"";
157  $insert->id_date_limit=$date_limit;
158  $date_payment=(isset($row[11]))?$row[11]:"";
159  $insert->id_date_payment=$date_payment;
160  $insert->id_nb_row=0;
161  }
162  // insert row into table with status
163  $insert->insert();
164  }
165  }
for($i=0;$i< Database::num_row($ret);$i++) $row
global $aseparator
$nb_row
Definition: search_view.php:6
$error
global $cn
Impacc_Csv_Sale_Purchase::transform (   $ledger_id,
  $import_id 
)
inherited

Works by id_group_code : all the rows with the same id_code_group belong to the same operation The operation will be written in the right ledger Only operation with a id_status = 0 can be transferred , -1 is in error and 1 means that it has already been transferred.

Definition at line 38 of file class_impacc_csv_sale_purchase.php.

39  {
40  throw new Exception("Not Yet Implemented");
41  }

Field Documentation

Impacc_Csv_Sale::$jr_date_paid
private

< date_paid will introduced after insert

Definition at line 25 of file class_impacc_csv_sale.php.

Impacc_Csv_Sale::$suggest_pj
private

Definition at line 26 of file class_impacc_csv_sale.php.


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