代码语言
.
CSharp
.
JS
Java
Asp.Net
C
MSSQL
PHP
Css
PLSQL
Python
Shell
EBS
ASP
Perl
ObjC
VB.Net
VBS
MYSQL
GO
Delphi
AS
DB2
Domino
Rails
ActionScript
Scala
代码分类
文件
系统
字符串
数据库
网络相关
图形/GUI
多媒体
算法
游戏
Jquery
Extjs
Android
HTML5
菜单
网页交互
WinForm
控件
企业应用
安全与加密
脚本/批处理
开放平台
其它
【
OracleEBS
】
客户对账单-本月欠款
作者:
专注Oracle EBS
/ 发布于
2012/11/29
/
699
create or replace function byamountfn ( customernum varchar2, startdate date, enddate date ) return char is v_amount number; v_receipt_amount number; refundamount number; l_receive_amount1 number; l_receive_amount2 number; lastdebt number; thisamount number; thismoeny number; upextendedamount number; begin ---------------------------**********得到上月欠款**************------------------------------- select sum(nvl(rct.extended_amount_tax, 0)) extended_amount --当前参数日期之前的所有货款 into v_amount from (select ctl.customer_trx_line_id, ct.customer_trx_id, ct.initial_customer_trx_id, ct.trx_number, nvl(cux_ar_utl_pkg.get_trx_gl_date(ct.customer_trx_id), ct.trx_date) trx_date, ct.bill_to_customer_id, nvl(ctl.gross_extended_amount, ctl.extended_amount) extended_amount_tax from ra_customer_trx_all ct, ra_customer_trx_lines_all ctl, hz_parties hpt, hz_cust_accounts hca, ra_cust_trx_types_all ctt, mtl_units_of_measure uom where ct.customer_trx_id = ctl.customer_trx_id and ct.org_id = ctl.org_id and ct.bill_to_customer_id = hca.cust_account_id and hca.party_id = hpt.party_id and ctt.cust_trx_type_id = ct.cust_trx_type_id and ctl.line_type != 'TAX' and ctt.type in ('INV', 'CM') and ctt.cust_trx_type_id != cux_ar_utl_pkg.get_return_commitment_type -- AND ctt.NAME != 'SH-内销开帐' and ctl.uom_code = uom.uom_code(+)) rct where 1 = 1 and rct.bill_to_customer_id = (select a.customer_id from ar_customers a where a.customer_number = customernum) and rct.trx_date <= startdate - 1; select sum(nvl(acr.functional_amount, 0)) --当前参数日期之前的所有应付款 into v_receipt_amount from ar_cash_receipts_v acr where acr.gl_date <= startdate - 1 and acr.state != 'REVERSED' and acr.customer_id = (select a.customer_id from ar_customers a where a.customer_number = customernum); select nvl(sum(araa.amount_applied), 0) --当前参数日期之前的所有退款 into refundamount from ar_cash_receipt_history_all acrh, ar_cash_receipts_all acr, ar_receivable_applications_all araa where acrh.gl_date <= startdate - 1 and acrh.status != 'REVERSED' and acr.cash_receipt_id = acrh.cash_receipt_id and acrh.cash_receipt_history_id = araa.cash_receipt_history_id and araa.applied_customer_trx_id is null and acrh.org_id = acr.org_id and araa.display = 'Y' and araa.status = 'ACTIVITY' and acr.pay_from_customer = (select a.customer_id from ar_customers a where a.customer_number = customernum); lastdebt := (v_amount - v_receipt_amount + refundamount); --小于当前日期之前的所有货款 减去 小于当前日期之前的所有应付帐款 加小于当前日期之前的所有退款=上月欠款 ---------------------------***********本月货款**********------------------------------- select nvl(sum(extended_amount), 0) into thisamount from (select ct.trx_number, ct.trx_date, decode(ctl.gross_extended_amount, null, ctl.extended_amount, ctl.gross_extended_amount) as extended_amount from ra_customer_trx_all ct, ra_customer_trx_lines_all ctl, hz_parties hpt, hz_cust_accounts hca, ra_cust_trx_types_all ctt, mtl_units_of_measure uom, ra_cust_trx_line_gl_dist_all rctl where ct.customer_trx_id = ctl.customer_trx_id and rctl.customer_trx_id = ct.customer_trx_id and 'REC' = rctl.account_class and 'Y' = rctl.latest_rec_flag and ct.org_id = ctl.org_id and ct.bill_to_customer_id = hca.cust_account_id and hca.party_id = hpt.party_id and ctt.cust_trx_type_id = ct.cust_trx_type_id and ctl.line_type != 'TAX' and ctt.type in ('INV', 'CM') and ctt.cust_trx_type_id != cux_ar_utl_pkg.get_return_commitment_type -- AND ctt.NAME != 'SH-内销开帐' and ctl.uom_code = uom.uom_code(+) and to_char(rctl.gl_date, 'yyyy-mm-dd') between to_char(startdate, 'YYYY-MM-DD') and to_char(enddate, 'YYYY-MM-DD') and hca.account_number = customernum); ---------------------------**********本月回款************------------------------------- select nvl(sum(acr.functional_amount), 0) --付款 into l_receive_amount1 from ar_cash_receipts_v acr where to_char(acr.gl_date, 'YYYY-MM-DD') between to_char(startdate, 'YYYY-MM-DD') and to_char(enddate, 'YYYY-MM-DD') and acr.state != 'REVERSED' and acr.customer_id = (select a.customer_id from ar_customers a where a.customer_number = customernum); select nvl(sum(araa.amount_applied), 0) --退款 into l_receive_amount2 from ar_cash_receipt_history_all acrh, ar_cash_receipts_all acr, ar_receivable_applications_all araa where to_char(acrh.gl_date, 'YYYY-MM-DD') between to_char(startdate, 'YYYY-MM-DD') and to_char(enddate, 'YYYY-MM-DD') and acrh.status != 'REVERSED' and acr.cash_receipt_id = acrh.cash_receipt_id and acrh.cash_receipt_history_id = araa.cash_receipt_history_id and araa.applied_customer_trx_id is null and acrh.org_id = acr.org_id and araa.display = 'Y' and araa.status = 'ACTIVITY' and acr.pay_from_customer = (select a.customer_id from ar_customers a where a.customer_number = customernum); thismoeny := (l_receive_amount1 - l_receive_amount2); --本月回款 = 本月应付帐款-本月退款 ---------------------------**********本月欠款************------------------------------- --本月欠款= 上月欠款+本月货款-本月回款 upextendedamount := (lastdebt + thisamount - thismoeny); return upextendedamount; end; cux_ar_utl_pkg.get_return_commitment_type function get_return_commitment_type return number is cursor csr_type is select cust_trx_type_id from ra_cust_trx_types_all where name = 'SH-保证金退回'; retval number; begin open csr_type; fetch csr_type into retval; close csr_type; return nvl(retval, -1); end;
试试其它关键字
本月欠款
同语言下
.
设置窗体的位置
.
初始化操作
.
在FORMS调用WEB页面
.
判断数据块的项是否为空
.
EBS 循环处理块记录
.
Oracle Form中调用并发请求生成报表并输出为PDF的方法
.
添加并发程序到指定职责API
.
EBS请求查询输出
.
删除 AP 发票相关脚本
.
ebs安全性
可能有用的
.
C#实现的html内容截取
.
List 切割成几份 工具类
.
SQL查询 多列合并成一行用逗号隔开
.
一行一行读取txt的内容
.
C#动态修改文件夹名称(FSO实现,不移动文件)
.
c# 移动文件或文件夹
.
c#图片添加水印
.
Java PDF转换成图片并输出给前台展示
.
网站后台修改图片尺寸代码
.
处理大图片在缩略图时的展示
专注Oracle EBS
贡献的其它代码
(
66
)
.
ERP系统里的BOM展开函数
.
EBS查找报表或菜单所属职责
.
查询用户客户化的文件配置
.
SQL写出带扩展数量的BOM多级清单
.
oracle开发常用LOV
.
Oracle Patch 版本的查询
.
科目余额SQL
.
根据报表文件名称关键字查找报表的执行文件名称等信息
.
查找在标准请求组里提交的报表所在的职责
.
查找在菜单里提交的报表所在职责
Copyright © 2004 - 2024 dezai.cn. All Rights Reserved
站长博客
粤ICP备13059550号-3