|
diff --git a/htdocs/product/card.php b/htdocs/product/card.php
index ce852876a3d..62b7d78b031 100644
--- a/htdocs/product/card.php
+++ b/htdocs/product/card.php
@@ -79,6 +79,14 @@ $confirm = GETPOST('confirm', 'alpha');
$socid = GETPOST('socid', 'int');
$duration_value = GETPOST('duration_value', 'int');
$duration_unit = GETPOST('duration_unit', 'alpha');
+
+$accountancy_code_sell = GETPOST('accountancy_code_sell', 'alpha');
+$accountancy_code_sell_intra = GETPOST('accountancy_code_sell_intra', 'alpha');
+$accountancy_code_sell_export = GETPOST('accountancy_code_sell_export', 'alpha');
+$accountancy_code_buy = GETPOST('accountancy_code_buy', 'alpha');
+$accountancy_code_buy_intra = GETPOST('accountancy_code_buy_intra', 'alpha');
+$accountancy_code_buy_export = GETPOST('accountancy_code_buy_export', 'alpha');
+
if (!empty($user->socid)) $socid = $user->socid;
$object = new Product($db);
@@ -1316,6 +1324,13 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
print ' |
';
} else // For external software
{
+ if (!empty($accountancy_code_sell)) { $object->accountancy_code_sell = $accountancy_code_sell; }
+ if (!empty($accountancy_code_sell_intra)) { $object->accountancy_code_sell_intra = $accountancy_code_sell_intra; }
+ if (!empty($accountancy_code_sell_export)) { $object->accountancy_code_sell_export = $accountancy_code_sell_export; }
+ if (!empty($accountancy_code_buy)) { $object->accountancy_code_buy = $accountancy_code_buy; }
+ if (!empty($accountancy_code_buy_intra)) { $object->accountancy_code_buy_intra = $accountancy_code_buy_intra; }
+ if (!empty($accountancy_code_buy_export)) { $object->accountancy_code_buy_export = $accountancy_code_buy_export; }
+
// Accountancy_code_sell
print '| '.$langs->trans("ProductAccountancySellCode").' | ';
print '';
diff --git a/htdocs/public/stripe/ipn.php b/htdocs/public/stripe/ipn.php
index d3a9521bf25..cc4d07b0a4b 100644
--- a/htdocs/public/stripe/ipn.php
+++ b/htdocs/public/stripe/ipn.php
@@ -1,6 +1,6 @@
- * Copyright (C) 2018 Frédéric France
+/* Copyright (C) 2018-2020 Thibault FOUCART
+ * Copyright (C) 2018 Frédéric France
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -109,7 +109,7 @@ if (!empty($conf->multicompany->enabled) && !empty($conf->stripeconnect->enabled
{
$sql = "SELECT entity";
$sql .= " FROM ".MAIN_DB_PREFIX."oauth_token";
- $sql .= " WHERE service = '".$db->escape($service)."' and tokenstring = '%".$db->escape($event->account)."%'";
+ $sql .= " WHERE service = '".$db->escape($service)."' and tokenstring LIKE '%".$db->escape($event->account)."%'";
dol_syslog(get_class($db)."::fetch", LOG_DEBUG);
$result = $db->query($sql);
@@ -126,8 +126,6 @@ if (!empty($conf->multicompany->enabled) && !empty($conf->stripeconnect->enabled
$key = 1;
}
$ret = $mc->switchEntity($key);
- if (!$res && file_exists("../../main.inc.php")) $res = @include "../../main.inc.php";
- if (!$res) die("Include of main fails");
}
// list of action
diff --git a/htdocs/societe/paymentmodes.php b/htdocs/societe/paymentmodes.php
index 6adf32dd392..3b2cc60cce4 100644
--- a/htdocs/societe/paymentmodes.php
+++ b/htdocs/societe/paymentmodes.php
@@ -1270,7 +1270,7 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard'
}
// List of Stripe payment modes
- if (!empty($conf->stripe->enabled) && !empty($conf->stripeconnect->enabled) && $object->fournisseur && !empty($stripesupplieracc))
+ if (!empty($conf->stripe->enabled) && !empty($conf->stripeconnect->enabled) && !empty($stripesupplieracc))
{
print load_fiche_titre($langs->trans('StripeBalance').($stripesupplieracc ? ' (Stripe connection with StripeConnect account '.$stripesupplieracc.')' : ' (Stripe connection with keys from Stripe module setup)'), $morehtmlright, 'stripe-s');
$balance = \Stripe\Balance::retrieve(array("stripe_account" => $stripesupplieracc));
diff --git a/htdocs/stripe/class/stripe.class.php b/htdocs/stripe/class/stripe.class.php
index a3199917f53..a710f092b89 100644
--- a/htdocs/stripe/class/stripe.class.php
+++ b/htdocs/stripe/class/stripe.class.php
@@ -83,16 +83,19 @@ class Stripe extends CommonObject
*
* @param string $mode 'StripeTest' or 'StripeLive'
* @param int $fk_soc Id of thirdparty
+ * @param int $entity Id of entity (-1 = current environment)
* @return string Stripe account 'acc_....' or '' if no OAuth token found
*/
- public function getStripeAccount($mode = 'StripeTest', $fk_soc = 0)
+ public function getStripeAccount($mode = 'StripeTest', $fk_soc = 0, $entity = -1)
{
global $conf;
+ if ($entity < 0) $entity = $conf->entity;
+
$sql = "SELECT tokenstring";
$sql .= " FROM ".MAIN_DB_PREFIX."oauth_token";
- $sql .= " WHERE entity = ".$conf->entity;
- $sql .= " AND service = '".$this->db->escape($mode)."'";
+ $sql .= " WHERE service = '".$this->db->escape($mode)."'";
+ $sql .= " AND entity = ".((int) $entity);
if ($fk_soc > 0) {
$sql .= " AND fk_soc = ".$fk_soc;
} else {
diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php
index 3a7d90cb732..f560fee0b44 100644
--- a/htdocs/takepos/invoice.php
+++ b/htdocs/takepos/invoice.php
@@ -233,29 +233,30 @@ if ($action == 'valid' && $user->rights->facture->creer)
// $conf->global->FACTURE_ADDON = $sav_FACTURE_ADDON;
//}
- $remaintopay = $invoice->getRemainToPay();
-
// Add the payment
- if (!$error && $res >= 0 && $remaintopay > 0) {
- $payment = new Paiement($db);
- $payment->datepaye = $now;
- $payment->fk_account = $bankaccount;
- $payment->amounts[$invoice->id] = $amountofpayment;
- if ($pay == 'cash') $payment->pos_change = price2num(GETPOST('excess', 'alpha'));
+ if (!$error && $res >= 0) {
+ $remaintopay = $invoice->getRemainToPay();
+ if ($remaintopay > 0) {
+ $payment = new Paiement($db);
+ $payment->datepaye = $now;
+ $payment->fk_account = $bankaccount;
+ $payment->amounts[$invoice->id] = $amountofpayment;
+ if ($pay == 'cash') $payment->pos_change = price2num(GETPOST('excess', 'alpha'));
- // If user has not used change control, add total invoice payment
- // Or if user has used change control and the amount of payment is higher than remain to pay, add the remain to pay
- if ($amountofpayment == 0 || $amountofpayment > $remaintopay) $payment->amounts[$invoice->id] = $remaintopay;
+ // If user has not used change control, add total invoice payment
+ // Or if user has used change control and the amount of payment is higher than remain to pay, add the remain to pay
+ if ($amountofpayment == 0 || $amountofpayment > $remaintopay) $payment->amounts[$invoice->id] = $remaintopay;
- $payment->paiementid = $paiementid;
- $payment->num_payment = $invoice->ref;
+ $payment->paiementid = $paiementid;
+ $payment->num_payment = $invoice->ref;
- if ($pay != "delayed") {
- $payment->create($user);
- $payment->addPaymentToBank($user, 'payment', '(CustomerInvoicePayment)', $bankaccount, '', '');
+ if ($pay != "delayed") {
+ $payment->create($user);
+ $payment->addPaymentToBank($user, 'payment', '(CustomerInvoicePayment)', $bankaccount, '', '');
+ $remaintopay = $invoice->getRemainToPay(); // Recalculate remain to pay after the payment is recorded
+ }
}
- $remaintopay = $invoice->getRemainToPay(); // Recalculate remain to pay after the payment is recorded
if ($remaintopay == 0) {
dol_syslog("Invoice is paid, so we set it to status Paid");
$result = $invoice->set_paid($user);
|