[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Noalyss-commit] [noalyss] 61/323: Fix some issues with PRINTJRN
From: |
Dany De Bontridder |
Subject: |
[Noalyss-commit] [noalyss] 61/323: Fix some issues with PRINTJRN |
Date: |
Wed, 14 Mar 2018 17:38:18 -0400 (EDT) |
sparkyx pushed a commit to branch master
in repository noalyss.
commit 4b3e8d33ba9e0cf55ad06993c28624bf6e8eedfe
Author: Dany De Bontridder <address@hidden>
Date: Wed Jan 17 21:51:19 2018 +0100
Fix some issues with PRINTJRN
---
html/user_login.php | 3 +-
include/class/acc_ledger.class.php | 130 +++++++++++++++++++++++++++-
include/class/print_ledger_simple.class.php | 36 +++++---
include/template/print_ledger_simple.php | 53 ++++++++----
4 files changed, 192 insertions(+), 30 deletions(-)
diff --git a/html/user_login.php b/html/user_login.php
index 2063dbe..8eec383 100644
--- a/html/user_login.php
+++ b/html/user_login.php
@@ -27,8 +27,9 @@ require_once NOALYSS_INCLUDE.'/lib/database.class.php';
require_once NOALYSS_INCLUDE.'/lib/itext.class.php';
require_once NOALYSS_INCLUDE.'/lib/http_input.class.php';
require_once NOALYSS_INCLUDE.'/lib/function_javascript.php';
+require_once NOALYSS_INCLUDE.'/lib/icon_action.class.php';
address@hidden($_SESSION['g_theme']);
+html_page_start($_SESSION['g_theme']);
$rep=new Database();
require_once NOALYSS_INCLUDE.'/class/user.class.php';
$User=new User($rep);
diff --git a/include/class/acc_ledger.class.php
b/include/class/acc_ledger.class.php
index 2e10a2d..d2d3e3a 100644
--- a/include/class/acc_ledger.class.php
+++ b/include/class/acc_ledger.class.php
@@ -646,6 +646,22 @@ class Acc_Ledger extends jrn_def_sql
*
* @paramp_array the structure is set in get_rowSimple, this array is
* modified,
+ @verbatim
+ jrn.jr_id as jr_id ,
+ jrn.jr_id as num ,
+ jrn.jr_def_id as jr_def_id,
+ jrn.jr_montant as montant,
+ substr(jrn.jr_comment,1,35) as comment,
+ to_char(jrn.jr_date,'DD-MM-YYYY') as date,
+ to_char(jrn.jr_date_paid,'DD-MM-YYYY') as date_paid,
+ jr_pj_number,
+ jr_internal,
+ jrn.jr_grpt_id as grpt_id,
+ jrn.jr_pj_name as pj,
+ jrn_def_type,
+ jrn.jr_tech_per
+ @endverbatim
+ *
* @param $trunc if the data must be truncated, usefull for pdf export
* @paramp_jrn_type is the type of the ledger (ACH or VEN)
* @param $a_TVA TVA Array (default null)
@@ -671,6 +687,7 @@ class Acc_Ledger extends jrn_def_sql
// init
$p_array['client']="";
$p_array['TVAC']=0;
+ $p_array['HTVA']=0;
$p_array['TVA']=array();
$p_array['AMOUNT_TVA']=0.0;
$p_array['dep_priv']=0;
@@ -678,7 +695,87 @@ class Acc_Ledger extends jrn_def_sql
$p_array['tva_dna']=0;
$p_array['tva_np']=0;
$dep_priv=0.0;
+
+
+ // if using the QUANT_* tables then get there the needed info
+ //
+ if (
$this->use_quant_table($p_array['grpt_id'],$p_array['jrn_def_type']) == TRUE)
+ {
+ // Initialize amount for VAT
+ $nb_tva=count($a_TVA);
+ for ($i=0;$i<$nb_tva;$i++) {
+ $p_array['TVA'][$i]=array($i,
+ array(
+ $a_TVA[$i]['tva_id'],
+ $a_TVA[$i]['tva_label'],
+ 0)
+ );
+ }
+ switch ($p_array['jrn_def_type'])
+ {
+ case "ACH":
+ $sql="select
+ sum(coalesce(qp_price,0)) as htva,
+ sum(coalesce(qp_vat)) as vat,
+ sum(coalesce(qp_nd_tva)) as nd_tva,
+ sum(coalesce(qp_nd_tva_recup)) as nd_tva_recup,
+ sum(coalesce(qp_dep_priv)) as dep_priv,
+ qp_vat_code as tva_code,
+ qp_supplier as fiche_id,
+ qp_vat_sided as tva_sided
+ from
+ quant_purchase
+ where
+ qp_internal=$1
+ group by qp_supplier,qp_vat_code,qp_vat_sided ";
+ break;
+ case "VEN":
+ $sql="select
+ sum(coalesce(qs_price,0)) as htva,
+ sum(coalesce(qs_vat)) as vat,
+ sum(0) as nd_tva,
+ sum(0) as nd_tva_recup,
+ sum(0) as dep_priv,
+ qs_vat_code as tva_code,
+ qs_client as fiche_id,
+ qs_vat_sided as tva_sided
+ from
+ quant_sold
+ where
+ qs_internal=$1
+ group by qs_client,qs_vat_code,qs_vat_sided ";
+ break;
+ default:
+ break;
+ }
+
$a_detail=$this->db->get_array($sql,array($p_array['jr_internal']));
+ $nb_detail=count($a_detail);
+ for ($x=0;$x<$nb_detail;$x++) {
+ $p_array['HTVA']=bcadd($p_array['HTVA'],$a_detail[$x]['htva']);
+
$p_array['tva_dna']=bcadd($p_array['tva_dna'],$a_detail[$x]['nd_tva_recup']);
+
$p_array['tva_dna']=bcadd($p_array['tva_dna'],$a_detail[$x]['nd_tva']);
+ $p_array['TVAC']=bcadd($p_array['TVAC'],$a_detail[$x]['htva']);
+ if ( $a_detail[$x]['tva_sided'] == 0)
+
$p_array['TVAC']=bcadd($p_array['TVAC'],$a_detail[$x]['vat']);
+
$p_array['TVAC']=bcadd($p_array['TVAC'],$a_detail[$x]['nd_tva']);
+
$p_array['TVAC']=bcadd($p_array['TVAC'],$a_detail[$x]['nd_tva_recup']);
+
$p_array['dep_priv']=bcadd($p_array['dep_priv'],$a_detail[$x]['dep_priv']);
+ $xdx=$a_detail[$x]['tva_code'];
+ //
$p_array['TVA'][$xdx]=bcadd($p_array['TVA'][$xdx],$a_detail[$x]['vat']);
+ //--- Put VAT in the right place in the array $a_TVA
+ $nb_tva=count($a_TVA);
+ for ($j=0;$j<$nb_tva;$j++) {
+ if ( $xdx == $p_array['TVA'][$j][1][0]) {
+
$p_array['TVA'][$j][1][2]=bcadd($p_array['TVA'][$j][1][2],$a_detail[$x]['vat']);
+
+ }
+ }
+ }
+ $fiche=new Fiche($this->db,$a_detail[0]['fiche_id']);
+
$p_array['client']=($trunc==0)?$fiche->getName():mb_substr($fiche->getName(),0,
20);
+ return $p_array;
+ }
//
// Retrieve data from jrnx
// Order is important for TVA autoreversed
@@ -3244,7 +3341,38 @@ class Acc_Ledger extends jrn_def_sql
{
return $this->db->get_value("select jrn_enable from jrn_def where
jrn_def_id=$1",[$this->id]);
}
-
+ /**
+ * Check if the operation is used in the table quant*
+ * @param integer $p_grpt_id
+ * @param string $p_jrn_type ledger's type ACH, VEN,ODS or FIN
+ * @return boolean TRUE if existing info in quant*
+ * @Exceptions code 1000 if unknown ledger's type
+ */
+ function use_quant_table($p_grpt_id,$p_jrn_type)
+ {
+ if ( $p_jrn_type == 'ACH')
+ {
+ $sql="select count(*) from jrnx join quant_purchase using (j_id)
where j_grpt=$1";
+ }elseif ($p_jrn_type=='VEN')
+ {
+ $sql="select count(*) from jrnx join quant_sold using (j_id) where
j_grpt=$1";
+ }elseif ($p_jrn_type=='FIN')
+ {
+ $sql="select count(*) from jrn join quant_fin using (jr_id) where
jr_grpt_id=$1";
+
+ }elseif ($p_jrn_type=='ODS') return 0;
+ else
+ {
+ throw new Exception(_('Journal incorrect'),1000);
+ }
+
+ $count=$this->db->get_value($sql,[$p_grpt_id]);
+
+ if ($count > 0) return TRUE;
+
+ return FALSE;
+
+ }
}
?>
diff --git a/include/class/print_ledger_simple.class.php
b/include/class/print_ledger_simple.class.php
index f40b69d..114d5f2 100644
--- a/include/class/print_ledger_simple.class.php
+++ b/include/class/print_ledger_simple.class.php
@@ -59,7 +59,10 @@ class Print_Ledger_Simple extends PDF
}
$this->rap_htva=$this->previous['price'];
- $this->rap_tvac=$this->previous['price']+$this->previous['vat'];
+ $this->rap_tvac=bcadd($this->previous['price'],$this->previous['vat']);
+ $this->rap_tvac=bcadd($this->rap_tvac,$this->previous['tva_nd']);
+ $this->rap_tvac=bcsub($this->rap_tvac,$this->previous['tva_np']);
+ $this->rap_tvac=bcsub($this->rap_tvac,$this->previous['reversed']);
$this->rap_priv=$this->previous['priv'];
$this->rap_nd=$this->previous['tva_nd'];
$this->rap_tva_np=$this->previous['tva_np'];
@@ -237,16 +240,7 @@ class Print_Ledger_Simple extends PDF
/* get other amount (without vat, total vat included, private, ND
*/
$other=$this->ledger->get_other_amount($a_jrn[$i]['jr_grpt_id']);
- $this->tp_htva=bcadd($this->tp_htva,$other['price']);
- $this->tp_tvac=bcadd($this->tp_tvac,$other['price']+$other['vat']);
- $this->tp_tva_np=bcadd($this->tp_tva_np,$other['tva_np']);
- $this->tp_priv=bcadd($this->tp_priv,$other['priv']);
- $this->tp_nd=bcadd($this->tp_nd,$other['tva_nd']);
- $this->rap_htva=bcadd($this->rap_htva,$other['price']);
- $this->rap_tvac=bcadd($this->rap_tvac,bcadd($other['price'],
bcsub($other['vat'],$other['tva_np'])));
- $this->rap_priv=bcadd($this->rap_priv,$other['priv']);
- $this->rap_nd=bcadd($this->rap_nd,$other['tva_nd']);
- $this->rap_tva_np=bcadd($this->rap_tva_np,$other['tva_np']);
+
$this->write_cell(15,5,nbm($other['price']),0,0,'R');
@@ -267,6 +261,26 @@ class Print_Ledger_Simple extends PDF
$l_tvac=bcadd($l_tvac,$other['tva_nd']);
$this->write_cell(15,5,nbm($l_tvac),0,0,'R');
$this->line_new(5);
+ // Total page
+ $this->tp_htva=bcadd($this->tp_htva,$other['price']);
+ $this->tp_tvac=bcadd($this->tp_tvac,$other['price']);
+ $this->tp_tvac=bcadd($this->tp_tvac,$other['vat']);
+ $this->tp_tvac=bcadd($this->tp_tvac,$other['tva_nd']);
+ $this->tp_tvac=bcsub($this->tp_tvac,$other['tva_np']);
+ $this->tp_tva_np=bcadd($this->tp_tva_np,$other['tva_np']);
+ $this->tp_priv=bcadd($this->tp_priv,$other['priv']);
+ $this->tp_nd=bcadd($this->tp_nd,$other['tva_nd']);
+
+ // Total report
+ $this->rap_htva=bcadd($this->rap_htva,$other['price']);
+ $this->rap_tvac=bcadd($this->rap_tvac,$other['price']);
+ $this->rap_tvac=bcadd($this->rap_tvac,$other['vat']);
+ $this->rap_tvac=bcsub($this->rap_tvac,$other['tva_np']);
+ $this->rap_tvac=bcadd($this->rap_tvac,$other['tva_nd']);
+ $this->rap_priv=bcadd($this->rap_priv,$other['priv']);
+ $this->rap_nd=bcadd($this->rap_nd,$other['tva_nd']);
+ $this->rap_tva_np=bcadd($this->rap_tva_np,$other['tva_np']);
+
}
}
diff --git a/include/template/print_ledger_simple.php
b/include/template/print_ledger_simple.php
index 7ea1ce4..5656c60 100644
--- a/include/template/print_ledger_simple.php
+++ b/include/template/print_ledger_simple.php
@@ -40,42 +40,60 @@ $tot['dna']=0;
$tot['tva_nd']=0;
$tot['tvac']=0;
$tot['tva']=array();
-bcscale(2);
+bcscale(4);
foreach ($Row as $line) {
$i++;
/*
* Get date of reconcile operation
*/
$ret_reconcile=$cn->execute('reconcile_date',array($line['jr_id']));
- if ($line["jr_pj_number"]=="A17.1392") { var_dump($line); echo
"1-".$line['HTVA'];}
$class = ($i % 2 == 0) ? ' class="even" ' : ' class="odd" ';
echo "<tr $class>";
+
+ // Receipt number
echo "<TD>" . h($line['jr_pj_number']) . "</TD>";
+
+ // Date
echo "<TD>" . smaller_date($line['date']) . "</TD>";
echo "<TD>" . smaller_date($line['date_paid']) . "</TD>";
+
+ // Internal with detail
echo "<TD>" . HtmlInput::detail_op($line['jr_id'], $line['jr_internal']) .
"</TD>";
+
+ // find the tiers (normally in $Row !
$tiers = $Jrn->get_tiers($line['jrn_def_type'], $line['jr_id']);
- if ($line["jr_pj_number"]=="A17.1392") { echo "2-".$line['HTVA'];}
echo td($tiers);
+
+ // Label
echo "<TD>" . h($line['comment']) . "</TD>";
- $dep_priv=($line['dep_priv']==0)?"":nbm($line['dep_priv']);
+
+ // Private expense
+ $dep_priv=($line['dep_priv']==0)?"":nbm(round($line['dep_priv'],2),2);
$tot['dep_priv']=bcadd($tot['dep_priv'], floatval($line['dep_priv']));
- $dna=($line['dna']==0)?"":nbm($line['dna']);
- $tot['dna']=bcadd($tot['dna'],floatval($line['dna']));
- if ($line["jr_pj_number"]=="A17.1392") { echo "3-".$line['HTVA'];}
- echo "<TD class=\"num\">" . nbm($line['HTVA']) . "</TD>";
- $tot['htva']=bcadd($tot['htva'], floatval($line['HTVA']));
+
+ // No deductible
+ $dna=($line['dna']==0)?"":nbm(round($line['dna'],2),2);
+ $tot['dna']=bcadd($tot['dna'],round(floatval($line['dna'])),2);
+
+ // HTVA amount
+ echo "<TD class=\"num\">" . nbm(round($line['HTVA'],2),2) . "</TD>";
+ $tot['htva']=bcadd($tot['htva'], round(floatval($line['HTVA']),2));
echo "<TD class=\"num\">" .$dep_priv . "</TD>";
echo "<TD class=\"num\">" . $dna . "</TD>";
+
+
//--------------------------------------------------------------------------
+ // If VAT then display it
+
//--------------------------------------------------------------------------
if ($own->MY_TVA_USE == 'Y' )
{
- $tva_dna=($line['tva_dna']==0)?"":nbm($line['tva_dna']);
- $tot['tva_nd']=bcadd($tot['tva_nd'], floatval($line['tva_dna']));
+ $tva_dna=($line['tva_dna']==0)?"":nbm(round($line['tva_dna']),2);
+ $tot['tva_nd']=bcadd($tot['tva_nd'],
round(floatval($line['tva_dna']),2));
echo "<TD class=\"num\">" . $tva_dna. "</TD>";
$a_tva_amount=array();
+
foreach ($line['TVA'] as $lineTVA)
- {
+ {
foreach ($a_Tva as $idx=>$line_tva)
{
@@ -89,16 +107,17 @@ foreach ($Row as $line) {
foreach ($a_Tva as $line_tva)
{
$a=$line_tva['tva_id'];
- if ( isset($a_tva_amount[$a])) {
- echo '<td class="num">'.nb($a_tva_amount[$a]).'</td>';
-
$tot['tva'][$a]=(isset($tot['tva'][$a]))?bcadd($tot['tva'][$a],floatval($a_tva_amount[$a])):floatval($a_tva_amount[$a]);
+ if ( isset($a_tva_amount[$a]) && $a_tva_amount[$a] != 0) {
+ echo '<td class="num">'.nb(round($a_tva_amount[$a],2)).'</td>';
+
$tot['tva'][$a]=(isset($tot['tva'][$a]))?bcadd($tot['tva'][$a],round(floatval($a_tva_amount[$a]),2)):round(floatval($a_tva_amount[$a]),2);
}
else
printf("<td class=\"num\"></td>");
}
}
- echo '<td class="num">'.$line['TVAC'].'</td>';
- $tot['tvac']=bcadd($tot['tvac'], floatval($line['TVAC']));
+
+ echo '<td class="num">'.round($line['TVAC'],2).'</td>';
+ $tot['tvac']=bcadd($tot['tvac'], round(floatval($line['TVAC']),2));
/*
* If reconcile print them
*/
- [Noalyss-commit] [noalyss] 69/323: Task #0001530: Réécriture PRINTJRN : export PDF, (continued)
- [Noalyss-commit] [noalyss] 69/323: Task #0001530: Réécriture PRINTJRN : export PDF, Dany De Bontridder, 2018/03/14
- [Noalyss-commit] [noalyss] 80/323: before deleting a card , check if it is not used as an attribute in another card, Dany De Bontridder, 2018/03/14
- [Noalyss-commit] [noalyss] 78/323: esthetic, Dany De Bontridder, 2018/03/14
- [Noalyss-commit] [noalyss] 70/323: Task #0001530: Réécriture PRINTJRN : export CSV : Purchase List (L), Dany De Bontridder, 2018/03/14
- [Noalyss-commit] [noalyss] 73/323: Missing import of icon_action, Dany De Bontridder, 2018/03/14
- [Noalyss-commit] [noalyss] 75/323: Merge branch 'rewrite-printjrn', Dany De Bontridder, 2018/03/14
- [Noalyss-commit] [noalyss] 76/323: Small bug in save_card, Dany De Bontridder, 2018/03/14
- [Noalyss-commit] [noalyss] 71/323: task #1531: Historique poste et fiche d'après exercice opération, Dany De Bontridder, 2018/03/14
- [Noalyss-commit] [noalyss] 83/323: Esthétique Recherche action, Dany De Bontridder, 2018/03/14
- [Noalyss-commit] [noalyss] 68/323: Task #0001530: Réécriture PRINTJRN Add Financial Ledger Adapt test file, Dany De Bontridder, 2018/03/14
- [Noalyss-commit] [noalyss] 61/323: Fix some issues with PRINTJRN,
Dany De Bontridder <=
- [Noalyss-commit] [noalyss] 79/323: before deleting a card , check if it is not used as an attribute in another card, Dany De Bontridder, 2018/03/14
- [Noalyss-commit] [noalyss] 04/323: Improve Doxygen documentation, Dany De Bontridder, 2018/03/14
- [Noalyss-commit] [noalyss] 60/323: remove deprecated theme, Dany De Bontridder, 2018/03/14
- [Noalyss-commit] [noalyss] 56/323: Task #0001527: Effacement du champ code fiche : bouton, Dany De Bontridder, 2018/03/14
- [Noalyss-commit] [noalyss] 43/323: Rewriting Change class Own by Noalyss_Parameter_Folder, Dany De Bontridder, 2018/03/14
- [Noalyss-commit] [noalyss] 84/323: Doc, Dany De Bontridder, 2018/03/14
- [Noalyss-commit] [noalyss] 81/323: task #1531: Historique poste et fiche d'après exercice opération Fait aussi pour le bouton historique, Dany De Bontridder, 2018/03/14
- [Noalyss-commit] [noalyss] 85/323: cosmetique, Dany De Bontridder, 2018/03/14
- [Noalyss-commit] [noalyss] 82/323: Esthétique Recherche action, Dany De Bontridder, 2018/03/14
- [Noalyss-commit] [noalyss] 88/323: comment, Dany De Bontridder, 2018/03/14