Export Form Action

It is possible to include an additional form for a customer package that provides information on the value of shipped goods used by customs for duty or taxes.

Overview

In addition to the already existing documents related to a consignment, it may be necessary to provide information on the value of shipped goods according to custom rules provided by the price strategy. This may be needed for tax purposes, customs declaration etc., where certain discounts or promotions should not be reflected.

To enable generation of such a document, a new Export Form action was added to the warehousingbackoffice extension. It allows you to print an export form document from the consignment details view in the Backoffice Order Fulfillment perspective.

The export form contains a list of shipped goods, their prices, and quantities. The prices in the export form may vary from those included in the invoice, since the invoice contains prices after promotions. Price calculation is handled by the specific Export Form Price Strategy implementation, providing an easy and flexible way to apply specific calculation logic.

Action Definition

The action is located in the warehousingbackoffice extension under /backoffice/resources/actions. The action definition contains button icons and label files. The definition.xml file points to the action's class name and sets the name and the icons to use for display.

definition.xml:
...
<action-definition id="de.hybris.platform.warehousingbackoffice.actions.exportforms"
                   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                   xsi:noNamespaceSchemaLocation="http://www.hybris.com/schema/cockpitng/action-definition.xsd">
    <name>export.forms.action</name>
    <description>Export Forms Action</description>
    <author>hybris</author>
    <version>0.1</version>
    <actionClassName>de.hybris.platform.warehousingbackoffice.actions.exportforms.ExportFormsAction</actionClassName>
    <inputType>de.hybris.platform.ordersplitting.model.ConsignmentModel</inputType>
    <iconUri>icons/icon_action_printer_default.png</iconUri>
    <iconDisabledUri>icons/icon_action_printer_disabled.png</iconDisabledUri>
    <iconHoverUri>icons/icon_action_printer_hover.png</iconHoverUri>
    <settings>
        <setting key="viewMode" default-value="iconAndText"/>
    </settings>
</action-definition>
...

Export Form Rendering

An export form is a printout of data about shipped products, including their value calculated according to custom rules provided by the price strategy. It displays the following information:

  • Date Printed: The date on which the export form was printed.
  • Order Number: The number or identifier of the order.
  • Order Date: The date on which the order was placed.
  • Ship to Address: Complete address and phone number of the destination address.
For each consignment entry on the export form list, the following information is provided:
  • Product Code: Code used to identify the packaged products.
  • Product Name: The name of the product.
  • Item Price: The price of one item.
  • Qty: The quantity of items shipped.
  • Total Price: The total price of items in the consignment entry.

The currency displayed in the header is taken from the order. No price conversion is performed.

Backoffice Configuration

The action is available from the consignment editor area in the Order Fulfillment perspective.

warehousingbackoffice-backoffice-config.xml:
...
    <context type="Consignment" merge-by="type" component="warehouseEditorAreaActions">
        <y:actions xmlns:y="http://www.hybris.com/cockpit/config/hybris">
            <y:group qualifier="common">
                <y:label>actiongroup.common</y:label>
                <y:action action-id="de.hybris.platform.warehousingbackoffice.actions.printpickslipaction" property="currentObject" />
                <y:action action-id="de.hybris.platform.warehousingbackoffice.actions.printpackaction" property="currentObject" />
                <y:action action-id="de.hybris.platform.warehousingbackoffice.actions.printshippinglabelaction" property="currentObject" />
                <y:action action-id="de.hybris.platform.warehousingbackoffice.actions.exportforms" property="currentObject"/>
                <y:action action-id="de.hybris.platform.warehousingbackoffice.actions.shipaction" property="currentObject" />
                <y:action action-id="de.hybris.platform.warehousingbackoffice.actions.confirmpickupaction" property="currentObject" />
                <y:action action-id="de.hybris.platform.warehousingbackoffice.actions.reallocateaction" property="currentObject" />
            </y:group>
        </y:actions>
    </context>
...

A WarehouseAdministrator, WarehouseManager, or WarehouseAgent can print the export form by clicking on the Export Form button.

Export Form Price Strategy

The strategy was implemented in the warehousing extension. Strategy methods define how the product price and total price are calculated for the export form.

The calculateProductPrice returns the value of item price. The calculateTotalPrice method calculates the total price per consignment entry, based on the item price value and the consignment entry state. This allows you to apply desired custom logic to both item and total price calculations.

The DefaultExportFormPriceStrategy contains the default strategy implementation, using:
  • order entry's base price as the item price.
  • item price multiplied by item quantity in the consignment entry as the total price per entry.
ExportFormPriceStrategy.java:
...
    /**
     * Calculates single product price for use in Export Form. Should not return null
     * @param consignmentEntry
     *           {@link ConsignmentEntryModel} to calculate product price for
     * @return product price calculated based on consignment entry
     */
    BigDecimal calculateProductPrice(ConsignmentEntryModel consignmentEntry);
    /**
     * Calculates total price of product for use in Export Form based on precalculated item price. Should not return
     * null.
     * @param productPrice
     *           price of single product item
     * @param consignmentEntry
     *           {@link ConsignmentEntryModel} to calculate total for, based on precalculated productPrice
     * @return total price calculated based on product price
     */
    BigDecimal calculateTotalPrice(BigDecimal productPrice, ConsignmentEntryModel consignmentEntry);
...

The following shows the Spring configuration for the Export Form Price Strategy.

warehousing-spring.xml:
...
<alias alias="exportFormPriceStrategy" name="defaultExportFormPriceStrategy"/>
<bean id="defaultExportFormPriceStrategy"
    class="de.hybris.platform.warehousing.consignmententry.strategy.impl.DefaultExportFormPriceStrategy"/>
...

Export Form Context

The context was implemented in the warehousing extension. To avoid redundant calls to price calculation methods, all prices are calculated during the context initialization and stored in the exportForm field.

ExportFormContext.java:
...
    @Override
    public void init(final ConsignmentProcessModel businessProcessModel, final DocumentPageModel documentPageModel)
    {
        super.init(businessProcessModel, documentPageModel);
        setExportForm(createExportFormContent(businessProcessModel.getConsignment()));
    }
...

Price calculation is performed according to the ExportFormPriceStrategy implementation injected into the context. In standard configuration, the DefaultExportFormPriceStrategy is used.

The following shows the Spring configuration for the export form context.

warehousing-spring.xml:
...
    <alias name="defaultExportFormContext" alias="exportFormContext" />
    <bean id="defaultExportFormContext" class="de.hybris.platform.warehousing.labels.context.ExportFormContext" parent="abstractDocumentContext" scope="prototype">
        <property name="exportFormPriceStrategy" ref="exportFormPriceStrategy" />
    </bean>
...