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