|
|
@@ -672,8 +672,10 @@ public class InvoiceGroupServiceImpl implements InvoiceGroupService {
|
|
|
List<InvoiceInventoryDO> inventoryList = invoiceInventoryService.getInvoiceInventoryListByInvoiceId(invoice.getId());
|
|
|
JSONObject detailObj;
|
|
|
BigDecimal taxExcludedAmount = BigDecimal.ZERO;
|
|
|
+ BigDecimal taxExcludedAmounttotal = BigDecimal.ZERO;
|
|
|
BigDecimal se = BigDecimal.ZERO;
|
|
|
BigDecimal taxIncludedAmount = BigDecimal.ZERO;
|
|
|
+ BigDecimal taxIncludedAmounttotal = BigDecimal.ZERO;
|
|
|
if (inventoryList.isEmpty()) {
|
|
|
int index = 1;
|
|
|
detailObj = new JSONObject();
|
|
|
@@ -689,7 +691,8 @@ public class InvoiceGroupServiceImpl implements InvoiceGroupService {
|
|
|
BigDecimal taxRate = new BigDecimal(configApi.getPlatformConfigValueByKey("newinvoice.taxRate"));
|
|
|
detailObj.set("SL", taxRate);
|
|
|
//含税金额
|
|
|
- taxIncludedAmount = invoice.getPrice();
|
|
|
+ taxIncludedAmount = invoice.getPrice().add(invoice.getZkprice());
|
|
|
+ taxIncludedAmounttotal = invoice.getPrice();
|
|
|
if (type == 1) {
|
|
|
taxIncludedAmount = BigDecimal.ZERO.subtract(invoice.getPrice());
|
|
|
}
|
|
|
@@ -697,6 +700,7 @@ public class InvoiceGroupServiceImpl implements InvoiceGroupService {
|
|
|
// detailObj.set("DYLZFPMXXH", dylzfpmxxh);
|
|
|
//不含税金额
|
|
|
taxExcludedAmount = taxIncludedAmount.divide(new BigDecimal(1).add(taxRate), 2, RoundingMode.HALF_UP);
|
|
|
+ taxExcludedAmounttotal = taxIncludedAmounttotal.divide(new BigDecimal(1).add(taxRate), 2, RoundingMode.HALF_UP);
|
|
|
//金额
|
|
|
detailObj.set("JE", taxIncludedAmount.setScale(2, RoundingMode.HALF_UP));
|
|
|
//税额
|
|
|
@@ -713,6 +717,41 @@ public class InvoiceGroupServiceImpl implements InvoiceGroupService {
|
|
|
//0:不使用,1:使用,SPID为空时必填
|
|
|
detailObj.set("YHZCBS", 0);
|
|
|
detailArray.add(detailObj);
|
|
|
+
|
|
|
+
|
|
|
+ if(invoice.getZkprice() != null && invoice.getZkprice().compareTo(BigDecimal.ZERO) > 0) {
|
|
|
+ JSONObject detailObj2 = new JSONObject();
|
|
|
+ detailObj2.set("XH", index);
|
|
|
+ //商品编码
|
|
|
+ detailObj2.set("SPBM", spbm);
|
|
|
+ //项目名称
|
|
|
+ detailObj2.set("XMMC", spmc);
|
|
|
+ //税率
|
|
|
+ detailObj2.set("SL", taxRate);
|
|
|
+ //含税金额
|
|
|
+ taxIncludedAmount = BigDecimal.ZERO.subtract( invoice.getZkprice());
|
|
|
+// String dylzfpmxxh = String.valueOf(IdWorker.getId()).substring(0,8);
|
|
|
+// detailObj.set("DYLZFPMXXH", dylzfpmxxh);
|
|
|
+ //不含税金额
|
|
|
+ taxExcludedAmount = taxIncludedAmount.divide(new BigDecimal(1).add(taxRate), 2, RoundingMode.HALF_UP);
|
|
|
+ //金额
|
|
|
+ detailObj2.set("JE", taxIncludedAmount.setScale(2, RoundingMode.HALF_UP));
|
|
|
+ //税额
|
|
|
+ se = taxIncludedAmount.subtract(taxExcludedAmount);
|
|
|
+ detailObj2.set("SE", se.setScale(2, RoundingMode.HALF_UP));
|
|
|
+ //扣除额
|
|
|
+ detailObj2.set("KCE", "");
|
|
|
+ //行性质。0-正常行 1-折扣行 2-被折扣行
|
|
|
+ detailObj2.set("FPHXZ", "0");
|
|
|
+ //含税标志
|
|
|
+ detailObj2.set("HSBZ", "1");
|
|
|
+ //空:非零税率,1:免税,2:不征税 3:普通零税率
|
|
|
+ detailObj2.set("LSLBS", "");
|
|
|
+ //0:不使用,1:使用,SPID为空时必填
|
|
|
+ detailObj2.set("YHZCBS", 0);
|
|
|
+ detailArray.add(detailObj2);
|
|
|
+ }
|
|
|
+
|
|
|
InvoiceInventorySaveReqVO saveReqVO = new InvoiceInventorySaveReqVO();
|
|
|
saveReqVO.setInvoiceId(invoice.getId());
|
|
|
saveReqVO.setSort(index);
|
|
|
@@ -777,7 +816,7 @@ public class InvoiceGroupServiceImpl implements InvoiceGroupService {
|
|
|
reqObj.set("BZ", remark);
|
|
|
}
|
|
|
//价税合计
|
|
|
- reqObj.set("JSHJ", taxIncludedAmount.setScale(2, RoundingMode.HALF_UP));
|
|
|
+ reqObj.set("JSHJ", taxIncludedAmounttotal.setScale(2, RoundingMode.HALF_UP));
|
|
|
//系统来源
|
|
|
reqObj.set("SX_XTLY", StrUtil.isNotBlank(sysSource) ? sysSource : "SX_LYEQ");
|
|
|
// reqObj.set("DDMXXX", detailArray);
|
|
|
@@ -786,7 +825,7 @@ public class InvoiceGroupServiceImpl implements InvoiceGroupService {
|
|
|
// reqDDZ.add(reqObj);
|
|
|
reqDDZ.add(jsonObject);
|
|
|
invoice.setCHjse(se);
|
|
|
- invoice.setCBhsje(taxExcludedAmount);
|
|
|
+ invoice.setCBhsje(taxExcludedAmounttotal);
|
|
|
});
|
|
|
requestBody.set("DDZXX", reqDDZ);
|
|
|
return requestBody;
|