-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfrmAjusPreVen.frm
398 lines (356 loc) · 11.7 KB
/
frmAjusPreVen.frm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
VERSION 5.00
Begin VB.Form frmAjusPreVen
BackColor = &H00C0C0C0&
BorderStyle = 4 'Fixed ToolWindow
Caption = "Ajuste Precio de Venta"
ClientHeight = 3540
ClientLeft = 2760
ClientTop = 3630
ClientWidth = 5295
ControlBox = 0 'False
BeginProperty Font
Name = "Trebuchet MS"
Size = 11.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 3540
ScaleWidth = 5295
ShowInTaskbar = 0 'False
Begin PCGestion.chameleonButton cbAceptar
Height = 795
Left = 4320
TabIndex = 1
Top = 1845
Width = 930
_extentx = 1640
_extenty = 1402
btype = 9
tx = "&Aceptar"
enab = -1 'True
font = "frmAjusPreVen.frx":0000
coltype = 1
focusr = -1 'True
bcol = 11513775
bcolo = 11513775
fcol = 0
fcolo = 0
mcol = 12632256
mptr = 1
micon = "frmAjusPreVen.frx":002C
picn = "frmAjusPreVen.frx":004A
umcol = -1 'True
soft = 0 'False
picpos = 2
ngrey = 0 'False
fx = 0
hand = 0 'False
check = 0 'False
value = 0 'False
End
Begin PCGestion.chameleonButton cbCancelar
Height = 795
Left = 4320
TabIndex = 2
TabStop = 0 'False
Top = 2700
Width = 930
_extentx = 1640
_extenty = 1402
btype = 9
tx = "&Cancelar"
enab = -1 'True
font = "frmAjusPreVen.frx":0D26
coltype = 1
focusr = -1 'True
bcol = 11513775
bcolo = 11513775
fcol = 0
fcolo = 0
mcol = 12632256
mptr = 1
micon = "frmAjusPreVen.frx":0D52
picn = "frmAjusPreVen.frx":0D70
umcol = -1 'True
soft = 0 'False
picpos = 2
ngrey = 0 'False
fx = 0
hand = 0 'False
check = 0 'False
value = 0 'False
End
Begin PCGestion.bsGradientLabel lblPreVenEx
Height = 495
Left = 1695
Top = 735
Width = 1560
_extentx = 2514
_extenty = 873
caption = ""
fount = "frmAjusPreVen.frx":164C
captioncolour = 0
colour1 = 15640462
colour2 = 11311500
captionalignment= 2
End
Begin PCGestion.miText ioPREVEN
Height = 480
Left = 1665
TabIndex = 0
Top = 2460
Width = 1635
_extentx = 2884
_extenty = 847
font = "frmAjusPreVen.frx":167A
dspformat = ""
enabled = -1 'True
espassword = -1 'True
End
Begin PCGestion.bsGradientLabel lblPreVenSug
Height = 495
Left = 1695
Top = 1860
Width = 1560
_extentx = 2514
_extenty = 873
caption = ""
fount = "frmAjusPreVen.frx":16A6
captioncolour = 0
colour1 = 15640462
colour2 = 11311500
captionalignment= 2
End
Begin PCGestion.bsGradientLabel lblPVPIVA
Height = 495
Left = 1695
Top = 3015
Width = 1560
_extentx = 2752
_extenty = 873
caption = ""
fount = "frmAjusPreVen.frx":16D4
captioncolour = 0
colour1 = 15640462
colour2 = 11311500
captionalignment= 2
End
Begin PCGestion.bsGradientLabel lblPRECOM
Height = 495
Left = 1695
Top = 120
Width = 1560
_extentx = 2514
_extenty = 873
caption = ""
fount = "frmAjusPreVen.frx":1702
captioncolour = 0
colour1 = 15640462
colour2 = 11311500
captionalignment= 2
End
Begin PCGestion.bsGradientLabel lblMargen
Height = 495
Left = 4380
Top = 105
Width = 900
_extentx = 979
_extenty = 873
caption = ""
fount = "frmAjusPreVen.frx":1730
captioncolour = 0
colour1 = 15640462
colour2 = 11311500
captionalignment= 2
End
Begin PCGestion.miCombo cbTIPOIVA
Height = 510
Left = 1650
TabIndex = 9
Top = 1305
Width = 3615
_extentx = 6376
_extenty = 900
font = "frmAjusPreVen.frx":175E
End
Begin VB.Label Label20
Alignment = 1 'Right Justify
BackStyle = 0 'Transparent
Caption = "IVA"
Height = 330
Left = 1155
TabIndex = 10
Top = 1395
Width = 420
End
Begin VB.Label Label5
Alignment = 1 'Right Justify
BackStyle = 0 'Transparent
Caption = "PRECIO COMPRA"
Height = 630
Left = 600
TabIndex = 8
Top = 45
Width = 1005
End
Begin VB.Label Label3
Alignment = 1 'Right Justify
BackStyle = 0 'Transparent
Caption = "MARGEN %"
Height = 300
Left = 3135
TabIndex = 7
Top = 180
Width = 1215
End
Begin VB.Label Label2
Alignment = 1 'Right Justify
BackStyle = 0 'Transparent
Caption = "PVP + IVA"
Height = 300
Left = 480
TabIndex = 6
Top = 3135
Width = 1125
End
Begin VB.Label Label1
Alignment = 1 'Right Justify
BackStyle = 0 'Transparent
Caption = "PRECIO VENTA FINAL"
Height = 630
Left = 90
TabIndex = 5
Top = 2415
Width = 1515
End
Begin VB.Label Label19
Alignment = 1 'Right Justify
BackStyle = 0 'Transparent
Caption = "PRECIO VENTA EXACTO"
Height = 630
Left = 75
TabIndex = 4
Top = 660
Width = 1515
End
Begin VB.Label Label4
Alignment = 1 'Right Justify
BackStyle = 0 'Transparent
Caption = "SUGERENCIA"
Height = 330
Left = 270
TabIndex = 3
Top = 1950
Width = 1335
End
End
Attribute VB_Name = "frmAjusPreVen"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'---------------------------------------------------------------------------------------
' Modulo : frmAjusPreVen
' Fecha/Hora : 30/11/2003 13:23
' Autor : JCASTILLO
' Propósito : Ajustar el precio de venta conforme a la tarifa seleccionada
' teniendo en cuenta los precios psicologicos.
'---------------------------------------------------------------------------------------
Option Explicit
'precio de Compra (original)
Public AJ_Precio_Compra As Double
'% de margen de la tarifa seleccionada
Public AJ_Margen_Tarifa As Single
'precio de venta final (despues del ajuste)
Public AJ_PreVenta_Final As Double
'si hemos salido del formulario por cancelar (no hacer cambios)
Public AJ_Cancelado As Boolean
'tipo de IVA (16, 7, 4 o 0)
Public AJ_TipoIVA As Byte
Private Sub cbAceptar_Click()
Unload Me
End Sub
Private Sub cbCancelar_Click()
'salimos por cancelar
AJ_Cancelado = True
Unload Me
End Sub
Private Sub cbTIPOIVA_Validate(Cancel As Boolean)
If cbTIPOIVA.Text = "" Then
Cancel = True
cbTIPOIVA.SetFocus
Else
AJ_TipoIVA = CByte(cbTIPOIVA.Text)
lblPVPIVA.Caption = Format(Replace(ioPREVEN.Valor, ".", ",") + (Replace(ioPREVEN.Valor, ".", ",") * devuelve_campo("SELECT IVA FROM IVA WHERE CODIGO = " & AJ_TipoIVA) / 100), "Currency")
End If
End Sub
Private Sub Form_Load()
Move (Screen.Width - Width) \ 2, Separacion_MDIForm
With ioPREVEN
.dspFormat = "Currency"
.SoloNumeros = True
.Alineacion = 1
.PermitirBlanco = False
End With
With cbTIPOIVA
.ConexionString = locCnn
.LenCodigo = 3
.SQLString = "SELECT CODIGO, CAST(IVA AS char(" & .LenCodigo & ")) + ' - ' + DESCRIPCION FROM IVA WHERE MBAJA = 0 ORDER BY CODIGO"
DoEvents
.CodigoWidth = 500
.carga
End With
lblMargen.Caption = AJ_Margen_Tarifa
lblPRECOM.Caption = Format(AJ_Precio_Compra, "Currency")
lblPreVenEx.Caption = Format(AJ_Precio_Compra + ((AJ_Precio_Compra * AJ_Margen_Tarifa) / 100), "Currency")
lblPreVenSug.Caption = Format(aproxima_precio(AJ_Precio_Compra + ((AJ_Precio_Compra * AJ_Margen_Tarifa) / 100)), "Currency")
ioPREVEN.Text = aproxima_precio(Format(AJ_Precio_Compra + ((AJ_Precio_Compra * AJ_Margen_Tarifa) / 100), "Currency"))
cbTIPOIVA.Text = AJ_TipoIVA
lblPVPIVA.Caption = Format(Replace(ioPREVEN.Valor, ".", ",") + (Replace(ioPREVEN.Valor, ".", ",") * devuelve_campo("SELECT IVA FROM IVA WHERE CODIGO = " & AJ_TipoIVA) / 100), "Currency")
End Sub
'---------------------------------------------------------------------------------------
' Subrutina : aproxima_precio
' Fecha/Hora : 30/11/2003 14:49
' Autor : JCASTILLO
' Propósito :
'
' Algoritmo de aproximacion a precios psicologicos
' Si tiene centimos:
'
' Si son mas de 50 centimos, ajustar hacia arriba poniendo
' ,90
'
' Si son menos de 50 centimos, ajustar hacia abajo poniendo
' ,99
' Si es un entero:
'
' Restar un centimo de euro para poner a ,99
'---------------------------------------------------------------------------------------
Private Function aproxima_precio(Preven As Double) As Double
'redondear a 2 decimales (euro)
Preven = Round(Preven, 2)
'determinar si tiene decimales:
If Int(Preven) = Preven Then
'si no tiene decimales:
'redondear hacia abajo (restar 0.01)
aproxima_precio = Int(Preven) - 0.01
Else 'si tiene decimales:
'obtener la parte decimal. Si son >= 50 cens ...
If Preven - Int(Preven) >= 50 Then
'ponerle .90 centimos (redondear hacia arriba)
aproxima_precio = Int(Preven) + 0.9
Else
'redondear hacia abajo (una unidad menos y ponerle 0.99)
aproxima_precio = Int(Preven) - 0.01
End If
End If
End Function
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
If Not AJ_Cancelado Then AJ_PreVenta_Final = ioPREVEN.Valor
End Sub