Developing Plug-Ins - ProductPricing

From iDempiere en

This tutorial is brought to you by Diego Ruiz from BX Service GmbH (www.bx-service.com). If you have questions, criticism or improvement suggestions, feel free to visit me (Diego.ruiz).

Goal of this tutorial

The goal of this turorial is to show you how you can exten Product Pricing in your own plug-in. To read more about changing product pricing click here.

Prerequisites

Before you start developing plug-ins, you should take a look at Developing Plug-Ins without affecting trunk and Get your Plug-In started to get a good starting point.

The workflow

Create a ProductPricingFactory

Create two classes. One for the Factory and one for the actual ProductPricing. We name it MyProductPricingFactory and MyProductPricing. The class in charge to define the rules to calculate the product pricing must extend the AbstractProductPricing class.

PluginPricing1.png

Now to the interesting part. Let your ProductPricingFactory implement the IProductPricingFactory interface and the necessary newProductPricingInstance() method. Here you check yourself for the AD_Client_ID and decide if and which ProductPricing class you want to provide. If you return null the system will look into the other defined factories. Here we check for any client that is not a default client (Garden and System):

PluginPricing2.png

The next step is to add a component definition to your plug-in. Click on New>New>Others and select Component Definition from the list:

Plugincallout11.png

You should create a new directory named OSGI-INF in your project root. This is by OSGi conventions the place for component definitions. All your definitions should go there as *.xml files.

Click on next and chose a name of your choice. Make sure the name is unique. Also click on browse and select your ProductPricingFactory class.

Open the component.xml and switch to the service tab. Add org.adempiere.base.IProductPricingFactory to the Provides Services section.

Check the MANIFEST.MF tab of your manifest file and look for the line which starts with "Service-Component: ..." and make sure the correct path to you xml is inserted here.

Before exporting a bundle jar file you have to be sure that your component definition xml in OSGI-INF file is exported into the jar file. Open the build.properties file and look whether all your definitions are checked in the "Binary Build" list.

Cookies help us deliver our services. By using our services, you agree to our use of cookies.