[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Noalyss-commit] [noalyss] 04/05: Allow to use 4 decimal for Purchase +
From: |
Dany De Bontridder |
Subject: |
[Noalyss-commit] [noalyss] 04/05: Allow to use 4 decimal for Purchase + predefined operation and display detail |
Date: |
Thu, 22 Oct 2015 11:53:22 +0000 |
sparkyx pushed a commit to branch master
in repository noalyss.
commit 3d49d7ff093a0b1ccb7bb27893cea9fd25c9bd45
Author: Dany De Bontridder <address@hidden>
Date: Thu Oct 22 13:04:02 2015 +0200
Allow to use 4 decimal for Purchase + predefined operation and display
detail
---
include/class/class_acc_ledger_purchase.php | 67 +++++++++++++++------------
include/class/class_acc_operation.php | 2 +-
include/class/class_pre_op_ach.php | 26 +++++++---
include/class/class_pre_op_ven.php | 2 +-
include/template/ledger_detail_ach.php | 6 +--
sql/upgrade.sql | 49 +++++++++++++++++++
6 files changed, 108 insertions(+), 44 deletions(-)
diff --git a/include/class/class_acc_ledger_purchase.php
b/include/class/class_acc_ledger_purchase.php
index 86b8afb..e59ebf7 100644
--- a/include/class/class_acc_ledger_purchase.php
+++ b/include/class/class_acc_ledger_purchase.php
@@ -662,38 +662,45 @@ class Acc_Ledger_Purchase extends Acc_Ledger
if ( $g_parameter->MY_TVA_USE=='Y')
{
- $r=$this->db->exec_sql("select insert_quant_purchase ".
- "(null".
- ",".$j_id. /* 2 */
- ",'".${"e_march".$i}."'". /* 3 */
- ",".${"e_quant".$i}.",". /* 4 */
- round($amount,2). /* 5 */
- ",".$acc_amount->amount_vat. /* 6 */
- ",".$oTva->get_parameter('id'). /*
7 */
- ",".$acc_amount->amount_nd. /*
8 */
- ",".$acc_amount->nd_vat. /*
9 */
- ",".$acc_amount->nd_ded_vat. /*
10 */
- ",".$acc_amount->amount_perso. /*
11 */
- ",'".$e_client."',".
$acc_amount->amount_unpaid.")"); /* 12 */
+ $r=$this->db->exec_sql("select insert_quant_purchase
($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14)",
+ array(
+ null /*1*/
+ ,$j_id /* 2 */
+ ,${"e_march".$i} /* 3 */
+ ,${"e_quant".$i} /* 4 */
+ ,round($amount,2) /* 5 */
+ ,$acc_amount->amount_vat /* 6 */
+ ,$oTva->get_parameter('id') /* 7 */
+ ,$acc_amount->amount_nd /* 8 */
+ ,$acc_amount->nd_vat /* 9 */
+ ,$acc_amount->nd_ded_vat /* 10 */
+ ,$acc_amount->amount_perso /* 11 */
+ ,$e_client /* 12 */
+ , $acc_amount->amount_unpaid /*13*/
+ ,${'e_march'.$i.'_price'} /* 14 */
+ ));
+
}
else
{
- $r=$this->db->exec_sql("select insert_quant_purchase ".
- "(null".
- ",".$j_id.
- ",'".${"e_march".$i}."'".
- ",".${"e_quant".$i}.",".
- round($amount,2).
- ",0".
- ",null".
- ",".$acc_amount->amount_nd.
- ",0".
- ",".$acc_amount->nd_ded_vat.
- ",".$acc_amount->amount_perso.
-
",'".$e_client."',".$acc_amount->amount_unpaid.")");
-
-
+ $r=$this->db->exec_sql("select insert_quant_purchase
($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14)",
+ array(
+ null /*1*/
+ ,$j_id /* 2 */
+ ,${"e_march".$i} /* 3 */
+ ,${"e_quant".$i} /* 4 */
+ ,round($amount,2) /* 5 */
+ ,0 /* 6 */
+ ,null/* 7 */
+ ,$acc_amount->amount_nd /* 8 */
+ ,0 /* 9 */
+ ,$acc_amount->nd_ded_vat /* 10 */
+ ,$acc_amount->amount_perso /* 11 */
+ ,$e_client /* 12 */
+ , $acc_amount->amount_unpaid /*13*/
+ ,${'e_march'.$i.'_price'} /* 14 */
+ ));
}
} // end loop : save all items
@@ -1236,7 +1243,7 @@ class Acc_Ledger_Purchase extends Acc_Ledger
$Price=new INum();
$Price->setReadOnly(false);
$Price->size=9;
-
$Price->javascript="onBlur='format_number(this);clean_tva($i);compute_ledger($i)'";
+
$Price->javascript="onBlur='format_number(this,4);clean_tva($i);compute_ledger($i)'";
$array[$i]['pu']=$Price->input("e_march".$i."_price",$march_price);
if ( $g_parameter->MY_TVA_USE=='Y')
{
@@ -1469,7 +1476,7 @@ class Acc_Ledger_Purchase extends Acc_Ledger
$r.=$fiche_name;
$r.='</td>';
$r.='<td class="num">';
- $r.=nbm(${"e_march".$i."_price"});
+ $r.=nbm(${"e_march".$i."_price"},4);
$r.='</td>';
$r.='<td class="num">';
$r.=nbm(${"e_quant".$i});
diff --git a/include/class/class_acc_operation.php
b/include/class/class_acc_operation.php
index 7d5df8e..02b6d11 100644
--- a/include/class/class_acc_operation.php
+++ b/include/class/class_acc_operation.php
@@ -688,7 +688,7 @@ class Acc_Purchase extends Acc_Detail
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_vat_sided
+ qp_valid, qp_dep_priv,j_text,qp_vat_sided,qp_unit
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));
}
diff --git a/include/class/class_pre_op_ach.php
b/include/class/class_pre_op_ach.php
index 2f92bf2..3f30851 100644
--- a/include/class/class_pre_op_ach.php
+++ b/include/class/class_pre_op_ach.php
@@ -47,8 +47,10 @@ class Pre_op_ach extends Pre_operation_detail
$march="e_march".$i;
$this->$march=$_POST['e_march'.$i];
$this->{"e_march".$i."_price"}=(isset
($_POST['e_march'.$i."_price"]))?$_POST['e_march'.$i."_price"]:0;
+
$this->{"e_march".$i."_price"}=(trim($_POST['e_march'.$i."_price"])=="")?0:$_POST['e_march'.$i."_price"];
$this->{"e_march".$i."_tva_id"}=(isset
($_POST['e_march'.$i."_tva_id"]))?$_POST['e_march'.$i."_tva_id"]:0;
$this->{"e_march".$i."_tva_amount"}=(isset($_POST['e_march'.$i."_tva_amount"]))?$_POST['e_march'.$i."_tva_amount"]:0;
+
$this->{"e_march".$i."_label"}=(isset($_POST['e_march'.$i."_label"]))?$_POST['e_march'.$i."_label"]:null;
$this->{"e_quant".$i}=$_POST['e_quant'.$i];
}
@@ -76,19 +78,27 @@ class Pre_op_ach extends Pre_operation_detail
// save the selling
for ($i=0;$i<$this->operation->nb_item;$i++)
{
- $sql=sprintf('insert into op_predef_detail
(opd_poste,opd_amount,opd_tva_id,opd_quantity,'.
- 'opd_debit,od_id,opd_tva_amount)'.
- ' values '.
- "('%s',%.2f,%d,%f,'%s',%d,%f)",
- $this->{"e_march".$i},
+ if ( strlen(trim($this->{"e_march".$i}))=="") continue;
+ $sql= 'insert into op_predef_detail (opd_poste,'
+ . 'opd_amount,'
+ . 'opd_tva_id,'
+ . 'opd_quantity,'
+ . 'opd_debit,'
+ . 'od_id ,'
+ . 'opd_tva_amount,'
+ . 'opd_comment'.
+ ')'.
+ ' values ($1,$2,$3,$4,$5,$6,$7,$8)';
+ $this->db->exec_sql($sql,
+ array($this->{"e_march".$i},
$this->{"e_march".$i."_price"},
$this->{"e_march".$i."_tva_id"},
$this->{"e_quant".$i},
't',
$this->operation->od_id,
- $this->{"e_march".$i."_tva_amount"}
- );
- $this->db->exec_sql($sql);
+ $this->{"e_march".$i."_tva_amount"},
+ $this->{"e_march".$i."_label"},
+ ));
}
}
catch (Exception $e)
diff --git a/include/class/class_pre_op_ven.php
b/include/class/class_pre_op_ven.php
index e31c975..318bb5b 100644
--- a/include/class/class_pre_op_ven.php
+++ b/include/class/class_pre_op_ven.php
@@ -76,7 +76,7 @@ class Pre_op_ven extends Pre_operation_detail
// save the selling
for ($i=0;$i<$this->operation->nb_item;$i++)
{
- if ( strlen(trim($this->{"e_march".$i}))==0) continue;
+ if ( strlen(trim($this->{"e_march".$i}))=="") continue;
$sql= 'insert into op_predef_detail (opd_poste,'
. 'opd_amount,'
. 'opd_tva_id,'
diff --git a/include/template/ledger_detail_ach.php
b/include/template/ledger_detail_ach.php
index 64a922a..cda6658 100644
--- a/include/template/ledger_detail_ach.php
+++ b/include/template/ledger_detail_ach.php
@@ -179,10 +179,8 @@ $str_anc="";
}
$row.=td($input->input() . $hidden);
$row.=td($sym_tva, 'style="text-align:center"');
- $pu = 0;
- if ($q['qp_quantite'] != 0)
- $pu = bcdiv($q['qp_price'], $q['qp_quantite']);
- $row.=td(nbm($pu), 'class="num"');
+ $pu = $q['qp_unit'];
+ $row.=td(nbm($pu,4), 'class="num"');
$row.=td(nbm($q['qp_quantite']), 'class="num"');
$no_ded = bcadd($q['qp_dep_priv'], $q['qp_nd_amount']);
diff --git a/sql/upgrade.sql b/sql/upgrade.sql
index 1022e62..ec7e852 100644
--- a/sql/upgrade.sql
+++ b/sql/upgrade.sql
@@ -182,6 +182,9 @@ LANGUAGE plpgsql;
alter table quant_sold add column qs_unit numeric(20,4) default 0;
update quant_sold set qs_unit = qs_price / qs_quantite;
+alter table quant_purchase add column qp_unit numeric(20,4) default 0;
+update quant_purchase set qp_unit = qp_price / qp_quantite;
+
CREATE OR REPLACE FUNCTION comptaproc.insert_quant_sold(p_internal text, p_jid
numeric, p_fiche character varying, p_quant numeric, p_price numeric, p_vat
numeric, p_vat_code integer, p_client character varying, p_tva_sided numeric,
p_price_unit numeric)
RETURNS void AS
$BODY$
@@ -202,3 +205,49 @@ begin
end;
$BODY$
LANGUAGE plpgsql;
+
+CREATE OR REPLACE FUNCTION comptaproc.insert_quant_purchase(p_internal text,
p_j_id numeric, p_fiche character varying, p_quant numeric, p_price numeric,
p_vat numeric, p_vat_code integer, p_nd_amount numeric, p_nd_tva numeric,
p_nd_tva_recup numeric, p_dep_priv numeric, p_client character varying,
p_tva_sided numeric,p_price_unit numeric)
+ RETURNS void AS
+$BODY$
+declare
+ fid_client integer;
+ fid_good integer;
+begin
+ select f_id into fid_client from
+ fiche_detail where ad_id=23 and ad_value=upper(trim(p_client));
+ select f_id into fid_good from
+ fiche_detail where ad_id=23 and ad_value=upper(trim(p_fiche));
+ insert into quant_purchase
+ (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_dep_priv,
+ qp_vat_sided,
+ qp_unit)
+ values
+ (p_internal,
+ p_j_id,
+ fid_good,
+ p_quant,
+ p_price,
+ p_vat,
+ p_vat_code,
+ p_nd_amount,
+ p_nd_tva,
+ p_nd_tva_recup,
+ fid_client,
+ p_dep_priv,
+ p_tva_sided,
+ p_price_unit);
+ return;
+end;
+ $BODY$
+ LANGUAGE plpgsql
\ No newline at end of file
- [Noalyss-commit] [noalyss] branch master updated (9bc7e44 -> 0be477f), Dany De Bontridder, 2015/10/22
- [Noalyss-commit] [noalyss] 01/05: Debug : do not complain about install file, Dany De Bontridder, 2015/10/22
- [Noalyss-commit] [noalyss] 02/05: Allow to use 4 decimal for Sales + predefined operation and display detail, Dany De Bontridder, 2015/10/22
- [Noalyss-commit] [noalyss] 03/05: Predefined operation VEN includes Comment + tva amount, Dany De Bontridder, 2015/10/22
- [Noalyss-commit] [noalyss] 05/05: By default, the card's attribute for Price has 4 decimal', Dany De Bontridder, 2015/10/22
- [Noalyss-commit] [noalyss] 04/05: Allow to use 4 decimal for Purchase + predefined operation and display detail,
Dany De Bontridder <=