Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions

:
#)CashBatchPost. Copyright © 2012 tourapp.com. All rights reserved. GPL3 Open Source Software License.
  
  package com.tourapp.tour.acctrec.screen.cash;
  
  import java.util.*;
  
CashBatchPost - Post the Cash Receipts.
 
 public class CashBatchPost extends BaseArTrxPostScreen
 {
    
Default constructor.
 
     public CashBatchPost()
     {
         super();
     }
    
Constructor.

Parameters:
record The main record for this screen.
itsLocation The location of this component within the parent.
parentScreen The parent screen.
fieldConverter The field this screen field is linked to.
iDisplayFieldDesc Do I display the field desc?
properties Addition properties to pass to the screen.
 
     public CashBatchPost(Record recordScreenLocation itsLocationBasePanel parentScreenConverter fieldConverterint iDisplayFieldDescMap<String,Objectproperties)
     {
         this();
         this.init(recorditsLocationparentScreenfieldConverteriDisplayFieldDescproperties);
     }
    
Initialize class fields.
 
     public void init(Record recordScreenLocation itsLocationBasePanel parentScreenConverter fieldConverterint iDisplayFieldDescMap<String,Objectproperties)
     {
         super.init(recorditsLocationparentScreenfieldConverteriDisplayFieldDescproperties);
     }
    
Get the screen display title.
 
     public String getTitle()
     {
         return "Post the Cash Receipts";
     }
    
Override this to open the main file.

You should pass this record owner to the new main file (ie., new MyNewTable(thisRecordOwner)).

Returns:
The new record.
 
     public Record openMainRecord()
     {
         return new CashBatch(this);
     }
    
Override this to open the other files in the query.
 
     public void openOtherRecords()
     {
         super.openOtherRecords(); 
             this.addRecord(((ReferenceField)this.getMainRecord().getField(.)).getReference(), true);
         else
             new CashBatchDetail(this);
         new CashBatchDist(this);
         
         new ArControl(this);
         
         new ArTrx(this);
         
         new BankTrx(this);
         
        new TransactionType(this);
    }
    
Add all the screen listeners.
    public void addListeners()
    {
        super.addListeners();
        
        
        this.getMainRecord().addListener(new SubFileFilter(this.getScreenRecord().getField(.), .nullnullnullnull));
        
        
        CashBatchDist recCashBatchDist = (CashBatchDist)this.getRecord(.);
        recCashBatchDist.addListener(new SubFileFilter(this.getRecord(.)));
        recCashBatchDist.addListener(new SubCountHandler(this.getScreenRecord().getField(.), .falsetrue));
        
        BookingModel recBooking = (BookingModel)((ReferenceField)recCashBatchDist.getField(.)).getReferenceRecord(this);
        recCashBatchDist.getField(.).addListener(new ReadSecondaryHandler((Record)recBookingnulltruetruetrue));     // Update record
        ArTrx recArTrx = (ArTrx)this.getRecord(.);
        recBooking.addArDetail(recArTrxnullfalse);
        
        recCashBatchDetail.close();
        try   {   // Recount totals
            while (recCashBatchDetail.hasNext())
            {
                recCashBatchDetail.next();
            }
        } catch (DBException ex)    {
            ex.printStackTrace();
        }
    }
    
Add the screen fields. Override this to create (and return) the screen record for this recordowner.

Returns:
The screen record.
    public Record addScreenRecord()
    {
        return new CashBatchScreenRecord(this);
    }
    
Set up all the screen fields.
    public void setupSFields()
    {
        this.setEnabled(false);
        box.setEnabled(true);
    }
    
Get the batch detail record.
    public Record getDetailRecord()
    {
        return this.getRecord(.);
    }
    
Return the distribution detail record.

Returns:
The dist record.
    public Record getDistRecord()
    {
        return this.getRecord(.);
    }
    
Get the base trx record.

Returns:
The record.
    public BaseTrx getBaseTrx()
    {
        return (BaseTrx)this.getRecord(.);
    }
    
Is the batch header record valid?

Returns:
true if valid (if false, set the last error).
    public boolean checkValidHeader()
    {
        boolean bSuccess = super.checkValidHeader();
        if (!bSuccess)
            return bSuccess;
        BaseApplication application = (BaseApplication)this.getTask().getApplication();
        if (recBankAcct == null)
        {
            this.displayError(application.getResources(.true).getString("Invalid Bank account, can't post"));
            return false;
        }
        BaseField fldDefAccountID = this.getRecord(.).getField(.);
        if (fldDefAccountID.isNull())
        {
            this.displayError(application.getResources(.true).getString("No default account set in control file"));
            return false;
        }
        if (this.getMainRecord().getField(.).isNull())
        {
            this.displayError(application.getResources(.true).getString("You must have a transaction date, can't post"));
            return false;
        }
        {
            this.displayError(application.getResources(.true).getString("The batch doesn't balance, can't post"));
            return false;
        }
        return true;
    }
    
Update the base trx to the new status.

Returns:
true if successful.
    public boolean updateBaseTrx()
    {
        boolean bSuccess = false;
        // Now post the total deposit amount
        BaseTrx recBaseTrx = this.getBaseTrx();
        Record recCashBatch = this.getMainRecord();
        TrxStatus recTrxStatus = (TrxStatus)((ReferenceField)recBaseTrx.getField(.)).getReferenceRecord();
        try   {
        // Step 2a - Create and write the bank transaction (in BankTrx).
            recBaseTrx.addNew();
            int iTrxStatusID = recTrxStatus.getTrxStatusID(...);
            recBaseTrx.getField(.).setValue(iTrxStatusID);
            recBaseTrx.getField(.).moveFieldToThis(recTrxStatus.getField(.));
            recBaseTrx.getField(.).moveFieldToThis(recCashBatch.getField(.));
            recBaseTrx.getField(.).setValue(recCashBatch.getField(.).getValue());
            recBaseTrx.getField(.).initField(.);
            recBaseTrx.getField(.).moveFieldToThis(recCashBatch.getField(.));
            recBaseTrx.getField(.).setValue(recCashBatch.getField(.).getValue());
            recBaseTrx.getField(.).initField(.);
            recBaseTrx.getField(.).moveFieldToThis(recTrxStatus.getField(.));
            // Step 2 - Post it to the G/L
            //+recAcctDetail.getDatabase().startTrx();
            // Step 2a - Create and write the bank transaction (in BankTrx).
            bSuccess = recBaseTrx.onPostTrx();
            if (!bSuccess)
                return bSuccess;
        } catch (DBException ex) {
            ex.printStackTrace();
            return false;
        }
        return bSuccess;    // Success
    }
    
Make sure this batch detail trx is valid.

Returns:
True if batch is okay.
    public boolean checkValidDetail()
    {
        boolean bSuccess = super.checkValidDetail();
        return bSuccess;
    }
    
Setup and post this base transaction.

Parameters:
recBaseTrx The base transaction to post.
recTransactionType The transaction type for the TRX posting.
Returns:
true If successful.
    public boolean postBaseTrx(BaseTrx recBaseTrxTransactionType recTransactionType)
    {
        // Step 2b - Post the transaction side of the distribution.
        BaseField fldDrAccountID = recBankAcct.getField(.);
        Record recDetail = this.getDetailRecord();
        double dAmount = recDetail.getField(.).getValue();
        boolean bSuccess = recBaseTrx.onPostTrxDist(fldDrAccountIDdAmount.);
        return bSuccess;
    }
    
Post the distribution detail.

Parameters:
recBaseTrx The base transaction to post.
recTransactionType The transaction type for the DIST posting.
Returns:
true If successful.
    public boolean postDistTrx(BaseTrx recBaseTrxTransactionType recTransactionType)
    {
        
        Record recBatchDetail = this.getDetailRecord();
        double dLocalTotal = recBatchDetail.getField(.).getValue();
        String strComment = recBatchDetail.getField(.).toString();
        
        return this.postDistTrx(recBaseTrxdLocalTotalstrCommentfldDefAccountID);
    }
New to GrepCode? Check out our FAQ X