[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Noalyss-commit] [noalyss] 119/162: Currency = payment automatic for Sal
From: |
Dany De Bontridder |
Subject: |
[Noalyss-commit] [noalyss] 119/162: Currency = payment automatic for Sales and Purchases |
Date: |
Sat, 11 Jul 2020 13:23:57 -0400 (EDT) |
sparkyx pushed a commit to annotated tag E-4
in repository noalyss.
commit 65393e331cdc1ce052306ef038be6aadbc204210
Author: Dany De Bontridder <danydb@noalyss.eu>
AuthorDate: 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] 114/162: Currency : export CSV history for card and accounting, fix bug with unneeded oc_vat_amount + add the currency rate, (continued)
- [Noalyss-commit] [noalyss] 114/162: Currency : export CSV history for card and accounting, fix bug with unneeded oc_vat_amount + add the currency rate, Dany De Bontridder, 2020/07/11
- [Noalyss-commit] [noalyss] 115/162: currency : adapt middle of payment, Dany De Bontridder, 2020/07/11
- [Noalyss-commit] [noalyss] 117/162: Currency : error when displaying, add 4 due to a mistype instruction, Dany De Bontridder, 2020/07/11
- [Noalyss-commit] [noalyss] 118/162: Currency : display correctly the saldo at the end / beginning operation, Dany De Bontridder, 2020/07/11
- [Noalyss-commit] [noalyss] 107/162: Currency : sales in listing mode, Dany De Bontridder, 2020/07/11
- [Noalyss-commit] [noalyss] 122/162: Merge branch 'master' into r700-currency, Dany De Bontridder, 2020/07/11
- [Noalyss-commit] [noalyss] 112/162: Database upgrade 131, Dany De Bontridder, 2020/07/11
- [Noalyss-commit] [noalyss] 116/162: Currency : send the saldo for financial ledger, Dany De Bontridder, 2020/07/11
- [Noalyss-commit] [noalyss] 123/162: Merge commit '3f53de417dd89e9a90a386404f93f8648155e046' into r700-currency, Dany De Bontridder, 2020/07/11
- [Noalyss-commit] [noalyss] 110/162: Currency : purchase oneline + extended html and csv, Dany De Bontridder, 2020/07/11
- [Noalyss-commit] [noalyss] 119/162: Currency = payment automatic for Sales and Purchases,
Dany De Bontridder <=
- [Noalyss-commit] [noalyss] 121/162: Merge branch 'master' into r700-currency, Dany De Bontridder, 2020/07/11
- [Noalyss-commit] [noalyss] 124/162: Missing bracket, Dany De Bontridder, 2020/07/11
- [Noalyss-commit] [noalyss] 125/162: Esthetic with button "Add accounting", Dany De Bontridder, 2020/07/11
- [Noalyss-commit] [noalyss] 131/162: Translation, Dany De Bontridder, 2020/07/11
- [Noalyss-commit] [noalyss] 133/162: Translation, Dany De Bontridder, 2020/07/11
- [Noalyss-commit] [noalyss] 120/162: 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, 2020/07/11
- [Noalyss-commit] [noalyss] 126/162: typo doc, Dany De Bontridder, 2020/07/11
- [Noalyss-commit] [noalyss] 127/162: Translation + use of httpInput, Dany De Bontridder, 2020/07/11
- [Noalyss-commit] [noalyss] 128/162: Translation, Dany De Bontridder, 2020/07/11
- [Noalyss-commit] [noalyss] 129/162: Translation, Dany De Bontridder, 2020/07/11