[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Noalyss-commit] [noalyss] 123/218: Currency = payment automatic for Sal
From: |
Dany De Bontridder |
Subject: |
[Noalyss-commit] [noalyss] 123/218: Currency = payment automatic for Sales and Purchases |
Date: |
Thu, 12 Sep 2019 15:58:52 -0400 (EDT) |
sparkyx pushed a commit to branch entreprise
in repository noalyss.
commit 65393e331cdc1ce052306ef038be6aadbc204210
Author: Dany De Bontridder <address@hidden>
Date: Sun Dec 9 18:45:34 2018 +0100
Currency = payment automatic for Sales and Purchases
---
include/class/acc_ledger_purchase.class.php | 23 ++++++++++++++++++++---
include/class/acc_ledger_sold.class.php | 22 ++++++++++++++++++++--
2 files changed, 40 insertions(+), 5 deletions(-)
diff --git a/include/class/acc_ledger_purchase.class.php
b/include/class/acc_ledger_purchase.class.php
index 76e0c03..2fc3cd5 100644
--- a/include/class/acc_ledger_purchase.class.php
+++ b/include/class/acc_ledger_purchase.class.php
@@ -547,7 +547,7 @@ class Acc_Ledger_Purchase extends Acc_Ledger
$tot_tva_ndded=0;
$tot_tva_reversed=0;
$tva=array();
-
+ $tot_amount_cur=0;
// find the currency from v_currency_last_value
$currency_rate_ref=new Acc_Currency($this->db, $p_currency_code);
@@ -755,6 +755,8 @@ class Acc_Ledger_Purchase extends Acc_Ledger
$operation_currency->oc_price_unit=${'e_march'.$i.'_price'};
$operation_currency->j_id=$j_id;
$operation_currency->insert();
+
$tot_amount_cur=round(bcadd($tot_amount_cur,$acc_amount->amount_currency),2);
+
$tot_amount_cur=round(bcadd($tot_amount_cur,$acc_amount->amount_vat_currency),2);
if (DEBUG ) {
echo __LINE__." insert into operation currency
oc_amount:{$acc_amount->amount_currency} oc_vat_amount
{$acc_amount->amount_vat_currency} <br>";
}
@@ -950,13 +952,28 @@ class Acc_Ledger_Purchase extends Acc_Ledger
$acc_pay->grpt=$acseq;
$acc_pay->jrn=$mp->get_parameter('ledger_target');
$acc_pay->periode=$tperiode;
- $acc_pay->type=($famount>=0)?'d':'c';
+ $acc_pay->type=($famount>=0)?'d':'c';
$let_other=$acc_pay->insert_jrnx();
-
+
+ // insert into operation_currency
+ $operation_currency=new Operation_currency_SQL($this->db);
+ $operation_currency->oc_amount=bcsub($tot_amount_cur,$acompte);
+ $operation_currency->oc_vat_amount=0;
+ $operation_currency->oc_price_unit=0;
+ $operation_currency->j_id=$let_other;
+ $operation_currency->insert();
+
/* insert into jrn */
$acc_pay->mt=$mt;
$acc_pay->desc=(!isset($e_comm_paiement) ||
strlen(trim($e_comm_paiement)) == 0) ?$e_comm:$e_comm_paiement;
+ // Add info for currency
+ $acc_pay->currency_id=$p_currency_code;
+ $acc_pay->currency_rate=$p_currency_rate;
+ $acc_pay->currency_rate_ref=$currency_rate_ref->get_rate();
+
+
+ // insert into the table JRN
$mp_jr_id=$acc_pay->insert_jrn();
$acjrn->grpt_id=$acseq;
$acjrn->update_internal_code($acinternal);
diff --git a/include/class/acc_ledger_sold.class.php
b/include/class/acc_ledger_sold.class.php
index ebf58c9..472de16 100644
--- a/include/class/acc_ledger_sold.class.php
+++ b/include/class/acc_ledger_sold.class.php
@@ -284,6 +284,8 @@ class Acc_Ledger_Sold extends Acc_Ledger {
$tot_amount = 0;
$tot_tva = 0;
$tot_debit = 0;
+ $tot_amount_cur=0;
+
$this->db->start();
$tva = array();
// find the currency from v_currency_last_value
@@ -440,6 +442,8 @@ class Acc_Ledger_Sold extends Acc_Ledger {
$operation_currency->oc_price_unit=${'e_march'.$i.'_price'};
$operation_currency->j_id=$j_id;
$operation_currency->insert();
+
$tot_amount_cur=round(bcadd($tot_amount_cur,$amount_currency),2);
+
$tot_amount_cur=round(bcadd($tot_amount_cur,$tva_item_currency),2);
}// end loop : save all items
/* save total customer */
@@ -608,9 +612,9 @@ class Acc_Ledger_Sold extends Acc_Ledger {
$poste_val = $sposte;
}
// Convert paid amount in EUR
- $acompte=bcmul($acompte, $p_currency_rate);
+ $acompte_eur=bcmul($acompte, $p_currency_rate);
- $famount=bcsub($cust_amount,$acompte);
+ $famount=bcsub($cust_amount,$acompte_eur);
$acc_pay->poste = $poste_val;
$acc_pay->qcode = $fqcode;
$acc_pay->amount = abs(round($famount, 2));
@@ -635,6 +639,20 @@ class Acc_Ledger_Sold extends Acc_Ledger {
$acc_pay->type = ($famount >= 0) ? 'c' : 'd';
$let_other = $acc_pay->insert_jrnx();
+ // insert into operation_currency
+ $operation_currency=new Operation_currency_SQL($this->db);
+ $operation_currency->oc_amount=bcsub($tot_amount_cur,$acompte);
+ $operation_currency->oc_vat_amount=0;
+ $operation_currency->oc_price_unit=0;
+ $operation_currency->j_id=$let_other;
+ $operation_currency->insert();
+
+ // Add info for currency
+ $acc_pay->currency_id=$p_currency_code;
+ $acc_pay->currency_rate=$p_currency_rate;
+ $acc_pay->currency_rate_ref=$currency_rate_ref->get_rate();
+
+
/* insert into jrn */
$acc_pay->mt = $mt;
$acjrn->grpt_id = $acseq;
- [Noalyss-commit] [noalyss] 86/218: Currency : show the currency of the ledger when entering info, (continued)
- [Noalyss-commit] [noalyss] 86/218: Currency : show the currency of the ledger when entering info, Dany De Bontridder, 2019/09/12
- [Noalyss-commit] [noalyss] 89/218: adapt to 7.2 ,array, Dany De Bontridder, 2019/09/12
- [Noalyss-commit] [noalyss] 90/218: Code cleaning : remove SQL with hardcoded value, Dany De Bontridder, 2019/09/12
- [Noalyss-commit] [noalyss] 109/218: Indentation, Dany De Bontridder, 2019/09/12
- [Noalyss-commit] [noalyss] 121/218: Currency : error when displaying, add 4 due to a mistype instruction, Dany De Bontridder, 2019/09/12
- [Noalyss-commit] [noalyss] 126/218: Merge branch 'master' into r700-currency, Dany De Bontridder, 2019/09/12
- [Noalyss-commit] [noalyss] 117/218: Currency : cosmetic display history : show only the value of the card/accounting, Dany De Bontridder, 2019/09/12
- [Noalyss-commit] [noalyss] 116/218: Database upgrade 131, Dany De Bontridder, 2019/09/12
- [Noalyss-commit] [noalyss] 120/218: Currency : send the saldo for financial ledger, Dany De Bontridder, 2019/09/12
- [Noalyss-commit] [noalyss] 135/218: Translation, Dany De Bontridder, 2019/09/12
- [Noalyss-commit] [noalyss] 123/218: Currency = payment automatic for Sales and Purchases,
Dany De Bontridder <=
- [Noalyss-commit] [noalyss] 131/218: Translation + use of httpInput, Dany De Bontridder, 2019/09/12
- [Noalyss-commit] [noalyss] 124/218: Currency : when we pay at the same time as we record the sale / purchase , either the bank is in euro (default currency) or the sale/purchase has the same currency than the financial ledger, Dany De Bontridder, 2019/09/12
- [Noalyss-commit] [noalyss] 138/218: Translation, Dany De Bontridder, 2019/09/12
- [Noalyss-commit] [noalyss] 139/218: Translation, Dany De Bontridder, 2019/09/12
- [Noalyss-commit] [noalyss] 137/218: Translation, Dany De Bontridder, 2019/09/12
- [Noalyss-commit] [noalyss] 140/218: Misc. Operation : input : Missing tag TR, Dany De Bontridder, 2019/09/12
- [Noalyss-commit] [noalyss] 144/218: Currency : meaning 1 EUR is worth x currency for Sales, Dany De Bontridder, 2019/09/12
- [Noalyss-commit] [noalyss] 141/218: Currency : for misc. operation, Dany De Bontridder, 2019/09/12
- [Noalyss-commit] [noalyss] 159/218: Currency : because of Misc Operation, the tiers must also be saved into operation_currency. Fix also PRINTJRN for currency, Dany De Bontridder, 2019/09/12
- [Noalyss-commit] [noalyss] 166/218: Typo, Dany De Bontridder, 2019/09/12