Ecosoft/Customization for Bicycle Manufacturer Case Study

From ADempiere
Revision as of 09:47, 21 September 2010 by Kittiu (Talk) (Deployment)

Jump to: navigation, search
This Wiki is read-only for reference purposes to avoid broken links.

This page is under construction --Kittiu 16:18, 20 September 2010 (UTC)

Overview

This page contain specific customization made for Bicycle Manufacturer Case Study. All customizations are made without touching the core application, using customization.jar techinque

Source code (compiled to customization.jar) of this project will be updated to @ Bicycle SVN

Enhancement Detail

Enable Print & Print Preview Buttons With specific Logic

Background

As of AD-360LTS, the Print and Print Preview Button is still not capable of enable/disable based on Document Status or other conditions, but only based on 1) report existence for that document type and 2) whether user has right to that report.

In our project, we have the need to prevent Document Forms (i.e., sales order, invoice, receipt) from being printed out when the document is not yet completed (or closed or voided) (DocStatus = CO, CL). There are some other alternative without touching the code, such as, have the status printout in big letters, so that people can spot it by their eye. But this is rejected by the client.

Requirement Summary

  • Use System Configurator window to control whether to use this feature.
  • Print and Print Preview button will be enabled only when the condition set is met. For example, we might want print buttons to enable only when document status is Complete/Closed/Voided, but except MM Shipment and AR Receipt Form that will be enabled in all DocStatus.

Deployment

1) org.compiere.model.GridTab.java
  • Modify isPrinted() function to also check for the ENABLE_PRINT_BUTTON_WITH_LOGIC’s logic
	public boolean isPrinted()
	{
		// Start of Modification - Enable Print Buttons with some logics
		/* 
		 * return m_vo.AD_Process_ID != 0; 
		 */
		if (m_vo.AD_Process_ID == 0) {
			return false;
		} 
		else { // Check if Status is on the Enable List
			String docstatuslist = MSysConfig.getValue("ENABLE_PRINT_BUTTON_WITH_LOGIC", null, Env.getAD_Client_ID(m_vo.ctx), Env.getAD_Org_ID(m_vo.ctx));
			if (docstatuslist != null && docstatuslist.toString().length() > 0)
				return Evaluator.evaluateLogic(this, docstatuslist);
			else // No logic defined, back to normal
				return true;
		}
		// End of Modification - Enable Print Buttons with some logics
	}	//	isPrinted
2) org.compiere.apps.APanel.java
  • Modify getTitle() function add 2 lines to also set enable the button,
    • aPrint.setEnabled(m_curTab.isPrinted());
    • aPrintPreview.setEnabled(m_curTab.isPrinted());
	public String getTitle()
	{
		// Start of Modification (add) - Enable Print Buttons with some logics
		aPrint.setEnabled(m_curTab.isPrinted());
		aPrintPreview.setEnabled(m_curTab.isPrinted());
		// End of Modification - Enable Print Buttons with some logics
3) Add new record in System Configurator window
  • Name: ENABLE_PRINT_BUTTON_WITH_LOGIC
  • Search Key: @C_DocType_ID@=120 | @C_DocType_ID@=119 | @DocStatus@='CO' | @DocStatus@='CL' | @DocStatus@='VO'
  • Note: 120, 119 is the c_doctype_id, many change from system to system. Check Document Type window for the current id.

Sysconfig enable print.jpg

Remarks:

  • Discussion about this feature in forum [1]
  • In tracker, but not trunkable, as there is another alternative using rule script (applicable but not same result) [2]

Simple One Time Business Partner Credit Approval

Background

Given a Business Partner with Credit Status = Credit Watch. In the existing functionality,

  • If user creates a Sales Order (SO) for this Business Partner with Sales Amount more than the credit available (remaining),
  • He/she will not be able to complete the document. Clicking on Complete button will give warning message Credit On Hold… and Document Status will be changed to Invalid

As per existing functionality, the supervisor / admin will have to login and make change to Credit Status of this BP in Business Partner window to “Credit OK” or to increase the Credit Limit amount, and then supervisee will be able to complete document.

Currently, there is no built-in way to do one time approval in ADempiere.

This enhancement is to create a simple way (by select a CheckBox) for Supervisor of the SO creator to review and if everything is ok, make approval directly to this specific SO by ticking a CheckBox. And as the checkbox is ticked, the approval process will be ignored.

Remarks: At first, we are looking at using standard Workflow, but eventually found some difficulties,

  • Doc Process WF: This type of workflow is not even fired yet, as AD already stop it when check on Credit Limit.
  • Doc Value WF: This type of workflow will always send message to the Invoker (which is the user himself, no use). There is no way to specify the target approver.
  • This enhancement is not submitted as FR, as it is quite specific to this customer

Requirement Summary

