From dde18e803dd692d361002b2ab958ffc6a7c4644c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 25 Feb 2019 15:09:56 +0100 Subject: [PATCH 1/5] Fix transaction --- .../facture/class/api_invoices.class.php | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/htdocs/compta/facture/class/api_invoices.class.php b/htdocs/compta/facture/class/api_invoices.class.php index afecfd33b45..9bbb155eb60 100644 --- a/htdocs/compta/facture/class/api_invoices.class.php +++ b/htdocs/compta/facture/class/api_invoices.class.php @@ -372,7 +372,7 @@ class Invoices extends DolibarrApi throw new RestException(304, $this->invoice->error); } } - + /** * Add a contact type of given invoice * @@ -939,9 +939,8 @@ class Invoices extends DolibarrApi if(! DolibarrApiAccess::$user->rights->facture->creer) { throw new RestException(401); } - - $this->db->begin(); - + + $result = $this->invoice->fetch($id); if( ! $result ) { throw new RestException(404, 'Invoice not found'); @@ -958,8 +957,12 @@ class Invoices extends DolibarrApi if (! $this->invoice->paye) // protection against multiple submit { + $this->db->begin(); + $this->invoice->fetch_lines(); - + + $amount_ht = $amount_tva = $amount_ttc = array(); + // Loop on each vat rate $i=0; foreach($this->invoice->lines as $line) @@ -1009,14 +1012,14 @@ class Invoices extends DolibarrApi } else { - throw new RestException(500, 'Could not set paid'); - $this->db->rollback(); + $this->db->rollback(); + throw new RestException(500, 'Could not set paid'); } } else { - throw new RestException(500, 'Discount creation error'); - $this->db->rollback(); + $this->db->rollback(); + throw new RestException(500, 'Discount creation error'); } } From 8234c094124be615378169927406e50934bac647 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 25 Feb 2019 15:15:17 +0100 Subject: [PATCH 2/5] Try some fixes --- htdocs/stripe/class/stripe.class.php | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/htdocs/stripe/class/stripe.class.php b/htdocs/stripe/class/stripe.class.php index 8cc5b0218b1..646e5c19b12 100644 --- a/htdocs/stripe/class/stripe.class.php +++ b/htdocs/stripe/class/stripe.class.php @@ -243,13 +243,13 @@ class Stripe extends CommonObject /** * Get the Stripe payment intent * - * @param Societe $object Object tp pay on Stripe - * @param string $customer Stripe customer ref 'cus_xxxxxxxxxxxxx' via customerStripe() - * @param string $key ''=Use common API. If not '', it is the Stripe connect account 'acc_....' to use Stripe connect - * @param int $status Status (0=test, 1=live) - * @param int $usethirdpartyemailforreceiptemail 1=use thirdparty email fpr receipt - * @param int $mode automatic=automatic payment, manual=need confirmation - * @return \Stripe\PaymentIntent|null Stripe PaymentIntent or null if not found + * @param Societe $object Object to pay with Stripe + * @param string $customer Stripe customer ref 'cus_xxxxxxxxxxxxx' via customerStripe() + * @param string $key ''=Use common API. If not '', it is the Stripe connect account 'acc_....' to use Stripe connect + * @param int $status Status (0=test, 1=live) + * @param int $usethirdpartyemailforreceiptemail 1=use thirdparty email for receipt + * @param int $mode automatic=automatic payment, manual=need confirmation + * @return \Stripe\PaymentIntent|null Stripe PaymentIntent or null if not found */ public function getPaymentIntent($object, $customer, $key = null, $status = 0, $usethirdpartyemailforreceiptemail = 0, $mode = 'automatic') { @@ -284,7 +284,7 @@ class Stripe extends CommonObject $obj = $this->db->fetch_object($resql); $intent = $obj->ext_payment_id; - dol_syslog(get_class($this) . "::customerStripe found stripe customer key_account = ".$tiers); + dol_syslog(get_class($this) . "::customerStripe found record"); // Force to use the correct API key global $stripearrayofkeysbyenv; @@ -308,7 +308,7 @@ class Stripe extends CommonObject if (! in_array($object->multicurrency_code, $arrayzerounitcurrency)) $stripeamount=$object->multicurrency_total_ttc * 100; else $stripeamount = $object->multicurrency_total_ttc; - $fee = round(($amount * ($conf->global->STRIPE_APPLICATION_FEE_PERCENT / 100) + $conf->global->STRIPE_APPLICATION_FEE) * 100); + $fee = round(($object->total_ttc * ($conf->global->STRIPE_APPLICATION_FEE_PERCENT / 100) + $conf->global->STRIPE_APPLICATION_FEE) * 100); if ($fee < ($conf->global->STRIPE_APPLICATION_FEE_MINIMAL * 100)) { $fee = round($conf->global->STRIPE_APPLICATION_FEE_MINIMAL * 100); } @@ -328,9 +328,9 @@ class Stripe extends CommonObject { $dataforintent["application_fee"] = $fee; } - if ($societe->email && $usethirdpartyemailforreceiptemail) + if ($usethirdpartyemailforreceiptemail && $object->thirdparty->email) { - $dataforintent["receipt_email"] = $societe->email; + $dataforintent["receipt_email"] = $object->thirdparty->email; } try { From 5ffc1822d92825988192c053ee02bd1b535b3fc0 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 25 Feb 2019 19:01:51 +0100 Subject: [PATCH 3/5] Translation --- htdocs/langs/en_US/accountancy.lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/langs/en_US/accountancy.lang b/htdocs/langs/en_US/accountancy.lang index 8b3a5a6600b..a54ba98a7e5 100644 --- a/htdocs/langs/en_US/accountancy.lang +++ b/htdocs/langs/en_US/accountancy.lang @@ -150,7 +150,7 @@ ACCOUNTING_EXPENSEREPORT_JOURNAL=Expense report journal ACCOUNTING_SOCIAL_JOURNAL=Social journal ACCOUNTING_HAS_NEW_JOURNAL=Has new Journal -ACCOUNTING_ACCOUNT_TRANSFER_CASH=Accounting account of transfer +ACCOUNTING_ACCOUNT_TRANSFER_CASH=Accounting account of bank transfer ACCOUNTING_ACCOUNT_SUSPENSE=Accounting account of wait DONATION_ACCOUNTINGACCOUNT=Accounting account to register donations ADHERENT_SUBSCRIPTION_ACCOUNTINGACCOUNT=Accounting account to register subscriptions From 25d277acebdab803abbefb88842d578cfc28c112 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 25 Feb 2019 19:02:41 +0100 Subject: [PATCH 4/5] More complete translation --- htdocs/langs/en_US/accountancy.lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/langs/en_US/accountancy.lang b/htdocs/langs/en_US/accountancy.lang index a54ba98a7e5..e613d38ab05 100644 --- a/htdocs/langs/en_US/accountancy.lang +++ b/htdocs/langs/en_US/accountancy.lang @@ -150,7 +150,7 @@ ACCOUNTING_EXPENSEREPORT_JOURNAL=Expense report journal ACCOUNTING_SOCIAL_JOURNAL=Social journal ACCOUNTING_HAS_NEW_JOURNAL=Has new Journal -ACCOUNTING_ACCOUNT_TRANSFER_CASH=Accounting account of bank transfer +ACCOUNTING_ACCOUNT_TRANSFER_CASH=Accounting account of transitional bank transfer ACCOUNTING_ACCOUNT_SUSPENSE=Accounting account of wait DONATION_ACCOUNTINGACCOUNT=Accounting account to register donations ADHERENT_SUBSCRIPTION_ACCOUNTINGACCOUNT=Accounting account to register subscriptions From fc1d0b2dd5a13d1982772e4ebeeff5292f5e9343 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 25 Feb 2019 19:07:29 +0100 Subject: [PATCH 5/5] Add missing translation --- htdocs/langs/en_US/accountancy.lang | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/langs/en_US/accountancy.lang b/htdocs/langs/en_US/accountancy.lang index e613d38ab05..472e2166f6b 100644 --- a/htdocs/langs/en_US/accountancy.lang +++ b/htdocs/langs/en_US/accountancy.lang @@ -207,6 +207,7 @@ DescThirdPartyReport=Consult here the list of third-party customers and vendors ListAccounts=List of the accounting accounts UnknownAccountForThirdparty=Unknown third-party account. We will use %s UnknownAccountForThirdpartyBlocking=Unknown third-party account. Blocking error +ThirdpartyAccountNotDefinedOrThirdPartyUnknown=Third-party account not defined or third party unknown. Blocking error. UnknownAccountForThirdpartyAndWaitingAccountNotDefinedBlocking=Unknown third-party account and waiting account not defined. Blocking error PaymentsNotLinkedToProduct=Payment not linked to any product / service