Created
February 24, 2024 11:29
-
-
Save Rohit-554/7177f81403a823d25572fafcc32613e9 to your computer and use it in GitHub Desktop.
a.html
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| private fun createTable( | |
| billDetail: BillSetting, | |
| party: PartyModelRequest, | |
| termsAndConditionAndNotes: TermsAndConditionAndNotes, | |
| billSignature: BillSignatureResponse, | |
| billSlogan: SloganResponse, | |
| selectedRadioButton: String | |
| ) { | |
| //TODO: if a condition is true by default do not remove else section code because it will | |
| //TODO: be used in future | |
| val showGstColumn = transactionList?.any { it.gstRate != GstRate.NO_GST } | |
| val showHsnColumn = transactionList?.any { it.hsnCode.isNotBlank() } | |
| var quantitySubtotal = 0.0 | |
| var amountSubtotal = 0.0 | |
| if (billDetail.panNumber.isBlank() or billDetail.gstNumber.isBlank()) { | |
| chunkValue = 1 | |
| } else if (billDetail.panNumber.isBlank() && billDetail.gstNumber.isBlank()) { | |
| chunkValue = 2 | |
| } | |
| if (billDetail.businessInformationExtraFields.isNullOrEmpty()) { | |
| chunkValue = 0 | |
| subList = emptyList() | |
| } else { | |
| subList = | |
| billDetail.businessInformationExtraFields.subList(0, chunkValue).toList() | |
| } | |
| Log.d("transactionvalue", "${transactionModel?.showNotes}${transactionModel?.note}") | |
| var billDoc = """ | |
| <html lang="en"><head> | |
| <meta charset="UTF-8"> | |
| <meta http-equiv="X-UA-Compatible" content="IE=edge"> | |
| <meta name="viewport" content="width=device-width, initial-scale=0.4"> | |
| <title>Document</title> | |
| <link rel="StyleSheet" href="../Invoice/invoice.css"> | |
| <style> | |
| body { | |
| padding: 0px !important; | |
| margin: 0px !important; | |
| box-sizing: border-box; | |
| } | |
| #invoice { | |
| font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, | |
| Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif; | |
| padding: 10px; | |
| margin: auto; | |
| } | |
| #invoice .center { | |
| text-align: center; | |
| } | |
| #invoice .right { | |
| text-align: right; | |
| } | |
| #invoice .left { | |
| text-align: left; | |
| } | |
| /* header */ | |
| #invoice .shop_name { | |
| font-size: 26px; | |
| } | |
| #invoice .invoice_txt { | |
| font-size: 16px; | |
| justify-content: space-between; | |
| display: flex; | |
| } | |
| #invoice .invoice_type{ | |
| margin-top: 30px; | |
| justify-content: space-between; | |
| display: flex; | |
| } | |
| #invoice .invoice_txt_no_image { | |
| font-size: 16px; | |
| } | |
| #invoice .header p, | |
| #invoice h3, | |
| #invoice h5, | |
| #invoice h1 { | |
| margin-bottom: 0px; | |
| } | |
| #invoice .address{ | |
| margin-bottom: 3px; | |
| } | |
| #invoice .address p { | |
| font-size: 12px; | |
| padding: 0px; | |
| } | |
| #invoice .horz_line { | |
| background: red; | |
| height: 5px; | |
| margin-bottom: 0px; | |
| } | |
| #invoice .horz_line_slogan { | |
| background: red; | |
| height: 0.5px; | |
| margin-bottom: 0px; | |
| } | |
| #invoice .horz_line1 { | |
| background: red; | |
| height: 0.5px; | |
| } | |
| #invoice .header .name { | |
| display: flex; | |
| justify-content: space-between; | |
| color: red; | |
| align-items: center; | |
| } | |
| #invoice .header .name h5 { | |
| font-weight: 500; | |
| } | |
| #invoice .header .contact { | |
| display: flex; | |
| justify-content: space-between; | |
| } | |
| #invoice .header .contact table tr{ | |
| width: 100%; | |
| } | |
| #invoice .header .contact p { | |
| font-size: 12px; | |
| padding: 0px; | |
| margin-top: 0px; | |
| font-weight: normal; | |
| } | |
| #invoice .header .contact td { | |
| padding: 0px; | |
| height: 22px; | |
| margin: 0px; | |
| text-align: left; | |
| } | |
| /* Invoice details */ | |
| #invoice .invoice_details { | |
| background-color: #ccf0e5; | |
| font-size: 13px; | |
| display: flex; | |
| justify-content: space-between; | |
| } | |
| /* shipping_details */ | |
| #invoice .shipping_details { | |
| display: flex; | |
| } | |
| #invoice .shipping_details .bill_to_txt, | |
| #invoice .ship_to_txt { | |
| font-weight: 500; | |
| font-size: 14px; | |
| } | |
| #invoice .shipping_details .ship_to { | |
| width: 50%; | |
| } | |
| #invoice .shipping_details .bill_to { | |
| width: 50%; | |
| } | |
| #invoice h4, | |
| #invoice h6 { | |
| margin-top: 3px; | |
| margin-bottom: 3px; | |
| font-size: 14px; | |
| } | |
| #invoice h6 { | |
| font-weight: 500; | |
| font-size: 12px; | |
| } | |
| /* amount_specification */ | |
| #invoice .amount_specification { | |
| float: right; | |
| text-align: right; | |
| margin-top: 5px; | |
| width: 40%; | |
| } | |
| #invoice .amount_specification h5, | |
| #invoice .amount_specification p { | |
| margin: 0px; | |
| padding: 5px; | |
| font-size: 12px; | |
| } | |
| #invoice .amount_specification_div { | |
| display: flex; | |
| width: 50%; | |
| justify-content: space-between; | |
| } | |
| #invoice .amount_specification td { | |
| width: 55%; | |
| } | |
| #invoice .amount_specification .bold { | |
| font-weight: bold; | |
| } | |
| #invoice .amount_specification table .bottom-border td { | |
| border-bottom: 1px solid red; | |
| } | |
| #invoice .amount_specification table .vertical-border td { | |
| border-bottom: 1px solid red; | |
| border-top: 1px solid red; | |
| } | |
| #invoice .amount_specification table .hz-line td { | |
| border-top: 1px solid red; | |
| } | |
| /* table */ | |
| #invoice table { | |
| width: 100%; | |
| margin-top: 5px; | |
| } | |
| #invoice table th { | |
| font-weight: normal; | |
| padding: 8px; | |
| border-right: 1px solid #fff; | |
| font-size: 13px; | |
| } | |
| #invoice table tr { | |
| padding: 2px; | |
| font-size: 12px; | |
| } | |
| #invoice table .bottom-border td { | |
| border-bottom: 1px solid rgba(203, 159, 159, 0.4); | |
| } | |
| #invoice table .bottom-border-red td { | |
| border-bottom: 1px solid red; | |
| } | |
| .content_table { | |
| width: 100%; | |
| } | |
| #invoice table .top-border-red td { | |
| border-top: 1px solid red; | |
| } | |
| #invoice table td { | |
| padding: 5px; | |
| } | |
| #invoice table .header { | |
| background: red; | |
| color: white; | |
| } | |
| #invoice table .sub_total { | |
| outline: 1px solid red; | |
| } | |
| #invoice table .sub_total td { | |
| padding: 5px; | |
| margin-top: 5px; | |
| } | |
| #invoice .spacing_div td { | |
| padding-top: 40px; | |
| } | |
| #invoice .footer_div { | |
| display: flex; | |
| justify-content: space-between; | |
| } | |
| .signature_footer { | |
| margin-top: 80px; | |
| width: 100%; | |
| display: grid; | |
| grid-template-columns: 1fr 1fr; | |
| justify-content: space-between; | |
| } | |
| .signature1 { | |
| width: 80%; | |
| display: flex; | |
| flex: 1; | |
| flex-direction: column; | |
| gap: 10px; | |
| } | |
| .signature2 { | |
| width: 80%; | |
| display: flex; | |
| flex: 0 0 auto; | |
| margin-left: auto; | |
| flex-direction: column; | |
| gap: 10px; | |
| } | |
| .signature_box { | |
| height: 70px; | |
| border: 0.5px solid #555; | |
| } | |
| .img_deg { | |
| float: right; | |
| } | |
| .signature_title { | |
| text-align: end; | |
| font-weight: 500; | |
| font-size: 12px; | |
| } | |
| .slogan_div { | |
| display: inline-block; | |
| /* Add any other common styles for slogan_div */ | |
| } | |
| .slogan.center { | |
| text-align: center; | |
| /* Add any other styles for center alignment */ | |
| } | |
| .slogan.left { | |
| text-align: left; | |
| /* Add any other styles for left alignment */ | |
| } | |
| .slogan.middle { | |
| text-align: center; | |
| /* Add any other styles for center alignment */ | |
| } | |
| .slogan.right { | |
| text-align: right; | |
| /* Add any other styles for right alignment */ | |
| } | |
| .thank_title { | |
| margin-top: 20px; | |
| } | |
| .image_text{ | |
| display: flex; | |
| align-items: flex-start; | |
| gap: 20px; | |
| width:100%; | |
| } | |
| .company_details{ | |
| display: flex; | |
| width: 100%; | |
| flex-direction: column; | |
| } | |
| .name { | |
| margin-bottom: 4px; | |
| } | |
| .name h1{ | |
| margin:0; padding: 0; | |
| } | |
| #invoice table .test{ | |
| width: 100%; | |
| background:red; | |
| margin-top: 0px; | |
| } | |
| </style> | |
| </head> | |
| <body> | |
| <div id="invoice" class="invoice_div"> | |
| <div class="header"> | |
| ${ | |
| if (billSlogan.isNotEmpty()) { | |
| val nonEmptySlogans = billSlogan.filter { it.isNotEmpty() } | |
| val totalSlogan = nonEmptySlogans.size | |
| when (totalSlogan) { | |
| 1 -> | |
| "<div class=\"a\" style=\"text-align: center; color: black;\">${nonEmptySlogans[0]}</div>" + | |
| "<div style=\"margin: 0;\">" + | |
| "<hr class=\"horz_line_slogan\"/>"+ | |
| "</div>" | |
| 2, 3 -> | |
| "<div class=\"a\" style=\"display: flex; justify-content: space-between;\">" + | |
| "<div style=\"color: black;\">${nonEmptySlogans[0]}</div>" + | |
| "<div style=\"color: black;\">${nonEmptySlogans[1]}</div>" + | |
| (if (totalSlogan == 3) "<div style=\"color: black;\">${nonEmptySlogans[2]}</div>" else "") + | |
| "</div>" + | |
| "<div style=\"margin: 0;\">" + | |
| "<hr class=\"horz_line_slogan\"/>"+ | |
| "</div>" | |
| else -> "" | |
| } | |
| } else { | |
| "" | |
| } | |
| } | |
| ${ | |
| if(billDetail.businessLogo!=null && billDetail.businessLogo!=""){ | |
| """ | |
| <div class = "invoice_type"> | |
| <p class="invoice_txt">${if (showGstColumn == true) "TAX INVOICE" else "INVOICE"}</p> | |
| <p class="invoice_txt" style="color: #AB8484">$selectedRadioButton</p> | |
| </div> | |
| <br> | |
| <div class="image_text"> | |
| ${ | |
| if(billDetail.businessLogo!=null && billDetail.businessLogo!=""){ | |
| "<img class=\"store-logo\" src=\"${billDetail.businessLogo}\" alt=\"Store Logo\" width=\"100\" height=\"100\">" | |
| } else { | |
| "" | |
| } | |
| } | |
| <div class="company_details"> | |
| <div class="name"> | |
| <h1 class="shop_name">$storeName</h1> | |
| </div> | |
| <div class="address"> | |
| <p class="shop_address">${billDetail.addressDetail}${if (billDetail.addressDetail.isEmpty() || billDetail.addressState.isEmpty()) "" else ","} ${billDetail.addressState}${if (billDetail.pinCode.isEmpty() || billDetail.pinCode.isEmpty()) "" else ","} ${billDetail.pinCode}</p> | |
| </div> | |
| <div class="contact"> | |
| <table> | |
| <tbody> | |
| <tr> | |
| ${if (billDetail.showPhoneNumber) "<td class=\"phone\"><strong>Phone:</strong> <span class=\"phone\">${billDetail.phoneNumber}</span></td>" else ""} | |
| ${if (billDetail.gstNumber.isNotBlank()) "<td class=\"gstin\"><strong>GSTIN:</strong> <span class=\"gstin\">${billDetail.gstNumber}</span></td>" else ""} | |
| ${if (billDetail.panNumber.isNotBlank()) "<td class=\"pan\"><strong>PAN Number:</strong> <span class=\"pan\">${billDetail.panNumber}</span></td>" else ""} | |
| ${ | |
| subList.joinToString("") { extraField -> | |
| val displayName = when (extraField.fieldName) { | |
| "fassai_key" -> "FSSAI No" | |
| "drug_key" -> "Drug Lic No" | |
| "email_key" -> "Email ID" | |
| else -> extraField.fieldName | |
| } | |
| if (!displayName.isNullOrBlank() && !extraField.fieldValue.isNullOrBlank()) { | |
| "<td colspan=1><div class=\"extra-field\"><p><strong>${displayName}:</strong> <span>${extraField.fieldValue}</span></p></div></td>" | |
| } else { | |
| "" | |
| } | |
| } | |
| } | |
| </tr> | |
| ${ | |
| if (!billDetail.businessInformationExtraFields.isNullOrEmpty()) { | |
| val filteredList = billDetail.businessInformationExtraFields | |
| .filter { extraField -> | |
| extraField.fieldName.isNotEmpty() && extraField.fieldValue.isNotEmpty() | |
| } | |
| if (chunkValue < filteredList.size) { | |
| filteredList | |
| .subList(chunkValue, filteredList.size) | |
| .chunked(3) | |
| .withIndex() | |
| .joinToString("") { (index, chunk) -> | |
| "<tr>${ | |
| chunk.joinToString("") { extraField -> | |
| val displayName = when (extraField.fieldName) { | |
| "fassai_key" -> "FSSAI No" | |
| "drug_key" -> "Drug Lic No" | |
| "email_key" -> "Email ID" | |
| else -> extraField.fieldName | |
| } | |
| "<td colspan=1><div class=\"extra-field\"><p><strong>${displayName}:</strong> <span>${extraField.fieldValue}</span></p></div></td>" | |
| } | |
| }</tr>" | |
| } | |
| } else { | |
| "" | |
| } | |
| } else { | |
| "" | |
| } | |
| } | |
| </tbody> | |
| </table> | |
| </div> | |
| </div> | |
| </div> | |
| """.trimIndent() | |
| } else { | |
| """ | |
| <div class = "invoice_type"> | |
| <p class="invoice_txt">${if (showGstColumn == true) "TAX INVOICE" else "INVOICE"}</p> | |
| <p class="invoice_txt" style="color: #AB8484">$selectedRadioButton</p> | |
| </div> | |
| <br> | |
| <br> | |
| <div class="name"> | |
| <h1 class="shop_name">$storeName</h1> | |
| </div> | |
| <div class="address"> | |
| <p class="shop_address"> | |
| ${billDetail.addressDetail}${if (billDetail.addressDetail.isEmpty() || billDetail.addressState.isEmpty()) "" else ","} | |
| ${billDetail.addressState}${if (billDetail.pinCode.isEmpty() || billDetail.pinCode.isEmpty()) "" else ","} | |
| ${billDetail.pinCode} | |
| </p> | |
| </div> | |
| <div class="contact"> | |
| <table> | |
| <tbody> | |
| <tr> | |
| ${if (billDetail.showPhoneNumber) "<td class=\"phone\"><strong>Phone:</strong> <span class=\"phone\">${billDetail.phoneNumber}</span></td>" else ""} | |
| ${if (billDetail.gstNumber.isNotBlank()) "<td class=\"gstin\"><strong>GSTIN:</strong> <span class=\"gstin\">${billDetail.gstNumber}</span></td>" else ""} | |
| ${if (billDetail.panNumber.isNotBlank()) "<td class=\"pan\"><strong>PAN Number:</strong> <span class=\"pan\">${billDetail.panNumber}</span></td>" else ""} | |
| ${ | |
| subList.joinToString("") { extraField -> | |
| val displayName = when (extraField.fieldName) { | |
| "fassai_key" -> "FSSAI No" | |
| "drug_key" -> "Drug Lic No" | |
| "email_key" -> "Email ID" | |
| else -> extraField.fieldName | |
| } | |
| if (!displayName.isNullOrBlank() && !extraField.fieldValue.isNullOrBlank()) { | |
| "<td colspan=1><div class=\"extra-field\"><p><strong>${displayName}:</strong> <span>${extraField.fieldValue}</span></p></div></td>" | |
| } else { | |
| "" | |
| } | |
| } | |
| } | |
| </tr> | |
| ${ | |
| if (!billDetail.businessInformationExtraFields.isNullOrEmpty()) { | |
| val filteredList = billDetail.businessInformationExtraFields | |
| .filter { extraField -> | |
| extraField.fieldName.isNotEmpty() && extraField.fieldValue.isNotEmpty() | |
| } | |
| if (chunkValue < filteredList.size) { | |
| filteredList | |
| .subList(chunkValue, filteredList.size) | |
| .chunked(3) | |
| .withIndex() | |
| .joinToString("") { (index, chunk) -> | |
| "<tr>${ | |
| chunk.joinToString("") { extraField -> | |
| val displayName = when (extraField.fieldName) { | |
| "fassai_key" -> "FSSAI No" | |
| "drug_key" -> "Drug Lic No" | |
| "email_key" -> "Email ID" | |
| else -> extraField.fieldName | |
| } | |
| "<td colspan=1><div class=\"extra-field\"><p><strong>${displayName}:</strong> <span>${extraField.fieldValue}</span></p></div></td>" | |
| } | |
| }</tr>" | |
| } | |
| } else { | |
| "" | |
| } | |
| } else { | |
| "" | |
| } | |
| } | |
| </tbody> | |
| </table> | |
| </div> | |
| """.trimIndent() | |
| } | |
| } | |
| <hr class="horz_line"/> | |
| </div> | |
| <div class="invoice_details"> | |
| <p style="margin-left: 8px;"><strong>Invoice No:</strong> <span class="invoiceNo">$billNumber</span></p> | |
| <p style="margin: 8px;><strong>Invoice Date:</strong> <span class="invoice_date">$transactionDate</span></p> | |
| </div> | |
| <div class="shipping_details"> | |
| <div class="bill_to"> | |
| <h5 class="bill_to_txt"> | |
| BILL TO | |
| </h5> | |
| <h4 class="name"> | |
| $billToName | |
| </h4> | |
| <h6 class="address"> | |
| ${if (party.billingAddress.isNullOrBlank()) "" else "${party.billingAddress} <br>"} | |
| ${if (party.billingAddressPincode.isNullOrBlank()) "" else "Pin: <span class=\"pin\"> ${party.billingAddressPincode}</span>"} | |
| </h6> | |
| <h6 class="phone"> | |
| ${if (party.mobile.isEmpty()) "" else "Phone: <span class=\"phone\">${party.mobile}</span>"} | |
| </h6> | |
| ${ | |
| if (party.panNumber.isNullOrBlank()) "" else "<h6 class=\"pan\">\n" + " PAN Number: <span class=\"pan\">${party.panNumber}</span>\n" + " </h6>" | |
| } | |
| ${ | |
| if (party.gstNumber.isNullOrBlank()) "" else "<h6 class=\"gstin\">\n" + " GSTIN: <span class=\"pan\">${party.gstNumber}</span>\n" + " </h6>" | |
| } | |
| <h6 class="placeOfSupply"> | |
| ${if (party.billingAddressState.isNullOrBlank()) "" else "State: <span class=\"pan\">${party.billingAddressState}</span>"} | |
| </h6> | |
| </div> | |
| <div class="ship_to"> | |
| <h5 class="ship_to_txt"> | |
| SHIP TO | |
| </h5> | |
| <h4 class="name"> | |
| $billToName | |
| </h4> | |
| <h6 class="address"> | |
| ${if (party.shippingAddress.isNullOrBlank()) "" else "${party.shippingAddress} <br>"} | |
| ${if (party.shippingAddressPincode.isNullOrBlank()) "" else "Pin: <span class=\"pin\"> ${party.shippingAddressPincode}</span>"} | |
| </h6> | |
| <h6 class="placeOfSupply"> | |
| ${if (party.shippingAddressState.isNullOrBlank()) "" else "State: <span class=\"pan\">${party.shippingAddressState}</span>"} | |
| </h6> | |
| </div> | |
| </div> | |
| <div class="content_table"> | |
| <table cellspacing="0"> | |
| <tbody><tr class="header"> | |
| <th class="left">SN</th> | |
| <th class="left">Items</th> | |
| ${if (showHsnColumn == true) "<th class=\"left\">HSN</th>" else ""} | |
| <th class="left">Quantity</th> | |
| <th class="left">Price per unit</th> | |
| ${if (showGstColumn == true) "<th class=\"left\">Tax per unit</th>" else ""} | |
| <th class="right">Amount</th> | |
| </tr> | |
| </div> | |
| """ | |
| var showQuantitySubtotal = true | |
| var gstSubtotal = 0.0 | |
| val gstMap = HashMap<GstRate, Double>() | |
| transactionModel?.let { | |
| if (it.extraCharges.gstRate > GstRate.TAX_EXEMPTED) { | |
| gstMap[it.extraCharges.gstRate] = | |
| it.extraCharges.totalAmount - it.extraCharges.taxableAmount | |
| } | |
| } | |
| val unit = if (transactionList.isNullOrEmpty()) "" else transactionList?.let { | |
| it[0].itemUnit | |
| } | |
| if (transactionList != null) { | |
| for (i in transactionList!!.indices) { | |
| val model = transactionList!![i] | |
| if (model.itemUnit != unit) { | |
| showQuantitySubtotal = false | |
| } | |
| quantitySubtotal += parseDouble(model.quantity) | |
| val price = | |
| if (InputFieldUtils.checkDecimal(model.price) == InputFieldUtils.FieldInput.CORRECT) object { | |
| val totalPrice = parseDouble(model.price) | |
| val basePrice = (totalPrice * 100) / (100 + model.gstRate.rate) | |
| val gstAmount = totalPrice - basePrice | |
| } | |
| else null | |
| val quantity = | |
| if (InputFieldUtils.checkDecimal(model.quantity) == InputFieldUtils.FieldInput.CORRECT) parseDouble( | |
| model.quantity | |
| ) else 0.0 | |
| amountSubtotal += parseDouble(model.amount) | |
| if (price != null && model.gstRate > GstRate.TAX_EXEMPTED) { | |
| gstSubtotal += quantity * price.gstAmount | |
| gstMap[model.gstRate] = | |
| (gstMap[model.gstRate] ?: 0.0) + quantity * price.gstAmount | |
| } | |
| //This is for displaying the item details like name, quantity, price, gst, amount | |
| billDoc = (billDoc + "<tr class=\"border bottom-border\">" + | |
| "<td class=\"left\" style=\"width: 25px;\">" + (i + 1) + "</td>" + // Adjust the width as needed | |
| "<td>" + model.itemName + "</td>" + | |
| if (showHsnColumn == true) "<td> ${model.hsnCode} </td>" else { | |
| "" | |
| } + | |
| "<td class=\"left\">" + model.quantity + " " + model.itemUnit + "</td>" + | |
| "<td class=\"left\">" + MainActivity.currencySymbol + " " + (price?.run { | |
| if (model.gstRate != GstRate.NO_GST && model.gstRate != GstRate.TAX_EXEMPTED) "%.2f".format( | |
| totalPrice - gstAmount | |
| ) else "%.2f".format(totalPrice) | |
| } ?: "-") + "</td>" + | |
| if (showGstColumn == true) { | |
| "<td class=\"left\">${ | |
| when { | |
| model.gstRate <= GstRate.TAX_EXEMPTED -> model.gstRate.title | |
| price == null -> "-" | |
| else -> "${MainActivity.currencySymbol} ${ | |
| "%.2f".format( | |
| price.gstAmount | |
| ) | |
| }(${model.gstRate.rate}%)" | |
| } | |
| }</td>" | |
| } else { | |
| "" | |
| } + | |
| "<td class=\"right\">" + MainActivity.currencySymbol + " " + model.amount + "</td>" + | |
| "</tr>") | |
| } | |
| } | |
| val spacing = | |
| "<tr class=\"spacing_div\">\n" + " <td></td>\n" + if (showHsnColumn == true) "<td></td>\n" else { | |
| "" | |
| } + " <td></td>\n" + if (showGstColumn == true) "<td></td>\n" else { | |
| "" | |
| } + " <td></td>\n" + " </tr>" | |
| billDoc += spacing | |
| val subTotal = """ | |
| <tr class="bottom-border-red top-border-red"> | |
| <td colspan="2"><strong>Sub Total</strong></td> | |
| ${if (showHsnColumn == true) "<td class=\"left\"></td>" else ""} | |
| <td class="left"><strong>${if (showQuantitySubtotal) quantitySubtotal else ""}</strong></td> | |
| <td class="left"></td> | |
| ${ | |
| if (showGstColumn == true) "<td class=\"left\"><strong>${MainActivity.currencySymbol} ${ | |
| "%.2f".format( | |
| gstSubtotal | |
| ) | |
| }</strong></td>" else "" | |
| } | |
| <td class="right"><strong>${MainActivity.currencySymbol} ${amountSubtotal.roundTo2DecimalPlaces()}</strong></td> | |
| </tr> | |
| </tbody></table></div> | |
| """.trimIndent() | |
| billDoc += subTotal | |
| billDoc += """ | |
| <div class="footer_div"> | |
| <div class="amount_specification"> | |
| <table cellspacing="0"> | |
| <tbody><tr class="bold"> | |
| <td class="center"></td> | |
| <td class="right"></td> | |
| </tr> | |
| ${ | |
| if (billDetail.accountHolderName.isEmpty() || billDetail.accountNumber.isEmpty() || billDetail.bankName.isEmpty() || billDetail.accountHolderName.isEmpty() || billDetail.upiId.isEmpty()) "" else """ | |
| <tr> | |
| <td class="left" style="font-weight: bold;">Bank Details</td> | |
| <td class="left received_amount"></td> | |
| </tr> | |
| """.trimIndent() | |
| } | |
| ${ | |
| if (billDetail.accountHolderName.isEmpty()) "" else """ | |
| <tr> | |
| <td class="left">Account holder:</td> | |
| <td class="left received_amount">${billDetail.accountHolderName}</td> | |
| </tr> | |
| """.trimIndent() | |
| } | |
| ${ | |
| if (billDetail.accountNumber.isEmpty()) "" else """ | |
| <tr> | |
| <td class="left">Account number:</td> | |
| <td class="left received_amount">${billDetail.accountNumber}</td> | |
| </tr> | |
| """.trimIndent() | |
| } | |
| ${ | |
| if (billDetail.bankName.isEmpty()) "" else """ | |
| <tr> | |
| <td class="left">Bank:</td> | |
| <td class="left received_amount">${billDetail.bankName}</td> | |
| </tr> | |
| """.trimIndent() | |
| } | |
| ${ | |
| if (billDetail.branch.isEmpty()) "" else """ | |
| <tr> | |
| <td class="left">Branch:</td> | |
| <td class="left received_amount">${billDetail.branch}</td> | |
| </tr> | |
| """.trimIndent() | |
| } | |
| ${ | |
| if (billDetail.ifscCode.isEmpty()) "" else """ | |
| <tr> | |
| <td class="left">IFSC code:</td> | |
| <td class="left received_amount">${billDetail.ifscCode}</td> | |
| </tr> | |
| """.trimIndent() | |
| } | |
| ${ | |
| if (billDetail.upiId.isEmpty()) "" else """ | |
| <tr> | |
| <td class="left">UPI ID:</td> | |
| <td class="left received_amount">${billDetail.upiId}</td> | |
| </tr> | |
| """.trimIndent() | |
| } | |
| ${ | |
| if(transactionModel?.showNotes == false){ | |
| """ | |
| <tr class="bottom-border-red top-border-red"> | |
| </tr> | |
| """.trimIndent() | |
| } else """ | |
| <tr> | |
| <td class="left" height = "20px"></td> | |
| <td class="left received_amount"></td> | |
| </tr> | |
| <tr> | |
| <td class="left" style="font-weight: bold;">Remark</td> | |
| <td class="left received_amount"></td> | |
| </tr> | |
| <tr > | |
| <td class="left" height="20px">${transactionModel?.note?.contains("\n").let { | |
| if (it == true) transactionModel?.note?.replace("\n", "<br>") else transactionModel?.note | |
| }}</td> | |
| <td class="left received_amount"></td> | |
| </tr> | |
| """.trimIndent() | |
| } | |
| ${ | |
| if (termsAndConditionAndNotes.termsAndCondition?.isEmpty() != false) { | |
| """ | |
| <tr class="bottom-border-red top-border-red"> | |
| </tr> | |
| """.trimIndent() | |
| } else """ | |
| <tr> | |
| <td class="left" height = "20px"></td> | |
| <td class="left received_amount"></td> | |
| </tr> | |
| <tr> | |
| <td class="left" style="font-weight: bold;">Terms and Conditions</td> | |
| <td class="left received_amount"></td> | |
| </tr> | |
| <tr > | |
| <td class="left" height="20px">${ | |
| termsAndConditionAndNotes.termsAndCondition!!.contains("\n").let { | |
| if (it) termsAndConditionAndNotes.termsAndCondition!!.replace( | |
| "\n", | |
| "<br>" | |
| ) else termsAndConditionAndNotes.termsAndCondition | |
| } | |
| }</td> | |
| <td class="left received_amount"></td> | |
| </tr> | |
| """.trimIndent() | |
| } | |
| </tbody></table> | |
| </div> | |
| """.trimIndent() | |
| billDoc += "<div class=\"amount_specification\">\n" + " <table cellspacing=\"0\">\n" + " \n" + " <tbody><tr class=\"bold\">\n" + " <td class=\"center\"></td>\n" + " <td class=\"right\"></td>\n" + " </tr>\n" | |
| transactionModel?.let { | |
| if (it.extraCharges.taxableAmount != 0.0) { | |
| billDoc += " <tr>\n" + " <td class=\"left\">Extra Charges${if (it.extraCharges.gstRate > GstRate.TAX_EXEMPTED) " (excluding ${it.extraCharges.gstRate.rate}% GST)" else ""}</td>\n" + " <td class=\"right received_amount\">${MainActivity.currencySymbol} ${ | |
| "%.2f".format(it.extraCharges.taxableAmount) | |
| }</td>\n" + " </tr>\n" | |
| } | |
| } | |
| billDoc += " <tr>\n" + " <td class=\"left\">Taxable Amount</td>\n" + " <td class=\"right received_amount\">${MainActivity.currencySymbol} ${ | |
| "%.2f".format( | |
| amountSubtotal - gstSubtotal | |
| ) | |
| }</td>\n" + " </tr>\n" | |
| gstMap.forEach { | |
| billDoc += " <tr>\n" + " <td class=\"left\">CGST @ ${it.key.rate / 2}%</td>\n" + " <td class=\"right received_amount\">${MainActivity.currencySymbol} ${ | |
| "%.2f".format( | |
| it.value / 2 | |
| ) | |
| }</td>\n" + " </tr>\n" + " <tr>\n" + " <td class=\"left\">SGST @ ${it.key.rate / 2}%</td>\n" + " <td class=\"right received_amount\">${MainActivity.currencySymbol} ${ | |
| "%.2f".format( | |
| it.value / 2 | |
| ) | |
| }</td>\n" + " </tr>" | |
| } | |
| if (transactionModel?.discountAmount != 0.0) { | |
| billDoc += " <tr>\n" + " <td class=\"left\">Discount</td>\n" + " <td class=\"right received_amount\">- ${MainActivity.currencySymbol} ${ | |
| "%.2f".format(transactionModel?.discountAmount) | |
| }</td>\n" + " </tr>\n" | |
| } | |
| billDoc += """ | |
| <div> | |
| <table> | |
| <tbody> | |
| <tr class="bold vertical-border"> | |
| <td class="left">Total Amount</td> | |
| <td class="right total_amount">${MainActivity.currencySymbol} ${transactionModel?.totalAmount}</td> | |
| </tr> | |
| <tr> | |
| <td class="left">Received Amount</td> | |
| <td class="right received_amount">${MainActivity.currencySymbol} ${ | |
| (transactionModel?.totalAmount?.toDoubleOrNull() | |
| ?.minus((transactionModel?.dueAmount ?: 0.0)))?.toAmountString() | |
| }</td> | |
| </tr> | |
| <tr class="bold"> | |
| <td class="left">Due Balance</td> | |
| <td class="right due_balance">${MainActivity.currencySymbol} ${(transactionModel?.dueAmount ?: 0.0).toAmountString()}</td> | |
| </tr> | |
| ${if (true) "" else """ | |
| <tr> | |
| <td class="left">Previous Due Balance</td> | |
| <td class="right prev_due_balance">${'$'} 100</td> | |
| </tr> | |
| <tr> | |
| <td class="left">Current Due Balance</td> | |
| <td class="right curr_due_balance">${'$'} 450</td> | |
| </tr> | |
| """} | |
| """.trimIndent() | |
| /*if(isLatest){ | |
| billDoc += """ | |
| <tr class = "hz-line"> | |
| <td class = "left">Previous Balance</td> | |
| <td class = "right prev_balance">${MainActivity.currencySymbol}${previousBalance}</td> | |
| </tr> | |
| <tr> | |
| <td class = "left">Current Balance</td> | |
| <td class = "right current_balance">${MainActivity.currencySymbol}${currentBalance}</td> | |
| </tr> | |
| """.trimIndent() | |
| }*/ | |
| billDoc += "</tbody></table></div></div>" | |
| billDoc += """ | |
| <div class="signature_footer"> | |
| <div class="signature1"> | |
| ${ | |
| if (billSignature?.showForCustomer == true) { | |
| "<div class=\"signature_box\"></div>" + | |
| "<div class=\"signature_title\">Customer Signature</div>" | |
| } else { | |
| "" | |
| } | |
| } | |
| </div> | |
| <div class="signature2"> | |
| <div class="img_deg"> | |
| ${ | |
| if (billSignature.showForBusiness) { | |
| if (billSignature.signatureImage != null && billSignature.signatureImage != "") { | |
| "<div class=\"right\">\n" + | |
| "<div class=\"img_deg\">\n" + | |
| "<img src=\"" + billSignature.signatureImage + "\" class=\"img_deg\" style=\"width: 100%; height: 70px; object-fit: contain; text-align: right;\"/>" + | |
| "<div class=\"signature_title\"> </div>\n" + | |
| "<div class=\"signature_title\">Authorised Signatory For</div>\n" + | |
| "<div class=\"signature_title\">" + storeName + "</div>\n" + | |
| "<div class=\"signature_title thank_title\">\n" + | |
| " Thank You For Your Business !\n" + | |
| "</div>" + | |
| "</div>" + | |
| "</div>"; | |
| } else { | |
| "<div class=\"signature2\">\n" + | |
| "<div class=\"img_deg\">\n" | |
| "<div class=\"signature_box\"></div>" + | |
| "<br>" + | |
| "<div class=\"signature_title\">Authorised Signatory For</div>\n" + | |
| "<div class=\"signature_title\">" + storeName + "</div>\n" + | |
| "<div class=\"signature_title thank_title\">\n" + | |
| " Thank You For Your Business !\n" + | |
| "</div>" + | |
| "</div>" + | |
| "</div>"; | |
| } | |
| } else { | |
| "<div class=\"signature_title thank_title\">\n" + | |
| " Thank You For Your Business !\n" + | |
| "</div>"; | |
| } | |
| } | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| """.trimIndent() | |
| billDoc += "</body></html>" | |
| if (isRegularSelected) { | |
| binding.pdfWebView.apply { | |
| loadDataWithBaseURL(null, billDoc, "text/HTML", "UTF-8", null) | |
| visibility = View.VISIBLE | |
| } | |
| binding.loadingBar.visibility = View.GONE | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment