Search in sources :

Example 41 with GLCodeEntity

use of org.mifos.accounts.financial.business.GLCodeEntity in project head by mifos.

the class SavingsCloseTest method setupChartOfAccountsAndFinancialTransactions.

@BeforeClass
public static void setupChartOfAccountsAndFinancialTransactions() {
    defaultCurrency = TestUtils.RUPEE;
    Money.setDefaultCurrency(defaultCurrency);
    Short glcodeId = Short.valueOf("1");
    String glcode = "123456";
    GLCodeEntity glCodeEntity = new GLCodeEntity(glcodeId, glcode);
    COABO coabo = new COABO("testAccountName", glCodeEntity);
    ChartOfAccountsCache chartOfAccountsCache = new ChartOfAccountsCache();
    chartOfAccountsCache.clear();
    chartOfAccountsCache.add(coabo);
    Map<FinancialActionConstants, String> actionToCreditAccount = new HashMap<FinancialActionConstants, String>();
    actionToCreditAccount.put(FinancialActionConstants.SAVINGS_INTERESTPOSTING, glcode);
    actionToCreditAccount.put(FinancialActionConstants.MANDATORYDEPOSIT, glcode);
    actionToCreditAccount.put(FinancialActionConstants.MANDATORYWITHDRAWAL, glcode);
    actionToCreditAccount.put(FinancialActionConstants.MANDATORYDEPOSIT_ADJUSTMENT, glcode);
    actionToCreditAccount.put(FinancialActionConstants.MANDATORYWITHDRAWAL_ADJUSTMENT, glcode);
    actionToCreditAccount.put(FinancialActionConstants.ROUNDING, glcode);
    FinancialRules.getInstance().setActionToCreditAccount(actionToCreditAccount);
    Map<FinancialActionConstants, String> actionToDebitAccount = new HashMap<FinancialActionConstants, String>();
    actionToDebitAccount.put(FinancialActionConstants.SAVINGS_INTERESTPOSTING, glcode);
    actionToDebitAccount.put(FinancialActionConstants.MANDATORYDEPOSIT, glcode);
    actionToDebitAccount.put(FinancialActionConstants.MANDATORYWITHDRAWAL, glcode);
    actionToDebitAccount.put(FinancialActionConstants.MANDATORYDEPOSIT_ADJUSTMENT, glcode);
    actionToDebitAccount.put(FinancialActionConstants.MANDATORYWITHDRAWAL_ADJUSTMENT, glcode);
    actionToDebitAccount.put(FinancialActionConstants.ROUNDING, glcode);
    FinancialRules.getInstance().setActionToDebitAccount(actionToDebitAccount);
    FinancialActionTypeEntity roundingAction = new FinancialActionTypeEntity();
    roundingAction.setId(FinancialActionConstants.ROUNDING.getValue());
    FinancialActionTypeEntity depositAction = new FinancialActionTypeEntity();
    depositAction.setId(FinancialActionConstants.MANDATORYDEPOSIT.getValue());
    FinancialActionTypeEntity withdrawalAction = new FinancialActionTypeEntity();
    withdrawalAction.setId(FinancialActionConstants.MANDATORYWITHDRAWAL.getValue());
    FinancialActionTypeEntity depositAdjustmentAction = new FinancialActionTypeEntity();
    depositAdjustmentAction.setId(FinancialActionConstants.MANDATORYDEPOSIT_ADJUSTMENT.getValue());
    FinancialActionTypeEntity withdrawalAdjustmentAction = new FinancialActionTypeEntity();
    withdrawalAdjustmentAction.setId(FinancialActionConstants.MANDATORYWITHDRAWAL_ADJUSTMENT.getValue());
    FinancialActionTypeEntity interestPostingAction = new FinancialActionTypeEntity();
    interestPostingAction.setId(FinancialActionConstants.SAVINGS_INTERESTPOSTING.getValue());
    FinancialActionCache.addToCache(depositAction);
    FinancialActionCache.addToCache(withdrawalAction);
    FinancialActionCache.addToCache(depositAdjustmentAction);
    FinancialActionCache.addToCache(withdrawalAdjustmentAction);
    FinancialActionCache.addToCache(interestPostingAction);
    FinancialActionCache.addToCache(roundingAction);
}
Also used : FinancialActionConstants(org.mifos.accounts.financial.util.helpers.FinancialActionConstants) FinancialActionTypeEntity(org.mifos.accounts.financial.business.FinancialActionTypeEntity) HashMap(java.util.HashMap) ChartOfAccountsCache(org.mifos.accounts.financial.util.helpers.ChartOfAccountsCache) COABO(org.mifos.accounts.financial.business.COABO) GLCodeEntity(org.mifos.accounts.financial.business.GLCodeEntity) BeforeClass(org.junit.BeforeClass)

