解决方案: |
下边两个脚本,第一个用于更新数据,使入库单的税率及税额等根据存货的税率进行调整。对于已经结算部分,我查了一下,客户的结算额都等于本币金额,所以不用做修改。第二个脚本用于查找剩余的税率为零的入库单,这一部分是因为存货的入库单为零或为空。 --更新数据 update rdrecords set itaxrate=b.iTaxRate,itaxprice=iprice*b.iTaxRate*0.01,ioritaxprice=itaxprice, isum=iprice+itaxprice,ioritaxcost=isum/iQuantity from rdrecords a right join RdRecord c on c.id=a.id and c.cVouchType='01' inner join Inventory b on b.cInvCode=a.cInvCode and b.itaxrate is not null and b.itaxrate<>0 where a.itaxrate=0 --存货税率是空或者是0的 select a.id,a.cInvCode as 存货编码,b.iTaxRate as 存货税率,a.iunitcost as 本币单价,a.ioricost as 原币单价, a.iprice as 本币金额,a.iorimoney as 园币金额,a.itaxrate as 税率,a.itaxprice as 本币税额, a.ioritaxprice as 园币税额,a.isum as 本币价税合计,a.ioritaxcost as 原币含税单价 from rdrecords a right join RdRecord c on c.id=a.id and c.cVouchType='01' inner join Inventory b on b.cInvCode=a.cInvCode --and b.itaxrate is not null and b.itaxrate<>0 where a.itaxrate=0 |