I have tables:
create table Aprovizionari
(
ID_Aprovizionare int identity(1,1) primary key,
CodCarte char(3) foreign key references Carti(CodCarte),
CodLibrarie char(3) foreign key references Librarii(CodLibrarie),
DataAprovizionare date default getdate(),
Cantitate int default 1
)
create table Returnari
(
CodRet char(3) primary key,
CodCarte char(3) foreign key references Carti(CodCarte),
CodLibrarie char(3) foreign key references Librarii(CodLibrarie),
CodEditura char(4) foreign key references Edituri(CodEditura),
DataRet date,
Cantitate int
)
I have a trigger that decrement the column Cantitate(Quantity) from Aprovizionari(Supply) while I add in Cantitate from another table Facturi(Invoices).
In Returnari(Returns -of books) I should have:
DataRet date,--this should be =DataAprovizionare+3 mounths
Cantitate int--this should be=the remaining Cantitate(Quantity) from Aprovizionari at date=DataAprovizionare+3 mounts