close all
sele 2
use se_prod
index on pcod to x
SELE 1
use se_movnf
set rela to pcod into se_prod

set filt to year(mdata)=2022 .and. mfges='E' .and. month(mdata)=10
repl all se_prod->nf_cstpis with '50', se_prod->nf_cstcof with '50', se_prod->nf_txpis with 1.65, se_prod->nf_txcof with 7.60 for pcod=se_prod->pcod .and. (xml_cstpis='49'.OR.xml_cstpis='99')
repl all se_prod->nf_cstpis with xml_cstpis, se_prod->nf_cstcof with se_prod->nf_cstpis, se_prod->nf_txpis with 0, se_prod->nf_txcof with 0 for pcod=se_prod->pcod .and. (xml_cstpis='04'.OR.xml_cstpis='06')

repl all cst_pis with '70', vl_bc_pis with 0, aliq_pis with 0, vl_pis with 0 for pcod=se_prod->pcod .and. (se_prod->nf_cstpis='04'.or.se_prod->nf_cstcof='06')
repl all cst_cofins with '70', vlbccofins with 0, aliqcofins with 0, vl_cofins with 0 for pcod=se_prod->pcod .and. (se_prod->nf_cstpis='04'.or.se_prod->nf_cstcof='06')

set filt to 
repl all cst_pis with '70', cst_cofins with '70' for cst_pis='73'
repl all cst_pis with '50', cst_cofins with '50' for cst_pis='73'
repl all cst_pis with '01', cst_cofins with '01' for cst_pis='49'

repl all vlbccofins with 0, aliqcofins with 0, vl_cofins with 0 for cst_pis='70'.and.vlbccofins>0
repl all vl_bc_pis with 0, aliq_pis with 0, vl_pis with 0 for cst_pis='70'.and.vl_bc_pis>0

repl all vl_bc_pis with mbaseicms, aliq_pis with 1.65, vl_pis with vl_bc_pis*aliq_pis/100 for (cst_pis='50'.or.cst_pis='01').and.vl_bc_pis=0
repl all vlbccofins with mbaseicms, aliqcofins with 7.60, vl_cofins with vlbccofins*aliqcofins/100 for (cst_pis='50'.or.cst_pis='01').and.vlbccofins=0

close all

sele 1
use se_prod

