[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Noalyss-commit] [noalyss] 06/08: Task #1266 - Automatisation de la coc
From: |
Dany De Bontridder |
Subject: |
[Noalyss-commit] [noalyss] 06/08: Task #1266 - Automatisation de la coche "payé" FIN : action concernée est cochée payée si montants égaux |
Date: |
Sat, 13 Feb 2016 01:42:19 +0000 |
sparkyx pushed a commit to branch master
in repository noalyss.
commit f260b74ef04330fa5078fa5ad9ebb6616e56a027
Author: Dany De Bontridder <address@hidden>
Date: Sat Feb 13 01:25:50 2016 +0100
Task #1266 - Automatisation de la coche "payé"
FIN : action concernée est cochée payée si montants égaux
---
include/class/class_acc_ledger_fin.php | 18 ++++
include/class/class_acc_operation.php | 38 ++++++++
.../include/class/class_acc_ledger_finTest.php | 16 ++--
.../include/class/class_acc_operationTest.php | 101 ++++++++++++++++++++
4 files changed, 165 insertions(+), 8 deletions(-)
diff --git a/include/class/class_acc_ledger_fin.php
b/include/class/class_acc_ledger_fin.php
index f472cd8..bef6e39 100644
--- a/include/class/class_acc_ledger_fin.php
+++ b/include/class/class_acc_ledger_fin.php
@@ -895,6 +895,13 @@ class Acc_Ledger_Fin extends Acc_Ledger
if (isNumber($rRapt) ==
1)
{
$rec->insert($rRapt);
+ try {
+
$oppaid=new Acc_Operation($this->db);
+
$oppaid->set_id($rRapt);
+
$oppaid->set_paid();
+ } catch
(Exception $ex) {
+ echo
_('Attention , erreur Acc_Ledger_Fin::insert , coche paiement');
+ }
}
}
}
@@ -904,6 +911,17 @@ class Acc_Ledger_Fin extends Acc_Ledger
$rec = new
Acc_Reconciliation($this->db);
$rec->set_jr_id($jr_id);
$rec->insert(${"e_concerned$i"});
+ try {
+ $oppaid=new
Acc_Operation($this->db);
+
$oppaid->set_id(${"e_concerned" . $i});
+
$conc_amount=$oppaid->get_amount();
+ if ($conc_amount ==
$acc_operation->amount)
+ {
+ $oppaid->set_paid();
+ }
+ } catch (Exception $ex) {
+ echo _('Attention , erreur
Acc_Ledger_Fin::insert , coche paiement');
+ }
}
}
diff --git a/include/class/class_acc_operation.php
b/include/class/class_acc_operation.php
index a064ab1..4612f0f 100644
--- a/include/class/class_acc_operation.php
+++ b/include/class/class_acc_operation.php
@@ -574,6 +574,44 @@ class Acc_Operation
$action->insert_operation();
}
}
+ /**
+ *
+ * @param type $p_id
+ */
+ function set_id($p_id)
+ {
+ if (isNumber($p_id)==0) {
+ throw new Exception(_('Acc_Operation::set_id , id invalide '));
+ }
+ $this->jr_id=$p_id;
+ }
+ /**
+ * \brief flag the operation as paid
+ */
+ function set_paid()
+ {
+ // Operation
+ if ( $this->jr_id == 0 )
+ throw new Exception(_('Object invalide, id incorrect'));
+ if (
+ $this->db->get_value('select count(*) from jrn where jr_id=$1',
+ array($this->jr_id)) == 0 )
+ throw new Exception(_('Object invalide, id incorrect'));
+
+ $this->db->exec_sql("update jrn set jr_rapt = 'paid' where jr_id = $1",
+ array($this->jr_id));
+ }
+ /**
+ * return amount of the jr_id
+ */
+ function get_amount()
+ {
+ if ( $this->jr_id == 0 )
+ throw new Exception(_('Object invalide, id incorrect'));
+ $amount=$this->db->get_value('select jr_montant from jrn where
jr_id=$1',
+ array($this->jr_id));
+ return $amount;
+ }
static function test_me()
{
$_SESSION['g_user']=NOALYSS_ADMINISTRATOR;
diff --git a/unit-test/include/class/class_acc_ledger_finTest.php
b/unit-test/include/class/class_acc_ledger_finTest.php
index c4ebba7..6c27eee 100644
--- a/unit-test/include/class/class_acc_ledger_finTest.php
+++ b/unit-test/include/class/class_acc_ledger_finTest.php
@@ -19,7 +19,7 @@ class Acc_Ledger_FinTest extends PHPUnit_Framework_TestCase
protected function setUp()
{
include 'global.php';
- $this->object=new Acc_Ledger_Fin($g_connection,1);
+ $this->object=new Acc_Ledger_Fin($g_connection, 1);
}
/**
@@ -38,8 +38,8 @@ class Acc_Ledger_FinTest extends PHPUnit_Framework_TestCase
*/
public function testVerify()
{
-
- $this->object->verify(null);
+
+ $this->object->verify(null);
}
/**
@@ -96,10 +96,10 @@ class Acc_Ledger_FinTest extends PHPUnit_Framework_TestCase
*/
public function testGet_bank_name()
{
- $name=$this->object->get_bank_name();
- var_export($name);
- if (strpos ($name,NOTFOUND) !=0 )
- $this->assertTrue(FALSE);
+ $name=$this->object->get_bank_name();
+ var_export($name);
+ if (strpos($name, NOTFOUND)!=0)
+ $this->assertTrue(FALSE);
}
/**
@@ -108,7 +108,7 @@ class Acc_Ledger_FinTest extends PHPUnit_Framework_TestCase
*/
public function testGet_bank()
{
- $this->assertEquals(27,$this->object->get_bank());
+ $this->assertEquals(9, $this->object->get_bank());
}
/**
diff --git a/unit-test/include/class/class_acc_operationTest.php
b/unit-test/include/class/class_acc_operationTest.php
new file mode 100644
index 0000000..6122fcd
--- /dev/null
+++ b/unit-test/include/class/class_acc_operationTest.php
@@ -0,0 +1,101 @@
+<?php
+/**
+ * Generated by PHPUnit_SkeletonGenerator on 2016-02-13 at 00:41:50.
+ * @backupGlobals enabled
+ */
+class Acc_OperationTest extends PHPUnit_Framework_TestCase
+{
+ /**
+ * @var Acc_OperationTest
+ */
+ protected $object;
+
+ /**
+ * Sets up the fixture, for example, opens a network connection.
+ * This method is called before a test is executed.
+ */
+ protected function setUp()
+ {
+ include 'global.php';
+ global $g_connection,$g_user;
+ $this->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()
+ {
+ }
+
+ /**
+ * @covers Acc_OperationTest::get
+ * @todo Implement testGet().
+ */
+ public function testGet()
+ {
+ $this->assertEquals(0,0);
+ }
+ /**
+ address@hidden Acc_Operation::seek_group
+ * @todo Implement seek_group()
+ */
+ public function testSeek_group()
+ {
+ $this->object->jr_id=39;
+ $r=$this->object->seek_group();
+ $this->assertEquals(2922,$r);
+ }
+ /**
+ * @covers Acc_Operation::set_id
+ * @todo Implement testId()
+ *
+ */
+ 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
+ * @todo Implement testSet_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";
+ } 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
+ * @todo Implement testGet_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']);
+ }
+
+ }
+}
- [Noalyss-commit] [noalyss] branch master updated (81fd85e -> 2a35058), Dany De Bontridder, 2016/02/12
- [Noalyss-commit] [noalyss] 01/08: Remove inexistant user, Dany De Bontridder, 2016/02/12
- [Noalyss-commit] [noalyss] 02/08: when removing an user , remove also his privilege in all folders, Dany De Bontridder, 2016/02/12
- [Noalyss-commit] [noalyss] 03/08: Task #9 - Ajouter un événement à celui-ci Add an sub event : clean fields but keep the person, Dany De Bontridder, 2016/02/12
- [Noalyss-commit] [noalyss] 04/08: Task #1267 - Lettrage : la colonne ref doit contenir le numéro de PJ #1267 : Lettrage : la colonne ref doit contenir le numéro de PJ, Dany De Bontridder, 2016/02/12
- [Noalyss-commit] [noalyss] 05/08: Montre le nombre de dossier maximum, Dany De Bontridder, 2016/02/12
- [Noalyss-commit] [noalyss] 06/08: Task #1266 - Automatisation de la coche "payé" FIN : action concernée est cochée payée si montants égaux,
Dany De Bontridder <=
- [Noalyss-commit] [noalyss] 07/08: Add NOALYSS_INCLUDE, Dany De Bontridder, 2016/02/12
- [Noalyss-commit] [noalyss] 08/08: Task #1253 - Perte de contexte en cas d'erreur sur la saisie d'une opération. #1253 : perte date si erreur dans journaux opération diverses, Dany De Bontridder, 2016/02/12