1   
2   
3   
4   
5   
6   
7   
8   
9   
10  
11  
12  
13  
14  
15  
16  package org.kuali.ole.fp.document;
17  
18  import static org.kuali.ole.sys.OLEConstants.FROM;
19  import static org.kuali.ole.sys.OLEConstants.TO;
20  
21  import org.apache.commons.lang.StringUtils;
22  import org.kuali.ole.fp.businessobject.GECSourceAccountingLine;
23  import org.kuali.ole.fp.businessobject.GECTargetAccountingLine;
24  import org.kuali.ole.integration.cam.CapitalAssetManagementModuleService;
25  import org.kuali.ole.sys.businessobject.GeneralLedgerPendingEntry;
26  import org.kuali.ole.sys.businessobject.GeneralLedgerPendingEntrySourceDetail;
27  import org.kuali.ole.sys.context.SpringContext;
28  import org.kuali.ole.sys.document.AmountTotaling;
29  import org.kuali.ole.sys.document.Correctable;
30  import org.kuali.ole.sys.document.validation.impl.AccountingDocumentRuleBaseConstants.GENERAL_LEDGER_PENDING_ENTRY_CODE;
31  import org.kuali.rice.kew.framework.postprocessor.DocumentRouteStatusChange;
32  import org.kuali.rice.kns.service.DataDictionaryService;
33  import org.kuali.rice.krad.document.Copyable;
34  import org.kuali.rice.krad.rules.rule.event.KualiDocumentEvent;
35  import org.kuali.rice.krad.rules.rule.event.SaveDocumentEvent;
36  
37  
38  
39  
40  
41  
42  
43  public class GeneralErrorCorrectionDocument extends CapitalAccountingLinesDocumentBase implements Copyable, Correctable, AmountTotaling, CapitalAssetEditable {
44      protected static org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(GeneralErrorCorrectionDocument.class);
45  
46      protected transient CapitalAssetManagementModuleService capitalAssetManagementModuleService;
47  
48      
49  
50  
51      public GeneralErrorCorrectionDocument() {
52          super();
53      }
54  
55      
56  
57  
58  
59  
60      @Override
61      public String getSourceAccountingLinesSectionTitle() {
62          return FROM;
63      }
64  
65      
66  
67  
68  
69  
70      @Override
71      public String getTargetAccountingLinesSectionTitle() {
72          return TO;
73      }
74  
75      
76  
77  
78      @Override
79      public Class getSourceAccountingLineClass() {
80          return GECSourceAccountingLine.class;
81      }
82  
83      
84  
85  
86      @Override
87      public Class getTargetAccountingLineClass() {
88          return GECTargetAccountingLine.class;
89      }
90  
91      
92  
93  
94  
95  
96  
97  
98  
99  
100     @Override
101     public void customizeExplicitGeneralLedgerPendingEntry(GeneralLedgerPendingEntrySourceDetail postable, GeneralLedgerPendingEntry explicitEntry) {
102         explicitEntry.setTransactionLedgerEntryDescription(buildTransactionLedgerEntryDescriptionUsingRefOriginAndRefDocNumber(postable));
103 
104         
105         
106         
107         explicitEntry.setReferenceFinancialDocumentNumber(null);
108         explicitEntry.setReferenceFinancialSystemOriginationCode(null);
109         explicitEntry.setReferenceFinancialDocumentTypeCode(null);
110     }
111 
112     
113 
114 
115 
116 
117 
118 
119 
120     protected String buildTransactionLedgerEntryDescriptionUsingRefOriginAndRefDocNumber(GeneralLedgerPendingEntrySourceDetail line) {
121         String description = "";
122         description = line.getReferenceOriginCode() + "-" + line.getReferenceNumber();
123 
124         if (StringUtils.isNotBlank(line.getFinancialDocumentLineDescription())) {
125             description += ": " + line.getFinancialDocumentLineDescription();
126         }
127         else {
128             description += ": " + getDocumentHeader().getDocumentDescription();
129         }
130 
131         if (description.length() > GENERAL_LEDGER_PENDING_ENTRY_CODE.GLPE_DESCRIPTION_MAX_LENGTH) {
132             description = description.substring(0, GENERAL_LEDGER_PENDING_ENTRY_CODE.GLPE_DESCRIPTION_MAX_LENGTH - 3) + "...";
133         }
134 
135         return description;
136     }
137 
138     
139 
140 
141     @Override
142     public void doRouteStatusChange(DocumentRouteStatusChange statusChangeEvent) {
143         super.doRouteStatusChange(statusChangeEvent);
144         this.getCapitalAssetManagementModuleService().deleteDocumentAssetLocks(this);
145     }
146 
147 
148     
149 
150 
151     @Override
152     public void postProcessSave(KualiDocumentEvent event) {
153         super.postProcessSave(event);
154         if (!(event instanceof SaveDocumentEvent)) { 
155             String documentTypeName = SpringContext.getBean(DataDictionaryService.class).getDocumentTypeNameByClass(this.getClass());
156             this.getCapitalAssetManagementModuleService().generateCapitalAssetLock(this, documentTypeName);
157         }
158     }
159 
160     
161 
162 
163     public CapitalAssetManagementModuleService getCapitalAssetManagementModuleService() {
164         if (capitalAssetManagementModuleService == null) {
165             capitalAssetManagementModuleService = SpringContext.getBean(CapitalAssetManagementModuleService.class);
166         }
167         return capitalAssetManagementModuleService;
168     }
169 }