My favorites | Sign in
Project Home Downloads Wiki Issues Source
READ-ONLY: This project has been archived. For more information see this post.
Search
for
c8  
Updated Jun 28, 2012 by jiangjia...@gmail.com

tables

haschargedpaid 已收已付
currentprocessamount当前收款/付款

收款

520 sale
524sale_return
845receivableadjust

付款

532purchase
536purchasereturn
847payableadjust

预收?

526charge

预付?

538payment

合作伙伴partnerbalance 按部门核算

haspaid付款
hascharged收款
receivable应收
payable应付
advance_received预收
advance+payment预付

x_e_UpdatePartnerBalance 更新合作伙伴余额

更新合作伙伴余额

参数

noteId表单id
tableid表id
partnerId合作伙伴id
departmentId表单部门id
receivable应收
payable应付
advanceReceived预收
advancePayment预付

PartnerBalance表结构

IndexNo
partnerId合作伙伴Id
departmentId部门Id
initReceivableBalance初始化应收
initAdvanceReceivedBalance初始化预收
initPayableBalance初始化应付
initAdvancePaymentBalance初始化预付
receivableBalance应收
payableBalance应付
AdvanceReceivedBalance预收
advanceReceivedBalance预付

更新各个相应字段

调价

x_e_adjustPrice

凭证

|借135库存科目

调价金额
贷541 其它业务收入调价金额

应付调整

1. 遍历明细更新收支类型余额

2. 更新合作伙伴余额

汇总明细收支类型科目和金额,根据类型0取负数,总金额取负数

凭证

借 收支类型科目和金额金额
贷 204 应付总金额

现金银行变动 x_e_BankInOut

银行存取款

x_e_MoveBank

转出和转入部门是否一致

一致情况

凭证

出现金银行部门->如现金银行部门

借 进现金或银行存款总金额
贷 出现金或银行存款总金额

不一致 出现金银行部门->入现金银行部门

借205内部应付总金额
贷 出现金或银行存款总金额

入现金银行部门->出现金银行部门

借 入现金或银行存款总金额
贷 123内部应收总金额

银行存取款

x_e_bankinout

调拨 x_e_allot

1. 遍历明细,执行出库和入库,出库更新aprice,入库更新加权平均价格,计算总成本

出仓库部门=入仓库部门

凭证

出部门->出部门

借135库存商品总金额-总成本
贷 541 其它业务收入总金额-总成品

不等于

出部门->入部门

借123 内部应收总金额
借512 商品销售成本B成本
贷135库存商品成本
贷502库存销售收入B,总金额

入部门->出部门

借135库存商品总金额
贷205内部应付总金额

工资单

x_e_salaryandbonus

更新收支类别余额

凭证

借511 管理费用总金额
贷215 应付工资总金额

应收调整

1. 遍历明细更新收支类型余额

2. 更新合作伙伴余额

汇总明细收支类型科目和金额,根据类型0取负数,总金额取负数

凭证

x_e_purchaseReturn 采购退货

借 122 应收总金额
贷 收支类型科目和金额金额

1. 遍历明细,更新库存,更新加权成本价,更新明细成本价格

2.

total_amount
tax_total
goods_total
change_total成本价,注意获取方式,当退货导致数量为0时

凭证一

借135 库存商品成本注意,已是负数
借 221002001 进项税
借 541 其它业务收入负 goods_total-change_total
贷 204 应付款负total_amount

凭证2

库存部门-部门

借135 成本负
借221002001tax_total负
借541 goods_total-change_total负
贷205 内部应付total_amount负

凭证3

部门到库存部门

借123 内部应付total_amount负
贷135成品负
贷221002001tax_total负
都541goods_total-change_total

x_e_SaleReturn 销售退货

销售退货-退货入库不更新成本价格

遍历明细,更新库存,获取当前成本价格,更新成本价格

goods_cost_total总成本
total_amount总金额+税
tax_total
goods_total总金额,不含税

减合作伙伴应付

凭证1

|| total_amount 乘-1
借122 应收账款
借511 商品销售成本 goods_cost_total 乘-1
贷501 商品销售收入goods_total 乘-1
贷135 库存商品 goods_cost_total乘-1
贷221002003 tax_total乘-1

凭证2

仓库部门-部门

借 123 内部应收goods_cost_total乘-1
贷135 库存商品 goods_cost_total乘-1

部门-仓库部门

借135 库存商品goods_cost_total乘-1
贷205 内部应付goods_cost_total乘-1

x_e_updategoodsStockBalance 更新商品数量/成本价返回成本价

参数

noteId表单id
tableId表id
storeId仓库id
goodsid货品id
quantity数量
price单价
updateAPricetype0 不更新成本 1 按加权平均更新成本 3 仅更新价格
output 返回成本价 当updateApriceType为1时返回总金额,总数量乘传入的单价

