//根据会计分录处理id找会计科目id(Tommy,2018-8-31)
Optional financeSubject = financeSubjectIDMapper.selectByUnitIdAndFinanceSub(String.valueOf( unitId ), Long.parseLong(String.valueOf(tFinanceDocumentEntrieListNew.get(j).getId())));
//会计分录处理映射表中的accountId
FinanceSubjectIDMapperExample example = new FinanceSubjectIDMapperExample();
FinanceSubjectIDMapperExample.Criteria criteria = example.createCriteria();
if (financeSubject.toString() != "[]"){
criteria.andFinanceSubIdEqualTo(String.valueOf(tFinanceDocumentEntrieListNew.get(j).getId()));
criteria.andUnitIdEqualTo(String.valueOf(unitId));
List financeSubjectIDMapperList = financeSubjectIDMapperService.selectByExample(example);
if (financeSubjectIDMapperList.size()>0){
FinanceVoucherSummary financeVoucherSummary = financeVoucherSummaryMapper.selectByDebitIdAndCreditId(financeSubjectIDMapperList.get(0).getAccountId(),tFinanceDocumentEntrieListNew.get(j).getDebitSubjectId(), financeSubjectIDMapperList.get(0).getAccountId(),tFinanceDocumentEntrieListNew.get(j).getCreditSubjectId());
//根据科目id和公司id查balanceid
if (financeVoucherSummary != null){
tDebitMoneySum = tDebitMoneySum.add(financeVoucherSummary.getDebitMoney());
tCreditMoneySum = tCreditMoneySum.add(financeVoucherSummary.getCreditMoney());
}
}
}
}
//函数调用判断会计分录是否平衡
BigDecimal a = Arith.compare(tDebitMoneySum, tCreditMoneySum);
if (a.doubleValue() != 0.0){
throw new BusinessException("科目余额为不平,请检查会计分录是否正确!");
}
}
/**
* 根据id获取并修改凭证
* @param request
* @return
* @throws Exception
*/
@RequestMapping(value = "/getFinanceVoucherById", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
public String getFinanceVoucherById(HttpServletRequest request) throws Exception {
Map map = new HashMap();
String message = "1";
String id = request.getParameter("id");
AuthPlatformUserInfo userInfo = userInfoUtils.getSimpleUserInfo(request);
if (userInfo == null) {
return "2";
}
String companyId = request.getParameter("companyId");
String month = request.getParameter("month");
if (StringUtils.isNotBlank(id)) {
FinanceVoucherExample example = new FinanceVoucherExample();
FinanceVoucherExample.Criteria criteria = example.createCriteria();
criteria.andIdEqualTo(Long.parseLong(id));
FinanceVoucher financeVoucher = financeVoucherMapper.selectByExample(example).get(0);
month = financeVoucher.getVoucherYearAndMonth();
companyId = String.valueOf(financeVoucher.getUnitId());
financeVoucher.setUpdateUser(userInfo.getName());
financeVoucherMapper.updateByPrimaryKey(financeVoucher);
//根据凭证id查询凭证明细
List financeVoucherDetailList = financeVoucherDetailMapper.selectByVoucherId(Long.parseLong(id));
map.put("financeVoucherDetailList",financeVoucherDetailList);
if (id.length() > 0){
//根据凭证明细id查凭证摘要
List financeVoucherSummaryList = financeVoucherSummaryMapper.selectByVoucherDetailId(Long.parseLong(id));
map.put("financeVoucherSummaryList", financeVoucherSummaryList);
}
}
//根据选择的月查询该月的所有凭证
FinanceVoucherExample financeVoucherExample = new FinanceVoucherExample();
FinanceVoucherExample.Criteria financeVoucherCriteria = financeVoucherExample.createCriteria();
financeVoucherCriteria.andVoucherYearAndMonthEqualTo(String.valueOf(month)).andUnitIdEqualTo(Long.parseLong(companyId));
List financeVoucherList = financeVoucherMapper.selectByExample(financeVoucherExample);
//排序排到最后
BookkeepingMode bookkeepingMode = new BookkeepingMode();
List financeVoucherListNew = bookkeepingMode.getSortVoucherList(financeVoucherList);
List financeVoucherListNew1 = new ArrayList();
if (financeVoucherListNew.size() >0) {
financeVoucherListNew1 = financeVoucherListNew.subList(0, financeVoucherListNew.size() - 1);
} else {
financeVoucherListNew1 = financeVoucherListNew;
}
map.put("financeVoucherList",financeVoucherListNew1);
message = WebUtil.getContent(map);
return message;
}
/**
* 根据凭证id修改凭证状态
* @param request
* @return
* @throws Exception
*/
@RequestMapping(value = "/updateFinanceVoucherStatus", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
public String updateFinanceVoucherStatus(HttpServletRequest request) throws Exception {
String message = "1";
String id = request.getParameter("voucherId");
if (id.length()>0){
AuthPlatformUserInfo userInfo = userInfoUtils.getSimpleUserInfo(request);
if (userInfo == null) {
return "2";
}
FinanceVoucher financeVoucher = new FinanceVoucher();
financeVoucher.setId(Long.parseLong(id));
financeVoucher.setCheckStatus((byte) 1);
financeVoucher.setCheckUser(userInfo.getName());
financeVoucherMapper.updateByPrimaryKeySelective(financeVoucher);
}
return message;
}
}
总结:以上是编辑:【麦穗】整理及AI智能原创关于《会计分录处理方式
》优质内容解答希望能帮助到您。