[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Noalyss-commit] [noalyss] 06/16: Add function for creating ledger with
From: |
Dany De Bontridder |
Subject: |
[Noalyss-commit] [noalyss] 06/16: Add function for creating ledger with a factory |
Date: |
Fri, 21 Nov 2014 23:17:33 +0000 |
sparkyx pushed a commit to branch master
in repository noalyss.
commit 9be4c7ae393baf642139864ac3b3dfd154ca4fa1
Author: Dany De Bontridder <address@hidden>
Date: Fri Nov 21 23:57:08 2014 +0100
Add function for creating ledger with a factory
---
include/ac_common.php | 38 ++++++++++++++++++++++++++++++++++++++
1 files changed, 38 insertions(+), 0 deletions(-)
diff --git a/include/ac_common.php b/include/ac_common.php
index 5dfd7e6..9648db8 100644
--- a/include/ac_common.php
+++ b/include/ac_common.php
@@ -1116,4 +1116,42 @@ function get_array_column($p_array,$key)
}
return $array;
}
+
+/**
+ * This function create a ledger object and return the right one.
+ * It uses the factory pattern
+ * @param Database $p_cn
+ * @param type $ledger_id
+ * @return Acc_Ledger
+ * @throws Exception
+ */
+function factory_Ledger(Database &$p_cn, $ledger_id)
+{
+ include_once 'class_acc_ledger_sold.php';
+ include_once 'class_acc_ledger_purchase.php';
+ include_once 'class_acc_ledger_fin.php';
+
+ $ledger=new Acc_Ledger($p_cn, $ledger_id);
+ $type=$ledger->get_type();
+
+ switch ($type)
+ {
+ case 'VEN':
+ $obj=new Acc_Ledger_Sold($p_cn, $ledger_id);
+ break;
+ case 'ACH':
+ $obj=new Acc_Ledger_Purchase($p_cn, $ledger_id);
+ break;
+ case 'FIN':
+ $obj= new Acc_Ledger_Fin($p_cn, $ledger_id);
+ break;
+ case 'ODS':
+ $obj=$ledger;
+ break;
+
+ default:
+ throw new Exception('Ledger type not found');
+ }
+ return $obj;
+}
?>
- [Noalyss-commit] [noalyss] branch master updated (9218e29 -> 016a84c), Dany De Bontridder, 2014/11/21
- [Noalyss-commit] [noalyss] 02/16: box Position for managing document template, Dany De Bontridder, 2014/11/21
- [Noalyss-commit] [noalyss] 03/16: Prototype.js remove the hack for autocomplete prob, Dany De Bontridder, 2014/11/21
- [Noalyss-commit] [noalyss] 04/16: Prototype.js remove the hack for autocomplete prob, Dany De Bontridder, 2014/11/21
- [Noalyss-commit] [noalyss] 05/16: Task #1044 - Implementation de Test Update doc, Dany De Bontridder, 2014/11/21
- [Noalyss-commit] [noalyss] 06/16: Add function for creating ledger with a factory,
Dany De Bontridder <=
- [Noalyss-commit] [noalyss] 08/16: Prototype.js remove the hack for autocomplete prob, Dany De Bontridder, 2014/11/21
- [Noalyss-commit] [noalyss] 09/16: Task #1045 - Amélioration apparence : tabs adaptive responsive, Dany De Bontridder, 2014/11/21
- [Noalyss-commit] [noalyss] 12/16: Prototype.js remove the hack for autocomplete prob, Dany De Bontridder, 2014/11/21
- [Noalyss-commit] [noalyss] 10/16: Task #1054 - Menu to list, Dany De Bontridder, 2014/11/21
- [Noalyss-commit] [noalyss] 01/16: Documentation, Dany De Bontridder, 2014/11/21
- [Noalyss-commit] [noalyss] 07/16: Task #1054 - Menu to list, Dany De Bontridder, 2014/11/21
- [Noalyss-commit] [noalyss] 11/16: Task #1054 - Menu to list, Dany De Bontridder, 2014/11/21
- [Noalyss-commit] [noalyss] 13/16:, Dany De Bontridder, 2014/11/21
- [Noalyss-commit] [noalyss] 15/16: Task #1045 - Amélioration apparence : Textarea appearance for Chrome, Dany De Bontridder, 2014/11/21
- [Noalyss-commit] [noalyss] 16/16: Add filter when choosing a distribution key, Dany De Bontridder, 2014/11/21