[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Phpcompta-dev] r5161 - in phpcompta/tags/rel650/include: . template
From: |
phpcompta-dev |
Subject: |
[Phpcompta-dev] r5161 - in phpcompta/tags/rel650/include: . template |
Date: |
Thu, 6 Dec 2012 22:56:37 +0100 (CET) |
Author: danydb
Date: 2012-12-06 22:56:36 +0100 (Thu, 06 Dec 2012)
New Revision: 5161
Modified:
phpcompta/tags/rel650/include/class_acc_ledger.php
phpcompta/tags/rel650/include/class_acc_ledger_purchase.php
phpcompta/tags/rel650/include/class_acc_ledger_sold.php
phpcompta/tags/rel650/include/class_acc_operation.php
phpcompta/tags/rel650/include/export_histo_csv.php
phpcompta/tags/rel650/include/template/ledger_detail_ach.php
phpcompta/tags/rel650/include/template/ledger_detail_ven.php
Log:
0000762: TVA intracommunautaire : montant facture au lieu montant
op?\195?\169ration
Modified: phpcompta/tags/rel650/include/class_acc_ledger.php
===================================================================
--- phpcompta/tags/rel650/include/class_acc_ledger.php 2012-12-06 20:51:09 UTC
(rev 5160)
+++ phpcompta/tags/rel650/include/class_acc_ledger.php 2012-12-06 21:56:36 UTC
(rev 5161)
@@ -799,6 +799,7 @@
public function list_operation($sql, $offset, $p_paid = 0)
{
global $g_parameter, $g_user;
+ bcscale(2);
$table = new Sort_Table();
$gDossier = dossier::id();
$amount_paid = 0.0;
@@ -924,10 +925,12 @@
$positive = ($positive < 0) ? 1 : 0;
}
$r.="<TD align=\"right\">";
-
- $tot = ($positive != 0) ? $tot - $row['jr_montant'] :
$tot + $row['jr_montant'];
+ $t_amount=$row['jr_montant'];
+ if ($row['total_invoice'] != null &&
$row['total_invoice'] != $row['jr_montant'])
+ $t_amount=$row['total_invoice'];
+ $tot = ($positive != 0) ? bcsub($tot , $t_amount ):
bcadd($tot , $t_amount);
//STAN $positive always == 0
- $r.=( $positive != 0 ) ? "<font color=\"red\"> - " .
nbm($row['jr_montant']) . "</font>" : nbm($row['jr_montant']);
+ $r.=( $positive != 0 ) ? "<font color=\"red\"> - " .
nbm($t_amount) . "</font>" : nbm($t_amount);
$r.="</TD>";
@@ -2536,7 +2539,20 @@
when jrn_def_type='VEN' then (select ad_value from fiche_detail
where ad_id=23 and f_id=(select max(qs_client) from quant_sold join jrnx using
(j_id) join jrn as e on (e.jr_grpt_id=j_grpt) where e.jr_id=x.jr_id))
when jrn_def_type = 'ACH' then (select ad_value from fiche_detail
where ad_id=23 and f_id=(select max(qp_supplier) from quant_purchase join jrnx
using (j_id) join jrn as e on (e.jr_grpt_id=j_grpt) where e.jr_id=x.jr_id))
when jrn_def_type = 'FIN' then (select ad_value from fiche_detail
where ad_id=23 and f_id=(select qf_other from quant_fin where
quant_fin.jr_id=x.jr_id))
- end as quick_code
+ end as quick_code,
+ case
+ when jrn_def_type='VEN' then
+ (select sum(qs_price)+sum(vat) from
+ (select qs_internal,qs_price,case when
qs_vat_sided<>0 then 0 else qs_vat end as vat from quant_sold where
qs_internal=X.jr_internal) as ven_invoice
+ )
+ when jrn_def_type = 'ACH' then
+ (
+ select
sum(qp_price)+sum(vat)+sum(qp_nd_tva)+sum(qp_nd_tva_recup)
+ from
+ (select
qp_internal,qp_price,qp_nd_tva,qp_nd_tva_recup,case when qp_vat_sided<>0 then 0
else qp_vat end as vat from quant_purchase where qp_internal=X.jr_internal) as
invoice_purchase
+ )
+ else null
+ end as total_invoice
from
Modified: phpcompta/tags/rel650/include/class_acc_ledger_purchase.php
===================================================================
--- phpcompta/tags/rel650/include/class_acc_ledger_purchase.php 2012-12-06
20:51:09 UTC (rev 5160)
+++ phpcompta/tags/rel650/include/class_acc_ledger_purchase.php 2012-12-06
21:56:36 UTC (rev 5161)
@@ -354,7 +354,7 @@
/* First we save all the items without vat */
$fiche=new Fiche($this->db);
$fiche->get_by_qcode(${"e_march".$i});
-
+ $tva_both=0;
/* tva */
if ($g_parameter->MY_TVA_USE=='Y')
{
@@ -362,6 +362,7 @@
$oTva=new Acc_Tva($this->db);
$oTva->set_parameter('id',$idx_tva);
$oTva->load();
+
$tva_both=$oTva->get_parameter("both_side");
}
/* We have to compute all the amount thanks Acc_Compute */
@@ -382,7 +383,7 @@
$acc_amount->amount_vat= ${'e_march'.$i.'_tva_amount'};
}
- if ($oTva->get_parameter("both_side")==0)
$tot_tva=bcadd($tot_tva,$acc_amount->amount_vat);
+ if ($tva_both==0)
$tot_tva=bcadd($tot_tva,$acc_amount->amount_vat);
}
$acc_operation=new Acc_Operation($this->db);
@@ -415,7 +416,7 @@
$tot_perso+=$acc_amount->amount_perso;
}
- if ( ! $fiche->empty_attribute(ATTR_DEF_TVA_NON_DEDUCTIBLE))
+ if ( ! $fiche->empty_attribute(ATTR_DEF_TVA_NON_DEDUCTIBLE) &&
$tva_both==0)
{
$acc_amount->nd_vat_rate=$fiche->strAttribut(ATTR_DEF_TVA_NON_DEDUCTIBLE);
$acc_amount->compute_nd_vat();
@@ -423,7 +424,7 @@
/* save op. */
}
- if ( !
$fiche->empty_attribute(ATTR_DEF_TVA_NON_DEDUCTIBLE_RECUP))
+ if ( !
$fiche->empty_attribute(ATTR_DEF_TVA_NON_DEDUCTIBLE_RECUP) && $tva_both==0)
{
$acc_amount->nd_ded_vat_rate=$fiche->strAttribut(ATTR_DEF_TVA_NON_DEDUCTIBLE_RECUP);
$acc_amount->compute_ndded_vat();
@@ -492,7 +493,7 @@
//-----
if ( $g_parameter->MY_TVA_USE=='Y')
{
- if ( $oTva->get_parameter("both_side")==1)
$n_both=$acc_amount->amount_vat;
+ if ( $tva_both==1) $n_both=$acc_amount->amount_vat;
$r=$this->db->exec_sql("select insert_quant_purchase ".
"(null".
@@ -602,7 +603,7 @@
/* save op. */
$acc_operation->type='d';
$acc_operation->qcode='';
- if ( ! $fiche->empty_attribute(ATTR_DEF_ACCOUNT_ND_TVA_ND))
+ if ( ! $fiche->empty_attribute(ATTR_DEF_ACCOUNT_ND_TVA_ND) &&
$tva_both==0)
{
$dna=$fiche->strAttribut(ATTR_DEF_ACCOUNT_ND_TVA_ND);
}
@@ -622,7 +623,7 @@
{
$dna_default=new Acc_Parm_Code($this->db,'TVA_DED_IMPOT');
/* save op. */
- if ( ! $fiche->empty_attribute(ATTR_DEF_ACCOUNT_ND_TVA))
+ if ( ! $fiche->empty_attribute(ATTR_DEF_ACCOUNT_ND_TVA) &&
$tva_both==0)
{
$dna=$fiche->strAttribut(ATTR_DEF_ACCOUNT_ND_TVA);
}
@@ -1087,10 +1088,8 @@
/* use vat */
if ( $g_parameter->MY_TVA_USE=='Y')
{
-
$march_tva_id=(isset(${"e_march$i"."_tva_id"}))?${"e_march$i"."_tva_id"}:""
- ;
-
$march_tva_amount=(isset(${"e_march$i"."_tva_amount"}))?${"e_march$i"."_tva_amount"}:""
- ;
+
$march_tva_id=(isset(${"e_march$i"."_tva_id"}))?${"e_march$i"."_tva_id"}:"";
+
$march_tva_amount=(isset(${"e_march$i"."_tva_amount"}))?${"e_march$i"."_tva_amount"}:"";
}
Modified: phpcompta/tags/rel650/include/class_acc_ledger_sold.php
===================================================================
--- phpcompta/tags/rel650/include/class_acc_ledger_sold.php 2012-12-06
20:51:09 UTC (rev 5160)
+++ phpcompta/tags/rel650/include/class_acc_ledger_sold.php 2012-12-06
21:56:36 UTC (rev 5161)
@@ -324,8 +324,8 @@
$oTva=new Acc_Tva($this->db);
$idx_tva=${'e_march'.$i.'_tva_id'};
$tva_item=${'e_march'.$i.'_tva_amount'};
- $oTva->set_parameter("id",$idx_tva);
- $oTva->load();
+ $oTva->set_parameter("id",$idx_tva);
+ $oTva->load();
/* if empty then we need to compute it */
if (trim($tva_item)=='')
{
Modified: phpcompta/tags/rel650/include/class_acc_operation.php
===================================================================
--- phpcompta/tags/rel650/include/class_acc_operation.php 2012-12-06
20:51:09 UTC (rev 5160)
+++ phpcompta/tags/rel650/include/class_acc_operation.php 2012-12-06
21:56:36 UTC (rev 5161)
@@ -602,7 +602,7 @@
{
parent::get();
$sql="SELECT qs_id, qs_internal, qs_fiche, qs_quantite, qs_price,
qs_vat,
- qs_vat_code, qs_client, qs_valid, j_id,j_text
+ qs_vat_code, qs_client, qs_valid, j_id,j_text,qs_vat_sided
FROM quant_sold join jrnx using(j_id) where j_grpt=$1";
$this->det->array=$this->db->get_array($sql,array($this->det->jr_grpt_id));
}
@@ -627,7 +627,7 @@
parent::get();
$sql="SELECT qp_id, qp_internal, j_id, qp_fiche, qp_quantite,
qp_price, qp_vat,
qp_vat_code, qp_nd_amount, qp_nd_tva, qp_nd_tva_recup,
qp_supplier,
- qp_valid, qp_dep_priv,j_text
+ qp_valid, qp_dep_priv,j_text,qp_vat_sided
FROM quant_purchase join jrnx using(j_id) where j_grpt=$1";
$this->det->array=$this->db->get_array($sql,array($this->det->jr_grpt_id));
}
Modified: phpcompta/tags/rel650/include/export_histo_csv.php
===================================================================
--- phpcompta/tags/rel650/include/export_histo_csv.php 2012-12-06 20:51:09 UTC
(rev 5160)
+++ phpcompta/tags/rel650/include/export_histo_csv.php 2012-12-06 21:56:36 UTC
(rev 5161)
@@ -43,7 +43,7 @@
printf('"%s";',"Tiers");
printf('"%s";',"Description");
printf('"%s";',"Note");
-printf('"%s"',"Montant");
+printf('"%s"',"Montant opération");
printf("\r\n");
for ($i=0;$i<count($res);$i++)
@@ -60,12 +60,13 @@
$amount=$res[$i]['jr_montant'];
+ if ( $res[$i]['total_invoice']!=null &&
$res[$i]['jr_montant']!=$res[$i]['total_invoice'])
+ $amount=$res[$i]['total_invoice'];
if ( $res[$i]['jrn_def_type'] == 'FIN')
{
- $positive = $cn->get_value("select qf_amount from quant_fin where
jr_id=$1",array($res[$i]['jr_id']));
- if ( $positive !='' ) $amount=$positive;
+ $positive = $cn->get_value("select qf_amount from quant_fin
where jr_id=$1",array($res[$i]['jr_id']));
+ if ( $positive !='' ) $amount=$positive;
}
-
printf('%s',nb($amount));
printf("\r\n");
Modified: phpcompta/tags/rel650/include/template/ledger_detail_ach.php
===================================================================
--- phpcompta/tags/rel650/include/template/ledger_detail_ach.php
2012-12-06 20:51:09 UTC (rev 5160)
+++ phpcompta/tags/rel650/include/template/ledger_detail_ach.php
2012-12-06 21:56:36 UTC (rev 5161)
@@ -182,7 +182,7 @@
$tva_amount=bcadd($q['qp_vat'],$q['qp_nd_tva']);
$tva_amount=bcadd($tva_amount,$q['qp_nd_tva_recup']);
$class="";
- if ($tva->get_parameter("both_side")==1) {
+ if ($q['qp_vat_sided']<>0) {
$class=' style="text-decoration:line-through"';
$tvac=bcsub($tvac,$q['qp_vat']);
}
Modified: phpcompta/tags/rel650/include/template/ledger_detail_ven.php
===================================================================
--- phpcompta/tags/rel650/include/template/ledger_detail_ven.php
2012-12-06 20:51:09 UTC (rev 5160)
+++ phpcompta/tags/rel650/include/template/ledger_detail_ven.php
2012-12-06 21:56:36 UTC (rev 5161)
@@ -176,7 +176,7 @@
if ($owner->MY_TVA_USE=='Y')
{
$class="";
- if ($tva->get_parameter("both_side")==1) {
+ if ($q['qs_vat_sided'] != 0) {
$class=' style="text-decoration:line-through"';
$tvac=bcsub($tvac,$q['qs_vat']);
}
---
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] r5161 - in phpcompta/tags/rel650/include: . template,
phpcompta-dev <=