View Javadoc
1   /*
2    * Copyright 2008-2009 The Kuali Foundation
3    * 
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    * 
8    * http://www.opensource.org/licenses/ecl2.php
9    * 
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.kuali.ole.pdp.batch.service.impl;
17  
18  import java.util.List;
19  
20  import org.kuali.ole.pdp.batch.service.AchAdviceNotificationService;
21  import org.kuali.ole.pdp.businessobject.CustomerProfile;
22  import org.kuali.ole.pdp.businessobject.PaymentDetail;
23  import org.kuali.ole.pdp.businessobject.PaymentGroup;
24  import org.kuali.ole.pdp.service.PaymentGroupService;
25  import org.kuali.ole.pdp.service.PdpEmailService;
26  import org.kuali.ole.sys.service.NonTransactional;
27  import org.kuali.rice.core.api.datetime.DateTimeService;
28  import org.kuali.rice.krad.service.BusinessObjectService;
29  
30  /**
31   * @see org.kuali.ole.pdp.batch.service.AchAdviceNotificationService
32   */
33  public class AchAdviceNotificationServiceImpl implements AchAdviceNotificationService {
34      private PdpEmailService pdpEmailService;
35      private PaymentGroupService paymentGroupService;
36  
37      private DateTimeService dateTimeService;
38      private BusinessObjectService businessObjectService;
39  
40      /**
41       * Set to NonTransactional so the payment advice email sent date will be updated and saved after the email is sent
42       * 
43       * @see org.kuali.ole.pdp.batch.service.AchAdviceNotificationService#sendAdviceNotifications()
44       */
45      @NonTransactional
46      public void sendAdviceNotifications() {
47          // get list of payments to send notification for
48          List<PaymentGroup> paymentGroups = paymentGroupService.getAchPaymentsNeedingAdviceNotification();
49          for (PaymentGroup paymentGroup : paymentGroups) {
50              CustomerProfile customer = paymentGroup.getBatch().getCustomerProfile();
51  
52              // verify the customer profile is setup to create advices
53              if (customer.getAdviceCreate()) {
54                  for (PaymentDetail paymentDetail : paymentGroup.getPaymentDetails()) {
55                      pdpEmailService.sendAchAdviceEmail(paymentGroup, paymentDetail, customer);
56                  }
57              }
58  
59              // update advice sent date on payment
60              paymentGroup.setAdviceEmailSentDate(dateTimeService.getCurrentTimestamp());
61              businessObjectService.save(paymentGroup);
62          }
63      }
64  
65      /**
66       * Sets the pdpEmailService attribute value.
67       * 
68       * @param pdpEmailService The pdpEmailService to set.
69       */
70      @NonTransactional
71      public void setPdpEmailService(PdpEmailService pdpEmailService) {
72          this.pdpEmailService = pdpEmailService;
73      }
74  
75      /**
76       * Sets the dateTimeService attribute value.
77       * 
78       * @param dateTimeService The dateTimeService to set.
79       */
80      @NonTransactional
81      public void setDateTimeService(DateTimeService dateTimeService) {
82          this.dateTimeService = dateTimeService;
83      }
84  
85      /**
86       * Sets the businessObjectService attribute value.
87       * 
88       * @param businessObjectService The businessObjectService to set.
89       */
90      @NonTransactional
91      public void setBusinessObjectService(BusinessObjectService businessObjectService) {
92          this.businessObjectService = businessObjectService;
93      }
94  
95      /**
96       * Sets the paymentGroupService attribute value.
97       * 
98       * @param paymentGroupService The paymentGroupService to set.
99       */
100     @NonTransactional
101     public void setPaymentGroupService(PaymentGroupService paymentGroupService) {
102         this.paymentGroupService = paymentGroupService;
103     }
104 }