From 6029d9141418d547761ccb9838bc4a4474dc6c62 Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Sat, 12 May 2018 12:53:01 +0200 Subject: [PATCH] Task #448 : correct bug when saving into quant_purchase --- include/class/acc_ledger_purchase.class.php | 5 ++++- include/sql/patch/upgrade128.sql | 6 +++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/include/class/acc_ledger_purchase.class.php b/include/class/acc_ledger_purchase.class.php index f1202ea28..a3974d39f 100644 --- a/include/class/acc_ledger_purchase.class.php +++ b/include/class/acc_ledger_purchase.class.php @@ -589,6 +589,7 @@ class Acc_Ledger_Purchase extends Acc_Ledger // Set the currency rate $acc_amount->set_parameter("currency_rate", $p_currency_rate); $acc_amount->convert_euro(); + $amount_euro=$acc_amount->amount; // Compute VAT or take the given one if ( $g_parameter->MY_TVA_USE=='Y') @@ -624,6 +625,8 @@ class Acc_Ledger_Purchase extends Acc_Ledger $tot_amount=round(bcadd($tot_amount,$acc_amount->amount),2); + $tot_amount=round(bcadd($tot_amount,$acc_amount->amount_nd),2); + $tot_amount=round(bcadd($tot_amount,$acc_amount->amount_perso),2); /* get the account and explode if necessary */ $sposte=$fiche->strAttribut(ATTR_DEF_ACCOUNT); @@ -708,7 +711,7 @@ class Acc_Ledger_Purchase extends Acc_Ledger ,$j_id /* 2 */ ,${"e_march".$i} /* 3 */ ,${"e_quant".$i} /* 4 */ - ,round($acc_amount->amount,2) /* 5 */ + ,round($amount_euro,2) /* 5 */ ,$acc_amount->amount_vat /* 6 */ ,$oTva->get_parameter('id') /* 7 */ ,$acc_amount->amount_nd /* 8 */ diff --git a/include/sql/patch/upgrade128.sql b/include/sql/patch/upgrade128.sql index a491ed5f1..8a1bf87ec 100644 --- a/include/sql/patch/upgrade128.sql +++ b/include/sql/patch/upgrade128.sql @@ -78,9 +78,9 @@ COMMENT ON COLUMN public.currency.cr_name IS 'Name of the currency' ; CREATE TABLE public.operation_currency ( id bigserial NOT NULL, - oc_amount numeric(6) NOT NULL, -- amount in currency - oc_vat_amount numeric(6) NULL DEFAULT 0, -- vat amount in currency - oc_price_unit numeric(6) NULL, -- unit price in currency + oc_amount numeric(20,6) NOT NULL, -- amount in currency + oc_vat_amount numeric(20,6) NULL DEFAULT 0, -- vat amount in currency + oc_price_unit numeric(20,6) NULL, -- unit price in currency j_id int8 NOT NULL, -- fk to jrnx CONSTRAINT operation_currency_pk PRIMARY KEY (id) );