不更新成本

如果传入quantity大于0 ,仅当前库存商品数量为0,金额为0时用price,quantity更新 传入小于0,则更新数量

返回当前成本

按加权平均更新成本

新数量=quantity+原数量

如果新数量大于0 ,计算新成本, (quantity*price+ 原数量原成本)/新数量

更新数量和成本价

如果新数量等于0 ,考虑采购退货后库存为0时,则仅更新数量

其它值,库存出现负数,报告错误

返回成本价

x_e_checkStockCanUse

参数

tableid
goodsid
quantity单据的数量
currentquantity库存数量
currentonroad库存在途数量

出库时currentquantity -currentonroad 必须大于quantity

x_e_payment 采购付款

明细按单据类型分类

||已收,单据类型 520 sale,524 salereturn ,854 receivableadjust)
detail_total全部金额汇总
received_total
payment_total已付,单据类型532 purchase, 536 purchasereturn,847 payableadjust
advance_received预收 单据类型526 charge
advance_payment 预付 单据类型538 payment
advance_payment+ @total_amount-@detail_title允许单据总金额不同于合计,这样多出的部分也算作预付

遍历付款明细

如果是526 charge 且单号是0,则更新合作伙伴 已收款-当前付款

如果是538 payment 且单号为0,则更新合作伙伴已付款+当前付款

如果是526 charge 且单号不为0,则更新charge.advance_received_process+当前付款

如果是538 payment 且单号不为0,则更新payment.advance_payment_process+当前付款

如果是532 purchase 且单号不为0, 则更新purchase.haspaid+当前付款

如果是536,且单号不为0,则更新purchasereturn.haspiad-当前付款

如果是847 payableadjust 且单号不为0则根据类型0 已付-当前付款,否则+当前付款

如果是520 sale ,且单号不为0,则sale.haschargd- 当前付款

如果是540 salereturn 且单号不为0,则salereturn.hascharged+当前付款

如果是845 receivableadjust,根据类型receivableadjust.hascharged+ 或-当前付款

凭证一

借 204 应付 payment_total
借126 预付款advance_payment
贷 100 现金或银行存款total_amount
122 应收账款received_total乘-1
贷 206 预付款advance_received 乘 -1

银行部门不等于单据部门

凭证2

部门到银行部门

借 现金或银行存款总金额
贷 205 内部应付总金额

凭证2

银行部门到部门

借123 内部应收总金额
贷 现金或银行存款总金额

x_e_charge 销售收款

c8/c9映射

表charge/chargedetailsale_charge/sale_charge_line

currentprocessamount列
relationtable int form_name nvarchar

涉及单据列映射

hascharged/haspaidpaid

在c8中,单据头只有总金额和已付/已收,所有的收款付款均在销售收款/销售付款中处理

比较搞,遍历收款明细

如果单据类型是520 sale并且单号是0,则视为期初应收, 合作伙伴的已付-当前付款

如果单据类型是532 purchase 并且单号是0 ,则视为期初应付 合作伙伴已付+当前金额

如果单据类型是526 charge并且单号不为0,则更新对应单据的预收记录 advancereceivedprocess

如果单据类型是538 payment并且单号不为0,则更新对应单据的预付字段 advancepaymentprocess

如果单据类型是520 sale并且单号不为0,则更新对应单据的hasCharge

如果单据类型是524 salereturn ,并且单号不为0则更新hascharged-currentprocess

如果单据是845 receivableadjust 并且单号不为0根据调整类型0 - ,其它加,更新对应单据的hascharged字段

如果单据是532 purchase,并且单号不为0,则更新对应单据的haspaid-currentprocess

如果单据是536 purchasereturn 并且单号不为0,则更新对应单据的haspaid+currentprocess

如果单据是847 并且单号不为0,根据调整类型0+,其它减payableadjust haspaid 字段

凭证一

借 101/102现金或银行存款总金额
借 204 应付款
借 126 预付款
贷 122 应收款
贷 206 预收款

凭证二

部门->银行部门

借 123内部应收总金额
贷 现金或银行存款总金额

凭证三

银行部门->部门

借 现金或银行存款总金额
贷205 内部应付总金额

x_e_sale 执行销售单

1. 表sale/saledetail

2. 遍历saledetail,进行调用 x_e_updategoodsStockBalance 出库操作,计算总成本价格

3. 计算总金额(quantity*price+tax),tax,不含税金额

4. 用总金额更新合作伙伴应收款

5. 创建凭证1

6. 如果部门不等于仓库部门,创建凭证2,凭证3

凭证一

122应收总金额
511商品销售成本总成本
501 商品销售收入不含税金额
135库存商品总成本
221002003tax

凭证2

仓库部门->部门

凭证3

部门->仓库部门

借123内部应收总成本
贷135库存商品总成本

