Allow to use 4 decimal for Purchase + predefined operation and display detail
This commit is contained in:
parent
6e812ee686
commit
3d49d7ff09
6 changed files with 108 additions and 44 deletions
|
|
@ -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});
|
||||
|
|
|
|||
|
|
@ -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));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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,'
|
||||
|
|
|
|||
|
|
@ -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']);
|
||||
|
|
|
|||
|
|
@ -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
|
||||
Loading…
Add table
Add a link
Reference in a new issue