Bug #0000873: Si achat utilisant le poste comptable dans DEP_PRIV alors le mettre en dépense privee
This commit is contained in:
parent
f97afde4ee
commit
6feea4e12e
4 changed files with 84 additions and 12 deletions
|
|
@ -511,11 +511,11 @@ class Acc_Ledger extends jrn_def_sql
|
|||
|
||||
/** @brief Get simplified row from ledger
|
||||
*
|
||||
* @paramfrom periode
|
||||
* @paramto periode
|
||||
* @paramp_limit starting line
|
||||
* @paramp_offset number of lines
|
||||
* @paramtrunc if data must be truncated (pdf export)
|
||||
* @param p_from periode
|
||||
* @param p_to periode
|
||||
* @param p_limit starting line
|
||||
* @param p_offset number of lines
|
||||
* @param trunc if data must be truncated (pdf export)
|
||||
*
|
||||
* \return an Array with the asked data
|
||||
*/
|
||||
|
|
@ -1093,7 +1093,8 @@ class Acc_Ledger extends jrn_def_sql
|
|||
$fiche_def_id = $fiche->get_fiche_def_ref_id();
|
||||
// Customer or supplier
|
||||
if ($fiche_def_id == FICHE_TYPE_CLIENT ||
|
||||
$fiche_def_id == FICHE_TYPE_FOURNISSEUR)
|
||||
$fiche_def_id == FICHE_TYPE_FOURNISSEUR
|
||||
||$fiche_def_id == FICHE_TYPE_ADM_TAX)
|
||||
{
|
||||
$p_array['TVAC'] = $code['j_montant'];
|
||||
|
||||
|
|
@ -1104,6 +1105,11 @@ class Acc_Ledger extends jrn_def_sql
|
|||
$p_array['reversed'] = true;
|
||||
$p_array['TVAC']*=-1;
|
||||
}
|
||||
if ($fiche_def_id == FICHE_TYPE_ADM_TAX && $code['j_debit'] == 'f')
|
||||
{
|
||||
$p_array['reversed'] = true;
|
||||
$p_array['TVAC']*=-1;
|
||||
}
|
||||
if ($fiche_def_id == FICHE_TYPE_FOURNISSEUR && $code['j_debit'] == 't')
|
||||
{
|
||||
$p_array['reversed'] = true;
|
||||
|
|
@ -1115,7 +1121,9 @@ class Acc_Ledger extends jrn_def_sql
|
|||
// if we use the ledger ven / ach for others card than supplier and customer
|
||||
if ($fiche_def_id != FICHE_TYPE_VENTE &&
|
||||
$fiche_def_id != FICHE_TYPE_ACH_MAR &&
|
||||
$fiche_def_id != FICHE_TYPE_ACH_SER)
|
||||
$fiche_def_id != FICHE_TYPE_ACH_SER &&
|
||||
$fiche_def_id != FICHE_TYPE_ACH_MAT
|
||||
)
|
||||
{
|
||||
$p_array['TVAC'] = $code['j_montant'];
|
||||
|
||||
|
|
@ -1173,7 +1181,7 @@ class Acc_Ledger extends jrn_def_sql
|
|||
$p_array['dep_priv'] = $dep_priv;
|
||||
}
|
||||
}
|
||||
$p_array['TVAC'] = sprintf('% 10.2f', $p_array['TVAC'] - $dep_priv);
|
||||
$p_array['TVAC'] = sprintf('% 10.2f', $p_array['TVAC'] );
|
||||
$p_array['HTVA'] = sprintf('% 10.2f', $p_array['TVAC'] - $p_array['AMOUNT_TVA']);
|
||||
$r = "";
|
||||
$a_tva_amount = array();
|
||||
|
|
|
|||
|
|
@ -179,6 +179,7 @@ define ("FICHE_TYPE_EMPL",25);
|
|||
define ("FICHE_TYPE_ADM_TAX",14);
|
||||
define ("FICHE_TYPE_ACH_MAR",2);
|
||||
define ("FICHE_TYPE_ACH_SER",3);
|
||||
define ("FICHE_TYPE_ACH_MAT",7);
|
||||
|
||||
|
||||
define ('JS_INFOBULLE','
|
||||
|
|
|
|||
|
|
@ -33,7 +33,6 @@ $gDossier=dossier::id();
|
|||
|
||||
require_once('class_database.php');
|
||||
require_once("class_acc_ledger.php");
|
||||
$cn=new Database($gDossier);
|
||||
|
||||
|
||||
require_once ('class_user.php');
|
||||
|
|
@ -145,16 +144,17 @@ else
|
|||
$col_tva.='"Tva '.$line_tva['tva_label'].'";';
|
||||
}
|
||||
}
|
||||
echo '"Date";"operation";"Client/Fourn.";"Commentaire";"inter.";"HTVA";'.$col_tva.'"TVAC"'."\n\r";
|
||||
echo '"Date";"operation";"Client/Fourn.";"Commentaire";"inter.";"HTVA";privé;'.$col_tva.'"TVAC"'."\n\r";
|
||||
foreach ($Row as $line)
|
||||
{
|
||||
printf('"%s";"%s";"%s";"%s";"%s";%s;',
|
||||
printf('"%s";"%s";"%s";"%s";"%s";%s;%s;',
|
||||
$line['date'],
|
||||
$line['num'],
|
||||
$Jrn->get_tiers($line['jrn_def_type'],$line['jr_id']),
|
||||
$line['comment'],
|
||||
$line['jr_internal'],
|
||||
nb($line['HTVA']));
|
||||
nb($line['HTVA']),
|
||||
nb($line['dep_priv']));
|
||||
$a_tva_amount=array();
|
||||
foreach ($line['TVA'] as $lineTVA)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -0,0 +1,63 @@
|
|||
-- si la fiche utilise le code DEPENSE PRIVEE alors ajout dans QP_DEP_PRIV
|
||||
with m as (select qp_id, qp_price from quant_purchase join fiche_detail on (qp_fiche=f_id and ad_id=5) where ad_value in (select p_value from parm_code where p_code='DEP_PRIV'))
|
||||
update quant_purchase as e set qp_dep_priv=(select qp_price from m where m.qp_id=e.qp_id);
|
||||
-- évite les valeurs nulles dans quant_purchase
|
||||
update quant_purchase set qp_dep_priv = 0 where qp_dep_priv is null;
|
||||
-- update script insert_quant_purchase
|
||||
|
||||
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)
|
||||
RETURNS void AS
|
||||
$BODY$
|
||||
declare
|
||||
fid_client integer;
|
||||
fid_good integer;
|
||||
account_priv account_type;
|
||||
fid_good_account account_type;
|
||||
begin
|
||||
select p_value into account_priv from parm_code where p_code='DEP_PRIV';
|
||||
|
||||
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));
|
||||
select ad_value into fid_good_account from fiche_detail where ad_id=5 and f_id=fid_good;
|
||||
|
||||
if account_priv = fid_good_account then
|
||||
p_dep_priv=p_price;
|
||||
end if;
|
||||
|
||||
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)
|
||||
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);
|
||||
return;
|
||||
end;
|
||||
$BODY$
|
||||
LANGUAGE plpgsql;
|
||||
|
||||
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue