01: /*
02: * Copyright 2007 The Kuali Foundation.
03: *
04: * Licensed under the Educational Community License, Version 1.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.opensource.org/licenses/ecl1.php
09: *
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.module.pdp.service.impl;
17:
18: import java.util.Iterator;
19:
20: import org.kuali.core.service.MailService;
21: import org.kuali.module.pdp.bo.Batch;
22: import org.kuali.module.pdp.bo.CustomerProfile;
23: import org.kuali.module.pdp.bo.PaymentDetail;
24: import org.kuali.module.pdp.bo.PaymentGroup;
25: import org.kuali.module.pdp.service.AchEmailService;
26: import org.kuali.module.pdp.service.EnvironmentService;
27: import org.kuali.module.pdp.service.PaymentDetailService;
28: import org.springframework.transaction.annotation.Transactional;
29:
30: @Transactional
31: public class AchEmailServiceImpl implements AchEmailService {
32: private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger
33: .getLogger(AchEmailServiceImpl.class);
34:
35: private PaymentDetailService paymentDetailService;
36: private EnvironmentService environmentService;
37: private MailService mailService;
38:
39: /**
40: * @see org.kuali.module.pdp.service.AchEmailService#sendAchEmails()
41: */
42: public void sendAchEmails() {
43: LOG.debug("sendAchEmails() started");
44:
45: Iterator iter = paymentDetailService
46: .getAchPaymentsWithUnsentEmail();
47: while (iter.hasNext()) {
48: PaymentDetail pd = (PaymentDetail) iter.next();
49: PaymentGroup pg = pd.getPaymentGroup();
50: Batch batch = pg.getBatch();
51: CustomerProfile cust = batch.getCustomerProfile();
52:
53: if (cust.getAdviceCreate().booleanValue()) {
54: if (environmentService.isProduction()) {
55: // Send it to the real recipients
56: } else {
57: // Send it to ourselves for test purposes
58:
59: }
60: }
61: // if ($ENV{'testing'} eq 'y') {
62: // print "sending email to pdphelp\@yahoo.com for disb # $disb_nbr\n";
63: // $mailer->open( {'To' => 'pdphelp@yahoo.com',
64: // 'From' => $adv_rtrn_email_addr,
65: // 'Subject' => "TESTING!:$adv_subj_ln_txt"})
66: // || &terminate("Trouble Sending advice email for disb - $disb_nbr");
67: // } else {
68: // print "sending email to $adv_email_addr for disb # $disb_nbr\n";
69: // $mailer->open( {'To' => $adv_email_addr,
70: // 'From' => $adv_rtrn_email_addr,
71: // 'Subject' => $adv_subj_ln_txt})
72: // || &terminate("Trouble Sending advice email for disb - $disb_nbr");
73: // }
74: // } else {
75: // print "bouncing email to $adv_rtrn_email_addr for disb # $disb_nbr\n";
76: // $mailer->open( {'To' => $adv_rtrn_email_addr,
77: // 'From' => 'fms_operations@indiana.edu',
78: // 'Subject' => 'Unable to send advice email'})
79: // || &terminate("Trouble Sending error advice email for disb - $disb_nbr");
80: // print $mailer "Could not email this advice because no email ";
81: // print $mailer "address was found.\n\n\n";
82: // }
83: }
84: }
85:
86: public void setPaymentDetailService(PaymentDetailService pds) {
87: paymentDetailService = pds;
88: }
89: }
|