Following is the TO-BE process for SO Credit Approval.

  • User creates SO (Sales Order), select BP (Business Partner) and add SO Lines with the total amount exceed Credit Available for this BP.
  • User clicks Complete Button to try to complete the document. The system will not allow and give warning message. DocStaus changes to Invalid. Without changing of the amount of SO lines, he/she will not able to continue.
  • User will notify his/her supervisor (manually) to approve the underline SO number.
  • Supervisor, will login to ADempiere as normal, open up the problem SO number, review and make decision.
    • If Approve,
      • Supervisor will click on “Credit Approved?” checkbox at the bottom of page and Save this document.
      • Supervisor will either notify his/her supervisee to go back and complete it, or he/she will complete by him/herself.
      • With the “Credit Approved?” checkbox checked, ADempiere should not give any warning.
      • End of the completion process.
    • If not Approve,
      • Supervisor simply does not do anything, and either go back to his/her to void it. Or he/she could void it by him/herself.
      • Supervisor simply does not do anything, and either
        • Keep it as ‘Invalid’ status and approve it when BP settles payment and their credit is available.
        • Or void it by him/herself or even go back to his/her supervisee to do it.

Note:

  • Since we do not use the Workflow to track, but use a simple Credit Approved CheckBox. Do make sure that,

CreditApprovedCheckbox.jpg

  • This checkbox is visible only when the document status is Invalid
  • This checkbox should be Editable only for the specified supervisor but show as Read Only for other users at all time.
  • When SO document is copied as new SO, this checkbox will always be unchecked (although the original is checked)
  • Even this SO is already approved, but if user change Business Partner or the Line Amount (so the credit available is changed), this checkbox should be cleared.

Deployment

1) Use Application Dictionary to setup proper UI
  • Table and column widnow --> IsCreditApproved column in table C_Order set to editable.
update ad_column set isupdateable = 'Y' where ad_column_id = 2176;
  • Window Tab & Field window --> add Credit Approved field at the bottom of window.
update ad_field
set seqno = 540, issameline = 'Y', isdisplayed = 'Y', displaylogic = '@OrderType@=''SO''&@DocStatus@=''IN'''
where ad_field_id = 1088;
  • Use Table and Column window and set Readonly logic for Credit Approved field, Readonly for end users, and Editable for approving users.
update ad_column 
set readonlylogic = '@#AD_User_Name@!''nantachai'' & @#AD_User_Name@!''SuperUser''' 
where ad_column_id = 2176;
2) Setup Rules Scripts to ensure that if user change BP or total amount, Credit Approved will be unchecked
  • Rule: Reset_IsCreditApproved
import org.compiere.util.DB;
String sql = "update c_order set iscreditapproved = 'N' where c_order_id = "+ A_Tab.getValue("C_Order_ID");
int no = DB.executeUpdate(sql);
result = "";

  • Table and Column window --> Assign this rule to
    • C_Order.C_BPartner_ID: @script:beanshell:Reset_IsCreditApproved
    • C_OrderLine.LineNetAmt: @script:beanshell:Reset_IsCreditApproved
3) org.compiere.model.MOrder.java
  • Modify method prepareIt() so that, if IsCreditApproved field is ‘Y’, then by pass the credit checking.
// -- if (MBPartner.SOCREDITSTATUS_CreditHold.equals(bp.getSOCreditStatus(grandTotal)))
if (MBPartner.SOCREDITSTATUS_CreditHold.equals(bp.getSOCreditStatus(grandTotal)) && this.isCreditApproved() == false)

DocAction to show only Prepare when DocStatus = Draft

Background

Each Document Type, there is a certain list of DocAction defined in ADempiere. Although we can use Role Security / Document Action to control list of action based on role, we can't restrict DocAction based on DocStatus. In our case, when document status is "Prepare" we don't want want end user to complete it immediately (double check routine).

Requirement Summary

For Order Window

  • When DocStatus = “Draft”
    • Click on DocAction button
    • Show only “Prepare” action
  • When DocStatus != “Draft”
    • Click on DocAction button
    • Show more actions, i.e., Prepare, Complete, Close, Void

Deployment

1) org.compiere.model.MOrder.java
  • Implement DocOption interface
public class MOrder extends X_C_Order implements DocAction, DocOptions
{
  • Add customizeValidActions() function to overwrite the existing list of action.
    /**
     * Customize Valid Actions
     * @param docStatus
     * @param processing
     * @param orderType
     * @param isSOTrx
     * @param AD_Table_ID
     * @param docAction
     * @param options
     * @return Number of valid options
     */
    public int customizeValidActions (String docStatus, Object processing, 
                    String orderType, String isSOTrx, int AD_Table_ID, String[] docAction, String[] options, int index) {
    	
    	// If status = Drafted, only show "Prepare" in the list
    	if (docStatus.equals(DocumentEngine.STATUS_Drafted)) {
    		// 1. Remove all
    		for (int i = 0; i < options.length; i++) {
    			options[i] = null;
    		}
    		// 2. Add Prepare
    		options[0] = DocumentEngine.ACTION_Prepare;
    		index = 1;
    	}
    	
    	return index;
    }

2) For Order windows, make sure default is set to "Prepare"