REPL ALL COD_NAT WITH "110" FOR PCODCLAFIS=4011010
REPL ALL COD_NAT WITH "110" FOR PCODCLAFIS=4012010
REPL ALL COD_NAT WITH "110" FOR PCODCLAFIS=4015021
REPL ALL COD_NAT WITH "110" FOR PCODCLAFIS=4015029
REPL ALL COD_NAT WITH "110" FOR PCODCLAFIS=4022110
REPL ALL COD_NAT WITH "110" FOR PCODCLAFIS=4022120
REPL ALL COD_NAT WITH "110" FOR PCODCLAFIS=4022930
REPL ALL COD_NAT WITH "110" FOR PCODCLAFIS=4029900
REPL ALL COD_NAT WITH "110" FOR PCODCLAFIS=4031000
REPL ALL COD_NAT WITH "110" FOR PCODCLAFIS=4039000
REPL ALL COD_NAT WITH "111" FOR PCODCLAFIS=4061010
REPL ALL COD_NAT WITH "111" FOR PCODCLAFIS=4061090
REPL ALL COD_NAT WITH "111" FOR PCODCLAFIS=4062000
REPL ALL COD_NAT WITH "111" FOR PCODCLAFIS=4069020
REPL ALL COD_NAT WITH "111" FOR PCODCLAFIS=4069090
REPL ALL COD_NAT WITH "123" FOR PCODCLAFIS=9012100
REPL ALL COD_NAT WITH "123" FOR PCODCLAFIS=9012200
REPL ALL COD_NAT WITH "108" FOR PCODCLAFIS=10059010
REPL ALL COD_NAT WITH "105" FOR PCODCLAFIS=10062020
REPL ALL COD_NAT WITH "105" FOR PCODCLAFIS=10063011
REPL ALL COD_NAT WITH "105" FOR PCODCLAFIS=10063021
REPL ALL COD_NAT WITH "113" FOR PCODCLAFIS=11010010
REPL ALL COD_NAT WITH "108" FOR PCODCLAFIS=11022000
REPL ALL COD_NAT WITH "108" FOR PCODCLAFIS=11029000
REPL ALL COD_NAT WITH "108" FOR PCODCLAFIS=11041200
REPL ALL COD_NAT WITH "108" FOR PCODCLAFIS=11041900
REPL ALL COD_NAT WITH "108" FOR PCODCLAFIS=11042300
REPL ALL COD_NAT WITH "108" FOR PCODCLAFIS=11042900
REPL ALL COD_NAT WITH "108" FOR PCODCLAFIS=11081200
REPL ALL COD_NAT WITH "108" FOR PCODCLAFIS=11081400
REPL ALL COD_NAT WITH "125" FOR PCODCLAFIS=15121911
REPL ALL COD_NAT WITH "125" FOR PCODCLAFIS=15141910
REPL ALL COD_NAT WITH "125" FOR PCODCLAFIS=15152910
REPL ALL COD_NAT WITH "110" FOR PCODCLAFIS=18061000
REPL ALL COD_NAT WITH "110" FOR PCODCLAFIS=18062000
REPL ALL COD_NAT WITH "110" FOR PCODCLAFIS=18063110
REPL ALL COD_NAT WITH "110" FOR PCODCLAFIS=18063210
REPL ALL COD_NAT WITH "110" FOR PCODCLAFIS=18063220
REPL ALL COD_NAT WITH "110" FOR PCODCLAFIS=18069000
REPL ALL COD_NAT WITH "110" FOR PCODCLAFIS=19011010
REPL ALL COD_NAT WITH "110" FOR PCODCLAFIS=19011020
REPL ALL COD_NAT WITH "110" FOR PCODCLAFIS=19011030
REPL ALL COD_NAT WITH "110" FOR PCODCLAFIS=19011090
REPL ALL COD_NAT WITH "110" FOR PCODCLAFIS=19012000
REPL ALL COD_NAT WITH "110" FOR PCODCLAFIS=19019020
REPL ALL COD_NAT WITH "110" FOR PCODCLAFIS=19019090
REPL ALL COD_NAT WITH "119" FOR PCODCLAFIS=19021900
REPL ALL COD_NAT WITH "119" FOR PCODCLAFIS=19022000
REPL ALL COD_NAT WITH "119" FOR PCODCLAFIS=19023000
REPL ALL COD_NAT WITH "108" FOR PCODCLAFIS=20052000
REPL ALL COD_NAT WITH "108" FOR PCODCLAFIS=20057000
REPL ALL COD_NAT WITH "108" FOR PCODCLAFIS=20058000
REPL ALL COD_NAT WITH "108" FOR PCODCLAFIS=20059900
REPL ALL COD_NAT WITH "641" FOR PCODCLAFIS=20093100
REPL ALL COD_NAT WITH "641" FOR PCODCLAFIS=20096100
REPL ALL COD_NAT WITH "641" FOR PCODCLAFIS=20098990
REPL ALL COD_NAT WITH "123" FOR PCODCLAFIS=21011110
REPL ALL COD_NAT WITH "123" FOR PCODCLAFIS=21011190
REPL ALL COD_NAT WITH "123" FOR PCODCLAFIS=21011200
REPL ALL COD_NAT WITH "115" FOR PCODCLAFIS=21021090
REPL ALL COD_NAT WITH "115" FOR PCODCLAFIS=21023000
REPL ALL COD_NAT WITH "641" FOR PCODCLAFIS=21069010
REPL ALL COD_NAT WITH "641" FOR PCODCLAFIS=21069029
REPL ALL COD_NAT WITH "641" FOR PCODCLAFIS=21069030
REPL ALL COD_NAT WITH "641" FOR PCODCLAFIS=21069050
REPL ALL COD_NAT WITH "641" FOR PCODCLAFIS=21069090
REPL ALL COD_NAT WITH "420" FOR PCODCLAFIS=22011000
REPL ALL COD_NAT WITH "613" FOR PCODCLAFIS=22021000
REPL ALL COD_NAT WITH "671" FOR PCODCLAFIS=22029100
REPL ALL COD_NAT WITH "110" FOR PCODCLAFIS=22029900
REPL ALL COD_NAT WITH "671" FOR PCODCLAFIS=22030000
REPL ALL COD_NAT WITH "202" FOR PCODCLAFIS=28142000
REPL ALL COD_NAT WITH "202" FOR PCODCLAFIS=30049099
REPL ALL COD_NAT WITH "202" FOR PCODCLAFIS=33030020
REPL ALL COD_NAT WITH "202" FOR PCODCLAFIS=33043000
REPL ALL COD_NAT WITH "202" FOR PCODCLAFIS=33049100
REPL ALL COD_NAT WITH "202" FOR PCODCLAFIS=33049910
REPL ALL COD_NAT WITH "202" FOR PCODCLAFIS=33049990
REPL ALL COD_NAT WITH "202" FOR PCODCLAFIS=33051000
REPL ALL COD_NAT WITH "202" FOR PCODCLAFIS=33052000
REPL ALL COD_NAT WITH "202" FOR PCODCLAFIS=33053000
REPL ALL COD_NAT WITH "202" FOR PCODCLAFIS=33059000
REPL ALL COD_NAT WITH "202" FOR PCODCLAFIS=33061000
REPL ALL COD_NAT WITH "202" FOR PCODCLAFIS=33062000
REPL ALL COD_NAT WITH "202" FOR PCODCLAFIS=33069000
REPL ALL COD_NAT WITH "202" FOR PCODCLAFIS=33071000
REPL ALL COD_NAT WITH "202" FOR PCODCLAFIS=33072010
REPL ALL COD_NAT WITH "202" FOR PCODCLAFIS=33072090
REPL ALL COD_NAT WITH "202" FOR PCODCLAFIS=33074900
REPL ALL COD_NAT WITH "202" FOR PCODCLAFIS=33079000
REPL ALL COD_NAT WITH "202" FOR PCODCLAFIS=34011190
REPL ALL COD_NAT WITH "202" FOR PCODCLAFIS=34011900
REPL ALL COD_NAT WITH "202" FOR PCODCLAFIS=34012010
REPL ALL COD_NAT WITH "202" FOR PCODCLAFIS=34012090
REPL ALL COD_NAT WITH "202" FOR PCODCLAFIS=34013000
REPL ALL COD_NAT WITH "202" FOR PCODCLAFIS=34021190
REPL ALL COD_NAT WITH "202" FOR PCODCLAFIS=34022000
REPL ALL COD_NAT WITH "202" FOR PCODCLAFIS=34029031
REPL ALL COD_NAT WITH "202" FOR PCODCLAFIS=34029039
REPL ALL COD_NAT WITH "202" FOR PCODCLAFIS=34029090
REPL ALL COD_NAT WITH "202" FOR PCODCLAFIS=39261000
REPL ALL COD_NAT WITH "202" FOR PCODCLAFIS=39262000
REPL ALL COD_NAT WITH "202" FOR PCODCLAFIS=39269040
REPL ALL COD_NAT WITH "202" FOR PCODCLAFIS=39269090
REPL ALL COD_NAT WITH "130" FOR PCODCLAFIS=48181000
REPL ALL COD_NAT WITH "130" FOR PCODCLAFIS=48182000
REPL ALL COD_NAT WITH "130" FOR PCODCLAFIS=48183000
REPL ALL COD_NAT WITH "130" FOR PCODCLAFIS=48189090
REPL ALL COD_NAT WITH "202" FOR PCODCLAFIS=56012110
REPL ALL COD_NAT WITH "202" FOR PCODCLAFIS=56012190
REPL ALL COD_NAT WITH "202" FOR PCODCLAFIS=64022000
REPL ALL COD_NAT WITH "202" FOR PCODCLAFIS=64029990
REPL ALL COD_NAT WITH "202" FOR PCODCLAFIS=64041900
REPL ALL COD_NAT WITH "202" FOR PCODCLAFIS=96031000
REPL ALL COD_NAT WITH "202" FOR PCODCLAFIS=96032100
REPL ALL COD_NAT WITH "202" FOR PCODCLAFIS=96032900
REPL ALL COD_NAT WITH "202" FOR PCODCLAFIS=96033000
REPL ALL COD_NAT WITH "202" FOR PCODCLAFIS=96039000
REPL ALL COD_NAT WITH "202" FOR PCODCLAFIS=96190000

close all
