add vendor address list

This commit is contained in:
gowthaman 2024-04-29 22:43:34 +05:30
parent 4d7f5ccdfb
commit ae11f05aba
4 changed files with 46 additions and 7 deletions

View File

@ -431,7 +431,17 @@ fun exportInvoices(invoices: List<Invoice>) {
val sh = wb.createSheet() val sh = wb.createSheet()
val headers: List<String> = listOf( val headers: List<String> = listOf(
"Number", "Date", "Reference PO", "Status", "Vendor Name", "Vendor Address", "Product Id", "Product Name", "Unit Price", "Quantity", "Total Amount" "Number",
"Date",
"Reference PO",
"Status",
"Vendor Name",
"Vendor Address",
"Product Id",
"Product Name",
"Unit Price",
"Quantity",
"Total Amount"
) )
createHeaderRow(headers, sh, wb) createHeaderRow(headers, sh, wb)
@ -571,7 +581,7 @@ fun ImportFromExcel(fileType: FileType, filePath: String) {
FileType.POS -> { FileType.POS -> {
//poNum, poDate, validTill, refQuoteNum, prodName, prodQuantity, totalAmount, products, vendorName, vendorGst, vendorAddress, tnc[]. docs[] //poNum, poDate, validTill, refQuoteNum, prodName, prodQuantity, totalAmount, products, vendorName, vendorGst, vendorAddress, tnc[]. docs[]
val PoMap: MutableMap<String, PurchaseOrder> = mutableMapOf() val poMap: MutableMap<String, PurchaseOrder> = mutableMapOf()
sh.rowIterator().forEach { row -> sh.rowIterator().forEach { row ->
if (row == null) return@forEach if (row == null) return@forEach
val poNum = stringFromCellHelper(row.getCell(0)) val poNum = stringFromCellHelper(row.getCell(0))
@ -586,10 +596,21 @@ fun ImportFromExcel(fileType: FileType, filePath: String) {
val totalPoAmount = doubleFromCellHelper(row.getCell(9)) val totalPoAmount = doubleFromCellHelper(row.getCell(9))
//tncs, docs //tncs, docs
val prod = POProducts("", prodName, 0.0, prodQuantity, "") val prod = POProducts(
if (PoMap.containsKey(poNum)) { productId = "",
productName = prodName,
unitPrice = 0.0,
quantity = prodQuantity,
billQty = prodQuantity,
gstPct = 0.0,
taxableValue = 0.0,
totalValue = 0.0,
description = "",
uom = ""
)
if (poMap.containsKey(poNum)) {
//repeated row //repeated row
PoMap.get(poNum)?.products?.add(prod) poMap.get(poNum)?.products?.add(prod)
} else { } else {
val vendor = Vendor() val vendor = Vendor()
vendor.name = vendorName vendor.name = vendorName
@ -600,7 +621,7 @@ fun ImportFromExcel(fileType: FileType, filePath: String) {
po.poDate = poDate po.poDate = poDate
po.referenceQuotation = refQuoteNum po.referenceQuotation = refQuoteNum
po.validTill = poValidTill po.validTill = poValidTill
PoMap.put(poNum, po) poMap[poNum] = po
} }
} }
} }

View File

@ -251,8 +251,13 @@ class SafeStringDeserializer : JsonDeserializer<String>() {
} }
} }
enum class AddressType {
BILLING, SHIPPING
}
data class ContactPerson(val name: String = "", val email: String = "", val mobile: String = "") data class ContactPerson(val name: String = "", val email: String = "", val mobile: String = "")
data class Address(val type: AddressType = AddressType.BILLING,
val address: String = "",
val pincode: String = "")
@Entity @Entity
open class Vendor : BaseTenantModel() { open class Vendor : BaseTenantModel() {
fun patchValues(updatedVendor: Vendor) { fun patchValues(updatedVendor: Vendor) {
@ -264,6 +269,7 @@ open class Vendor : BaseTenantModel() {
this.contacts = updatedVendor.contacts this.contacts = updatedVendor.contacts
this.outstanding = updatedVendor.outstanding this.outstanding = updatedVendor.outstanding
this.asOnWhichDate = updatedVendor.asOnWhichDate this.asOnWhichDate = updatedVendor.asOnWhichDate
this.addressList = updatedVendor.addressList
} }
var name: String = "" var name: String = ""
@ -274,6 +280,8 @@ open class Vendor : BaseTenantModel() {
var outstanding: Double? = 0.0 var outstanding: Double? = 0.0
var asOnWhichDate: LocalDate? = null var asOnWhichDate: LocalDate? = null
@DbJsonB
var addressList: List<Address>? = mutableListOf()
@DbJsonB @DbJsonB
var contacts: List<ContactPerson> = mutableListOf() var contacts: List<ContactPerson> = mutableListOf()

View File

@ -0,0 +1,2 @@
-- apply alter tables
alter table vendor add column if not exists address_list jsonb;

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<migration xmlns="http://ebean-orm.github.io/xml/ns/dbmigration">
<changeSet type="apply">
<addColumn tableName="vendor">
<column name="address_list" type="jsonb"/>
</addColumn>
</changeSet>
</migration>