Advertisement
Guest User

pie de impresión de factura

a guest
Oct 21st, 2016
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.83 KB | None | 0 0
  1.  
  2. Sub OnFormat
  3.  
  4. End Sub
  5.  
  6. Sub OnBeforePrint
  7. Dim puntero, codbar, sem
  8.  
  9.  
  10.  
  11. 'Semaforo para contador de paginas
  12.  
  13. if label80.caption = "ult" then
  14. actpage.Text = CInt(totpage.Text)
  15. end if
  16.  
  17. If CInt(totpage.Text) - CInt(actpage.Text) = 1 Then
  18. label80.caption = "ult"
  19. end if
  20.  
  21. If CInt(actpage.Text) <> CInt(totpage.Text) Then
  22.  
  23. 'llamada a funcion para pasar transporte
  24. PoneTransporte
  25. Else
  26.  
  27. 'llamda a funcion para poner totales e impuestos
  28. PoneTotal
  29.  
  30. End If
  31.  
  32.  
  33. codbar = appcontext.funciones.trc("punted", "campoa1", "codigo = '" & puntero & "' and clase = '" & Field8.Text & "'")
  34. 'codigo de barras con formato itf25_08 - Llamada a funcion MacroXLS
  35. label59.Caption = MacroXLS(codbar, "0")
  36.  
  37. Barcode1.caption = GeneraCodigoBarrasCAE
  38. barcodetext.text = GeneraCodigoBarrasCAE
  39.  
  40.  
  41. Select Case actualcopy
  42. Case "1"
  43. label65.Caption = "ORIGINAL"
  44.  
  45. Case "2"
  46. label65.Caption = "DUPLICADO"
  47.  
  48. Case "3"
  49. label65.Caption = "TRIPLICADO"
  50.  
  51. Case "4"
  52. label65.Caption = "CUADRUPLICADO"
  53.  
  54. Case "5"
  55. label65.Caption = "QUINTUPLICADO"
  56.  
  57. Case "6"
  58. label65.Caption = "SEXTUPLICADO"
  59.  
  60. End Select
  61.  
  62. label81.caption = "NOTA > ESTE DOCUMENTO EQUIVALE A U$S "&appcontext.funciones.formato(CDbl(netoo.text/field46.text), "#,##0.00")&" AL TIPO DE CAMBIO 1 U$s = $ "&field46.text&" (SEGUN PRESUPUESTO) DEBIENDO SER LIQUIDADO SU MPORTE EN u$S O SU EQUIVALENTE EN $ S/COTIZ BNA T/VENDEDOR AL DIA DEL VENCIMIENTO O EL DEL PAGO EFECTIVO, EL QUE FUERE MAYOR"
  63.  
  64. if field46.text <> 1 then
  65. label81.visible = true
  66. else
  67. label81.visible = false
  68. end if
  69.  
  70.  
  71.  
  72.  
  73.  
  74. End Sub
  75.  
  76.  
  77.  
  78. Sub PoneTotal()
  79.  
  80. Field35.text=Abs(Field35.text)
  81. Field36.text=Abs(Field36.text)
  82. Field38.text=Abs(Field38.text)
  83.  
  84. if not(Field8.Text="A") then
  85. Field34.Text = cdbl(Field35.Text)
  86. Field33.visible = False
  87. Label33.visible = False
  88. Field37.visible = False
  89. Label47.visible = False
  90. Field32.visible = False
  91. Label30.visible = False
  92. line26.visible = False
  93. Line30.visible = False
  94. Line35.visible = False
  95. End if
  96.  
  97. if not(Field8.Text="B") then
  98. Field32.Text = cdbl(Field35.Text) - cdbl(Field36.Text) - cdbl(Field38.Text)
  99. Field33.Text = cdbl(Field36.Text)
  100. Field34.Text = cdbl(Field35.Text)
  101. end if
  102.  
  103. Field37.text = cdbl(Field38.Text)
  104.  
  105. with appcontext.funciones
  106. Field32.text = .formato(Field32.text, "#,##0.00")
  107. Field33.text = .formato(Field33.text, "#,##0.00")
  108. Field34.text = .formato(Field34.text, "#,##0.00")
  109. Field37.text = .formato(Field37.text, "#,##0.00")
  110. label46.Caption = "Son:"
  111. Label45.Caption = appcontext.evalvalor("enletras(" & netoo.Text & ")")
  112. end with
  113.  
  114.  
  115.  
  116. end Sub
  117.  
  118. Sub PoneTransporte()
  119.  
  120. 'metodo que maneja los valores del transporte en el pie
  121. Field32.Text = "-"
  122. Field33.Text = "-"
  123. Field34.Text = "-"
  124. Field37.Text = "-"
  125. Label45.Caption = "Transporte a la hoja Nº: " & CInt(actpage.text) + 1
  126. Label46.Caption = ""
  127.  
  128. End Sub
  129.  
  130. Function MacroXLS(DataToEncode, ReturnType)
  131. Dim DataToPrint
  132. Dim OnlyCorrectData
  133. Dim StringLength
  134. Dim i
  135. Dim factor
  136. Dim WeightedTotal
  137. Dim CurrentCharNum
  138. Dim CheckDigit
  139.  
  140. ' Get data from user, this is the DataToEncode
  141. DataToEncode = RTrim(LTrim(DataToEncode))
  142. DataToPrint = ""
  143.  
  144. ' Check to make sure data is numeric and remove dashes, etc.
  145. OnlyCorrectData = ""
  146. StringLength = Len(DataToEncode)
  147.  
  148. 'Add all numbers to OnlyCorrectData str
  149. For i = 1 To StringLength
  150. If IsNumeric(Mid(DataToEncode, i, 1)) Then
  151. OnlyCorrectData = OnlyCorrectData & Mid(DataToEncode, i, 1)
  152. End If
  153. Next
  154.  
  155. DataToEncode = OnlyCorrectData
  156.  
  157. '<<<< Calculate Check Digit >>>>
  158. factor = 3
  159. WeightedTotal = 0
  160.  
  161. For i = Len(DataToEncode) To 1 Step -1
  162. 'Get the value of each number starting at the end
  163. CurrentCharNum = Mid(DataToEncode, i, 1)
  164. 'multiply by the weighting factor which is 3,1,3,1...
  165. 'and add the sum together
  166. WeightedTotal = WeightedTotal + CurrentCharNum * factor
  167. 'change factor for next calculation
  168. factor = 4 - factor
  169. Next
  170.  
  171. 'Find the CheckDigit by finding the smallest number that = a multiple of 10
  172. i = (WeightedTotal Mod 10)
  173. If i <> 0 Then
  174. CheckDigit = (10 - i)
  175. Else
  176. CheckDigit = 0
  177. End If
  178.  
  179. 'Add check digit to number to DataToEncode
  180. DataToEncode = DataToEncode & CheckDigit
  181.  
  182. 'Check for an even number of digits, add 0 if not even
  183. If (Len(DataToEncode) Mod 2) = 1 Then
  184. DataToEncode = "0" & DataToEncode
  185. end if
  186.  
  187. StringLength = Len(DataToEncode)
  188.  
  189. For i = 1 To StringLength Step 2
  190. 'Get the value of each number pair
  191. CurrentCharNum = (Mid(DataToEncode, i, 2))
  192. 'Get the AscWII value of CurrentChar according to chart by to the value
  193. If CurrentCharNum < 94 Then
  194. DataToPrint = DataToPrint & ChrW(CurrentCharNum + 33)
  195. end if
  196. If CurrentCharNum > 93 Then
  197. DataToPrint = DataToPrint & ChrW(CurrentCharNum + 103)
  198. end if
  199. Next
  200.  
  201. 'ReturnType 0 returns data formatted to the barcode font
  202. If ReturnType = 0 Then
  203. MacroXLS = ChrW(203) & DataToPrint & ChrW(204) & " "
  204. End If
  205.  
  206. 'ReturnType 1 returns data formatted for human readable text
  207. If ReturnType = 1 Then
  208. MacroXLS = DataToEncode
  209. End If
  210.  
  211. 'ReturnType 2 returns the check digit for the data supplied
  212. If ReturnType = 2 Then
  213. MacroXLS = CStr(CheckDigit)
  214. End If
  215.  
  216. end function
  217.  
  218. Function GeneraCodigoBarrasCAE()
  219. on error resume next
  220.  
  221. Dim cuit, numclase, ptoventa, fecae
  222. Dim x, d, p, i, cont
  223. Dim numero
  224. Dim anchocodigo
  225.  
  226. 'funcion que compone el codigo de barras
  227.  
  228. 'Cuit de la empresa que origina el CAE
  229.  
  230. cuit = Replace(Replace(label10.Caption, "C.U.I.T.: ", ""), "-", "")
  231.  
  232.  
  233. 'numero de clase
  234.  
  235. if len(label16.text) = 1 then
  236. numclase = "0" & label16.text
  237. else
  238. numclase = label16.text
  239. end if
  240.  
  241. 'Punto de Venta
  242. ptoventa = Mid(Field11.Text, 1, 4)
  243.  
  244. 'le da formarto a la fecha de vencimiento del cae
  245. fecae = appcontext.funciones.formato(field31.Text, "yyyymmdd")
  246.  
  247. 'arma numero de codigo de barra
  248. numero = cuit & numclase & ptoventa & Field30.Text & fecae
  249.  
  250. 'arma digitoverificador
  251. p = 0
  252. i = 0
  253. cont = 0
  254.  
  255. For x = 1 To Len(numero)
  256. If cont = 0 Then
  257. i = i + Int(Mid(numero, x, 1))
  258. cont = cont + 1
  259. Else
  260. p = p + Int(Mid(numero, x, 1))
  261. cont = cont - 1
  262. End If
  263. Next
  264.  
  265. d = Int(i * 3) + Int(p) - 1000
  266. d = Right(d, 1)
  267.  
  268. 'agrega digito verificador
  269. numero = numero & d
  270.  
  271. 'devuelve valor
  272. GeneraCodigoBarrasCAE = numero
  273.  
  274. 'vacio variables
  275. Set cuit = Nothing
  276. Set numclase = Nothing
  277. Set ptoventa = Nothing
  278. Set fechacae = Nothing
  279. Set x = Nothing
  280. Set d = Nothing
  281. Set p = Nothing
  282. Set i = Nothing
  283. Set cont = Nothing
  284. Set numero = Nothing
  285.  
  286.  
  287. end Function
  288.  
  289.  
  290.  
  291. Sub OnAfterPrint
  292.  
  293. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement