[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Noalyss-commit] [noalyss] 09/24: Supplemental TAX : manage parameter A
From: |
Dany De Bontridder |
Subject: |
[Noalyss-commit] [noalyss] 09/24: Supplemental TAX : manage parameter A ledger can have only 1 supplemental tax |
Date: |
Tue, 12 Jul 2022 07:05:29 -0400 (EDT) |
sparkyx pushed a commit to branch master
in repository noalyss.
commit c4645e68e1919e36b4f5a3026ba85e9f29e1cba5
Author: sparkyx <danydb@noalyss.eu>
AuthorDate: Tue May 17 14:32:47 2022 +0200
Supplemental TAX : manage parameter
A ledger can have only 1 supplemental tax
---
html/ajax_misc.php | 6 +-
include/acc_other_tax.inc.php | 32 ++++
include/ajax/ajax_other_tax.php | 49 ++++++
include/class/acc_other_tax_mtable.class.php | 167 +++++++++++++++++++++
include/constant.php | 4 +-
include/database/acc_other_tax_sql.class.php | 67 +++++++++
include/lib/message_javascript.php | 2 +
.../test_postgres_json_array.php | 0
sql/upgrade.sql | 15 ++
9 files changed, 339 insertions(+), 3 deletions(-)
diff --git a/html/ajax_misc.php b/html/ajax_misc.php
index e9be4d0d2..8a2fe06ff 100644
--- a/html/ajax_misc.php
+++ b/html/ajax_misc.php
@@ -311,8 +311,10 @@ $path = array(
// search all card , analytic or accounting
"search_account_card"=>"ajax_search_account_card",
// Mobile device menu from mobile_device_mtable
- "mobile_device_menu"=>"ajax_mobile_device_menu"
-) ;
+ "mobile_device_menu"=>"ajax_mobile_device_menu",
+ // other_tax
+ "other_tax"=>"ajax_other_tax"
+) ;
if (array_key_exists($op, $path)) {
require NOALYSS_INCLUDE.'/ajax/'.$path[$op].".php";
diff --git a/include/acc_other_tax.inc.php b/include/acc_other_tax.inc.php
new file mode 100644
index 000000000..3e3a74e66
--- /dev/null
+++ b/include/acc_other_tax.inc.php
@@ -0,0 +1,32 @@
+<?php
+/*
+ * This file is part of NOALYSS.
+ *
+ * PhpCompta is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * PhpCompta is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with PhpCompta; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+/**
+ * @file
+ * @brief manage the public.acc_other_tax
+ */
+?>
+<div class="content">
+<?php
+$acc_other_tax=Acc_Other_Tax_MTable::build(-1);
+$acc_other_tax->create_js_script();
+$acc_other_tax->display_table();
+?>
+
+</div>
+
diff --git a/include/ajax/ajax_other_tax.php b/include/ajax/ajax_other_tax.php
new file mode 100644
index 000000000..145f28829
--- /dev/null
+++ b/include/ajax/ajax_other_tax.php
@@ -0,0 +1,49 @@
+<?php
+/*
+ * This file is part of NOALYSS.
+ *
+ * PhpCompta is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * PhpCompta is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with PhpCompta; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * Copyright (2002-2022) Author Dany De Bontridder <danydb@noalyss.eu>
+ */
+global $g_user;
+if ( $g_user->check_module("OTAX") == 0) die();
+
+try {
+ $table=$http->request('table');
+ $action=$http->request('action');
+ $p_id=$http->request('p_id', "number");
+ $ctl_id=$http->request('ctl');
+
+} catch(Exception $e) {
+ echo $e->getMessage();
+ return;
+}
+
+$acc_other_tax=Acc_Other_Tax_MTable::build($p_id);
+
+if ($action == "input") {
+ $acc_other_tax->send_header();
+ echo $acc_other_tax->ajax_input()->saveXML();
+} elseif ($action=="save") {
+
+ $acc_other_tax->send_header();
+ echo $acc_other_tax->ajax_save()->saveXML();
+}elseif ($action=="delete") {
+ $acc_other_tax->send_header();
+ echo $acc_other_tax->ajax_delete()->saveXML();
+
+}else {
+ die("error");
+}
\ No newline at end of file
diff --git a/include/class/acc_other_tax_mtable.class.php
b/include/class/acc_other_tax_mtable.class.php
new file mode 100644
index 000000000..0b0054e1d
--- /dev/null
+++ b/include/class/acc_other_tax_mtable.class.php
@@ -0,0 +1,167 @@
+<?php
+/*
+ * This file is part of NOALYSS.
+ *
+ * PhpCompta is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * PhpCompta is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with PhpCompta; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * Copyright (2002-2022) Author Dany De Bontridder <danydb@noalyss.eu>
+ */
+class Acc_Other_Tax_MTable extends Manage_Table_SQL
+{
+ /**
+ * @brief Build and returns an object
+ * @param int $p_id
+ */
+ static public function build($p_id=-1)
+ {
+ $cn=Dossier::connect();
+ $object_sql=new Acc_Other_Tax_SQL($cn,$p_id);
+
+ $object=new Acc_Other_Tax_MTable($object_sql);
+ $object->set_object_name("other_tax_ctl");
+ $object->set_callback("ajax_misc.php");
+ $object->add_json_param("op","other_tax");
+
$object->set_order(["ac_label","ac_rate","ac_accounting","ajrn_def_id"]);
+
+ $object->set_col_label("ac_label",_("Nom"));
+ $object->set_col_label("ajrn_def_id",_("Journaux"));
+ $object->set_col_label("ac_rate",_("Taux"));
+ $object->set_col_tips("ac_rate",82);
+ $object->set_col_label("ac_accounting",_("Poste comptable"));
+ $object->set_col_tips("ac_accounting",81);
+ $object->set_col_type("ac_accounting","custom");
+ $object->set_col_type("ajrn_def_id","custom");
+ $object->set_property_visible("ajrn_def_id",false);
+ return $object;
+ }
+ function input_custom($p_key,$p_value) {
+ switch ($p_key) {
+ case "ac_accounting":
+ $accounting=new IPoste("ac_accounting",$p_value);
+ $accounting->set_attribute('gDossier',Dossier::id());
+ $accounting->set_attribute('jrn',0);
+ $accounting->set_attribute('account','ac_accounting');
+ echo $accounting->input();
+ break;
+ case "ajrn_def_id":
+ $cn=Dossier::connect();
+ $a_ledger=$cn->get_array("select
+ jrn_def_id,jrn_def_name ,
+ coalesce ( (select
array_position(ajrn_def_id,jrn_def_id) from acc_other_tax
+ where ac_id=$1
+ ),0) as in_array
+ from jrn_def
+ where
+ jrn_enable=1
+ and jrn_def_type in ('ACH','VEN')
+ order by
jrn_def_name",[$this->get_table()->get("ac_id")]);
+ if (empty($a_ledger) ) {
+ echo _("Aucun journal disponible");
+ return;
+ }
+ $nb_ledger=count($a_ledger);
+ echo '<ul class="tab_row">';
+ for ($i=0;$i<$nb_ledger;$i++) {
+ $icheckbox=new
ICheckBox("check[]",$a_ledger[$i]['jrn_def_id']);
+ if ( $a_ledger[$i]['in_array']!=0) {
+ $icheckbox->set_check($a_ledger[$i]['jrn_def_id']);
+ }
+ echo '<li>',
+ $icheckbox->input(),
+ h($a_ledger[$i]['jrn_def_name']),
+ '</li>';
+
+ }
+ echo '</ul>';
+ break;
+ }
+ }
+ function display_row_custom($p_key, $p_value, $p_id = 0)
+ {
+ $cn=Dossier::connect();
+ switch ($p_key)
+ {
+ case 'ac_accounting':
+ $label=$cn->get_value("select pcm_lib from tmp_pcmn where
pcm_val=$1",
+ [$p_value]);
+ echo '<td>',
+ h($p_value),
+ " ",
+ h($label),
+ '</td>';
+ break;
+ }
+
+ }
+
+ function check()
+ {
+ $row=$this->get_table();
+ $cn=$row->get_cn();
+
+ if ( trim($row->getp("ac_rate")) == "") {
+ $row->setp("ac_rate",0);
+ }
+
+ if ( $row->getp("ac_rate")>100 || $row->getp("ac_rate")< 0 ) {
+ $this->set_error("ac_rate",_("Valeur invalide"));
+ }
+
+ $accounting=$row->getp("ac_accounting");
+ $nb_accounting=$cn->get_value("select count(*) from tmp_pcmn where
pcm_val =format_account($1)",
+ [$accounting]);
+ if (empty($accounting)||$nb_accounting == 0) {
+ $this->set_error("ac_accounting",_("Poste comptable inexistant"));
+ }
+
+ $ledger=$row->get("ajrn_def_id");
+ if ( $ledger != "{}" && ! empty ($ledger))
+ {
+ $ledger=trim($ledger,'{');
+ $ledger=trim($ledger,'}');
+ $a_ledger=explode(",",$ledger);
+
+ $nb_ledger=count($a_ledger);
+ $pk=$row->get("ac_id");
+ for ($i=0;$i<$nb_ledger;$i++) {
+ if ($cn->get_value("select count(*) from acc_other_tax
+ where
+ array_position(ajrn_def_id,$1) is not null
+ and ac_id != $2
+ ",[$a_ledger[$i],$pk]) > 0)
+ {
+ $this->set_error("ajrn_def_id",_("Journal déjà utilisé
dans autre taxe"));
+ }
+ }
+ }
+
+
+ if ($this->count_error()>0) {
+ return false;
+ }
+ return true;
+ }
+ function input()
+ {
+ $this->set_property_visible("ajrn_def_id",true);
+ return parent::input();
+ }
+
+ function from_request()
+ {
+ parent::from_request(); // TODO: Change the autogenerated stub
+ $http=new HttpInput();
+
$this->table->set("ajrn_def_id","{".join(",",$http->post("check","array",array()))."}");
+ }
+}
diff --git a/include/constant.php b/include/constant.php
index a453ed2ac..a2d1d766b 100644
--- a/include/constant.php
+++ b/include/constant.php
@@ -599,7 +599,9 @@ function noalyss_class_autoloader($class) {
"card_property"=>"class/card_property.class.php",
"pdfland"=>"class/pdf_land.class.php",
"pdf_anc_acc_list"=>"class/pdf_anc_acc_list.class.php",
-
'acc_reconciliation_lettering'=>'class/acc_reconciliation_lettering.class.php'
+
'acc_reconciliation_lettering'=>'class/acc_reconciliation_lettering.class.php',
+ "acc_other_tax_mtable"=>'class/acc_other_tax_mtable.class.php',
+ 'acc_other_tax_sql'=>'database/acc_other_tax_sql.class.php'
);
if ( isset ($aClass[$class]) ) {
require_once NOALYSS_INCLUDE."/".$aClass[$class];
diff --git a/include/database/acc_other_tax_sql.class.php
b/include/database/acc_other_tax_sql.class.php
new file mode 100644
index 000000000..0a11c91c9
--- /dev/null
+++ b/include/database/acc_other_tax_sql.class.php
@@ -0,0 +1,67 @@
+<?php
+/*
+* This file is part of NOALYSS.
+*
+* NOALYSS is free software; you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation; either version 2 of the License, or
+* (at your option) any later version.
+*
+* NOALYSS is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* 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
+*/
+/**
+ * class_action_gestion_sql.php
+ *
+ * @file
+ * @brief abstract of the table public.action_gestion */
+
+
+/**
+ * @class Acc_Other_Tax_SQL
+ * @brief ORM public.acc_other_tax
+ */
+
+class Acc_Other_Tax_SQL extends Table_Data_SQL
+{
+
+ function __construct(DatabaseCore $p_cn, $p_id=-1)
+ {
+ $this->table="public.acc_other_tax";
+ $this->primary_key="ac_id";
+ /*
+ * List of columns
+ */
+ $this->name=array(
+ "ac_id"=>"ac_id",
+ "ac_label"=>"ac_label",
+ "ac_rate"=>"ac_rate",
+ "ajrn_def_id"=>"ajrn_def_id",
+ "ac_accounting"=>"ac_accounting"
+ );
+ /*
+ * Type of columns
+ */
+ $this->type=array(
+ "ac_id"=>"numeric",
+ "ac_label"=>"text",
+ "ac_rate"=>"numeric",
+ "ajrn_def_id"=>"array",
+ "ac_accounting"=>"text"
+ );
+
+
+ $this->default=array(
+ "ac_id"=>"auto"
+
+ );
+ parent::__construct($p_cn, $p_id);
+ }
+
+}
diff --git a/include/lib/message_javascript.php
b/include/lib/message_javascript.php
index 792b7d777..5a29c3467 100644
--- a/include/lib/message_javascript.php
+++ b/include/lib/message_javascript.php
@@ -114,4 +114,6 @@ content[78]="<?php echo
htmlspecialchars($file_too_large,ENT_QUOTES)?>";
content[79]="<?php echo htmlspecialchars(_("Les postes comptables sont entre
[] , les fiches entre {} et les postes analytiques entre {{ }}"))?>";
content[80]="<?php echo htmlspecialchars(_("Oui pour charger les fichiers
javascripts et CSS standards"),ENT_QUOTES)?>";
+content[81]="<?php echo htmlspecialchars(_("Recommendé d'avoir un poste
propre"),ENT_QUOTES)?>";
+content[82]="<?php echo htmlspecialchars(_("valeur en % "),ENT_QUOTES)?>";
</script>
diff --git a/sql/upgrade.sql b/scenario/test_postgres_json_array.php
similarity index 100%
copy from sql/upgrade.sql
copy to scenario/test_postgres_json_array.php
diff --git a/sql/upgrade.sql b/sql/upgrade.sql
index e69de29bb..fbb6dac2f 100644
--- a/sql/upgrade.sql
+++ b/sql/upgrade.sql
@@ -0,0 +1,15 @@
+-- auto-generated definition
+create table acc_other_tax
+(
+ ac_id serial constraint acc_other_tax_pk
primary key,
+ ac_label text not null,
+ ac_rate numeric (5,2) not null,
+ ajrn_def_id integer[],
+ ac_accounting account_type not null
+);
+comment on table acc_other_tax is 'Other tax ';
+comment on column acc_other_tax.ac_label is 'Label of the tax';
+comment on column acc_other_tax.ac_rate is 'rate of the tax in percent';
+comment on column acc_other_tax.ajrn_def_id is 'array of to FK jrn_def
(jrn_def_id)';
+comment on column acc_other_tax.ac_accounting is 'FK tmp_pcmn (pcm_val)';
+
- [Noalyss-commit] [noalyss] branch master updated (f8d23563a -> cbc0d3fb7), Dany De Bontridder, 2022/07/12
- [Noalyss-commit] [noalyss] 01/24: Cosmetic : error message when user cannot add card, Dany De Bontridder, 2022/07/12
- [Noalyss-commit] [noalyss] 02/24: remove direct access to $_POST and extract, Dany De Bontridder, 2022/07/12
- [Noalyss-commit] [noalyss] 03/24: ISelect->display fails if this->value if null, Dany De Bontridder, 2022/07/12
- [Noalyss-commit] [noalyss] 06/24: Bug when ledger badly parametrized, Dany De Bontridder, 2022/07/12
- [Noalyss-commit] [noalyss] 08/24: Merge branch 'devel', Dany De Bontridder, 2022/07/12
- [Noalyss-commit] [noalyss] 05/24: Security : management , profile access, Dany De Bontridder, 2022/07/12
- [Noalyss-commit] [noalyss] 09/24: Supplemental TAX : manage parameter A ledger can have only 1 supplemental tax,
Dany De Bontridder <=
- [Noalyss-commit] [noalyss] 13/24: code documentation, Dany De Bontridder, 2022/07/12
- [Noalyss-commit] [noalyss] 10/24: New : 2178 Additional Tax : input in purchase and sale ledger - tax with positive amount - tax with negative amount - tax in currency, Dany De Bontridder, 2022/07/12
- [Noalyss-commit] [noalyss] 11/24: Nouveau #0002178: Cotisation de solidarité Impression : Listing (HTML, CSV et PDF) Impression : Extended (HTML, CSV et PDF) Negatif amount and currency, Dany De Bontridder, 2022/07/12
- [Noalyss-commit] [noalyss] 14/24: Additional Tax : database changes, Dany De Bontridder, 2022/07/12
- [Noalyss-commit] [noalyss] 16/24: Additional Tax : export operation PDF, Dany De Bontridder, 2022/07/12
- [Noalyss-commit] [noalyss] 17/24: Additional Tax : automatic compute, Dany De Bontridder, 2022/07/12
- [Noalyss-commit] [noalyss] 23/24: Bug : supplemental tax cannot be deleted, Dany De Bontridder, 2022/07/12
- [Noalyss-commit] [noalyss] 19/24: Cosmetic : waiting box if confirmed, Dany De Bontridder, 2022/07/12
- [Noalyss-commit] [noalyss] 04/24: Remove unauthorized profile, Dany De Bontridder, 2022/07/12
- [Noalyss-commit] [noalyss] 07/24: cosmetic, Dany De Bontridder, 2022/07/12