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

Manage one row of operation of Sale / Purchase for importing them. More...

Inheritance diagram for Impacc_Csv_Sale_Purchase:
Inheritance graph
Collaboration diagram for Impacc_Csv_Sale_Purchase:
Collaboration graph

Public Member Functions

 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...
 

Detailed Description

Manage one row of operation of Sale / Purchase for importing them.

Definition at line 30 of file class_impacc_csv_sale_purchase.php.

Member Function Documentation

static Impacc_Csv_Sale_Purchase::check ( Impacc_Import_detail_SQL  $row,
  $p_format_date,
  $p_thousand,
  $p_decimal 
)
static

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 ( )

Definition at line 113 of file class_impacc_csv_sale_purchase.php.

114  {
115  throw new Exception("Not Yet Implemented");
116  }
Impacc_Csv_Sale_Purchase::record ( Impacc_Csv  $p_csv,
Impacc_File  $p_file 
)

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 
)

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  }

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