借135库存商品总成本
贷内部应付205总成本

x_e_expense 费用开支

现金或银行存款科目根据现金银行的类型确定

1 合计总金额

2. 遍历明细,更新收入支出类别余额,获得收入支出每科目汇总

3. 创建凭证1

4. 如果银行部门不等于部门,创建凭证2,3

凭证1

贷 收入支出每科目汇总每科目汇总金额,多条
借 现金或银行存款科目 总金额

凭证2

部门->现金银行部门

借 现金或银行存款科目总金额
贷 205内部应付总金额

凭证3

现金银行部门->部门

||总金额
借 123 内受应收总金额
贷 现金或银行存款科目

x_e_InCome 其它收入

1. 合计总金额

2. 遍历明细,更新收入支出类别余额

凭证1

部门id=部门id

借现款或现金银行科目总金额
贷 明细收支类别汇总金额多条

如果银行所属部门不等于部门

凭证2

部门到 银行部门

借 123 内部应收总金额
贷 现款或现金银行科目总金额

凭证3

银行部门到部门

借 现款或现金银行科目总金额
贷 205 内部应收总金额

x_e_purchase 采购单

传两个部门id

凭证1

借135库存商品不含税金额
借221002001 进项税额 tax
贷204 应付账款含税金额

凭证2

仓库部门id到部门id

借 135库存商品不含税金额
借221002001税金
贷205 内部应付含税金额

凭证3

部门id到仓库部门id

|贷135
借123内部应收 含税总金额
不含税
贷221002001

x_e_createcredence 创建凭证

参数

noteid表单id
tableid表id
departmentId部门id
todepartment部门id
employeeid员工id
debitsubjectid1,debit1 - 4 借1到4,等于0 为没有
creditsubjectid1,credit1-4贷1到4,等于0,为没有

123,内部应收科目,205 内部应付科目

插入明细,更新对应科目余额

如果科目等于123/205,则调用x_e_updateToDepartmentBalance

x_e_updateToDepartmentBalance

参数

从c8移值

departmentId
todepartmentId
receivable
payable

c8 实现了按部门核算,所以,单独的通过科目表的余额字段无法表达各部门的不同,c8创建一个一系列xxxBalance表,在移值到c9的过程中,这部分加以保留

c9的业务逻辑大部分都是通过存储过程实现的,属于过程化的编程守法,很难一下子转到面对对象编程,为了保持项目进度,使用先移值再重构的方式

表 todepartmentBalance/department_rests

idid
parentIdparent_id
todeparmtnetIddepartment_id
initreceivableBalanceinit_receivable
initpayableBalanceinit_payable
payablebalancepayable
receivableBalancereceivable

partnerbalance/partner_rests

idid
indexNo
parentidpartner_id
departmentiddepartment_id
initreceivablebalanceinit_receivable
initpayableblanceinit_payable
initadvancepaymentbalanceinit_pre_paid
initadvancereceivedbalanceinit_pre_received
receivablebalancereceivable
payableblanacepayable
advancereceivedbalancepre_received
advancepaymentbanalcepre_paid
haspaidpaid
haschargereceived

bankbalance/bank_rests

idid
indexno
parentidbank_id
departmentiddepartment_id
init_balanceinit_rest
balancerest
onroadbalanceon_road

inouttypebalance/income_expense_type_rests

idid
indexno
parentidincome_expense_type_id
departmentiddepartment_id
initbalanceinit_rest
balancerest

subjectbalance/subject_rests

idid
indexno
parentidsubject_id
departmentiddepartment_id
initbalanceinit_rest
balancerest

存储过程移值 业务类型过程移动到workflow中成为实例方法

x_e_UpdateSubjectBalanceupdate_subject_rest
x_e_UpdateBankBalanceupdate_bank_rest
x_e_CreateCredencecreate_voucher
x_e_UpdateToDepartmentBalanceupdate_department_rest
x_e_CreateCredencecreate_voucher
x_e_UpdateGoodsStockBalanceupdate_on_hand
x_e_checkStockCanUsecheck_store_can_use
x_e_UpdatePartnerBalanceupdate_partner_rest
x_e_UpdateInOutTypeBalanceupdate_income_expense_type_rest
x_e_salesale_order
x_e_purchasepurchase_order
x_e_purchaseReturnpurchase_return
x_e_SaleReturnsale_return
x_e_Incomeincome
x_e_expenseexpense
x_e_UpdateBankOnRoadupdate_bank_on_road
x_e_UpdateGoodsStockOnRoadupdate_on_hand_on_road
x_e_adjustPriceadjust_price
x_e_MoveBankbank_move1,bank_move2
x_e_BankInOutbank_change
x_e_receivableadjust|receivable_adjust
x_e_payableadjustpayable_adjust
x_e_allotallot1,allot2

Powered by Google Project Hosting