销售发票调整

This commit is contained in:
mzr 2025-03-07 10:20:53 +08:00
parent 596f18ae49
commit 48a5679ac4
1 changed files with 64 additions and 60 deletions

View File

@ -40,7 +40,7 @@ import java.util.Map;
@Path("so/saleinvoice/operator")
public class saveCommitAction extends AbstractNCCRestResource {
public static String fplxStr = "";// 开票申请发票类型
public static String fplxStr = "";//开票申请发票类型
public saveCommitAction() {
@ -118,7 +118,7 @@ public class saveCommitAction extends AbstractNCCRestResource {
.queryVOByIDs(ids);
SaleInvoiceVO saleInvoiceVO22 = saleInvoiceVO[0];
SaleInvoiceHVO saleInvoiceHVO = saleInvoiceVO22.getParentVO();
// 销售发票审核开始
//销售发票审核开始
InvocationInfoProxy.getInstance().setUserId(saleInvoiceHVO.getApprover());
CloudPFlowContext context = new CloudPFlowContext();
context.setBillType("32");
@ -133,7 +133,7 @@ public class saveCommitAction extends AbstractNCCRestResource {
IBatchRunScriptService service = (IBatchRunScriptService) NCLocator.getInstance()
.lookup(IBatchRunScriptService.class);
SCMScriptResultDTO result = service.runBacth(context, SaleInvoiceVO.class);
// 销售发票审核结束
//销售发票审核结束
TaxInvoiceType typeObj = TaxInvoiceType.SpecialInvoice;
SaleInvoiceToTaxInvServiceImpl saleInvoiceToTaxInvService = new SaleInvoiceToTaxInvServiceImpl();
saleInvoiceToTaxInvService.issueTaxInvoice(saleInvoiceVO, typeObj);
@ -173,20 +173,20 @@ public class saveCommitAction extends AbstractNCCRestResource {
JSONObject bill = new JSONObject();
// billhead 结构
JSONObject billhead = new JSONObject();
billhead = originalJson.getJSONObject("billhead");// 传入JSON对象
billhead.put("pk_org_v", originalJson.getJSONObject("billhead").getString("pk_org"));// 开票组织版本=开票组织
billhead.put("pk_group", "00");// 集团
billhead = originalJson.getJSONObject("billhead");//传入JSON对象
billhead.put("pk_org_v", originalJson.getJSONObject("billhead").getString("pk_org"));//开票组织版本=开票组织
billhead.put("pk_group", "00");//集团
fplxStr = originalJson.getJSONObject("billhead").getString("vdef22");
billhead.put("vtrantypecode", "32-02");// 发票类型编码
billhead.put("cbiztypeid", "SO01");// 业务流程
billhead.put("approver", "BIP");// 审批人
billhead.put("fstatusflag", 1);// 单据状态
billhead.put("billmaker", "BIP");// 制单人
billhead.put("csendcountryid", "CN");// 发货国家
billhead.put("crececountryid", "CN");// 收货国家
billhead.put("ctaxcountryid", "CN");// 报税国家
// 2025-2-8付业要求修改根据发票类型Q自定义档案对照发票类型
String ctrantypeidStr = "32-02";// 默认普通发票
billhead.put("vtrantypecode", "32-02");//发票类型编码
billhead.put("cbiztypeid", "SO01");//业务流程
billhead.put("approver", "BIP");//审批人
billhead.put("fstatusflag", 1);//单据状态
billhead.put("billmaker", "BIP");//制单人
billhead.put("csendcountryid", "CN");//发货国家
billhead.put("crececountryid", "CN");//收货国家
billhead.put("ctaxcountryid", "CN");//报税国家
//2025-2-8付业要求修改根据发票类型Q自定义档案对照发票类型
String ctrantypeidStr = "32-02";//默认普通发票
if (fplxStr != null && fplxStr.equals("31")) {
ctrantypeidStr = "32-01";
} else if (fplxStr != null && fplxStr.equals("32")) {
@ -194,14 +194,14 @@ public class saveCommitAction extends AbstractNCCRestResource {
} else if (fplxStr != null && fplxStr.equals("36")) {
ctrantypeidStr = "32-Cxx-03";
}
billhead.put("ctrantypeid", ctrantypeidStr);// 发票类型
// billhead.put("ctrantypeid", "32-02");//发票类型
billhead.put("fbuysellflag", "1");// 购销类型
billhead.put("creator", "BIP");// 创建人
billhead.put("ctrantypeid", ctrantypeidStr);//发票类型
//billhead.put("ctrantypeid", "32-02");//发票类型
billhead.put("fbuysellflag", "1");//购销类型
billhead.put("creator", "BIP");//创建人
billhead.put("ccurrencyid", "CNY");// 本位币
billhead.put("corigcurrencyid", "CNY");// 币种
billhead.put("nexchangerate", 1);// 折本汇率
billhead.put("btriatradeflag", 0);// 三角贸易
billhead.put("corigcurrencyid", "CNY");//币种
billhead.put("nexchangerate", 1);//折本汇率
billhead.put("btriatradeflag", 0);//三角贸易
JSONObject newItem = new JSONObject();
JSONObject otherJson = new JSONObject();
JSONArray csaleinvoicebid = new JSONArray();
@ -212,36 +212,36 @@ public class saveCommitAction extends AbstractNCCRestResource {
JSONObject itemDetails = new JSONObject();
itemDetails = item;
itemDetails.put("carorgid", originalJson.getJSONObject("billhead").getString("pk_org"));// 应收组织
itemDetails.put("carorgid", originalJson.getJSONObject("billhead").getString("pk_org"));//应收组织
itemDetails.put("csendstockorgid",
originalJson.getJSONObject("billhead").getString("pk_org"));// 库存组织原始版本
itemDetails.put("cmaterialid", item.getString("cmaterialvid"));// 物料编码
originalJson.getJSONObject("billhead").getString("pk_org"));//库存组织原始版本
itemDetails.put("cmaterialid", item.getString("cmaterialvid"));//物料编码
Map<String, Object> value2 = getSaleorderVo(item.getString("csrcbid"));
if (value2 == null) {
resultJson = new JSONObject();
resultJson.put("tsType", "1");
return resultJson;
}
itemDetails.put("vfirsttype", "30");// 源头单据类型
itemDetails.put("vfirstcode", value2.get("vbillcode"));// 源头单据号
itemDetails.put("blargessflag", value2.get("blargessflag"));// 赠品
itemDetails.put("vfirsttrantype", "30-01");// 源头交易类型
itemDetails.put("vfirstrowno", value2.get("crowno"));// 源头单据行号
itemDetails.put("cfirstid", item.getString("csrcid"));// 源头单据主表
itemDetails.put("cfirstbid", item.getString("csrcbid"));// 源头单据子表
itemDetails.put("vsrctype", "30");// 来源单据类型
itemDetails.put("vsrccode", value2.get("vbillcode"));// 来源单据号
itemDetails.put("vsrctrantype", "30-01");// 来源交易类型
itemDetails.put("vsrcrowno", value2.get("crowno"));// 来源单据行号
itemDetails.put("vfirsttype", "30");//源头单据类型
itemDetails.put("vfirstcode", value2.get("vbillcode"));//源头单据号
itemDetails.put("blargessflag", value2.get("blargessflag"));//赠品
itemDetails.put("vfirsttrantype", "30-01");//源头交易类型
itemDetails.put("vfirstrowno", value2.get("crowno"));//源头单据行号
itemDetails.put("cfirstid", item.getString("csrcid"));//源头单据主表
itemDetails.put("cfirstbid", item.getString("csrcbid"));//源头单据子表
itemDetails.put("vsrctype", "30");//来源单据类型
itemDetails.put("vsrccode", value2.get("vbillcode"));//来源单据号
itemDetails.put("vsrctrantype", "30-01");//来源交易类型
itemDetails.put("vsrcrowno", value2.get("crowno"));//来源单据行号
// 通过 ntaxrate 获取 taxcode
String taxcodeStr = getTaxcode(item.getString("ntaxrate"));
// taxcodeStr 放入 bodyMap
itemDetails.put("ctaxcodeid", taxcodeStr);// 税码
itemDetails.put("nnum", item.getString("nastnum"));// 主数量
itemDetails.put("ftaxtypeflag", 1);// 扣税类别
itemDetails.put("pk_group", "00");// 集团
itemDetails.put("pk_org", originalJson.getJSONObject("billhead").getString("pk_org"));// 开票组织
itemDetails.put("cunitid", item.getString("castunitid"));// 主单位
itemDetails.put("ctaxcodeid", taxcodeStr);//税码
itemDetails.put("nnum", item.getString("nastnum"));//主数量
itemDetails.put("ftaxtypeflag", 1);//扣税类别
itemDetails.put("pk_group", "00");//集团
itemDetails.put("pk_org", originalJson.getJSONObject("billhead").getString("pk_org"));//开票组织
itemDetails.put("cunitid", item.getString("castunitid"));//主单位
// double nastnum = Double.parseDouble(item.getString("nastnum"));//数量
// double nqtorigtaxprice = Double.parseDouble(item.getString("nqtorigtaxprice"));//含税单价
@ -286,7 +286,7 @@ public class saveCommitAction extends AbstractNCCRestResource {
BigDecimal ntaxrate = new BigDecimal(item.getString("ntaxrate")).divide(new BigDecimal("100")); // 税率
ntaxrate = ntaxrate.setScale(4, RoundingMode.HALF_UP);
// 含税净价
//含税净价
BigDecimal norigtaxnetprice = nqtorigtaxprice;
// 1. 计算价税合计含税金额
BigDecimal norigtaxmny = nastnum.multiply(norigtaxnetprice).setScale(2, RoundingMode.HALF_UP);
@ -325,19 +325,19 @@ public class saveCommitAction extends AbstractNCCRestResource {
norigtaxnetprice = norigtaxnetprice.multiply(nexchangerate);
itemDetails.put("nqtorigprice", nqtorigprice);// 无税单价
itemDetails.put("norigprice", nqtorigprice);// 主无税单价
itemDetails.put("norigmny", norigmny);// 无税金额
itemDetails.put("nmny", norigmny);// 本币无税金额
itemDetails.put("norigtaxmny", norigtaxmny);// 价税合计
itemDetails.put("norigtaxprice", norigtaxprice);// 主含税单价
itemDetails.put("norignetprice", norignetprice);// 主无税净价
itemDetails.put("nqtorigtaxprice", nqtorigtaxprice);// 含税单价
itemDetails.put("ntax", ntax);// 税额
itemDetails.put("ncaltaxmny", ncaltaxmny);// 计税金额
itemDetails.put("norigtaxnetprice", norigtaxnetprice);// 主含税净价
itemDetails.put("nnetprice", norignetprice);// 主本币无税净价
itemDetails.put("ntaxmny", norigtaxmny);// 本币价税合计
itemDetails.put("nqtorigprice", nqtorigprice);//无税单价
itemDetails.put("norigprice", nqtorigprice);//主无税单价
itemDetails.put("norigmny", norigmny);//无税金额
itemDetails.put("nmny", norigmny);//本币无税金额
itemDetails.put("norigtaxmny", norigtaxmny);//价税合计
itemDetails.put("norigtaxprice", norigtaxprice);//主含税单价
itemDetails.put("norignetprice", norignetprice);//主无税净价
itemDetails.put("nqtorigtaxprice", nqtorigtaxprice);//含税单价
itemDetails.put("ntax", ntax);//税额
itemDetails.put("ncaltaxmny", ncaltaxmny);//计税金额
itemDetails.put("norigtaxnetprice", norigtaxnetprice);//主含税净价
itemDetails.put("nnetprice", norignetprice);//主本币无税净价
itemDetails.put("ntaxmny", norigtaxmny);//本币价税合计
csaleinvoicebid.add(itemDetails);
@ -390,9 +390,13 @@ public class saveCommitAction extends AbstractNCCRestResource {
private static Map<String, Object> getSaleorderVo(String csourcebillbidStr) throws BusinessException {
IUAPQueryBS queryBS = NCLocator.getInstance().lookup(IUAPQueryBS.class);
String sql = " select s.vbillcode,s.csaleorderid,sb.csaleorderbid,sb.crowno,sb.blargessflag,sb.nexchangerate,s.corigcurrencyid from so_saleorder_b sb\n"
+ "inner join so_saleorder s on sb.csaleorderid=s.csaleorderid\n"
+ "where sb.csaleorderbid='" + csourcebillbidStr + "' ";
String sql = " select s.vbillcode,s.csaleorderid, s.corigcurrencyid," +
" sb.csaleorderbid,sb.crowno,sb.blargessflag,sb.nexchangerate," +
" bdc.code currencycode" +
" from so_saleorder_b sb" +
" inner join so_saleorder s on sb.csaleorderid=s.csaleorderid" +
" left join bd_currtype bdc on s.corigcurrencyid=bdc.pk_currtype" +
" where sb.csaleorderbid='" + csourcebillbidStr + "' ";
Map<String, Object> value2 = (Map<String, Object>) queryBS.executeQuery(sql, new MapProcessor());
return value2;
}