diff --git a/htdocs/langs/en_US/paypal.lang b/htdocs/langs/en_US/paypal.lang index 42a95d8002b..56093e07a74 100644 --- a/htdocs/langs/en_US/paypal.lang +++ b/htdocs/langs/en_US/paypal.lang @@ -31,6 +31,7 @@ OrderIsCreated=Order created InvoiceIsCreated=Invoice created PaypalCreateOrderEnabled=Enable the ability to create customer orders PaypalCreateInvoiceEnabled=Enable the ability to create customer invoices +UseThePriceDefinedInPaypal=Use the price defined in Paypal instead of the one defined in Dolibarr DefaultProductShippingCosts=Select the product to be used for adding shipping costs. DefaultPaypalAccount=Select the bank account to be used as a Paypal account, this will deduct the Paypal fee when adding a payment. diff --git a/htdocs/langs/fr_FR/paypal.lang b/htdocs/langs/fr_FR/paypal.lang index 6a73994a273..6e74ebcaceb 100644 --- a/htdocs/langs/fr_FR/paypal.lang +++ b/htdocs/langs/fr_FR/paypal.lang @@ -31,6 +31,7 @@ OrderIsCreated=Commande créée InvoiceIsCreated=Facture créée PaypalCreateOrderEnabled=Activer la possibilité de créer des commandes clients. PaypalCreateInvoiceEnabled=Activer la possibilité de créer des factures clients. +UseThePriceDefinedInPaypal=Utiliser le prix défini dans Paypal au lieu de celui défini dans Dolibarr DefaultProductShippingCosts=Sélectionnez le produit qui sera utilisé pour l'ajout des frais de port. DefaultPaypalAccount=Sélectionner le compte bancaire qui sera utilisé comme compte Paypal, ceci permettra de déduire les frais Paypal lors de l'ajout d'un paiement. diff --git a/htdocs/paypal/admin/import.php b/htdocs/paypal/admin/import.php index fda11b0fb64..c0a60c09880 100755 --- a/htdocs/paypal/admin/import.php +++ b/htdocs/paypal/admin/import.php @@ -203,6 +203,33 @@ if ($conf->facture->enabled) print ''; } +// Invoice +if ($conf->facture->enabled) +{ + $var=!$var; + print ''; + print ''.$langs->trans("UseThePriceDefinedInPaypal").''; + print ' '; + + print ''; + if ($conf->use_javascript_ajax) + { + print ajax_constantonoff('PAYPAL_USE_PRICE_DEFINED_IN_PAYPAL'); + } + else + { + if($conf->global->PAYPAL_USE_PRICE_DEFINED_IN_PAYPAL == 0) + { + print ''.img_picto($langs->trans("Disabled"),'off').''; + } + else if($conf->global->PAYPAL_USE_PRICE_DEFINED_IN_PAYPAL == 1) + { + print ''.img_picto($langs->trans("Enabled"),'on').''; + } + } + print ''; +} + // Shipping costs $var=!$var; print '
'; diff --git a/htdocs/paypal/ajaxtransaction.php b/htdocs/paypal/ajaxtransaction.php index 8852c5b9c3d..52322aabf34 100644 --- a/htdocs/paypal/ajaxtransaction.php +++ b/htdocs/paypal/ajaxtransaction.php @@ -176,9 +176,27 @@ if (isset($_GET['action']) && ! empty($_GET['action']) && isset($_GET['transacti if ($ret > 0) { $qty=$_SESSION[$_GET['transaction_id']]["L_QTY".$i]; + + if ($conf->global->PAYPAL_USE_PRICE_DEFINED_IN_PAYPAL) + { + if ($_SESSION[$_GET['transaction_id']]["L_AMT".$i]) + { + $amount_ht = ($_SESSION[$_GET['transaction_id']]["L_AMT".$i] - $_SESSION[$_GET['transaction_id']]["L_SHIPPINGAMT".$i]); + } + else + { + $amount_ht = ($_SESSION[$_GET['transaction_id']]["AMT"] - $_SESSION[$_GET['transaction_id']]["SHIPAMOUNT"] - $_SESSION[$_GET['transaction_id']]["L_TAXAMT".$i]); + } + + $unitprice_ht = ($amount_ht / $qty); + } + else + { + $unitprice_ht = $product->price; + } - if ($subelement == 'commande') $fields = array($object_id,$product->description,$product->price,$qty,$product->tva_tx,$product->localtax1_tx,$product->localtax2_tx,$product->id,0,0,0,$product->price_base_type,0,'','',$product->product_type); - if ($subelement == 'facture') $fields = array($object_id,$product->description,$product->price,$qty,$product->tva_tx,$product->localtax1_tx,$product->localtax2_tx,$product->id,0,'','',0,0,0,$product->price_base_type,0,$product->product_type); + if ($subelement == 'commande') $fields = array($object_id,$product->description,$unitprice_ht,$qty,$product->tva_tx,$product->localtax1_tx,$product->localtax2_tx,$product->id,0,0,0,$product->price_base_type,0,'','',$product->product_type); + if ($subelement == 'facture') $fields = array($object_id,$product->description,$unitprice_ht,$qty,$product->tva_tx,$product->localtax1_tx,$product->localtax2_tx,$product->id,0,'','',0,0,0,$product->price_base_type,0,$product->product_type); $result = $object->addline($fields[0],$fields[1],$fields[2],$fields[3],$fields[4],$fields[5],$fields[6],$fields[7],$fields[8],$fields[9],$fields[10],$fields[11],$fields[12],$fields[13],$fields[14],$fields[15],$fields[16]); @@ -357,14 +375,14 @@ if (isset($_GET['action']) && ! empty($_GET['action']) && isset($_GET['transacti if ($_SESSION[$_GET['transaction_id']]["L_AMT".$i]) { $amount_ht = ($_SESSION[$_GET['transaction_id']]["L_AMT".$i] - $_SESSION[$_GET['transaction_id']]["L_SHIPPINGAMT".$i]); - $unitprice_ht = ($amount_ht / $qty); } else { $amount_ht = ($_SESSION[$_GET['transaction_id']]["AMT"] - $_SESSION[$_GET['transaction_id']]["SHIPAMOUNT"] - $_SESSION[$_GET['transaction_id']]["L_TAXAMT".$i]); - $unitprice_ht = ($amount_ht / $qty); } + $unitprice_ht = ($amount_ht / $qty); + $return_arr['contents'].= ''; $return_arr['contents'].= ''.$_SESSION[$_GET['transaction_id']]["L_NUMBER".$i].''; $return_arr['contents'].= ''.$_SESSION[$_GET['transaction_id']]["L_NAME".$i].''; @@ -423,13 +441,13 @@ if (isset($_GET['action']) && ! empty($_GET['action']) && isset($_GET['transacti $return_arr['contents'].= ''; } - /* +/* $return_arr['contents'].= '
'; foreach ($_SESSION[$_GET['transaction_id']] as $key => $value) { $return_arr['contents'].= $key.': '.$value.'
'; } - */ +*/ echo json_encode($return_arr); }