| Line 2200... |
Line 2200... |
| 2200 |
result.append("Failed: ").append(failedCount).append(" tickets\n");
|
2200 |
result.append("Failed: ").append(failedCount).append(" tickets\n");
|
| 2201 |
LOGGER.info("Completed resolveOldEscalationTickets migration. Resolved {} tickets, Failed {} tickets.", resolvedCount, failedCount);
|
2201 |
LOGGER.info("Completed resolveOldEscalationTickets migration. Resolved {} tickets, Failed {} tickets.", resolvedCount, failedCount);
|
| 2202 |
|
2202 |
|
| 2203 |
return result.toString();
|
2203 |
return result.toString();
|
| 2204 |
}
|
2204 |
}
|
| - |
|
2205 |
|
| - |
|
2206 |
public void postCreditNoteForDuplicateInvoice(String duplicateInvoice, String activeInvoice) throws Exception {
|
| - |
|
2207 |
List<Order> orders = orderRepository.selectByInvoiceNumber(activeInvoice);
|
| - |
|
2208 |
if (orders.isEmpty()) throw new RuntimeException("No orders found for " + activeInvoice);
|
| - |
|
2209 |
|
| - |
|
2210 |
Order firstOrder = orders.get(0);
|
| - |
|
2211 |
SellerWarehouse sellerWarehouse = sellerWarehouseRepository.selectByWarehouseIdAndSellerId(
|
| - |
|
2212 |
firstOrder.getWarehouseId(), firstOrder.getSellerId());
|
| - |
|
2213 |
|
| - |
|
2214 |
sellerWarehouse.setCreditNoteSequence(sellerWarehouse.getCreditNoteSequence() + 1);
|
| - |
|
2215 |
String cnNumber = "CN-" + sellerWarehouse.getPrefix() + sellerWarehouse.getCreditNoteSequence();
|
| - |
|
2216 |
|
| - |
|
2217 |
InvoicePdfModel invoicePdfModel = invoiceService.getInvoicePdfModelForIrn(orders);
|
| - |
|
2218 |
|
| - |
|
2219 |
String billingDateStr = com.spice.profitmandi.common.util.StringUtils.toString(firstOrder.getBillingTimestamp().toLocalDate());
|
| - |
|
2220 |
List<String[]> invoiceRefs = java.util.Collections.singletonList(
|
| - |
|
2221 |
new String[]{duplicateInvoice, billingDateStr});
|
| - |
|
2222 |
|
| - |
|
2223 |
String sellerGstin = "09AACCN9802G2ZC";
|
| - |
|
2224 |
String reason = "Credit Note against duplicate invoice " + duplicateInvoice;
|
| - |
|
2225 |
|
| - |
|
2226 |
com.spice.profitmandi.dao.entity.transaction.CreditNote creditNote = new com.spice.profitmandi.dao.entity.transaction.CreditNote();
|
| - |
|
2227 |
creditNote.setCreditNoteNumber(cnNumber);
|
| - |
|
2228 |
creditNote.setFofoId(firstOrder.getRetailerId());
|
| - |
|
2229 |
creditNote.setCnDate(java.time.LocalDate.now().atTime(com.spice.profitmandi.common.util.Utils.MAX_TIME));
|
| - |
|
2230 |
creditNote.setType(com.spice.profitmandi.dao.entity.transaction.CreditNoteType.RETURNS);
|
| - |
|
2231 |
creditNote.setOriginalInvoiceNumber(duplicateInvoice);
|
| - |
|
2232 |
creditNote.setCreateTimestamp(java.time.LocalDateTime.now());
|
| - |
|
2233 |
creditNoteRepository.persist(creditNote);
|
| - |
|
2234 |
|
| - |
|
2235 |
for (Order order : orders) {
|
| - |
|
2236 |
com.spice.profitmandi.dao.entity.transaction.CreditNoteLine cnLine = new com.spice.profitmandi.dao.entity.transaction.CreditNoteLine();
|
| - |
|
2237 |
cnLine.setCreditNoteId(creditNote.getId());
|
| - |
|
2238 |
cnLine.setDescription(order.getLineItem().getItem().getItemDescription());
|
| - |
|
2239 |
cnLine.setQuantity(order.getLineItem().getQuantity());
|
| - |
|
2240 |
cnLine.setUnitPrice(order.getLineItem().getUnitPrice());
|
| - |
|
2241 |
cnLine.setAmount(order.getLineItem().getUnitPrice() * order.getLineItem().getQuantity());
|
| - |
|
2242 |
cnLine.setCgst(order.getLineItem().getCgstRate());
|
| - |
|
2243 |
cnLine.setSgst(order.getLineItem().getSgstRate());
|
| - |
|
2244 |
cnLine.setIgst(order.getLineItem().getIgstRate());
|
| - |
|
2245 |
cnLine.setHsnCode(order.getLineItem().getHsnCode());
|
| - |
|
2246 |
creditNoteLineRepository.persist(cnLine);
|
| - |
|
2247 |
}
|
| - |
|
2248 |
|
| - |
|
2249 |
LOGGER.info("Credit Note {} created against duplicate invoice {}", cnNumber, duplicateInvoice);
|
| - |
|
2250 |
|
| - |
|
2251 |
gstProService.generateCreditNoteIrn(cnNumber, java.time.LocalDate.now(), invoicePdfModel, invoiceRefs, sellerGstin, reason);
|
| - |
|
2252 |
LOGGER.info("Credit Note IRN posted to NIC: CN={} against {}", cnNumber, duplicateInvoice);
|
| - |
|
2253 |
}
|
| 2205 |
}
|
2254 |
}
|
| 2206 |
|
2255 |
|
| 2207 |
//7015845171
|
2256 |
//7015845171
|
| 2208 |
|
2257 |
|