瀏覽代碼

公积金报表按钮权限

yaoyu 3 周之前
父節點
當前提交
0e020fac4a

+ 16 - 0
hr/hr/src/client/nc/bs/hr/plugin/GetDataUtil.java

@@ -3,6 +3,7 @@ package nc.bs.hr.plugin;
 import java.util.HashMap;
 import java.util.Map;
 
+import nc.bs.framework.common.InvocationInfoProxy;
 import nc.bs.framework.common.NCLocator;
 import nc.itf.uap.IUAPQueryBS;
 import nc.jdbc.framework.processor.BeanProcessor;
@@ -10,6 +11,7 @@ import nc.jdbc.framework.processor.ColumnProcessor;
 import nc.jdbc.framework.processor.MapProcessor;
 import nc.vo.org.FinanceOrgVO;
 import nc.vo.pu.m25.entity.InvoiceItemVO;
+import nc.vo.pub.BusinessException;
 
 public class GetDataUtil {
 
@@ -319,5 +321,19 @@ public class GetDataUtil {
 		return map;
 	}
 	
+	//ȨÏÞ¹ýÂË
+	public static String powerRole(String cuserid) throws BusinessException {
+		StringBuffer sql = new StringBuffer();
+		sql.append("SELECT");
+		sql.append("	sm_role.role_code");
+		sql.append(" FROM");
+		sql.append("	sm_role sm_role");
+		sql.append("	LEFT JOIN sm_user_role sm_user_role ON sm_role.pk_role = sm_user_role.pk_role");
+		sql.append(" WHERE");
+		sql.append("	sm_user_role.cuserid = '"+cuserid+"'");
+		sql.append("	AND ( sm_role.role_code = 'GJJ_HR001' OR sm_role.role_code = 'GJJ_CW001' )");
+		return (String) iuap.executeQuery(sql.toString(), new ColumnProcessor());
+	}
+	
 	
 }

+ 236 - 122
hr/hr/src/client/nc/ui/hr/baod_orders/view/AccumulationFundAllocationUI.java

@@ -28,8 +28,10 @@ import javax.swing.table.TableCellRenderer;
 
 import nc.bs.framework.common.InvocationInfoProxy;
 import nc.bs.framework.common.NCLocator;
+import nc.bs.hr.plugin.GetDataUtil;
 import nc.desktop.ui.WorkbenchEnvironment;
 import nc.hr.utils.OutputDialogUtil;
+import nc.itf.hr.IReceivableService;
 import nc.itf.hr.SocialInsuranceAllMaintain;
 import nc.itf.uap.IUAPQueryBS;
 import nc.jdbc.framework.SQLParameter;
@@ -38,6 +40,7 @@ import nc.jdbc.framework.processor.ColumnListProcessor;
 import nc.jdbc.framework.processor.ColumnProcessor;
 import nc.jdbc.framework.processor.MapListProcessor;
 import nc.jdbc.framework.processor.MapProcessor;
+import nc.log.NcLog;
 import nc.ui.pub.ButtonObject;
 import nc.ui.pub.ToftPanel;
 import nc.ui.pub.beans.MessageDialog;
@@ -48,6 +51,9 @@ import nc.ui.pub.beans.UITablePane;
 import nc.ui.pub.beans.ValueChangedEvent;
 import nc.ui.pub.beans.ValueChangedListener;
 import nc.ui.pub.link.BillLinkOneNodeCenter;
+import nc.vo.arap.receivable.AggReceivableBillVO;
+import nc.vo.arap.receivable.ReceivableBillItemVO;
+import nc.vo.arap.receivable.ReceivableBillVO;
 import nc.vo.fipub.exception.ExceptionHandler;
 import nc.vo.fipub.freevalue.Module;
 import nc.vo.gl.pubvoucher.DetailVO;
@@ -59,6 +65,7 @@ import nc.vo.pub.BusinessException;
 import nc.vo.pub.SuperVO;
 import nc.vo.pub.lang.UFBoolean;
 import nc.vo.pub.lang.UFDate;
+import nc.vo.pub.lang.UFDateTime;
 import nc.vo.pub.lang.UFDouble;
 import nc.vo.pubapp.pattern.data.ValueUtils;
 import nc.vo.pubapp.pattern.exception.ExceptionUtils;
