diff --git a/src/main/kotlin/com/restapi/controllers/Excel.kt b/src/main/kotlin/com/restapi/controllers/Excel.kt index 4f65feb..fb4698d 100644 --- a/src/main/kotlin/com/restapi/controllers/Excel.kt +++ b/src/main/kotlin/com/restapi/controllers/Excel.kt @@ -431,7 +431,17 @@ fun exportInvoices(invoices: List) { val sh = wb.createSheet() val headers: List = 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) @@ -571,7 +581,7 @@ fun ImportFromExcel(fileType: FileType, filePath: String) { FileType.POS -> { //poNum, poDate, validTill, refQuoteNum, prodName, prodQuantity, totalAmount, products, vendorName, vendorGst, vendorAddress, tnc[]. docs[] - val PoMap: MutableMap = mutableMapOf() + val poMap: MutableMap = mutableMapOf() sh.rowIterator().forEach { row -> if (row == null) return@forEach val poNum = stringFromCellHelper(row.getCell(0)) @@ -586,10 +596,21 @@ fun ImportFromExcel(fileType: FileType, filePath: String) { val totalPoAmount = doubleFromCellHelper(row.getCell(9)) //tncs, docs - val prod = POProducts("", prodName, 0.0, prodQuantity, "") - if (PoMap.containsKey(poNum)) { + val prod = POProducts( + 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 - PoMap.get(poNum)?.products?.add(prod) + poMap.get(poNum)?.products?.add(prod) } else { val vendor = Vendor() vendor.name = vendorName @@ -600,7 +621,7 @@ fun ImportFromExcel(fileType: FileType, filePath: String) { po.poDate = poDate po.referenceQuotation = refQuoteNum po.validTill = poValidTill - PoMap.put(poNum, po) + poMap[poNum] = po } } } diff --git a/src/main/kotlin/com/restapi/domain/models.kt b/src/main/kotlin/com/restapi/domain/models.kt index 264214b..ff6b210 100644 --- a/src/main/kotlin/com/restapi/domain/models.kt +++ b/src/main/kotlin/com/restapi/domain/models.kt @@ -251,8 +251,13 @@ class SafeStringDeserializer : JsonDeserializer() { } } +enum class AddressType { + BILLING, SHIPPING +} 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 open class Vendor : BaseTenantModel() { fun patchValues(updatedVendor: Vendor) { @@ -264,6 +269,7 @@ open class Vendor : BaseTenantModel() { this.contacts = updatedVendor.contacts this.outstanding = updatedVendor.outstanding this.asOnWhichDate = updatedVendor.asOnWhichDate + this.addressList = updatedVendor.addressList } var name: String = "" @@ -274,6 +280,8 @@ open class Vendor : BaseTenantModel() { var outstanding: Double? = 0.0 var asOnWhichDate: LocalDate? = null + @DbJsonB + var addressList: List
? = mutableListOf() @DbJsonB var contacts: List = mutableListOf() diff --git a/src/main/resources/dbmigration/1.27.sql b/src/main/resources/dbmigration/1.27.sql new file mode 100644 index 0000000..b3c537f --- /dev/null +++ b/src/main/resources/dbmigration/1.27.sql @@ -0,0 +1,2 @@ +-- apply alter tables +alter table vendor add column if not exists address_list jsonb; diff --git a/src/main/resources/dbmigration/model/1.27.model.xml b/src/main/resources/dbmigration/model/1.27.model.xml new file mode 100644 index 0000000..8d4ff8b --- /dev/null +++ b/src/main/resources/dbmigration/model/1.27.model.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file