Commit da1ae75d authored by stone's avatar stone

[fix]增值税台账数据修改

parent bf2c6bef
package com.hand.hls.hlcm.util;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
import org.apache.http.HttpStatus;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.util.List;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
/**
* Created with IntelliJ IDEA.
* Description:
* User: huangtianyang
* Date: 2018-08-23
* Time: 上午9:24
*/
public class HlsFileUtil {
private static Logger logger = LoggerFactory.getLogger(HlsFileUtil.class);
/**
* 批量打包
*
* @param files 需要打包的文件
* @param fileName 压缩文件名
*/
public static void zipFile(List<File> files, String fileName) throws IOException {
File zipFile = new File(fileName);
FileOutputStream outputStream = new FileOutputStream(zipFile);
ZipOutputStream out = new ZipOutputStream(outputStream);
// byte[] buffer = new byte[1024];
for (File file : files) {
FileInputStream in = null;
if (file.exists() && !file.isDirectory()) {
in = new FileInputStream(file);
out.putNextEntry(new ZipEntry(file.getName()));
IOUtils.copy(in, out);
// IOUtils.read(in, buffer);
// IOUtils.write(buffer, out);
}
IOUtils.closeQuietly(in);
}
IOUtils.closeQuietly(out);
IOUtils.closeQuietly(outputStream);
}
/*
* copy from weck
* */
public static void downloadFile(String filePath, String fileName, HttpServletResponse response) {
File file = new File(filePath);
if (!file.exists()) {
logger.error("target file does not exists.");
response.setStatus(HttpStatus.SC_NO_CONTENT);
} else {
response.setContentType("application/octet-stream");
// response.setContentType("application/force-download");// 设置强制下载不打开
// response.setContentType("multipart/form-data");
response.addHeader("Content-Disposition",
"attachment;fileName=" + fileName);// 设置文件名
response.setContentLength((int) (FileUtils.sizeOf(file)));
FileInputStream is = null;
OutputStream os = null;
doFileStream(response, file, is, os);
}
}
public static void downloadFile(String filePath, String fileName, HttpServletResponse response, String fileType) {
File file = new File(filePath);
if (!file.exists()) {
logger.error("target file does not exists.");
response.setStatus(HttpStatus.SC_NO_CONTENT);
} else {
response.setContentType(chooseMimeType(fileType));
// response.setContentType("application/force-download");// 设置强制下载不打开
// response.setContentType("multipart/form-data");
response.addHeader("Content-Disposition",
chooseHeader(fileName, fileType));// 设置文件名
response.setContentLength((int) (FileUtils.sizeOf(file)));
FileInputStream is = null;
OutputStream os = null;
doFileStream(response, file, is, os);
}
}
private static void doFileStream(HttpServletResponse response, File file, FileInputStream is, OutputStream os) {
try {
is = new FileInputStream(file);
os = response.getOutputStream();
IOUtils.copy(is, os);
} catch (Exception e) {
logger.error("io transformation failed when download file.", e);
} finally {
IOUtils.closeQuietly(is);
IOUtils.closeQuietly(os);
}
}
private static String chooseMimeType(String suffix) {
String mimeType;
switch (suffix) {
case "pdf":
mimeType = "application/pdf";
break;
default:
mimeType = "application/octet-stream";
}
return mimeType;
}
private static String chooseHeader(String fileName, String type) {
String header;
switch (type) {
case "pdf":
header = "inline;fileName=" + fileName;
break;
default:
header = "attachment;fileName=" + fileName;
}
return header;
}
}
<?xml version="1.0" encoding="UTF-8"?>
<!--
$Author: ZLF
$Date: 2015-1-21 下午3:09:38
$Revision: 1.0
$Purpose:
-->
<bm:model xmlns:bm="http://www.leaf-framework.org/schema/bm" needAccessControl="false">
<bm:operations>
<bm:operation name="query">
<bm:query-sql><![CDATA[
SELECT * FROM (
SELECT h.period_year,
h.period_num,
h.internal_period_num,
h.journal_date,
h.journal_num,
reference3 contract_number,
reference4 bp_code,
(SELECT BP_NAME
FROM hls_bp_master
WHERE bp_code = reference4
AND ROWNUM = 1) bp_name,
l.journal_header_id,
(SELECT hi.invoice_date
FROM acr_invoice_hd hi, acr_invoice_ln li
WHERE hi.invoice_hd_id = li.invoice_hd_id
AND hi.reversed_flag = 'N'
AND (li.cashflow_id = l.cashflow_id OR
li.ref_n03 = l.journal_header_id)
AND ROWNUM = 1) invoice_date,
SUM(decode(reference6, NULL, 0, NVL(l.amount_cr,0))) amount_tax,
DECODE(h.je_transaction_code,
'HL_CSH_CONSOLIDATION_DALAY',
'违约金',
'HL_SALES_TAX_ACT_NEW',
(SELECT DECODE(cf_item,
2,
'首付款',
8,
'留购价',
1,
times,
200,
'提前结清款',
250,
'回购款',
0,
'设备款')
FROM con_contract_cashflow
WHERE cashflow_id = l.cashflow_id)) times,
DECODE(h.je_transaction_code,
'HL_CSH_CONSOLIDATION_DALAY',
h.journal_date,
'HL_SALES_TAX_ACT_NEW',
(SELECT due_date
FROM con_contract_cashflow
WHERE cashflow_id = l.cashflow_id)) due_date,
DECODE(h.je_transaction_code,
'HL_CSH_CONSOLIDATION_DALAY',
SUM(decode(reference6, NULL, l.amount_dr, 0)),
'HL_SALES_TAX_ACT_NEW',
(SELECT due_amount
FROM con_contract_cashflow
WHERE cashflow_id = l.cashflow_id)) due_amount,
(SELECT principal
FROM con_contract_cashflow
WHERE cashflow_id = l.cashflow_id) principal,
DECODE(h.je_transaction_code,
'HL_CSH_CONSOLIDATION_DALAY',
SUM(decode(reference6, NULL, l.amount_dr, 0)),
'HL_SALES_TAX_ACT_NEW',
(SELECT decode(cf_item, 8, due_amount, interest)
FROM con_contract_cashflow
WHERE cashflow_id = l.cashflow_id)) interest,
DECODE(h.je_transaction_code,
'HL_CSH_CONSOLIDATION_DALAY',
SUM(decode(reference6, NULL, 0, NVL(l.amount_cr,0))),
'HL_SALES_TAX_ACT_NEW',
(SELECT vat_due_amount
FROM con_contract_cashflow
WHERE cashflow_id = l.cashflow_id)) vat_due_amount,
nvl(ROUND((DECODE(h.je_transaction_code,
'HL_CSH_CONSOLIDATION_DALAY',
SUM(decode(reference6, NULL, 0, NVL(l.amount_cr,0))),
'HL_SALES_TAX_ACT_NEW',
(SELECT vat_due_amount
FROM con_contract_cashflow
WHERE cashflow_id = l.cashflow_id))) /
(DECODE(h.je_transaction_code,
'HL_CSH_CONSOLIDATION_DALAY',
SUM(decode(reference6, NULL, l.amount_dr, 0)),
'HL_SALES_TAX_ACT_NEW',
(SELECT due_amount
FROM con_contract_cashflow
WHERE cashflow_id = l.cashflow_id
AND due_amount > 0)) -
DECODE(h.je_transaction_code,
'HL_CSH_CONSOLIDATION_DALAY',
SUM(decode(reference6, NULL, 0, NVL(l.amount_cr,0))),
'HL_SALES_TAX_ACT_NEW',
(SELECT vat_due_amount
FROM con_contract_cashflow
WHERE cashflow_id = l.cashflow_id
AND vat_due_amount > 0))),
2) * 100,
0) || '%' vat_rate,
h.je_transaction_code
FROM hls_journal_header h, hls_journal_detail l
WHERE h.journal_header_id = l.journal_header_id
AND h.je_transaction_code IN
('HL_SALES_TAX_ACT_NEW', 'HL_CSH_CONSOLIDATION_DALAY')
and( (trunc(h.journal_date)<=trunc(to_date('2020-01-31','yyyy-mm-dd')) and h.description='MANUAL_IMPORT')or(trunc(h.journal_date)>trunc(to_date('2020-01-31','yyyy-mm-dd'))))
AND not EXISTS (SELECT 1
FROM acr_invoice_hd hi, acr_invoice_ln li
WHERE hi.invoice_hd_id = li.invoice_hd_id
AND hi.vat_interface_status = 'BACK'
AND to_char(hi.invoice_date,'yyyymm') <= ${@base_period}
AND (li.cashflow_id = l.cashflow_id OR
li.ref_n04 = l.journal_line_id))
GROUP BY l.reference1,
reference3,
reference4,
h.journal_num,
l.cashflow_id,
l.journal_header_id,
h.je_transaction_code,
h.period_year,
h.period_num,
h.internal_period_num,
h.journal_date
UNION
SELECT h.period_year,
h.period_num,
h.internal_period_num,
h.journal_date,
h.journal_num,
reference3 contract_number,
reference4 bp_code,
(SELECT BP_NAME
FROM hls_bp_master
WHERE bp_code = reference4
AND ROWNUM = 1) bp_name,
l.journal_header_id,
(SELECT hi.invoice_date
FROM acr_invoice_hd hi, acr_invoice_ln li
WHERE hi.invoice_hd_id = li.invoice_hd_id
AND hi.reversed_flag = 'N'
AND hi.vat_interface_status = 'BACK'
AND li.cf_item = 2
and hi.contract_id = l.source_doc_id
AND ROWNUM = 1) invoice_date,
l.amount_dr amount_tax,
'首付款' times,
(SELECT due_date
FROM con_contract_cashflow
WHERE contract_id = l.source_doc_id
AND cf_item = 2
AND ROWNUM = 1) due_date,
(SELECT due_amount
FROM con_contract_cashflow
WHERE contract_id = l.source_doc_id
AND cf_item = 2
AND ROWNUM = 1)
due_amount,
(SELECT principal
FROM con_contract_cashflow
WHERE contract_id = l.source_doc_id
AND cf_item = 2
AND ROWNUM = 1) principal,
(SELECT interest
FROM con_contract_cashflow
WHERE contract_id = l.source_doc_id
AND cf_item = 2
AND ROWNUM = 1) interest,
(SELECT vat_due_amount
FROM con_contract_cashflow
WHERE contract_id = l.source_doc_id
AND cf_item = 2
AND ROWNUM = 1) vat_due_amount,
NVL(ROUND((
(SELECT vat_due_amount
FROM con_contract_cashflow
WHERE contract_id = l.source_doc_id
AND cf_item = 2
AND ROWNUM = 1)
/
(SELECT net_due_amount
FROM con_contract_cashflow
WHERE contract_id = l.source_doc_id
AND cf_item = 2
AND ROWNUM = 1)
),
2) * 100,
0) || '%' vat_rate,
h.je_transaction_code
FROM hls_journal_header h, hls_journal_detail l
WHERE h.journal_header_id = l.journal_header_id
AND h.je_transaction_code = 'LEASE_INCEPT'
AND l.je_template_ln_id = 8797
and( (trunc(h.journal_date)<=trunc(to_date('2020-01-31','yyyy-mm-dd')) and h.description='MANUAL_IMPORT')or(trunc(h.journal_date)>trunc(to_date('2020-01-31','yyyy-mm-dd'))))
AND not EXISTS
(SELECT 1
FROM acr_invoice_hd hi, acr_invoice_ln li
WHERE hi.invoice_hd_id = li.invoice_hd_id
AND hi.vat_interface_status = 'BACK'
AND to_char(hi.invoice_date,'yyyymm') <= ${@base_period}
AND ((hi.contract_id = l.source_doc_id AND li.cf_item IN (2))))
) t1
#WHERE_CLAUSE#
]]></bm:query-sql>
</bm:operation>
</bm:operations>
<bm:data-filters>
<bm:data-filter enforceOperations="query" expression="to_char(t1.journal_date,'yyyymm') = ${@base_period}"/>
</bm:data-filters>
<bm:query-fields>
<bm:query-field name="contract_number" queryExpression="t1.contract_number = ${@contract_number}"/>
<bm:query-field name="bp_name" queryExpression="t1.bp_name = ${@bp_name}"/>
<bm:query-field name="journal_date" queryExpression="to_char(t1.journal_date,'yyyy-mm-dd') = ${@journal_date}"/>
<bm:query-field name="invoice_date" queryExpression="to_char(t1.invoice_date,'yyyy-mm-dd') = ${@invoice_date}"/>
<bm:query-field name="invoice_kind" queryExpression="to_char(t1.invoice_kind,'yyyy-mm-dd') = ${@invoice_kind}"/>
</bm:query-fields>
</bm:model>
<?xml version="1.0" encoding="UTF-8"?>
<!--
$Author: ZLF
$Date: 2015-1-21 下午3:09:38
$Revision: 1.0
$Purpose:
-->
<bm:model xmlns:bm="http://www.leaf-framework.org/schema/bm" needAccessControl="false">
<bm:operations>
<bm:operation name="query">
<bm:query-sql><![CDATA[
SELECT * FROM (
SELECT h.period_year,
h.period_num,
h.internal_period_num,
h.journal_date,
h.journal_num,
reference3 contract_number,
reference4 bp_code,
(SELECT BP_NAME
FROM hls_bp_master
WHERE bp_code = reference4
AND ROWNUM = 1) bp_name,
l.journal_header_id,
(SELECT hi.invoice_date
FROM acr_invoice_hd hi, acr_invoice_ln li
WHERE hi.invoice_hd_id = li.invoice_hd_id
AND hi.reversed_flag = 'N'
AND (li.cashflow_id = l.cashflow_id OR
li.ref_n03 = l.journal_header_id)
AND ROWNUM = 1) invoice_date,
SUM(decode(reference6, NULL, 0, NVL(l.amount_cr,0))) amount_tax,
DECODE(h.je_transaction_code,
'HL_CSH_CONSOLIDATION_DALAY',
'违约金',
'HL_SALES_TAX_ACT_NEW',
(SELECT DECODE(cf_item,
2,
'首付款',
8,
'留购价',
1,
times,
200,
'提前结清款',
250,
'回购款',
0,
'设备款')
FROM con_contract_cashflow
WHERE cashflow_id = l.cashflow_id)) times,
DECODE(h.je_transaction_code,
'HL_CSH_CONSOLIDATION_DALAY',
h.journal_date,
'HL_SALES_TAX_ACT_NEW',
(SELECT due_date
FROM con_contract_cashflow
WHERE cashflow_id = l.cashflow_id)) due_date,
DECODE(h.je_transaction_code,
'HL_CSH_CONSOLIDATION_DALAY',
SUM(decode(reference6, NULL, l.amount_dr, 0)),
'HL_SALES_TAX_ACT_NEW',
(SELECT due_amount
FROM con_contract_cashflow
WHERE cashflow_id = l.cashflow_id)) due_amount,
(SELECT principal
FROM con_contract_cashflow
WHERE cashflow_id = l.cashflow_id) principal,
DECODE(h.je_transaction_code,
'HL_CSH_CONSOLIDATION_DALAY',
SUM(decode(reference6, NULL, l.amount_dr, 0)),
'HL_SALES_TAX_ACT_NEW',
(SELECT decode(cf_item, 8, due_amount, interest)
FROM con_contract_cashflow
WHERE cashflow_id = l.cashflow_id)) interest,
DECODE(h.je_transaction_code,
'HL_CSH_CONSOLIDATION_DALAY',
SUM(decode(reference6, NULL, 0, NVL(l.amount_cr,0))),
'HL_SALES_TAX_ACT_NEW',
(SELECT vat_due_amount
FROM con_contract_cashflow
WHERE cashflow_id = l.cashflow_id)) vat_due_amount,
nvl(ROUND((DECODE(h.je_transaction_code,
'HL_CSH_CONSOLIDATION_DALAY',
SUM(decode(reference6, NULL, 0, NVL(l.amount_cr,0))),
'HL_SALES_TAX_ACT_NEW',
(SELECT vat_due_amount
FROM con_contract_cashflow
WHERE cashflow_id = l.cashflow_id))) /
(DECODE(h.je_transaction_code,
'HL_CSH_CONSOLIDATION_DALAY',
SUM(decode(reference6, NULL, l.amount_dr, 0)),
'HL_SALES_TAX_ACT_NEW',
(SELECT due_amount
FROM con_contract_cashflow
WHERE cashflow_id = l.cashflow_id
AND due_amount > 0)) -
DECODE(h.je_transaction_code,
'HL_CSH_CONSOLIDATION_DALAY',
SUM(decode(reference6, NULL, 0, NVL(l.amount_cr,0))),
'HL_SALES_TAX_ACT_NEW',
(SELECT vat_due_amount
FROM con_contract_cashflow
WHERE cashflow_id = l.cashflow_id
AND vat_due_amount > 0))),
2) * 100,
0) || '%' vat_rate,
h.je_transaction_code
FROM hls_journal_header h, hls_journal_detail l
WHERE h.journal_header_id = l.journal_header_id
AND h.je_transaction_code IN
('HL_SALES_TAX_ACT_NEW', 'HL_CSH_CONSOLIDATION_DALAY')
and( (trunc(h.journal_date)<=trunc(to_date('2020-01-31','yyyy-mm-dd')) and h.description='MANUAL_IMPORT')or(trunc(h.journal_date)>trunc(to_date('2020-01-31','yyyy-mm-dd'))))
AND not EXISTS (SELECT 1
FROM acr_invoice_hd hi, acr_invoice_ln li
WHERE hi.invoice_hd_id = li.invoice_hd_id
AND hi.vat_interface_status = 'BACK'
AND to_char(hi.invoice_date,'yyyymm') <= ${@base_period}
AND (li.cashflow_id = l.cashflow_id OR
li.ref_n04 = l.journal_line_id))
GROUP BY l.reference1,
reference3,
reference4,
h.journal_num,
l.cashflow_id,
l.journal_header_id,
h.je_transaction_code,
h.period_year,
h.period_num,
h.internal_period_num,
h.journal_date
UNION
SELECT h.period_year,
h.period_num,
h.internal_period_num,
h.journal_date,
h.journal_num,
reference3 contract_number,
reference4 bp_code,
(SELECT BP_NAME
FROM hls_bp_master
WHERE bp_code = reference4
AND ROWNUM = 1) bp_name,
l.journal_header_id,
(SELECT hi.invoice_date
FROM acr_invoice_hd hi, acr_invoice_ln li
WHERE hi.invoice_hd_id = li.invoice_hd_id
AND hi.reversed_flag = 'N'
AND hi.vat_interface_status = 'BACK'
AND li.cf_item = 2
and hi.contract_id = l.source_doc_id
AND ROWNUM = 1) invoice_date,
l.amount_dr amount_tax,
'首付款' times,
(SELECT due_date
FROM con_contract_cashflow
WHERE contract_id = l.source_doc_id
AND cf_item = 2
AND ROWNUM = 1) due_date,
(SELECT due_amount
FROM con_contract_cashflow
WHERE contract_id = l.source_doc_id
AND cf_item = 2
AND ROWNUM = 1)
due_amount,
(SELECT principal
FROM con_contract_cashflow
WHERE contract_id = l.source_doc_id
AND cf_item = 2
AND ROWNUM = 1) principal,
(SELECT interest
FROM con_contract_cashflow
WHERE contract_id = l.source_doc_id
AND cf_item = 2
AND ROWNUM = 1) interest,
(SELECT vat_due_amount
FROM con_contract_cashflow
WHERE contract_id = l.source_doc_id
AND cf_item = 2
AND ROWNUM = 1) vat_due_amount,
NVL(ROUND((
(SELECT vat_due_amount
FROM con_contract_cashflow
WHERE contract_id = l.source_doc_id
AND cf_item = 2
AND ROWNUM = 1)
/
(SELECT net_due_amount
FROM con_contract_cashflow
WHERE contract_id = l.source_doc_id
AND cf_item = 2
AND ROWNUM = 1)
),
2) * 100,
0) || '%' vat_rate,
h.je_transaction_code
FROM hls_journal_header h, hls_journal_detail l
WHERE h.journal_header_id = l.journal_header_id
AND h.je_transaction_code = 'LEASE_INCEPT'
AND l.je_template_ln_id = 8797
and( (trunc(h.journal_date)<=trunc(to_date('2020-01-31','yyyy-mm-dd')) and h.description='MANUAL_IMPORT')or(trunc(h.journal_date)>trunc(to_date('2020-01-31','yyyy-mm-dd'))))
AND not EXISTS
(SELECT 1
FROM acr_invoice_hd hi, acr_invoice_ln li
WHERE hi.invoice_hd_id = li.invoice_hd_id
AND hi.vat_interface_status = 'BACK'
AND to_char(hi.invoice_date,'yyyymm') <= ${@base_period}
AND ((hi.contract_id = l.source_doc_id AND li.cf_item IN (2))))
) t1
#WHERE_CLAUSE#
]]></bm:query-sql>
</bm:operation>
</bm:operations>
<bm:data-filters>
<bm:data-filter enforceOperations="query" expression="t1.journal_date &lt;= add_months(last_day(to_date(${@base_period},'yyyymm')),-1)"/>
</bm:data-filters>
<bm:query-fields>
<bm:query-field name="contract_number" queryExpression="t1.contract_number = ${@contract_number}"/>
<bm:query-field name="bp_name" queryExpression="t1.bp_name = ${@bp_name}"/>
<bm:query-field name="journal_date" queryExpression="to_char(t1.journal_date,'yyyy-mm-dd') = ${@journal_date}"/>
<bm:query-field name="base_period" queryExpression="to_char(t1.journal_date,'yyyymm') &lt; ${@base_period}"/>
<bm:query-field name="invoice_date" queryExpression="to_char(t1.invoice_date,'yyyy-mm-dd') = ${@invoice_date}"/>
<bm:query-field name="invoice_kind" queryExpression="to_char(t1.invoice_kind,'yyyy-mm-dd') = ${@invoice_kind}"/>
</bm:query-fields>
</bm:model>
...@@ -27,7 +27,7 @@ var override_queryfields = [ ...@@ -27,7 +27,7 @@ var override_queryfields = [
var add_datafilters = [{ var add_datafilters = [{
name: 'base_period', name: 'base_period',
expression: "t1.invoice_date <= last_day(to_date(${@base_period},'yyyymm'))" expression: "to_char(t1.invoice_date,'yyyymm') = ${@base_period}"
}]; }];
override(); override();
......
...@@ -19,6 +19,17 @@ ...@@ -19,6 +19,17 @@
record.set('base_period_n',new Date().format('yyyy-mm').toString()); record.set('base_period_n',new Date().format('yyyy-mm').toString());
} }
}; };
//查询时调用
window['${/parameter/@bp_seq}${/parameter/@layout_code}_on_layout_dynamic_grid_query'] = function(ds, qpara, bp_seq) {
var grid_ds_id_before= get_dsid_by_tabcode_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'G_BEFORE_RESULT', 'con_contract');
var grid_ds_id_current= get_dsid_by_tabcode_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'G_CURRENT_RESULT', 'con_contract');
//debugger
if(ds.id==grid_ds_id_before){
ds.setQueryUrl('${/request/@context_path}/autocrud/rpt.RPT555.con_je_vat_query/query');
}else if(ds.id==grid_ds_id_current){
ds.setQueryUrl('${/request/@context_path}/autocrud/rpt.RPT555.con_je_vat_current_query/query');
}
};
]]></script> ]]></script>
<a:screen-include screen="modules/cont/CON500/con_contract_get_layout_code.lview"/> <a:screen-include screen="modules/cont/CON500/con_contract_get_layout_code.lview"/>
</a:view> </a:view>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment