BLOG

NEXT STEPS

Posts Tagged ‘Jacopo Cappellato’

OFBiz Tutorial: Charts of Accounts

Wednesday, February 9th, 2011

Ofbiz-tutorial-accounting-charts

A sometime misunderstood concept in OFBiz accounting is the account class of an account; this OFBiz Tutorial will provide quick notes to avoid errors.

During the setup of a Chart of Accounts in OFBiz, it is important to assign the proper account class to each of the accounts; in fact the account class determines:

1) if the account carries a debit or credit balance
2) the financial report in which the account is included.

The complete list of classes that you can assign to an account is described by the account class tree in OFBiz:

DEBIT

|___> NON_POSTING
|
|___> CONTRA_REVENUE
|
|___> ASSET
|         |_________> LONGTERM_ASSET
|         |
|         |_________> CURRENT_ASSET
|                                 |____> CASH_EQUIVALENT
|                                 |
|                                 |____> INVENTORY_ASSET
|
|___> DISTRIBUTION
|               |___> RETURN_OF_CAPITAL
|               |
|               |___> DIVIDEND
|
|___> EXPENSE
|_________> CASH_EXPENSE
|                       |____> INTEREST_EXPENSE
|                       |
|                       |____> COGS_EXPENSE
|                       |
|                       |____> SGA_EXPENSE
|
|_________> NON_CASH_EXPENSE
|____> DEPRECIATION
|
|____> AMORTIZATION
|
|____> INVENTORY_ADJUST

CREDIT

|___> CONTRA_ASSET
|              |___> ACCUM_DEPRECIATION
|              |
|              |___> ACCUM_AMORTIZATION
|
|___> LIABILITY
|         |_________> CURRENT_LIABILITY
|         |
|         |_________> LONGTERM_LIABILITY
|
|___> EQUITY
|         |_________> OWNERS_EQUITY
|         |
|         |_________> RETAINED_EARNINGS
|
|___> REVENUE
|
|___> INCOME
|________> CASH_INCOME
|
|________> NON_CASH_INCOME

RESOURCE

Asset (longterm, current, cash, inventory), expense (cash, interest, cost of goods sold, sales general administrative, non cash, depreciation, amortization, inventory adjustment) and distribution (dividend, return of capital) accounts each follow the same set of debit/credit rules. Debits increase these accounts and credits decrease these accounts. All these accounts carry a debit balance except contra revenue.

Liability (current, longterm), revenue and equity (retained earnings, owners equity) accounts follow opposite rules: credits increase liabilities, revenues, and equity, while debits decrease these accounts. All these accounts carry a credit balance except contra asset.

All the accounts belonging to the following classes are included in the Balance Sheet:

* all asset and contra asset classes
* all liability classes
* all equity classes

All the accounts belonging to the following classes are included in the Income Statement:

* all revenue and contra revenue classes
* all expense classes
* all income classes

All the accounts belonging to the cash equivalent class are included in the Cash Flow Statement.

- Jacopo

Jacopo Cappellato is VP of Technology at HotWax Media and has been involved with the OFBiz project since 2003. He is an OFBiz Project Committer and a member of both the OFBiz Project Management Committee and the Apache Software Foundation.
Jacopo Cappellato - OFBiz Developer - OFBiz Expert

OFBiz Tutorial – Order Entry and Ship Groups

Friday, April 16th, 2010

A robust enterprise eCommerce system needs to handle manual order entries that are sometimes complex. In this OFBiz Tutorial we will go over how this works in OFBiz.

Example:

An order clerk has to place a sales order on behalf of a customer (order received by fax, by mail, by phone etc..); the order contains several items and the customer asks that the order is shipped with two (or more) shipments with different delivery dates and/or to different postal addresses and/or with different shipment methods or shipping instructions; the customer clearly specify the items to be assigned to each shipment.

How can you do this in OFBiz?

The order clerk can easily place an order like this by defining multiple ship groups: ship groups represent a way to group into different sets the items of an order and each ship group has its own shipping options, delivery dates, shipment address. Ship groups are created during order checkout.

