[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Phpcompta-dev] r4406 - in phpcompta/trunk: include sql
From: |
phpcompta-dev |
Subject: |
[Phpcompta-dev] r4406 - in phpcompta/trunk: include sql |
Date: |
Fri, 18 Nov 2011 15:55:15 +0100 (CET) |
Author: danydb
Date: 2011-11-18 15:55:13 +0100 (Fri, 18 Nov 2011)
New Revision: 4406
Modified:
phpcompta/trunk/include/class_acc_ledger_purchase.php
phpcompta/trunk/include/class_acc_ledger_sold.php
phpcompta/trunk/include/class_acc_tva.php
phpcompta/trunk/include/tva.inc.php
phpcompta/trunk/sql/tva.sql
Log:
0000392: Cocontractant : TVA au d?\195?\169bit ET cr?\195?\169dit
Modified: phpcompta/trunk/include/class_acc_ledger_purchase.php
===================================================================
--- phpcompta/trunk/include/class_acc_ledger_purchase.php 2011-11-18
14:52:58 UTC (rev 4405)
+++ phpcompta/trunk/include/class_acc_ledger_purchase.php 2011-11-18
14:55:13 UTC (rev 4406)
@@ -384,7 +384,7 @@
$acc_amount->amount_vat= ${'e_march'.$i.'_tva_amount'};
}
- $tot_tva+=$acc_amount->amount_vat;
+ if ($oTva->get_parameter("both_side")==0)
$tot_tva=bcadd($tot_tva,$acc_amount->amount_vat);
}
$acc_operation=new Acc_Operation($this->db);
@@ -667,6 +667,20 @@
$acc_operation->periode=$tperiode;
if ( $value > 0 ) $tot_debit=bcadd($tot_debit,$value);
$acc_operation->insert_jrnx();
+ // if TVA is on both side, we deduce it immediately
+ if ( $oTva->get_parameter("both_side")==1)
+ {
+ $poste_vat=$oTva->get_side('c');
+ $cust_amount=bcadd($tot_amount,$tot_tva);
+ $acc_operation=new Acc_Operation($this->db);
+ $acc_operation->date=$e_date;
+ $acc_operation->poste=$poste_vat;
+ $acc_operation->amount=$value;
+ $acc_operation->grpt=$seq;
+ $acc_operation->jrn=$p_jrn;
+ $acc_operation->type='c';
+ $acc_operation->periode=$tperiode;
+ }
}
}
Modified: phpcompta/trunk/include/class_acc_ledger_sold.php
===================================================================
--- phpcompta/trunk/include/class_acc_ledger_sold.php 2011-11-18 14:52:58 UTC
(rev 4405)
+++ phpcompta/trunk/include/class_acc_ledger_sold.php 2011-11-18 14:55:13 UTC
(rev 4406)
@@ -333,7 +333,7 @@
$tva[$idx_tva]+=$tva_item;
else
$tva[$idx_tva]=$tva_item;
- $tot_tva=round(bcadd($tva_item,$tot_tva),2);
+ if ($oTva->get_parameter("both_side")==0)
$tot_tva=round(bcadd($tva_item,$tot_tva),2);
}
/* Save the stock */
@@ -429,6 +429,21 @@
$acc_operation->periode=$tperiode;
if ($value < 0 ) $tot_debit=bcadd($tot_debit,abs($value));
$acc_operation->insert_jrnx();
+
+ // if TVA is on both side, we deduce it immediately
+ if ( $oTva->get_parameter("both_side")==1)
+ {
+ $poste_vat=$oTva->get_side('d');
+ $cust_amount=bcadd($tot_amount,$tot_tva);
+ $acc_operation=new Acc_Operation($this->db);
+ $acc_operation->date=$e_date;
+ $acc_operation->poste=$poste_vat;
+ $acc_operation->amount=$value;
+ $acc_operation->grpt=$seq;
+ $acc_operation->jrn=$p_jrn;
+ $acc_operation->type='d';
+ $acc_operation->periode=$tperiode;
+ }
}
Modified: phpcompta/trunk/include/class_acc_tva.php
===================================================================
--- phpcompta/trunk/include/class_acc_tva.php 2011-11-18 14:52:58 UTC (rev
4405)
+++ phpcompta/trunk/include/class_acc_tva.php 2011-11-18 14:55:13 UTC (rev
4406)
@@ -43,7 +43,8 @@
"label"=>"tva_label",
"rate"=>"tva_rate",
"comment"=>"tva_comment",
- "account"=>"tva_poste");
+ "account"=>"tva_poste",
+ "both_side"=>'tva_both_side');
function __construct ($p_init,$p_tva_id=0)
{
@@ -94,14 +95,15 @@
public function insert()
{
if ( $this->verify() != 0 ) return;
- $sql="select tva_insert($1,$2,$3,$4)";
+ $sql="select tva_insert($1,$2,$3,$4,$5)";
$res=$this->cn->exec_sql(
$sql,
array($this->tva_label,
$this->tva_rate,
$this->tva_comment,
- $this->tva_poste)
+ $this->tva_poste,
+ $this->tva_both_side)
);
$this->tva_id=$this->cn->get_current_seq('s_tva');
$err=Database::fetch_result($res);
@@ -110,14 +112,15 @@
public function update()
{
if ( $this->verify() != 0 ) return;
- $sql="update tva_rate set
tva_label=$1,tva_rate=$2,tva_comment=$3,tva_poste=$4 ".
- " where tva_id = $5";
+ $sql="update tva_rate set
tva_label=$1,tva_rate=$2,tva_comment=$3,tva_poste=$4,tva_both_side=$5 ".
+ " where tva_id = $6";
$res=$this->cn->exec_sql(
$sql,
array($this->tva_label,
$this->tva_rate,
$this->tva_comment,
$this->tva_poste,
+ $this->tva_both_side,
$this->tva_id)
);
@@ -129,7 +132,7 @@
*/
public function load()
{
- $sql="select tva_label,tva_rate, tva_comment,tva_poste from tva_rate
where tva_id=$1";
+ $sql="select tva_label,tva_rate, tva_comment,tva_poste,tva_both_side
from tva_rate where tva_id=$1";
$res=$this->cn->exec_sql(
$sql,
array($this->tva_id)
Modified: phpcompta/trunk/include/tva.inc.php
===================================================================
--- phpcompta/trunk/include/tva.inc.php 2011-11-18 14:52:58 UTC (rev 4405)
+++ phpcompta/trunk/include/tva.inc.php 2011-11-18 14:55:13 UTC (rev 4406)
@@ -35,6 +35,7 @@
echo '<p class="notice">Vous ne pouvez pas effacer tous taux' .
' Si votre société n\'utilise pas la TVA, changer dans le
menu société</p>';
}
+$both=(isset($_REQUEST['both']))?1:0;
//-----------------------------------------------------
// Record Change
if (isset($_POST['confirm_mod'])
@@ -54,23 +55,21 @@
{
if (isset($_POST['confirm_add']))
{
- $sql = "select tva_insert($1,$2,$3,$4)";
+ $sql = "select tva_insert($1,$2,$3,$4,$5)";
$res = $cn->exec_sql(
$sql, array($tva_label,
$tva_rate,
$tva_comment,
- $tva_poste)
+ $tva_poste,
+ $both)
);
$err = Database::fetch_result($res);
}
if (isset($_POST['confirm_mod']))
{
$Res = $cn->exec_sql(
- "select tva_modify($tva_id,'$tva_label',
- '$tva_rate','$tva_comment','$tva_poste')");
- $Res = $cn->exec_sql(
- "select tva_modify($1,$2,$3,$4,$5)", array($tva_id,
$tva_label, $tva_rate, $tva_comment, $tva_poste)
+ "select tva_modify($1,$2,$3,$4,$5,$6)", array($tva_id,
$tva_label, $tva_rate, $tva_comment, $tva_poste,$both)
);
$err = Database::fetch_result($Res);
}
@@ -96,7 +95,7 @@
}
//-----------------------------------------------------
// Display
-$sql = "select tva_id,tva_label,tva_rate,tva_comment,tva_poste from tva_rate
order by tva_label";
+$sql = "select tva_id,tva_label,tva_rate,tva_comment,tva_poste,tva_both_side
from tva_rate order by tva_label";
$Res = $cn->exec_sql($sql);
?>
<TABLE>
@@ -105,6 +104,7 @@
<th>Taux</th>
<th>Commentaire</th>
<th>Poste</th>
+ <th>Utilisé en même temps au crédit et au débit</th>
</tr>
<?php
$val = Database::fetch_all($Res);
@@ -116,7 +116,8 @@
'tva_label' => $row['tva_label'],
'tva_rate' => $row['tva_rate'],
'tva_comment' => $row['tva_comment'],
- 'tva_poste' => $row['tva_poste']
+ 'tva_poste' => $row['tva_poste'],
+ 'tva_both_side' => $row['tva_both_side']
);
echo "<TR>";
@@ -142,6 +143,11 @@
echo "</TD>";
echo "<TD>";
+ $str_msg=( $row['tva_both_side']==1)?'Employé au crédit et débit':'normal'
;
+ echo $str_msg;
+ echo "</TD>";
+
+ echo "<TD>";
echo HtmlInput::submit("rm", "Efface");
echo HtmlInput::submit("mod", "Modifie");
$w = new IHidden();
@@ -194,12 +200,14 @@
<th>Taux</th>
<th>Commentaire</th>
<th>Poste</th>
+ <th>Double côté</th>
</tr>
<tr>
<td> <?php echo $tva_array[$index]['tva_label'];?></td>
<td> <?php echo $tva_array[$index]['tva_rate'];?></td>
<td> <?php echo $tva_array[$index]['tva_comment'];?></td>
<td> <?php echo $tva_array[$index]['tva_poste'];?></td>
+ <td> <?php echo $tva_array[$index]['tva_both_side'];?></td>
</Tr>
</table>
<?php
@@ -248,6 +256,14 @@
echo $w->input('tva_poste', '')
?></td>
</Tr>
+ <tr>
+ <td align="right">Utilisé au débit et au crédit afin d'annuler cette
tva </td>
+ <td> <?php
+ $w = new ICheckBox("both", 1);
+ $w->size = 20;
+ echo $w->input('both', '')
+ ?></td>
+ </Tr>
</table>
<input type="submit" class="button" value="Confirme" name="confirm_add">
<input type="submit" class="button" value="Cancel" name="no">
@@ -302,6 +318,15 @@
echo $w->input('tva_poste', $tva_array[$index]['tva_poste'])
?></td>
</Tr>
+ <tr>
+ <td align="right">Utilisé au débit et au crédit afin d'annuler cette
tva </td>
+ <td> <?php
+ $w = new ICheckBox("both",$tva_array[$index]['tva_both_side'] );
+ $w->selected=$tva_array[$index]['tva_both_side'];
+ $w->size = 20;
+ echo $w->input('both', '')
+ ?></td>
+ </Tr>
</table>
<input type="submit" class="button" value="Confirme" name="confirm_mod">
<input type="submit" class="button" value="Cancel" name="no">
Modified: phpcompta/trunk/sql/tva.sql
===================================================================
--- phpcompta/trunk/sql/tva.sql 2011-11-18 14:52:58 UTC (rev 4405)
+++ phpcompta/trunk/sql/tva.sql 2011-11-18 14:55:13 UTC (rev 4406)
@@ -1,74 +1,85 @@
alter table tva_rate add tva_both_side integer ;
alter table tva_rate alter tva_both_side set default 0;
-update tva_rate set tva_both_side=0;drop FUNCTION
comptaproc.tva_modify(integer, text, numeric, text, text);
-
-CREATE OR REPLACE FUNCTION comptaproc.tva_modify(integer, text, numeric, text,
text,integer)
- RETURNS integer
- LANGUAGE plpgsql
-AS $function$
-declare
- p_tva_id alias for $1;
- p_tva_label alias for $2;
- p_tva_rate alias for $3;
- p_tva_comment alias for $4;
- p_tva_poste alias for $5;
- p_tva_both_side alias for $6;
- debit text;
- credit text;
- nCount integer;
-begin
-if length(trim(p_tva_label)) = 0 then
- return 3;
-end if;
-
-if length(trim(p_tva_poste)) != 0 then
- if position (',' in p_tva_poste) = 0 then return 4; end if;
- debit = split_part(p_tva_poste,',',1);
- credit = split_part(p_tva_poste,',',2);
- select count(*) into nCount from tmp_pcmn where
pcm_val=debit::account_type;
- if nCount = 0 then return 4; end if;
- select count(*) into nCount from tmp_pcmn where
pcm_val=credit::account_type;
- if nCount = 0 then return 4; end if;
-
-end if;
-update tva_rate set
tva_label=p_tva_label,tva_rate=p_tva_rate,tva_comment=p_tva_comment,tva_poste=p_tva_poste,tva_both_side=p_tva_both_side
- where tva_id=p_tva_id;
-return 0;
-end;
-$function$
-drop FUNCTION comptaproc.tva_insert(text, numeric, text, text);
-CREATE OR REPLACE FUNCTION comptaproc.tva_insert(text, numeric, text,
text,integer)
- RETURNS integer
- LANGUAGE plpgsql
-AS $function$
-declare
- l_tva_id integer;
- p_tva_label alias for $1;
- p_tva_rate alias for $2;
- p_tva_comment alias for $3;
- p_tva_poste alias for $4;
- p_tva_both_side alias for $5;
- debit text;
- credit text;
- nCount integer;
-begin
-if length(trim(p_tva_label)) = 0 then
- return 3;
-end if;
-
-if length(trim(p_tva_poste)) != 0 then
- if position (',' in p_tva_poste) = 0 then return 4; end if;
- debit = split_part(p_tva_poste,',',1);
- credit = split_part(p_tva_poste,',',2);
- select count(*) into nCount from tmp_pcmn where
pcm_val=debit::account_type;
- if nCount = 0 then return 4; end if;
- select count(*) into nCount from tmp_pcmn where
pcm_val=credit::account_type;
- if nCount = 0 then return 4; end if;
-
-end if;
-select into l_tva_id nextval('s_tva') ;
-insert into
tva_rate(tva_id,tva_label,tva_rate,tva_comment,tva_poste,tva_both_side)
- values
(l_tva_id,p_tva_label,p_tva_rate,p_tva_comment,p_tva_poste,p_tva_both_side);
-return 0;
-end;
-$function$
+update tva_rate set tva_both_side=0;
+
+----------------------------------------------------------------------
+-- TVA MODIFY
+----------------------------------------------------------------------
+drop FUNCTION comptaproc.tva_modify(integer, text, numeric, text, text);
+
+CREATE OR REPLACE FUNCTION comptaproc.tva_modify(integer, text, numeric, text,
text,integer)
+ RETURNS integer
+ LANGUAGE plpgsql
+AS $function$
+declare
+ p_tva_id alias for $1;
+ p_tva_label alias for $2;
+ p_tva_rate alias for $3;
+ p_tva_comment alias for $4;
+ p_tva_poste alias for $5;
+ p_tva_both_side alias for $6;
+ debit text;
+ credit text;
+ nCount integer;
+begin
+if length(trim(p_tva_label)) = 0 then
+ return 3;
+end if;
+
+if length(trim(p_tva_poste)) != 0 then
+ if position (',' in p_tva_poste) = 0 then return 4; end if;
+ debit = split_part(p_tva_poste,',',1);
+ credit = split_part(p_tva_poste,',',2);
+ select count(*) into nCount from tmp_pcmn where
pcm_val=debit::account_type;
+ if nCount = 0 then return 4; end if;
+ select count(*) into nCount from tmp_pcmn where
pcm_val=credit::account_type;
+ if nCount = 0 then return 4; end if;
+
+end if;
+update tva_rate set
tva_label=p_tva_label,tva_rate=p_tva_rate,tva_comment=p_tva_comment,tva_poste=p_tva_poste,tva_both_side=p_tva_both_side
+ where tva_id=p_tva_id;
+return 0;
+end;
+$function$
+
+----------------------------------------------------------------------
+-- TVA INSERT
+----------------------------------------------------------------------
+
+drop FUNCTION comptaproc.tva_insert(text, numeric, text, text);
+
+CREATE OR REPLACE FUNCTION comptaproc.tva_insert(text, numeric, text,
text,integer)
+ RETURNS integer
+ LANGUAGE plpgsql
+AS $function$
+declare
+ l_tva_id integer;
+ p_tva_label alias for $1;
+ p_tva_rate alias for $2;
+ p_tva_comment alias for $3;
+ p_tva_poste alias for $4;
+ p_tva_both_side alias for $5;
+ debit text;
+ credit text;
+ nCount integer;
+begin
+if length(trim(p_tva_label)) = 0 then
+ return 3;
+end if;
+
+if length(trim(p_tva_poste)) != 0 then
+ if position (',' in p_tva_poste) = 0 then return 4; end if;
+ debit = split_part(p_tva_poste,',',1);
+ credit = split_part(p_tva_poste,',',2);
+ select count(*) into nCount from tmp_pcmn where
pcm_val=debit::account_type;
+ if nCount = 0 then return 4; end if;
+ select count(*) into nCount from tmp_pcmn where
pcm_val=credit::account_type;
+ if nCount = 0 then return 4; end if;
+
+end if;
+select into l_tva_id nextval('s_tva') ;
+insert into
tva_rate(tva_id,tva_label,tva_rate,tva_comment,tva_poste,tva_both_side)
+ values
(l_tva_id,p_tva_label,p_tva_rate,p_tva_comment,p_tva_poste,p_tva_both_side);
+return 0;
+end;
+$function$
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Phpcompta-dev] r4406 - in phpcompta/trunk: include sql,
phpcompta-dev <=