Plugins  LAST
 All Data Structures Files Functions Variables Pages
class_impacc_verify.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  * Copyright (C) 2016 Dany De Bontridder <dany@alchimerys.be>
5  *
6  * This program is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program. If not, see <http://www.gnu.org/licenses/>.
18  */
19 
20 //!@file
21 //@brief Verify info from impacc.import_detail
22 
23 require_once DIR_IMPORT_ACCOUNT."/database/class_impacc_import_detail_sql.php";
24 
25 ///All the methods to check the column from
26 /// The table impacc.import_detail are here
28 {
29 
30  //-----------------------------------------------------------------------
31  ///
32  ///
33  //!@param $row is an Impacc_Import_detail_SQL object
34  //-----------------------------------------------------------------------
35  static function check_quantity(Impacc_Import_detail_SQL $row, $p_thousand,
36  $p_decimal)
37  {
38  $row->id_quant_conv=Impacc_Tool::convert_amount($row->id_quant,
39  $p_thousand, $p_decimal);
40  if (isNumber($row->id_quant_conv)==0)
41  {
42  $and=($row->id_message=="")?"":",";
43  $row->id_message.=$and."CK_INVALID_AMOUNT";
44  }
45  }
46 
47  //-----------------------------------------------------------------------
48  ///
49  ///
50  //!@param $row is an Impacc_Import_detail_SQL object
51  //-----------------------------------------------------------------------
52  static function check_amount_vat(Impacc_Import_detail_SQL $row, $p_thousand,
53  $p_decimal)
54  {
55  $row->id_amount_vat_conv=Impacc_Tool::convert_amount($row->id_amount_vat,
56  $p_thousand, $p_decimal);
57  if (isNumber($row->id_amount_vat_conv)==0)
58  {
59  $and=($row->id_message=="")?"":",";
60  $row->id_message.=$and."CK_INVALID_AMOUNT";
61  }
62  }
63 
64  //-------------------------------------------------------------------
65  /// Check that the sale / purchase card exist
66  /// Update the object $row (id_message)
67  //!@param $row is an Impacc_Import_detail_SQL object
68  //-------------------------------------------------------------------
70  {
71  $cn=Dossier::connect();
72  $card=new Fiche($cn);
73  $card->get_by_qcode($row->id_acc_second, false);
74  if ($card->id==0)
75  {
76  $and=($row->id_message=="")?"":",";
77  $row->id_message.=$and."CK_INVALID_ACCOUNTING";
78  }
79  }
80 
81  //-------------------------------------------------------------------
82  /// Check that TVA_CODE does exist , return true if exists otherwise false
83  //-------------------------------------------------------------------
84  static function check_tva($p_tva_code)
85  {
86  $cn=Dossier::connect();
87  global $g_parameter;
88  // If we don't use VAT , no need to check it
89  if ($g_parameter->MY_TVA_USE=="N")
90  return true;
91 
92  // VAT Mandatory and empty
93  if ($p_tva_code=="")
94  {
95  return false;
96  }
97 
98  $exist=$cn->get_value("select count(*) from impacc.parameter_tva where tva_code=$1",
99  array($p_tva_code));
100  if ($exist!=1)
101  {
102  return false;
103  }
104  return true;
105  }
106 
107  //-------------------------------------------------------------------
108  /// Check that the date payment has valid format . Return false or
109  // a valid date in format DD.MM.YYYY
110  //!\param $p_date is the value to check
111  //!\param $p_format_date check for date_limit and date_payment
112  //-------------------------------------------------------------------
113  static function check_date($p_date,$p_format_date)
114  {
115  if ($p_date=="") return false;
116 
117  $test=DateTime::createFromFormat($p_format_date, $p_date);
118 
119  if ($test==false)
120  {
121  return false;
122  }
123  else
124  {
125  $p_return=$test->format('d.m.Y');
126  return $p_return;
127  }
128  }
129 
130  //-------------------------------------------------------------------
131  /// Check that a card exist and use a valid accounting
132  //!@param $p_account quick_code of a card,
133  //!@returns a Fiche object if correct , else false
134  //-------------------------------------------------------------------
135  static function check_card($p_account)
136  {
137  $cn=Dossier::connect();
138  $card=new Fiche($cn);
139  $card->get_by_qcode($p_account, false);
140  if ($card->id==0)
141  {
142 
143  return false;
144  }
145  else
146  {
147  // The accounting must also be checked
148  $poste_str=$card->strAttribut(ATTR_DEF_ACCOUNT);
149 
150  $poste=new Acc_Account_Ledger($cn, $poste_str);
151  if ($poste->do_exist()==0)
152  {
153  return false;
154  }
155  }
156  return $card;
157  }
158  //-------------------------------------------------------------------
159  /// Check that a card belong to a ledger
160  //!@param $p_account quick_code of a card,
161  //!@param $p_ledger ledger id , to see if not zero check if belong to ledger
162  //!@returns true if correct , else false
163  //-------------------------------------------------------------------
164  static function check_belong_card(Fiche $p_account,$p_ledger)
165  {
166 
167  return true;
168  }
169 
170 }
static convert_amount($p_amount, $p_thousand, $p_decimal)
convert_amount($array[$i]->id_amount_novat,$this->detail->s_thousand,$this->s_decimal); ...
for($i=0;$i< Database::num_row($ret);$i++) $row
static check_belong_card(Fiche $p_account, $p_ledger)
Check that a card belong to a ledger.
static check_date($p_date, $p_format_date)
Check that the date payment has valid format . Return false or.
global $g_parameter
Definition: ajax.php:27
static check_service(Impacc_Import_detail_SQL $row)
Check that the sale / purchase card exist Update the object $row (id_message)
static check_amount_vat(Impacc_Import_detail_SQL $row, $p_thousand, $p_decimal)
static check_quantity(Impacc_Import_detail_SQL $row, $p_thousand, $p_decimal)
global $cn
static check_tva($p_tva_code)
Check that TVA_CODE does exist , return true if exists otherwise false.
All the methods to check the column from The table impacc.import_detail are here. ...
static check_card($p_account)
Check that a card exist and use a valid accounting.