[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Phpcompta-dev] r593 - in trunk/rapport_avance: . doc include
From: |
phpcompta-dev |
Subject: |
[Phpcompta-dev] r593 - in trunk/rapport_avance: . doc include |
Date: |
Sun, 1 Dec 2013 20:51:19 +0100 (CET) |
Author: danydb
Date: 2013-12-01 20:51:18 +0100 (Sun, 01 Dec 2013)
New Revision: 593
Added:
trunk/rapport_avance/include/class_rapav.php
Modified:
trunk/rapport_avance/ajax_save_param_detail.php
trunk/rapport_avance/doc/test_unitaire.bin
trunk/rapport_avance/include/class_formulaire_param_detail.php
trunk/rapport_avance/include/class_rapav_declaration.php
Log:
Task #0000927: Formule sur les dates : ?\195?\169ch?\195?\169ance, paiement ou
op?\195?\169ration
Modified: trunk/rapport_avance/ajax_save_param_detail.php
===================================================================
--- trunk/rapport_avance/ajax_save_param_detail.php 2013-11-28 13:47:36 UTC
(rev 592)
+++ trunk/rapport_avance/ajax_save_param_detail.php 2013-12-01 19:51:18 UTC
(rev 593)
@@ -43,7 +43,7 @@
$acc_tva->type_detail = 2;
$acc_tva->tt_id = $code_base;
$acc_tva->jrn_def_id = $p_ledger;
- $acc_tva->date_paid=(isset($p_paid))?1:0;
+ $acc_tva->date_paid=$p_paid;
if ($acc_tva->verify() == 1)
{
$code = 'nok';
@@ -71,7 +71,7 @@
$acc_formula->p_id = $p_id;
$acc_formula->type_detail = 1;
$acc_formula->jrn_def_id = $p_ledger;
- $acc_formula->date_paid=(isset($p_paid))?1:0;
+ $acc_formula->date_paid=$p_paid;
if ($acc_formula->verify() == 1)
{
$code = 'nok';
@@ -128,7 +128,7 @@
$acc_account->type_detail = 4;
$acc_account->type_sum_account = $account_sum_type;
$acc_account->jrn_def_id = $p_ledger;
- $acc_account->date_paid=(isset($p_paid))?1:0;
+ $acc_account->date_paid=$p_paid;
if ($acc_account->verify() == 1)
{
$code = 'nok';
Modified: trunk/rapport_avance/doc/test_unitaire.bin
===================================================================
--- trunk/rapport_avance/doc/test_unitaire.bin 2013-11-28 13:47:36 UTC (rev
592)
+++ trunk/rapport_avance/doc/test_unitaire.bin 2013-12-01 19:51:18 UTC (rev
593)
@@ -1,21 +1,25 @@
RAPAV;4
"Test unitaire";"Test des différentes fonctionnalité"
-142;F1;Formule;3;10;14;1
-143;F2;"Formule N-1";3;20;14;3
-144;F3;"Formule journal OD uniquement";3;30;14;1
-145;PC1;"Poste comptable code tva tous les journaux";3;40;14;1
-146;PC2;"Poste comptable &code tva tous les journaux N-1";3;50;14;3
-147;PC3;"Poste comptable code tva Achat";3;60;14;1
-148;P1;"Poste comptable tous les journaux (6% & 4111)";3;70;14;1
-149;P2;"Poste comptable tous les journaux (6% & 4111) N-1";3;80;14;3
-150;P3;"Poste comptable tous les journaux (6% & 4111) uniqt Achat 2";3;90;14;1
+135;F1;Formule;3;10;12;1
+136;F2;"Formule N-1";3;20;12;3
+137;F3;"Formule journal OD uniquement";3;30;12;1
+138;PC1;"Poste comptable code tva tous les journaux";3;40;12;1
+139;PC2;"Poste comptable &code tva tous les journaux N-1";3;50;12;3
+140;PC3;"Poste comptable code tva Achat";3;60;12;1
+141;P1;"Poste comptable tous les journaux (6% & 4111)";3;70;12;1
+142;P2;"Poste comptable tous les journaux (6% & 4111) N-1";3;80;12;3
+143;P3;"Poste comptable tous les journaux (6% & 4111) uniqt Achat 2";3;90;12;1
+144;Date-paiement;"Formule Date - paiement";3;100;12;1
+145;date-echeance;"Formule Date échéance";3;110;12;1
RAPAV_DETAIL
-128;142;;;[44%];;;;1;;;;0
-129;143;;;[44%];;;;1;;;;0
-131;144;;;[44%];;;;1;;;;0
-134;147;%;1;;;ACH;1;2;;;;0
-135;146;%;1;;;ACH;1;2;;;;0
-136;145;%;1;;;ACH;1;2;;;;0
-137;148;6%;;;;;;4;4111;1;;0
-138;149;6%;;;;;;4;4111;1;;0
-139;150;6%;;;;;;4;4111;1;;0
+112;135;;;[44%];;;;1;;;;0
+113;136;;;[44%];;;;1;;;;0
+114;137;;;[44%];;;;1;;;;0
+115;138;%;1;;;ACH;1;2;;;;0
+116;139;%;1;;;ACH;1;2;;;;0
+117;140;%;1;;;ACH;1;2;;;;0
+118;141;6%;;;;;;4;4111;1;;0
+119;142;6%;;;;;;4;4111;1;;0
+120;143;6%;;;;;;4;4111;1;;0
+121;144;;;[70%];;;;1;;;;1
+122;145;;;[70%];;;;1;;;;2
Modified: trunk/rapport_avance/include/class_formulaire_param_detail.php
===================================================================
--- trunk/rapport_avance/include/class_formulaire_param_detail.php
2013-11-28 13:47:36 UTC (rev 592)
+++ trunk/rapport_avance/include/class_formulaire_param_detail.php
2013-12-01 19:51:18 UTC (rev 593)
@@ -28,6 +28,7 @@
*/
require_once 'class_rapport_avance_sql.php';
require_once 'class_rapav_formulaire.php';
+require_once 'class_rapav.php';
class Formulaire_Param_Detail extends Formulaire_Param_Detail_SQL
{
@@ -42,41 +43,6 @@
require_once 'template/param_detail_new.php';
}
- function get_ledger_name()
- {
- global $cn;
- $ledger = "";
- if ($this->jrn_def_id == null || $this->jrn_def_id == -1)
- {
- $ledger = " tous les journaux";
- } else
- {
- $tledger = $cn->get_value('select jrn_def_name from jrn_def where
jrn_def_id=$1', array($this->jrn_def_id));
- $ledger.=" le journal " . $tledger;
- }
- return $ledger;
- }
-
- static function input_ledger()
- {
- global $cn;
- $select = new ISelect('p_ledger');
- $a_ledger = $cn->make_array('select jrn_def_id,jrn_def_name from
jrn_def order by 2', 1);
- $a_ledger[0]['label'] = '-- Tous les journaux -- ';
- $select->value = $a_ledger;
-
- echo '<p> Filtrage par journal ' . $select->input() . '</p>';
- }
-
- static function input_date_paiement()
- {
- $ck_paid = new ICheckBox('p_paid');
- echo '<p> La date donnée concerne la date de paiement, ce qui limitera
la recherche aux journaux VEN et ACH ';
- echo HtmlInput::infobulle(36);
- echo $ck_paid->input();
- echo '</p>';
- }
-
}
class RAPAV_Formula extends Formulaire_Param_Detail
@@ -84,8 +50,8 @@
function display_row()
{
- $ledger = $this->get_ledger_name();
- $paid = ( $this->date_paid != 0 ) ? "la date concerne la date de
paiement, la recherche sera limitée au journaux de type ACH & VEN" : "";
+ $ledger = RAPAV::get_ledger_name($this->jrn_def_id);
+ $paid = RAPAV::str_date_type($this->date_paid);
printf("Résultat de la formule %s utilisant $ledger %s",
$this->fp_formula, $paid);
}
@@ -100,8 +66,8 @@
$account->set_attribute('noquery', 1);
$account->set_attribute('account', $account->id);
echo $account->input();
- Formulaire_Param_Detail::input_date_paiement();
- Formulaire_Param_Detail::input_ledger();
+ RAPAV::input_date_paiement();
+ RAPAV::input_ledger();
}
function verify()
@@ -127,9 +93,9 @@
function display_row()
{
global $cn;
- $ledger = $this->get_ledger_name();
+ $ledger = RAPAV::get_ledger_name($this->jrn_def_id);;
$type_total = $cn->get_value("select tt_label from
rapport_advanced.total_type where tt_id=$1", array($this->tt_id));
- $paid = ( $this->date_paid != 0 ) ? "la date concerne la date de
paiement, la recherche sera limitée au journaux de type ACH & VEN" : "";
+ $paid = RAPAV::str_date_type($this->date_paid);
printf("Poste comptable %s avec le code tva %s (%s) dans le journal de
type %s [ %s ] $ledger %s", $this->tmp_val, $this->tva_id, $this->tva_id,
$this->jrn_def_type, $type_total, $paid);
}
@@ -168,8 +134,8 @@
echo td($code_base->input());
echo '</tr>';
echo '</table>';
- Formulaire_Param_Detail::input_date_paiement();
- Formulaire_Param_Detail::input_ledger();
+ RAPAV::input_date_paiement();
+ RAPAV::input_ledger();
}
function verify()
@@ -247,8 +213,8 @@
function display_row()
{
global $cn;
- $ledger = $this->get_ledger_name();
- $paid = ( $this->date_paid != 0 ) ? "la date concerne la date de
paiement, la recherche sera limitée au journaux de type ACH & VEN" : "";
+ $ledger = RAPAV::get_ledger_name($this->jrn_def_id);;
+ $paid = RAPAV::str_date_type($this->date_paid);
$total_type_account = $cn->get_value('select tt_label from
rapport_advanced.total_type_account where tt_id=$1',
array($this->type_sum_account));
printf("Total %s poste comptable %s utilisé avec le poste comptable %s
utilisant $ledger %s", $total_type_account, $this->tmp_val,
$this->with_tmp_val, $paid);
}
@@ -282,8 +248,8 @@
echo ' utilisé avec le poste comptable ' . HtmlInput::infobulle(203);
echo $account_second->input();
echo '</p>';
- Formulaire_Param_Detail::input_date_paiement();
- Formulaire_Param_Detail::input_ledger();
+ RAPAV::input_date_paiement();
+ RAPAV::input_ledger();
}
function verify()
@@ -309,7 +275,7 @@
{
global $cn;
$total_type_account = $cn->get_value('select tt_label from
rapport_advanced.total_type_account where tt_id=$1',
array($this->type_sum_account));
- $ledger = $this->get_ledger_name();
+ $ledger = RAPAV::get_ledger_name($this->jrn_def_id);;
printf("Total %s poste comptable %s utilisé avec le poste comptable %s
rapprochée dans la période donnée
avec une opération utilisant le poste comptable %s
utilisant $ledger", $total_type_account, $this->tmp_val, $this->with_tmp_val,
$this->operation_pcm_val);
}
@@ -354,7 +320,7 @@
echo $account_third->input();
echo '</p>';
- Formulaire_Param_Detail::input_ledger();
+ RAPAV::input_ledger();
}
function verify()
Added: trunk/rapport_avance/include/class_rapav.php
===================================================================
--- trunk/rapport_avance/include/class_rapav.php
(rev 0)
+++ trunk/rapport_avance/include/class_rapav.php 2013-12-01 19:51:18 UTC
(rev 593)
@@ -0,0 +1,130 @@
+<?php
+
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+/**
+ * Common function to RAPAV_Listing RAPAV_Formulaire and RAPAV_Declaration
+ *
+ * @author dany
+ */
+class RAPAV
+{
+
+ /**
+ * Return the ledger's name of p_jrn
+ * @param $p_jrn jrn_def::jrn_def_id if -1, it means all the ledger
+ * @return string
+ */
+ static function get_ledger_name($p_jrn)
+ {
+ global $cn;
+ $ledger = "";
+ if ($p_jrn == null || $p_jrn == -1)
+ {
+ $ledger = " tous les journaux";
+ } else
+ {
+ $tledger = $cn->get_value('select jrn_def_name from jrn_def where
jrn_def_id=$1', array($p_jrn));
+ $ledger.=" le journal " . $tledger;
+ }
+ return $ledger;
+ }
+ /**
+ * display a choice of ledger
+ * @global cn
+ */
+ static function input_ledger()
+ {
+ global $cn;
+ $select = new ISelect('p_ledger');
+ $a_ledger = $cn->make_array('select jrn_def_id,jrn_def_name from
jrn_def order by 2', 1);
+ $a_ledger[0]['label'] = '-- Tous les journaux -- ';
+ $select->value = $a_ledger;
+
+ echo '<p> Filtrage par journal ' . $select->input() . '</p>';
+ }
+ /**
+ * Display a select for the date
+ */
+ static function input_date_paiement()
+ {
+ $s_date = new ISelect('p_paid');
+ $s_date->value = array();
+ $s_date->value[] = array("value" => 0, "label" => 'Date calendrier');
+ $s_date->value[] = array("value" => 1, "label" => 'Date de paiement');
+ $s_date->value[] = array("value" => 2, "label" => 'Date d\'échéance');
+ echo '<p> Si la date donnée concerne la date de paiement ou
d\'écheance, cela limitera la recherche aux journaux VEN et ACH ';
+ echo HtmlInput::infobulle(36);
+ echo $s_date->input();
+ echo '</p>';
+ }
+ /**
+ * Compute the string to display for date
+ * @param $p_type
+ * @return string
+ * @throws Exception
+ */
+ static function str_date_type($p_type)
+ {
+ switch ($p_type)
+ {
+ case 0:
+ return "";
+ break;
+ case 1:
+ return "la date concerne la date de paiement, la recherche
sera limitée au journaux de type ACH & VEN";
+ break;
+ case 2:
+ return "la date concerne la date d'échéance, la recherche sera
limitée au journaux de type ACH & VEN";
+ break;
+ }
+ throw new Exception('str_date_type : type de date inconnu');
+ }
+
+ /**
+ * Compute the SQL for the date
+ * - 0 given date
+ * - 1 Date of payment
+ * - 2 Limit Date
+ * @param $p_date integer
+ * @return string
+ * @throws Exception if $p_date not valid
+ */
+ static function get_sql_date($p_date)
+ {
+ switch ($p_date)
+ {
+ case 0:
+ $sql_date = "and (jrn1.j_date >= to_date($2,'DD.MM.YYYY') and
jrn1.j_date <= to_date($3,'DD.MM.YYYY'))";
+ break;
+ case 1:
+ $sql_date = " and j_id in
+ (select j_id from jrnx join jrn on (j_grpt = jr_grpt_id)
+ where
+ coalesce(jr_date_paid,to_date('01.01.1900','DD.MM.YYYY'))
>= to_date($2,'DD.MM.YYYY')
+ and
coalesce(jr_date_paid,to_date('01.01.1900','DD.MM.YYYY')) <=
to_date($3,'DD.MM.YYYY')
+ )
+ ";
+ break;
+ case 2:
+ $sql_date = " and j_id in
+ (select j_id from jrnx join jrn on (j_grpt = jr_grpt_id)
+ where
+ coalesce(jr_ech,to_date('01.01.1900','DD.MM.YYYY')) >=
to_date($2,'DD.MM.YYYY')
+ and coalesce(jr_ech,to_date('01.01.1900','DD.MM.YYYY')) <=
to_date($3,'DD.MM.YYYY')
+ )
+ ";
+ break;
+
+ default:
+ throw new Exception('get_sql_date paramètre invalide');
+ break;
+ }
+ return $sql_date;
+ }
+
+}
Modified: trunk/rapport_avance/include/class_rapav_declaration.php
===================================================================
--- trunk/rapport_avance/include/class_rapav_declaration.php 2013-11-28
13:47:36 UTC (rev 592)
+++ trunk/rapport_avance/include/class_rapav_declaration.php 2013-12-01
19:51:18 UTC (rev 593)
@@ -742,10 +742,16 @@
}
if ($this->form->date_paid == 1)
{
- $sql.=sprintf(" and jr_date_paid >= to_date('%s','DD.MM.YYYY') and
jr_date_paid <= to_date ('%s','DD.MM.YYYY')", $p_start, $p_end);
+ $sql.=sprintf(" and j_id in ( select j_id from jrnx join jrn on
(j_grpt=jr_grpt_id) where jr_date_paid >= to_date('%s','DD.MM.YYYY') and
jr_date_paid <= to_date ('%s','DD.MM.YYYY'))", $p_start, $p_end);
$p_start = '01.01.1900';
$p_end = '01.01.2100';
}
+ if ($this->form->date_paid == 2)
+ {
+ $sql.=sprintf(" and j_id in ( select j_id from jrnx join jrn on
(j_grpt=jr_grpt_id) where jr_ech >= to_date('%s','DD.MM.YYYY') and jr_ech <=
to_date ('%s','DD.MM.YYYY'))", $p_start, $p_end);
+ $p_start = '01.01.1900';
+ $p_end = '01.01.2100';
+ }
$amount = Impress::parse_formula($cn, "", $this->form->fp_formula,
$p_start, $p_end, true, 1, $sql);
return $amount['montant'];
}
@@ -825,6 +831,8 @@
{
$filter_ledger = " and j_jrn_def = " .
sql_string($this->form->jrn_def_id);
}
+ $sql_date=RAPAV::get_sql_date($this->form->date_paid );
+/*
if ($this->form->date_paid == 1)
{
$sql_date=" and j_id in
@@ -839,12 +847,12 @@
else
{
$sql_date="and (j_date >= to_date($2,'DD.MM.YYYY') and j_date <=
to_date($3,'DD.MM.YYYY'))";
- }
+ }*/
if ($this->form->jrn_def_type == 'ACH')
{
$sql = "select coalesce(sum(qp_vat),0) as amount
- from quant_purchase join jrnx
using (j_id)
+ from quant_purchase join jrnx
as jrn1 using (j_id)
where qp_vat_code=$1
$sql_date
and j_poste::text like ($4)
$filter_ledger";
@@ -857,7 +865,7 @@
if ($this->form->jrn_def_type == 'VEN')
{
$sql = "select coalesce(sum(qs_vat),0) as amount
- from quant_sold join jrnx using
(j_id)
+ from quant_sold join jrnx as
jrn1 using (j_id)
where qs_vat_code=$1
$sql_date
and j_poste::text like ($4)
$filter_ledger";
@@ -890,6 +898,8 @@
{
$filter_ledger = " and j_jrn_def = " .
sql_string($this->form->jrn_def_id);
}
+ $sql_date=RAPAV::get_sql_date($this->form->date_paid );
+/*
if ($this->form->date_paid == 1)
{
$sql_date=" and j_id in
@@ -904,10 +914,10 @@
else
{
$sql_date="and (j_date >= to_date($2,'DD.MM.YYYY') and j_date <=
to_date($3,'DD.MM.YYYY'))";
- }
+ }*/
if ($this->form->jrn_def_type == 'ACH')
{
- $sql = "select coalesce(sum(qp_price),0) as amount from
quant_purchase join jrnx using (j_id)
+ $sql = "select coalesce(sum(qp_price),0) as amount from
quant_purchase join jrnx as jrn1 using (j_id)
where qp_vat_code=$1 $sql_date
and j_poste::text like ($4)
$filter_ledger";
@@ -920,7 +930,7 @@
if ($this->form->jrn_def_type == 'VEN')
{
$sql = "select coalesce(sum(qs_price),0) as amount from quant_sold
- join jrnx using (j_id)
+ join jrnx as jrn1 using (j_id)
where qs_vat_code=$1 $sql_date
and j_poste::text like ($4)
$filter_ledger";
$amount = $this->cn->get_value($sql, array($this->form->tva_id,
@@ -998,7 +1008,8 @@
$filter_ledger = " and jrn1.j_jrn_def = " .
sql_string($this->form->jrn_def_id);
}
- if ($this->form->date_paid == 1)
+ $sql_date=RAPAV::get_sql_date($this->form->date_paid );
+ /*if ($this->form->date_paid == 1)
{
$sql_date=" and j_id in
(select j_id from jrnx join jrn on (j_grpt = jr_grpt_id)
@@ -1012,7 +1023,7 @@
else
{
$sql_date="and (jrn1.j_date >= to_date($3,'DD.MM.YYYY') and
jrn1.j_date <= to_date($4,'DD.MM.YYYY'))";
- }
+ }*/
bcscale(2);
switch ($this->form->type_sum_account)
{
@@ -1028,17 +1039,17 @@
join jrnx as jrn2 on (jrn1.j_grpt=jrn2.j_grpt)
where
jrn1.j_poste like $1
+ $sql_date
and
- jrn2.j_poste like $2
- $sql_date
+ jrn2.j_poste like $4
$filter_ledger
) as tv_amount
";
$amount = $cn->get_value($sql, array(
$this->form->tmp_val,
- $this->form->with_tmp_val,
$p_start,
- $p_end
+ $p_end,
+ $this->form->with_tmp_val
));
// if C-D is asked then reverse the result
if ($this->form->type_sum_account == 2)
---
PhpCompta est un logiciel de comptabilité libre en ligne (full web)
Projet opensource http://www.phpcompta.eu
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Phpcompta-dev] r593 - in trunk/rapport_avance: . doc include,
phpcompta-dev <=