Example 42 with GLCodeEntity

use of org.mifos.accounts.financial.business.GLCodeEntity in project head by mifos.

the class SavingsAdjustmentTest method setupChartOfAccountsAndFinancialTransactions.

@BeforeClass
public static void setupChartOfAccountsAndFinancialTransactions() {
    defaultCurrency = TestUtils.RUPEE;
    Money.setDefaultCurrency(defaultCurrency);
    Short glcodeId = Short.valueOf("1");
    String glcode = "123456";
    GLCodeEntity glCodeEntity = new GLCodeEntity(glcodeId, glcode);
    COABO coabo = new COABO("testAccountName", glCodeEntity);
    ChartOfAccountsCache chartOfAccountsCache = new ChartOfAccountsCache();
    chartOfAccountsCache.clear();
    chartOfAccountsCache.add(coabo);
    Map<FinancialActionConstants, String> actionToCreditAccount = new HashMap<FinancialActionConstants, String>();
    actionToCreditAccount.put(FinancialActionConstants.MANDATORYDEPOSIT, glcode);
    actionToCreditAccount.put(FinancialActionConstants.MANDATORYWITHDRAWAL, glcode);
    actionToCreditAccount.put(FinancialActionConstants.MANDATORYDEPOSIT_ADJUSTMENT, glcode);
    actionToCreditAccount.put(FinancialActionConstants.MANDATORYWITHDRAWAL_ADJUSTMENT, glcode);
    FinancialRules.getInstance().setActionToCreditAccount(actionToCreditAccount);
    Map<FinancialActionConstants, String> actionToDebitAccount = new HashMap<FinancialActionConstants, String>();
    actionToDebitAccount.put(FinancialActionConstants.MANDATORYDEPOSIT, glcode);
    actionToDebitAccount.put(FinancialActionConstants.MANDATORYWITHDRAWAL, glcode);
    actionToDebitAccount.put(FinancialActionConstants.MANDATORYDEPOSIT_ADJUSTMENT, glcode);
    actionToDebitAccount.put(FinancialActionConstants.MANDATORYWITHDRAWAL_ADJUSTMENT, glcode);
    FinancialRules.getInstance().setActionToDebitAccount(actionToDebitAccount);
    FinancialActionTypeEntity depositAction = new FinancialActionTypeEntity();
    depositAction.setId(FinancialActionConstants.MANDATORYDEPOSIT.getValue());
    FinancialActionTypeEntity withdrawalAction = new FinancialActionTypeEntity();
    withdrawalAction.setId(FinancialActionConstants.MANDATORYWITHDRAWAL.getValue());
    FinancialActionTypeEntity depositAdjustmentAction = new FinancialActionTypeEntity();
    depositAdjustmentAction.setId(FinancialActionConstants.MANDATORYDEPOSIT_ADJUSTMENT.getValue());
    FinancialActionTypeEntity withdrawalAdjustmentAction = new FinancialActionTypeEntity();
    withdrawalAdjustmentAction.setId(FinancialActionConstants.MANDATORYWITHDRAWAL_ADJUSTMENT.getValue());
    FinancialActionCache.addToCache(depositAction);
    FinancialActionCache.addToCache(withdrawalAction);
    FinancialActionCache.addToCache(depositAdjustmentAction);
    FinancialActionCache.addToCache(withdrawalAdjustmentAction);
}
Also used : FinancialActionConstants(org.mifos.accounts.financial.util.helpers.FinancialActionConstants) FinancialActionTypeEntity(org.mifos.accounts.financial.business.FinancialActionTypeEntity) HashMap(java.util.HashMap) ChartOfAccountsCache(org.mifos.accounts.financial.util.helpers.ChartOfAccountsCache) COABO(org.mifos.accounts.financial.business.COABO) GLCodeEntity(org.mifos.accounts.financial.business.GLCodeEntity) BeforeClass(org.junit.BeforeClass)

Example 43 with GLCodeEntity

use of org.mifos.accounts.financial.business.GLCodeEntity in project head by mifos.

the class FeeInstallmentTest method createMonthlyOnDayFeeBO.

