001/**
002 * Copyright 2004-2014 The Kuali Foundation
003 *
004 * Licensed under the Educational Community License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.opensource.org/licenses/ecl2.php
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016package org.kuali.hr.lm.leaveCalendar.validation;
017
018import java.math.BigDecimal;
019import java.util.ArrayList;
020import java.util.List;
021import java.util.Map;
022import java.util.Set;
023
024import org.joda.time.DateTime;
025import org.joda.time.LocalDate;
026import org.junit.After;
027import org.junit.Assert;
028import org.junit.Before;
029import org.junit.Test;
030import org.kuali.hr.KPMEWebTestCase;
031import org.kuali.kpme.core.FunctionalTest;
032import org.kuali.kpme.tklm.api.leave.block.LeaveBlock;
033import org.kuali.kpme.tklm.api.leave.block.LeaveBlockContract;
034import org.kuali.kpme.tklm.leave.block.LeaveBlockBo;
035import org.kuali.kpme.tklm.leave.calendar.validation.LeaveCalendarValidationUtil;
036import org.kuali.kpme.tklm.leave.summary.LeaveSummary;
037import org.kuali.kpme.tklm.leave.summary.LeaveSummaryRow;
038
039@FunctionalTest
040public class LeaveCalendarValidationServiceTest extends KPMEWebTestCase {
041        
042        @Before
043        public void setUp() throws Exception {
044                super.setUp();
045        }
046        
047        @After
048        public void tearDown() throws Exception {
049                super.tearDown();
050        }
051        
052        @Test
053        public void testValidateAvailableLeaveBalance() throws Exception {
054                LeaveSummary ls = new LeaveSummary();
055                LeaveSummaryRow lsr = new LeaveSummaryRow();
056                lsr.setAccrualCategory("testAC");
057                lsr.setAccrualCategoryId("5000");
058                lsr.setLeaveBalance(new BigDecimal(5));
059                List<LeaveSummaryRow> lsrList = new ArrayList<LeaveSummaryRow>();
060                lsrList.add(lsr);
061                ls.setLeaveSummaryRows(lsrList);
062                
063                // adding brand new leave blocks
064                // earn code "EC" does not allow negative accrual balance
065                List<String> errors = LeaveCalendarValidationUtil.validateAvailableLeaveBalanceForUsage("EC", "02/15/2012", "02/15/2012", new BigDecimal(8), null);
066                Assert.assertEquals("Incorrect number of error messages", 1, errors.size());
067                String anError = errors.get(0);
068                Assert.assertTrue("error message not correct" , anError.equals("Requested leave amount 8 is greater than available leave balance 0.00"));
069                
070                // earn code "EC1" allows negative accrual balance
071                errors = LeaveCalendarValidationUtil.validateAvailableLeaveBalanceForUsage("EC1", "02/15/2012", "02/15/2012", new BigDecimal(8), null);
072                Assert.assertTrue("There should NOT be error message(s)" , errors.isEmpty());
073                
074                //updating an existing leave block
075        LeaveBlock.Builder aLeaveBlock = LeaveBlock.Builder.create("xxx", "EC", new BigDecimal(-10));
076                //aLeaveBlock.setEarnCode("EC");
077                //aLeaveBlock.setLeaveAmount(new BigDecimal(-10));
078                
079                errors = LeaveCalendarValidationUtil.validateAvailableLeaveBalanceForUsage("EC", "02/15/2012", "02/15/2012", new BigDecimal(3), aLeaveBlock.build());
080                Assert.assertTrue("There should NOT be error message(s)" , errors.isEmpty());
081                
082                aLeaveBlock.setLeaveAmount(new BigDecimal(-2));
083                errors = LeaveCalendarValidationUtil.validateAvailableLeaveBalanceForUsage("EC", "02/15/2012", "02/15/2012", new BigDecimal(10), aLeaveBlock.build());
084                anError = errors.get(0);
085                Assert.assertTrue("error message not correct" , anError.equals("Requested leave amount 10 is greater than available leave balance 2.00"));
086        }
087        
088        @Test
089        public void testValidateLeaveSpanOverMaxUsageRule() throws Exception {
090                LeaveSummary ls = new LeaveSummary();
091                LeaveSummaryRow lsr = new LeaveSummaryRow();
092                lsr.setAccrualCategory("testAC");
093                lsr.setUsageLimit(new BigDecimal(39));
094                List<LeaveSummaryRow> lsrList = new ArrayList<LeaveSummaryRow>();
095                lsrList.add(lsr);
096                ls.setLeaveSummaryRows(lsrList);
097                // adding brand new leave blocks
098                List<String> errors = LeaveCalendarValidationUtil.validateLeaveAccrualRuleMaxUsage(ls, "EC", "02/15/2012", "02/19/2012", new BigDecimal(8), null);
099                Assert.assertEquals("There should be 1 error message" , 1, errors.size());
100                String anError = errors.get(0);
101                Assert.assertTrue("error message not correct" , anError.equals("This leave request would exceed the usage limit for " + lsr.getAccrualCategory()));
102        }
103        
104        @Test
105        public void testValidateLeaveSpanUnderMaxUsageRule() throws Exception {
106                LeaveSummary ls = new LeaveSummary();
107                LeaveSummaryRow lsr = new LeaveSummaryRow();
108                lsr.setAccrualCategory("testAC");
109                lsr.setUsageLimit(new BigDecimal(41));
110                List<LeaveSummaryRow> lsrList = new ArrayList<LeaveSummaryRow>();
111                lsrList.add(lsr);
112                ls.setLeaveSummaryRows(lsrList);
113                // adding brand new leave blocks
114                List<String> errors = LeaveCalendarValidationUtil.validateLeaveAccrualRuleMaxUsage(ls, "EC", "02/15/2012", "02/19/2012", new BigDecimal(8), null);
115                Assert.assertEquals("There should be no error message" , 0, errors.size());
116        }
117        
118        @Test
119        public void testValidateLeaveSpanEqualMaxUsageRule() throws Exception {
120                LeaveSummary ls = new LeaveSummary();
121                LeaveSummaryRow lsr = new LeaveSummaryRow();
122                lsr.setAccrualCategory("testAC");
123                lsr.setUsageLimit(new BigDecimal(40));
124                List<LeaveSummaryRow> lsrList = new ArrayList<LeaveSummaryRow>();
125                lsrList.add(lsr);
126                ls.setLeaveSummaryRows(lsrList);
127                // adding brand new leave blocks
128                List<String> errors = LeaveCalendarValidationUtil.validateLeaveAccrualRuleMaxUsage(ls, "EC", "02/15/2012", "02/19/2012", new BigDecimal(8), null);
129                Assert.assertEquals("There should be no error message" , 0, errors.size());
130        }
131        
132        @Test
133        public void testValidateLeaveNonSpanOverMaxUsageRule() throws Exception {
134                LeaveSummary ls = new LeaveSummary();
135                LeaveSummaryRow lsr = new LeaveSummaryRow();
136                lsr.setAccrualCategory("testAC");
137                lsr.setUsageLimit(new BigDecimal(5));
138                List<LeaveSummaryRow> lsrList = new ArrayList<LeaveSummaryRow>();
139                lsrList.add(lsr);
140                ls.setLeaveSummaryRows(lsrList);
141                // adding brand new leave blocks
142                List<String> errors = LeaveCalendarValidationUtil.validateLeaveAccrualRuleMaxUsage(ls, "EC", "02/15/2012", "02/15/2012", new BigDecimal(8), null);
143                Assert.assertEquals("There should be 1 error message" , 1, errors.size());
144                String anError = errors.get(0);
145                Assert.assertTrue("error message not correct" , anError.equals("This leave request would exceed the usage limit for " + lsr.getAccrualCategory()));
146        }
147        
148        @Test
149        public void testValidateLeaveNonSpanEqualsMaxUsageRule() throws Exception {
150                LeaveSummary ls = new LeaveSummary();
151                LeaveSummaryRow lsr = new LeaveSummaryRow();
152                lsr.setAccrualCategory("testAC");
153                lsr.setUsageLimit(new BigDecimal(5));
154                List<LeaveSummaryRow> lsrList = new ArrayList<LeaveSummaryRow>();
155                lsrList.add(lsr);
156                ls.setLeaveSummaryRows(lsrList);
157
158                List<String> errors = LeaveCalendarValidationUtil.validateLeaveAccrualRuleMaxUsage(ls, "EC", "02/15/2012", "02/15/2012", new BigDecimal(5), null);
159                Assert.assertEquals("There should be no error message" , 0, errors.size());
160
161        }
162        
163        @Test
164        public void testValidateEditLeaveBlockMaxUsageRuleCaseOne() throws Exception {
165                //Leave Amount increases, Earn Code unchanged
166                LeaveSummary ls = new LeaveSummary();
167                LeaveSummaryRow lsr = new LeaveSummaryRow();
168                lsr.setAccrualCategory("testAC");
169                lsr.setUsageLimit(new BigDecimal(50));
170                lsr.setPendingLeaveRequests(new BigDecimal(25));
171                lsr.setYtdApprovedUsage(new BigDecimal(15));
172                List<LeaveSummaryRow> lsrList = new ArrayList<LeaveSummaryRow>();
173                lsrList.add(lsr);
174                ls.setLeaveSummaryRows(lsrList);
175                
176                //updating an existing leave block
177        LeaveBlock.Builder aLeaveBlock = LeaveBlock.Builder.create("xxx", "EC", new BigDecimal(-10));
178                //LeaveBlockBo aLeaveBlock = new LeaveBlockBo();
179                //aLeaveBlock.setEarnCode("EC");
180                //aLeaveBlock.setLeaveAmount(new BigDecimal(-10)); //this amount, multiplied by the days in the span, is considered to be part of the pending leave requests.
181                List<String> errors = new ArrayList<String>();
182
183                // EC1 belongs to the accrual category testAC
184                // should still be under 50 effective difference is +9, over 1 days = 9 -> 40+12 < 50
185                errors = LeaveCalendarValidationUtil.validateLeaveAccrualRuleMaxUsage(ls, "EC", "02/15/2012", "02/15/2012", new BigDecimal(19), aLeaveBlock.build());
186                Assert.assertTrue("There should be no error message test 1" , errors.size()== 0);
187                
188                // should be right at 50 effective difference is +10, over 1 days = 10 -> 40+10 = 50
189                errors = LeaveCalendarValidationUtil.validateLeaveAccrualRuleMaxUsage(ls, "EC", "02/15/2012", "02/15/2012", new BigDecimal(20), aLeaveBlock.build());
190                Assert.assertTrue("There should be no error message test 2" , errors.size()== 0);
191                
192                // should be over 50 effective difference is +11, over 1 day = 11 -> 40+11 > 50
193                errors = LeaveCalendarValidationUtil.validateLeaveAccrualRuleMaxUsage(ls, "EC", "02/15/2012", "02/15/2012", new BigDecimal(21), aLeaveBlock.build());
194                Assert.assertTrue("There should be 1 error message test 3" , errors.size()== 1);
195                
196                // should be over 50 effective difference is +2, over 6 days = 12 -> 40+12 > 50
197                errors = LeaveCalendarValidationUtil.validateLeaveAccrualRuleMaxUsage(ls, "EC", "02/15/2012", "02/20/2012", new BigDecimal(12), aLeaveBlock.build());
198                Assert.assertTrue("There should be 1 error message test 5" , errors.size()== 1);
199                
200                // should be under effective difference is +2, over 4 days = 8 -> 40+8 < 50
201                errors = LeaveCalendarValidationUtil.validateLeaveAccrualRuleMaxUsage(ls, "EC", "02/15/2012", "02/18/2012", new BigDecimal(12), aLeaveBlock.build());
202                Assert.assertTrue("There should be 1 error message test 6" , errors.size()== 1);
203        }
204        
205        @Test
206        public void testValidateEditLeaveBlockMaxUsageRuleCaseTwo() throws Exception {
207                //Leave Amount decreases, earn code remains the same.
208                LeaveSummary ls = new LeaveSummary();
209                LeaveSummaryRow lsr = new LeaveSummaryRow();
210                lsr.setAccrualCategory("testAC");
211                lsr.setUsageLimit(new BigDecimal(50));
212                lsr.setPendingLeaveRequests(new BigDecimal(25));
213                lsr.setYtdApprovedUsage(new BigDecimal(30));
214                List<LeaveSummaryRow> lsrList = new ArrayList<LeaveSummaryRow>();
215                lsrList.add(lsr);
216                ls.setLeaveSummaryRows(lsrList);
217                
218                //updating an existing leave block
219                //Somehow a block enters the system that exceeds max_usage. The only way for it to be saved
220                //is if the net change drops below the usage limit.
221        LeaveBlock.Builder aLeaveBlock = LeaveBlock.Builder.create("xxx", "EC", new BigDecimal(-10));
222                //LeaveBlockBo aLeaveBlock = new LeaveBlockBo();
223                //aLeaveBlock.setEarnCode("EC");
224                //aLeaveBlock.setLeaveAmount(new BigDecimal(-10));
225                List<String> errors = new ArrayList<String>();
226
227                // effective difference is (-2), over 1 days = -2 -> 55+(-2) > 50
228                errors = LeaveCalendarValidationUtil.validateLeaveAccrualRuleMaxUsage(ls, "EC", "02/15/2012", "02/15/2012", new BigDecimal(8), aLeaveBlock.build());
229                Assert.assertTrue("There should be 1 error message" , errors.size()== 1);
230                
231                // should be equal effective difference is (-0.5), over 5 days = -2.5 -> 55+(-2.5) > 50
232                errors = LeaveCalendarValidationUtil.validateLeaveAccrualRuleMaxUsage(ls, "EC", "02/15/2012", "02/19/2012", new BigDecimal(9.5), aLeaveBlock.build());
233                Assert.assertTrue("There should be 1 error message" , errors.size()== 1);
234        }
235
236        @Test
237        public void testValidateEditLeaveBlockMaxUsageRuleCaseThree() throws Exception {
238                //Leave Amount static, earn code changes.
239                LeaveSummary ls = new LeaveSummary(); 
240                LeaveSummaryRow lsr = new LeaveSummaryRow();
241                lsr.setAccrualCategory("testAC");
242                lsr.setUsageLimit(new BigDecimal(50));
243                lsr.setPendingLeaveRequests(new BigDecimal(25));
244                lsr.setYtdApprovedUsage(new BigDecimal(15));
245
246                LeaveSummaryRow lsr2 = new LeaveSummaryRow();
247                lsr2.setAccrualCategory("testAC2");
248                lsr2.setUsageLimit(new BigDecimal(15));
249                lsr2.setPendingLeaveRequests(new BigDecimal(5));
250                lsr2.setYtdApprovedUsage(new BigDecimal(4));
251                
252                List<LeaveSummaryRow> lsrList = new ArrayList<LeaveSummaryRow>();
253                lsrList.add(lsr);
254                lsrList.add(lsr2);
255                ls.setLeaveSummaryRows(lsrList);
256                
257                //updating an existing leave block
258        LeaveBlock.Builder aLeaveBlock = LeaveBlock.Builder.create("xxx", "EC", new BigDecimal(-10));
259        aLeaveBlock.setAccrualCategory("testAC");
260                //LeaveBlockBo aLeaveBlock = new LeaveBlockBo();
261                //aLeaveBlock.setEarnCode("EC");
262                //aLeaveBlock.setAccrualCategory("testAC");
263                //aLeaveBlock.setLeaveAmount(new BigDecimal(-10));
264                List<String> errors = new ArrayList<String>();
265
266                //Changing to an earn code with different accrual category, testAC2
267                errors = LeaveCalendarValidationUtil.validateLeaveAccrualRuleMaxUsage(ls, "EC2", "02/15/2012", "02/15/2012", new BigDecimal(6), aLeaveBlock.build());
268                Assert.assertTrue("There should be no error message. reached usage limit." , errors.size()== 0);
269                
270                //Changing to an earn code with different accrual category, testAC2
271                errors = LeaveCalendarValidationUtil.validateLeaveAccrualRuleMaxUsage(ls, "EC2", "02/15/2012", "02/15/2012", new BigDecimal(7), aLeaveBlock.build());
272                Assert.assertTrue("There should be 1 error message, there were " + errors.size() + " errors" , errors.size()== 1);
273                
274                //Changing to an earn code with different accrual category, testAC2 with spanning days.
275                errors = LeaveCalendarValidationUtil.validateLeaveAccrualRuleMaxUsage(ls, "EC2", "02/15/2012", "02/19/2012", new BigDecimal(1), aLeaveBlock.build());
276                Assert.assertTrue("There should be no error message, there were " + errors.size() + " errors" , errors.size()== 0);
277                
278                //Changing to an earn code with different accrual category, testAC2 with spanning days.
279                errors = LeaveCalendarValidationUtil.validateLeaveAccrualRuleMaxUsage(ls, "EC2", "02/15/2012", "02/20/2012", new BigDecimal(1), aLeaveBlock.build());
280                Assert.assertTrue("There should be no error message, there were " + errors.size() + " errors" , errors.size()== 0);
281                
282                //Changing to an earn code with different accrual category, testAC2 with spanning days.
283                errors = LeaveCalendarValidationUtil.validateLeaveAccrualRuleMaxUsage(ls, "EC2", "02/15/2012", "02/21/2012", new BigDecimal(1), aLeaveBlock.build());
284                Assert.assertTrue("There should be 1 error message, there were " + errors.size() + " errors" , errors.size()== 1);
285                
286                //Changing to an earn code within same accrual category, testAC
287                errors = LeaveCalendarValidationUtil.validateLeaveAccrualRuleMaxUsage(ls, "EC1", "02/15/2012", "02/15/2012", new BigDecimal(10), aLeaveBlock.build());
288                Assert.assertTrue("There should be no error message, there were " + errors.size() + " errors" , errors.size()== 0);
289                
290                //Changing to an earn code within same accrual category, testAC with spanning days.
291                errors = LeaveCalendarValidationUtil.validateLeaveAccrualRuleMaxUsage(ls, "EC1", "02/15/2012", "02/19/2012", new BigDecimal(2), aLeaveBlock.build());
292                Assert.assertTrue("There should be 0 error message, there were " + errors.size() + " errors" , errors.size()== 0);
293                
294                //Changing to an earn code within same accrual category, testAC with spanning days.
295                errors = LeaveCalendarValidationUtil.validateLeaveAccrualRuleMaxUsage(ls, "EC2", "02/15/2012", "02/25/2012", new BigDecimal(1), aLeaveBlock.build());
296                Assert.assertTrue("There should be 1 error message, there were " + errors.size() + " errors" , errors.size()== 1);
297                                
298        }
299        @Test
300        public void testGetWarningTextForLeaveBlocks() throws Exception {
301                // create two leave blocks with two different earn codes
302                // earn code "ECA" has fmla=Y, has earn code group with warning messages
303                // earn Code "ECB" has fmla = N, has earn code group with warning messages
304                // earn code "ECC" does not have earn code group with warning messages
305
306                List<LeaveBlock> leaveBlocks = new ArrayList<LeaveBlock>();
307                LeaveBlockBo lbA = new LeaveBlockBo();
308                lbA.setEarnCode("ECA");
309                lbA.setLeaveDate(LocalDate.now().toDate());
310                leaveBlocks.add(LeaveBlockBo.to(lbA));
311
312                LeaveBlockBo lbB = new LeaveBlockBo();
313                lbB.setEarnCode("ECB");
314                lbB.setLeaveDate(LocalDate.now().toDate());
315                leaveBlocks.add(LeaveBlockBo.to(lbB));
316
317                LeaveBlockBo lbC = new LeaveBlockBo();
318                lbC.setEarnCode("ECC");
319                lbC.setLeaveDate(LocalDate.now().toDate());
320                leaveBlocks.add(LeaveBlockBo.to(lbC));
321
322                Map<String, Set<String>> allMessages = LeaveCalendarValidationUtil.getWarningMessagesForLeaveBlocks(leaveBlocks, LocalDate.now().toDateTimeAtStartOfDay(), new DateTime().plusDays(1));
323        int numberOfMessages = 0;
324        for (Set<String> msgs : allMessages.values()){
325            numberOfMessages += msgs.size();
326        }
327                Assert.assertTrue("There should be 2 warning messages, not " + numberOfMessages, numberOfMessages== 2);
328
329        for (Set<String> msgs : allMessages.values()){
330            for (String message : msgs) {
331                Assert.assertTrue("Warning message should be 'Test Message' or 'Test Message1'", message.equals("Test Message") || message.equals("Test Message1"));
332            }
333        }
334        }
335        
336        /* In order for tests of the following form to work, need to change status of a document to enroute/approved
337         * without actually routing / approving the document. OR, set up a context within which these actions can be performed.
338         */
339/*      @Test
340        public void testValidatePendingTransactions() throws Exception {
341                Assert.assertNull(null);
342                BalanceTransfer bt = new BalanceTransfer();
343                bt.setAmountTransferred(new BigDecimal(1.0));
344                bt.setTransferAmount(new BigDecimal(1.0));
345                bt.setForfeitedAmount(new BigDecimal(1.0));
346                bt.setAccrualCategoryRule("");
347                bt.setEffectiveDate(TKUtils.getCurrentDate());
348                bt.setFromAccrualCategory("testAC");
349                bt.setToAccrualCategory("testAC2");
350                bt.setPrincipalId("admin");
351                
352                mockSubmitToWorkflow(bt);
353
354                Calendar cal = Calendar.getInstance();
355                cal.setTime(TKUtils.getCurrentDate());
356                cal.add(Calendar.MONTH, -1);
357                Date from = cal.getTime();
358                cal.add(Calendar.MONTH, 2);
359                Date to = cal.getTime();
360                Map<String,Set<String>> allMessages = new HashMap<String, Set<String>>();
361                allMessages.putAll(LeaveCalendarValidationUtil.validatePendingTransactions("admin", LocalDate.fromDateFields(from), LocalDate.fromDateFields(to)));
362                
363                Assert.assertTrue(allMessages.get("actionMessages").size() > 0);
364                Set<String> actionMessages = allMessages.get("actionMessage");
365                
366                Assert.assertTrue("Should contain warning message for pending transaction", actionMessages.contains("A pending balance transfer exists on this calendar. " + 
367                                "It must be finalized before this calendar can be approved"));
368        }
369
370        private void mockSubmitToWorkflow(BalanceTransfer balanceTransfer) {
371                // TODO Auto-generated method stub
372                //balanceTransfer.setStatus(HrConstants.ROUTE_STATUS.ENROUTE);
373        EntityNamePrincipalName principalName = null;
374        if (balanceTransfer.getPrincipalId() != null) {
375            principalName = KimApiServiceLocator.getIdentityService().getDefaultNamesForPrincipalId(balanceTransfer.getPrincipalId());
376        }
377
378                MaintenanceDocument document = KRADServiceLocatorWeb.getMaintenanceDocumentService().setupNewMaintenanceDocument(BalanceTransfer.class.getName(),
379                                "BalanceTransferDocumentType",KRADConstants.MAINTENANCE_NEW_ACTION);
380
381        String personName = (principalName != null  && principalName.getDefaultName() != null) ? principalName.getDefaultName().getCompositeName() : StringUtils.EMPTY;
382        String date = TKUtils.formatDate(balanceTransfer.getEffectiveLocalDate());
383        document.getDocumentHeader().setDocumentDescription(personName + " (" + balanceTransfer.getPrincipalId() + ")  - " + date);
384                Map<String,String[]> params = new HashMap<String,String[]>();
385                
386                KRADServiceLocatorWeb.getMaintenanceDocumentService().setupMaintenanceObject(document, KRADConstants.MAINTENANCE_NEW_ACTION, params);
387                BalanceTransfer btObj = (BalanceTransfer) document.getNewMaintainableObject().getDataObject();
388                
389                btObj.setAccrualCategoryRule(balanceTransfer.getAccrualCategoryRule());
390                btObj.setEffectiveDate(balanceTransfer.getEffectiveDate());
391                btObj.setForfeitedAmount(balanceTransfer.getForfeitedAmount());
392                btObj.setFromAccrualCategory(balanceTransfer.getFromAccrualCategory());
393                btObj.setPrincipalId(balanceTransfer.getPrincipalId());
394                btObj.setToAccrualCategory(balanceTransfer.getToAccrualCategory());
395                btObj.setTransferAmount(balanceTransfer.getTransferAmount());
396                btObj.setAmountTransferred(balanceTransfer.getAmountTransferred());
397                btObj.setSstoId(balanceTransfer.getSstoId());
398                btObj.setDocumentHeaderId(document.getDocumentHeader().getWorkflowDocument().getDocumentId());
399        //LmServiceLocator.getBalanceTransferService().saveOrUpdate(btObj);
400                document.getNewMaintainableObject().setDataObject(btObj);
401                try {
402                        KRADServiceLocatorWeb.getDocumentService().saveDocument(document);
403                } catch (WorkflowException e) {
404                        // TODO Auto-generated catch block
405                        Assert.fail("Caught workflow exception while saving document");
406                }
407                document.getDocumentHeader().getWorkflowDocument().saveDocument("");
408                
409                balanceTransfer = LmServiceLocator.getBalanceTransferService().transfer(btObj);
410
411        }*/
412                
413}