对方科目的取数逻辑和二开指导原创
金蝶云社区-小红没有帽
小红没有帽
33人赞赏了该文章 1,259次浏览 未经作者许可,禁止转载编辑于2022年07月01日 09:40:55

以下均基于PT-146887(202109 补丁,企业版补丁号7.7.2297.10,标准版补丁号PT-146889(7.7.2298.5)及以后版本适用,其他早期版本逻辑介绍部分不完全适用。


1.      二开接口使用,建议调用Kingdee.K3.FIN.GL.App.Core.VchOtherSideEntryInfor 的相关方法,此类包括VchOtherSideEntryInfor的构造函数,和GetVoucherOtherSideEntryInfor的取数方法,其中构造函数输入参数有两个1.上下文Context,2.需要获取对方科目的完整凭证信息(tempTableVoucherchEntry 临时表(string类型)))

临时表tempTableVoucherchEntry结构如下(以下字段均可在凭证分录表T_GL_VOUCHERENTRY中取到):

            FVOUCHERID           int                  not null default 0, 凭证内码

            FENTRYID             int                  not null default 0,分录内码

            FAccountID           int                  not null default 0,科目内码

            FAMOUNT              decimal(28,10)       not null default 0,本位币金额

            FAMOUNTFOR           decimal(28,10)       not null default 0,原币金额

            FExchangeRate        decimal(23,10)       not null default 0,汇率

            FDC                  int                  not null default 0 分录方向

示例代码如下:

image.png


返回值为临时表,其中字段如下:

                FVoucherID           int                  not null default 0,凭证内码

                FEntryID             int                  not null default 0,分录内码

                FDC                  smallint             not null default -1,分录方向

                FAccountID           int                  not null default 0,科目内码

                FAmount              decimal(28,10)       not null default 0,本位币金额

                FAmountFor           decimal(28,10)       not null default 0,原币金额

                FExchangeRate        decimal(23,10)       not null default 0,汇率

                FSideEntryID         int                  not null default 0,对方分录内码

                FSideDC              smallint             not null default -1,对方分录方向

                FSideAccountID       int                  not null default 0,对方科目内码

                FSideAmount          decimal(28,10)       not null default 0,对方本位币金额

                FSideAmountFor       decimal(28,10)       not null default 0,对方原币金额

                FSideExchangeRate    decimal(23,10)       null default 0对方汇率

2.      对方科目取数逻辑:

  1. 根据单张凭证中的分录顺序,借贷平衡为判断依据,对凭证内部进行分录编组,达成接待平衡的数据为一组,实际匹配对方科目时会进行隔离(可理解为不同凭证),以下会以组作为最小单元进行对方科目匹配

  2. 如果组内分录为全借方或全贷方,将会进行红字转换

  3. 循环组内数据,将表外科目的分录先进行匹配,匹配原则为自己对自己,

  4. 循环组内剩余数据,处理一借多贷,一贷多借的场景,对方科目为自己的反方向,

  5. 循环组内剩余数据,处理多借多贷的数据:

    1. 优先金额相等的借贷分录进行匹配

    2. 剩余为全借方或全贷方的组内数据进行红字转换

    3. 对转换后的借贷分录进行分别计数(以数量少的为本方,数量多的为对方)

    4. 循环本方数据,读取金额,并依次从对方科目进行金额取数(多退少补的原则),直到所有本方科目匹配完成

  6. 对以上拆分数据除表外科目的部分进行借贷互换的倍增(确保每条分录都能找到自己的对方)

 


赞 33