Code:
Public Sub ObracunPID()
On Error Resume Next
Dim BRUTO, BRUTO1, NETO As Currency
Dim rst, rsl As DAO.Recordset
Set rsl = CurrentDb.OpenRecordset("Radnici", dbOpenDynaset)
rsl.FindFirst "RadnikID=" & Me.ObracunR_Subform!RadnikID
Set rst = Forms!Obracun![ObracunD Subform].Form.RecordsetClone
If rst.RecordCount > 0 Then
rst.MoveFirst
End If
' 1 - ********** ! OBRACUN PiD !
If Not IsNull(Forms![Obracun]![ObracunZ Subform]!Text11) Then
BRUTO = Forms![Obracun]![ObracunZ Subform]!Text11
BRUTO1 = BRUTO
NETO = Forms![Obracun]![ObracunZ Subform]!Text10
Else
BRUTO = 0
BRUTO1 = 0
NETO = 0
End If
If BRUTO < Forms![Obracun]!MjOsnova Then
If BRUTO <> 0 Then
BRUTO1 = BRUTO
If MsgBox("OBRACUN DOPRINOSA NA OSTVARENU PLATU ?", vbYesNo + vbQuestion + vbDefaultButton1) = vbNo Then
BRUTO = Forms![Obracun]!MjOsnova
End If
End If
End If
' 2 - ********** ! OBRACUN PiD ! Dodati i odbitke na POREZ !!!
Do While rst.EOF = False
If rst!Oznaka = "P" Then
If BRUTO1 > Forms![Obracun]!Neoporez Then
rst.Edit
If (BRUTO1 - (BRUTO * Forms!Obracun!Text101 / 100) - Forms!Obracun!Neoporez - rsl!Odbitak1 - rsl!Odbitak2) > 0 Then
rst!IznosDoprinosa = (BRUTO1 - (BRUTO * Forms!Obracun!Text101 / 100) - Forms!Obracun!Neoporez - rsl!Odbitak1 - rsl!Odbitak2) * rst!Stopa / 100
Else
rst!IznosDoprinosa = 0
End If
rst.Update
Else
rst.Edit
rst!IznosDoprinosa = 0
rst.Update
End If
If rst!Oznaka = "s" Then
If NETO = Forms![Obracun]!NajNizaPl Then
rst.Edit
rst!IznosDoprinosa = NajNizaPl * 1.5 / 100
rst.Update
Else
rst!IznosDoprinosa = NajNizaPl * 3 / 100
End If
rst.MoveNext
If rst.EOF = True Then
Exit Do
End If
Loop
Forms![Obracun]![ObracunD Subform].Requery
End Sub
Public Sub ObracunPID()
On Error Resume Next
Dim BRUTO, BRUTO1, NETO As Currency
Dim rst, rsl As DAO.Recordset
Set rsl = CurrentDb.OpenRecordset("Radnici", dbOpenDynaset)
rsl.FindFirst "RadnikID=" & Me.ObracunR_Subform!RadnikID
Set rst = Forms!Obracun![ObracunD Subform].Form.RecordsetClone
If rst.RecordCount > 0 Then
rst.MoveFirst
End If
' 1 - ********** ! OBRACUN PiD !
If Not IsNull(Forms![Obracun]![ObracunZ Subform]!Text11) Then
BRUTO = Forms![Obracun]![ObracunZ Subform]!Text11
BRUTO1 = BRUTO
NETO = Forms![Obracun]![ObracunZ Subform]!Text10
Else
BRUTO = 0
BRUTO1 = 0
NETO = 0
End If
If BRUTO < Forms![Obracun]!MjOsnova Then
If BRUTO <> 0 Then
BRUTO1 = BRUTO
If MsgBox("OBRACUN DOPRINOSA NA OSTVARENU PLATU ?", vbYesNo + vbQuestion + vbDefaultButton1) = vbNo Then
BRUTO = Forms![Obracun]!MjOsnova
End If
End If
End If
' 2 - ********** ! OBRACUN PiD ! Dodati i odbitke na POREZ !!!
Do While rst.EOF = False
If rst!Oznaka = "P" Then
If BRUTO1 > Forms![Obracun]!Neoporez Then
rst.Edit
If (BRUTO1 - (BRUTO * Forms!Obracun!Text101 / 100) - Forms!Obracun!Neoporez - rsl!Odbitak1 - rsl!Odbitak2) > 0 Then
rst!IznosDoprinosa = (BRUTO1 - (BRUTO * Forms!Obracun!Text101 / 100) - Forms!Obracun!Neoporez - rsl!Odbitak1 - rsl!Odbitak2) * rst!Stopa / 100
Else
rst!IznosDoprinosa = 0
End If
rst.Update
Else
rst.Edit
rst!IznosDoprinosa = 0
rst.Update
End If
If rst!Oznaka = "s" Then
If NETO = Forms![Obracun]!NajNizaPl Then
rst.Edit
rst!IznosDoprinosa = NajNizaPl * 1.5 / 100
rst.Update
Else
rst!IznosDoprinosa = NajNizaPl * 3 / 100
End If
rst.MoveNext
If rst.EOF = True Then
Exit Do
End If
Loop
Forms![Obracun]![ObracunD Subform].Requery
End Sub
Potpis