|
|
@@ -13,10 +13,7 @@ import com.usoftchina.saas.commons.po.BillCodeSeq;
|
|
|
import com.usoftchina.saas.commons.po.Status;
|
|
|
import com.usoftchina.saas.context.BaseContextHolder;
|
|
|
import com.usoftchina.saas.exception.BizException;
|
|
|
-import com.usoftchina.saas.money.mapper.BanksubledgerMapper;
|
|
|
-import com.usoftchina.saas.money.mapper.OthspendingsMapper;
|
|
|
-import com.usoftchina.saas.money.mapper.OthspendingsdetailMapper;
|
|
|
-import com.usoftchina.saas.money.mapper.StatsinfoMapper;
|
|
|
+import com.usoftchina.saas.money.mapper.*;
|
|
|
import com.usoftchina.saas.money.po.*;
|
|
|
import com.usoftchina.saas.money.service.OthspendingsService;
|
|
|
import com.usoftchina.saas.page.PageRequest;
|
|
|
@@ -45,6 +42,12 @@ public class OthspendingsServiceImpl extends CommonBaseServiceImpl<OthspendingsM
|
|
|
private StatsinfoMapper statsinfoMapper;
|
|
|
@Autowired
|
|
|
private MessageLogService messageLogService;
|
|
|
+ @Autowired
|
|
|
+ private BankinformationMapper bankinformationMapper;
|
|
|
+ @Autowired
|
|
|
+ private SubledgerMapper subledgerMapper;
|
|
|
+ @Autowired
|
|
|
+ private PaybalanceMapper paybalanceMapper;
|
|
|
|
|
|
@Override
|
|
|
public DocBaseDTO insert(Othsp othsp) {
|
|
|
@@ -61,13 +64,21 @@ public class OthspendingsServiceImpl extends CommonBaseServiceImpl<OthspendingsM
|
|
|
Long id = othspendings.getId();
|
|
|
|
|
|
|
|
|
+ DocBaseDTO baseDTO = new DocBaseDTO();
|
|
|
if (othspendings.getId() > 0){
|
|
|
othspendingsMapper.updateByPrimaryKeySelective(othspendings);
|
|
|
+ baseDTO = getBaseDTOById(id);
|
|
|
+ //日志记录
|
|
|
+ messageLogService.update(baseDTO);
|
|
|
}else {
|
|
|
othspendings.setCompanyId(BaseContextHolder.getCompanyId());
|
|
|
othspendings.setOs_recorder(BaseContextHolder.getUserName());
|
|
|
othspendingsMapper.insertSelective(othspendings);
|
|
|
id = othspendings.getId();
|
|
|
+
|
|
|
+ baseDTO = getBaseDTOById(id);
|
|
|
+ //日志记录
|
|
|
+ messageLogService.save(baseDTO);
|
|
|
}
|
|
|
|
|
|
Iterator isdet = othspendingsdetails.iterator();
|
|
|
@@ -82,9 +93,6 @@ public class OthspendingsServiceImpl extends CommonBaseServiceImpl<OthspendingsM
|
|
|
othspendingsdetailMapper.insertSelective(othspendingsdetail);
|
|
|
}
|
|
|
}
|
|
|
- DocBaseDTO baseDTO = getBaseDTOById(id);
|
|
|
- //日志记录
|
|
|
- messageLogService.save(baseDTO);
|
|
|
return baseDTO;
|
|
|
}
|
|
|
|
|
|
@@ -94,7 +102,7 @@ public class OthspendingsServiceImpl extends CommonBaseServiceImpl<OthspendingsM
|
|
|
othspendingsdetailMapper.deleteItem(id);
|
|
|
DocBaseDTO baseDTO = getBaseDTOById(Long.valueOf(id));
|
|
|
//日志记录
|
|
|
- messageLogService.save(baseDTO);
|
|
|
+ messageLogService.delete(baseDTO);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -102,7 +110,7 @@ public class OthspendingsServiceImpl extends CommonBaseServiceImpl<OthspendingsM
|
|
|
othspendingsdetailMapper.deleteItem(id);
|
|
|
DocBaseDTO baseDTO = getBaseDTOById(Long.valueOf(id));
|
|
|
//日志记录
|
|
|
- messageLogService.save(baseDTO);
|
|
|
+ messageLogService.deleteDetail(baseDTO);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -149,6 +157,48 @@ public class OthspendingsServiceImpl extends CommonBaseServiceImpl<OthspendingsM
|
|
|
othspendings.getOs_bankcode(), "+");
|
|
|
}
|
|
|
|
|
|
+ //资金账号表
|
|
|
+ int bk_id = othspendings.getOs_bankid();
|
|
|
+
|
|
|
+ Double bk_amount = othspendings.getOs_amount();
|
|
|
+ //付款方
|
|
|
+ Bankinformation bankinformation = bankinformationMapper.selectByPrimaryKey(bk_id);
|
|
|
+ Double beginamount = bankinformation.getBk_beginamount();
|
|
|
+ Double spending = bankinformation.getBk_spending() == null ? new Double(0) : bankinformation.getBk_spending();
|
|
|
+ Double incomme = bankinformation.getBk_income() == null ? new Double(0) : bankinformation.getBk_income();
|
|
|
+ bankinformation.setBk_thisamount(beginamount + incomme - spending - bk_amount);
|
|
|
+ bankinformation.setBk_income(incomme);
|
|
|
+ bankinformation.setBk_spending(spending + bk_amount);
|
|
|
+
|
|
|
+ /**
|
|
|
+ * ve_preamount=nvl(ve_preamount,0)+pb_preamount,
|
|
|
+ * ve_payamount=nvl(ve_payamount,0)-pb_pbdamount,
|
|
|
+ * ve_leftamount=ve_beginapamount-ve_beginprepayamount+ve_payamount-ve_preamount;
|
|
|
+ */
|
|
|
+ Vendor vendorData = paybalanceMapper.selectVendorByPrimaryKey(othspendings.getOs_vendid());
|
|
|
+ Double preamount = vendorData.getVe_preamount()==null?new Double(0):vendorData.getVe_preamount();
|
|
|
+ Double beginapamount = vendorData.getVe_beginapamount()==null?new Double(0):vendorData.getVe_beginapamount();
|
|
|
+ Double beginprepayamount= vendorData.getVe_beginprepayamount()==null?new Double(0):vendorData.getVe_beginprepayamount();
|
|
|
+ Double payamount = vendorData.getVe_payamount()==null?new Double(0):vendorData.getVe_payamount();
|
|
|
+
|
|
|
+ Vendor vendor = new Vendor();
|
|
|
+ vendor.setId(Long.valueOf(othspendings.getOs_vendid()));
|
|
|
+ vendor.setVe_preamount(preamount);
|
|
|
+ vendor.setVe_payamount(payamount - bk_amount);
|
|
|
+ vendor.setVe_leftamount(beginapamount-beginprepayamount+payamount-bk_amount-preamount);
|
|
|
+ paybalanceMapper.updateVendorByPrimaryKeySelective(vendor);
|
|
|
+
|
|
|
+ //插入subledger中间表
|
|
|
+ Subledger subledger = new Subledger();
|
|
|
+ subledger.setSl_code(othspendings.getOs_code());
|
|
|
+ subledger.setSl_kind("其他支出单");
|
|
|
+ subledger.setSl_custid(0);
|
|
|
+ subledger.setSl_vendid(othspendings.getOs_vendid());
|
|
|
+ subledger.setSl_date(othspendings.getOs_date());
|
|
|
+ subledger.setSl_amount(bk_amount);
|
|
|
+ subledger.setCompanyId(BaseContextHolder.getCompanyId());
|
|
|
+ subledgerMapper.insertSelective(subledger);
|
|
|
+
|
|
|
//计算期间金额
|
|
|
Statsinfo statsinfo = new Statsinfo();
|
|
|
List<Integer> ymList = othspendingsdetailMapper.selectYm(Math.toIntExact(id));
|
|
|
@@ -165,7 +215,7 @@ public class OthspendingsServiceImpl extends CommonBaseServiceImpl<OthspendingsM
|
|
|
}
|
|
|
DocBaseDTO baseDTO = getBaseDTOById(id);
|
|
|
//日志记录
|
|
|
- messageLogService.save(baseDTO);
|
|
|
+ messageLogService.audit(baseDTO);
|
|
|
return baseDTO;
|
|
|
}
|
|
|
|
|
|
@@ -180,6 +230,7 @@ public class OthspendingsServiceImpl extends CommonBaseServiceImpl<OthspendingsM
|
|
|
//删除中间表
|
|
|
othspendings = othspendingsMapper.selectByPrimaryKey(id);
|
|
|
banksubledgerMapper.deleteByPrimaryKey(othspendings.getOs_code(), "其他收入单");
|
|
|
+ subledgerMapper.deleteByPrimaryKey(othspendings.getOs_code(), "其他支出单");
|
|
|
|
|
|
//资金
|
|
|
Double amount = banksubledgerMapper.selectThisamount(othspendings.getOs_bankcode());
|
|
|
@@ -192,6 +243,38 @@ public class OthspendingsServiceImpl extends CommonBaseServiceImpl<OthspendingsM
|
|
|
othspendings.getOs_bankcode(), "-");
|
|
|
}
|
|
|
|
|
|
+ //资金账号表
|
|
|
+ int bk_id = othspendings.getOs_bankid();
|
|
|
+
|
|
|
+ Double bk_amount = othspendings.getOs_amount();
|
|
|
+ //付款方
|
|
|
+ Bankinformation bankinformation = bankinformationMapper.selectByPrimaryKey(bk_id);
|
|
|
+ Double beginamount = bankinformation.getBk_beginamount();
|
|
|
+ Double spending = bankinformation.getBk_spending() == null ? new Double(0) : bankinformation.getBk_spending();
|
|
|
+ Double incomme = bankinformation.getBk_income() == null ? new Double(0) : bankinformation.getBk_income();
|
|
|
+ bankinformation.setBk_thisamount(beginamount + incomme - spending - bk_amount);
|
|
|
+ bankinformation.setBk_income(incomme);
|
|
|
+ bankinformation.setBk_spending(spending + bk_amount);
|
|
|
+
|
|
|
+ /**
|
|
|
+ * ve_preamount=nvl(ve_preamount,0)+pb_preamount,
|
|
|
+ * ve_payamount=nvl(ve_payamount,0)-pb_pbdamount,
|
|
|
+ * ve_leftamount=ve_beginapamount-ve_beginprepayamount+ve_payamount-ve_preamount;
|
|
|
+ */
|
|
|
+ Vendor vendorData = paybalanceMapper.selectVendorByPrimaryKey(othspendings.getOs_vendid());
|
|
|
+ Double preamount = vendorData.getVe_preamount()==null?new Double(0):vendorData.getVe_preamount();
|
|
|
+ Double beginapamount = vendorData.getVe_beginapamount()==null?new Double(0):vendorData.getVe_beginapamount();
|
|
|
+ Double beginprepayamount= vendorData.getVe_beginprepayamount()==null?new Double(0):vendorData.getVe_beginprepayamount();
|
|
|
+ Double payamount = vendorData.getVe_payamount()==null?new Double(0):vendorData.getVe_payamount();
|
|
|
+
|
|
|
+ Vendor vendor = new Vendor();
|
|
|
+ vendor.setId(Long.valueOf(othspendings.getOs_vendid()));
|
|
|
+ vendor.setVe_preamount(preamount);
|
|
|
+ vendor.setVe_payamount(payamount + bk_amount);
|
|
|
+ vendor.setVe_leftamount(beginapamount+beginprepayamount-payamount+bk_amount+preamount);
|
|
|
+ paybalanceMapper.updateVendorByPrimaryKeySelective(vendor);
|
|
|
+
|
|
|
+
|
|
|
//计算期间金额
|
|
|
Statsinfo statsinfo = new Statsinfo();
|
|
|
List<Integer> ymList = othspendingsdetailMapper.selectYm(id);
|
|
|
@@ -209,7 +292,7 @@ public class OthspendingsServiceImpl extends CommonBaseServiceImpl<OthspendingsM
|
|
|
|
|
|
DocBaseDTO baseDTO = getBaseDTOById(Long.valueOf(id));
|
|
|
//日志记录
|
|
|
- messageLogService.save(baseDTO);
|
|
|
+ messageLogService.unAudit(baseDTO);
|
|
|
}
|
|
|
|
|
|
@Override
|