PageRenderTime 11ms CodeModel.GetById 2ms app.highlight 3ms RepoModel.GetById 2ms app.codeStats 0ms

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