销售发票红冲接口调整
This commit is contained in:
parent
6dc1f0e9b1
commit
7f896b3f37
|
@ -40,6 +40,7 @@ import java.util.List;
|
|||
*
|
||||
* @author lj
|
||||
* @date 2025/03/14
|
||||
* @update 20250415 mzr修改
|
||||
*/
|
||||
@Path("so/saleinvoice/operator")
|
||||
public class BillSaveAction extends AbstractNCCRestResource {
|
||||
|
@ -162,9 +163,17 @@ public class BillSaveAction extends AbstractNCCRestResource {
|
|||
public static SaleInvoiceVO makeNewRedRushSaleInvoice(SaleInvoiceVO originalVO, JSONObject bject) throws Exception {
|
||||
try {
|
||||
SaleInvoiceVO saleInvoiceVO = new SaleInvoiceVO();
|
||||
SaleInvoiceHVO saleInvoiceHVO = originalVO.getParentVO(); // 主实体
|
||||
SaleInvoiceBVO[] saleInvoiceBVOs = originalVO.getChildrenVO(); // 子实体
|
||||
SaleInvoiceHVO newSaleInvoiceHVO = new SaleInvoiceHVO(); // 新主实体
|
||||
// 发票主实体
|
||||
SaleInvoiceHVO saleInvoiceHVO = originalVO.getParentVO();
|
||||
// 发票子实体数组
|
||||
SaleInvoiceBVO[] saleInvoiceBVOs = originalVO.getChildrenVO();
|
||||
// 发票新主实体
|
||||
SaleInvoiceHVO newSaleInvoiceHVO = new SaleInvoiceHVO();
|
||||
|
||||
// 单据日期
|
||||
UFDate dbilldate = new UFDate(bject.getString("dbilldate"));
|
||||
// 制单日期
|
||||
UFDate dmakedate = new UFDate(bject.getString("creationtime"));
|
||||
|
||||
// 子实体属性赋值
|
||||
UFDouble sumNum = new UFDouble(); // 合计数量
|
||||
|
@ -180,42 +189,41 @@ public class BillSaveAction extends AbstractNCCRestResource {
|
|||
for (SaleInvoiceBVO saleInvoiceBVO : saleInvoiceBVOs) {
|
||||
String csaleinvoicebid = saleInvoiceBVO.getCsaleinvoicebid(); // 子表id
|
||||
// 筛选参数红冲的子表集合
|
||||
List<JSONObject> newParamsSaleInvoiceBVOs = bvoList.stream().filter(item -> {
|
||||
List<JSONObject> newBvoArr = bvoList.stream().filter(item -> {
|
||||
String parCsaleinvoicebid = item.getString("vbdef15") + ""; // 子表id
|
||||
return csaleinvoicebid.equals(parCsaleinvoicebid);
|
||||
}).toList();
|
||||
if (newParamsSaleInvoiceBVOs.size() <= 0) {
|
||||
if (newBvoArr.size() <= 0) {
|
||||
continue;
|
||||
}
|
||||
JSONObject paramSaleInvoiceBVO = newParamsSaleInvoiceBVOs.get(0); // 参数子表
|
||||
SaleInvoiceBVO newSaleInvoiceBVO = new SaleInvoiceBVO();
|
||||
// BeanUtil.copyProperties(saleInvoiceBVO,newSaleInvoiceBVO);
|
||||
JSONObject bipBvoJson = newBvoArr.get(0); // 参数子表
|
||||
SaleInvoiceBVO newInvBVO = new SaleInvoiceBVO();
|
||||
// 克隆取值原子表销售发票
|
||||
newSaleInvoiceBVO = (SaleInvoiceBVO) CloneUtil.depthClone(saleInvoiceBVO);
|
||||
newInvBVO = (SaleInvoiceBVO) CloneUtil.depthClone(saleInvoiceBVO);
|
||||
// 赋值之后修改子实体红冲时字段
|
||||
newSaleInvoiceBVO.setCsaleinvoicebid(null); // 发票子实体id
|
||||
newSaleInvoiceBVO.setDbilldate(newSaleInvoiceHVO.getDbilldate()); // 开票日期
|
||||
newSaleInvoiceBVO.setNastnum(new UFDouble(paramSaleInvoiceBVO.getString("nastnum"))); // 数量
|
||||
newSaleInvoiceBVO.setNnum(new UFDouble(paramSaleInvoiceBVO.getString("nnum"))); // 主数量
|
||||
newSaleInvoiceBVO.setNtax(new UFDouble(paramSaleInvoiceBVO.getString("ntax"))); // 税额
|
||||
newSaleInvoiceBVO.setNmny(new UFDouble(paramSaleInvoiceBVO.getString("nmny"))); // 本币无税金额
|
||||
newSaleInvoiceBVO.setNtaxmny(new UFDouble(paramSaleInvoiceBVO.getString("ntaxmny"))); // 本币价税合计
|
||||
newSaleInvoiceBVO.setNcaltaxmny(new UFDouble(paramSaleInvoiceBVO.getString("ncaltaxmny"))); // 计税金额
|
||||
newSaleInvoiceBVO.setNorigmny(new UFDouble(paramSaleInvoiceBVO.getString("norigmny"))); // 无税金额
|
||||
newSaleInvoiceBVO.setNorigtaxmny(new UFDouble(paramSaleInvoiceBVO.getString("norigtaxmny"))); // 价税合计
|
||||
newSaleInvoiceBVO.setCopposesrcbid(paramSaleInvoiceBVO.getString("csaleinvoicebid")); // 对冲来源子表id
|
||||
newSaleInvoiceBVO.setNqtunitnum(null); // 报价数量
|
||||
newSaleInvoiceBVO.setCsaleinvoiceid(null); // 发票关联主表id
|
||||
newSaleInvoiceBVO.setNtotalcostnum(null); // 累计成本结算数量
|
||||
newSaleInvoiceBVO.setNtotalincomemny(null); // 累计确认应收金额
|
||||
newSaleInvoiceBVO.setNtotalincomenum(null); // 累计确认应收数量
|
||||
newSaleInvoiceBVO.setVchangerate("1.00/1.00"); // 换算率
|
||||
newSaleInvoiceBVOs[i++] = newSaleInvoiceBVO;
|
||||
sumNum = sumNum.add(new UFDouble(paramSaleInvoiceBVO.getString("nnum")));
|
||||
sumNtax = sumNtax.add(new UFDouble(paramSaleInvoiceBVO.getString("ntax")));
|
||||
sumNcaltaxmny = sumNcaltaxmny.add(new UFDouble(paramSaleInvoiceBVO.getString("ncaltaxmny")));
|
||||
sumNorigmny = sumNorigmny.add(new UFDouble(paramSaleInvoiceBVO.getString("norigmny")));
|
||||
sumNorigtaxmny = sumNorigtaxmny.add(new UFDouble(paramSaleInvoiceBVO.getString("norigtaxmny")));
|
||||
newInvBVO.setCsaleinvoicebid(null); // 发票子实体id
|
||||
newInvBVO.setDbilldate(dbilldate); // 开票日期
|
||||
newInvBVO.setNastnum(new UFDouble(bipBvoJson.getString("nastnum"))); // 数量
|
||||
newInvBVO.setNnum(new UFDouble(bipBvoJson.getString("nnum"))); // 主数量
|
||||
newInvBVO.setNtax(new UFDouble(bipBvoJson.getString("ntax"))); // 税额
|
||||
newInvBVO.setNmny(new UFDouble(bipBvoJson.getString("nmny"))); // 本币无税金额
|
||||
newInvBVO.setNtaxmny(new UFDouble(bipBvoJson.getString("ntaxmny"))); // 本币价税合计
|
||||
newInvBVO.setNcaltaxmny(new UFDouble(bipBvoJson.getString("ncaltaxmny"))); // 计税金额
|
||||
newInvBVO.setNorigmny(new UFDouble(bipBvoJson.getString("norigmny"))); // 无税金额
|
||||
newInvBVO.setNorigtaxmny(new UFDouble(bipBvoJson.getString("norigtaxmny"))); // 价税合计
|
||||
newInvBVO.setCopposesrcbid(bipBvoJson.getString("vbdef15")); // 对冲来源子表id
|
||||
newInvBVO.setNqtunitnum(null); // 报价数量
|
||||
newInvBVO.setCsaleinvoiceid(null); // 发票关联主表id
|
||||
newInvBVO.setNtotalcostnum(null); // 累计成本结算数量
|
||||
newInvBVO.setNtotalincomemny(null); // 累计确认应收金额
|
||||
newInvBVO.setNtotalincomenum(null); // 累计确认应收数量
|
||||
newInvBVO.setVchangerate("1.00/1.00"); // 换算率
|
||||
newSaleInvoiceBVOs[i++] = newInvBVO;
|
||||
sumNum = sumNum.add(new UFDouble(bipBvoJson.getString("nnum")));
|
||||
sumNtax = sumNtax.add(new UFDouble(bipBvoJson.getString("ntax")));
|
||||
sumNcaltaxmny = sumNcaltaxmny.add(new UFDouble(bipBvoJson.getString("ncaltaxmny")));
|
||||
sumNorigmny = sumNorigmny.add(new UFDouble(bipBvoJson.getString("norigmny")));
|
||||
sumNorigtaxmny = sumNorigtaxmny.add(new UFDouble(bipBvoJson.getString("norigtaxmny")));
|
||||
}
|
||||
|
||||
// 克隆取值原子表销售发票
|
||||
|
@ -223,8 +231,8 @@ public class BillSaveAction extends AbstractNCCRestResource {
|
|||
// 赋值之后修改主实体红冲时字段
|
||||
newSaleInvoiceHVO.setCsaleinvoiceid(null); // 发票主实体id
|
||||
newSaleInvoiceHVO.setVbillcode(null); // 发票号
|
||||
newSaleInvoiceHVO.setDbilldate(new UFDate()); // 开票日期
|
||||
newSaleInvoiceHVO.setDmakedate(new UFDate()); // 制单日期
|
||||
newSaleInvoiceHVO.setDbilldate(dbilldate); // 开票日期
|
||||
newSaleInvoiceHVO.setDmakedate(dmakedate); // 制单日期
|
||||
newSaleInvoiceHVO.setBsubunitflag(UFBoolean.TRUE); // 冲抵标记
|
||||
newSaleInvoiceHVO.setFopposeflag(2); // 对冲标记 (2:对冲生成)
|
||||
newSaleInvoiceHVO.setFstatusflag(1); // 单据状态 (1:自由态)
|
||||
|
@ -257,7 +265,7 @@ public class BillSaveAction extends AbstractNCCRestResource {
|
|||
*/
|
||||
public static IVApplicationAggVO makeNewRedRushIVApplicationAggVO(IVApplicationHeadVO applyHeadVO, IVApplicationBodyVO[] ivApplicationBodyVOS, JSONObject bject, SaleInvoiceVO[] returnApproveSaleInvoiceVOs) throws Exception {
|
||||
try {
|
||||
IVApplicationAggVO ivApplicationAggVO = new IVApplicationAggVO();
|
||||
IVApplicationAggVO applicationAggVO = new IVApplicationAggVO();
|
||||
IVApplicationHeadVO newivApplicationHeadVO = new IVApplicationHeadVO(); // 新主实体
|
||||
|
||||
// 取新生成红冲发票的主实体数据
|
||||
|
@ -268,7 +276,6 @@ public class BillSaveAction extends AbstractNCCRestResource {
|
|||
SaleInvoiceHVO rpSaleInvoiceHVO = rpSaleInvoiceVOs[0].getParentVO();
|
||||
|
||||
// 主实体属性赋值
|
||||
// BeanUtil.copyProperties(applyHeadVO,newivApplicationHeadVO, CopyOptions.create().setIgnoreNullValue(true));
|
||||
// 克隆取值原子表开票申请
|
||||
newivApplicationHeadVO = (IVApplicationHeadVO) CloneUtil.depthClone(applyHeadVO);
|
||||
// 根据参数判断是否为部分红冲
|
||||
|
@ -293,14 +300,14 @@ public class BillSaveAction extends AbstractNCCRestResource {
|
|||
for (IVApplicationBodyVO ivApplicationBodyVO : ivApplicationBodyVOS) {
|
||||
String src_pkdetail = ivApplicationBodyVO.getSrc_pkdetail(); // 来源单据行id
|
||||
// 筛选参数红冲的子表集合
|
||||
List<JSONObject> newParamsSaleInvoiceBVOs = bvoList.stream().filter(item -> {
|
||||
List<JSONObject> newBvoArr = bvoList.stream().filter(item -> {
|
||||
String parCsaleinvoicebid = item.getString("vbdef15") + ""; // 子表id
|
||||
return src_pkdetail.equals(parCsaleinvoicebid);
|
||||
}).toList();
|
||||
if (newParamsSaleInvoiceBVOs.size() <= 0) {
|
||||
if (newBvoArr.size() <= 0) {
|
||||
continue;
|
||||
}
|
||||
JSONObject paramSaleInvoiceBVO = newParamsSaleInvoiceBVOs.get(0); // 参数子表
|
||||
JSONObject bipBvoJson = newBvoArr.get(0); // 参数子表
|
||||
IVApplicationBodyVO newivApplicationBodyVO = new IVApplicationBodyVO();
|
||||
// BeanUtil.copyProperties(ivApplicationBodyVO,newivApplicationBodyVO, CopyOptions.create().setIgnoreNullValue(true));
|
||||
// 克隆取值原子表开票申请
|
||||
|
@ -308,22 +315,23 @@ public class BillSaveAction extends AbstractNCCRestResource {
|
|||
// 赋值之后修改子实体红冲时字段
|
||||
newivApplicationBodyVO.setPk_ivappdetail(null); // 开票申请子实体id
|
||||
newivApplicationBodyVO.setBillno(null); // 开票申请子实体单据号
|
||||
newivApplicationBodyVO.setSe(new UFDouble(paramSaleInvoiceBVO.getString("ntax"))); // 税额
|
||||
newivApplicationBodyVO.setXmsl(new UFDouble(paramSaleInvoiceBVO.getString("nnum"))); // 数量
|
||||
newivApplicationBodyVO.setXmje(new UFDouble(paramSaleInvoiceBVO.getString("norigmny"))); // 金额
|
||||
newivApplicationBodyVO.setXmjshj(new UFDouble(paramSaleInvoiceBVO.getString("norigtaxmny"))); // 价税合计
|
||||
newivApplicationBodyVO.setBchcje(new UFDouble(paramSaleInvoiceBVO.getString("norigtaxmny")).multiply(new UFDouble(-1))); // 本次红冲金额 = 本次参数红冲金额
|
||||
newivApplicationBodyVO.setSe(new UFDouble(bipBvoJson.getString("ntax"))); // 税额
|
||||
newivApplicationBodyVO.setXmsl(new UFDouble(bipBvoJson.getString("nnum"))); // 数量
|
||||
newivApplicationBodyVO.setXmje(new UFDouble(bipBvoJson.getString("norigmny"))); // 金额
|
||||
newivApplicationBodyVO.setXmjshj(new UFDouble(bipBvoJson.getString("norigtaxmny"))); // 价税合计
|
||||
// 本次红冲金额 = 本次参数红冲金额
|
||||
newivApplicationBodyVO.setBchcje(new UFDouble(bipBvoJson.getString("norigtaxmny")).multiply(new UFDouble(-1)));
|
||||
newivApplicationBodyVOS[i++] = newivApplicationBodyVO;
|
||||
sumSe = sumSe.add(new UFDouble(paramSaleInvoiceBVO.getString("ntax")));
|
||||
sumXmsl = sumXmsl.add(new UFDouble(paramSaleInvoiceBVO.getString("nnum")));
|
||||
sumXmje = sumXmje.add(new UFDouble(paramSaleInvoiceBVO.getString("norigmny")));
|
||||
sumXmjshj = sumXmjshj.add(new UFDouble(paramSaleInvoiceBVO.getString("norigtaxmny")));
|
||||
sumBchcje = sumBchcje.add(new UFDouble(paramSaleInvoiceBVO.getString("norigtaxmny")).multiply(new UFDouble(-1)));
|
||||
sumSe = sumSe.add(new UFDouble(bipBvoJson.getString("ntax")));
|
||||
sumXmsl = sumXmsl.add(new UFDouble(bipBvoJson.getString("nnum")));
|
||||
sumXmje = sumXmje.add(new UFDouble(bipBvoJson.getString("norigmny")));
|
||||
sumXmjshj = sumXmjshj.add(new UFDouble(bipBvoJson.getString("norigtaxmny")));
|
||||
sumBchcje = sumBchcje.add(new UFDouble(bipBvoJson.getString("norigtaxmny")).multiply(new UFDouble(-1)));
|
||||
}
|
||||
// 赋值之后修改主实体红冲时字段
|
||||
newivApplicationHeadVO.setPk_ivapplication(null); // 开票申请单主实体id
|
||||
newivApplicationHeadVO.setBillno(null); // 单据号
|
||||
newivApplicationHeadVO.setPreparedate(new UFDate()); // 单据日期
|
||||
newivApplicationHeadVO.setPreparedate(new UFDate(bject.getString("dbilldate"))); // 单据日期
|
||||
newivApplicationHeadVO.setJshj(sumXmjshj); // 价税合计
|
||||
newivApplicationHeadVO.setHjje(sumXmje); // 合计金额
|
||||
newivApplicationHeadVO.setHjse(sumSe); // 合计税额
|
||||
|
@ -337,9 +345,9 @@ public class BillSaveAction extends AbstractNCCRestResource {
|
|||
newivApplicationHeadVO.setHcyy("2"); // 红冲原因:2(开票有误)
|
||||
|
||||
// 组装VO
|
||||
ivApplicationAggVO.setParentVO(newivApplicationHeadVO);
|
||||
ivApplicationAggVO.setChildrenVO(newivApplicationBodyVOS);
|
||||
return ivApplicationAggVO;
|
||||
applicationAggVO.setParentVO(newivApplicationHeadVO);
|
||||
applicationAggVO.setChildrenVO(newivApplicationBodyVOS);
|
||||
return applicationAggVO;
|
||||
} catch (Exception e) {
|
||||
throw new BusinessException(e.getMessage());
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue