[*] BO : no payment is registered on order creation for check and bankwire payment

git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@11296 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
aFolletete committed 2011-12-16 10:10:48 +00:00
1 parent d6c85b63d5
commit 6f03353f96
3 files changed
+25 -29

No files matched your search

+16 -18
View File
@@ -130,6 +130,10 @@ abstract class PaymentModuleCore extends Module
die($errorMessage); die($errorMessage);
} }
$order_status = new OrderState((int)$id_order_state, (int)$order->id_lang);
if (!Validate::isLoadedObject($order_status))
throw new PrestashopException('Can\'t load Order state status');
foreach ($cart_delivery_option as $id_address => $key_carriers) foreach ($cart_delivery_option as $id_address => $key_carriers)
foreach ($delivery_option_list[$id_address][$key_carriers]['carrier_list'] as $id_carrier => $data) foreach ($delivery_option_list[$id_address][$key_carriers]['carrier_list'] as $id_carrier => $data)
foreach ($data['package_list'] as $id_package) foreach ($data['package_list'] as $id_package)
@@ -194,6 +198,13 @@ abstract class PaymentModuleCore extends Module
// Creating order // Creating order
$result = $order->add(); $result = $order->add();
// Register Payment only if the order status validate the order
if ($result && $order_status->logable)
{
if (!$order->addOrderPayment($amountPaid))
throw new PrestashopException('Can\'t save Order Payment');
}
$order_list[] = $order; $order_list[] = $order;
// Insert new Order detail list using cart for the current order // Insert new Order detail list using cart for the current order
@@ -210,13 +221,6 @@ abstract class PaymentModuleCore extends Module
$order_carrier->shipping_cost_tax_incl = (float)$order->total_shipping_tax_incl; $order_carrier->shipping_cost_tax_incl = (float)$order->total_shipping_tax_incl;
$order_carrier->add(); $order_carrier->add();
} }
// Register Payment
if (!$order->addOrderPayment($amountPaid))
{
$errorMessage = Tools::displayError('Can\'t save payment');
Logger::addLog($errorMessage, 4, '0000003', 'Order', intval($order->id));
die($errorMessage);
}
// Next ! // Next !
foreach ($order_detail_list as $key => $order_detail) foreach ($order_detail_list as $key => $order_detail)
@@ -244,8 +248,6 @@ abstract class PaymentModuleCore extends Module
//$orderDetail = new OrderDetail(null, null, $this->context); //$orderDetail = new OrderDetail(null, null, $this->context);
//$orderDetail->createList($order, $cart, $id_order_state); //$orderDetail->createList($order, $cart, $id_order_state);
//$this->addPCC($order->id, $order->id_currency, $amountPaid);
// Construct order detail table for the email // Construct order detail table for the email
$productsList = ''; $productsList = '';
$products = $cart->getProducts(); $products = $cart->getProducts();
@@ -343,14 +345,10 @@ abstract class PaymentModuleCore extends Module
} }
// Hook validate order // Hook validate order
$orderStatus = new OrderState((int)$id_order_state, (int)$order->id_lang); Hook::exec('newOrder', array('cart' => $cart, 'order' => $order, 'customer' => $customer, 'currency' => $currency, 'orderStatus' => $order_status));
if (Validate::isLoadedObject($orderStatus)) foreach ($cart->getProducts() AS $product)
{ if ($order_status->logable)
Hook::exec('newOrder', array('cart' => $cart, 'order' => $order, 'customer' => $customer, 'currency' => $currency, 'orderStatus' => $orderStatus)); ProductSale::addProductSale((int)$product['id_product'], (int)$product['cart_quantity']);
foreach ($cart->getProducts() AS $product)
if ($orderStatus->logable)
ProductSale::addProductSale((int)$product['id_product'], (int)$product['cart_quantity']);
}
if (Configuration::get('PS_STOCK_MANAGEMENT') && $order_detail->getStockState()) if (Configuration::get('PS_STOCK_MANAGEMENT') && $order_detail->getStockState())
{ {
@@ -433,7 +431,7 @@ abstract class PaymentModuleCore extends Module
$data = array_merge($data, $extraVars); $data = array_merge($data, $extraVars);
// Join PDF invoice // Join PDF invoice
if ((int)(Configuration::get('PS_INVOICE')) AND Validate::isLoadedObject($orderStatus) AND $orderStatus->invoice AND $order->invoice_number) if ((int)(Configuration::get('PS_INVOICE')) && $order_status->invoice && $order->invoice_number)
{ {
$fileAttachment['content'] = PDF::invoice($order, 'S'); $fileAttachment['content'] = PDF::invoice($order, 'S');
$fileAttachment['name'] = Configuration::get('PS_INVOICE_PREFIX', (int)($order->id_lang)).sprintf('%06d', $order->invoice_number).'.pdf'; $fileAttachment['name'] = Configuration::get('PS_INVOICE_PREFIX', (int)($order->id_lang)).sprintf('%06d', $order->invoice_number).'.pdf';
+1 -1
View File
@@ -1054,7 +1054,7 @@ class OrderCore extends ObjectModel
SELECT `id_order_carrier` SELECT `id_order_carrier`
FROM `'._DB_PREFIX_.'order_carrier` FROM `'._DB_PREFIX_.'order_carrier`
WHERE `id_order` = '.(int)$order_invoice->id_order.' WHERE `id_order` = '.(int)$order_invoice->id_order.'
AND `id_order_invoice` IS NULL'); AND (`id_order_invoice` IS NULL OR `id_order_invoice` = 0)');
$order_carrier = new OrderCarrier($id_order_carrier); $order_carrier = new OrderCarrier($id_order_carrier);
$order_carrier->id_order_invoice = (int)$order_invoice->id; $order_carrier->id_order_invoice = (int)$order_invoice->id;
$order_carrier->update(); $order_carrier->update();
+8 -10
View File
@@ -57,7 +57,7 @@ INSERT INTO `PREFIX_module` (`id_module`, `name`, `active`) VALUES (1, 'homefeat
(34, 'graphvisifire', 1),(35, 'graphxmlswfcharts', 1),(36, 'graphgooglechart', 1),(37, 'graphartichow', 1),(39, 'gridhtml', 1),(40, 'statsbestcustomers', 1), (34, 'graphvisifire', 1),(35, 'graphxmlswfcharts', 1),(36, 'graphgooglechart', 1),(37, 'graphartichow', 1),(39, 'gridhtml', 1),(40, 'statsbestcustomers', 1),
(41, 'statsorigin', 1),(42, 'pagesnotfound', 1),(43, 'sekeywords', 1),(44, 'statsproduct', 1),(45, 'statsbestproducts', 1),(46, 'statsbestcategories', 1), (41, 'statsorigin', 1),(42, 'pagesnotfound', 1),(43, 'sekeywords', 1),(44, 'statsproduct', 1),(45, 'statsbestproducts', 1),(46, 'statsbestcategories', 1),
(47, 'statsbestvouchers', 1),(48, 'statsbestsuppliers', 1),(49, 'statscarrier', 1),(50, 'statsnewsletter', 1),(51, 'statssearch', 1),(52, 'statscheckup', 1),(53, 'statsstock', 1), (47, 'statsbestvouchers', 1),(48, 'statsbestsuppliers', 1),(49, 'statscarrier', 1),(50, 'statsnewsletter', 1),(51, 'statssearch', 1),(52, 'statscheckup', 1),(53, 'statsstock', 1),
(54, 'blockstore', 1),(55, 'statsforecast', 1), (54, 'blockstore', 1),(55, 'statsforecast', 1),
/* new themes : modules to add */ /* new themes : modules to add */
(56, 'blocktopmenu', 1), (56, 'blocktopmenu', 1),
(57, 'blocksharefb', 1), (57, 'blocksharefb', 1),
@@ -78,12 +78,12 @@ INSERT INTO `PREFIX_module_access` (`id_profile`, `id_module`, `configure`, `vie
INSERT INTO `PREFIX_module_shop` (`id_module`, `id_shop`) (SELECT `id_module`, 1 FROM `PREFIX_module`); INSERT INTO `PREFIX_module_shop` (`id_module`, `id_shop`) (SELECT `id_module`, 1 FROM `PREFIX_module`);
/* /*
* rightcolumn=6, leftcolumn=7, home=8, header=9, top=14, * rightcolumn=6, leftcolumn=7, home=8, header=9, top=14,
*/ */
INSERT INTO `PREFIX_hook_module` (`id_module`, `id_hook`, `position`) VALUES INSERT INTO `PREFIX_hook_module` (`id_module`, `id_hook`, `position`) VALUES
/* homefeatured */ /* homefeatured */
(1, 8, 2), (1, 8, 2),
(1, 9, 23), (1, 9, 23),
@@ -326,8 +326,6 @@ INSERT INTO `PREFIX_order_detail_tax` (`id_order_detail`, `id_tax`, `unit_amount
(1, 1, '76.860000', '76.860000'), (1, 1, '76.860000', '76.860000'),
(2, 1, '24.420000', '24.420000'); (2, 1, '24.420000', '24.420000');
INSERT INTO `PREFIX_order_payment` (`id_order`, `id_currency`, `amount`, `payment_method`, `date_add`) VALUES (1, 1, '626.37', 'Chèque', NOW());
INSERT INTO `PREFIX_manufacturer` (`id_manufacturer`, `name`, `date_add`, `date_upd`, `active`) VALUES (1, 'Apple Computer, Inc', NOW(), NOW(), 1); INSERT INTO `PREFIX_manufacturer` (`id_manufacturer`, `name`, `date_add`, `date_upd`, `active`) VALUES (1, 'Apple Computer, Inc', NOW(), NOW(), 1);
INSERT INTO `PREFIX_manufacturer` (`id_manufacturer`, `name`, `date_add`, `date_upd`, `active`) VALUES(2, 'Shure Incorporated', NOW(), NOW(), 1); INSERT INTO `PREFIX_manufacturer` (`id_manufacturer`, `name`, `date_add`, `date_upd`, `active`) VALUES(2, 'Shure Incorporated', NOW(), NOW(), 1);
@@ -1670,7 +1668,7 @@ CREATE TABLE IF NOT EXISTS `PREFIX_newsletter` (
`active` tinyint(1) unsigned NOT NULL DEFAULT '0', `active` tinyint(1) unsigned NOT NULL DEFAULT '0',
PRIMARY KEY (`id_slide`) PRIMARY KEY (`id_slide`)
) ENGINE=ENGINE_TYPE DEFAULT CHARSET=UTF8; ) ENGINE=ENGINE_TYPE DEFAULT CHARSET=UTF8;
CREATE TABLE IF NOT EXISTS `PREFIX_homeslider_slides_lang` ( CREATE TABLE IF NOT EXISTS `PREFIX_homeslider_slides_lang` (
`id_slide` int(10) unsigned NOT NULL, `id_slide` int(10) unsigned NOT NULL,
`id_lang` int(10) unsigned NOT NULL, `id_lang` int(10) unsigned NOT NULL,
@@ -1683,7 +1681,7 @@ CREATE TABLE IF NOT EXISTS `PREFIX_newsletter` (
) ENGINE=ENGINE_TYPE DEFAULT CHARSET=UTF8; ) ENGINE=ENGINE_TYPE DEFAULT CHARSET=UTF8;
INSERT INTO `PREFIX_configuration` (name, value) INSERT INTO `PREFIX_configuration` (name, value)
VALUES VALUES
("HOMESLIDER_WIDTH", "535"), ("HOMESLIDER_WIDTH", "535"),
("HOMESLIDER_HEIGHT", "300"), ("HOMESLIDER_HEIGHT", "300"),
("HOMESLIDER_SPEED", "1300"), ("HOMESLIDER_SPEED", "1300"),
@@ -1691,7 +1689,7 @@ VALUES
INSERT INTO `PREFIX_homeslider` (id_slide, id_shop) VALUES (1, 1),(2, 1), (3, 1), (4, 1), (5, 1); INSERT INTO `PREFIX_homeslider` (id_slide, id_shop) VALUES (1, 1),(2, 1), (3, 1), (4, 1), (5, 1);
INSERT INTO `PREFIX_homeslider_slides` (id_slide, position, active) INSERT INTO `PREFIX_homeslider_slides` (id_slide, position, active)
VALUES (1, 1, 1), (2, 2, 1), (3, 3, 1), (4, 4, 1), (5, 5, 1); VALUES (1, 1, 1), (2, 2, 1), (3, 3, 1), (4, 4, 1), (5, 5, 1);
INSERT INTO `PREFIX_homeslider_slides_lang` (id_slide, id_lang, title, description, legend, url, image) VALUES INSERT INTO `PREFIX_homeslider_slides_lang` (id_slide, id_lang, title, description, legend, url, image) VALUES