For example, let’s suppose that the order clerk has to place an order for 10 units of the product with id WG-1111 and 5 units of the product with id GZ-1000.

The customer needs immediately 5 units of WG-1111 and prefers to pay for the quickest shipment method available, while all the 5 units of GZ-1000 and the remaining 5 units of WG-1111 (together with some promotional items) can wait and so they will be shipped using a cheaper and slower shipping method later.

Let’s do this step by step.

The first part is easy because it is exactly like placing a standard order:

go to the order entry screen and enter the customer id

sg1

add to the cart 10 units of WG-1111 and 5 units of GZ-1000 (don’t worry about the ship groups now, you will do this at checkout); if you are running the standard OFBiz demo you will also get some promotional items

sg2

now we are ready for the checkout and we click on the “Finalize Order” button;

sg3

the first checkout screen let us select the shipment address and this is where we add the second ship group that we need by clicking on the “New Ship Group” button:

sg4

the page will reload with two ship group sections; set the shipment address for each of them and click on the “Continue” button

sg5

in the next screen you will have the ability to move the items from one ship group to the other; initially all the items will be in the first ship group and the second one will be empty

sg6

using the drop down boxes and the quantity field near each item you can move the items to the second ship group

sg7

now click on the “Continue” button, the next screen will let you set the shipment method and options for each ship group; just make sure you select the proper method for each group;

sg8

sg9

The next steps are exactly the same as a standard order, so complete the checkout and confirm the order.

The exercise is now complete!

If you visit the order detail screen you will notice that there are now two boxes for the shipment information (one for each group):

sg10

You can now fulfill the order as usual and the only difference is that you will create two different shipments (one for each ship group): when the shipment is created from the ship group, OFBiz will create a shipment containing the items assigned to that ship group only.

- Jacopo

Jacopo Cappellato is VP of Technology at HotWax Media and has been involved with the OFBiz project since 2003. He is an OFBiz Project Committer and a member of both the OFBiz Project Management Committee and the Apache Software Foundation.Jacopo Cappellato - OFBiz Developer - OFBiz Expert

OFBiz Tutorial – Implementing a Product PDF export

Tuesday, February 23rd, 2010

In our last post of the tutorial series OFBiz Tutorial – Implementing a Product CSV export we have learned how to quickly implement a CSV export of a list of rows.

In this post we will perform similar steps in order to create a PDF version of the “Product List” screen.
PDF exports are supported out of the box by the OFBiz widgets.
In this excercise we will:

  1. add to the product list screen a link, close to the CSV export link we have created in our last post, that will generate the PDF export
  2. add to the controller.xml file the request and view entries for the new PDF export screen
  3. implement the new screen definition for the PDF export screen; the screen will reuse the same form used by html screen but with a different decorator (more suited for PDF output)

Adding a link element

We have already learned how to create a link in a screen. We add it after the “CSV Export” link:

1
2
3
4
<container style="button-bar">
    <link target="ProductListExport" text="CSV Export" style="buttontext"/>
    <link target="ProductListPDF" text="PDF Export" style="buttontext"/>
</container>
  • the new link is inside of the same “container” element of the “CSV Export” link; we want the two links rendered close to each other
  • the link element is defined in the same way we have defined the other link

Controller entries for a PDF export screen

1
2
3
4
5
6
<request-map uri="ProductListPDF">  
    <security https="true" auth="true"/> 
    <response name="success" type="view" value="ProductListPDFScreen"/>
</request-map> 
... 
<view-map name="ProductListPDFScreen" type="screenfop" content-type="application/pdf" page="component://hwm/widget/HwmScreens.xml#ProductListPDF"/>

The entries are very similar to the ones we have implemented in a previous post for the product list screen. There are just a couple of things to notice:

  • as usual, the request-map uri must match with the target of the link element in the screen (”ProductListPDF”)
  • in the view-map, the type is now “screenfop” (instead of “screen”) because we have to invoke the “fop screen renderer” to generate a PDF output
  • in the view-map we have also set the content-type to “application/pdf” as useful metadata information for the browser

