Cashbook-to-Cashbook transfer in Adempiere

While implementing accounting need for one of the customer the requirement was that the system shall allow transfer between to Cashbook accounts. These cashbook accounts may belong to same branch (organization) or they may belong to different branches. While the customer could have achieved this by doing two separate journal entries the inclination was to achieve this using single transaction. This article describes the customization done by Walking Tree team to achieve the desired result.

Database Change

ALTER TABLE adempiere.c_cashline ADD c_cashbook_id numeric(10,0);
ALTER TABLE adempiere.c_cashline ADD CONSTRAINT ccashbook_ccashline FOREIGN KEY (c_cashbook_id)
REFERENCES adempiere.c_cashbook (c_cashbook_id) MATCH SIMPLE

This change allows you to see the target CashBook drop down on the Cash Line tab of the Cash Journal window. Of course you need to generate database fields, tab fields, and models (I_C_CashLine and X_C_CashLine). The CashBook selected on the Cash Journal tab acts as source CashBook.

Cash Book

Code Changes

Change in
else if ( MCashLine.CASHTYPE_CashbookTransfer.equals(line.getCashType()) && !line.isGenerated()) {
// The user is completing CashBook to CashBook transfer. While one entry will be created manually, the
// entry into the account is being debited (in which money will go), will be automatically generated.
// Since the same code will be used, it is important that we don't end up calling recursive method for
// the auto generated cash journal as well.
// For account posting during the transfer following needs to be done
// CR - CashAsset of Book1 (negative amount)
// DB - CashAsset of Book2
MCash mCash = new MCash(this.getCtx(), 0, this.get_TrxName() );

mCash.setAD_Org_ID( line.getAD_Org_ID() );
mCash.setC_CashBook_ID( line.getC_CashBook_ID() );
mCash.setBeginningBalance( BigDecimal.ZERO );
mCash.setEndingBalance( line.getAmount() );
mCash.setDateAcct( getDateAcct() );
mCash.setDocAction( DocAction.ACTION_Prepare );

if (! {
m_processMsg = "Could not create target Cash Journal";
return DocAction.STATUS_Invalid;
} else {
MCashLine mCashLine = new MCashLine( this.getCtx(), 0, this.get_TrxName() );
mCashLine.setC_Cash_ID( mCash.getC_Cash_ID() );
mCashLine.setC_Currency_ID( mCash.getC_Currency_ID() );
mCashLine.setCashType( X_C_CashLine.CASHTYPE_CashbookTransfer );
mCashLine.setAmount( line.getAmount() );

if ( ! ) {
m_processMsg = "Could not create target Cash Journal Line";
return DocAction.STATUS_Invalid;

mCash.processIt( DocAction.ACTION_Complete );

Changes in
else if ( CASHTYPE_CashbookTransfer.equals(getCashType()) ) {
if ( getC_CashBook_ID() == 0 ) {

setAmount( getAmount().negate() );

Change in
/** Account Type - Cash - CashBook Transfer */
public static final int ACCTTYPE_CashBookTransfer = 25;

Check for cashbook transfer:
else if ( ( AcctType == ACCTTYPE_CashAsset ) || ( AcctType == ACCTTYPE_CashBookTransfer ) )

Change in
/** CashBook Transfer - B */
public static final String CASHTYPE_BOOK_TRANSFER = "B";

private int m_C_CashBook_ID = 0;
public int getC_CashBook_ID() {
return m_C_CashBook_ID;

public void setC_CashBook_ID(int mCCashBookID) {
m_C_CashBook_ID = mCCashBookID;

Add following line in DocLine_Cash (MCashLine line, Doc_Cash doc) constructor:
m_C_CashBook_ID = line.getC_CashBook_ID();

Change in
else if ( CashType.equals(DocLine_Cash.CASHTYPE_BOOK_TRANSFER ) ) {
fact.createLine( line,
getAccount(Doc.ACCTTYPE_CashAsset, as),
line.getAmount() );

Below screen show the accounting facts after transfer of cash between two cashbooks belonging to same organization:

If cashbook belongs to different organizations then I see two additional accounting facts
– Intercompany due to and
– Intercompany due from

Accounting facts

I hope above information helps you in taking advantage of Adempiere’s amazing power. In case you need any professional help, you can reach us by visiting our Contact Us page.

Also, we have started a poll to know your opinion regarding the best available ERP solution for the SME sector. Click here to participate in the poll. If your favorite ERP is not listed then do let us know.

Tagged with: , , , , ,
Posted in ADempiere, EagleRP
One comment on “Cashbook-to-Cashbook transfer in Adempiere
  1. Surya bhushan says:

    You have not mentioned anything about the second posting where Petty Cash Debited and Suspense Balance Credited in Fertilizer organization. This posting is mandatory to knock-off the suspense balance. As per my observation you must have another type called “Received from Cashbook” and selection of that cashbook from where this cashbook received the cash. Then this posting will happen and your suspense balance get know-off.

    Please let me know how you achieved this posting in the second posting print shot.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

We Have Moved Our Blog!

We have moved our blog to our company site. Check out for all latest blogs.

Sencha Select Partner Sencha Training Partner
Xamarin Authorized Partner
Recent Publication
%d bloggers like this: