
<body bgcolor=ffffff>

<table width=100%>
  <tr>
    <td width=10>&nbsp;</td>

    <td>
      <table width=100%>
        <tr>
          <td>
            <h4>
            <%company%><br>
            <%address%>
            </h4>
          </td>

          <th><img src=sql-ledger.png border=0 width=84 height=58></th>

          <td align=right>
            <h4>
            Tel: <%tel%><br>
            Fax: <%fax%>
            </h4>
          </td>
        </tr>

      </table>
    </td>
  </tr>

  <tr>
    <td>&nbsp;</td>

    <td>
      <table width=100% cellspacing=5>
        <tr bgcolor=000000>
	  <th width=50% align=left><font color=ffffff>TO</th>
	</tr>

	<tr valign=top>
	  <td>
	  <%name%>
	  <br><%address1%>
	  <%if address2%>
	  <br><%address2%>
	  <%end address2%>
	  <br><%city%>
	  <%if state%>
	  , <%state%>
	  <%end state%>
	  <%zipcode%>
	  <%if country%>
	  <br><%country%>
	  <%end country%>
	  <br>

	  <%if contact%>
	  <br><%contact%>
	  <br>
	  <%end contact%>

	  <%if vendorphone%>
	  <br>Tel: <%vendorphone%>
	  <%end vendorphone%>

	  <%if vendorfax%>
	  <br>Fax: <%vendorfax%>
	  <%end vendorfax%>

	  <%if email%>
	  <br><%email%>
	  <%end email%>

	  <%if vendortaxnumber%>
	  <br><%vendortaxnumber%>
	  <%end vendortaxnumber%>

	  </td>

	  <td>
	  <%shiptoname%>
	  <br><%shiptoaddress1%>
	  <%if shiptoaddress2%>
	  <br><%shiptoaddress2%>
	  <%end shiptoaddress2%>
	  <br><%shiptocity%>
	  <%if shiptostate%>
	  , <%shiptostate%>
	  <%end shiptostate%>
	  <%shiptozipcode%>
	  <%if shiptocountry%>
	  <br><%shiptocountry%>
	  <%end shiptocountry%>
	  <br>

	  <%if shiptocontact%>
	  <br><%shiptocontact%>
	  <br>
	  <%end shiptocontact%>

	  <%if shiptophone%>
	  <br>Tel: <%shiptophone%>
	  <%end shiptophone%>

	  <%if shiptofax%>
	  <br>Fax: <%shiptofax%>
	  <%end shiptofax%>

	  <%if shiptoemail%>
	  <br><%shiptoemail%>
	  <%end shiptoemail%>
	  </td>

	</tr>
      </table>
    </td>
  </tr>

  <tr height=5></tr>

  <tr>
    <td>&nbsp;</td>
    <th align=left>
      <h2>D E B I T &nbsp;&nbsp;&nbsp; I N V O I C E</h2>
    </th>
  </tr>
 
  <tr height=5></tr>
  
  <tr>
    <td>&nbsp;</td>
  
    <td>
      <table width=100% border=1>
        <tr>
	  <th width=14% align=left nowrap>Invoice #</th>
	  <th width=14% align=left nowrap>Date</th>
	  <th width=14% align=left nowrap>Due</th>
	  <th width=14% align=left nowrap>Order #</th>
	  <th width=14% align=left nowrap>Contact</th>
	  <th width=14% align=left nowrap>Shipping Point</th>
	  <th width=14% align=left nowrap>Ship via</th>
	</tr>

	<tr>
	  <td><%invnumber%></td>
	  <td><%invdate%></td>
	  <td><%duedate%></td>
	  <td><%ordnumber%>&nbsp;</td>
	  <td><%employee%>&nbsp;</td>
	  <td><%shippingpoint%>&nbsp;</td>
	  <td><%shipvia%>&nbsp;</td>
	</tr>
      </table>
    </td>
  </tr>

  <tr>
    <td>&nbsp;</td>
  
    <td>
      <table width=100%>
        <tr bgcolor=000000>
          <th align=right nowrap><font color=ffffff>Item</th>
          <th align=left nowrap><font color=ffffff>Number</th>
          <th align=left nowrap><font color=ffffff>Description</th>
          <th>&nbsp;</th>
          <th align=right nowrap><font color=ffffff>Qt'y</th>
          <th>&nbsp;</th>
          <th align=right nowrap><font color=ffffff>Unit Price</th>
          <th align=right nowrap><font color=ffffff>Disc %</th>
          <th align=right nowrap><font color=ffffff>Extended</th>
        </tr>

        <%foreach number%>
        <tr valign=top>
          <td align=right><%runningnumber%>.</td>
          <td><%number%></td>
          <td><%description%></td>
          <td><%deliverydate%></td>
          <td align=right><%qty%></td>
          <td><%unit%></td>
          <td align=right><%sellprice%></td>
          <td align=right><%discountrate%></td>
          <td align=right><%linetotal%></td>
        </tr>
	<tr>
	  <td></td>
	  <td></td>
	  <td><%notes%></td>
	</tr>
        <%end number%>

        <tr>
          <td colspan=9><hr noshade></td>
        </tr>
    
        <tr>
          <%if taxincluded%>
          <th colspan=7 align=right>Total</th>
          <td colspan=2 align=right><%invtotal%></td>
          <%end taxincluded%>

          <%if not taxincluded%>
          <th colspan=7 align=right>Subtotal</th>
          <td colspan=2 align=right><%subtotal%></td>
          <%end taxincluded%>
        </tr>

        <%foreach tax%>
        <tr>
	  <th colspan=3 align=left><font size=-2>Registration No. <%taxnumber%></font></th>
          <th colspan=4 align=right nowrap><%taxdescription%> on <%taxbase%> @ <%taxrate%> %</th>
          <td colspan=2 align=right><%tax%></td>
        </tr>
        <%end tax%>

	<%if not taxincluded%>
	<tr>
          <th colspan=7 align=right>Total</th>
          <td colspan=2 align=right><%invtotal%></td>
	</tr>
	<%end taxincluded%>

        <%if paid%>
        <tr>
          <th colspan=7 align=right>Paid</th>
          <td colspan=2 align=right>- <%paid%></td>
        </tr>
        <%end paid%>

        <tr>
          <td colspan=5>&nbsp;</td>
          <td colspan=4><hr noshade></td>
        </tr>

        <%if total%>
        <tr>
          <td colspan=5>&nbsp;</td>
          <th colspan=2 align=right nowrap>Balance Due</th>
          <th colspan=2 align=right><%total%></th>
        </tr>
        <%end total%>

        <tr>
      </table>
    </td>
  </tr>

  <tr>
    <td>&nbsp;</td>

    <td>
      <table width=100%>
        <tr valign=top>
	  <th align=left><%text_amount%> ***** <%decimal%>/100</th>
          <td align=right nowrap>
          All prices in <b><%currency%></b>
          </td>
        </tr>
	<%if taxincluded%>
	<tr>
	  <th align=left><font size=-2>Taxes included in price</font></th>
	</tr>
	<%end taxincluded%>
      </table>
    </td>
  </tr>
  
  <tr height=5></tr>

  <tr>
    <td>&nbsp;</td>
    
    <td>
      <table width=100%>
        <tr valign=top>
	  <td width=40%>
	    <%notes%>
	  </td>

  <%if paid_1%>
	  <td width=60% align=right>
	    <table width=100% border=1>
	      <tr>
		<td>
		  <table width=100%>
		    <tr bgcolor=000000>
		      <th colspan=4><font color=ffffff>Payments</th>
		    </tr>

		    <tr>
		      <th align=left>Date</th>
		      <th align=left>&nbsp;</th>
		      <th align=left>Source</th>
		      <th align=left width=1%>Amount</th>
		    </tr>
  <%end paid_1%>

		    <%foreach payment%>
		    <tr>
		      <td nowrap><%paymentdate%></td>
		      <td nowrap><%paymentaccount%></td>
		      <td><%paymentsource%></td>
		      <td><%payment%></td>
		    </tr>
		    <%end payment%>
		    
  <%if paid_1%>
		  </table>
		</td>
	      </tr>
	    </table>
  <%end paid_1%>
        </tr>
      </table>
    </td>
  </tr>

  <tr>
    <td>&nbsp;</td>

    <td><hr noshade></td>
  </tr>

</table>

</body>
</html>