Screen definition for PDF export screens

There isn’t anything special in a screen definition for a PDF export; the screen is defined in the same way of a normal screen, except for a couple of details:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<screen name="ProductListPDF">  
    <section>  
        <actions>  
            <set field="viewSize" value="10000"/>  
            <set field="pageLayoutName" value="main-page-landscape"/>  
            <entity-condition entity-name="Product" list="products">  
                <order-by field-name="productId"/>  
            </entity-condition>  
        </actions>  
        <widgets>  
            <decorator-screen name="FoReportDecorator" location="component://common/widget/CommonScreens.xml">  
                <decorator-section name="body">  
                    <container>  
                        <label text="Finished Products" style="h1"/>  
                    </container>  
                    <include-form name="ListProducts" location="component://hwm/widget/HwmForms.xml"/>  
                </decorator-section>  
            </decorator-screen>  
        </widgets>  
    </section> 
</screen>
  • the screen definition is mostly identical to the “product list screen” except for the decorator element: we are now using the FoReportDecorator that is one of the screen decorators available out of the box in OFBiz (it renders simple PDF reports with a page-of-pages footer, logo etc.)
  • in particular, the entity-condition element is the same and it is used to select the list of products for the export
  • the form that is included is the same of the “product list screen”: we will not have to re-implement it because the widget renderer will take care of rendering it into the proper output (PDF or CSV or html)
  • as we already did for the CSV screen, the “set” field operation, where we set “viewSize” to “10000″, is an easy way to “disable” pagination; we actually define the top limit of our product export to 10000 records here, but of course we can use a different value
  • there is an additional set operation here (for “pageLayoutName”), to set the PDF layout to landscape

Conclusion

The exercise is complete and we can test the product PDF by clicking the “PDF Export” link (there is no need to restart OFBiz).

Implementing the PDF report ended up being very similar to implementing the CSV export (or HTML screen): in OFBiz the same patterns, tools and languages can be reused to dramatically improve productivity.

- Jacopo

Jacopo Cappellato is VP of Technology at HotWax Media and has been involved with the OFBiz project since 2003. He is an OFBiz Project Committer and a member of both the OFBiz Project Management Committee and the Apache Software Foundation.Jacopo Cappellato - OFBiz Developer - OFBiz Expert

OFBiz Tutorial – Implementing a Product CSV export

Thursday, February 11th, 2010

At the end of the last post in our OFBiz tutorial series we have completed the final version of a simple product list screen completely based on OFBiz widgets.

Here is the screen definition:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<screen name="ProductList">
    <section>
        <actions>
            <entity-condition entity-name="Product" list="products">
                <order-by field-name="productId"/>
            </entity-condition>
        </actions>
        <widgets>
            <decorator-screen name="HwmCommonDecorator" location="component://hwm/widget/CommonScreens.xml">
                <decorator-section name="body">
                    <label text="Finished Products" style="h1"/>
                    <include-form name="ListProducts" location="component://hwm/widget/HwmForms.xml"/>
                </decorator-section>
            </decorator-screen>
        </widgets>
    </section>
</screen>

and the form definition:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<form name="ListProducts" type="list" list-name="products">
    <row-actions>
        <service service-name="getProductInventoryAvailable" result-map="inventoryAvailableMap">
            <field-map field-name="productId" from-field="productId"/>
        </service>
    </row-actions>
    <field name="productId" widget-style="buttontext">
        <hyperlink target="/catalog/control/EditProduct" description="${productId}" target-type="inter-app">
            <parameter param-name="productId"/>
        </hyperlink>
    </field>
    <field name="productTypeId" title="Product Type">
        <display-entity entity-name="ProductType"/>
    </field>
    <field name="internalName"><display/></field>
    <field name="description"><display/></field>
    <field name="qoh" entry-name="inventoryAvailableMap.quantityOnHandTotal">
        <display/>
    </field>
    <field name="atp" entry-name="inventoryAvailableMap.availableToPromiseTotal">
        <display/>
    </field>
</form>

and the end result is this:
The final result

