Fix central - stock - improve doc

This commit is contained in:
sparkyx 2004-04-03 01:38:39 +00:00
parent a205cb766c
commit 07bb3f7c6d
6 changed files with 23 additions and 22 deletions

View file

@ -63,8 +63,6 @@ $sql="insert into centralized( c_j_id,
from jrnx left join jrn on jr_grpt_id=j_grpt
where
j_tech_per =".$p_periode."
and jr_internal != 'ANNULE'
and j_internal != 'ANNULE'
order by j_date,j_grpt,j_debit desc ";
$Res=StartSql($p_cn);
$Res=ExecSql($p_cn,$sql);

View file

@ -628,10 +628,12 @@ function RecordInvoice($p_cn,$p_array,$p_user,$p_jrn)
$a_vat=ComputeVat($p_cn, $a_good,$a_quant,$a_price);
$sum_vat=0.0;
foreach ( $a_vat as $element => $t) {
echo_debug(" a_vat element $element t $t");
$sum_vat+=$t;
echo_debug("sum_vat = $sum_vat");
if ( $a_vat != null ){
foreach ( $a_vat as $element => $t) {
echo_debug(" a_vat element $element t $t");
$sum_vat+=$t;
echo_debug("sum_vat = $sum_vat");
}
}
// First we add in jrnx
@ -659,7 +661,7 @@ function RecordInvoice($p_cn,$p_array,$p_user,$p_jrn)
InsertStockGoods($p_cn,$j_id,$a_good[$i],$a_quant[$i],'c');
}
// Insert Vat
if (sizeof($a_vat) != 0 ) // no vat
if ( $a_vat!= null ) // no vat
{
foreach ($a_vat as $tva_id => $tva_amount ) {
$poste=GetTvaPoste($p_cn,$tva_id,'c');
@ -907,12 +909,14 @@ function RecordAchat($p_cn,$p_array,$p_user,$p_jrn)
$a_vat=ComputeVat($p_cn, $a_good,$a_quant,$a_price);
$sum_vat=0.0;
foreach ( $a_vat as $element => $t) {
echo_debug(" a_vat element $element t $t");
$sum_vat+=$t;
echo_debug("sum_vat = $sum_vat");
if ( $a_vat != null ) {
foreach ( $a_vat as $element => $t) {
echo_debug(" a_vat element $element t $t");
$sum_vat+=$t;
echo_debug("sum_vat = $sum_vat");
}
}
// First we add in jrnx
// First we add in jrnx
// Compute the j_grpt
$seq=GetNextId($p_cn,'j_grpt')+1;
@ -934,7 +938,7 @@ function RecordAchat($p_cn,$p_array,$p_user,$p_jrn)
InsertStockGoods($p_cn,$j_id,$a_good[$i],$a_quant[$i],'d');
}
// Insert Vat
if (sizeof($a_vat) != 0 ) // no vat
if ( $a_vat != null ) // no vat
{
foreach ($a_vat as $tva_id => $tva_amount ) {
$poste=GetTvaPoste($p_cn,$tva_id,'d');

View file

@ -968,7 +968,7 @@ function NextJrn($p_cn,$p_type)
*/
function SetInternalCode($p_cn,$p_grpt,$p_jrn)
{
$num=CountSql($p_cn,"select * from jrn where jr_def_id=$p_jrn and jr_internal != 'ANNULE'");
$num=CountSql($p_cn,"select * from jrn where jr_def_id=$p_jrn and jr_internal != 'ANNULE'")+1;
$atype=GetJrnProperty($p_cn,$p_jrn);
$type=$atype['jrn_def_code'];
$internal_code=sprintf("%s-%05d",$type,$num);

View file

@ -36,6 +36,7 @@ include_once("postgres.php");
*/
function GetTvaRate($p_cn,$p_tva_id) {
if (strlen(trim($p_tva_id))==0) return 0;
$Res=pg_exec($p_cn,"select tva_id,tva_rate,tva_label from tva_rate where tva_id=".$p_tva_id);
if (pg_NumRows($Res) == 0 ) return null;
@ -65,10 +66,11 @@ echo_debug("ComputeVat $a_fiche $a_quant $a_price");
// foreach goods
for ( $i=0 ; $i < sizeof($a_fiche);$i++) {
// if the card id is null or empty
if ( isNumber($a_fiche[$i])==0) continue;
if ( isNumber($a_fiche[$i])==0
or strlen(trim($a_fiche[$i]))==0) continue;
// Get the tva_id
$tva_id=GetFicheAttribut($p_cn,$a_fiche[$i],ATTR_DEF_TVA);
if ( $tva_id == 'Unknown' ) continue;
// for each fiche find the tva_rate and tva_id
$a_vat=GetTvaRate($p_cn,$tva_id);
@ -150,7 +152,7 @@ function InsertJrnx($p_cn,$p_type,$p_user,$p_jrn,$p_poste,$p_date,$p_amount,$p_g
$sql=sprintf("insert into jrnx (j_date,j_montant, j_poste,j_grpt, j_jrn_def,j_debit,j_tech_user,j_tech_per)
values (to_date('%s','DD.MM.YYYY'),abs(%.2f),%d,%d,%d,%s,'%s',%d)",
$p_date,$p_amount,$p_poste,$p_grpt,$p_jrn,$debit,$p_user,$p_periode);
$p_date,round($p_amount,2),$p_poste,$p_grpt,$p_jrn,$debit,$p_user,$p_periode);
echo_debug("InsertJrnx $sql");
$Res=ExecSql($p_cn,$sql);
return GetSequence($p_cn,'s_jrn_op');
@ -184,7 +186,7 @@ function InsertJrn($p_cn,$p_date,$p_echeance,$p_jrn,$p_comment,$p_amount,$p_grpt
}
$sql=sprintf("insert into jrn (jr_def_id,jr_montant,jr_comment,jr_date,jr_ech,jr_grpt_id,jr_tech_per)
values ( %d,abs(%.2f),'%s',to_date('%s','DD.MM.YYYY'),%s,%d,%d)",
$p_jrn, $p_amount,$p_comment,$p_date,$p_echeance,$p_grpt,$p_periode);
$p_jrn, round($p_amount,2),$p_comment,$p_date,$p_echeance,$p_grpt,$p_periode);
echo_debug("InsertJrn $sql");
$Res=ExecSql($p_cn,$sql);
return GetSequence($p_cn,'s_jrn');

View file

@ -22,10 +22,9 @@ echo "The file install.log will be created with
the log of the installation, just check if
it finished with the message
installation ok"
# Output the log to install log
exec 3>install.log 2>&3 1>&3
set -xv
#set -xv
version=3
VerifOutil() {

View file

@ -176,8 +176,6 @@ INSERT INTO ac_users VALUES (1, NULL, NULL, 'phpcompta', 1, 'b1cc88e1907cde80cb2
--
INSERT INTO ac_dossier VALUES (1, 'Demo', 'Base de données pour développement & démo', 0);
INSERT INTO ac_dossier VALUES (8, 'Test', 'Test du modèle', 0);
INSERT INTO ac_dossier VALUES (9, 'Test 2', 'Test 2', 0);
--