Author: danydb Date: 2014-02-01 22:18:27 +0100 (Sat, 01 Feb 2014) New Revision: 684
Modified: trunk/transform/include/class_transform_declarant.php trunk/transform/include/class_transform_intervat.php trunk/transform/include/class_transform_representative.php trunk/transform/include/intervat_listing_assujetti_step_2.inc.php trunk/transform/unit-test/bootstrap.php trunk/transform/unit-test/transform_IntervatTest.php Log: Update test-unit + we dont give an array as parameter but a Transform_Declarant for append_listing Modified: trunk/transform/include/class_transform_declarant.php =================================================================== --- trunk/transform/include/class_transform_declarant.php 2014-02-01 15:17:43 UTC (rev 683) +++ trunk/transform/include/class_transform_declarant.php 2014-02-01 21:18:27 UTC (rev 684) @@ -32,6 +32,7 @@ @endcode */ // Copyright Author Dany De Bontridder [email protected] +require_once 'class_transform_sql.php'; class Transform_Declarant { @@ -74,30 +75,47 @@ * vatnumber */ var $vatnumber; - + /** + * readOnly + */ + var $readOnly; + function __construct() + { + $this->readOnly=false; + $this->data=new Intervat_Declarant_SQL; + } function fromPost() { - $this->name = HtmlInput::default_value_post("p_dec_name", null); - $this->street = HtmlInput::default_value_post("p_dec_street", null); - $this->postcode = HtmlInput::default_value_post("p_dec_postcode", null); - $this->city = HtmlInput::default_value_post("p_dec_city", null); - $this->countrycode = HtmlInput::default_value_post("p_dec_countrycode", null); + global $g_parameter; + $this->name = HtmlInput::default_value_post("p_dec_name", $g_parameter->MY_NAME); + $this->street = HtmlInput::default_value_post("p_dec_street", $g_parameter->MY_STREET); + $this->postcode = HtmlInput::default_value_post("p_dec_postcode", $g_parameter->MY_CP); + $this->city = HtmlInput::default_value_post("p_dec_city", $g_parameter->MY_COMMUNE); + $this->countrycode = HtmlInput::default_value_post("p_dec_countrycode", "BE"); $this->email = HtmlInput::default_value_post("p_dec_email", null); - $this->phone = HtmlInput::default_value_post("p_dec_phone", null); - $this->vatnumber = HtmlInput::default_value_post("p_dec_vatnumber", null); + $this->phone = HtmlInput::default_value_post("p_dec_phone", $g_parameter->MY_TEL); + $this->vatnumber = HtmlInput::default_value_post("p_dec_vatnumber", $g_parameter->MY_TVA); $this->year=HtmlInput::default_value_post('p_year',null); } function input() { $h_name = new IText('p_dec_name', $this->name); + $h_name->readOnly=$this->readOnly; $h_vatnumber = new IText('p_dec_vatnumber', $this->vatnumber); + $h_vatnumber->readOnly=$this->readOnly; $h_street = new IText('p_dec_street', $this->street); + $h_street->readOnly=$this->readOnly; $h_postcode = new IText('p_dec_postcode', $this->postcode); + $h_postcode->readOnly=$this->readOnly; $h_city = new IText('p_dec_city', $this->city); + $h_city->readOnly=$this->readOnly; $h_countrycode = new IText('p_dec_countrycode', $this->countrycode); + $h_countrycode->readOnly=$this->readOnly; $h_email = new IText('p_dec_email', $this->email); + $h_email->readOnly=$this->readOnly; $h_phone = new IText('p_dec_phone', $this->phone); + $h_phone->readOnly=$this->readOnly; require_once 'template/listing_assujetti_declarant.php'; } @@ -115,6 +133,11 @@ $this->data->insert(); } + function display() + { + $this->readOnly=true; + $this->input(); + } } Modified: trunk/transform/include/class_transform_intervat.php =================================================================== --- trunk/transform/include/class_transform_intervat.php 2014-02-01 15:17:43 UTC (rev 683) +++ trunk/transform/include/class_transform_intervat.php 2014-02-01 21:18:27 UTC (rev 684) @@ -112,7 +112,7 @@ @endcode * */ - function append_client_listing(Transform_Declarant $p_declarant,$p_array) + function append_client_listing(Transform_Declarant $p_declarant) { // variable $vat_amount_sum = 0; @@ -130,12 +130,12 @@ - $this->append_declarant($decl, $p_declarant,$p_array); + $this->append_declarant($decl, $p_declarant); $periode = $this->domdoc->createElementNS($this->ns, "ns2:Period", $periode); $decl->appendChild($periode); - $this->append_listing($decl, $p_array); + $this->append_listing($decl, $p_declarant); $l = $this->domdoc->getElementsByTagNameNS($this->ns, "ClientListingConsignment"); @@ -163,7 +163,7 @@ </ns2:Declarant> @endcode */ - function append_declarant(DOMElement $p_dom, Transform_Declarant $p_declarant,$p_array) + function append_declarant(DOMElement $p_dom, Transform_Declarant $p_declarant) { @@ -196,7 +196,7 @@ * @param type $p_array */ - function append_listing(DOMElement $p_dom, $p_array) + function append_listing(DOMElement $p_dom, Transform_Declarant $p_declarant) { /* * Client are in array Modified: trunk/transform/include/class_transform_representative.php =================================================================== --- trunk/transform/include/class_transform_representative.php 2014-02-01 15:17:43 UTC (rev 683) +++ trunk/transform/include/class_transform_representative.php 2014-02-01 21:18:27 UTC (rev 684) @@ -16,119 +16,155 @@ * You should have received a copy of the GNU General Public License * along with NOALYSS; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ + */ // Copyright Author Dany De Bontridder [email protected] /** * @brief contains the representative - @code + @code $ID = "0000000097"; -$issued = "BE"; -$type = 'TIN'; -$name = "Nom Mandataire"; -$street = "Nom de rue"; -$postcode = "9999"; -$city = "TESTCITY"; -$countrycode = "BE"; -$email = "[email protected]"; -$phone = "000000000"; - @endcode + $issued = "BE"; + $type = 'TIN'; + $name = "Nom Mandataire"; + $street = "Nom de rue"; + $postcode = "9999"; + $city = "TESTCITY"; + $countrycode = "BE"; + $email = "[email protected]"; + $phone = "000000000"; + @endcode */ - +require_once 'class_transform_sql.php'; class Transform_Representative { + /** * id is the id of the listing */ var $id; + /** * issued by */ - var $issued; - /** - * Type (TIN) - */ - var $type; - /** - * name - */ - var $name; - /** - * street - */ - var $street; - /** - * Postcode - */ - var $postcode; - /** - * city - */ - var $city; - /** - * country code (BE) - */ - var $countrycode; - /** - * email - */ - var $email; - /** - * phone - */ - var $phone; - /** - * Transform_Representative_SQL - */ - var $data; - function fromPost() - { - $this->id=HtmlInput::default_value_post("p_id",1); - $this->type=HtmlInput::default_value_post("p_type",null); - $this->name=HtmlInput::default_value_post("p_name",null); - $this->street=HtmlInput::default_value_post("p_street",null); - $this->postcode=HtmlInput::default_value_post("p_postcode",null); - $this->city=HtmlInput::default_value_post("p_city",null); - $this->countrycode=HtmlInput::default_value_post("p_countrycode",null); - $this->email=HtmlInput::default_value_post("p_email",null); - $this->phone=HtmlInput::default_value_post("p_phone",null); - $this->issued=HtmlInput::default_value_post("p_issued",null); - } - function input() - { - $h_type=new ISelect('p_type'); - $h_type->value=array( - array("label"=>'TIN',"value"=>"TIN"), - array("label"=>'NVAT',"value"=>"NVAT"), - array("label"=>'other',"value"=>"other") - ); - $h_type->selected=$this->type; - $h_name=new IText('p_name',$this->name); - $h_street=new IText('p_street',$this->street); - $h_postcode=new IText('p_postcode',$this->postcode); - $h_city=new IText('p_city',$this->city); - $h_countrycode=new IText('p_countrycode',$this->countrycode); - $h_email=new IText('p_email',$this->email); - $h_phone=new IText('p_phone',$this->phone); - $h_id=new INum('p_id',$this->id); - $h_issued=new IText("p_issued",$this->issued); - require_once 'template/listing_assujetti_representative.php'; + var $issued; - } - function insert() - { - var_dump($this->id); - $this->data->rp_listing_id=$this->id; - $this->data->rp_issued=$this->issued; - $this->data->rp_type=$this->type; - $this->data->rp_name=$this->name; - $this->data->rp_street=$this->street; - $this->data->rp_postcode=$this->postcode; - $this->data->rp_countrycode=$this->countrycode; - $this->data->rp_email=$this->email; - $this->data->rp_phone=$this->phone; - - $this->data->insert(); - } + /** + * Type (TIN) + */ + var $type; + + /** + * name + */ + var $name; + + /** + * street + */ + var $street; + + /** + * Postcode + */ + var $postcode; + + /** + * city + */ + var $city; + + /** + * country code (BE) + */ + var $countrycode; + + /** + * email + */ + var $email; + + /** + * phone + */ + var $phone; + + /** + * Transform_Representative_SQL + */ + var $data; + /** + * readOnly + */ + var $readOnly; + function __construct() + { + $this->readOnly=false; + $this->data=new Intervat_Representative_SQL(); + } + function fromPost() + { + $this->id = HtmlInput::default_value_post("p_id", 1); + $this->type = HtmlInput::default_value_post("p_type", null); + $this->name = HtmlInput::default_value_post("p_name", null); + $this->street = HtmlInput::default_value_post("p_street", null); + $this->postcode = HtmlInput::default_value_post("p_postcode", null); + $this->city = HtmlInput::default_value_post("p_city", null); + $this->countrycode = HtmlInput::default_value_post("p_countrycode", null); + $this->email = HtmlInput::default_value_post("p_email", null); + $this->phone = HtmlInput::default_value_post("p_phone", null); + $this->issued = HtmlInput::default_value_post("p_issued", null); + } + + function input() + { + $h_type = new ISelect('p_type'); + $h_type->value = array( + array("label" => 'TIN', "value" => "TIN"), + array("label" => 'NVAT', "value" => "NVAT"), + array("label" => 'other', "value" => "other") + ); + $h_type->selected = $this->type; + $h_type->readOnly=$this->readOnly; + $h_name = new IText('p_name', $this->name); + $h_name->readOnly=$this->readOnly; + $h_street = new IText('p_street', $this->street); + $h_street->readOnly=$this->readOnly; + $h_postcode = new IText('p_postcode', $this->postcode); + $h_postcode->readOnly=$this->readOnly; + $h_city = new IText('p_city', $this->city); + $h_city->readOnly=$this->readOnly; + $h_countrycode = new IText('p_countrycode', $this->countrycode); + $h_countrycode->readOnly=$this->readOnly; + $h_email = new IText('p_email', $this->email); + $h_email->readOnly=$this->readOnly; + $h_phone = new IText('p_phone', $this->phone); + $h_phone->readOnly=$this->readOnly; + $h_id = new INum('p_id', $this->id); + $h_id->readOnly=$this->readOnly; + $h_issued = new IText("p_issued", $this->issued); + $h_issued->readOnly=$this->readOnly; + require_once 'template/listing_assujetti_representative.php'; + } + + function insert() + { + $this->data->rp_listing_id = $this->id; + $this->data->rp_issued = $this->issued; + $this->data->rp_type = $this->type; + $this->data->rp_name = $this->name; + $this->data->rp_street = $this->street; + $this->data->rp_postcode = $this->postcode; + $this->data->rp_countrycode = $this->countrycode; + $this->data->rp_email = $this->email; + $this->data->rp_phone = $this->phone; + + $this->data->insert(); + } + + function display() + { + $this->readOnly = true; + $this->input(); + } + } - Modified: trunk/transform/include/intervat_listing_assujetti_step_2.inc.php =================================================================== --- trunk/transform/include/intervat_listing_assujetti_step_2.inc.php 2014-02-01 15:17:43 UTC (rev 683) +++ trunk/transform/include/intervat_listing_assujetti_step_2.inc.php 2014-02-01 21:18:27 UTC (rev 684) @@ -32,7 +32,8 @@ $year = HtmlInput::default_value_post('p_year', NULL); $atva = HtmlInput::default_value_post('h_tva', null); $compute_date = HtmlInput::default_value_post('p_compute_date', null); - +$rejected=array(); + // If inputtype is null not choice between file or compute if ($inputtype == null) { @@ -114,7 +115,7 @@ $i++; if (count($data) != 4 || $i == 1) { - $o_data[$i] = _('Ligne non importée') . join(' - ', $data); + $rejected[] = _('Ligne non importée') . join(' - ', $data); continue; } /* @@ -246,10 +247,14 @@ $cn->rollback(); throw new Exception(_('Ne peut pas ajouter ') . h($o_data[$i]->c_name) . '-' . h($o_data[$i]->c_vatnumber), 3); } +} /** * Show the result */ -} - +echo $representative->display(); +echo $declarant->display(); +$a_listing=new Intervat_Client_SQL; +$ret=$a_listing->seek(' where d_id = $1',array($declarant->data->d_id)); +require 'template/listing_client_display.php'; ?> Modified: trunk/transform/unit-test/bootstrap.php =================================================================== --- trunk/transform/unit-test/bootstrap.php 2014-02-01 15:17:43 UTC (rev 683) +++ trunk/transform/unit-test/bootstrap.php 2014-02-01 21:18:27 UTC (rev 684) @@ -20,8 +20,16 @@ // Copyright Author Dany De Bontridder [email protected] -$path='/home/dany/developpement/phpcompta/phpcompta-trunk/include:..:../include'; +$path='/home/dany/developpement/phpcompta/rel671/include:..:../include:/usr/share/php/PHPUnit'; $old_path= get_include_path(); set_include_path($old_path.':'.$path); +require_once 'Framework/SelfDescribing.php'; +require_once 'Framework/Test.php'; +require_once 'Framework/Assert.php'; +require_once 'Framework/TestCase.php'; +require_once 'class_database.php'; +require_once 'class_transform_intervat.php'; +require_once 'constant.php'; +require_once 'class_own.php'; Modified: trunk/transform/unit-test/transform_IntervatTest.php =================================================================== --- trunk/transform/unit-test/transform_IntervatTest.php 2014-02-01 15:17:43 UTC (rev 683) +++ trunk/transform/unit-test/transform_IntervatTest.php 2014-02-01 21:18:27 UTC (rev 684) @@ -47,10 +47,11 @@ * @endcode * */ -require_once 'class_transform_intervat.php'; -require_once 'class_transform_representative.php'; require_once 'bootstrap.php'; +require_once 'class_transform_representative.php'; +require_once 'class_dossier.php'; + /** * Generated by PHPUnit_SkeletonGenerator 1.2.1 on 2014-01-25 at 18:01:08. */ @@ -65,6 +66,7 @@ /** * Sets up the fixture, for example, opens a network connection. * This method is called before a test is executed. + * @backupGlobals enabled */ protected function setUp() { @@ -107,7 +109,16 @@ </ns2:ClientListing> </ns2:ClientListingConsignment> '; + global $cn, $g_parameter; + $cn = new Database(26); + $g_parameter = new Own($cn); + $_REQUEST['gDossier'] = 26; + $this->request = new Transform_Request_SQL; + $this->request->r_type = 'phpunit-intervat'; + $this->request->insert(); + $this->representative = new Transform_Representative(); + $this->representative->data->r_id = $this->request->r_id; $this->representative->id = "0000000097"; $this->representative->issued = "BE"; $this->representative->type = 'TIN'; @@ -118,10 +129,12 @@ $this->representative->countrycode = "BE"; $this->representative->email = "[email protected]"; $this->representative->phone = "000000000"; - /* + $this->representative->insert(); + /* * Variables */ - $this->declarant=new Transform_Declarant(); + $this->declarant = new Transform_Declarant(); + $this->declarant->data->r_id = $this->request->r_id; $this->declarant->vat_number = "0000000097"; $this->declarant->name = "Nom Declarant"; $this->declarant->street = "Rue du declarant"; @@ -130,6 +143,7 @@ $this->declarant->countrycode = "BE"; $this->declarant->email = "[email protected]"; $this->declarant->phone = "000000000"; + $this->declarant->insert(); } /** @@ -144,9 +158,14 @@ /** * @covers Intervat::append_root * @todo Implement testAppend_root(). + * @backupGlobals enabled */ public function testAppend_root() { + global $cn, $g_parameter; + $cn = new Database(26); + $g_parameter = new Own($cn); + $_REQUEST['gDossier'] = 26; $this->object->append_root(); $result = $this->object->domdoc->saveXML(); $must_march = '<?xml version="1.0" encoding="ISO-8859-1"?> @@ -160,7 +179,10 @@ public function testAppend_representative() { - + global $cn, $g_parameter; + $cn = new Database(26); + $g_parameter = new Own($cn); + $_REQUEST['gDossier'] = 26; $this->object->append_root(); $this->object->append_representative($this->representative); $result = $this->object->domdoc->saveXML(); @@ -173,9 +195,13 @@ */ public function testAppend_client_listing() { + global $cn, $g_parameter; + $cn = new Database(26); + $g_parameter = new Own($cn); + $_REQUEST['gDossier'] = 26; $this->object->append_root(); $this->object->append_representative($this->representative); - $this->object->append_client_listing($this->declarant,array()); + $this->object->append_client_listing($this->declarant); $result = $this->object->domdoc->saveXML(); $this->assertEquals($this->result, $result); } @@ -186,12 +212,16 @@ */ public function testAppend_declarant() { + global $cn, $g_parameter; + $cn = new Database(26); + $g_parameter = new Own($cn); + $_REQUEST['gDossier'] = 26; $this->object->append_root(); - $dom=$this->object->domdoc->createElement("Listing"); - $this->object->append_declarant($dom,$this->declarant,array()); + $dom = $this->object->domdoc->createElement("Listing"); + $this->object->append_declarant($dom, $this->declarant); $this->object->domdoc->appendChild($dom); $result = $this->object->domdoc->saveXML(); - $expected='<?xml version="1.0" encoding="ISO-8859-1"?> + $expected = '<?xml version="1.0" encoding="ISO-8859-1"?> <ns2:ClientListingConsignment xmlns:ns2="http://www.minfin.fgov.be/ClientListingConsignment" xmlns="http://www.minfin.fgov.be/InputCommon" ClientListingsNbr="1"/> <Listing xmlns:ns2="http://www.minfin.fgov.be/ClientListingConsignment"> <ns2:Declarant xmlns:ns2="http://www.minfin.fgov.be/ClientListingConsignment"> @@ -209,5 +239,14 @@ $this->assertEquals($expected, $result); } + function call_inline() + { + $this->setUp(); + } } +/* +$a = new IntervatTest; +$a->call_inline(); +$a->testAppend_representative(); +*/ \ No newline at end of file --- PhpCompta est un logiciel de comptabilité libre en ligne (full web) Projet opensource http://www.phpcompta.eu _______________________________________________ Phpcompta est un logiciel libre de comptabilité en ligne (http://www.phpcompta.eu) Phpcompta-dev mailing list [email protected] https://lists.nongnu.org/mailman/listinfo/phpcompta-dev