Our next goal, the subject of this post, is to provide a CSV (Comma Separated Value) export of the same list of products; we will do this by reusing as much as possible the artifacts already implemented for the html screen.

A CSV file is a widely used simple format for the exchange of data between different software systems; for example, Microsoft Excel can easily import a CSV file into a spreadsheet. From a technical point of view a CSV file is a plain text file where each line represents a row from a list of homogeneous data, and the fields are separated by the comma character.
CSV exports are supported out of the box by the OFBiz widgets.
In this excercise we will:

  1. add to the product list screen a link that will generate the CSV export
  2. add to the controller.xml file the request and view entries for the new CSV export screen
  3. implement the new screen definition for the CSV export screen; the screen will reuse the same form used by html screen

Adding a link element

We will add a link from the product list screen to invoke the product CSV export screen. The definition of a link element in a screen is easy:

1
2
3
<container style="button-bar">
    <link target="ProductListExport" text="CSV Export" style="buttontext"/>
</container>
  • the “container” element is not mandatory but we have used it in order to create an invisible region of the screen for the links (we will add a new link in our next post, for PDF exports)
  • the link element is defined in the same way we have defined the link field in the product list form in our last post

Controller entries for a CSV export screen

1
2
3
4
5
6
<request-map uri="ProductListExport">
    <security https="true" auth="true"/>
    <response name="success" type="view" value="ProductListExportScreen"/>
</request-map>
...
<view-map name="ProductListExportScreen" type="screencsv" content-type="text/csv" page="component://hwm/widget/HwmScreens.xml#ProductListExport"/>

The entries are very similar to the ones we have implemented in a previous post for the product list screen. There are just a couple of things to notice:

  • the request-map uri must match with the target of the link element in the screen (”ProductListExport”)
  • in the view-map, the type is now “screencsv” (instead of “screen”) because we have to invoke the “csv screen renderer”
  • in the view-map we have also set the content-type to “text/csv” as useful metadata information for the browser

Screen definition for CSV export screens

There isn’t anything special in a screen definition for a CSV export; the screen is defined in the same way of a normal screen, except for a couple of details:

1
2
3
4
5
6
7
8
9
10
11
12
13
<screen name="ProductListExport">
    <section>
        <actions>
            <set field="viewSize" value="10000"/>
            <entity-condition entity-name="Product" list="products">
                <order-by field-name="productId"/>
            </entity-condition>
        </actions>
        <widgets>
            <include-form name="ListProducts" location="component://hwm/widget/HwmForms.xml"/>
        </widgets>
    </section>
</screen>
  • the screen definition is mostly identical to the “product list screen”
  • in particular, the entity-condition element is the same and it is used to select the list of products for the export
  • the form that is included is the same of the “product list screen”: we will not have to re-implement it because the widget renderer will take care of rendering it into the proper output (CSV or html)
  • the “set” field operation, where we set “viewSize” to “10000″, is an easy way to “disable” pagination; we actually define the top limit of our product export to 10000 records here, but of course we can use a different value

Conclusion

The exercise is complete and we can test the product export by clicking the “CSV Export” link (there is no need to restart OFBiz).

Implementing the CSV export ended up being a trivial task because, thanks to the OFBiz widgets, we have reused most of the work we did for the html screen.

In the next tutorial post we will perform similar steps to implement the PDF version of the same screen.

- Jacopo

Jacopo Cappellato is VP of Technology at HotWax Media and has been involved with the OFBiz project since 2003. He is an OFBiz Project Committer and a member of both the OFBiz Project Management Committee and the Apache Software Foundation.

Jacopo Cappellato - OFBiz Developer - OFBiz Expert

OFBiz Tutorial – Enhancing the Product list screen

Wednesday, January 27th, 2010

As you become an expert OFBiz developer, you will certainly need to know all about the OFBiz Form Widget! Here at HotWax Media we use the Form Widget regularly, whether as part of a front end e-commerce shopping cart or as part of a back-end ERP administration screen (for example OFBiz screens to handle order management, warehouse management, and inventory management as part of your integrated online retail OFBiz system).

