<!doctype html>
<html>

<head>
	<meta charset="utf-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<title>Invoice</title>
	<link href="https://fonts.googleapis.com/css?family=Open+Sans:400,700&display=swap" rel="stylesheet">
</head>
<style type="text/css">
	body {
		background: #f1f1f1;
		color: #000 !important;
	}

	table tbody .auto td {
		width: 415px;
		word-break: break-all;
	}
</style>

<body>
	<center>
		<table cellpadding="5" cellspacing="0" width="400" bgcolor="#ffffff" style="font-family:Arial, sans-serif;">
			<tr>
				<td align="center" style="font-size:24px; color: #000000;">
					<% if(user.isGST ) { %>
						TAX INVOICE
						<% } else { %>
							INVOICE
							<% } %>
				</td>
			</tr>

			<% if(user.shopName) { %>
				<tr style="font-size:25px;">
					<td align="center">
						<%= user.shopName %>
					</td>
				</tr>
				<% } %>
					<tr style="font-size:12px;">
						<td align="center">
							<%= user.shopAddr %>

						</td>
					</tr>
					<% if(user.city) { %>
						<tr style="font-size:12px;">
							<td align="center">
								<%= user.city %>-<%= user.pincode %>(<%= user.state%>)
							</td>
						</tr>
						<% } %>

							<tr style="font-size:12px;">
								<td align="center">
									Phone No:<%= user.mobileNo %>
								</td>
							</tr>
							<% if(user.gstNo && user.isGST ) { %>

								<tr style="font-size:12px;">
									<td align="center">
										GSTIN: <%= user.gstNo %>
									</td>
								</tr>
								<% } %>

									<tr style="font-size:12px;">
										<td align="center">
											Counter Billing
										</td>
									</tr>
									<tr>
										<td>
											<table>
												<tr>
													<td valign="top" width="200">
														<table>
															<tr height="22">
																<td align="left" style="font-size:12px;">BILL NO:</td>
																<td align="left" style="font-size:12px;">
																	<% if (user.isGST) { %>
																		<%= gstBillNo%>
																			<% }else{ %>
																				<%= nonGstBillNo%>
																					<% } %>
																</td>
															</tr>
															<tr height="22">
																<td align="left" style="font-size:12px;">BILL TO:</td>
																<td align="left" style="font-size:12px;">
																	<% if (customer.name) { %>
																		<%= customer.name %>
																			<% } %>
																</td>
															</tr>

															<% if (customer.address) { %>
																<tr height="22">
																	<td align="left" style="font-size:12px;"></td>
																	<td align="left" style="font-size:12px;">
																		<%= customer.address %>
																	</td>
																</tr>
																<% } %>
																	<tr height="22">
																		<td align="left" style="font-size:12px;"
																			width="68">
																			Contact No :
																		</td>
																		<td align="left" style="font-size:12px;">
																			<% if (customer.mobileNo) { %>
																				<%= customer.mobileNo %>
																					<% } %>
																		</td>
																	</tr>
														</table>
													</td>
													<td width="175" valign="top" style="padding-bottom:0px;">
														<table>
															<% let dateObj=new Date(invoiceDate) %>
																<% let
																	curDate=`${dateObj.getDate()}/${dateObj.getMonth() +
																	1}/${dateObj.getFullYear()}` %>
																	<tr height="22">
																		<td width="98" align="left"
																			style="font-size:12px;">DATE
																			:</td>
																		<td width="52" align="right"
																			style="font-size:12px;">
																			<%= curDate %>
																		</td>
																	</tr>
														</table>
													</td>
												</tr>
											</table>
										</td>
									</tr>
									<tr>
										<td colspan="2">
											<table>
												<tr>
													<td width="400" height="5" colspan="2"
														style="border-bottom:dashed 2px #000000; border-top:dashed 2px #000000">
														<table width="400">
															<tr height="22">
																<td align="left" width="76"
																	style="font-size:12px; text-align: center;">
																	Description</td>
																<td width="45" align="left"
																	style="font-size:12px; text-align: center;">HSN.
																</td>
																<td width="45" align="left"
																	style="font-size:12px; text-align: center;">Qty.
																</td>
																<td width="45" align="left"
																	style="font-size:12px; text-align: center;">
																	MRP
																</td>

																<td width="60" align="left"
																	style="font-size:12px; text-align: center;">
																	Rate</td>
																<td width="55" align="left"
																	style="font-size:12px; text-align: center;">
																	NetAmnt
																</td>
																<% if(user.isGST ) { %>
																	<td width="90" align="left"
																		style="font-size:12px; text-align: center;">
																		Tax%</td>
																	<% } %>
															</tr>
														</table>
													</td>
												</tr>
											</table>
										</td>
									</tr>
									<tr>
										<td colspan="8">
											<table>
												<tr>
													<td valign="top" width="400">
														<table>
															<% let total_item=0, item_Quantity=0 %>
																<% for (let item of items) { %>
																	<% total_item++%>
																		<tr class="auto" height="25">
																			<td align="left" width="80"
																				style="font-size:12px;">
																				<%= item.name %>
																					<% if(item.imei) { %>
																						<div style="
                                                display: flex;
                                                justify-content: space-between;
                                                width: 100%;
                                              ">
																							<span
																								style="font-size: 9px;">IMEI:
																								&nbsp;
																								<%= item.imei %>
																							</span>
																						</div>
																						<% } %>
																			</td>
																			<td align="center" width="50"
																				style="font-size:12px;">
																				<%= user.isGST ? item.serial_no :
																					undefined %>
																			</td>
																			<td align="center" width="60"
																				style="font-size:12px;">
																				<%= item.quantity %>
																					<% item_Quantity=item_Quantity +
																						item.quantity%>
																			</td>
																			<td align="center" width="40"
																				style="font-size:12px;">
																				<%= item.price %>
																			</td>
																			<td align="center" width="40"
																				style="font-size:12px;">
																				<%= item.totalAmount %>
																			</td>
																			<td align="center" width="40"
																				style="font-size:12px;">
																				<%= item.totalAmount %>
																			</td>
																			<% if(user.isGST ) { %>

																				<td align="center" width="60"
																					style="font-size:12px;">
																					<%= item.gst %>
																				</td>
																				<% } %>
																		</tr>
																		<% } %>


														</table>
													</td>
												<tr>
													<td width="400" height="4" colspan="2"
														style="border-bottom:dashed 2px #000000;">&nbsp;
													</td>
												</tr>
									</tr>
		</table>
		</td>
		</tr>
		<tr>
			<td colspan="2">
				<table width="400">
					<tr height="22" style="border-bottom:dashed 2px #000000; border-top:dashed 2px #000000">
						<td align="left" width="134" style="font-size:12px;">ITEMS &nbsp; &nbsp; <%= total_item %>
						</td>
						<td align="center" width="134" style="font-size:12px;">Qty &nbsp; &nbsp; <%= item_Quantity %>
						</td>
						<td align="center" width="64" style="font-size:12px;">
							<%= totalAmount %>
						</td>
					</tr>
					<tr>
						<td width="400" height="4" colspan="3" style="border-top:dashed 2px #000000;">&nbsp;
						</td>
					</tr>
					<tr>
						<td align="left" style="font-size:18px">Total Amount: </td>
						<td align="right" width="136" style="font-size:15px;"></td>
						<td align="right" width="136" style="font-size:18px;">
							<%= totalAmount %>
						</td>
					</tr>
				</table>
		<tr>
			<td align="center" width="100%" style="font-size:22px">Total Savings: <%= discount%>
			</td>
		</tr>
		</td>
		</tr>
		<tr>
			<td>
				<table width="400">
					<%let total_Tax=0, is_CGST=gstType%> %>
						<% for(let item of items) { %>
							<% total_Tax=total_Tax + (item.totalAmount - item.gstAmount);%>
								<% } %>
									<% if (is_CGST[0]=="C" || is_CGST[0]=="I" ) { %>
										<tr height="22" width="100%">
											<td align="left" width="25%" style="font-size:12px;">&nbsp;</td>
											<td align="left" width="25%" style="font-size:12px;">GST</td>
											<td align="right" width="25%" style="font-size:12px;">TAX AMT</td>
											<td align="left" width="25%" style="font-size:12px;">&nbsp;</td>
										</tr>
										<% } %>
											<% if(is_CGST[0]=="C" ) { %>
												<tr height="22" width="100%">
													<td align="left" width="25%" style="font-size:12px;">&nbsp;</td>
													<td align="left" width="25%" style="font-size:12px;">SGST</td>
													<td align="right" width="25%" style="font-size:12px;">
														<%= Number((total_Tax)/2).toFixed(2) %>
													</td>
													<td align="left" width="25%" style="font-size:12px;">&nbsp;</td>
												</tr>
												<tr height="22" width="100%">
													<td align="left" width="25%" style="font-size:12px;">&nbsp;</td>
													<td align="left" width="25%" style="font-size:12px;">CGST</td>
													<td align="right" width="25%" style="font-size:12px;">
														<%= Number((total_Tax)/2).toFixed(2) %>
													</td>
													<td align="left" width="25%" style="font-size:12px;">&nbsp;</td>
												</tr>
												<% } %>
													<% if(is_CGST[0]=="I" ) { %>
														<tr height="22" width="100%">
															<td align="left" width="25%" style="font-size:12px;">&nbsp;
															</td>
															<td align="left" width="25%" style="font-size:12px;">IGST
															</td>
															<td align="right" width="25%" style="font-size:12px;">
																<%= Number(total_Tax).toFixed(2) %>
															</td>
															<td align="left" width="25%" style="font-size:12px;">&nbsp;
															</td>
														</tr>
														<% } %>
				</table>
			</td>
		</tr>
		<tr>
			<td colspan="2">
				<table>
					<tr>
						<td valign="top" width="400">
							<table width="400">
								<tr height="22">
									<td align="right" width="375" style="font-size:18px;">Net To Pay :</td>
									<td align="right" width="175" style="font-size:18px;">
										<%= totalAmount - discount %>
									</td>
								</tr>
							</table>
						</td>
					</tr>
				</table>
			</td>
		</tr>
	</center>
</body>

</html>