private FeeBO createMonthlyOnDayFeeBO(int every) throws Exception {
    MeetingBO feeMeeting = new MeetingBO(RecurrenceType.MONTHLY, (short) every, new DateTime().toDate(), MeetingType.PERIODIC_FEE);
    FeeBO feeBO = new AmountFeeBO(new Money(TestUtils.RUPEE, "10.0"), "Fee", FeeCategory.ALLCUSTOMERS, FeeFrequencyType.PERIODIC, new GLCodeEntity(Short.valueOf("1"), "10000"), feeMeeting, null, new DateTime().minusDays(14).toDate(), TestUtils.makeUserWithLocales().getId());
    return feeBO;
}
Also used : Money(org.mifos.framework.util.helpers.Money) MeetingBO(org.mifos.application.meeting.business.MeetingBO) GLCodeEntity(org.mifos.accounts.financial.business.GLCodeEntity) FeeBO(org.mifos.accounts.fees.business.FeeBO) AmountFeeBO(org.mifos.accounts.fees.business.AmountFeeBO) DateTime(org.joda.time.DateTime) AmountFeeBO(org.mifos.accounts.fees.business.AmountFeeBO)

Example 44 with GLCodeEntity

use of org.mifos.accounts.financial.business.GLCodeEntity in project head by mifos.

the class TestObjectFactory method createLoanOfferingFromLastLoan.

public static LoanOfferingBO createLoanOfferingFromLastLoan(final String name, final String shortName, final ApplicableTo applicableTo, final Date startDate, final PrdStatus offeringStatus, final Double defIntRate, final InterestType interestType, final boolean interestDeductedAtDisbursement, final boolean principalDueInLastInstallment, final MeetingBO meeting, final GraceType graceType, final LoanPrdActionForm loanPrdActionForm) {
    PrdApplicableMasterEntity prdApplicableMaster = new PrdApplicableMasterEntity(applicableTo);
    ProductCategoryBO productCategory = TestObjectFactory.getLoanPrdCategory();
    GracePeriodTypeEntity gracePeriodType = new GracePeriodTypeEntity(graceType);
    InterestTypesEntity interestTypes = new InterestTypesEntity(interestType);
    GLCodeEntity glCodePrincipal = (GLCodeEntity) StaticHibernateUtil.getSessionTL().get(GLCodeEntity.class, Short.valueOf("11"));
    GLCodeEntity glCodeInterest = (GLCodeEntity) StaticHibernateUtil.getSessionTL().get(GLCodeEntity.class, Short.valueOf("21"));
    short gracePeriodDuration = (short) 2;
    LoanOfferingBO loanOffering;
    boolean loanCounter = true;
    boolean waiverInterest = true;
    try {
        loanOffering = new LoanOfferingBO(getContext(), name, shortName, productCategory, prdApplicableMaster, startDate, null, null, gracePeriodType, gracePeriodDuration, interestTypes, defIntRate, defIntRate, defIntRate, loanCounter, interestDeductedAtDisbursement, principalDueInLastInstallment, new ArrayList<FundBO>(), new ArrayList<FeeBO>(), new ArrayList<PenaltyBO>(), meeting, glCodePrincipal, glCodeInterest, loanPrdActionForm, waiverInterest);
    } catch (ProductDefinitionException e) {
        throw new RuntimeException(e);
    }
    PrdStatusEntity prdStatus = testObjectPersistence.retrievePrdStatus(offeringStatus);
    LoanOfferingTestUtils.setStatus(loanOffering, prdStatus);
    LoanOfferingTestUtils.setGracePeriodType(loanOffering, gracePeriodType, gracePeriodDuration);
    return (LoanOfferingBO) testObjectPersistence.persist(loanOffering);
}
Also used : InterestTypesEntity(org.mifos.application.master.business.InterestTypesEntity) MifosRuntimeException(org.mifos.core.MifosRuntimeException) ProductCategoryBO(org.mifos.accounts.productdefinition.business.ProductCategoryBO) ProductDefinitionException(org.mifos.accounts.productdefinition.exceptions.ProductDefinitionException) LoanOfferingBO(org.mifos.accounts.productdefinition.business.LoanOfferingBO) ArrayList(java.util.ArrayList) GLCodeEntity(org.mifos.accounts.financial.business.GLCodeEntity) GracePeriodTypeEntity(org.mifos.accounts.productdefinition.business.GracePeriodTypeEntity) PrdStatusEntity(org.mifos.accounts.productdefinition.business.PrdStatusEntity) PrdApplicableMasterEntity(org.mifos.accounts.productdefinition.business.PrdApplicableMasterEntity)

Example 45 with GLCodeEntity

use of org.mifos.accounts.financial.business.GLCodeEntity in project head by mifos.

the class TestObjectFactory method createSavingsProduct.

