前言
客户现场,实施同事在给客户做固定资产上报录入项目,其中标准产品的固定资产清单,要求一旦进行固定资产的清理,系统中就会将固定资产进行折算,和帐期进行关联,系统提起清理单以后,就会按照设定好的公式进行对资产的费用进行扣除。但是,实际中,客户在日常的提起固定资产清理单以后,需要进行流程审批,在分配到下级企业,进行固定资产的变卖等操作,这其中也需要时间,(意思就是说流程整个下来,需要很长的时间,不是我黑国企哦...)。因此,需要做一个单独的固定资产清算单,大概内容和标准产品差不多功能,但是不与业务进行关联限制,只是进行固定资产清单的录入,然后套打打印。等固定资产变卖以后,有收入以后,再在标准产品中进行提起清理单结算。啰里啰唆一大堆,现在反正就是项目的需要,逃不过研究固定资产清理标准产品代码了。
标准产品模块
财务会计/固定资产/日常结算/固定资产清理
固定资产清理列表界面 (FaClearBillListUI)
然后呢,点击新增按钮,进行新增固定资产清单,首先呢,点击新增按钮以后,会首先弹出 过滤卡片,然后点击 卡片查询 会列出所有的未进行固定资产清理的固定资产(好绕啊...) ,选择一条固定资产以后,点击确定,会把该条固定资产信息带入到 新增固定资产清理单界面。
新增固定资产清理单界面(FaClearBillEditUI)
点击分录进行增加固定资产,此时,会再次弹出过滤卡片,供用户选择固定资产。普通的分录点击新增分录的时候,只会新增一行空白行,但是这里确实能够弹出过滤框,供用户进行选择,然后再将用户选择的内容填充到新增加的分录中。原因是因为分录的新增行方法进行了改变 (actionInsertLine_actionPerformed)。
接下来呢,将进行源代码分析!let's do it !
源码分析
固定资产清理单列表(FaClearBillListUI):在新增按钮中,设置弹框dialog属性,然后弹框显示。
1 public void actionAddNew_actionPerformed(ActionEvent e) throws Exception {
// 新增按钮 2 CommonQueryWithResultDialog dialog = new CommonQueryWithResultDialog(); 3 4 if (getUIWindow() == null) 5 dialog.setOwner((Component) getUIContext().get("OwnerWindow")); 6 else { 7 dialog.setOwner(this); 8 } 9 HashMap hmParam = gethmParamD(); 10 boolean isRange = "true".equals(hmParam.get("FA_040").toString()); 11 FACommonProcessor processor = new FACommonProcessor(); 12 processor.setRange(isRange); 13 dialog.setProcessor(processor); 14 15 dialog.setParentUIClassName(getMetaDataPK().getFullName()); 16 dialog.setEntityViewInfo(new EntityViewInfo()); 17 dialog.setQueryObjectPK(new MetaDataPK("com.kingdee.eas.fi.fa.manage", 18 "FaCurCardQuery")); 19 dialog.setTitle(getUITitle()); 20 dialog.setHeight(525); 21 dialog.setSelectMode(10); 22 dialog.setOpenType(0); 23 24 if ((dialog.show()) || (dialog.hasKeyValue())) { 25 getUIContext().put("SearchResult", dialog.getSearchResult()); 26 getUIContext().put("isUseScan", "false"); 27 super.actionAddNew_actionPerformed(e); 28 } else { 29 SysUtil.abort(); 30 } 31 } 32 33 public HashMap gethmParamD() { 34 HashMap hmParam = new HashMap(); 35 try { 36 hmParam = FaManageUtils.getFAParameter(getCurrentCompany().getId()); 37 } catch (Exception e) { 38 handUIException(e); 39 } 40 return hmParam; 41 }
双击过滤卡片框选中以后,跳转到清单数据新增界面(FaClearBillEditUI),选择清理方式,然后再分录中新增固定资产卡片,最后进行保存,提交,审核,反审核等操作。
1 public void actionAddNew_actionPerformed(ActionEvent e) throws Exception {
//新增按钮 清空当前分录内容,弹出过滤卡片框,新增清理单据 2 CommonQueryWithResultDialog dialog = initDialog(); 3 4 if ((dialog.show()) || (dialog.hasKeyValue())) { 5 super.actionAddNew_actionPerformed(e); 6 this.kdtEntry.removeRows(); 7 setTable(dialog.getSearchResult()); 8 } else { 9 SysUtil.abort(); 10 } 11 } 12 13 14 15 16 --------initDialog------------ 17 18 private CommonQueryWithResultDialog initDialog() throws Exception { 19 CommonQueryWithResultDialog dialog = new CommonQueryWithResultDialog(); 20 21 if (getUIWindow() == null) 22 dialog.setOwner((Component) getUIContext().get("OwnerWindow")); 23 else { 24 dialog.setOwner(this); 25 } 26 27 HashMap hmParam = gethmParamD(); 28 boolean isRange = "true".equals(hmParam.get("FA_040").toString()); 29 FACommonProcessor processor = new FACommonProcessor(); 30 processor.setRange(isRange); 31 dialog.setProcessor(processor); 32 33 dialog.setParentUIClassName(getMetaDataPK().getFullName()); 34 dialog.setEntityViewInfo(new EntityViewInfo()); 35 dialog.setQueryObjectPK(new MetaDataPK("com.kingdee.eas.fi.fa.manage", 36 "FaCurCardQuery")); 37 dialog.setTitle(this.btnFilterCard.getText()); 38 dialog.setHeight(525); 39 dialog.setSelectMode(10); 40 dialog.setOpenType(0); 41 return dialog; 42 }
点击分录,不是简单的新增一行空白分录,而是弹出 过滤卡片框,进行固定资产的选择。下面就是新增一行分录的代码:
1 public void actionInsertLine_actionPerformed(ActionEvent e) 2 throws Exception { 3 CommonQueryWithResultDialog dialog = initDialog(); 4 5 if ((dialog.show()) || (dialog.hasKeyValue())) 6 setTable(dialog.getSearchResult()); 7 else 8 SysUtil.abort(); 9 }
其中的 setTable 方法,就是将 用户在 过滤卡片过滤框 选择的多行或者单行 记录 批量进行赋值 显示到分录中
1 private void setTable(ArrayList rowSet) throws Exception { 2 if ((rowSet != null) && (rowSet.size() > 0)) { 3 for (int i = 0; i < rowSet.size(); ++i) { 4 IRow result = (IRow) rowSet.get(i); 5 6 for (int j = 0; j < getDetailTable().getRowCount(); ++j) { 7 Object oldID = getDetailTable().getRow(j).getCell( 8 "curCardID").getValue(); 9 Object newID = result.getCell("id").getValue(); 10 if ((oldID != null) && (newID != null) 11 && (oldID.toString().equals(newID.toString()))) { 12 break label1045; 13 } 14 } 15 FaCurCardInfo curCard = getCurCardInfo(result.getCell("id") 16 .getValue().toString()); 17 18 EffectedStatusEnum effectedStatus = curCard.getEffectedStatus(); 19 CheckedStatusEnum checkedStatus = curCard.getCheckedStatus(); 20 BlockedStatusEnum blockedStatus = curCard.getBlockedStatus(); 21 DeletedStatusEnum deletedStatus = curCard.getDeletedStatus(); 22 FaBizStatusEnum bizStatus = curCard.getBizStatus(); 23 FaLeaseStatusEnum leaseStatus = curCard.getLeaseStatus(); 24 25 if ((effectedStatus == null) 26 || (effectedStatus != EffectedStatusEnum.EFFECTED) 27 || (checkedStatus == null) 28 || (checkedStatus != CheckedStatusEnum.AUDITED) 29 || (blockedStatus == null) 30 || (blockedStatus != BlockedStatusEnum.UNBLOCKED) 31 || (deletedStatus == null) 32 || (deletedStatus != DeletedStatusEnum.NORMAL) 33 || (!(bizStatus.getValue().endsWith("99"))) 34 || (FaLeaseStatusEnum.FINANCE_LEASE_OUT 35 .equals(leaseStatus)) 36 || (FaLeaseStatusEnum.WORKING_LEASE_OUT 37 .equals(leaseStatus))) { 38 continue; 39 } 40 41 FaClearBillEntryInfo entry = (FaClearBillEntryInfo) createNewDetailData(getDetailTable()); 42 IRow row = getDetailTable().addRow(); 43 super.loadLineFields(getDetailTable(), row, entry); 44 row.getCell("curCardID").setValue(curCard.getId().toString()); 45 row.getCell("faCatName").setValue( 46 curCard.getAssetCat().getName()); 47 row.getCell("assetNumber").setValue(curCard.getNumber()); 48 row.getCell("assetName").setValue(curCard.getAssetName()); 49 row.getCell("assetSpec").setValue(curCard.getSpecs()); 50 row.getCell("measureUnit").setValue( 51 curCard.getMeasureUnit().getName()); 52 row.getCell("assetAmount").setValue(curCard.getAssetAmt()); 53 row.getCell("curCardLocalAmount").setValue( 54 curCard.getAssetValue()); 55 row.getCell("curCardAddUPDep").setValue(curCard.getAccuDepr()); 56 row.getCell("curCardDepPrepare") 57 .setValue(curCard.getDecValue()); 58 row.getCell("curCardAccountDate").setValue( 59 curCard.getAccountDate()); 60 row.getCell("curCardDeprTTerm") 61 .setValue(curCard.getDeprTTerm()); 62 row.getCell("isHasNew").setValue( 63 Boolean.valueOf(curCard.isHasNew())); 64 row.getCell("clrQty").setValue(curCard.getAssetAmt()); 65 row.getCell("canDoClear").setValue( 66 Boolean.valueOf(checkDeprePolicy(curCard, 0))); 67 row.getCell("clrFare").setValue(ZERO); 68 row.getCell("spilthMoveIn").setValue(ZERO); 69 row.getCell("spilthIncome").setValue(ZERO); 70 row.getCell("price").setValue(ZERO); 71 row.getCell("isNeedReDepr").setValue(curCard); 72 row.getCell("initEvalValue").setValue( 73 curCard.getInitEvalValue()); 74 row.getCell("isEvaledBefore").setValue( 75 Boolean.valueOf(curCard.isIsEvaledBefore())); 76 row.getCell("calcuByEvaluate").setValue( 77 Boolean.valueOf(curCard.getAssetCat() 78 .isCalcuByEvaluate())); 79 row.getCell("clrFare").setValue(curCard.getAddons()); 80 row.getCell("spilthIncome").setValue( 81 curCard.getTreatmentIncome()); 82 83 row.getCell("barCode").setValue(curCard.getBarCode()); 84 row.getCell("groupNumber").setValue(curCard.getGroupNumber()); 85 dealClearQtyChange(getDetailTable().getRowCount() - 1, 0); 86 87 if (curCard.getPropertyValue() != null) { 88 Map cellMap = new HashMap(); 89 KDTColumns cc = getDetailTable().getColumns(); 90 for (int j = 0; j < cc.size(); ++j) { 91 String key = cc.getColumn(j).getKey(); 92 if (key != null) { 93 cellMap.put(key.toLowerCase(), row.getCell(key)); 94 } 95 } 96 String prefix = "propertyValue."; 97 FaDefPropertyValueInfo pv = curCard.getPropertyValue(); 98 String[] cols = pv.getDefPropertyNames(); 99 for (int j = 0; j < cols.length; ++j) { 100 String name = prefix + cols[j]; 101 ICell cell = (ICell) cellMap.get(name.toLowerCase()); 102 label1045: if (cell != null) { 103 cell.setValue(pv.get(cols[j])); 104 } 105 } 106 } 107 } 108 } 109 110 if (getDetailTable().getRowCount() >= 1) 111 return; 112 MsgBox.showInfo(Util.getWindow(this), EASResource.getString(className, 113 "FaClearBillEditUI_NoCardCanClear")); 114 SysUtil.abort(); 115 }
分录字段
清理数量(clrQty) 清理原值(clrOriginal) 清理累计折旧(clrAddupDep) 清理减值准备(clrDecPrep) 清理费用(clrFare) 残料入库成本(spilthMoveln) 出售金额(price)
残料收入(spilthIncome) 残料处理方式(spilthDeal) 备注(commont) 清理评估价值(clrEvalValue)