|
|
@@ -44,7 +44,6 @@ import org.springblade.los.finance.invoices.service.IFinInvoiceItemDetailService
|
|
|
import org.springblade.los.finance.invoices.service.IFinInvoicesItemsService;
|
|
|
import org.springblade.los.finance.invoices.service.IFinInvoicesService;
|
|
|
import org.springblade.los.finance.invoices.vo.FinInvoicesVO;
|
|
|
-import org.springblade.system.entity.Dept;
|
|
|
import org.springblade.system.feign.ISysClient;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
@@ -98,7 +97,7 @@ public class FinInvoicesServiceImpl extends ServiceImpl<FinInvoicesMapper, FinIn
|
|
|
public R submit(FinInvoices finInvoices) {
|
|
|
String deptId = "";
|
|
|
String deptName = "";
|
|
|
- String branchId = deptUtils.getDeptPid()+"";
|
|
|
+ String branchId = deptUtils.getDeptPid() + "";
|
|
|
//获取部门ids对应中文名
|
|
|
if (ObjectUtils.isNotNull(AuthUtil.getDeptId())) {
|
|
|
deptId = AuthUtil.getDeptId();
|
|
|
@@ -294,25 +293,33 @@ public class FinInvoicesServiceImpl extends ServiceImpl<FinInvoicesMapper, FinIn
|
|
|
finAccBills.setUpdateUser(AuthUtil.getUserId());
|
|
|
finAccBills.setUpdateTime(new Date());
|
|
|
finAccBills.setUpdateUserName(AuthUtil.getUserName());
|
|
|
- if ("CNY".equals(item.getCurCode())){
|
|
|
- if ("C".equals(finAccBills.getAccountDc())){
|
|
|
- if (item.getCurrentAmount().compareTo(finAccBills.getAmountCrLoc().subtract(finAccBills.getAppliedInvoiceAmount()).subtract(finAccBills.getUninvoicedAmount())) > 0) {
|
|
|
- throw new RuntimeException("本次开票金额大于未开票金额");
|
|
|
+ if ("CNY".equals(item.getCurCode())) {
|
|
|
+ if ("C".equals(finAccBills.getAccountDc())) {
|
|
|
+ if (ObjectUtils.isNull(item.getApplySrcId())) {
|
|
|
+ if (item.getCurrentAmount().compareTo(finAccBills.getAmountCrLoc().subtract(finAccBills.getAppliedInvoiceAmount()).subtract(finAccBills.getUninvoicedAmount())) > 0) {
|
|
|
+ throw new RuntimeException("本次开票金额大于未开票金额");
|
|
|
+ }
|
|
|
}
|
|
|
- }else{
|
|
|
- if (item.getCurrentAmount().compareTo(finAccBills.getAmountDrLoc().subtract(finAccBills.getAppliedInvoiceAmount()).subtract(finAccBills.getUninvoicedAmount())) > 0) {
|
|
|
- throw new RuntimeException("本次开票金额大于未开票金额");
|
|
|
+ } else {
|
|
|
+ if (ObjectUtils.isNull(item.getApplySrcId())) {
|
|
|
+ if (item.getCurrentAmount().compareTo(finAccBills.getAmountDrLoc().subtract(finAccBills.getAppliedInvoiceAmount()).subtract(finAccBills.getUninvoicedAmount())) > 0) {
|
|
|
+ throw new RuntimeException("本次开票金额大于未开票金额");
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
finAccBills.setUninvoicedAmount(finAccBills.getUninvoicedAmount().add(item.getCurrentAmount()));
|
|
|
- }else{
|
|
|
- if ("C".equals(finAccBills.getAccountDc())){
|
|
|
- if (item.getCurrentAmount().compareTo(finAccBills.getAmountCrLoc().subtract(finAccBills.getAppliedInvoiceAmountUsd()).subtract(finAccBills.getUninvoicedAmountUsd())) > 0) {
|
|
|
- throw new RuntimeException("本次开票金额大于未开票金额");
|
|
|
+ } else {
|
|
|
+ if ("C".equals(finAccBills.getAccountDc())) {
|
|
|
+ if (ObjectUtils.isNull(item.getApplySrcId())) {
|
|
|
+ if (item.getCurrentAmount().compareTo(finAccBills.getAmountCrLoc().subtract(finAccBills.getAppliedInvoiceAmountUsd()).subtract(finAccBills.getUninvoicedAmountUsd())) > 0) {
|
|
|
+ throw new RuntimeException("本次开票金额大于未开票金额");
|
|
|
+ }
|
|
|
}
|
|
|
- }else{
|
|
|
- if (item.getCurrentAmount().compareTo(finAccBills.getAmountDrLoc().subtract(finAccBills.getAppliedInvoiceAmountUsd()).subtract(finAccBills.getUninvoicedAmountUsd())) > 0) {
|
|
|
- throw new RuntimeException("本次开票金额大于未开票金额");
|
|
|
+ } else {
|
|
|
+ if (ObjectUtils.isNull(item.getApplySrcId())) {
|
|
|
+ if (item.getCurrentAmount().compareTo(finAccBills.getAmountDrLoc().subtract(finAccBills.getAppliedInvoiceAmountUsd()).subtract(finAccBills.getUninvoicedAmountUsd())) > 0) {
|
|
|
+ throw new RuntimeException("本次开票金额大于未开票金额");
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
finAccBills.setUninvoicedAmountUsd(finAccBills.getUninvoicedAmountUsd().add(item.getCurrentAmount()));
|
|
|
@@ -507,23 +514,23 @@ public class FinInvoicesServiceImpl extends ServiceImpl<FinInvoicesMapper, FinIn
|
|
|
finAccBills.setUpdateUser(AuthUtil.getUserId());
|
|
|
finAccBills.setUpdateTime(new Date());
|
|
|
finAccBills.setUpdateUserName(AuthUtil.getUserName());
|
|
|
- if ("CNY".equals(item.getCurCode())){
|
|
|
- if ("C".equals(finAccBills.getAccountDc())){
|
|
|
+ if ("CNY".equals(item.getCurCode())) {
|
|
|
+ if ("C".equals(finAccBills.getAccountDc())) {
|
|
|
if (item.getCurrentAmount().compareTo(finAccBills.getUninvoicedAmount()) > 0) {
|
|
|
throw new RuntimeException("本次开票金额大于已开票金额");
|
|
|
}
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
if (item.getCurrentAmount().compareTo(finAccBills.getUninvoicedAmount()) > 0) {
|
|
|
throw new RuntimeException("本次开票金额大于已开票金额");
|
|
|
}
|
|
|
}
|
|
|
finAccBills.setUninvoicedAmount(finAccBills.getUninvoicedAmount().subtract(item.getCurrentAmount()));
|
|
|
- }else{
|
|
|
- if ("C".equals(finAccBills.getAccountDc())){
|
|
|
+ } else {
|
|
|
+ if ("C".equals(finAccBills.getAccountDc())) {
|
|
|
if (item.getCurrentAmount().compareTo(finAccBills.getUninvoicedAmountUsd()) > 0) {
|
|
|
throw new RuntimeException("本次开票金额大于已开票金额");
|
|
|
}
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
if (item.getCurrentAmount().compareTo(finAccBills.getUninvoicedAmountUsd()) > 0) {
|
|
|
throw new RuntimeException("本次开票金额大于已开票金额");
|
|
|
}
|
|
|
@@ -580,25 +587,25 @@ public class FinInvoicesServiceImpl extends ServiceImpl<FinInvoicesMapper, FinIn
|
|
|
if (finAccBills == null) {
|
|
|
throw new RuntimeException("未找到账单明细,操作失败");
|
|
|
}
|
|
|
- if ("CNY".equals(item.getCurCode())){
|
|
|
+ if ("CNY".equals(item.getCurCode())) {
|
|
|
BigDecimal amount = finAccBills.getAppliedInvoiceAmount().subtract(finAccBills.getAppliedInvoiceAmountStl());
|
|
|
- if ("C".equals(finAccBills.getAccountDc())){
|
|
|
+ if ("C".equals(finAccBills.getAccountDc())) {
|
|
|
if (item.getCurrentAmount().compareTo(finAccBills.getAmountCr().subtract(amount)) > 0) {
|
|
|
throw new RuntimeException("本次申请金额大于未申请金额");
|
|
|
}
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
if (item.getCurrentAmount().compareTo(finAccBills.getAmountDr().subtract(amount)) > 0) {
|
|
|
throw new RuntimeException("本次申请金额大于未申请金额");
|
|
|
}
|
|
|
}
|
|
|
finAccBills.setAppliedInvoiceAmount(finAccBills.getAppliedInvoiceAmount().add(item.getCurrentAmount()));
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
BigDecimal amount = finAccBills.getAppliedInvoiceAmountUsd().subtract(finAccBills.getAppliedInvoiceAmountStlUsd());
|
|
|
- if ("C".equals(finAccBills.getAccountDc())){
|
|
|
+ if ("C".equals(finAccBills.getAccountDc())) {
|
|
|
if (item.getCurrentAmount().compareTo(finAccBills.getAmountCrUsd().subtract(amount)) > 0) {
|
|
|
throw new RuntimeException("本次申请金额大于未申请金额");
|
|
|
}
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
if (item.getCurrentAmount().compareTo(finAccBills.getAmountDrUsd().subtract(amount)) > 0) {
|
|
|
throw new RuntimeException("本次申请金额大于未申请金额");
|
|
|
}
|
|
|
@@ -675,12 +682,12 @@ public class FinInvoicesServiceImpl extends ServiceImpl<FinInvoicesMapper, FinIn
|
|
|
if (finAccBills == null) {
|
|
|
throw new RuntimeException("未找到账单明细,操作失败");
|
|
|
}
|
|
|
- if ("CNY".equals(item.getCurCode())){
|
|
|
+ if ("CNY".equals(item.getCurCode())) {
|
|
|
if (item.getCurrentAmount().compareTo(finAccBills.getAppliedInvoiceAmount()) > 0) {
|
|
|
throw new RuntimeException("本次申请金额大于未申请金额");
|
|
|
}
|
|
|
finAccBills.setAppliedInvoiceAmount(finAccBills.getAppliedInvoiceAmount().subtract(item.getCurrentAmount()));
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
if (item.getCurrentAmount().compareTo(finAccBills.getAppliedInvoiceAmountUsd()) > 0) {
|
|
|
throw new RuntimeException("本次申请金额大于未申请金额");
|
|
|
}
|