In this post we will explore some of the features offered by the form widget, the layer in the OFBiz framework that enables the implementation of list based user interface elements. We will do this by continuing the exercise we started in our earlier “OFBiz Tutorial” posts. Specifically, this exercise is based on the “hwm” component we have setup in OFBiz Tutorial – Custom Components In OFBiz and on the custom “product list” screen we have built in OFBiz Tutorial – Building A Simple Product List Screen Here is the form widget definition for the list of products that we have created in the last post:

1
2
3
<form name="ListProducts" type="list" list-name="products">
    <auto-fields-entity entity-name="Product" default-field-type="display"/> 
</form>

The auto-fields element was all we needed to retrieve the fields defined in the “Product” entity (entity-name) and render them as “display” fields (default-field-type). The goal of this post is to fine tune the list definition, in order to render only a subset of the fields and also to render them in a richer way; specifically:

  • we want to render the “product id” field as a link to the “product detail screen” in the OFBiz “Catalog” application

  • instead of displaying the id in the “product type id” field, we want to display the description associated to that id
  • we are only interested in the following fields from the “Product” entity: “product id” (as a link), “product type id” (as a description), “internal name”, “description”
  • we want to add two computed fields containing the “quantity on hand” and “available to promise” quantity of the items in inventory

Defining links

In order to transform the “product id” field into a link, we will simply add the field definition right after the “auto-fields” element; in this way, the explicit field type (link) will override the field type defined by the “default-field-type” attribute; here is the updated field definition:

1
2
3
4
5
6
7
8
<form name="ListProducts" type="list" list-name="products">
    <auto-fields-entity entity-name="Product" default-field-type="display"/> 
    <field name="productId" widget-style="buttontext">
        <hyperlink target="/catalog/control/EditProduct" target-type="inter-app" description="${productId}"> 
            <parameter param-name="productId"/> 
        </hyperlink> 
    </field> 
</form>

When you refresh the screen you will immediately see the new form definition in action. Here are some details about the new field definition:

  • the attribute widget-style=”buttontext” sets the style for the field by using one of the many styles available in OFBiz (and defined in a shared CSS stylesheet; you can of course define and use your own styles)

  • the “description” attribute in the “hyperlink” element defines the text rendered as hyperlink; we have used the ${} notation to insert the “productId” variable
  • the “target” attribute in the “hyperlink” element defines the url for the hyperlink; this url is defined in the controller.xml file of the corresponding “catalog” web application (defined in the applications/product component); since the link, from the “hwm” application, points to a different application we use the target-type=”inter-app” attribute
  • the “description” attribute in the “hyperlink” element defines the text rendered as hyperlink; we have used the ${} notation to insert there the “productId” variable
  • the “parameter” element is needed because the EditProduct url requires that a productId parameter is passed to it

Performing lookups to different entities

Instead of displaying the id for the product type, as stored in the Product.productTypeId field, we prefer to display the description associated to that type; for example, instead of “FINISHED_GOOD” we want “Finished Good”. The description is not stored in the Product entity, it is instead in the ProductType entity: we have to use the Product.productTypeId field to perform a table lookup in the ProductType entity (Product.productTypeId = ProductType.productTypeId), and use the content of the ProductType.description field when the form is rendered. The form widget has built-in support for this, the “display-entity” element:

1
2
3
<field name="productTypeId" title="Product Type">
    <display-entity entity-name="ProductType"/>
</field>

When you refresh the screen you will immediately see the new form definition in action. Here are some details about the new field definition:

  • the “entity-name” defines the entity to lookup

  • this is all we have to specify here, because, if not specified, OFBiz assumes that the name of the field (name=”productTypeId”) is the same in both entities and assumes that a “description” field is available in the referenced entity; if the id and description fields in the referenced entity have different names, you can specify them by adding the “description” and “key-field-name” attributes to the “display-entity” element

Displaying just the fields we need

We now realize that we don’t need most of the fields of the “Product” entity; for this reason it is easier to remove the “auto-fields” element and simply add the field definition for the two more fields we want to display (”internal name” and “description”). Here is the new form definition:

