Llista les factures que s’han creat i estan afectades pel IGIC

select DocDate,DocNum,U_B1SYS_EXT_INV
from OINV FACTURES
join (
select CF.DocEntry 
from OINV CF
join INV1 LF on LF.DocEntry=CF.DocEntry
join OVTG GI on GI.Code=LF.VatGroup
where GI.U_B1SYS_SPEC_REGIME=8
group by CF.DocEntry) DADES on DADES.DocEntry=FACTURES.DocEntry

Actualització:

UPDATE F SET F.U_B1SYS_EXT_INV='N' 
FROM OINV F
INNER JOIN (
select CF.DocEntry 
from OINV CF
join INV1 LF on LF.DocEntry=CF.DocEntry
join OVTG GI on GI.Code=LF.VatGroup
where GI.U_B1SYS_SPEC_REGIME=8
group by CF.DocEntry) DADES ON DADES.DocEntry=F.DocEntry

Abonaments:

UPDATE F SET F.U_B1SYS_EXT_INV='Y' 
FROM ORIN F
INNER JOIN (
select CF.DocEntry 
from ORIN CF
join RIN1 LF on LF.DocEntry=CF.DocEntry
join OVTG GI on GI.Code=LF.VatGroup
where GI.U_B1SYS_SPEC_REGIME=8
group by CF.DocEntry) DADES ON DADES.DocEntry=F.DocEntry

 

image_pdf