|
@@ -344,7 +344,8 @@ open class InvoiceService( |
|
|
|
|
|
|
|
|
// For checking mandatory field in each row |
|
|
// For checking mandatory field in each row |
|
|
val emptyRowList: MutableList<Int> = mutableListOf() |
|
|
val emptyRowList: MutableList<Int> = mutableListOf() |
|
|
val mandatoryColumns = listOf(0,1,4,5,10,11,12) // Mandatory Field in column 0,1,4,5,10,11,12 |
|
|
|
|
|
|
|
|
// Beria cannot provide Payment Milestone when importing the invoice, so it cannot be checked and import to DB |
|
|
|
|
|
val mandatoryColumns = listOf(0,1,10,11,12) // Mandatory Field in column 0,1,10,11,12 |
|
|
|
|
|
|
|
|
if (workbook == null) { |
|
|
if (workbook == null) { |
|
|
return InvoiceResponse(false, "No Excel import", newProjectCodes, emptyRowList, invoicesResult, ArrayList(), ArrayList()) // if workbook is null |
|
|
return InvoiceResponse(false, "No Excel import", newProjectCodes, emptyRowList, invoicesResult, ArrayList(), ArrayList()) // if workbook is null |
|
@@ -373,15 +374,14 @@ open class InvoiceService( |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (newProjectCodes.size == 0){ |
|
|
|
|
|
val milestonepaymentWithCode = getMilestonePaymentWithProjectCode(projectsCodes) |
|
|
|
|
|
// println("newProjectCodes == 0") |
|
|
|
|
|
// println(checkMilestonePayment(sheet, 2, 5, 0, 1, milestonepaymentWithCode)) |
|
|
|
|
|
val paymenMilestones = checkMilestonePaymentByStageAndDescription(sheet, 2, 4,5, 0, 1, milestonepaymentWithCode) |
|
|
|
|
|
if (paymenMilestones.isNotEmpty()){ |
|
|
|
|
|
return InvoiceResponse(false, "Imported Invoice's format is incorrect", newProjectCodes, emptyRowList, invoicesResult, duplicateItemsInInvoice, paymenMilestones) |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
// Beria cannot provide Payment Milestone when importing the invoice, so it cannot be checked and import to DB |
|
|
|
|
|
// if (newProjectCodes.size == 0){ |
|
|
|
|
|
// val milestonepaymentWithCode = getMilestonePaymentWithProjectCode(projectsCodes) |
|
|
|
|
|
// val paymenMilestones = checkMilestonePaymentByStageAndDescription(sheet, 2, 4,5, 0, 1, milestonepaymentWithCode) |
|
|
|
|
|
// if (paymenMilestones.isNotEmpty()){ |
|
|
|
|
|
// return InvoiceResponse(false, "Imported Invoice's format is incorrect", newProjectCodes, emptyRowList, invoicesResult, duplicateItemsInInvoice, paymenMilestones) |
|
|
|
|
|
// } |
|
|
|
|
|
// } |
|
|
|
|
|
|
|
|
if (invoicesResult.size >= 1 || |
|
|
if (invoicesResult.size >= 1 || |
|
|
newProjectCodes.size >= 1 || |
|
|
newProjectCodes.size >= 1 || |
|
@@ -394,9 +394,9 @@ open class InvoiceService( |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
for (i in 2..sheet.lastRowNum){ |
|
|
for (i in 2..sheet.lastRowNum){ |
|
|
val paymentMilestoneId = getMilestonePaymentId(ExcelUtils.getCell(sheet, i, 1).stringCellValue, ExcelUtils.getCell(sheet, i, 5).stringCellValue) |
|
|
|
|
|
// println("paymentMilestoneId--------------: $paymentMilestoneId") |
|
|
|
|
|
val milestonePayment = milestonePaymentRepository.findById(paymentMilestoneId).orElseThrow() |
|
|
|
|
|
|
|
|
// Beria cannot provide Payment Milestone when importing the invoice, so it cannot be checked and import to DB |
|
|
|
|
|
// val paymentMilestoneId = getMilestonePaymentId(ExcelUtils.getCell(sheet, i, 1).stringCellValue, ExcelUtils.getCell(sheet, i, 5).stringCellValue) |
|
|
|
|
|
// val milestonePayment = milestonePaymentRepository.findById(paymentMilestoneId).orElseThrow() |
|
|
val invoice = Invoice().apply { |
|
|
val invoice = Invoice().apply { |
|
|
invoiceNo = ExcelUtils.getCell(sheet, i, 0).stringCellValue |
|
|
invoiceNo = ExcelUtils.getCell(sheet, i, 0).stringCellValue |
|
|
projectCode = ExcelUtils.getCell(sheet, i, 1).stringCellValue |
|
|
projectCode = ExcelUtils.getCell(sheet, i, 1).stringCellValue |
|
@@ -411,7 +411,8 @@ open class InvoiceService( |
|
|
invoiceDate = ExcelUtils.getCell(sheet, i, 10).dateCellValue.toInstant().atZone(ZoneId.systemDefault()).toLocalDate() |
|
|
invoiceDate = ExcelUtils.getCell(sheet, i, 10).dateCellValue.toInstant().atZone(ZoneId.systemDefault()).toLocalDate() |
|
|
dueDate = ExcelUtils.getCell(sheet, i, 11).dateCellValue.toInstant().atZone(ZoneId.systemDefault()).toLocalDate() |
|
|
dueDate = ExcelUtils.getCell(sheet, i, 11).dateCellValue.toInstant().atZone(ZoneId.systemDefault()).toLocalDate() |
|
|
issueAmount = ExcelUtils.getCell(sheet, i, 12).numericCellValue.toBigDecimal() |
|
|
issueAmount = ExcelUtils.getCell(sheet, i, 12).numericCellValue.toBigDecimal() |
|
|
this.milestonePayment = milestonePayment |
|
|
|
|
|
|
|
|
// Beria cannot provide Payment Milestone when importing the invoice, so it cannot be checked and import to DB |
|
|
|
|
|
// this.milestonePayment = milestonePayment |
|
|
} |
|
|
} |
|
|
saveAndFlush(invoice) |
|
|
saveAndFlush(invoice) |
|
|
} |
|
|
} |
|
|