diff --git a/include/class/acc_operation.class.php b/include/class/acc_operation.class.php
index 56f22bf89..73c3d1a1c 100644
--- a/include/class/acc_operation.class.php
+++ b/include/class/acc_operation.class.php
@@ -869,13 +869,14 @@ EOF;
return $type_operation;
}
/**
- * create a form to recreate the operation and returns it, just like a correct
- *
+ * @brief create a form to recreate the operation and returns it, just like a correct
+ * @param $p_id string DOMID of the form
*/
function form_clone_operation($p_id) {
// retrieve all info about operation
$operation = $this->get_quant();
$array=$operation->compute_array();
+
global $g_user;
$a_code=$this->db->get_array("select code from v_menu_dependency vmd where me_code=$1 and p_id=$2",
array( $operation->signature,$g_user->get_profile()));
@@ -918,14 +919,30 @@ EOF;
// For Misc Operation , if a card is given then there is no accounting
if ( $operation->signature==="ODS") {
- $nb_array=count($array);
- for ($i=0;$i<$nb_array;$i++) {
- if (isset ($array["qc_".$i] ) && $array["qc_".$i] != "" ) {
- $array["poste".$i]="";
+ $nb_array = count($array);
+ for ($i = 0; $i < $nb_array; $i++) {
+ if (isset ($array["qc_" . $i]) && $array["qc_" . $i] != "") {
+ $array["poste" . $i] = "";
}
}
}
-
+
+ if ( $operation->signature==="ACH" || $operation->signature=="VEN") {
+ $idx=0;
+ foreach ($operation->det->array as $item) {
+ if ( isset ($item['qs_vat_sided']) && $item['qs_vat_sided'] != 0 ) {
+ $array['e_march'.$idx.'_tva_amount']=0;
+ }elseif (isset ($item['qp_vat_sided']) && $item['qp_vat_sided'] != 0 ){
+ $array['e_march'.$idx.'_tva_amount']=0;
+ }
+ $idx++;
+ }
+ if ( DEBUGNOALYSS>1) {
+ echo \Noalyss\Dbg::hidden_info("operation->det_array", $operation->det->array);
+ echo \Noalyss\Dbg::hidden_info("array", $array);
+ }
+ }
+
// transform the operation into hidden element
$r.=HtmlInput::simple_array_to_hidden($array);
$r.=HtmlInput::hidden("e_comm",$operation->det->jr_comment);
diff --git a/unit-test/include/class/acc_operation.Test.php b/unit-test/include/class/acc_operation.Test.php
deleted file mode 100644
index a03d9af84..000000000
--- a/unit-test/include/class/acc_operation.Test.php
+++ /dev/null
@@ -1,129 +0,0 @@
-object = new Acc_Operation($g_connection);
-
-
- }
-
- /**
- * Tears down the fixture, for example, closes a network connection.
- * This method is called after a test is executed.
- */
- protected function tearDown():void
- {
- }
-
- /**
- *@covers Acc_Operation::seek_group
- */
- public function testSeek_group()
- {
- $this->object->jr_id=6;
- $r=$this->object->seek_group();
- $this->assertEquals(8,$r);
- }
- /**
- * @covers Acc_Operation::set_id
- *
- */
- public function testSet_id()
- {
- $this->object->set_id(1000);
- $this->assertEquals(1000,$this->object->jr_id);
- try {
- $this->object->set_id('AB');
- } catch (Exception $e) {
- $this->assertEquals($e->getMessage(),'Acc_Operation::set_id , id invalide ');
- }
- }
- /**
- * @covers Acc_Operation::set_paid
- */
- function testSet_Paid()
- {
- $row=$this->object->db->get_array('select * from jrn where jr_rapt <> $1 limit 1',array('paid'));
- if ( ! $row ) {
- echo "Aucune ligne trouvée";
- $this->assertTrue(TRUE);
- } else {
- $this->object->jr_id=$row[0]['jr_id'];
- $this->object->set_paid();
- $status=$this->object->db->get_value ('select jr_rapt from jrn where jr_id=$1',array($row[0]['jr_id']));
- $this->assertEquals($status,'paid');
- }
-
- }
- /**
- * @covers Acc_Operation::get_amount
- */
- function testGet_Amount()
- {
- $row=$this->object->db->get_array('select * from jrn limit 1');
- if ( ! $row ) {
- echo "Aucune ligne trouvée";
- $this->assertTrue(FALSE);
- } else {
- $this->object->jr_id=$row[0]['jr_id'];
- $amount=$this->object->get_amount();
- $this->assertEquals($amount,$row[0]['jr_montant']);
- }
-
- }
- /**
- * provide data for testAmount_Currency
- * @return type
- */
- public function data_amount_currency()
- {
- return array(
- /* sale */
- array(659,146.95),
- array(657,146.95),
- array(649,0),
- /* purchase*/
- array(680,680.33),
- array(683,834.91),
- array(526,0),
- /* financial */
- array(658,146.95),
- array(684,200),
- array(685,300),
- /* misc operation */
- array(686,25.25),
-
- );
- }
- /**
- * @testdox acc_operation::get_amount_currency - sale-purchase-fin-misc
- * @covers Acc_Operation::get_amount_currency
- * @dataProvider data_amount_currency
- */
- function testGet_AmountCurrency($p_jrn_id,$p_amount_currency)
- {
- global $g_connection;
- $acc_operation=new Acc_Detail($g_connection,$p_jrn_id);
- $acc_operation->get();
- $acc_operation->get_quant();
- $actual_amount=round($acc_operation->get_currency_amount(),2);
- $this->assertEquals($p_amount_currency,$actual_amount,"currency values doesn't match for $p_jrn_id");
- }
-}
diff --git a/unit-test/include/class/acc_operationTest.php b/unit-test/include/class/acc_operationTest.php
new file mode 100644
index 000000000..0d9c5dfb0
--- /dev/null
+++ b/unit-test/include/class/acc_operationTest.php
@@ -0,0 +1,258 @@
+object = new Acc_Operation($g_connection);
+
+
+ }
+
+ /**
+ * Tears down the fixture, for example, closes a network connection.
+ * This method is called after a test is executed.
+ */
+ protected function tearDown():void
+ {
+ }
+
+ /**
+ *@covers Acc_Operation::seek_group
+ */
+ public function testSeek_group()
+ {
+ $this->object->jr_id=6;
+ $r=$this->object->seek_group();
+ $this->assertEquals(8,$r);
+ }
+ /**
+ * @covers Acc_Operation::set_id
+ *
+ */
+ public function testSet_id()
+ {
+ $this->object->set_id(1000);
+ $this->assertEquals(1000,$this->object->jr_id);
+ try {
+ $this->object->set_id('AB');
+ } catch (Exception $e) {
+ $this->assertEquals($e->getMessage(),'Acc_Operation::set_id , id invalide ');
+ }
+ }
+ /**
+ * @covers Acc_Operation::set_paid
+ */
+ function testSet_Paid()
+ {
+ $row=$this->object->db->get_array('select * from jrn where jr_rapt <> $1 limit 1',array('paid'));
+ if ( ! $row ) {
+ echo "Aucune ligne trouvée";
+ $this->assertTrue(TRUE);
+ } else {
+ $this->object->jr_id=$row[0]['jr_id'];
+ $this->object->set_paid();
+ $status=$this->object->db->get_value ('select jr_rapt from jrn where jr_id=$1',array($row[0]['jr_id']));
+ $this->assertEquals($status,'paid');
+ }
+
+ }
+ /**
+ * @covers Acc_Operation::get_amount
+ */
+ function testGet_Amount()
+ {
+ $row=$this->object->db->get_array('select * from jrn limit 1');
+ if ( ! $row ) {
+ echo "Aucune ligne trouvée";
+ $this->assertTrue(FALSE);
+ } else {
+ $this->object->jr_id=$row[0]['jr_id'];
+ $amount=$this->object->get_amount();
+ $this->assertEquals($amount,$row[0]['jr_montant']);
+ }
+
+ }
+ /**
+ * provide data for testAmount_Currency
+ * @return type
+ */
+ public function data_amount_currency()
+ {
+ return array(
+ /* sale */
+ array(659,146.95),
+ array(657,146.95),
+ array(649,0),
+ /* purchase*/
+ array(680,680.33),
+ array(683,834.91),
+ array(526,0),
+ /* financial */
+ array(658,146.95),
+ array(684,200),
+ array(685,300),
+ /* misc operation */
+ array(686,25.25),
+
+ );
+ }
+ /**
+ * @testdox acc_operation::get_amount_currency - sale-purchase-fin-misc
+ * @covers Acc_Operation::get_amount_currency
+ * @dataProvider data_amount_currency
+ */
+ function testGet_AmountCurrency($p_jrn_id,$p_amount_currency)
+ {
+ global $g_connection;
+ $acc_operation=new Acc_Detail($g_connection,$p_jrn_id);
+ $acc_operation->get();
+ $acc_operation->get_quant();
+ $actual_amount=round($acc_operation->get_currency_amount(),2);
+ $this->assertEquals($p_amount_currency,$actual_amount,"currency values doesn't match for $p_jrn_id");
+ }
+
+ /**
+ * @testDox Test form_clone_operation SALE
+ * @return void
+ */
+ function testForm_clone_operation_sale()
+ {
+ global $g_connection;
+ // use jr_id=160 : 5 rows
+ $duplicate = new Acc_Operation($g_connection);
+ $duplicate->jr_id=160;
+ ob_start();
+
+ $result=$duplicate->form_clone_operation("test");
+ ob_end_clean();
+
+ $this->assertTrue(stripos($result,'')>0, "sale : HTML doesn't contain nb_item = 5");
+ // use jr_id=910 : 1 rows
+ $duplicate = new Acc_Operation($g_connection);
+ $duplicate->jr_id=910;
+ ob_start();
+ $result=$duplicate->form_clone_operation("test");
+ ob_end_clean();
+ $this->assertStringContainsString(strtoupper(''), strtoupper($result));
+ $this->assertStringContainsString(
+ strtoupper('')
+ ,strtoupper($result));
+
+ // use jr_id=659 VAT_SIDED
+ $duplicate = new Acc_Operation($g_connection);
+ $duplicate->jr_id=659;
+ ob_start();
+ $result=$duplicate->form_clone_operation("test");
+ ob_end_clean();
+ $this->assertStringContainsString(
+ strtoupper('')
+ , strtoupper($result));
+ $this->assertStringContainsString(
+ strtoupper('')
+ , strtoupper($result));
+ $this->assertStringContainsString(
+ strtoupper( '')
+ , strtoupper($result));
+
+ }
+
+ /**
+ * @testDox Test form_clone_operation PURCHASE
+ * @return void
+ */
+ function testForm_clone_operation_purchase()
+ { global $g_connection;
+ // use jr_id 158 4 rows
+ $duplicate = new Acc_Operation($g_connection);
+ $duplicate->jr_id=158;
+ ob_start();
+
+ $result=$duplicate->form_clone_operation("test");
+ ob_end_clean();
+
+ $this->assertTrue(stripos($result,'')>0
+ , "purchase : HTML doesn't contain nb_item = 4 $result");
+
+ $this->assertStringContainsString(
+ strtoupper('')
+ ,strtoupper($result));
+
+ $this->assertStringContainsString(
+ strtoupper('')
+ ,strtoupper($result));
+
+ // use jr_id 680 VAT_SIDED
+ $duplicate = new Acc_Operation($g_connection);
+ $duplicate->jr_id=680;
+ ob_start();
+
+ $result=strtoupper($duplicate->form_clone_operation("test"));
+ ob_end_clean();
+
+ $this->assertStringContainsString(
+ strtoupper( ''),
+ $result);
+ $this->assertStringContainsString(
+ strtoupper(''),$result);
+ $this->assertStringContainsString(
+ strtoupper(''),$result);
+
+ }
+ /**
+ * @testDox Test form_clone_operation MISC OP
+ * @return void
+ */
+ function testForm_clone_operation_ods()
+ {
+ global $g_connection;
+ // use jr_id 317 1 rows
+ $duplicate = new Acc_Operation($g_connection);
+ $duplicate->jr_id=317;
+ ob_start();
+
+ $result=strtoupper($duplicate->form_clone_operation("test"));
+ ob_end_clean();
+ $this->assertTrue(stripos($result,'')>0
+ , "MO : HTML doesn't contain nb_item = 3 ");
+ $this->assertStringContainsString(
+ strtoupper('') ,
+ $result);
+
+ }
+ /**
+ * @testDox Test form_clone_operation FIN
+ * @return void
+ */
+ function testForm_clone_operation_fin()
+ {
+ // use jr_id 250 1 rows
+ global $g_connection;
+ $duplicate = new Acc_Operation($g_connection);
+ $duplicate->jr_id=250;
+ ob_start();
+
+ $result=strtoupper($duplicate->form_clone_operation("test"));
+ ob_end_clean();
+
+ $this->assertStringContainsString(
+ strtoupper('') ,
+ $result);
+ }
+
+}