/beta/accounting/include_MakeDocItemRows.asp

http://github.com/khaneh/Orders · ASP · 551 lines · 437 code · 31 blank · 83 comment · 56 complexity · 2f48da7d07c6d63f0e0e9d809f826f6e MD5 · raw file

  1. <%
  2. '
  3. ' This Include file is for use in MakeDoc.asp
  4. ' only becase of improving readability of code.
  5. '
  6. ' response.write sys & "," & sysDefaultGLAccount& "<br>"
  7. Sub WriteRow()
  8. '-- Added By kid 830531 Emptying OTHER reasons
  9. if GLAccount="18001" then GLAccount=""
  10. '--
  11. if ""&Account="" then
  12. AccountClass="RepAccountInput2"
  13. else
  14. AccountClass="RepAccountInput"
  15. end if
  16. if ""&GLAccount="" then 'OR GLAccount="18001" then
  17. AccountGLClass="RepGLInput"
  18. else
  19. AccountGLClass="RepGLInput2"
  20. end if
  21. %> <TR class='<%if tempCounter MOD 2 = 0 then response.write "RepTR1" else response.write "RepTR2"%>'>
  22. <td>
  23. <INPUT class="<%=AccountClass%>" maxlength="6" TYPE="text" NAME="Account<%=tempCounter%>" value="<%=Account%>" style="width:30pt" <%=disabled%> readonly>
  24. </td>
  25. <td>
  26. <INPUT class="<%=AccountGLClass%>" maxlength="5" TYPE="text" NAME="GLAccount<%=tempCounter%>" value="<%=GLAccount%>" onKeyPress="return mask(this,true);" onblur="check(this,true)" <%=disabled%>>
  27. </td>
  28. <td align=rihgt><%=AccountTitle%></td>
  29. <td style="padding:2px;" width=200>
  30. <textarea readonly Name="Description<%=tempCounter%>" style="font-family:tahoma;overflow:auto;border:none; background:transparent; width:100%; height:25px; font-size:7pt;" <%=disabled%>><%=VoidText & LineDescription%></textarea>
  31. </td>
  32. <td dir='LTR' align='right'>&nbsp;<%=Separate(Credit)%></td>
  33. <td dir='LTR' align='right'><%=Separate(Debit)%>
  34. <INPUT TYPE="hidden" NAME="IsCredit<%=tempCounter%>" Value="<%=not(IsCredit)%>">
  35. <INPUT TYPE="hidden" NAME="Amount<%=tempCounter%>" Value="<%=Amount%>">
  36. <INPUT TYPE="hidden" NAME="Ref1<%=tempCounter%>" Value="<%=Ref1%>">
  37. <INPUT TYPE="hidden" NAME="Ref2<%=tempCounter%>" Value="<%=Ref2%>"></td>
  38. </TR>
  39. <%
  40. End Sub
  41. Sub WriteFirstRow()
  42. '-- Added By kid 830531 Emptying OTHER reasons
  43. if FirstGLAccount="18001" then FirstGLAccount=""
  44. '--
  45. if ""&Account="" then
  46. AccountClass="RepAccountInput"
  47. else
  48. AccountClass="RepAccountInput2"
  49. end if
  50. if ""&FirstGLAccount="" then 'OR FirstGLAccount="18001" then
  51. AccountGLClass="RepGLInput"
  52. FirstGLAccount=0
  53. else
  54. AccountGLClass="RepGLInput2"
  55. end if
  56. %> <TR class='<%if tempCounter MOD 2 = 0 then response.write "RepTR1" else response.write "RepTR2"%>'>
  57. <td rowspan=<%=ItemLines%> title="<%if disabled="disabled" then response.write " ǁ " else response.write sys end if%>">
  58. <INPUT TYPE="checkbox" NAME="Items" Value="<%=tempCounter%>" onclick="return selectRow(this.parentNode.parentNode);" <%=disabled%>>
  59. <INPUT TYPE="hidden" NAME="Item<%=tempCounter%>" Value="<%=ItemID%>" >
  60. <INPUT TYPE="hidden" NAME="Lines<%=tempCounter%>" Value="<%=ItemLines%>">
  61. <INPUT TYPE="hidden" NAME="Sys<%=tempCounter%>" Value="<%=sys%>"></td>
  62. <td rowspan='<%=ItemLines%>' dir='LTR' align='right' valign='top' <%if VoidText <> "" then response.write " bgcolor='#FFCCCC'"%>>
  63. <%=effectiveDate%><br><br>(<A style="font-size:7pt;" HREF="ShowItem.asp?sys=<%=sys%>&Item=<%=ItemID%>" target="_blank"><%=VoidText & Descriptions(ItemType)%></A>)
  64. <br><br><%=VoidLink%></td>
  65. <td class="RepTD1">
  66. <INPUT class="<%=AccountClass%>" maxlength="6" TYPE="text" NAME="Account<%=tempCounter%>" value="<%=Account%>" style="width:30pt" <%=disabled%> raedonly>
  67. </td>
  68. <td>
  69. <INPUT class="<%=AccountGLClass%>" maxlength="5" TYPE="text" NAME="GLAccount<%=tempCounter%>" value="<%=FirstGLAccount%>" onKeyPress="return mask(this,false);" onblur="check(this,false)" <%=disabled%> <%if AccountGLClass="RepGLInput2" and FirstGLAccount<>0 and sys <>"AO" then response.write " readonly"%>>
  70. </td>
  71. <td><%=AccountTitle%></td>
  72. <td style="padding:2px;" width=200>
  73. <textarea readonly Name="Description<%=tempCounter%>" style="font-family:tahoma;overflow:auto;border:none; background:transparent; width:100%; height:25px; font-size:7pt;" <%=disabled%>><%=VoidText & LineDescription%></textarea>
  74. </td>
  75. <td dir='LTR' align='right'>&nbsp;<%=Separate(Debit)%></td>
  76. <td dir='LTR' align='right'><%=Separate(Credit) %>
  77. <INPUT TYPE="hidden" NAME="IsCredit<%=tempCounter%>" Value="<%=IsCredit%>">
  78. <INPUT TYPE="hidden" NAME="Amount<%=tempCounter%>" Value="<%=Amount%>">
  79. <INPUT TYPE="hidden" NAME="Ref1<%=tempCounter%>" Value="<%=Ref1%>">
  80. <INPUT TYPE="hidden" NAME="Ref2<%=tempCounter%>" Value="<%=Ref2%>"></td>
  81. </TR>
  82. <%
  83. End Sub
  84. mySQL="SELECT * FROM AXItemTypes"
  85. Set RS1 = conn.execute(mySQL)
  86. do while not RS1.eof
  87. Descriptions(RS1("ID"))=RS1("Name")
  88. Rs1.movenext
  89. loop
  90. 'Changed by Kid 820828 :
  91. OrderBy = sys & "Items.EffectiveDate, "& sys & "Items.Type, "& sys & "Items.ID"
  92. AdditionalConditions =""
  93. if request.form("FromDate")<>"" then AdditionalConditions = AdditionalConditions & "AND ("& sys & "Items.EffectiveDate >= N'"& request.form("FromDate") & "') "
  94. if request.form("ToDate")<>"" then AdditionalConditions = AdditionalConditions & "AND ("& sys & "Items.EffectiveDate <= N'"& request.form("ToDate") & "') "
  95. if request.form("ItemTypes").count>0 then
  96. AdditionalConditions = AdditionalConditions & "AND ("
  97. myOr=""
  98. for i=1 to request.form("ItemTypes").count
  99. AdditionalConditions = AdditionalConditions & myOr & sys & "Items.Type=" & request.form("ItemTypes")(i)
  100. myOR="OR "
  101. next
  102. AdditionalConditions = AdditionalConditions & ") "
  103. if ubound(ItemLinksArray)>-1 then
  104. AdditionalConditions = AdditionalConditions & "AND ("& sys & "Items.Link IN ("& ItemLinks & ") ) "
  105. end if
  106. end if
  107. ' Changed By Kid 830216:
  108. ' Changed By Sam 871024:
  109. mySQL="SELECT "& sys & "Items.*, Accounts.AccountTitle, GLAccounts.Name AS GLAccountName, "& sys & "Memo.Description AS MmoDescription, "& sys & "Memo.Type AS MemoType, ISNULL(Receipts.CashAmount, 0) AS RcpCash, ISNULL(Receipts.ChequeAmount, 0) AS RcpChq, Receipts.ChequeQtty AS ChqQtty, ISNULL(Payments.CashAmount, 0) AS PayCash, ISNULL(Payments.ChequeAmount, 0) AS PayChq, ReceivedCash.Description AS CashDescription, ISNULL(ISNULL(Invoices.Number, Vouchers.Number),'-') AS Number, Invoices.IsA FROM ReceivedCash RIGHT OUTER JOIN Receipts ON ReceivedCash.Receipt = Receipts.ID RIGHT OUTER JOIN "& sys & "Items INNER JOIN Accounts ON "& sys & "Items.Account = Accounts.ID LEFT OUTER JOIN Invoices ON " & sys & "Items.Link = Invoices.ID LEFT OUTER JOIN Vouchers ON " & sys & "Items.Link = Vouchers.ID LEFT OUTER JOIN GLAccounts ON "& sys & "Items .GLAccount = GLAccounts.ID AND "& sys & "Items .GL = GLAccounts.GL LEFT OUTER JOIN Payments ON "& sys & "Items.Link = Payments.ID ON Receipts.ID = "& sys & "Items.Link LEFT OUTER JOIN "& sys & "Memo ON "& sys & "Items.Link = "& sys & "Memo.ID WHERE ("& sys & "Items.GL_Update = 1) AND ("& sys & "Items.GL = '"& OpenGL & "') "& AdditionalConditions & " ORDER BY "& OrderBy
  110. 'response.write(mySQL)
  111. 'response.end
  112. Set RS1 = conn.execute(mySQL)
  113. if Not (RS1.EOF) then
  114. %>
  115. <TABLE class="RepTable" width='90%' align='center'>
  116. <TR>
  117. <TD colspan=8 dir='rtl' align='center'>
  118. </TD>
  119. </TR>
  120. <TR>
  121. <TD class="RepTableTitle" colspan=8 dir='rtl' align='center'> <B><%=sysName%></B> .
  122. </TD>
  123. </TR>
  124. <TR class="RepTableHeader">
  125. <TD width=5><INPUT TYPE="checkbox" onclick="selectAll(this)"></TD>
  126. <TD width=60></TD>
  127. <TD></TD>
  128. <TD width=30></TD>
  129. <TD width=160> </TD>
  130. <TD width=200></TD>
  131. <TD width=60></TD>
  132. <TD width=60></TD>
  133. </TR>
  134. <%
  135. While Not (RS1.EOF)
  136. disabled=""
  137. thisLink=clng(RS1("Link"))
  138. for i=0 to ubound(ItemLinksArray)
  139. if clng(ItemLinksArray(i))=thisLink then
  140. ItemLinksArray(i)=0
  141. 'exit for
  142. end if
  143. next
  144. tempCounter=tempCounter+1
  145. Amount=cdbl(RS1("AmountOriginal"))
  146. Vat = cdbl(RS1("Vat"))
  147. Ref1=""
  148. Ref2=""
  149. if RS1("IsCredit")=True then
  150. IsCredit=True
  151. Credit=Amount
  152. Debit=""
  153. else
  154. IsCredit=false
  155. Credit=""
  156. Debit=Amount
  157. end if
  158. if RS1("Voided")=True then
  159. IsCredit = not (IsCredit)
  160. tmp=Debit
  161. Debit=Credit
  162. Credit=tmp
  163. VoidText = " "
  164. VoidLink = "<B><A href='SubsysDocsEdit.asp?act=find&link=" & sys & RS1("ID") & "' target='_blank'> </A></B>"
  165. else
  166. VoidText = ""
  167. VoidLink = ""
  168. end if
  169. effectiveDate= RS1("EffectiveDate")
  170. ItemID= RS1("ID")
  171. ItemType = RS1("Type")
  172. MemoType = RS1("MemoType")
  173. Account = RS1("Account")
  174. FirstGLAccount =RS1("firstGLAccount")
  175. DestGLAccount = RS1("GLAccount")
  176. DestGLAccName = RS1("GLAccountName")
  177. AccountTitle = RS1("AccountTitle")
  178. ItemLines=2
  179. LineDescription="&nbsp;"
  180. '****
  181. '****
  182. if ItemType=3 AND MemoType=7 then
  183. 'Type = 3 ()
  184. 'MemoType = 7 ()
  185. if (NOT IsCredit and not RS1("Voided")) or (IsCredit and RS1("Voided")) then
  186. ItemLines=2
  187. LineDescription=RS1("MmoDescription")
  188. '--------------
  189. Call WriteFirstRow()
  190. '--------------
  191. mySQL="SELECT ToItemType,ToItemLink FROM InterMemoRelation WHERE (FromItemType='"& sys & "') AND (FromItemLink='"& RS1("Link") & "')"
  192. Set RS2=Conn.Execute(mySQL)
  193. if not rs2.eof then
  194. ToSys=RS2("ToItemType")
  195. ToItemLink=RS2("ToItemLink")
  196. else
  197. response.write "<br>" & mySQL
  198. response.end
  199. end if
  200. mySQL="SELECT "& ToSys & "Items.FirstGLAccount, "& ToSys & "Items.Account, Accounts.AccountTitle, "& ToSys & "Memo.Description FROM "& ToSys & "Items INNER JOIN Accounts ON "& ToSys & "Items.Account = Accounts.ID INNER JOIN "& ToSys & "Memo ON "& ToSys & "Items.Link = "& ToSys & "Memo.ID WHERE ("& ToSys & "Items.Type = 3) AND ("& ToSys & "Items.Link = '"& ToItemLink & "')"
  201. Set RS2=Conn.Execute(mySQL)
  202. Account = RS2("Account")
  203. GLAccount = RS2("firstGLAccount")
  204. AccountTitle = RS2("AccountTitle")
  205. LineDescription=RS2("Description")
  206. RS2.Close
  207. '--------------
  208. Call WriteRow()
  209. '--------------
  210. else
  211. ' Type = 3 , MemoType = 7 , but IsCredit=True
  212. ' When there is a "Transfrer Memo" which is a credit item (destination of transfer action).
  213. ' In this case we don't show the memo. (because it is shown as "debit" somewhere else)
  214. tempCounter = tempCounter - 1
  215. end if
  216. '****
  217. '****
  218. elseif ItemType=2 AND left(DestGLAccount,2) = "12" then
  219. 'Type = 2 ()
  220. '[ ]
  221. ItemType=10
  222. ItemLines=2
  223. LineDescription=RS1("CashDescription")
  224. '--------------
  225. Call WriteFirstRow()
  226. '--------------
  227. Account = ""
  228. GLAccount = DestGLAccount
  229. AccountTitle = DestGLAccName
  230. ' -----------
  231. Call WriteRow()
  232. '------------
  233. '****
  234. '****
  235. elseif ItemType=2 then
  236. 'Type = 2 ()
  237. '[ ]
  238. ReceiptID= RS1("Link")
  239. RcpCash= cdbl(RS1("RcpCash"))
  240. ChqQtty= RS1("ChqQtty")
  241. ItemLines=ChqQtty+1
  242. if RcpCash<>0 then ItemLines = ItemLines +1
  243. LineDescription=" " & AccountTitle & " " & ReceiptID
  244. '--------------------------
  245. '--------------------------
  246. mySQL="select * from CashRegisterLines where Type=1 and voided=0 and link=" & ReceiptID
  247. set RS2=conn.Execute(mySQL)
  248. isA = CBool(RS2("isA"))
  249. RS2.close
  250. set RS2=nothing
  251. if sys="AR" then
  252. mySQL="SELECT ISNULL(CONVERT(tinyint, Invoices.IsA), 2) AS IsA, Accounts.IsADefault, ISNULL(InvoicePrintForms.ID,0) as invPrintForm FROM Accounts INNER JOIN ARItems ON ARItems.Account = Accounts.ID LEFT OUTER JOIN ARItemsRelations ON ARItemsRelations.CreditARItem = ARItems.ID LEFT OUTER JOIN ARItems ARItems_2 ON ARItems_2.ID = ARItemsRelations.DebitARItem LEFT OUTER JOIN Invoices ON ARItems_2.Link = Invoices.ID left outer join InvoicePrintForms on ARItems_2.Link=InvoicePrintForms.InvoiceID and InvoicePrintForms.Voided=0 WHERE (ARItems.Type = 2) AND (ARItems.Link = '"& ReceiptID & "')"
  253. Set RS2=Conn.Execute(mySQL)
  254. if cint(RS2("IsA"))=1 and RS2("invPrintForm")=0 then disabled="disabled"
  255. Rs2.close
  256. Set Rs2=Nothing
  257. end if
  258. '--------------
  259. Call WriteFirstRow()
  260. '--------------
  261. if RcpCash<>0 then
  262. if IsCredit then
  263. Credit=RcpCash
  264. Debit=""
  265. else
  266. Credit=""
  267. Debit=RcpCash
  268. end if
  269. Amount = RcpCash
  270. Account = ""
  271. ' NEW cash
  272. if IsA then
  273. GLAccount = sysCashGLAccountA
  274. AccountTitle = sysCashGLAccountAName
  275. else
  276. GLAccount = sysCashGLAccountB
  277. AccountTitle = sysCashGLAccountBName
  278. end if
  279. 'GLAccount = DestGLAccount
  280. 'AccountTitle = DestGLAccName
  281. LineDescription=" " & RS1("AccountTitle") & " " & ReceiptID
  282. '--------------
  283. Call WriteRow()
  284. '--------------
  285. end if
  286. if ChqQtty <> 0 then
  287. Set RS2=Conn.Execute("SELECT * FROM ReceivedCheques WHERE (Receipt='"& ReceiptID& "')")
  288. do while not RS2.eof
  289. Amount=RS2("Amount")
  290. if IsCredit then
  291. Credit=Amount
  292. Debit=""
  293. else
  294. Credit=""
  295. Debit=Amount
  296. end if
  297. Account = ""
  298. ' NEW cash
  299. if IsA then
  300. GLAccount = sysChequeGLAccountA
  301. AccountTitle = sysChequeGLAccountAName
  302. else
  303. GLAccount = sysChequeGLAccountB
  304. AccountTitle = sysChequeGLAccountBName
  305. end if
  306. 'GLAccount = DestGLAccount
  307. 'AccountTitle = DestGLAccName
  308. Ref1=RS2("ChequeNo")
  309. Ref2=RS2("ChequeDate")
  310. LineDescription=" "& Ref1 & " "& Ref2 & " "& RS2("BankOfOrigin") & " " & ReceiptID & " "& RS2("Description") & " " & RS1("AccountTitle")
  311. '--------------
  312. Call WriteRow()
  313. '--------------
  314. RS2.moveNext
  315. loop
  316. RS2.close
  317. end if
  318. '****
  319. '****
  320. elseif ItemType=5 then
  321. 'Type = 5 ()
  322. PaymentID= RS1("Link")
  323. PayCash= cdbl(RS1("PayCash"))
  324. PayChq= cdbl(RS1("PayChq"))
  325. IsA=false
  326. if NOT(PayCash=0 AND PayChq=0) then
  327. ItemLines=1
  328. LineDescription=" " & AccountTitle & " " & PaymentID
  329. if PayCash<>0 then ItemLines = ItemLines + 1
  330. if PayChq=0 then
  331. ' Only Cash
  332. '--------------
  333. Call WriteFirstRow()
  334. '--------------
  335. if IsCredit then
  336. Credit=PayCash
  337. Debit=""
  338. else
  339. Credit=""
  340. Debit=PayCash
  341. end if
  342. Amount = PayCash
  343. Account = ""
  344. GLAccount = DestGLAccount
  345. AccountTitle = DestGLAccName
  346. LineDescription=" " & RS1("AccountTitle") & " " & PaymentID
  347. '--------------
  348. Call WriteRow()
  349. '--------------
  350. else
  351. ' Some Cheques + (maybe) chash
  352. Set RS2 = Server.CreateObject("ADODB.Recordset")
  353. RS2.CursorLocation=3 'Because in ADOVBS_INC adUseClient=3
  354. 'CheqStatus = 21 means: paid cheque is still not passed
  355. mySQL="SELECT PaidCheques.ChequeNo, PaidCheques.ChequeDate, PaidCheques.Description, PaidCheques.Amount, BnkGLAcc.GLAccount, GLAccounts.Name AS GLAccName FROM (SELECT Banker, GLAccount, GL FROM BankerCheqStatusGLAccountRelation WHERE (GL = "& openGL & ") AND (CheqStatus = 21)) BnkGLAcc INNER JOIN GLAccounts ON BnkGLAcc.GL = GLAccounts.GL AND BnkGLAcc.GLAccount = GLAccounts.ID RIGHT OUTER JOIN PaidCheques ON BnkGLAcc.Banker = PaidCheques.Banker WHERE (PaidCheques.Payment = "& PaymentID & ")"
  356. RS2.Open mySQL ,Conn,3 '3=adOpenStatic
  357. PayChqQtty = RS2.RecordCount
  358. ItemLines = ItemLines + PayChqQtty
  359. '--------------
  360. Call WriteFirstRow()
  361. '--------------
  362. if PayCash<>0 then
  363. if IsCredit then
  364. Credit=PayCash
  365. Debit=""
  366. else
  367. Credit=""
  368. Debit=PayCash
  369. end if
  370. Amount = PayCash
  371. Account = ""
  372. GLAccount = DestGLAccount
  373. AccountTitle = DestGLAccName
  374. LineDescription=" " & RS1("AccountTitle") & " " & PaymentID
  375. '--------------
  376. Call WriteRow()
  377. '--------------
  378. end if
  379. Do While NOT RS2.eof
  380. Amount=RS2("Amount")
  381. if IsCredit then
  382. Credit=Amount
  383. Debit=""
  384. else
  385. Credit=""
  386. Debit=Amount
  387. end if
  388. Ref1= RS2("ChequeNo")
  389. Ref2= RS2("ChequeDate")
  390. Account = ""
  391. GLAccount = RS2("GLAccount")
  392. AccountTitle = RS2("GLAccName")
  393. LineDescription=" "& Ref1 & " "& Ref2 & " " & RS1("AccountTitle") & " "& RS2("Description") & " "
  394. '--------------
  395. Call WriteRow()
  396. '--------------
  397. RS2.moveNext
  398. Loop
  399. RS2.close
  400. Set RS2=Nothing
  401. end if
  402. else
  403. response.write "<br><B> </B>"
  404. end if
  405. '****
  406. '****
  407. else
  408. ' Other Item Types
  409. ' (Invoice / RevInvoice / Non-Transfer Memo)
  410. if Vat > 0 then
  411. ItemLines = 3
  412. else
  413. ItemLines = 2
  414. end if
  415. LineDescription=Descriptions(ItemType)
  416. select case ItemType
  417. case 1:
  418. number = RS1("Number")
  419. if number = "" or number="-" then
  420. number = RS1("Link") & " "
  421. if CBool(RS1("IsA")) then disabled="disabled"
  422. end if
  423. if cdbl(RS1("GLAccount")) = 13003 then
  424. LineDescription=" "& number
  425. else
  426. LineDescription=" "& number & " " & RS1("AccountTitle")
  427. end if
  428. VatDescription = " "& number & " " & RS1("AccountTitle")
  429. case 3:
  430. LineDescription=RS1("MmoDescription")
  431. case 4:
  432. number = RS1("Number")
  433. if number = "" or IsNull(number) then
  434. number = RS1("Link") & " "
  435. end if
  436. LineDescription="ѐ "& RS1("AccountTitle") & " ѐ "& number
  437. VatDescription = " ѐ "& number & " " & RS1("AccountTitle")
  438. case 5:
  439. LineDescription=" "& RS1("AccountTitle") & " "& RS1("Link")
  440. VatDescription = ""
  441. case 6:
  442. number = RS1("Number")
  443. if number = "-" then
  444. number = RS1("Link") & " "
  445. end if
  446. 'response.write(RS1("Account"))
  447. 'response.end
  448. LineDescription = " "& RS1("AccountTitle") & " "& number
  449. VatDescription = " " & RS1("AccountTitle") & " " & number
  450. end select
  451. '--------------
  452. if ItemType = 6 then
  453. LineDescription = " "& number
  454. set rs = Conn.Execute("select count(id) as cnt from VoucherLines where Voucher_ID=" & rs1("link"))
  455. ItemLines = 1 + CInt(rs("cnt"))
  456. if Vat > 0 then ItemLines = ItemLines + 1
  457. else
  458. if Vat > 0 then
  459. ItemLines = 3
  460. else
  461. ItemLines = 2
  462. end if
  463. end if
  464. Call WriteFirstRow()
  465. '--------------
  466. 'tmpAccount = Account
  467. Account = ""
  468. GLAccount = RS1("GLAccount")
  469. AccountTitle = RS1("GLAccountName")
  470. Amount = Amount - Vat
  471. if isCredit = 0 then
  472. Debit = Debit - Vat
  473. else
  474. Credit = Credit - Vat
  475. end if
  476. ' -----------
  477. if ItemType = 6 then
  478. 'LineDescription = " "& RS1("AccountTitle") & " "& number
  479. set rs=Conn.Execute("select VoucherLines.*,InventoryItems.Unit from VoucherLines left outer join PurchaseOrders on VoucherLines.RelatedPurchaseOrderID=PurchaseOrders.id left outer join InventoryItems on PurchaseOrders.TypeID=InventoryItems.ID and PurchaseOrders.IsService=0 where Voucher_ID=" & rs1("link"))
  480. while not rs.eof
  481. LineDescription = " " & rs("qtty") & " "
  482. if not IsNull(rs("unit")) then LineDescription = LineDescription & rs("unit") & " "
  483. LineDescription = LineDescription & RS("lineTitle") & " "& number
  484. Credit=rs("price")
  485. Debit=""
  486. Amount=rs("price")
  487. Call WriteRow()
  488. rs.moveNext
  489. wend
  490. rs.close
  491. set rs=nothing
  492. else
  493. Call WriteRow()
  494. end if
  495. '------------ SAM
  496. 'Account = tmpAccount
  497. if Vat > 0 then
  498. Amount = Vat
  499. LineDescription = VatDescription
  500. if isCredit = 0 then
  501. Debit = Vat
  502. else
  503. Credit = Vat
  504. end if
  505. GLAccount = sysVatAccount
  506. AccountTitle = sysVatAccountName
  507. '------------
  508. call WriteRow()
  509. '------------
  510. end if
  511. end if
  512. RS1.MoveNext
  513. Wend
  514. %>
  515. <TR>
  516. <TD class="RepTableFooter" colspan='8' align=center>&nbsp;<INPUT style="font-family:tahoma;border:1 solid black; width:50px;" type="submit" value="">&nbsp;</td>
  517. </TR>
  518. </TABLE>
  519. <br>
  520. <% end if%>