Aggiunto progetto GPW_Data
This commit is contained in:
@@ -0,0 +1,69 @@
|
||||
-- richiama update x sistemazione voci PERM --> MPP
|
||||
|
||||
BEGIN TRAN ;
|
||||
|
||||
WITH cte as (
|
||||
SELECT g.dataLav
|
||||
,g.idxDipendente
|
||||
,codGiust
|
||||
,minuti
|
||||
,automatico
|
||||
,dbo.f_chkFunDip(g.idxDipendente) AS chk
|
||||
,dbo.f_chkFunDipMin(g.idxDipendente,g.dataLav,'MPP') AS minChk -- calcolo gli eventuali minuti MPP
|
||||
,t.minArcoPres
|
||||
,t.minLav
|
||||
,t.minArcoPres-t.minLav as chkDiff
|
||||
FROM dbo.Giustificativi AS g
|
||||
LEFT JOIN TimbratureExpl AS t ON g.idxDipendente = t.idxDipendente AND g.dataLav = t.dataLav
|
||||
WHERE codGiust = 'PERM'
|
||||
AND minuti <= 60
|
||||
AND dbo.f_chkFunDip(g.idxDipendente) <> ''
|
||||
AND minuti = dbo.f_chkFunDipMin(g.idxDipendente,g.dataLav,'MPP')
|
||||
)
|
||||
UPDATE dbo.Giustificativi
|
||||
SET codGiust = 'MPP'
|
||||
FROM dbo.Giustificativi AS g
|
||||
INNER JOIN cte ON g.idxDipendente = cte.idxDipendente
|
||||
AND g.dataLav = cte.dataLav
|
||||
AND g.codGiust = 'PERM'
|
||||
AND g.minuti = cte.minuti
|
||||
|
||||
-- test
|
||||
SELECT g.dataLav
|
||||
,g.idxDipendente
|
||||
,codGiust
|
||||
,minuti
|
||||
,automatico
|
||||
,dbo.f_chkFunDip(g.idxDipendente)
|
||||
,dbo.f_chkFunDipMin(g.idxDipendente,g.dataLav,'MPP') -- calcolo gli eventuali minuti MPP
|
||||
,t.minArcoPres
|
||||
,t.minLav
|
||||
,t.minArcoPres-t.minLav
|
||||
FROM dbo.Giustificativi AS g
|
||||
LEFT JOIN TimbratureExpl AS t ON g.idxDipendente = t.idxDipendente AND g.dataLav = t.dataLav
|
||||
WHERE codGiust = 'MPP'
|
||||
AND minuti <= 60
|
||||
AND dbo.f_chkFunDip(g.idxDipendente) <> ''
|
||||
AND minuti = dbo.f_chkFunDipMin(g.idxDipendente,g.dataLav,'MPP')
|
||||
|
||||
COMMIT
|
||||
|
||||
|
||||
-- ricalcolo giornate
|
||||
|
||||
DECLARE @RC int
|
||||
DECLARE @idxDipendente int
|
||||
DECLARE @inizio datetime
|
||||
DECLARE @fine datetime
|
||||
|
||||
|
||||
EXECUTE @RC = [dbo].[stp_ricalcolaTimbExpl_byPeriodoUser]
|
||||
0
|
||||
,'20130301'
|
||||
,'20130501'
|
||||
GO
|
||||
|
||||
-- registro versione...
|
||||
INSERT INTO [dbo].[LogUpdateDb] ([Versione],[Data]) VALUES(330, GETDATE())
|
||||
GO
|
||||
SELECT * FROM LogUpdateDb ORDER BY Versione DESC
|
||||
Reference in New Issue
Block a user