public static SavingsOfferingBO createSavingsProduct(final String name, final String shortName, final ApplicableTo applicableTo, final Date startDate, final PrdStatus status, final Double recommendedAmount, final RecommendedAmountUnit recommendedAmountUnit, final Double intRate, final Double maxAmtWithdrawl, final Double minAmtForInt, final SavingsType savingsType, final InterestCalcType interestCalculationType, final MeetingBO intCalcMeeting, final MeetingBO intPostMeeting, final Short depGLCode, final Short withGLCode) {
    GLCodeEntity depglCodeEntity = (GLCodeEntity) StaticHibernateUtil.getSessionTL().get(GLCodeEntity.class, depGLCode);
    GLCodeEntity intglCodeEntity = (GLCodeEntity) StaticHibernateUtil.getSessionTL().get(GLCodeEntity.class, withGLCode);
    ProductCategoryBO productCategory = (ProductCategoryBO) TestObjectFactory.getObject(ProductCategoryBO.class, SAMPLE_CATEGORY);
    PrdApplicableMasterEntity prdApplicableMaster = new PrdApplicableMasterEntity(applicableTo);
    SavingsTypeEntity savingsTypeEntity = new SavingsTypeEntity(savingsType);
    InterestCalcTypeEntity intCalType = new InterestCalcTypeEntity(interestCalculationType);
    RecommendedAmntUnitEntity amountUnit = new RecommendedAmntUnitEntity(recommendedAmountUnit);
    SavingsOfferingBO product;
    try {
        product = new SavingsOfferingBO(TestUtils.makeUserWithLocales(), name, shortName, productCategory, prdApplicableMaster, startDate, null, null, amountUnit, savingsTypeEntity, intCalType, intCalcMeeting, intPostMeeting, TestUtils.createMoney(recommendedAmount), TestUtils.createMoney(maxAmtWithdrawl), TestUtils.createMoney(minAmtForInt), intRate, depglCodeEntity, intglCodeEntity);
    } catch (ProductDefinitionException e) {
        throw new RuntimeException(e);
    } catch (SystemException e) {
        throw new RuntimeException(e);
    }
    PrdStatusEntity prdStatus = testObjectPersistence.retrievePrdStatus(status);
    product.setPrdStatus(prdStatus);
    return (SavingsOfferingBO) testObjectPersistence.persist(product);
}
Also used : MifosRuntimeException(org.mifos.core.MifosRuntimeException) SavingsTypeEntity(org.mifos.accounts.productdefinition.business.SavingsTypeEntity) SystemException(org.mifos.framework.exceptions.SystemException) ProductCategoryBO(org.mifos.accounts.productdefinition.business.ProductCategoryBO) InterestCalcTypeEntity(org.mifos.accounts.productdefinition.business.InterestCalcTypeEntity) ProductDefinitionException(org.mifos.accounts.productdefinition.exceptions.ProductDefinitionException) SavingsOfferingBO(org.mifos.accounts.productdefinition.business.SavingsOfferingBO) GLCodeEntity(org.mifos.accounts.financial.business.GLCodeEntity) PrdStatusEntity(org.mifos.accounts.productdefinition.business.PrdStatusEntity) RecommendedAmntUnitEntity(org.mifos.accounts.productdefinition.business.RecommendedAmntUnitEntity) PrdApplicableMasterEntity(org.mifos.accounts.productdefinition.business.PrdApplicableMasterEntity)

Aggregations

GLCodeEntity (org.mifos.accounts.financial.business.GLCodeEntity)58 Money (org.mifos.framework.util.helpers.Money)21 MeetingBO (org.mifos.application.meeting.business.MeetingBO)18 ProductDefinitionException (org.mifos.accounts.productdefinition.exceptions.ProductDefinitionException)17 Test (org.junit.Test)16 MifosRuntimeException (org.mifos.core.MifosRuntimeException)15 FinancialActionTypeEntity (org.mifos.accounts.financial.business.FinancialActionTypeEntity)14 Date (java.sql.Date)12 ArrayList (java.util.ArrayList)11 FeeBO (org.mifos.accounts.fees.business.FeeBO)11 ProductCategoryBO (org.mifos.accounts.productdefinition.business.ProductCategoryBO)11 COABO (org.mifos.accounts.financial.business.COABO)10 PersistenceException (org.mifos.framework.exceptions.PersistenceException)10 PrdApplicableMasterEntity (org.mifos.accounts.productdefinition.business.PrdApplicableMasterEntity)9 PrdStatusEntity (org.mifos.accounts.productdefinition.business.PrdStatusEntity)9 ApplicationException (org.mifos.framework.exceptions.ApplicationException)8 AmountFeeBO (org.mifos.accounts.fees.business.AmountFeeBO)7 SystemException (org.mifos.framework.exceptions.SystemException)7 CategoryTypeEntity (org.mifos.accounts.fees.business.CategoryTypeEntity)6 FeeFrequencyTypeEntity (org.mifos.accounts.fees.business.FeeFrequencyTypeEntity)6