@@ -79,6 +86,7 @@ public class AccumulationFundAllocationUI extends ToftPanel {
 	private ButtonObject bt_output = new ButtonObject("导出", "", 2, "bt_output");
 	private ButtonObject bt_voucher = new ButtonObject("生成凭证", "", 2, "bt_voucher");
 	private ButtonObject bt_linkvouchar = new ButtonObject("联查凭证", "", 2, "bt_linkvouchar");
+	private ButtonObject bt_arrecbill = new ButtonObject("生成内部应收单", "", 2, "bt_arrecbill");
 
 	private JProgressBar pb;
 	private UITablePane tablepanel = null;
@@ -95,8 +103,8 @@ public class AccumulationFundAllocationUI extends ToftPanel {
 	private String[] subheading = { "序号", "员工编号", "姓名", "缴费基数", "个人部分", "公司部分", "备注" };
 	private String orgCode;// 查询组织
 	private String period;// 查询期间
-	private Map<String, Map<String, UFDouble>> beforePsgMoney = null; // 处理前金额
-	private Map<String, Map<String, UFDouble>> afterPsgMoney = null; // 处理后金额
+	private Map<String, Map<String, UFDouble>> beforePsgMoney = null;// 处理前金额
+	private Map<String, Map<String, UFDouble>> afterPsgMoney = null;// 处理后金额
 	Map<String, Map<String, String>> middleTableData = null;// 中间表数据
 	private SocialInsuranceAllMaintain siaMaintain = NCLocator.getInstance().lookup(SocialInsuranceAllMaintain.class);
 	private Map<String, UFDouble> tableFourSelfMap = null;// 表四(凭证)
@@ -115,11 +123,23 @@ public class AccumulationFundAllocationUI extends ToftPanel {
 	}
 
 	public void initialize() {
-		setLayout(new BorderLayout());
-		add(getUIPanel0(), BorderLayout.NORTH);
-		add(getUIPanel2(), BorderLayout.CENTER);
-		add(getUIPanel4(), BorderLayout.SOUTH);
-		setButtons(new ButtonObject[] { this.bt_query, this.bt_insert, this.bt_update, this.bt_output, this.bt_voucher, this.bt_linkvouchar });// 添加按钮
+		try {
+			setLayout(new BorderLayout());
+			add(getUIPanel0(), BorderLayout.NORTH);
+			add(getUIPanel2(), BorderLayout.CENTER);
+			add(getUIPanel4(), BorderLayout.SOUTH);
+			String cuserid = InvocationInfoProxy.getInstance().getUserId();
+			String roleCode = GetDataUtil.powerRole(cuserid);
+			if("GJJ_HR001".equals(roleCode)) {
+				setButtons(new ButtonObject[] { this.bt_query, this.bt_insert, this.bt_update, this.bt_output });// 添加按钮
+			}else if("GJJ_CW001".equals(roleCode)){
+				setButtons(new ButtonObject[] { this.bt_query, this.bt_output, this.bt_voucher, this.bt_linkvouchar, this.bt_arrecbill });// 添加按钮
+			}else {
+				setButtons(new ButtonObject[] { this.bt_query, this.bt_insert, this.bt_update, this.bt_output, this.bt_voucher, this.bt_linkvouchar, this.bt_arrecbill });// 添加按钮
+			}
+		} catch (Exception e) {
+			MessageDialog.showHintDlg(this, "提示", e.getMessage());
+		}
 	}
 
 	private UILabel getOrgLabel() {
@@ -293,20 +313,15 @@ public class AccumulationFundAllocationUI extends ToftPanel {
 				onoutput();
 			} else if ("bt_linkvouchar".equals(bt.getCode())) {
 				String pkvouchersql = "select voucher_pk from voucher_flag where tablename='公积金分摊表' and orgcode='" + orgCode + "' and period='" + period + "' and nvl(dr,0)=0 ";
-
 				Object voucher_pk = iuap.executeQuery(pkvouchersql, new ColumnProcessor());
-
 				if (null != voucher_pk) {
 					String sqlvoucher = "select num from gl_voucher where pk_voucher='" + voucher_pk + "' ";
 					Object vouchernum = iuap.executeQuery(sqlvoucher, new ColumnProcessor());
 					if (null != vouchernum) {
-
 						VoucherVO[] aggvos = GLPubProxy.getRemoteVoucher().queryByPks(new String[] { voucher_pk.toString() });
-
 						BillLinkOneNodeCenter.linkQuery_Dialog(this, "C0", new String[] { voucher_pk.toString() }, aggvos, true);
 					}
 				}
-
 			} else if ("bt_voucher".equals(bt.getCode())) {
 				String pkvouchersql = "select voucher_pk from voucher_flag where tablename='公积金分摊表' and orgcode='" + orgCode + "' and period='" + period + "' and nvl(dr,0)=0 ";
 				Object voucher_pk = iuap.executeQuery(pkvouchersql, new ColumnProcessor());
@@ -325,7 +340,6 @@ public class AccumulationFundAllocationUI extends ToftPanel {
 				// 组装生成凭证数据
 				Map<String, UFDouble> voucheramount = getVoucherAmount(getTablePanel());
 				VoucherVO voucher = getVoucherVO(voucheramount);
-
 				for (DetailVO detail : voucher.getDetails()) {
 					if (detail.getAss() != null && detail.getAss().length > 0) {
 						String assIDs = GLPubProxy.getRemoteFreevaluePub().getAssID_RequiresNew(detail.getAss(), false, "", InvocationInfoProxy.getInstance().getGroupId(), Module.GL);
@@ -333,7 +347,6 @@ public class AccumulationFundAllocationUI extends ToftPanel {
 					}
 				}
 				OperationResultVO[] rs = GLPubProxy.getRemoteVoucher().save((VoucherVO) voucher, new Boolean(true));
-
 				// 保存已经生成凭证的标识pk
 				String pk = rs[0].m_strPK;
 				StringBuilder insertSQL = new StringBuilder("insert into voucher_flag (TABLENAME, ORGCODE, PERIOD,  VOUCHER_PK) values (");
@@ -342,11 +355,22 @@ public class AccumulationFundAllocationUI extends ToftPanel {
 				insertSQL.append("'").append(period).append("', ");
 				insertSQL.append("'").append(pk).append("'); ");
 				siaMaintain.executeBaseDAO(insertSQL.toString());
-
 				MessageDialog.showHintDlg(this, "提示", "凭证已生成");
-
+			} else if ("bt_arrecbill".equals(bt.getCode())) {
+				// 验证内部应收是否存在
+				String pk_recbillsql = "select pk_recbill from ar_recbill where def11='公积金分摊表_" + orgCode + "_" + period + "' and nvl(dr,0)=0 ";
+				Object pk_recbill = iuap.executeQuery(pk_recbillsql, new ColumnProcessor());
+				if (null != pk_recbill) {
+					ExceptionUtils.wrappBusinessException("内部应收单【" + period + "】已经生成!不能重复生成!");
+				}
+				MessageDialog.showHintDlg(this, "", "生成内部应收单开始");
+				// 组装应收单数据新增应收单
+				String billNO = addReceivableBill(getTablePanel());
+				MessageDialog.showHintDlg(this, "提示", "内部应收单已生成 " + billNO);
 			}
 		} catch (Exception e) {
+			e.printStackTrace();
+			NcLog.info(e.getMessage());
 			MessageDialog.showHintDlg(this, "提示", e.getMessage());
 		}
 	}
@@ -409,7 +433,6 @@ public class AccumulationFundAllocationUI extends ToftPanel {
 		UFDouble tableSixOrg = tableMap.get("tableSix").get("org");// 实际已缴当月工资个人部分未扣公司部分
 		UFDouble tableSevenStaff = tableMap.get("tableSeven").get("staff");// 实际未缴当月工资个人部分已扣个人部分
 		UFDouble tableSevenOrg = tableMap.get("tableSeven").get("org");// 实际未缴当月工资个人部分已扣公司部分
-
 		UFDouble queryTableNine = nvl(queryTableNine(orgCode, period), 2);// 个人工资表扣缴数
 		Map<String, String> TableTenMap = queryTableTen(orgCode, period);
 		UFDouble TableTenStaff = nvl(TableTenMap.get("so_staff_sum"), 2);// 个人实际缴纳数
@@ -452,8 +475,7 @@ public class AccumulationFundAllocationUI extends ToftPanel {
 			}
 		};
 		tablepanel.getTable().setModel(model);
-		tablepanel.getTable().setColumnWidth(new int[] { 300, 150, 150, 280, 150, 150, 190, 190, 160 });
-
+		tablepanel.getTable().setColumnWidth(new int[] { 300, 150, 150, 300, 150, 150, 200, 190, 160 });
 		TableCellRenderer renderer = new DefaultTableCellRenderer() {
 			@Override
 			public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
@@ -470,7 +492,6 @@ public class AccumulationFundAllocationUI extends ToftPanel {
 				} else {
 					setForeground(Color.BLACK);
 				}
-
 				// 返回渲染的组件
 				return this;
 			}
@@ -494,7 +515,6 @@ public class AccumulationFundAllocationUI extends ToftPanel {
 			String orgMoney = null;
 			// orgName可能存在为空的情况,拼接的时候会把null拼接到新的字符串,使用三目运算处理改问题
 			String combinedField = title + (orgName == null ? "" : orgName) + clerkcode + clerkname;
-
 			// 取中间表数据
 			Map<String, String> middleTableMap = middleTableData.get(combinedField);
 			// middleTableMap为空表示中间表为空,使用原始数据,不为空使用中间表数据
@@ -523,7 +543,6 @@ public class AccumulationFundAllocationUI extends ToftPanel {
 					mapMoney.put("beforePsgOrgMoney", beforePsgOrgMoney);
 					beforePsgMoney.put(clerkcode, mapMoney);
 				}
-
 			}
 		}
 	}
@@ -548,7 +567,6 @@ public class AccumulationFundAllocationUI extends ToftPanel {
 		if ("表七:实际未缴当月工资个人部分已扣".equals(title)) {
 			tableSevenSelfMap = new HashMap<String, UFDouble>();
 		}
-
 		dataList.add(new Object[] { title });
 		dataList.add(subheading);
 		Map<String, UFDouble> MapMoney = new HashMap<String, UFDouble>();
@@ -632,7 +650,6 @@ public class AccumulationFundAllocationUI extends ToftPanel {
 				}
 				// 输出行数据
 				dataList.add(new Object[] { i + 1, clerkcode, clerkname, basicsMoney, staffMoney, orgMoney, mark, str + orgName });
-
 				if ("表一:由个人承担".equals(title)) {
 					tableOneOrgMap.put(clerkcode + "," + clerkname, orgMoney);
 				}
@@ -642,7 +659,6 @@ public class AccumulationFundAllocationUI extends ToftPanel {
 				if ("表七:实际未缴当月工资个人部分已扣".equals(title)) {
 					tableSevenSelfMap.put(clerkcode + "," + clerkname, staffMoney);
 				}
-
 				// 统计小计
 				staffSubtotal = staffSubtotal.add(staffMoney);
 				orgSubtotal = orgSubtotal.add(orgMoney);
@@ -662,14 +678,12 @@ public class AccumulationFundAllocationUI extends ToftPanel {
 					if ("表四:个人部分已在集团内其他公司扣除".equals(title)) {
 						tableFourSelfMap.put(orgName, staffSubtotal);
 					}
-
 					staffSubtotal = new UFDouble(0.00, 2);
 					orgSubtotal = new UFDouble(0.00, 2);
 				}
 			} else {
 				// 输出行数据
 				dataList.add(new Object[] { i + 1, clerkcode, clerkname, basicsMoney, staffMoney, orgMoney, mark, str });
-
 				if ("表一:由个人承担".equals(title)) {
 					tableOneOrgMap.put(clerkcode + "," + clerkname, orgMoney);
 				}
@@ -930,7 +944,7 @@ public class AccumulationFundAllocationUI extends ToftPanel {
 		sql.append(" )ORDER BY orgname");
 		return (List<Map<String, String>>) iuap.executeQuery(sql.toString(), new MapListProcessor());
 	}
-	
+
 	/**
 	 * 查询实际集团内其他公司已缴当月工资个人部分已扣
 	 * 
@@ -951,7 +965,7 @@ public class AccumulationFundAllocationUI extends ToftPanel {
 		sql.append(" ORDER BY CONTRIBUTORYORG");
 		return (List<Map<String, String>>) iuap.executeQuery(sql.toString(), new MapListProcessor());
 	}
-	
+
 	/**
 	 * 查询工资表扣缴数
 	 * 
@@ -1027,7 +1041,7 @@ public class AccumulationFundAllocationUI extends ToftPanel {
 	public UFDouble nvl(Object obj, int power) {
 		return MathTool.nvl(ValueUtils.getUFDouble(obj)).setScale(2, UFDouble.ROUND_HALF_UP);
 	}
-	
+
 	/**
 	 * 导出
 	 */
@@ -1039,10 +1053,9 @@ public class AccumulationFundAllocationUI extends ToftPanel {
 	}
 
 	/**
-	 * 获取修改数据打开修改界面
+	 * 获取修改数据打开修改界面 修改数据
 	 * 
 	 * @param table
-	 *            修改数据
 	 */
 	private void update(UITablePane table) {
 		try {
@@ -1092,14 +1105,14 @@ public class AccumulationFundAllocationUI extends ToftPanel {
 	}
 
 	/**
+	 * 
 	 * 组装凭证借贷金额
 	 * 
 	 * @param tablepane
+	 * 
 	 */
 	private Map<String, UFDouble> getVoucherAmount(UITablePane tablepane) {
-
 		Map<String, UFDouble> map = new LinkedHashMap<String, UFDouble>();
-
 		// 表一 个人承担-公司部分合计
 		Object objgs = tablepane.getTable().getValueAt(2, 2);
 		// 表一 个人承担-个人部分合计
@@ -1156,9 +1169,7 @@ public class AccumulationFundAllocationUI extends ToftPanel {
 		// 金额=表三(由部门承担) 表三 个人部分+公司部分合计 (个人部分为0)
 		UFDouble bsbmhj = bmgs.add(bmgr);
 
-		/**
-		 * 借方:其他应收款/单位往来/对应公司-上海茗杰商务咨询有限公司 注:辅助核算客商和人关联的,尤咏杰---上海茗杰商务咨询有限公司
-		 */
+		/** 借方:其他应收款/单位往来/对应公司-上海茗杰商务咨询有限公司 注:辅助核算客商和人关联的,尤咏杰---上海茗杰商务咨询有限公司 **/
 		// 现在只有1个人(尤咏杰),先写默认值,后续有新增人员再进行优化
 		UFDouble wbgs = objwbgs == null ? UFDouble.ZERO_DBL : new UFDouble(objwbgs.toString());
 		UFDouble wbgr = objwbgr == null ? UFDouble.ZERO_DBL : new UFDouble(objwbgr.toString());
@@ -1169,23 +1180,21 @@ public class AccumulationFundAllocationUI extends ToftPanel {
 		// 金额=表四 个人部分合计
 		UFDouble bsgr = objbsgr == null ? UFDouble.ZERO_DBL : new UFDouble(objbsgr.toString());
 
-		/**
-		 * 生成的凭证自动加一行借方数据,等于管理费用/社会保险费/部门:其他虚拟财务与应付账款/预估成本/办公费/部门:合计值 借方:应付职工薪酬/住房公积金
-		 **/
+		/** 生成的凭证自动加一行借方数据,等于管理费用/社会保险费/部门:其他虚拟财务与应付账款/预估成本/办公费/部门:合计值 借方:应付职工薪酬/住房公积金 **/
 		// 金额=管理费用/住房公积金+应付账款/预估成本/办公费
 		UFDouble gjjhj = gjjcmpamout.add(bsbmhj);
 
 		/** 贷方: 预付账款/待摊费用/待摊事项:公积金摊销 **/
 		// 金额=公积金汇缴单实际缴纳数
 		UFDouble jsibcomount = objsibco == null ? UFDouble.ZERO_DBL : new UFDouble(objsibco.toString());
+		// 金额=社保分摊表金额扣除内部往来
+		UFDouble xjsibcomount = jsibcomount.sub(bsgr);
 
 		/** 贷方: 其他应收款/个人往来 **/
 		// 金额=表七个人部分合计
 		UFDouble bqgrmx = objbqgr == null ? UFDouble.ZERO_DBL : new UFDouble(objbqgr.toString());
 
-		/**
-		 * 生成的凭证自动加一行借方数据,等于管理费用/社会保险费/部门:其他虚拟财务与应付账款/预估成本/办公费/部门:合计值 贷方:应付职工薪酬/住房公积金
-		 **/
+		/** 生成的凭证自动加一行借方数据,等于管理费用/社会保险费/部门:其他虚拟财务与应付账款/预估成本/办公费/部门:合计值 贷方:应付职工薪酬/住房公积金 **/
 		// 金额=管理费用/住房公积金+应付账款/预估成本/办公费
 		UFDouble gjjhd = gjjcmpamout.add(bsbmhj);
 
@@ -1194,26 +1203,22 @@ public class AccumulationFundAllocationUI extends ToftPanel {
 		map.put("其他应收款/个人往来", byblhj);
 		map.put("应付账款/预估成本/办公费", bsbmhj);
 		map.put("其他应收款/单位往来", wbgshj);
-		map.put("其他应收款/内部往来", bsgr);
+		// map.put("其他应收款/内部往来", bsgr);
 		map.put("应付职工薪酬/住房公积金", gjjhj);
-		map.put("预付账款/待摊费用/贷方", jsibcomount);
+		map.put("预付账款/待摊费用/贷方", xjsibcomount);
 		map.put("其他应收款/个人往来/贷方", bqgrmx);
 		map.put("应付职工薪酬/住房公积金/贷方", gjjhd);
-
 		return map;
-
 	}
 
 	// 凭证封装
 	public VoucherVO getVoucherVO(Map<String, UFDouble> map) throws Exception {
-
 		VoucherVO voucher = new VoucherVO();
 		String pk_org = getPk_financeorg(orgCode);
-
 		// 组织版本
 		String pk_group = InvocationInfoProxy.getInstance().getGroupId();// 集团
-//		String year = period.substring(0, 4);// 会计年度
-//		String month = period.substring(5, 7);// 会计月份
+		// String year = period.substring(0, 4);// 会计年度
+		// String month = period.substring(5, 7);// 会计月份
 		Date newDate = convertStringToDate(period + "-01", "yyyy-MM-dd");
 		String nexMonthDate = getMonthFirstDate(newDate);// 下月最后一天
 		String year = nexMonthDate.substring(0, 4);// 会计年度
@@ -1222,7 +1227,6 @@ public class AccumulationFundAllocationUI extends ToftPanel {
 		String pk_accountGlbook = tran_accountingbook(pk_org);// 核算账簿
 		String pk_vouchertype = vouchertypeGetCode("03");// 凭证类型03;
 		String pk_org_v = getPkorgv(pk_org);
-
 		voucher.setPk_vouchertype(pk_vouchertype);// 记账凭证
 		voucher.setAttachment(0);
 		voucher.setDetailmodflag(UFBoolean.TRUE);
@@ -1246,11 +1250,8 @@ public class AccumulationFundAllocationUI extends ToftPanel {
 		voucher.setPk_org_v(pk_org_v);
 		voucher.setPk_group(pk_group);
 		voucher.setPk_accountingbook(pk_accountGlbook);
-
 		ArrayList<DetailVO> itemarr = new ArrayList<DetailVO>();
-
 		for (Entry<String, UFDouble> entry : map.entrySet()) {
-
 			String key = entry.getKey();
 			String km_code = "";
 			UFDouble creditamount = UFDouble.ZERO_DBL;
@@ -1268,7 +1269,6 @@ public class AccumulationFundAllocationUI extends ToftPanel {
 				arrassvo.add(assvos[0]);
 				itemVO.setAss((AssVO[]) arrassvo.toArray(new AssVO[0]));
 				itemarr.add(itemVO);
-
 			} else if ("其他应收款/五险一金".equals(key)) {
 				km_code = "122104";// 其他应收款/五险一金
 				debitamount = entry.getValue();// 借方发生额
@@ -1276,7 +1276,6 @@ public class AccumulationFundAllocationUI extends ToftPanel {
 				DetailVO itemVO = new DetailVO();
 				getDetailvo(itemVO, pk_accasoa, creditamount, debitamount, voucher, "缴纳" + year + "年" + month + "月 公积金");
 				itemarr.add(itemVO);
-
 			} else if ("其他应收款/个人往来".equals(key)) {
 				km_code = "122102";// 其他应收款/个人往来
 				debitamount = entry.getValue();// 借方发生额
@@ -1302,7 +1301,6 @@ public class AccumulationFundAllocationUI extends ToftPanel {
 					}
 					UFDouble debitamounttotal1 = debitamounttotal;
 				}
-
 				if (null != tableSixSelfMap) {// 表六 个人部分
 					UFDouble debitamounttotal = new UFDouble();
 					for (Entry<String, UFDouble> tableSixSelfEntry : tableSixSelfMap.entrySet()) {
@@ -1324,7 +1322,6 @@ public class AccumulationFundAllocationUI extends ToftPanel {
 					}
 					UFDouble debitamounttotal1 = debitamounttotal;
 				}
-
 			} else if ("应付账款/预估成本/办公费".equals(key)) {
 				km_code = "22020205";// 应付账款/预估成本/办公费
 				debitamount = entry.getValue();// 借方发生额
@@ -1341,7 +1338,6 @@ public class AccumulationFundAllocationUI extends ToftPanel {
 				arrassvo.add(assvos2[0]);
 				itemVO.setAss((AssVO[]) arrassvo.toArray(new AssVO[0]));
 				itemarr.add(itemVO);
-
 			} else if ("其他应收款/单位往来".equals(key)) {
 				km_code = "122101";// 其他应收款/单位往来
 				debitamount = entry.getValue();// 借方发生额
@@ -1354,40 +1350,39 @@ public class AccumulationFundAllocationUI extends ToftPanel {
 				arrassvo.add(assvos[0]);
 				itemVO.setAss((AssVO[]) arrassvo.toArray(new AssVO[0]));
 				itemarr.add(itemVO);
-
-			} else if ("其他应收款/内部往来".equals(key)) {
-				// 取表四个人部分合计包含各个子公司,每个公司一条明细
-				km_code = "12210503";// 其他应收款/内部往来/代垫费用
-				debitamount = entry.getValue();// 借方发生额
-				pk_accasoa = tranKm(km_code, pk_accountGlbook);// 科目
-				if (null != tableFourSelfMap) {// 表四每个公司小计
-					UFDouble debitamounttotal = new UFDouble();
-					for (Entry<String, UFDouble> tableFourSelfEntry : tableFourSelfMap.entrySet()) {
-						String orgName = tableFourSelfEntry.getKey();
-						UFDouble debitamountOrg = tableFourSelfEntry.getValue();// 借方发生额
-						debitamounttotal = debitamounttotal.add(debitamountOrg);
-						if (debitamountOrg.doubleValue() != 0) {
-							DetailVO itemVO = new DetailVO();
-							getDetailvo(itemVO, pk_accasoa, creditamount, debitamountOrg, voucher, "缴纳" + year + "年" + month + "月 公积金 ");
-							// 辅助核算
-							AssVO[] assvos = getAss(pk_accasoa, "0004", getbd_cust_supplier_code(orgName), pk_org);// 客商
-							ArrayList<AssVO> arrassvo = new ArrayList<AssVO>();
-							arrassvo.add(assvos[0]);
-							itemVO.setAss((AssVO[]) arrassvo.toArray(new AssVO[0]));
-							itemarr.add(itemVO);
-						}
-					}
-					UFDouble debitamounttotal1 = debitamounttotal;
-				}
-
-			} else if ("应付职工薪酬/住房公积金".equals(key)) {
+			}
+			// else if ("其他应收款/内部往来".equals(key)) {
+			// // 取表四个人部分合计包含各个子公司,每个公司一条明细
+			// km_code = "12210503";// 其他应收款/内部往来/代垫费用
+			// debitamount = entry.getValue();// 借方发生额
+			// pk_accasoa = tranKm(km_code, pk_accountGlbook);// 科目
+			// if (null != tableFourSelfMap) {// 表四每个公司小计
+			// UFDouble debitamounttotal = new UFDouble();
+			// for (Entry<String, UFDouble> tableFourSelfEntry : tableFourSelfMap.entrySet()) {
+			// String orgName = tableFourSelfEntry.getKey();
+			// UFDouble debitamountOrg = tableFourSelfEntry.getValue();// 借方发生额
+			// debitamounttotal = debitamounttotal.add(debitamountOrg);
+			// if (debitamountOrg.doubleValue() != 0) {
+			// DetailVO itemVO = new DetailVO();
+			// getDetailvo(itemVO, pk_accasoa, creditamount, debitamountOrg, voucher, "缴纳" + year + "年" + month + "月 公积金 ");
+			// // 辅助核算
+			// AssVO[] assvos = getAss(pk_accasoa, "0004", getbd_cust_supplier_code(orgName), pk_org);// 客商
+			// ArrayList<AssVO> arrassvo = new ArrayList<AssVO>();
+			// arrassvo.add(assvos[0]);
+			// itemVO.setAss((AssVO[]) arrassvo.toArray(new AssVO[0]));
+			// itemarr.add(itemVO);
+			// }
+			// }
+			// UFDouble debitamounttotal1 = debitamounttotal;
+			// }
+			// }
+			else if ("应付职工薪酬/住房公积金".equals(key)) {
 				km_code = "221106";// 应付职工薪酬/住房公积金 无辅助核算
 				debitamount = entry.getValue();// 借方发生额
 				pk_accasoa = tranKm(km_code, pk_accountGlbook);// 科目
 				DetailVO itemVO = new DetailVO();
 				getDetailvo(itemVO, pk_accasoa, creditamount, debitamount, voucher, "缴纳" + year + "年" + month + "月 公积金 ");
 				itemarr.add(itemVO);
-
 			} else if ("预付账款/待摊费用/贷方".equals(key)) {
 				// km_code = "220201";
 				km_code = "112301";// 预付账款/待摊费用
@@ -1402,7 +1397,6 @@ public class AccumulationFundAllocationUI extends ToftPanel {
 				arrassvo.add(assvos[0]);
 				itemVO.setAss((AssVO[]) arrassvo.toArray(new AssVO[0]));
 				itemarr.add(itemVO);
-
 			} else if ("其他应收款/个人往来/贷方".equals(key)) {
 				km_code = "122102";// 其他应收款/个人往来
 				creditamount = entry.getValue();// 贷方发生额
@@ -1438,13 +1432,10 @@ public class AccumulationFundAllocationUI extends ToftPanel {
 			}
 		}
 		voucher.setDetails((DetailVO[]) itemarr.toArray(new DetailVO[0]));
-
 		return voucher;
-
 	}
 
 	private DetailVO getDetailvo(DetailVO itemVO, String pk_accasoa, UFDouble creditamount, UFDouble debitamount, VoucherVO voucher, String explanation) throws BusinessException {
-
 		String pk_currtype = getcurrtype("CNY");// 币种
 		itemVO.setPk_accasoa(pk_accasoa);// 会计科目
 		itemVO.setCreditamount(creditamount);// 贷方
@@ -1478,9 +1469,7 @@ public class AccumulationFundAllocationUI extends ToftPanel {
 		itemVO.setPk_unit(voucher.getPk_org());
 		itemVO.setPk_unit_v(voucher.getPk_org_v());
 		itemVO.setPk_currtype(pk_currtype);// 币种
-
 		return itemVO;
-
 	}
 
 	private AssVO[] getAss(String pk_km, String code1, String pk_checkvalue1, String pk_org) throws ClassNotFoundException, BusinessException {
@@ -1500,26 +1489,21 @@ public class AccumulationFundAllocationUI extends ToftPanel {
 		if (ass_arr != null) {
 			for (int j = 0; j < ass_arr.size(); j++) {
 				HashMap assmap = (HashMap) ass_arr.get(j);
-
 				String getRefnodename = assmap.get("refnodename") + "";
-
 				String fullclassname = assmap.get("fullclassname") + "";
 				SuperVO refvo = initSuperVOClass(Class.forName(fullclassname));
-
 				String qrykey = "code";
 				if ("项目".equals(getRefnodename)) {
 					qrykey = "project_code";
 				} else if ("部门".equals(getRefnodename)) {
 					qrykey = "name";
 				}
-
 				String refsql = "select * from   " + refvo.getTableName() + " where  nvl(dr,0) = 0   and ( " + qrykey + "  ='" + pk_checkvalue1 + "'  or " + refvo.getPKFieldName() + " = '"
 						+ pk_checkvalue1 + "' )";
 				if (refvo.getTableName().equals("org_dept")) {
 					refsql = "select * from   " + refvo.getTableName() + " where  nvl(dr,0) = 0  and   pk_org  = '" + pk_org + "'  and ( " + qrykey + "  ='" + pk_checkvalue1 + "'  or "
 							+ refvo.getPKFieldName() + " = '" + pk_checkvalue1 + "' )";
 				} else if (refvo.getTableName().equals("bd_defdoc")) {
-
 					if ("公司内部专业(自定义档案)".equals(getRefnodename)) {
 						refsql = "select * from   " + refvo.getTableName() + " where  nvl(dr,0) = 0  and  ( " + qrykey + "  ='" + pk_checkvalue1 + "'  or " + refvo.getPKFieldName() + " = '"
 								+ pk_checkvalue1 + "' )  " + "and  pk_defdoclist =(select pk_defdoclist from  bd_defdoclist  where   code = 'HR016' )     ";
@@ -1531,15 +1515,11 @@ public class AccumulationFundAllocationUI extends ToftPanel {
 								+ pk_checkvalue1 + "' )  " + "and  pk_defdoclist =(select pk_defdoclist from  bd_defdoclist  where   code = '14' )     ";
 					}
 				}
-
 				SuperVO dataVO = (SuperVO) iuap.executeQuery(refsql, new BeanProcessor(Class.forName(fullclassname)));
-
 				if (dataVO == null) {
 					throw new BusinessException("辅助核算翻译失败:" + pk_checkvalue1);
 				}
-
 				AssVO tempAss = new AssVO();
-
 				String pk_checkvalue = dataVO.getPrimaryKey();
 				String code = "";
 				if ("项目".equals(getRefnodename)) {
@@ -1547,7 +1527,6 @@ public class AccumulationFundAllocationUI extends ToftPanel {
 				} else {
 					code = dataVO.getAttributeValue("code") + "";
 				}
-
 				if ("".equals(getRefnodename)) {
 					// 说明是基本类型,则直接当作字符串保存
 					tempAss.setPk_Checkvalue(code);
@@ -1555,11 +1534,9 @@ public class AccumulationFundAllocationUI extends ToftPanel {
 					tempAss.setChecktypecode(assmap.get("code") + "");
 					tempAss.setChecktypename(assmap.get("name") + "");
 				} else {
-					//
 					tempAss.setPk_Checktype(assmap.get("pk_accassitem") + "");
 					tempAss.setChecktypecode(assmap.get("code") + "");
 					tempAss.setChecktypename(assmap.get("name") + "");
-
 					if ("项目".equals(getRefnodename)) {
 						tempAss.setCheckvaluename(dataVO.getAttributeValue("project_name") + "");
 					} else {
@@ -1636,10 +1613,8 @@ public class AccumulationFundAllocationUI extends ToftPanel {
 		String sql = "select  pk_vouchertype     from  bd_vouchertype  where  code   = ? and nvl(dr,0) = 0 ";
 		SQLParameter parameter = new SQLParameter();
 		parameter.addParam(pk);
-
 		Object pk_vouchertype = iuap.executeQuery(sql, parameter, new ColumnProcessor());
 		return pk_vouchertype != null ? pk_vouchertype + "" : "";
-
 	}
 
 	/**
@@ -1649,10 +1624,8 @@ public class AccumulationFundAllocationUI extends ToftPanel {
 		String sql = "select   pk_vid    from  org_financeorg_v  where   pk_financeorg    = ? and nvl(dr,0) = 0 ";
 		SQLParameter parameter = new SQLParameter();
 		parameter.addParam(pk);
-
 		Object pk_vid = iuap.executeQuery(sql, parameter, new ColumnProcessor());
 		return pk_vid != null ? pk_vid + "" : "";
-
 	}
 
 	/**
@@ -1667,7 +1640,6 @@ public class AccumulationFundAllocationUI extends ToftPanel {
 				+ "   and bd_accasoa.pk_accchart =\n" + "       (select pk_accchart\n" + "           from bd_accchart\n" + "          where  originalchart =\n"
 				+ "                 (select pk_curraccchart\n" + "                    from org_accountingbook\n" + "                   where pk_accountingbook = ? and alterchart <> '~' and\n"
 				+ "           tempversionflag <> 'Y'));";
-
 		SQLParameter parameter = new SQLParameter();
 		parameter.addParam(km_code);
 		parameter.addParam(pk_accountingbook);
@@ -1695,7 +1667,6 @@ public class AccumulationFundAllocationUI extends ToftPanel {
 
 	// 员工编号查询人员编码
 	private String psndocCode(String clerkcode) throws BusinessException {
-
 		String sql = "select bd_psndoc.code from  hi_psnjob " + "inner join bd_psndoc on bd_psndoc.pk_psndoc=hi_psnjob.pk_psndoc " + "and nvl(hi_psnjob.dr,0)=0 and nvl(bd_psndoc.dr,0)=0 "
 				+ "and hi_psnjob.clerkcode='" + clerkcode + "'  ";
 		Object code = (String) iuap.executeQuery(sql, new ColumnProcessor());
@@ -1703,31 +1674,22 @@ public class AccumulationFundAllocationUI extends ToftPanel {
 	}
 
 	private String getPk_financeorg(String code) throws BusinessException {
-
 		String sql = "select pk_financeorg  from  org_financeorg  where code='" + code + "' and nvl(dr,0)=0 and enablestate ='2' ";
-
 		Object pk_financeorg = (String) iuap.executeQuery(sql, new ColumnProcessor());
 		return pk_financeorg != null ? pk_financeorg + "" : "";
-
 	}
 
 	private String getpk_user(String code) throws BusinessException {
-
 		String sql = "select cuserid   from  sm_user  where user_code='" + code + "' and nvl(dr,0)=0 and enablestate ='2' ";
-
 		Object cuserid = (String) iuap.executeQuery(sql, new ColumnProcessor());
 		return cuserid != null ? cuserid + "" : "";
-
 	}
 
 	// 根据客商名称查询客商编码
 	private String getbd_cust_supplier_code(String name) throws BusinessException {
-
 		String sql = "select code  from  bd_cust_supplier  where name='" + name + "' and nvl(dr,0)=0  ";
-
 		Object code = (String) iuap.executeQuery(sql, new ColumnProcessor());
 		return code != null ? code + "" : "";
-
 	}
 
 	// 日期格式转字符串
@@ -1738,7 +1700,6 @@ public class AccumulationFundAllocationUI extends ToftPanel {
 		calendar.set(Calendar.DAY_OF_MONTH, calendar.getActualMaximum(Calendar.DAY_OF_MONTH));
 		Date first = calendar.getTime();
 		return convertDateToString(first, "yyyy-MM-dd");
-
 	}
 
 	// 获取下个月最后一天
@@ -1773,4 +1734,157 @@ public class AccumulationFundAllocationUI extends ToftPanel {
 		return resultDate;
 	}
 
+	/**
+	 * 
+	 * 生成内部应收单
+	 * 
+	 * @throws Exception
+	 * 
+	 */
+	private String addReceivableBill(UITablePane tablepane) throws Exception {
+		String billNO = "";
+		Map<String, UFDouble> map = new LinkedHashMap<String, UFDouble>();
+		// 表四 个人部分已在集团内其他公司扣除-个人部分合计
+		Object objbsgr = tablepane.getTable().getValueAt(5, 2);
+		/** 借方:其他应收款/内部往来/代垫费用/对应公司 **/
+		// 金额=表四 个人部分合计
+		UFDouble bsgr = objbsgr == null ? UFDouble.ZERO_DBL : new UFDouble(objbsgr.toString());// 20385.96
+		if (null != tableFourSelfMap) {// 表四每个公司小计
+			AggReceivableBillVO aggReceivableBillVO = new AggReceivableBillVO();
+			ReceivableBillVO receivableBillVO = new ReceivableBillVO();
+			// 赋值主表数据
+			receivableBillVO.setDef11("公积金分摊表_" + orgCode + "_" + period);
+			String pk_org = getPk_financeorg(orgCode);
+			// 组织版本
+			String pk_group = InvocationInfoProxy.getInstance().getGroupId();// 集团
+			String pk_user = InvocationInfoProxy.getInstance().getUserId();// 制单人
+			String pk_org_v = getPkorgv(pk_org);
+			receivableBillVO.setBillstatus(-1);
+			receivableBillVO.setPk_group(pk_group);
+			receivableBillVO.setPk_org(pk_org);
+			receivableBillVO.setPk_org_v(pk_org_v);
+			receivableBillVO.setPk_fiorg(pk_org);// 应收财务组织
+			receivableBillVO.setSett_org(pk_org);// 结算财务组织
+			receivableBillVO.setSett_org_v(pk_org);// 结算财务组织版本
+			receivableBillVO.setBillmaker(pk_user);// 制单人
+			receivableBillVO.setBilldate(new UFDate());// 单据日期
+			receivableBillVO.setCreator(pk_user);// 创建人
+			receivableBillVO.setCreationtime(new UFDateTime());// 创建时间
+			receivableBillVO.setBusidate(new UFDate());// 开票日期
+			receivableBillVO.setObjtype(0);// 往来对象
+			receivableBillVO.setPk_deptid(GetDataUtil.getDeptPK("000101205"));// 收款部门
+			receivableBillVO.setLocal_money(bsgr);// 合计金额--本币金额
+			receivableBillVO.setMoney(bsgr);// 原币金额
+			String pk_bankaccsub = GetDataUtil.getBankaccsubPK("310066218018000420123");
+			receivableBillVO.setRecaccount(pk_bankaccsub);// 收款银行账户
+			receivableBillVO.setPk_busitype(GetDataUtil.getBusitypePK("AR01"));// 业务流程:选择收款
+			receivableBillVO.setBillclass("ys");// 单据大类:应收单
+			String year = period.substring(0, 4);// 会计年度
+			String month = period.substring(5, 7);// 会计月份
+			receivableBillVO.setBillyear(year);// 单据会计年度
+			receivableBillVO.setBillperiod(month);// 单据会计期间
+			receivableBillVO.setIsreded(UFBoolean.FALSE);// 是否红冲过
+			receivableBillVO.setIsflowbill(UFBoolean.FALSE);// 是否流程单据
+			receivableBillVO.setPk_billtype("F0");// 单据类型编码
+			String pk_currtype = getcurrtype("CNY");// 币种
+			receivableBillVO.setPk_currtype(pk_currtype);// 币种
+			receivableBillVO.setPk_balatype(GetDataUtil.getBalatypePK("12"));
+			String pk_country = GetDataUtil.getCountryzonePK("CN");// 国家地区 默认CN
+			receivableBillVO.setSendcountryid(pk_country);// 发货国
+			receivableBillVO.setTaxcountryid(pk_country);// 报税国
+			receivableBillVO.setSubjcode("112301");// 科目编码
+			receivableBillVO.setSrc_syscode(0);// 单据来源系统
+			receivableBillVO.setSyscode(0);// 单据所属系统
+			receivableBillVO.setScomment("S00009");// 摘要
+			receivableBillVO.setMoney(bsgr);// 金额
+			// 应收类型:内部应收单(含代垫费用)
+			String pk_tradetype = "F0-Cxx-01";
+			receivableBillVO.setPk_tradetype(pk_tradetype);
+			String pk_billtypeid = GetDataUtil.getBilltypePK(pk_tradetype, pk_group);
+			receivableBillVO.setPk_tradetypeid(pk_billtypeid);
+			receivableBillVO.setIsflowbill(UFBoolean.FALSE);// 是否流程单据
+			receivableBillVO.setIsreded(UFBoolean.FALSE);// 是否红冲过
+			aggReceivableBillVO.setParentVO(receivableBillVO);
+			List<ReceivableBillItemVO> listItemVO = new ArrayList<ReceivableBillItemVO>();
+			int rowNo = 0;
+			for (Entry<String, UFDouble> tableFourSelfEntry : tableFourSelfMap.entrySet()) {
+				rowNo++;
+				String orgName = tableFourSelfEntry.getKey();// 公司名称
+				UFDouble debitamount = tableFourSelfEntry.getValue();// 借方发生额
+				if (debitamount.doubleValue() != 0) {
+					ReceivableBillItemVO receivableBillItemVO = new ReceivableBillItemVO();
+					// 赋值子表数据
+					receivableBillItemVO.setPk_org(pk_org);
+					receivableBillItemVO.setPk_org_v(pk_org_v);
+					receivableBillItemVO.setPk_group(pk_group);
+					receivableBillItemVO.setPk_fiorg(pk_org);// 应收财务组织
+					receivableBillItemVO.setDef30("06");// 费用归属:06待摊费用"
+					receivableBillItemVO.setDef30(GetDataUtil.getDefdocPK("06", "05", "待摊费用"));
+					receivableBillItemVO.setDef26(GetDataUtil.getDefdocPK("S00009", "08", "代垫费用"));// 收款摘要:S00009代垫费用
+					receivableBillItemVO.setDef29(GetDataUtil.getDefdocPK("060501", "YS001", "不开票结算"));// 收款业务性质:060501不开票结算
+					receivableBillItemVO.setDef15(GetDataUtil.getDefdocPK("其他合同(财务专用)", "01", "其他合同(财务专用)"));// 经营合同名称
+					receivableBillItemVO.setDef16("其他合同(财务专用)");// 合同编号
+					receivableBillItemVO.setDef10(year + month + "公积金个人部分");// 备注
+					String code = getbd_cust_supplier_code(orgName);// 根据名称查询code
+					receivableBillItemVO.setCustomer(GetDataUtil.getCustomerPK(code));// 客户
+					receivableBillItemVO.setOrdercubasdoc(GetDataUtil.getCustomerPK(code));// 订单客户
+					receivableBillItemVO.setTaxcodeid(GetDataUtil.getTaxcodePK("10"));// 税码
+					receivableBillItemVO.setTaxrate(new UFDouble(0));// 税率
+					receivableBillItemVO.setLocal_money_bal(debitamount);// 组织本币余额
+					receivableBillItemVO.setLocal_money_de(debitamount);// 价税合计
+					receivableBillItemVO.setLocal_notax_de(debitamount);// 金额
+					receivableBillItemVO.setLocal_tax_de(new UFDouble(0));// 税额
+					receivableBillItemVO.setLocal_price(debitamount);// 本币单价
+					receivableBillItemVO.setLocal_taxprice(debitamount);// 本币含税单价
+					receivableBillItemVO.setMoney_bal(debitamount);// 原币余额
+					receivableBillItemVO.setMoney_de(debitamount);// 借方原币金额
+					receivableBillItemVO.setNotax_de(debitamount);// 借方原币无税金额
+					receivableBillItemVO.setOccupationmny(debitamount);// 预占用原币余额
+					receivableBillItemVO.setCaltaxmny(debitamount);// 计税金额
+					receivableBillItemVO.setPrice(debitamount);// 单价
+					receivableBillItemVO.setTaxprice(debitamount);// 含税单价
+					receivableBillItemVO.setBilldate(new UFDate());// 单据日期
+					receivableBillItemVO.setBusidate(new UFDate());// 起算日期
+					receivableBillItemVO.setPk_billtype("F0");// 单据类型编码
+					receivableBillItemVO.setBillclass("ys");// 单据大类
+					receivableBillItemVO.setRowno(rowNo);// 单据分录号--行号
+					receivableBillItemVO.setRowtype(22);// 行类型:22代垫
+					receivableBillItemVO.setDirection(1);// 方向:1借方
+					receivableBillItemVO.setPk_currtype(pk_currtype);// 币种
+					receivableBillItemVO.setTaxtype(1);// 扣税类别:1应税外加
+					receivableBillItemVO.setObjtype(0);// 往来对象
+					receivableBillItemVO.setPk_balatype(GetDataUtil.getBalatypePK("12"));
+					receivableBillItemVO.setSendcountryid(pk_country);// 发货国
+					receivableBillItemVO.setBuysellflag(1);// 购销类型 1国内销售
+					// receivableBillItemVO.setConfernum("ARAP_0001A81000000000NVK0_D02024012200077450");// 内部交易结算号
+					receivableBillItemVO.setPk_billtype("F0");// 单据类型编码
+					receivableBillItemVO.setPk_deptid(GetDataUtil.getDeptPK("000101205"));// 部门
+					receivableBillItemVO.setPk_deptid_v(GetDataUtil.getDeptPK("000101205"));// 部门
+					receivableBillItemVO.setPk_psndoc(GetDataUtil.getPsndocPK("1001A8100000003IHP1U"));// 业务员
+					// 应收类型:内部应收单(含代垫费用);
+					receivableBillItemVO.setPk_tradetype(pk_tradetype);
+					receivableBillItemVO.setPk_tradetypeid(pk_billtypeid);
+					receivableBillItemVO.setQuantity_bal(new UFDouble(1));// 数量余额
+					receivableBillItemVO.setQuantity_de(new UFDouble(1));// 借方数量
+					receivableBillItemVO.setRate(new UFDouble(1));// 组织本币税率
+					receivableBillItemVO.setRecaccount(pk_bankaccsub);// 收款银行账户
+					receivableBillItemVO.setRececountryid(pk_country);// 收货国
+					receivableBillItemVO.setSett_org(pk_org);// 结算财务组织
+					receivableBillItemVO.setSett_org_v(pk_org);// 结算财务组织版本
+					receivableBillItemVO.setTriatradeflag(UFBoolean.FALSE);// 三角贸易区
+					receivableBillItemVO.setSettlecurr(pk_currtype);// 收款币种
+					receivableBillItemVO.setSettlemoney(debitamount);// 收款金额
+					listItemVO.add(receivableBillItemVO);
+				}
+			}
+			aggReceivableBillVO.setChildrenVO(listItemVO.toArray(new ReceivableBillItemVO[listItemVO.size()]));
+			// 调用应收单新增方法
+			IReceivableService receivableService = NCLocator.getInstance().lookup(IReceivableService.class);
+			AggReceivableBillVO aggvo = receivableService.receivable_RequiresNew(aggReceivableBillVO);
+			ReceivableBillVO headerVO = (ReceivableBillVO) aggvo.getParentVO();
+			billNO = headerVO.getBillno();
+		}
+		return billNO;
+	}
+
 }

+ 28 - 87
hr/hr/src/client/nc/ui/hr/baod_orders/view/ServiceChargeAllocationUI.java

@@ -28,6 +28,7 @@ import javax.swing.table.TableCellRenderer;
 
 import nc.bs.framework.common.InvocationInfoProxy;
 import nc.bs.framework.common.NCLocator;
+import nc.bs.hr.plugin.GetDataUtil;
 import nc.desktop.ui.WorkbenchEnvironment;
 import nc.hr.utils.OutputDialogUtil;
 import nc.itf.hr.SocialInsuranceAllMaintain;
@@ -111,11 +112,23 @@ public class ServiceChargeAllocationUI extends ToftPanel {
 	}
 
 	public void initialize() {
-		setLayout(new BorderLayout());
-		add(getUIPanel0(), BorderLayout.NORTH);
-		add(getUIPanel2(), BorderLayout.CENTER);
-		add(getUIPanel4(), BorderLayout.SOUTH);
-		setButtons(new ButtonObject[] { this.bt_query, this.bt_update, this.bt_output, this.bt_voucher, this.bt_linkvouchar });// 添加按钮
+		try {
+			setLayout(new BorderLayout());
+			add(getUIPanel0(), BorderLayout.NORTH);
+			add(getUIPanel2(), BorderLayout.CENTER);
+			add(getUIPanel4(), BorderLayout.SOUTH);
+			String cuserid = InvocationInfoProxy.getInstance().getUserId();
+			String roleCode = GetDataUtil.powerRole(cuserid);
+			if("GJJ_HR001".equals(roleCode)) {
+				setButtons(new ButtonObject[] { this.bt_query, this.bt_output, this.bt_voucher, this.bt_linkvouchar });// 添加按钮
+			}else if("GJJ_CW001".equals(roleCode)){
+				setButtons(new ButtonObject[] { this.bt_query, this.bt_update, this.bt_output });// 添加按钮
+			}else {
+				setButtons(new ButtonObject[] { this.bt_query, this.bt_update, this.bt_output, this.bt_voucher, this.bt_linkvouchar });// 添加按钮
+			}
+		} catch (Exception e) {
+			MessageDialog.showHintDlg(this, "提示", e.getMessage());
+		}
 	}
 
 	private UILabel getOrgLabel() {
@@ -137,7 +150,6 @@ public class ServiceChargeAllocationUI extends ToftPanel {
 			// 权限组织
 			String[] pkorgs = FunctionPermProfileManager.getInstance().getProfile(WorkbenchEnvironment.getInstance().getLoginUser().getUser_code()).getFuncSubInfo(nodeCode).getFuncPermissionPkorgs();
 			this.ivjOrgPanel.getRefModel().setFilterPks(pkorgs);
-
 			this.ivjOrgPanel.setBounds(new Rectangle(100, 20));
 			this.ivjOrgPanel.setPreferredSize(new Dimension(170, 20));
 			// this.ivjOrgPanel.setMultiSelectedEnabled(true);
@@ -289,26 +301,18 @@ public class ServiceChargeAllocationUI extends ToftPanel {
 				onoutput();
 			} else if ("bt_linkvouchar".equals(bt.getCode())) {
 				String pkvouchersql = "select voucher_pk from voucher_flag where tablename='服务费分摊表' and orgcode='" + orgCode + "' and period='" + period + "' and nvl(dr,0)=0 ";
-
 				Object voucher_pk = iuap.executeQuery(pkvouchersql, new ColumnProcessor());
-
 				if (null != voucher_pk) {
 					String sqlvoucher = "select num from gl_voucher where pk_voucher='" + voucher_pk + "' ";
 					Object vouchernum = iuap.executeQuery(sqlvoucher, new ColumnProcessor());
 					if (null != vouchernum) {
-
 						VoucherVO[] aggvos = GLPubProxy.getRemoteVoucher().queryByPks(new String[] { voucher_pk.toString() });
-
 						BillLinkOneNodeCenter.linkQuery_Dialog(this, "C0", new String[] { voucher_pk.toString() }, aggvos, true);
 					}
 				}
-
 			} else if ("bt_voucher".equals(bt.getCode())) {
-
 				String pkvouchersql = "select voucher_pk from voucher_flag where tablename='服务费分摊表' and orgcode='" + orgCode + "' and period='" + period + "' and nvl(dr,0)=0 ";
-
 				Object voucher_pk = iuap.executeQuery(pkvouchersql, new ColumnProcessor());
-
 				if (null != voucher_pk) {
 					String sqlvoucher = "select num from gl_voucher where pk_voucher='" + voucher_pk + "' ";
 					Object vouchernum = iuap.executeQuery(sqlvoucher, new ColumnProcessor());
@@ -318,38 +322,28 @@ public class ServiceChargeAllocationUI extends ToftPanel {
 						// 凭证已经被删除,更新中间库
 						StringBuilder insertSQL = new StringBuilder("update  voucher_flag set dr=1 where voucher_pk='" + voucher_pk + "' ");
 						siaMaintain.executeBaseDAO(insertSQL.toString());
-
 					}
-
 				}
-
 				MessageDialog.showHintDlg(this, "", "生成凭证开始");
-
 				// 组装生成凭证数据
 				Map<String, UFDouble> voucheramount = getVoucherAmount(getTablePanel());
 				VoucherVO voucher = getVoucherVO(voucheramount);
-
 				for (DetailVO detail : voucher.getDetails()) {
 					if (detail.getAss() != null && detail.getAss().length > 0) {
 						String assIDs = GLPubProxy.getRemoteFreevaluePub().getAssID_RequiresNew(detail.getAss(), false, "", InvocationInfoProxy.getInstance().getGroupId(), Module.GL);
 						detail.setAssid(assIDs);
 					}
 				}
-
 				OperationResultVO[] rs = GLPubProxy.getRemoteVoucher().save((VoucherVO) voucher, new Boolean(true));
-
 				// 保存已经生成凭证的标识pk
 				String pk = rs[0].m_strPK;
-
 				StringBuilder insertSQL = new StringBuilder("insert into voucher_flag (TABLENAME, ORGCODE, PERIOD,  VOUCHER_PK) values (");
 				insertSQL.append("'").append("服务费分摊表").append("',");
 				insertSQL.append("'").append(orgCode).append("', ");
 				insertSQL.append("'").append(period).append("', ");
 				insertSQL.append("'").append(pk).append("'); ");
 				siaMaintain.executeBaseDAO(insertSQL.toString());
-
 				MessageDialog.showHintDlg(this, "提示", "凭证已生成");
-
 			}
 		} catch (Exception e) {
 			MessageDialog.showHintDlg(this, "提示", e.getMessage());
@@ -381,7 +375,6 @@ public class ServiceChargeAllocationUI extends ToftPanel {
 				String clerkname = map.get("clerkname");
 				String orgName = map.get("orgname");
 				String basicssum = MathTool.nvl(ValueUtils.getUFDouble(map.get("basicssum"))).toString();
-
 				String staffsum = MathTool.nvl(ValueUtils.getUFDouble(map.get("staffsum"))).toString();
 				String orgsum = MathTool.nvl(ValueUtils.getUFDouble(map.get("orgsum"))).toString();
 				String mark = map.get("mark");
@@ -598,12 +591,10 @@ public class ServiceChargeAllocationUI extends ToftPanel {
 		moneyDispose("表三:由部门承担或全额公司承担", tableThree);
 		List<Map<String, String>> tableFour = queryTableFour(orgCode, period);
 		moneyDispose("表四:由公司承担", tableFour);
-
 		tableMap.put("tableOne", addTableToList("1-", dataList, "表一:个人承担", tableOne));
 		tableMap.put("tableTwo", addTableToList("2-", dataList, "表二:外部公司承担", tableTwo));
 		tableMap.put("tableThree", addTableToList("3-", dataList, "表三:由部门承担或全额公司承担", tableThree));
 		tableMap.put("tableFour", addTableToList("4-", dataList, "表四:由公司承担", tableFour));
-
 		UFDouble tableOneStaff = tableMap.get("tableOne").get("staff");// 个人承担个人部分
 		UFDouble tableOneOrg = tableMap.get("tableOne").get("org");// 个人承担公司部分
 		UFDouble tableTwoStaff = tableMap.get("tableTwo").get("staff");// 外部公司承担个人部分
@@ -612,7 +603,6 @@ public class ServiceChargeAllocationUI extends ToftPanel {
 		UFDouble tableThreeOrg = tableMap.get("tableThree").get("org");// 部门承担
 		UFDouble tableFourStaff = tableMap.get("tableFour").get("staff");// 公司承担个人部分
 		UFDouble tableFourOrg = tableMap.get("tableFour").get("org");// 公司承担公司部分
-
 		Map<String, String> TableTenMap = queryTableTen(orgCode, period);
 		// UFDouble TableTenStaff = nvl(TableTenMap.get("so_staff_sum"), 2);//个人实际缴纳数
 		// UFDouble TableTenOrg = nvl(TableTenMap.get("so_org_sum"), 2);//公司实际缴纳数
@@ -644,7 +634,6 @@ public class ServiceChargeAllocationUI extends ToftPanel {
 		tablepanel.getTable().setSelectionMode(1);
 		tablepanel.getTable().setAutoResizeMode(0);
 		tablepanel.getTable().setColumnWidth(new int[] { 300, 150, 150, 280, 150, 150, 190, 190, 160 });
-
 		TableCellRenderer renderer = new DefaultTableCellRenderer() {
 			@Override
 			public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
@@ -941,9 +930,7 @@ public class ServiceChargeAllocationUI extends ToftPanel {
 	 * @param tablepane
 	 */
 	private Map<String, UFDouble> getVoucherAmount(UITablePane tablepane) {
-
 		Map<String, UFDouble> map = new LinkedHashMap<String, UFDouble>();
-
 		// 表一 个人承担-公司部分合计
 		Object objgs = tablepane.getTable().getValueAt(2, 2);
 		// 表一 个人承担-个人部分合计
@@ -965,9 +952,7 @@ public class ServiceChargeAllocationUI extends ToftPanel {
 		// 金额=表三(由部门承担) 公司部分金额合计 K11
 		UFDouble bmcmpamount = objbmgs == null ? UFDouble.ZERO_DBL : new UFDouble(objbmgs.toString());
 
-		/**
-		 * 借方:其他应收款/单位往来/对应公司-上海茗杰商务咨询有限公司 注:辅助核算客商和人关联的,尤咏杰---上海茗杰商务咨询有限公司 ;徐樑--- 上海祥蕙投资管理有限公司
-		 */
+		/** 借方:其他应收款/单位往来/对应公司-上海茗杰商务咨询有限公司 注:辅助核算客商和人关联的,尤咏杰---上海茗杰商务咨询有限公司 ;徐樑--- 上海祥蕙投资管理有限公司 **/
 		// 现在只有1个人(尤咏杰),先写默认值,后续有新增人员再进行优化
 		// 金额=表二(外部公司承担) 公司部分金额合计 K12
 		UFDouble bcmpamount = objwbgs == null ? UFDouble.ZERO_DBL : new UFDouble(objwbgs.toString());
@@ -993,17 +978,13 @@ public class ServiceChargeAllocationUI extends ToftPanel {
 		map.put("其他应收款/单位往来", bcmpamount);
 		// map.put("应交税费", yjsamount);
 		map.put("预付账款/贷方", jsibcomount);
-
 		return map;
-
 	}
 
 	// 凭证封装
 	public VoucherVO getVoucherVO(Map<String, UFDouble> map) throws Exception {
-
 		VoucherVO voucher = new VoucherVO();
 		String pk_org = getPk_financeorg(orgCode);
-
 		// 组织版本
 		String pk_group = InvocationInfoProxy.getInstance().getGroupId();// 集团
 		Date newDate = convertStringToDate(period + "-01", "yyyy-MM-dd");
@@ -1038,11 +1019,8 @@ public class ServiceChargeAllocationUI extends ToftPanel {
 		voucher.setPk_org_v(pk_org_v);
 		voucher.setPk_group(pk_group);
 		voucher.setPk_accountingbook(pk_accountGlbook);
-
 		ArrayList<DetailVO> itemarr = new ArrayList<DetailVO>();
-
 		for (Entry<String, UFDouble> entry : map.entrySet()) {
-
 			String key = entry.getKey();
 			String km_code = "";
 			UFDouble creditamount = UFDouble.ZERO_DBL;
@@ -1060,7 +1038,6 @@ public class ServiceChargeAllocationUI extends ToftPanel {
 				arrassvo.add(assvos[0]);
 				itemVO.setAss((AssVO[]) arrassvo.toArray(new AssVO[0]));
 				itemarr.add(itemVO);
-
 			} else if ("其他应收款/个人往来".equals(key)) {
 				km_code = "122102";// 其他应收款/个人往来
 				debitamount = entry.getValue();// 借方发生额
@@ -1077,7 +1054,6 @@ public class ServiceChargeAllocationUI extends ToftPanel {
 					itemVO.setAss((AssVO[]) arrassvo.toArray(new AssVO[0]));
 					// itemarr.add(itemVO);
 				}
-
 			} else if ("应付账款/预估成本/办公费".equals(key)) {
 				km_code = "22020205";// 应付账款/预估成本/办公费
 				debitamount = entry.getValue();// 借方发生额
@@ -1094,7 +1070,6 @@ public class ServiceChargeAllocationUI extends ToftPanel {
 				arrassvo.add(assvos2[0]);
 				itemVO.setAss((AssVO[]) arrassvo.toArray(new AssVO[0]));
 				// itemarr.add(itemVO);// 姜艳由部门全额代缴,个人不承担分摊费
-
 			} else if ("其他应收款/单位往来".equals(key)) {
 				km_code = "122101";// 其他应收款/单位往来
 				debitamount = entry.getValue();// 借方发生额
@@ -1107,16 +1082,15 @@ public class ServiceChargeAllocationUI extends ToftPanel {
 				arrassvo.add(assvos[0]);
 				itemVO.setAss((AssVO[]) arrassvo.toArray(new AssVO[0]));
 				itemarr.add(itemVO);
-
-				// }else if("应交税费".equals(key)){
-				// km_code= "2221010101";//应交税费/应交增值税/进项税额/认证抵扣
-				// debitamount = entry.getValue();//借方发生额
-				// pk_accasoa= tranKm(km_code, pk_accountGlbook);//科目
-				// DetailVO itemVO = new DetailVO();
-				// getDetailvo(itemVO, pk_accasoa, creditamount, debitamount, voucher, period+"人事代理服务费");
-				// itemarr.add(itemVO);
-
-			} else if ("预付账款/贷方".equals(key)) {
+			}
+			// else if("应交税费".equals(key)){
+			// km_code= "2221010101";//应交税费/应交增值税/进项税额/认证抵扣
+			// debitamount = entry.getValue();//借方发生额
+			// pk_accasoa= tranKm(km_code, pk_accountGlbook);//科目
+			// DetailVO itemVO = new DetailVO();
+			// getDetailvo(itemVO, pk_accasoa, creditamount, debitamount, voucher, period+"人事代理服务费");
+			// itemarr.add(itemVO);
+			else if ("预付账款/贷方".equals(key)) {
 				// km_code= "220201";
 				km_code = "112301";// 预付账款/待摊费用
 				creditamount = entry.getValue();// 贷方发生额
@@ -1134,22 +1108,17 @@ public class ServiceChargeAllocationUI extends ToftPanel {
 				itemarr.add(itemVO);
 			}
 		}
-
 		voucher.setDetails((DetailVO[]) itemarr.toArray(new DetailVO[0]));
-
 		return voucher;
-
 	}
 
 	private DetailVO getDetailvo(DetailVO itemVO, String pk_accasoa, UFDouble creditamount, UFDouble debitamount, VoucherVO voucher, String explanation) throws BusinessException {
-
 		String pk_currtype = getcurrtype("CNY");// 币种
 		itemVO.setPk_accasoa(pk_accasoa);// 会计科目
 		itemVO.setCreditamount(creditamount);// 贷方
 		itemVO.setCreditquantity(UFDouble.ZERO_DBL);// 数量
 		itemVO.setDebitamount(debitamount);// 借方
 		itemVO.setDirection("D");// 方向
-
 		itemVO.setDebitquantity(UFDouble.ZERO_DBL);
 		// itemVO.setDetailindex(Integer.parseInt(detailno));
 		itemVO.setDiscardflag(UFBoolean.FALSE);
@@ -1178,15 +1147,11 @@ public class ServiceChargeAllocationUI extends ToftPanel {
 		itemVO.setPk_unit(voucher.getPk_org());
 		itemVO.setPk_unit_v(voucher.getPk_org_v());
 		itemVO.setPk_currtype(pk_currtype);// 币种
-
 		return itemVO;
-
 	}
 
 	private AssVO[] getAss(String pk_km, String code1, String pk_checkvalue1, String pk_org) throws ClassNotFoundException, BusinessException {
-
 		ArrayList zrr = new ArrayList();
-
 		String sql = "select c.pk_accasoa,\n" + "       c.pk_accchart,\n" + "       c.pk_account,\n" + "       c.name,\n" + "       c.dispname,\n" + "       a.refnodename,\n" + "\n"
 				+ "       a.code,\n" + "       a.name,\n" + "       a.refnodename,\n" + "       m.defaulttablename,\n" + "       m.id,\n" + "       a.  pk_accassitem  ,  m.fullclassname  "
 				+ "  from bd_accassitem a, bd_accass b, bd_accasoa c, md_class m\n" + " where a.classid = m.id\n" + "   and a.pk_accassitem = b.pk_entity\n" + "   and b.pk_accasoa = c.pk_accasoa\n"
@@ -1200,19 +1165,15 @@ public class ServiceChargeAllocationUI extends ToftPanel {
 		if (ass_arr != null) {
 			for (int j = 0; j < ass_arr.size(); j++) {
 				HashMap assmap = (HashMap) ass_arr.get(j);
-
 				String getRefnodename = assmap.get("refnodename") + "";
-
 				String fullclassname = assmap.get("fullclassname") + "";
 				SuperVO refvo = initSuperVOClass(Class.forName(fullclassname));
-
 				String qrykey = "code";
 				if ("项目".equals(getRefnodename)) {
 					qrykey = "project_code";
 				} else if ("部门".equals(getRefnodename)) {
 					qrykey = "name";
 				}
-
 				String refsql = "select * from   " + refvo.getTableName() + " where  nvl(dr,0) = 0   and ( " + qrykey + "  ='" + pk_checkvalue1 + "'  or " + refvo.getPKFieldName() + " = '"
 						+ pk_checkvalue1 + "' )";
 				if (refvo.getTableName().equals("org_dept")) {
@@ -1231,15 +1192,11 @@ public class ServiceChargeAllocationUI extends ToftPanel {
 								+ pk_checkvalue1 + "' )  " + "and  pk_defdoclist =(select pk_defdoclist from  bd_defdoclist  where   code = '14' )     ";
 					}
 				}
-
 				SuperVO dataVO = (SuperVO) iuap.executeQuery(refsql, new BeanProcessor(Class.forName(fullclassname)));
-
 				if (dataVO == null) {
 					throw new BusinessException("辅助核算翻译失败:" + pk_checkvalue1);
 				}
-
 				AssVO tempAss = new AssVO();
-
 				String pk_checkvalue = dataVO.getPrimaryKey();
 				String code = "";
 				if ("项目".equals(getRefnodename)) {
@@ -1247,7 +1204,6 @@ public class ServiceChargeAllocationUI extends ToftPanel {
 				} else {
 					code = dataVO.getAttributeValue("code") + "";
 				}
-
 				if ("".equals(getRefnodename)) {
 					// 说明是基本类型,则直接当作字符串保存
 					tempAss.setPk_Checkvalue(code);
@@ -1258,11 +1214,9 @@ public class ServiceChargeAllocationUI extends ToftPanel {
 					tempAss.setPk_Checktype(assmap.get("pk_accassitem") + "");
 					tempAss.setChecktypecode(assmap.get("code") + "");
 					tempAss.setChecktypename(assmap.get("name") + "");
-
 					if ("项目".equals(getRefnodename)) {
 						tempAss.setCheckvaluename(dataVO.getAttributeValue("project_name") + "");
 					} else {
-
 						tempAss.setCheckvaluename(dataVO.getAttributeValue("name") + "");
 					}
 					tempAss.setPk_Checkvalue(pk_checkvalue);
@@ -1335,7 +1289,6 @@ public class ServiceChargeAllocationUI extends ToftPanel {
 		String sql = "select  pk_vouchertype     from  bd_vouchertype  where  code   = ? and nvl(dr,0) = 0 ";
 		SQLParameter parameter = new SQLParameter();
 		parameter.addParam(pk);
-
 		Object pk_vouchertype = iuap.executeQuery(sql, parameter, new ColumnProcessor());
 		return pk_vouchertype != null ? pk_vouchertype + "" : "";
 
@@ -1343,17 +1296,13 @@ public class ServiceChargeAllocationUI extends ToftPanel {
 
 	/**
 	 * 财务组织版本
-	 * 
 	 */
-
 	private String getPkorgv(String pk) throws BusinessException {
 		String sql = "select   pk_vid    from  org_financeorg_v  where   pk_financeorg    = ? and nvl(dr,0) = 0 ";
 		SQLParameter parameter = new SQLParameter();
 		parameter.addParam(pk);
-
 		Object pk_vid = iuap.executeQuery(sql, parameter, new ColumnProcessor());
 		return pk_vid != null ? pk_vid + "" : "";
-
 	}
 
 	/**
@@ -1396,7 +1345,6 @@ public class ServiceChargeAllocationUI extends ToftPanel {
 
 	// 员工编号查询人员编码
 	private String psndocCode(String clerkcode) throws BusinessException {
-
 		String sql = "select bd_psndoc.code from  hi_psnjob " + "inner join bd_psndoc on bd_psndoc.pk_psndoc=hi_psnjob.pk_psndoc " + "and nvl(hi_psnjob.dr,0)=0 and nvl(bd_psndoc.dr,0)=0 "
 				+ "and hi_psnjob.clerkcode='" + clerkcode + "'  ";
 		Object code = (String) iuap.executeQuery(sql, new ColumnProcessor());
@@ -1404,21 +1352,15 @@ public class ServiceChargeAllocationUI extends ToftPanel {
 	}
 
 	private String getPk_financeorg(String code) throws BusinessException {
-
 		String sql = "select pk_financeorg  from  org_financeorg  where code='" + code + "' and nvl(dr,0)=0 and enablestate ='2' ";
-
 		Object pk_financeorg = (String) iuap.executeQuery(sql, new ColumnProcessor());
 		return pk_financeorg != null ? pk_financeorg + "" : "";
-
 	}
 
 	private String getpk_user(String code) throws BusinessException {
-
 		String sql = "select cuserid   from  sm_user  where user_code='" + code + "' and nvl(dr,0)=0 and enablestate ='2' ";
-
 		Object cuserid = (String) iuap.executeQuery(sql, new ColumnProcessor());
 		return cuserid != null ? cuserid + "" : "";
-
 	}
 
 	// 日期格式转字符串
@@ -1429,7 +1371,6 @@ public class ServiceChargeAllocationUI extends ToftPanel {
 		calendar.set(Calendar.DAY_OF_MONTH, calendar.getActualMaximum(Calendar.DAY_OF_MONTH));
 		Date first = calendar.getTime();
 		return convertDateToString(first, "yyyy-MM-dd");
-
 	}
 
 	// 获取下个月最后一天

+ 76 - 143
hr/hr/src/client/nc/ui/hr/baod_orders/view/SocialInsuranceAllocationUI.java

@@ -26,7 +26,7 @@ import javax.swing.table.DefaultTableCellRenderer;
 import javax.swing.table.DefaultTableModel;
 import javax.swing.table.TableCellRenderer;
 
-import nc.bs.arap.plugin.GetDataUtil;
+import nc.bs.hr.plugin.GetDataUtil;
 import nc.bs.framework.common.InvocationInfoProxy;
 import nc.bs.framework.common.NCLocator;
 import nc.desktop.ui.WorkbenchEnvironment;
@@ -40,6 +40,7 @@ import nc.jdbc.framework.processor.ColumnListProcessor;
 import nc.jdbc.framework.processor.ColumnProcessor;
 import nc.jdbc.framework.processor.MapListProcessor;
 import nc.jdbc.framework.processor.MapProcessor;
+import nc.log.NcLog;
 import nc.ui.pub.ButtonObject;
 import nc.ui.pub.ToftPanel;
 import nc.ui.pub.beans.MessageDialog;
@@ -123,11 +124,23 @@ public class SocialInsuranceAllocationUI extends ToftPanel {
 	}
 
 	public void initialize() {
-		setLayout(new BorderLayout());
-		add(getUIPanel0(), BorderLayout.NORTH);
-		add(getUIPanel2(), BorderLayout.CENTER);
-		add(getUIPanel4(), BorderLayout.SOUTH);
-		setButtons(new ButtonObject[] { this.bt_query, this.bt_insert, this.bt_update, this.bt_output, this.bt_voucher, this.bt_linkvouchar, this.bt_arrecbill });// 添加按钮
+		try {
+			setLayout(new BorderLayout());
+			add(getUIPanel0(), BorderLayout.NORTH);
+			add(getUIPanel2(), BorderLayout.CENTER);
+			add(getUIPanel4(), BorderLayout.SOUTH);
+			String cuserid = InvocationInfoProxy.getInstance().getUserId();
+			String roleCode = GetDataUtil.powerRole(cuserid);
+			if("GJJ_HR001".equals(roleCode)) {
+				setButtons(new ButtonObject[] { this.bt_query, this.bt_output, this.bt_voucher, this.bt_linkvouchar, this.bt_arrecbill });// 添加按钮
+			}else if("GJJ_CW001".equals(roleCode)){
+				setButtons(new ButtonObject[] { this.bt_query, this.bt_insert, this.bt_update, this.bt_output });// 添加按钮
+			}else {
+				setButtons(new ButtonObject[] { this.bt_query, this.bt_insert, this.bt_update, this.bt_output, this.bt_voucher, this.bt_linkvouchar, this.bt_arrecbill });// 添加按钮
+			}
+		} catch (Exception e) {
+			MessageDialog.showHintDlg(this, "提示", e.getMessage());
+		}
 	}
 
 	private UILabel getOrgLabel() {
@@ -149,7 +162,6 @@ public class SocialInsuranceAllocationUI extends ToftPanel {
 			// 权限组织
 			String[] pkorgs = FunctionPermProfileManager.getInstance().getProfile(WorkbenchEnvironment.getInstance().getLoginUser().getUser_code()).getFuncSubInfo(nodeCode).getFuncPermissionPkorgs();
 			this.ivjOrgPanel.getRefModel().setFilterPks(pkorgs);
-
 			this.ivjOrgPanel.setBounds(new Rectangle(100, 20));
 			this.ivjOrgPanel.setPreferredSize(new Dimension(170, 20));
 			// this.ivjOrgPanel.setMultiSelectedEnabled(true);
@@ -259,7 +271,6 @@ public class SocialInsuranceAllocationUI extends ToftPanel {
 				this.ivjTablePanel.setName("TablePanel");
 				this.ivjTablePanel.setLayout(new CardLayout());
 			} catch (Throwable ivjExc) {
-
 			}
 		}
 		return this.ivjTablePanel;
@@ -301,20 +312,15 @@ public class SocialInsuranceAllocationUI extends ToftPanel {
 				onoutput();
 			} else if ("bt_linkvouchar".equals(bt.getCode())) {
 				String pkvouchersql = "select voucher_pk from voucher_flag where tablename='社保分摊表' and orgcode='" + orgCode + "' and period='" + period + "' and nvl(dr,0)=0 ";
-
 				Object voucher_pk = iuap.executeQuery(pkvouchersql, new ColumnProcessor());
-
 				if (null != voucher_pk) {
 					String sqlvoucher = "select num from gl_voucher where pk_voucher='" + voucher_pk + "' ";
 					Object vouchernum = iuap.executeQuery(sqlvoucher, new ColumnProcessor());
 					if (null != vouchernum) {
-
 						VoucherVO[] aggvos = GLPubProxy.getRemoteVoucher().queryByPks(new String[] { voucher_pk.toString() });
-
 						BillLinkOneNodeCenter.linkQuery_Dialog(this, "C0", new String[] { voucher_pk.toString() }, aggvos, true);
 					}
 				}
-
 			} else if ("bt_voucher".equals(bt.getCode())) {
 				String pkvouchersql = "select voucher_pk from voucher_flag where tablename='社保分摊表' and orgcode='" + orgCode + "' and period='" + period + "' and nvl(dr,0)=0 ";
 				Object voucher_pk = iuap.executeQuery(pkvouchersql, new ColumnProcessor());
@@ -333,7 +339,6 @@ public class SocialInsuranceAllocationUI extends ToftPanel {
 				// 组装生成凭证数据
 				Map<String, UFDouble> voucheramount = getVoucherAmount(getTablePanel());
 				VoucherVO voucher = getVoucherVO(voucheramount);
-
 				for (DetailVO detail : voucher.getDetails()) {
 					if (detail.getAss() != null && detail.getAss().length > 0) {
 						String assIDs = GLPubProxy.getRemoteFreevaluePub().getAssID_RequiresNew(detail.getAss(), false, "", InvocationInfoProxy.getInstance().getGroupId(), Module.GL);
@@ -341,7 +346,6 @@ public class SocialInsuranceAllocationUI extends ToftPanel {
 					}
 				}
 				OperationResultVO[] rs = GLPubProxy.getRemoteVoucher().save((VoucherVO) voucher, new Boolean(true));
-
 				// 保存已经生成凭证的标识pk
 				String pk = rs[0].m_strPK;
 				StringBuilder insertSQL = new StringBuilder("insert into voucher_flag (TABLENAME, ORGCODE, PERIOD,  VOUCHER_PK) values (");
@@ -350,7 +354,6 @@ public class SocialInsuranceAllocationUI extends ToftPanel {
 				insertSQL.append("'").append(period).append("', ");
 				insertSQL.append("'").append(pk).append("'); ");
 				siaMaintain.executeBaseDAO(insertSQL.toString());
-
 				MessageDialog.showHintDlg(this, "提示", "凭证已生成");
 			} else if ("bt_arrecbill".equals(bt.getCode())) {
 				// 验证内部应收是否存在
@@ -361,13 +364,12 @@ public class SocialInsuranceAllocationUI extends ToftPanel {
 				}
 				MessageDialog.showHintDlg(this, "", "生成内部应收单开始");
 				// 组装应收单数据新增应收单
-				addReceivableBill(getTablePanel());
-
-				MessageDialog.showHintDlg(this, "提示", "内部应收单已生成");
-
+				String billNO = addReceivableBill(getTablePanel());
+				MessageDialog.showHintDlg(this, "提示", "内部应收单已生成 " + billNO);
 			}
 		} catch (Exception e) {
 			e.printStackTrace();
+			NcLog.info(e.getMessage());
 			MessageDialog.showHintDlg(this, "提示", e.getMessage());
 		}
 	}
@@ -475,7 +477,6 @@ public class SocialInsuranceAllocationUI extends ToftPanel {
 		};
 		tablepanel.getTable().setModel(model);
 		tablepanel.getTable().setColumnWidth(new int[] { 300, 150, 150, 280, 150, 150, 190, 190, 160 });
-
 		TableCellRenderer renderer = new DefaultTableCellRenderer() {
 			@Override
 			public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
@@ -515,7 +516,6 @@ public class SocialInsuranceAllocationUI extends ToftPanel {
 			String orgMoney = null;
 			// orgName可能存在为空的情况,拼接的时候会把null拼接到新的字符串,使用三目运算处理改问题
 			String combinedField = title + (orgName == null ? "" : orgName) + clerkcode + clerkname;
-
 			// 取中间表数据
 			Map<String, String> middleTableMap = middleTableData.get(combinedField);
 			// middleTableMap为空表示中间表为空,使用原始数据,不为空使用中间表数据
@@ -556,7 +556,6 @@ public class SocialInsuranceAllocationUI extends ToftPanel {
 	 * @param ListMap
 	 */
 	private Map<String, UFDouble> addTableToList(String str, List<Object[]> dataList, String title, List<Map<String, String>> ListMap) {
-
 		if ("表四:个人部分已在集团内其他公司扣除".equals(title)) {
 			tableFourSelfMap = new HashMap<String, UFDouble>();
 		}
@@ -569,7 +568,6 @@ public class SocialInsuranceAllocationUI extends ToftPanel {
 		if ("表七:实际未缴当月工资个人部分已扣".equals(title)) {
 			tableSevenSelfMap = new HashMap<String, UFDouble>();
 		}
-
 		dataList.add(new Object[] { title });
 		dataList.add(subheading);
 		Map<String, UFDouble> MapMoney = new HashMap<String, UFDouble>();
@@ -637,7 +635,6 @@ public class SocialInsuranceAllocationUI extends ToftPanel {
 					afterPsgMoney.put(clerkcode, mapMoney);
 				}
 			}
-
 			// 统计合计
 			staffTotal = staffTotal.add(staffMoney);
 			orgTotal = orgTotal.add(orgMoney);
@@ -662,13 +659,11 @@ public class SocialInsuranceAllocationUI extends ToftPanel {
 				if ("表七:实际未缴当月工资个人部分已扣".equals(title)) {
 					tableSevenSelfMap.put(clerkcode + "," + clerkname, staffMoney);
 				}
-
 				if ("表三:由部门承担或全额公司承担".equals(title)) {
 					if (clerkname.equals("姜艳")) {
 						jiangyanOrg = orgMoney;
 					}
 				}
-
 				// 统计小计
 				staffSubtotal = staffSubtotal.add(staffMoney);
 				orgSubtotal = orgSubtotal.add(orgMoney);
@@ -694,7 +689,6 @@ public class SocialInsuranceAllocationUI extends ToftPanel {
 			} else {
 				// 输出行数据
 				dataList.add(new Object[] { i + 1, clerkcode, clerkname, basicsMoney, staffMoney, orgMoney, mark, str });
-
 				if ("表一:由个人承担".equals(title)) {
 					tableOneOrgMap.put(clerkcode + "," + clerkname, orgMoney);
 				}
@@ -1074,10 +1068,9 @@ public class SocialInsuranceAllocationUI extends ToftPanel {
 	}
 
 	/**
-	 * 获取修改数据打开修改界面
+	 * 获取修改数据打开修改界面 修改数据
 	 * 
 	 * @param table
-	 *            修改数据
 	 */
 	private void update(UITablePane table) {
 		try {
@@ -1132,9 +1125,7 @@ public class SocialInsuranceAllocationUI extends ToftPanel {
 	 * @param tablepane
 	 */
 	private Map<String, UFDouble> getVoucherAmount(UITablePane tablepane) {
-
 		Map<String, UFDouble> map = new LinkedHashMap<String, UFDouble>();
-
 		// 表一 个人承担-公司部分合计
 		Object objgs = tablepane.getTable().getValueAt(2, 2);
 		// 表一 个人承担-个人部分合计
@@ -1205,50 +1196,41 @@ public class SocialInsuranceAllocationUI extends ToftPanel {
 		// 金额=表四 个人部分合计
 		UFDouble bsgr = objbsgr == null ? UFDouble.ZERO_DBL : new UFDouble(objbsgr.toString());// 20385.96
 
-		/**
-		 * 生成的凭证自动加一行借方数据,等于管理费用/社会保险费/部门:其他虚拟财务与应付账款/预估成本/办公费/部门:合计值 借方:应付职工薪酬/社会保险费
-		 **/
+		/** 生成的凭证自动加一行借方数据,等于管理费用/社会保险费/部门:其他虚拟财务与应付账款/预估成本/办公费/部门:合计值 借方:应付职工薪酬/社会保险费 **/
 		// 金额=管理费用/社会保险费+应付账款/预估成本/办公费
 		UFDouble shbxfj = sbcmpamout.add(jiangyanOrg);
 
 		/** 贷方: 预付账款/待摊费用/待摊事项:社保摊销 **/
 		// 金额=社保分摊表金额
 		UFDouble jsibcomount = objsibco == null ? UFDouble.ZERO_DBL : new UFDouble(objsibco.toString());
-
+		// 金额=社保分摊表金额扣除内部往来
+		UFDouble xjsibcomount = jsibcomount.sub(bsgr);
 		/** 贷方: 其他应收款/个人往来 **/
 		// 金额=表七个人部分合计
 		UFDouble bqgrmx = objbqgr == null ? UFDouble.ZERO_DBL : new UFDouble(objbqgr.toString());
 
-		/**
-		 * 生成的凭证自动加一行借方数据,等于管理费用/社会保险费/部门:其他虚拟财务与应付账款/预估成本/办公费/部门:合计值 贷方:应付职工薪酬/社会保险费
-		 **/
+		/** 生成的凭证自动加一行借方数据,等于管理费用/社会保险费/部门:其他虚拟财务与应付账款/预估成本/办公费/部门:合计值 贷方:应付职工薪酬/社会保险费 **/
 		// 金额=管理费用/社会保险费+应付账款/预估成本/办公费
 		UFDouble shbxfd = sbcmpamout.add(jiangyanOrg);
 
-		// 借方合计 3316310.41
 		map.put("管理费用/社会保险费", sbcmpamout);
 		map.put("管理费用/社会保险费/残疾", sbcmpamoutcj);
 		map.put("其他应收款/五险一金", bwbqhj);
 		map.put("其他应收款/个人往来", byblhj);
 		map.put("应付账款/预估成本/办公费", jiangyanOrg);
 		map.put("其他应收款/单位往来", wbgshj);
-		map.put("其他应收款/内部往来", bsgr);
+		// map.put("其他应收款/内部往来", bsgr);
 		map.put("应付职工薪酬/社会保险费", shbxfj);
-		map.put("预付账款/待摊费用/贷方", jsibcomount);
+		map.put("预付账款/待摊费用/贷方", xjsibcomount);
 		map.put("其他应收款/个人往来/贷方", bqgrmx);
 		map.put("应付职工薪酬/社会保险费/贷方", shbxfd);
-
 		return map;
-
 	}
 
 	// 凭证封装
 	public VoucherVO getVoucherVO(Map<String, UFDouble> map) throws Exception {
-
 		VoucherVO voucher = new VoucherVO();
-
 		String pk_org = getPk_financeorg(orgCode);
-
 		// 组织版本
 		String pk_group = InvocationInfoProxy.getInstance().getGroupId();// 集团
 		// String year = period.substring(0, 4);// 会计年度
@@ -1262,7 +1244,6 @@ public class SocialInsuranceAllocationUI extends ToftPanel {
 		String pk_accountGlbook = tran_accountingbook(pk_org);// 核算账簿
 		String pk_vouchertype = vouchertypeGetCode("03");// 凭证类型03;
 		String pk_org_v = getPkorgv(pk_org);
-
 		voucher.setPk_vouchertype(pk_vouchertype);// 记账凭证
 		voucher.setAttachment(0);
 		voucher.setDetailmodflag(UFBoolean.TRUE);
@@ -1285,11 +1266,8 @@ public class SocialInsuranceAllocationUI extends ToftPanel {
 		voucher.setPk_org_v(pk_org_v);
 		voucher.setPk_group(pk_group);
 		voucher.setPk_accountingbook(pk_accountGlbook);
-
 		ArrayList<DetailVO> itemarr = new ArrayList<DetailVO>();
-
 		for (Entry<String, UFDouble> entry : map.entrySet()) {
-
 			String key = entry.getKey();
 			String km_code = "";
 			UFDouble creditamount = UFDouble.ZERO_DBL;
@@ -1307,7 +1285,6 @@ public class SocialInsuranceAllocationUI extends ToftPanel {
 				arrassvo.add(assvos[0]);
 				itemVO.setAss((AssVO[]) arrassvo.toArray(new AssVO[0]));
 				itemarr.add(itemVO);
-
 			} else if ("管理费用/社会保险费/残疾".equals(key)) {
 				km_code = "660203";// 管理费用/社会保险费
 				debitamount = entry.getValue();// 借方发生额
@@ -1320,7 +1297,6 @@ public class SocialInsuranceAllocationUI extends ToftPanel {
 				arrassvo.add(assvos[0]);
 				itemVO.setAss((AssVO[]) arrassvo.toArray(new AssVO[0]));
 				itemarr.add(itemVO);
-
 			} else if ("其他应收款/五险一金".equals(key)) {
 				km_code = "122104";// 其他应收款/五险一金
 				debitamount = entry.getValue();// 借方发生额
@@ -1328,7 +1304,6 @@ public class SocialInsuranceAllocationUI extends ToftPanel {
 				DetailVO itemVO = new DetailVO();
 				getDetailvo(itemVO, pk_accasoa, creditamount, debitamount, voucher, "缴纳" + year + "年" + month + "月 社保");
 				itemarr.add(itemVO);
-
 			} else if ("其他应收款/个人往来".equals(key)) {
 				km_code = "122102";// 其他应收款/个人往来
 				debitamount = entry.getValue();// 借方发生额
@@ -1354,7 +1329,6 @@ public class SocialInsuranceAllocationUI extends ToftPanel {
 					}
 					UFDouble debitamounttotal1 = debitamounttotal;
 				}
-
 				if (null != tableSixSelfMap) {// 表六 个人部分
 					UFDouble debitamounttotal = new UFDouble();
 					for (Entry<String, UFDouble> tableSixSelfEntry : tableSixSelfMap.entrySet()) {
@@ -1376,7 +1350,6 @@ public class SocialInsuranceAllocationUI extends ToftPanel {
 					}
 					UFDouble debitamounttotal1 = debitamounttotal;
 				}
-
 			} else if ("应付账款/预估成本/办公费".equals(key)) {
 				km_code = "22020205";// 应付账款/预估成本/办公费
 				debitamount = entry.getValue();// 借方发生额
@@ -1393,7 +1366,6 @@ public class SocialInsuranceAllocationUI extends ToftPanel {
 				arrassvo.add(assvos2[0]);
 				itemVO.setAss((AssVO[]) arrassvo.toArray(new AssVO[0]));
 				itemarr.add(itemVO);
-
 			} else if ("其他应收款/单位往来".equals(key)) {
 				km_code = "122101";// 其他应收款/单位往来
 				debitamount = entry.getValue();// 借方发生额
@@ -1406,40 +1378,39 @@ public class SocialInsuranceAllocationUI extends ToftPanel {
 				arrassvo.add(assvos[0]);
 				itemVO.setAss((AssVO[]) arrassvo.toArray(new AssVO[0]));
 				itemarr.add(itemVO);
-
-			} else if ("其他应收款/内部往来".equals(key)) {
-				// 取表四个人部分合计包含各个子公司,每个公司一条明细
-				km_code = "12210503";// 其他应收款/内部往来/代垫费用
-				debitamount = entry.getValue();// 借方发生额
-				pk_accasoa = tranKm(km_code, pk_accountGlbook);// 科目
-				if (null != tableFourSelfMap) {// 表四每个公司小计
-					UFDouble debitamounttotal = new UFDouble();
-					for (Entry<String, UFDouble> tableFourSelfEntry : tableFourSelfMap.entrySet()) {
-						String orgName = tableFourSelfEntry.getKey();
-						UFDouble debitamountOrg = tableFourSelfEntry.getValue();// 借方发生额
-						debitamounttotal = debitamounttotal.add(debitamountOrg);
-						if (debitamountOrg.doubleValue() != 0) {
-							DetailVO itemVO = new DetailVO();
-							getDetailvo(itemVO, pk_accasoa, creditamount, debitamountOrg, voucher, "缴纳" + year + "年" + month + "月 社保 ");
-							// 辅助核算
-							AssVO[] assvos = getAss(pk_accasoa, "0004", getbd_cust_supplier_code(orgName), pk_org);// 客商
-							ArrayList<AssVO> arrassvo = new ArrayList<AssVO>();
-							arrassvo.add(assvos[0]);
-							itemVO.setAss((AssVO[]) arrassvo.toArray(new AssVO[0]));
-							itemarr.add(itemVO);
-						}
-					}
-					UFDouble debitamounttotal1 = debitamounttotal;
-				}
-
-			} else if ("应付职工薪酬/社会保险费".equals(key)) {
+			}
+			// else if ("其他应收款/内部往来".equals(key)) {
+			// // 取表四个人部分合计包含各个子公司,每个公司一条明细
+			// km_code = "12210503";// 其他应收款/内部往来/代垫费用
+			// debitamount = entry.getValue();// 借方发生额
+			// pk_accasoa = tranKm(km_code, pk_accountGlbook);// 科目
+			// if (null != tableFourSelfMap) {// 表四每个公司小计
+			// UFDouble debitamounttotal = new UFDouble();
+			// for (Entry<String, UFDouble> tableFourSelfEntry : tableFourSelfMap.entrySet()) {
+			// String orgName = tableFourSelfEntry.getKey();
+			// UFDouble debitamountOrg = tableFourSelfEntry.getValue();// 借方发生额
+			// debitamounttotal = debitamounttotal.add(debitamountOrg);
+			// if (debitamountOrg.doubleValue() != 0) {
+			// DetailVO itemVO = new DetailVO();
+			// getDetailvo(itemVO, pk_accasoa, creditamount, debitamountOrg, voucher, "缴纳" + year + "年" + month + "月 社保 ");
+			// // 辅助核算
+			// AssVO[] assvos = getAss(pk_accasoa, "0004", getbd_cust_supplier_code(orgName), pk_org);// 客商
+			// ArrayList<AssVO> arrassvo = new ArrayList<AssVO>();
+			// arrassvo.add(assvos[0]);
+			// itemVO.setAss((AssVO[]) arrassvo.toArray(new AssVO[0]));
+			// itemarr.add(itemVO);
+			// }
+			// }
+			// UFDouble debitamounttotal1 = debitamounttotal;
+			// }
+			// }
+			else if ("应付职工薪酬/社会保险费".equals(key)) {
 				km_code = "221103";// 应付职工薪酬/社会保险费 无辅助核算
 				debitamount = entry.getValue();// 借方发生额
 				pk_accasoa = tranKm(km_code, pk_accountGlbook);// 科目
 				DetailVO itemVO = new DetailVO();
 				getDetailvo(itemVO, pk_accasoa, creditamount, debitamount, voucher, "缴纳" + year + "年" + month + "月 社保 ");
 				itemarr.add(itemVO);
-
 			} else if ("预付账款/待摊费用/贷方".equals(key)) {
 				// km_code = "220201";// 应付账款/实际应付款
 				km_code = "112301";// 预付账款/待摊费用
@@ -1454,7 +1425,6 @@ public class SocialInsuranceAllocationUI extends ToftPanel {
 				arrassvo.add(assvos[0]);
 				itemVO.setAss((AssVO[]) arrassvo.toArray(new AssVO[0]));
 				itemarr.add(itemVO);
-
 			} else if ("其他应收款/个人往来/贷方".equals(key)) {
 				km_code = "122102";// 其他应收款/个人往来
 				creditamount = entry.getValue();// 贷方发生额
@@ -1490,20 +1460,16 @@ public class SocialInsuranceAllocationUI extends ToftPanel {
 			}
 		}
 		voucher.setDetails((DetailVO[]) itemarr.toArray(new DetailVO[0]));
-
 		return voucher;
-
 	}
 
 	private DetailVO getDetailvo(DetailVO itemVO, String pk_accasoa, UFDouble creditamount, UFDouble debitamount, VoucherVO voucher, String explanation) throws BusinessException {
-
 		String pk_currtype = getcurrtype("CNY");// 币种
 		itemVO.setPk_accasoa(pk_accasoa);// 会计科目
 		itemVO.setCreditamount(creditamount);// 贷方
 		itemVO.setCreditquantity(UFDouble.ZERO_DBL);// 数量
 		itemVO.setDebitamount(debitamount);// 借方
 		itemVO.setDirection("D");// 方向
-
 		itemVO.setDebitquantity(UFDouble.ZERO_DBL);
 		itemVO.setDiscardflag(UFBoolean.FALSE);
 		itemVO.setExcrate1(UFDouble.ZERO_DBL);
@@ -1531,15 +1497,11 @@ public class SocialInsuranceAllocationUI extends ToftPanel {
 		itemVO.setPk_unit(voucher.getPk_org());
 		itemVO.setPk_unit_v(voucher.getPk_org_v());
 		itemVO.setPk_currtype(pk_currtype);// 币种
-
 		return itemVO;
-
 	}
 
 	private AssVO[] getAss(String pk_km, String code1, String pk_checkvalue1, String pk_org) throws ClassNotFoundException, BusinessException {
-
 		ArrayList zrr = new ArrayList();
-
 		String sql = "select c.pk_accasoa,\n" + "       c.pk_accchart,\n" + "       c.pk_account,\n" + "       c.name,\n" + "       c.dispname,\n" + "       a.refnodename,\n" + "\n"
 				+ "       a.code,\n" + "       a.name,\n" + "       a.refnodename,\n" + "       m.defaulttablename,\n" + "       m.id,\n" + "       a.  pk_accassitem  ,  m.fullclassname  "
 				+ "  from bd_accassitem a, bd_accass b, bd_accasoa c, md_class m\n" + " where a.classid = m.id\n" + "   and a.pk_accassitem = b.pk_entity\n" + "   and b.pk_accasoa = c.pk_accasoa\n"
@@ -1547,25 +1509,21 @@ public class SocialInsuranceAllocationUI extends ToftPanel {
 		if (code1 != null) {
 			sql += "  and   a.code = '" + code1 + "'  ";
 		}
-
-		; // 查询科目对应的辅助核算
+		;
+		// 查询科目对应的辅助核算
 		ArrayList ass_arr = (ArrayList) iuap.executeQuery(sql, new MapListProcessor());
 		if (ass_arr != null) {
 			for (int j = 0; j < ass_arr.size(); j++) {
 				HashMap assmap = (HashMap) ass_arr.get(j);
-
 				String getRefnodename = assmap.get("refnodename") + "";
-
 				String fullclassname = assmap.get("fullclassname") + "";
 				SuperVO refvo = initSuperVOClass(Class.forName(fullclassname));
-
 				String qrykey = "code";
 				if ("项目".equals(getRefnodename)) {
 					qrykey = "project_code";
 				} else if ("部门".equals(getRefnodename)) {
 					qrykey = "name";
 				}
-
 				String refsql = "select * from   " + refvo.getTableName() + " where  nvl(dr,0) = 0   and ( " + qrykey + "  ='" + pk_checkvalue1 + "'  or " + refvo.getPKFieldName() + " = '"
 						+ pk_checkvalue1 + "' )";
 				if (refvo.getTableName().equals("org_dept")) {
@@ -1584,15 +1542,11 @@ public class SocialInsuranceAllocationUI extends ToftPanel {
 								+ pk_checkvalue1 + "' )  " + "and  pk_defdoclist =(select pk_defdoclist from  bd_defdoclist  where   code = '14' )     ";
 					}
 				}
-
 				SuperVO dataVO = (SuperVO) iuap.executeQuery(refsql, new BeanProcessor(Class.forName(fullclassname)));
-
 				if (dataVO == null) {
 					throw new BusinessException("辅助核算翻译失败:" + pk_checkvalue1);
 				}
-
 				AssVO tempAss = new AssVO();
-
 				String pk_checkvalue = dataVO.getPrimaryKey();
 				String code = "";
 				if ("项目".equals(getRefnodename)) {
@@ -1600,8 +1554,6 @@ public class SocialInsuranceAllocationUI extends ToftPanel {
 				} else {
 					code = dataVO.getAttributeValue("code") + "";
 				}
-
-				//
 				if ("".equals(getRefnodename)) {
 					// 说明是基本类型,则直接当作字符串保存
 					tempAss.setPk_Checkvalue(code);
@@ -1609,28 +1561,21 @@ public class SocialInsuranceAllocationUI extends ToftPanel {
 					tempAss.setChecktypecode(assmap.get("code") + "");
 					tempAss.setChecktypename(assmap.get("name") + "");
 				} else {
-					//
 					tempAss.setPk_Checktype(assmap.get("pk_accassitem") + "");
 					tempAss.setChecktypecode(assmap.get("code") + "");
 					tempAss.setChecktypename(assmap.get("name") + "");
-
 					if ("项目".equals(getRefnodename)) {
 						tempAss.setCheckvaluename(dataVO.getAttributeValue("project_name") + "");
 					} else {
-
 						tempAss.setCheckvaluename(dataVO.getAttributeValue("name") + "");
 					}
-
 					tempAss.setPk_Checkvalue(pk_checkvalue);
 					tempAss.setCheckvaluecode(code);
-
 				}
-
 				if (tempAss != null && "".equals(tempAss.getPk_Checkvalue())) {
 					throw new BusinessException("辅助核算翻译失败:" + code);
 				}
 				zrr.add(tempAss);
-
 			}
 		} else {
 			return null;
@@ -1694,25 +1639,19 @@ public class SocialInsuranceAllocationUI extends ToftPanel {
 		String sql = "select  pk_vouchertype     from  bd_vouchertype  where  code   = ? and nvl(dr,0) = 0 ";
 		SQLParameter parameter = new SQLParameter();
 		parameter.addParam(pk);
-
 		Object pk_vouchertype = iuap.executeQuery(sql, parameter, new ColumnProcessor());
 		return pk_vouchertype != null ? pk_vouchertype + "" : "";
-
 	}
 
 	/**
 	 * 财务组织版本
-	 * 
 	 */
-
 	private String getPkorgv(String pk) throws BusinessException {
 		String sql = "select   pk_vid    from  org_financeorg_v  where   pk_financeorg    = ? and nvl(dr,0) = 0 ";
 		SQLParameter parameter = new SQLParameter();
 		parameter.addParam(pk);
-
 		Object pk_vid = iuap.executeQuery(sql, parameter, new ColumnProcessor());
 		return pk_vid != null ? pk_vid + "" : "";
-
 	}
 
 	/**
@@ -1727,7 +1666,6 @@ public class SocialInsuranceAllocationUI extends ToftPanel {
 				+ "   and bd_accasoa.pk_accchart =\n" + "       (select pk_accchart\n" + "           from bd_accchart\n" + "          where  originalchart =\n"
 				+ "                 (select pk_curraccchart\n" + "                    from org_accountingbook\n" + "                   where pk_accountingbook = ? and alterchart <> '~' and\n"
 				+ "           tempversionflag <> 'Y'));";
-
 		SQLParameter parameter = new SQLParameter();
 		parameter.addParam(km_code);
 		parameter.addParam(pk_accountingbook);
@@ -1756,7 +1694,6 @@ public class SocialInsuranceAllocationUI extends ToftPanel {
 	// 员工编号查询人员编码
 
 	private String psndocCode(String clerkcode) throws BusinessException {
-
 		String sql = "select bd_psndoc.code from  hi_psnjob " + "inner join bd_psndoc on bd_psndoc.pk_psndoc=hi_psnjob.pk_psndoc " + "and nvl(hi_psnjob.dr,0)=0 and nvl(bd_psndoc.dr,0)=0 "
 				+ "and hi_psnjob.clerkcode='" + clerkcode + "'  ";
 		Object code = (String) iuap.executeQuery(sql, new ColumnProcessor());
@@ -1764,31 +1701,22 @@ public class SocialInsuranceAllocationUI extends ToftPanel {
 	}
 
 	private String getPk_financeorg(String code) throws BusinessException {
-
 		String sql = "select pk_financeorg  from  org_financeorg  where code='" + code + "' and nvl(dr,0)=0 and enablestate ='2' ";
-
 		Object pk_financeorg = (String) iuap.executeQuery(sql, new ColumnProcessor());
 		return pk_financeorg != null ? pk_financeorg + "" : "";
-
 	}
 
 	private String getpk_user(String code) throws BusinessException {
-
 		String sql = "select cuserid   from  sm_user  where user_code='" + code + "' and nvl(dr,0)=0 and enablestate ='2' ";
-
 		Object cuserid = (String) iuap.executeQuery(sql, new ColumnProcessor());
 		return cuserid != null ? cuserid + "" : "";
-
 	}
 
 	// 根据客商名称查询客商编码
 	private String getbd_cust_supplier_code(String name) throws BusinessException {
-
 		String sql = "select code  from  bd_cust_supplier  where name='" + name + "' and nvl(dr,0)=0  ";
-
 		Object code = (String) iuap.executeQuery(sql, new ColumnProcessor());
 		return code != null ? code + "" : "";
-
 	}
 
 	// 日期格式转字符串
@@ -1799,7 +1727,6 @@ public class SocialInsuranceAllocationUI extends ToftPanel {
 		calendar.set(Calendar.DAY_OF_MONTH, calendar.getActualMaximum(Calendar.DAY_OF_MONTH));
 		Date first = calendar.getTime();
 		return convertDateToString(first, "yyyy-MM-dd");
-
 	}
 
 	// 获取下个月最后一天
@@ -1835,11 +1762,14 @@ public class SocialInsuranceAllocationUI extends ToftPanel {
 	}
 
 	/**
+	 * 
 	 * 生成内部应收单
 	 * 
 	 * @throws Exception
+	 * 
 	 */
-	private void addReceivableBill(UITablePane tablepane) throws Exception {
+	private String addReceivableBill(UITablePane tablepane) throws Exception {
+		String billNO = "";
 		Map<String, UFDouble> map = new LinkedHashMap<String, UFDouble>();
 		// 表四 个人部分已在集团内其他公司扣除-个人部分合计
 		Object objbsgr = tablepane.getTable().getValueAt(5, 2);
@@ -1856,6 +1786,7 @@ public class SocialInsuranceAllocationUI extends ToftPanel {
 			String pk_group = InvocationInfoProxy.getInstance().getGroupId();// 集团
 			String pk_user = InvocationInfoProxy.getInstance().getUserId();// 制单人
 			String pk_org_v = getPkorgv(pk_org);
+			receivableBillVO.setBillstatus(-1);
 			receivableBillVO.setPk_group(pk_group);
 			receivableBillVO.setPk_org(pk_org);
 			receivableBillVO.setPk_org_v(pk_org_v);
@@ -1871,7 +1802,8 @@ public class SocialInsuranceAllocationUI extends ToftPanel {
 			receivableBillVO.setPk_deptid(GetDataUtil.getDeptPK("000101205"));// 收款部门
 			receivableBillVO.setLocal_money(bsgr);// 合计金额--本币金额
 			receivableBillVO.setMoney(bsgr);// 原币金额
-			receivableBillVO.setRecaccount("310066218018000420123");// 收款银行账户
+			String pk_bankaccsub = GetDataUtil.getBankaccsubPK("310066218018000420123");
+			receivableBillVO.setRecaccount(pk_bankaccsub);// 收款银行账户
 			receivableBillVO.setPk_busitype(GetDataUtil.getBusitypePK("AR01"));// 业务流程:选择收款
 			receivableBillVO.setBillclass("ys");// 单据大类:应收单
 			String year = period.substring(0, 4);// 会计年度
@@ -1900,9 +1832,8 @@ public class SocialInsuranceAllocationUI extends ToftPanel {
 			receivableBillVO.setIsflowbill(UFBoolean.FALSE);// 是否流程单据
 			receivableBillVO.setIsreded(UFBoolean.FALSE);// 是否红冲过
 			aggReceivableBillVO.setParentVO(receivableBillVO);
-
 			List<ReceivableBillItemVO> listItemVO = new ArrayList<ReceivableBillItemVO>();
-			int rowNo=0;
+			int rowNo = 0;
 			for (Entry<String, UFDouble> tableFourSelfEntry : tableFourSelfMap.entrySet()) {
 				rowNo++;
 				String orgName = tableFourSelfEntry.getKey();// 公司名称
@@ -1916,9 +1847,9 @@ public class SocialInsuranceAllocationUI extends ToftPanel {
 					receivableBillItemVO.setPk_fiorg(pk_org);// 应收财务组织
 					receivableBillItemVO.setDef30("06");// 费用归属:06待摊费用"
 					receivableBillItemVO.setDef30(GetDataUtil.getDefdocPK("06", "05", "待摊费用"));
-					receivableBillItemVO.setDef26("S00009");// 收款摘要:S00009代垫费用
-					receivableBillItemVO.setDef29("060501");// 收款业务性质:060501不开票结算
-					receivableBillItemVO.setDef15("其他合同(财务专用)");// 经营合同名称
+					receivableBillItemVO.setDef26(GetDataUtil.getDefdocPK("S00009", "08", "代垫费用"));// 收款摘要:S00009代垫费用
+					receivableBillItemVO.setDef29(GetDataUtil.getDefdocPK("060501", "YS001", "不开票结算"));// 收款业务性质:060501不开票结算
+					receivableBillItemVO.setDef15(GetDataUtil.getDefdocPK("其他合同(财务专用)", "01", "其他合同(财务专用)"));// 经营合同名称
 					receivableBillItemVO.setDef16("其他合同(财务专用)");// 合同编号
 					receivableBillItemVO.setDef10(year + month + "社保个人部分");// 备注
 					String code = getbd_cust_supplier_code(orgName);// 根据名称查询code
@@ -1952,7 +1883,7 @@ public class SocialInsuranceAllocationUI extends ToftPanel {
 					receivableBillItemVO.setPk_balatype(GetDataUtil.getBalatypePK("12"));
 					receivableBillItemVO.setSendcountryid(pk_country);// 发货国
 					receivableBillItemVO.setBuysellflag(1);// 购销类型 1国内销售
-//					receivableBillItemVO.setConfernum("ARAP_0001A81000000000NVK0_D02024012200077450");// 内部交易结算号
+					// receivableBillItemVO.setConfernum("ARAP_0001A81000000000NVK0_D02024012200077450");// 内部交易结算号
 					receivableBillItemVO.setPk_billtype("F0");// 单据类型编码
 					receivableBillItemVO.setPk_deptid(GetDataUtil.getDeptPK("000101205"));// 部门
 					receivableBillItemVO.setPk_deptid_v(GetDataUtil.getDeptPK("000101205"));// 部门
@@ -1963,13 +1894,13 @@ public class SocialInsuranceAllocationUI extends ToftPanel {
 					receivableBillItemVO.setQuantity_bal(new UFDouble(1));// 数量余额
 					receivableBillItemVO.setQuantity_de(new UFDouble(1));// 借方数量
 					receivableBillItemVO.setRate(new UFDouble(1));// 组织本币税率
-					receivableBillItemVO.setRecaccount("310066218018000420123");// 收款银行账户
+					receivableBillItemVO.setRecaccount(pk_bankaccsub);// 收款银行账户
 					receivableBillItemVO.setRececountryid(pk_country);// 收货国
 					receivableBillItemVO.setSett_org(pk_org);// 结算财务组织
 					receivableBillItemVO.setSett_org_v(pk_org);// 结算财务组织版本
 					receivableBillItemVO.setTriatradeflag(UFBoolean.FALSE);// 三角贸易区
-					receivableBillItemVO.setSettlecurr(pk_currtype);//收款币种
-					receivableBillItemVO.setSettlemoney(debitamount);//收款金额
+					receivableBillItemVO.setSettlecurr(pk_currtype);// 收款币种
+					receivableBillItemVO.setSettlemoney(debitamount);// 收款金额
 					listItemVO.add(receivableBillItemVO);
 				}
 			}
@@ -1977,7 +1908,9 @@ public class SocialInsuranceAllocationUI extends ToftPanel {
 			// 调用应收单新增方法
 			IReceivableService receivableService = NCLocator.getInstance().lookup(IReceivableService.class);
 			AggReceivableBillVO aggvo = receivableService.receivable_RequiresNew(aggReceivableBillVO);
-
+			ReceivableBillVO headerVO = (ReceivableBillVO) aggvo.getParentVO();
+			billNO = headerVO.getBillno();
 		}
+		return billNO;
 	}
 }