1
2
3
4
5
6
7
8
9
10
11
12
<form name="ListProducts" type="list" list-name="products">
    <field name="productId" widget-style="buttontext"> 
        <hyperlink target="/catalog/control/EditProduct" description="${productId}" target-type="inter-app">
            <parameter param-name="productId"/>
        </hyperlink>
    </field>
    <field name="productTypeId" title="Product Type">
        <display-entity entity-name="ProductType"/>
    </field> 
    <field name="internalName"><display/></field>
    <field name="description"><display/></field>
</form>

Displaying fields computed by services

This is the most interesting part of this exercise. We want to add two additional fields to the list: one with the count of units physically in the warehouse for the product, and one with the units available in warehouse for sales (i.e. units not reserved by sales orders). This information is not stored in the Product or other entities, and computing the units is not an easy task, because, in order to enable multi warehouse support, material tracking and quality control, the OFBiz data model for inventory is rather complex. However there is a standard service (a reusable business logic) specifically designed to count inventory: the “getProductInventoryAvailable” service. In its simplest form the service takes as input a productId and returns as output a map containing two fields, “quantityOnHandTotal” and “availableToPromiseTotal”; this is exactly what we need. But we have to call this service for each record in the list, get the result from the service and use it to populate the two new columns. Again, the form widget assists us with built-in support for service calls, using the “row-actions” and “service” elements:

1
2
3
4
5
6
7
8
9
 
<form name="ListProducts" type="list" list-name="products">
    <row-actions> 
        <service service-name="getProductInventoryAvailable" result-map="inventoryAvailableMap">
            <field-map field-name="productId" from-field="productId"/>
        </service>
    </row-actions> 
... 
</form>
  • all the actions inside the “row-actions” section are executed before each row is rendered; this tag is similar to the “actions” tag that we have used in a previous post, with the only difference that “actions” is executed once before the list is rendered, while “row-actions” is executed before each and every row in the list; a form definition can also contain both action elements
  • the “service” action is a convenient way to invoke a service: the service name is specified with the “service-name” attribute, the “field-map” elements are used to pass the input parameters to the service, the “result-map” attribute defines the name of the output map

We can now add the two new computed fields in the following way:

1
2
3
4
5
6
<field name="qoh" entry-name="inventoryAvailableMap.quantityOnHandTotal"> 
    <display/>
</field> 
<field name="atp" entry-name="inventoryAvailableMap.availableToPromiseTotal">
    <display/>
</field>

the “entry-name” attribute is used to explicitly specify the source of the content: the service result map that we have named “inventoryAvailableMap”, and the “quantityOnHandTotal” and “availableToPromiseTotal” fields.

Conclusion

Here is the final result of our programming efforts:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<form name="ListProducts" type="list" list-name="products">
    <row-actions>
        <service service-name="getProductInventoryAvailable" result-map="inventoryAvailableMap">
            <field-map field-name="productId" from-field="productId"/>
        </service>
    </row-actions>
    <field name="productId" widget-style="buttontext">
        <hyperlink target="/catalog/control/EditProduct" description="${productId}" target-type="inter-app">
            <parameter param-name="productId"/>
        </hyperlink>
    </field>
    <field name="productTypeId" title="Product Type">
        <display-entity entity-name="ProductType"/>
    </field>
    <field name="internalName"><display/></field>
    <field name="description"><display/></field>
    <field name="qoh" entry-name="inventoryAvailableMap.quantityOnHandTotal">
        <display/>
    </field>
    <field name="atp" entry-name="inventoryAvailableMap.availableToPromiseTotal">
        <display/>
    </field>
</form>

and here is how the list is rendered:

The final result

Our form is now completed and in the next post we will reuse it to build a CSV (Comma Separated Value) export.

- Jacopo

Jacopo Cappellato is VP of Technology at HotWax Media and has been involved with the OFBiz project since 2003. He is an OFBiz Project Committer and a member of both the OFBiz Project Management Committee and the Apache Software Foundation.

Jacopo Cappellato - OFBiz Developer - OFBiz Expert