Commit a23e89cf authored by 陆正友's avatar 陆正友

扫码枪发票优化

parent a0851e30
<?xml version="1.0" encoding="UTF-8"?>
<!--
$Author: zhuxianfei
$Date: 2018/7/26 14:11
$Revision: 1.0
-->
<bm:model xmlns:bm="http://www.leaf-framework.org/schema/bm">
<bm:operations>
<bm:operation name="update">
<bm:update-sql><![CDATA[
begin
acp_invoice_import_pkg.ACP_INVOICE_IMPORT_TOTAL(
p_invoice_type => ${@invoice_type},
p_invoice_code => ${@invoice_code},
p_invoice_number => ${@invoice_number},
p_total_amount => ${@total_amount},
p_invoice_date => ${@invoice_date},
p_user_id => ${/session/@user_id},
p_contract_id => ${@contract_id});
end;
]]>
</bm:update-sql>
</bm:operation>
<bm:operation name="execute">
<bm:update-sql><![CDATA[
begin
acp_invoice_import_pkg.submit_wfl( p_contract_id => ${@contract_id},
p_user_id => ${/session/@user_id},
p_company_id => ${/session/@company_id});
end;
]]>
</bm:update-sql>
</bm:operation>
</bm:operations>
</bm:model>
......@@ -2,74 +2,76 @@
<a:screen xmlns:a="http://www.leaf-framework.org/application" customizationEnabled="true" dynamiccreateenabled="true"
trace="true">
<a:init-procedure>
<a:model-query defaultWhereClause="t1.user_id=${/session/@user_id}" model="basic.sys_session_info" rootPath="user_name_path"/>
<a:model-query defaultWhereClause="t1.user_id=${/session/@user_id}" model="basic.sys_session_info"
rootPath="user_name_path"/>
</a:init-procedure>
<a:view>
<a:link id="acp_invoice_inf_import_link" model="acp.ACP522.acp_invoice_inf_import" modelaction="update"/>
<a:link id="acp_invoice_inf_import_total_link" model="acp.ACP522.acp_invoice_inf_import_total" modelaction="update"/>
<a:link id="acp_invoice_inf_import_submit_link" model="acp.ACP522.acp_invoice_inf_import" modelaction="execute"/>
<script src="${/request/@context_path}/javascripts/calculate.js" type="text/javascript"/>
<script><![CDATA[
//移除前事件(grid,attach,gridbox,table)
window['${/parameter/@bp_seq}${/parameter/@layout_code}_on_layout_dynamic_grid_brfore_remove'] = function(ds, record, bp_seq) {
window['${/parameter/@bp_seq}${/parameter/@layout_code}_on_layout_dynamic_grid_brfore_remove'] = function (ds, record, bp_seq) {
return true;
};
Leaf.onReady(function () {
//document.getElementById("ext-gen935").placeholder = "在这输入姓名..";
// document.getElementById("ext-gen124").style.backgroundColor = 'red';
// document.getElementById("ext-gen124").setAttribute('placeholder','注:扫描时请将鼠标光标放在此处。。。');
// document.getElementById("ext-gen124").style.backgroundColor = 'red';
// document.getElementById("ext-gen124").setAttribute('placeholder','注:扫描时请将鼠标光标放在此处。。。');
//document.getElementById("ext-gen124").style.color = 'red';
//document.getElementById("ext-gen124").style.backgroundColor = '#FF7744';
var first=document.getElementsByClassName("item-input-wrap");
var second=first[2].getElementsByClassName('item-textField');
var third=second[0];
third.setAttribute('placeholder','注:扫描时请将鼠标光标放在此处。。。');
var first = document.getElementsByClassName("item-input-wrap");
var second = first[2].getElementsByClassName('item-textField');
var third = second[0];
third.setAttribute('placeholder', '注:扫描时请将鼠标光标放在此处。。。');
third.style.backgroundColor = '#FF7744';
});
//新增时调用(grid,table,gridBox)
window['${/parameter/@bp_seq}${/parameter/@layout_code}_on_layout_dynamic_grid_add'] = function(ds, record, config_records, bp_seq) {
record.set("created_by_n",'${/model/user_name_path/record/@user_desc}');
record.set("created_by",'${/session/@user_id}');
record.set("update_date",new Date());
window['${/parameter/@bp_seq}${/parameter/@layout_code}_on_layout_dynamic_grid_add'] = function (ds, record, config_records, bp_seq) {
record.set("created_by_n", '${/model/user_name_path/record/@user_desc}');
record.set("created_by", '${/session/@user_id}');
record.set("update_date", new Date());
};
//提交审批
window['${/parameter/@layout_code}_submit_approval_layout_dynamic_click'] = function() {
window['${/parameter/@layout_code}_submit_approval_layout_dynamic_click'] = function () {
debugger;
var hd_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'con_contract');
var ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'acp_invoice_ln');
var hd_record = $(hd_id).getAt(0);
var lease_item_amount=hd_record.get('lease_item_amount');
if($(ds_id).getAll().dirty){
var lease_item_amount = hd_record.get('lease_item_amount');
if ($(ds_id).getAll().dirty) {
return;
}
if ($(ds_id).validate()) {
debugger;
var records = $(ds_id).getAll();
if(records.length<1){
if (records.length < 1) {
Leaf.showMessage('提示', '未查询到发票信息,请添加发票信息!');
return;
}
var sum=0;
var sum = 0;
var sum_tax = 0;
var net_lease_item_amount = hd_record.get('net_lease_item_amount')||0;
for (var i = 0;i < records.length;i++) {
if(records[i].dirty){
var net_lease_item_amount = hd_record.get('net_lease_item_amount') || 0;
for (var i = 0; i < records.length; i++) {
if (records[i].dirty) {
Leaf.showMessage('${l:HLS.PROMPT}', '${l:HLS.EXECUTE_AFTER_SAVE}');
return;
}
var tempa=records[i].get('total_amount')||0;
var tempa = records[i].get('total_amount') || 0;
//var tempb=((records[i].get('net_amount')||0)+(records[i].get('tax_amount')||0));
var tempb=plus((records[i].get('net_amount')||0),(records[i].get('tax_amount')||0));
if(tempa!=tempb){
var tempb = plus((records[i].get('net_amount') || 0), (records[i].get('tax_amount') || 0));
if (tempa != tempb) {
Leaf.showMessage('提示', '发票明细行存在价税合计不等于不含税金额和税额之和!');
return;
}
var r = records[i];
var d = r.get(name);
var n = records[i].get('total_amount')||0;
var n = records[i].get('total_amount') || 0;
if (!isNaN(n)) {
sum = plus(sum, n);
}
......@@ -81,42 +83,42 @@
// }
// 营业外收入或营业外支出科目金额超过1,请联系系统管理员!
if (!isNaN(records[i].get('tax_amount')||0)) {
sum_tax=plus((records[i].get('tax_amount')||0),(sum_tax||0));
if (!isNaN(records[i].get('tax_amount') || 0)) {
sum_tax = plus((records[i].get('tax_amount') || 0), (sum_tax || 0));
}
//校验重复发票号码 add by 26887cz 2021-09-07
for(var j =i+1;j < records.length;j++){
if(records[i].get('invoice_number')==records[j].get('invoice_number')){
//校验重复发票号码 add by 26887cz 2021-09-07
for (var j = i + 1; j < records.length; j++) {
if (records[i].get('invoice_number') == records[j].get('invoice_number')) {
Leaf.showMessage('提示', '发票号码重复,请重新扫描输入!');
return;
}
}
}
if(sum!=lease_item_amount){
if (sum != lease_item_amount) {
Leaf.showMessage('提示', '本次发票明细含税总计不等于该合同设备价!');
return;
}
var diff = ((net_lease_item_amount + sum_tax - lease_item_amount) > 0 ? (net_lease_item_amount + sum_tax - lease_item_amount) : (lease_item_amount - sum_tax - net_lease_item_amount));
if(diff >1){
if (diff > 1) {
Leaf.showMessage('提示', '营业外收入或营业外支出科目金额超过1,请联系系统管理员!');
return;
}
Leaf.showConfirm('${l:HLS.PROMPT}', '确定提交审批吗?', function() {
Leaf.showConfirm('${l:HLS.PROMPT}', '确定提交审批吗?', function () {
window['${/parameter/@bp_seq}${/parameter/@layout_code}_lock_layout_dynamic_window']();
Leaf.request({
url: $('acp_invoice_inf_import_submit_link').getUrl(),
para: {
contract_id: hd_record.get('contract_id')
},
success: function(res) {
success: function (res) {
window['${/parameter/@bp_seq}${/parameter/@layout_code}_unlock_layout_dynamic_window']();
$('${/parameter/@winid}').close();
},
failure: function() {
failure: function () {
window['${/parameter/@bp_seq}${/parameter/@layout_code}_unlock_layout_dynamic_window']();
},
error: function() {
error: function () {
window['${/parameter/@bp_seq}${/parameter/@layout_code}_unlock_layout_dynamic_window']();
},
scope: this
......@@ -126,11 +128,11 @@
};
//更新时调用
window['${/parameter/@bp_seq}${/parameter/@layout_code}_on_layout_dynamic_update'] = function(ds, record, name, value, old_value, bp_seq) {
window['${/parameter/@bp_seq}${/parameter/@layout_code}_on_layout_dynamic_update'] = function (ds, record, name, value, old_value, bp_seq) {
var ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'con_contract');
var acp_ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'acp_invoice_ln');
var record = $(ds_id).getAt(0);
if(name == 'invoice'&&value&&record.get('contract_id')) {
if (name == 'invoice' && value && record.get('contract_id')) {
var contract_id = record.get('contract_id');
var strs = value.split(',');
var invoice_type = strs[1];
......@@ -138,14 +140,15 @@
var invoice_number = strs[3];
var net_amount = strs[4];
var invoice_date = strs[5];
var total_amount =strs[4];
//检验设备价格需要大于不含税金额
if (strs.length ==9) {
//校验重复发票号码 add by 26887cz 2021-09-07
if (strs.length == 9) {
//校验重复发票号码 add by 26887cz 2021-09-07
var acr_records = $(acp_ds_id).getAll();
for(var i= 0 ; i<acr_records.length ;i++){
if(acr_records[i].get("invoice_number") == invoice_number){
for (var i = 0; i < acr_records.length; i++) {
if (acr_records[i].get("invoice_number") == invoice_number) {
Leaf.showMessage('提示', '发票号码重复,请重新扫描!');
setTimeout(function() {
setTimeout(function () {
record.set('invoice', '');
}, 50);
return;
......@@ -161,24 +164,70 @@
invoice_date: invoice_date,
contract_id: contract_id
},
success: function () {
Leaf.SideBar.show({
msg: '导入成功',
duration: 2000
}
);
setTimeout(function() {
setTimeout(function () {
record.set('invoice', '');
}, 50);
$(acp_ds_id).setQueryParameter('contract_id', '${/parameter/@contract_id}');
$(acp_ds_id).query();
},failure: function() {
setTimeout(function() {
$(acp_ds_id).setQueryParameter('contract_id', '${/parameter/@contract_id}');
$(acp_ds_id).query();
}, failure: function () {
setTimeout(function () {
record.set('invoice', '');
}, 50);
},
error: function() {
setTimeout(function() {
error: function () {
setTimeout(function () {
record.set('invoice', '');
}, 50);
},
scope: this
});
} else if (strs.length == 8) {
//校验重复发票号码 add by 26887cz 2021-09-07
var acr_records = $(acp_ds_id).getAll();
for (var i = 0; i < acr_records.length; i++) {
if (acr_records[i].get("invoice_number") == invoice_number) {
Leaf.showMessage('提示', '发票号码重复,请重新扫描!');
setTimeout(function () {
record.set('invoice', '');
}, 50);
return;
}
}
Leaf.request({
url: $('acp_invoice_inf_import_total_link').getUrl(),
para: {
invoice_type: invoice_type,
invoice_code: invoice_code,
invoice_number: invoice_number,
total_amount: total_amount,
invoice_date: invoice_date,
contract_id: contract_id
},
success: function () {
Leaf.SideBar.show({
msg: '导入成功',
duration: 2000
}
);
setTimeout(function () {
record.set('invoice', '');
}, 50);
$(acp_ds_id).setQueryParameter('contract_id', '${/parameter/@contract_id}');
$(acp_ds_id).query();
}, failure: function () {
setTimeout(function () {
record.set('invoice', '');
}, 50);
},
error: function () {
setTimeout(function () {
record.set('invoice', '');
}, 50);
},
......@@ -186,13 +235,12 @@
});
} else {
Leaf.showMessage('提示', '发票信息有错误,请重新扫描!');
setTimeout(function() {
setTimeout(function () {
record.set('invoice', '');
}, 50);
}
}
};
]]></script>
<a:screen-include screen="modules/cont/CON500/con_contract_get_layout_code.lview"/>
</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