8. Sales Order Planning

1. Sales Order Planning Settings

With these settings, you can customize the way Embedded ERP calculate sales order planning.

All this settings are available under System > Configuration > Sales Order Planning

1. General

Setting Description
Allow planning Yes / No

2. Order Consideration Date Calculation

Here, you can set when the order is being considered. This is the start date for the planning.

Setting Description
Consider Order when placed Consider order after it is placed, whatever payment status
Consider Order when Paid Consider order after payment method send payment information to magento
Consider Order on Payment Validated Consider order when payment validated is set to true
Consider Order when Invoiced Consider order when its invoice is created
Include holy days Do not consider order on holy day (consider order the opened day after)
Consider Order for Tomorrow if placed after If order placed after X, the order is considered tomorrow


You must set only one of the 4 first option

If you set Consider Order when paid


Consider Order on Payment Validated


Consider Order when invoiced


some planning car be calculated wrongly with a date like 1970 because the system does not detect the “Paid date” or the “Payment date”, or the “Invoice date” because it is sent too late or not sent py the payment method.

If you have  date like “1970-01-01”, please choose : “Consider Order when placed”.

Holidays and Weekend options

  1. The week days considers like a week end are define in : System > Configuration > General > Locale Options > Weekend Days 
  2. The days of holidays are hard coded
  1. In the file : app/code/community/MDN/SalesOrderPlanning/Helper/Holidays.php
  2. Country is defined in  System > Configuration > General > Countries Options > Default Country

3. Ready to prepare

This is the date where all products are reserved for the order and then you can start to prepare it.

Setting Description
Avoid holy days If ready to prepare date is an holy day, select the next opened day
Method of calculating risk Select the method of calculating risk: in days or percentage
Worst date calculation value Value (percent or value) to calculate worst date

4. Shipping date

This is the date when you ship the order. This is generally equal to the “ready to prepare” date plus preparation duration.

Setting Description
Method of calculating risk Select the method of calculating risk: in days or percentage
Order Preparation Duration This the duration that you need to prepare an order. This is generally equal to 0 if you don’t have assemble products or make tests
Worst date calculation Mode Define the way to calculate worst date (percent or value).
Worst date calculation value Value (percent or value) to calculate worst date
Avoid holy days Do not consider order on holy day (consider order the opened day after)

5. Delivery date

Setting Description
Default Shipping Delay This is the default delay that your carriers need to ship products. You can customize this value by shipping mode / country using menus ERP > Tools > Shipping delay
Worst date calculation Mode Define the way to calculate worst date (percent or value)
Worst date calculation value Value (percent or value) to calculate worst date
Avoid holy days Do not consider order on holy day (consider order the opened day after)

6. Quote options

You can define here settings used to display estimated delivery date in the cart.

In order to estimate delivery date, the system needs to know if selected payment will be validated automatically (credit card, paypal) or if a manual validation is required (checks, bank transfer)...

Then, Embedded ERP considers 2 kinds of payment :

  • Immediate payment : these are payment method that are validated (or refused) just after placing order (credit card, paypal)
  • Delayed payment : payment methods that require a manual validation (bank transfer, check ...
Setting Description
Immediate payment methods Select methods for which validation is direct
Delayed payment method delay This is the average duration (in days) required to validate a delayed payment.

To display planing and quote date in cart :


2. Product Availability Status

1. Introduction

Embedded ERP is able to display advanced product availability message to the customer depending of stock level, supply delay, expected purchase orders etc...

To avoid unwanted sales when a product reach 0 stock, please note that ERP automatically decrements Product availability status at the moment the order is placed.

Here are the different messages that ERP can display :

  • In stock
  • Out of stock (product is not sellable)
  • Available under X weeks (you can setup custom messages based on the delay to supply the product)
  • Back in stock at XX/XX/XXX (based on purchase order delivery date)

Product availability status is calculated using this information :

  • Available stock : This is the stock available for sales. Available stock is equal to the product stock minus ordered quantity.
  • Supply Delay : this is the average supply delay when you purchase product to your supplier. This value can be set at the global level, supplier level or product level.
  • Expected purchase order : if you’re waiting for a purchase order delivery, the system uses this display expected delivery date.
  • Out of stock periods : you can setup out of stock periods

The supply delay definition done :

  • At Product level ( ERP -> product -> tab Purchase settings -> Default supply delay )
  • At Product-Supplier association Level ( ERP -> product -> tab Supplier -> Edit -> Supply delay settings)
  • At Supplier Level ( ERP -> Purchase-> Suppliers -> Select a  supplier -> Tab Misc-> Supply delay settings)
  • On the current Purchases Orders if there is a delivery date for this product  ( ERP -> product -> tab Purchase Orders)

The supply delay is calculated like this :

ERP check first if that information is set at the product level, if it’s set, it’s the delay that will be used.

If no supply delay is set at the product level, then ERP checks and use the best delay available in the product supplier-product association.

If there is no delay found on the 2 previous entries, ERP use the one set in

system > configuration > purchase > purchase product -> Default supply delay

Then, ERP display the default supply delay except if there is a product availability range message set for the supply delay value, we use the message set instead.

For more details please look at


For developers :

The supply delay is calculated in

  • app/code/community/MDN/SalesOrderPlanning/Model/ProductAvailabilityStatus.php
  • Function  getSupplyDelay()

Don’t mismatch with the Available delay with is calculated in

  • app/code/community/MDN/AdvancedStock/Helpe/rProduct/Base.php
  • function getAvailableQty()

All product availability status are stored into the table product_availability

2. Out of stock period

You can fill an “out of stock period” for each product.

The form is available in ERP > products > [select product] > Out of stock period.

To fill a out of stock period, first tick “Enabled” checkbox and fill in start date (required) and end date (optional).


This feature apply only if you have no local stock on warehouse allowed for sales. When you set an out of stock period, it means that your supplier(s) can t provide this product for this given period. AtT the end of the period, the Out of stock period has no more effect and the product is back in stock automatically by cron job run every day at 3 AM that refresh every product avilability status with an an out of stock period enabled.

Note : you have to define a begin date : 1 before the out of stock period begin date because the check of the date begin at midnigth of the day set.

3. Availability status

1. View

Embedded ERP store in database product availability information to improve speediness. This information is updated using background task.

To get availability information :

  • To list all availabilities : Select menus ERP > Tools > Product availability statuses
  • To get information for one product : select menu ERP > Products > [Select product] > “Product availability status tab”

In each screen, the system displays this information :

  • Available stock is 0 and backorders set to false
  • Available stock is 0 and there is an out of stock period without end date
  • Product stock status is “Out of stock” in the magento product sheet
Field Description
Website Product availability per website
Available qty Stock level available for sale
Supply delay Average delay for product supply. This value can be set at 3 levels :. .  (*) Product level (ERP > products > [Select product] > Purchase settings > supply delay). .  (*) If no value is available at the product level, the system look at the supplier level (for suppliers associated to the product). Supplier default supply delay can be set in ERP > Purchasing > Supplier > [Select supplier] > Miscellaneous > Supply delay.. .  (*) If no value is available at the supplier level, the system uses default value (System > Configuration > Purchase module > Purchase product > Supply delay).
Allow backorders If set to true, customers can’t buy products if available qty is 0
Supply date Contains estimated date for Purchase Order delivery.
Out of stock period Out of stock period set in the product sheet (ERP > Products > [Select product] > Out of stock tab
Salable This information is calculated using other values. If salable is “No”, product cant be sold on the website. Product is not sellable when
Status This is the product availability status that defines availability message :. .  (*) : In stock : product is in stock and sellable. .  (*) Available under delay : product is not in stock but can be purchase from your supplier(s). .  (*) Supply on : a supplier delivery is expected. .  (*) Out of stock until : product is not in stock and cant be supplied until X. It means that there is a out of stock period. .  (*) Out of stock without information : product is not in stock and no supply information is available.
Available date This is the estimated date where the product is back in stock. This date is used to calculate sales order planning. If product is in stock, this date is today
Message Message displayed on the website
Refresh Refresh product availability status

You can view the product by clicking on the button “View” and you will access to the ERP product. Click “force update of stock” to update the stock of this product.

2. Product availability status per website

This feature allow to enable the product availability status per website.

The option to enable it is in :

System > Configuration > ERP > Sales Order Planning > Product availability status > Enable for multiple websites


This option is set by default to ‘No’.

When this option is disabled you see from the ERP > products > your product > Availability status tab the following :


The Global website mean that it is the sum of the product availability for warehouse with the Admin : ‘sales’ assignment.

Once this option enabled you see now this:


It will show you the availability status of the product per website.

Of course this availability status per website depends of your warehouse assignments, to remember, a product is saleable only if the ‘sales’ assignment is ticked.

Please read :


3. Updates

Product availability statuses are automatically updated. 

ERP triggers some refresh event on each stock modification that can change the Availability status.

These updates are made using background task, it means that it may take a few minutes.

You can launch some mass manual updates on:

ERP > Tools > product availability statuses

If you wish to manually update product availability, 2 ways :

  • Click on the “refresh” link to update availability for one product
  • Click on refresh button  to update ALL availabilities
  • Filter and Select teh product you want and use the mass action to refresh the products you need.

Please think to look regularly to

System -> configuration -> ERP -> ERP Info -> Unconsistant Product Availability Status

System -> configuration -> ERP -> ERP Info -> Missing Product Availability Status 

4. Product availability ranges

ERP > Tools > Product availability ranges

If the a product is Out of stock AND you allow “backOrder and Notify customer”.

The product availability status of ERP will displays a message like “Available under X days” based on the product supply delay and pending purchase orders.

If you are no satisfied with such message, you can customize this message using:

ERP > Tools > Product availability ranges

the Idea is to override the message based on a range of “Availability days”

For each range, you can define :

  • From : range day start
  • To : range day end
  • Default caption : default caption displayed
  • Store XX : For each store, you can customize default caption (for multi language support)


If ERP calculates “Available under 3 days”

And if you define a Range

from 0 to 5 Days : Default Caption “Available Soon”, Store FR : “Bientôt Disponible”

On a product that have normally “Available under 3 days”, on the store US, you will have “Available Soon” and the store French you will have  “Bientôt Disponible”

Range sample :


4. Display the Product Availability Status on front-end

ERP allows to override Magento’s product availability status on product view pages (listing and detail)

When you upload ERP to your site, it overwrites default files located in :


Note : ** If you have a custom Magento theme, you have to copy the code of these files to the ones of your skin Take care to do this on **every product page where you want the product availability status to be displayed

Here are the instruction to make this modification on product list and detail

On product detail pages

Open the file :

See also


Add the following code where you find it relevant :

<?php $_product = $this->getProduct() ?>

    //display custom availability message
    $productAvailabilityStatus = $this->getProductAvailabilityStatus();
    $availabilityMessage = '';
    if ($productAvailabilityStatus)
            $availabilityMessage = $productAvailabilityStatus->getMessage();

<div id="div_availability" name="div_availability">
     <?php echo $availabilityMessage; ?>

On product listing pages

Open the file :

See also


Add this code where you find it relevant (usally around lines #64 & #105) :

Depending of magento version, replace

$productAvailabilityStatus = mage::getModel('SalesOrderPlanning/ProductAvailabilityStatus')->load($_product->getId(), 'pa_product_id');

$availabilityMessage = '';

if ($productAvailabilityStatus) {
   $availabilityMessage = $productAvailabilityStatus->getMessage();

echo $availabilityMessage;

On cart level

Edit the file :

See also


Add this code where you find it relevant (usually around line #60) :

$productAvailabilityStatus = mage::getModel('SalesOrderPlanning/ProductAvailabilityStatus')->load($_product->getId(), 'pa_product_id');

$availabilityMessage = '';

if ($productAvailabilityStatus) {
   $availabilityMessage = $productAvailabilityStatus->getMessage();

echo $availabilityMessage;


  • On some version of ERP, you have to set the function getIsSaleable “public” instead of “protected” in the file app/code/community/MDN/SalesOrderPlanning/Model/ProductAvailabilityStatus.php
  • The file list.phtml (product listing view) displays product list in both grid and list modes. You have to edit the file into the part corresponding to your display settings

Additional tricks

To display the global available and sellable Qty for a product

$availabilityMessage .= 'Qty available='.$productAvailabilityStatus->getpa_available_qty();

To display each warehouse Qty for a simple product

$stocks = mage::helper('AdvancedStock/Product_Base')->getStocks($_productSimple->getId());
foreach ($stocks as $stockItem) {
    echo $stockItem->getQty(); //real stock qty
    echo $stockItem->getAvailableQty(); //stock qty real available after ERP reservation

To display each warehouse Qty for all simple products of a configurable

$childIds = Mage::getModel('catalog/product_type_configurable')->getChildrenIds($_productConfigurable->getId());
foreach ($childIds as $key => $childId) {
    $stocks = mage::helper('AdvancedStock/Product_Base')->getStocks($childId);
    foreach ($stocks as $stockItem) {
        echo 'qty= '.$stockItem->getAvailableQty();

5. Elements impacting the product availability on front-end

After you install ERP, you have to configure the “product availability status” on the front (cf previous article of this section)

Once it is done,

you must understand why a product will by purchasable or not :

  1. check if you allow back order or not :


  1. check if the product is “in stock or “out of Stock”


Tip : If you encounter cron issue, click on Force stock update and update also the product availability status on this screen.

  1. check you sales assignment for you warehouses :


  1. check if you have correctly integrated on the front the product availability status


To be 100% sure, please checks if you see “div_availability” on your front “product view page” displaying the source code in the browser

  1. if it is a Configurable or Bundle product it work a bit differently, please checks :


  1. Check is the product is Enable or Disabled in Magento (in back office magento product view)

6. Common problems

Simple products

  • Does the product is stock managed ?
  • Does the product availability status is refreshed correctly ?
  • Does the product availability status is integrated on you skin/theme


  • Have you solved you conflicts using magento extension conflict on Mage_Catalog_Block_Product_View_Type_Simple

Configurable products

  • Does the product is NOT stock managed ?
  • Do you configurable product page contain custom code ?
  • Do you have any javascript error ont he page ?
  • Have you solved you conflicts using magento extension conflict on Mage_Catalog_Block_Product_View_Type_Configurable

3. Sales Order Planning

Our extension enables the calculation of estimated delivery date for a customer order: It is planning idea.

This function allows in real time to estimate the date when the customer will receive his order depending on different parameters such as product availability, supply needs planned, forwarder…etc

1. Back office

Shipping delay

This settings are available under menus ERP > Tools > Shipping delay.

This section allows you to define the delivery deadlines depending on forwarder and enables to define exceptions per countries. These data will be used to define an order schedule:

  • Estimate delivery dates display when customer place an order (in the basket or in the order confirmation sheet)
  • Estimate delivery dates calculation when order is placed

While displaying, the list of forwarders appears. If a forwarder does not appear on the list or if still not appears after you already add a forwarder in Magento, click on button “update”.

For each forwarder, you have to advise the following details:

Setting Description
Default delay It is the default transit time that your forwarder requires to deliver the customer when order is dispatched. It will be applied if no exception is defined. Please note that if you do not define any default transit time, the one defined in”System > Configuration > Planning > delivery > default transit time” will be taken into account.
Exceptions Exceptions will allow you to define a transit time per country different then default transit time. Exceptions shall follow this format (*) Country_code : transit time. .  (*) Exceptions shall be separated with a comma..

Configuration example: The following example defines a default transit time for the forwarder ” flatrate ” of 2 days. It will be used for all the countries not appearing in exceptions. However exceptions are defined for Germany (DE), Italy (IT) and France ( FR) with respectively transit times of 7,5 and 3 days.


2. Order view


Order planning is defined from 5 dates:

  • Date of order ( when order is placed)
  • Processing date: It is the date when order is taken into account especially in the purchasing point of vue. In general, this date corresponds with the order payment date.
  • Preparation date: It is the date when all products for the order are on stock and booked: the date when you can prepare the shipment. This date is worked out depending on default order products availability but also supply needs estimations.
  • Shipping date: Estimate shipping order date. This date is the date preparation date plus order preparation timing (configured previously).
  • Delivery date: It is the date when customer received his order. This date is worked out with configuration parameters and also with different forwarder transit time.

In order to configure the way these different dates are worked out; kindly check the section ” Configuration ” of this document.

You can see an order planning by going in the sheet order, tab ” Planning ”.

In front of each step, the last column shows data explaining the calculations. Kindly note that these instructions are only available in English.

Each step has also a ” maximum date ”. This date is calculated depending on parameters and allows advising the customer the delivery deadline (Chatel Law). In the configuration part, you can define a risk for each step (Example: in the worst case, the forwarder will have 2 days of delay to deliver the customer).

You also have the possibility of forcing these dates manually.

From all dates, ” Preparation date ” is very important because it defines the ” deadline ” for an order in terms of supply. This date will appear in the supply needs screen.

Color codes :

orange : more than 3 days late

red: more than 3 days late

green : not late

3. Estimated delivery date on front-end

Using ERP, you can display an estimation of products delivery date on the front-end, at both cart and customer account level.

It can displays 2 differents dates :

  • Estimated date : Delivery date calculated for the best case : all operations are not late (order preparation, product supply etc..)
  • Max date : Delivery date calculated for the worst case : using the “max dates”

At cart level

Edit the file app/design/frontend/[your theme]/template/checkout/cart.phtml

(if this file does not exist, you must duplicate it from app/design/frontend/base/default to your theme)

Add this code where you find it relevant:

$blockplanning = $this->getLayout()->createBlock('SalesOrderPlanning/Planning_Cart');
echo $blockplanning->toHtml();


Please note that:

  • In the shopping cart, if no shipping method is selected, those dates won’t appear.
  • Those dates are estimation and can’t be use else where that in cart.

At customer account level

Edit the file app/design/frontend/[your theme]/template/sales/order/info.phtml

(if this file doesn’t not exist, you must duplicate it from app/design/frontend/base/default to your theme)

Add this code where you find it relevant :

$blockplanning = $this->getLayout()->createBlock('SalesOrderPlanning/Planning_Graph');
echo $blockplanning->toHtml();