| Line 472... |
Line 472... |
| 472 |
|
472 |
|
| 473 |
} else {
|
473 |
} else {
|
| 474 |
documentNumber = this.getInvoiceNumber(fofoId, fofoStoreCode);
|
474 |
documentNumber = this.getInvoiceNumber(fofoId, fofoStoreCode);
|
| 475 |
}
|
475 |
}
|
| 476 |
|
476 |
|
| - |
|
477 |
CustomerAddress customerAddress = null;
|
| - |
|
478 |
if (customCustomer.getCustomerAddressId() != 0) {
|
| 477 |
CustomerAddress customerAddress = customer.getCustomerAddress().stream().filter(x -> x.getId() == customCustomer.getCustomerAddressId()).findFirst().get();
|
479 |
customerAddress = customer.getCustomerAddress().stream().filter(x -> x.getId() == customCustomer.getCustomerAddressId()).findFirst().get();
|
| 478 |
|
480 |
}
|
| 479 |
FofoOrder fofoOrder = this.createAndGetFofoOrder(customer.getId(), customCustomer.getGstNumber(), fofoId, documentNumber, totalAmount, customerAddress.getId());
|
481 |
FofoOrder fofoOrder = this.createAndGetFofoOrder(customer.getId(), customCustomer.getGstNumber(), fofoId, documentNumber, totalAmount, customCustomer.getCustomerAddressId());
|
| 480 |
|
482 |
|
| 481 |
this.createPaymentOptions(fofoOrder, createOrderRequest.getPaymentOptions());
|
483 |
this.createPaymentOptions(fofoOrder, createOrderRequest.getPaymentOptions());
|
| 482 |
|
484 |
|
| 483 |
int retailerAddressId = retailerRegisteredAddressRepository.selectAddressIdByRetailerId(fofoId);
|
485 |
int retailerAddressId = retailerRegisteredAddressRepository.selectAddressIdByRetailerId(fofoId);
|
| 484 |
|
486 |
|
| 485 |
Address retailerAddress = addressRepository.selectById(retailerAddressId);
|
487 |
Address retailerAddress = addressRepository.selectById(retailerAddressId);
|
| 486 |
|
488 |
|
| 487 |
Integer stateId = null;
|
489 |
Integer stateId = null;
|
| 488 |
if (customerAddress.getState().equals(retailerAddress.getState())) {
|
490 |
if (customerAddress != null && customerAddress.getState() != null && customerAddress.getState().equals(retailerAddress.getState())) {
|
| 489 |
try {
|
491 |
try {
|
| 490 |
State state = stateRepository.selectByName(customerAddress.getState());
|
492 |
State state = stateRepository.selectByName(customerAddress.getState());
|
| 491 |
stateId = Long.valueOf(state.getId()).intValue();
|
493 |
stateId = Long.valueOf(state.getId()).intValue();
|
| 492 |
} catch (Exception e) {
|
494 |
} catch (Exception e) {
|
| 493 |
LOGGER.error("Unable to get state rates");
|
495 |
LOGGER.error("Unable to get state rates");
|
| Line 1010... |
Line 1012... |
| 1010 |
customFofoOrderItem.setSgstAmount(sgstAmount);
|
1012 |
customFofoOrderItem.setSgstAmount(sgstAmount);
|
| 1011 |
customFofoOrderItem.setHsnCode(fofoOrderItem.getHsnCode());
|
1013 |
customFofoOrderItem.setHsnCode(fofoOrderItem.getHsnCode());
|
| 1012 |
customerFofoOrderItems.add(customFofoOrderItem);
|
1014 |
customerFofoOrderItems.add(customFofoOrderItem);
|
| 1013 |
}
|
1015 |
}
|
| 1014 |
pdfModel.setOrderItems(customerFofoOrderItems);
|
1016 |
pdfModel.setOrderItems(customerFofoOrderItems);
|
| - |
|
1017 |
String customerAddressStateCode = "";
|
| - |
|
1018 |
LOGGER.error("pdfModel.getCustomer().getAddress().getState() {}", pdfModel.getCustomer().getAddress().getState());
|
| - |
|
1019 |
LOGGER.error("pdfModel.getCustomer {}", pdfModel.getCustomer());
|
| 1015 |
String partnerAddressStateCode = stateRepository.selectByName(pdfModel.getRetailer().getAddress().getState()).getCode();
|
1020 |
String partnerAddressStateCode = stateRepository.selectByName(pdfModel.getRetailer().getAddress().getState()).getCode();
|
| - |
|
1021 |
if (pdfModel.getCustomer() != null && pdfModel.getCustomer().getAddress() != null &&
|
| - |
|
1022 |
pdfModel.getCustomer().getAddress().getState() != null &&
|
| - |
|
1023 |
!pdfModel.getCustomer().getAddress().getState().trim().isEmpty()) {
|
| 1016 |
String customerAddressStateCode = stateRepository.selectByName(pdfModel.getCustomer().getAddress().getState()).getCode();
|
1024 |
customerAddressStateCode = stateRepository.selectByName(pdfModel.getCustomer().getAddress().getState()).getCode();
|
| - |
|
1025 |
}
|
| - |
|
1026 |
|
| 1017 |
pdfModel.setPartnerAddressStateCode(partnerAddressStateCode);
|
1027 |
pdfModel.setPartnerAddressStateCode(partnerAddressStateCode);
|
| - |
|
1028 |
if (!customerAddressStateCode.equals("")) {
|
| 1018 |
pdfModel.setCustomerAddressStateCode(customerAddressStateCode);
|
1029 |
pdfModel.setCustomerAddressStateCode(customerAddressStateCode);
|
| - |
|
1030 |
}
|
| 1019 |
pdfModel.setCancelled(fofoOrder.getCancelledTimestamp() != null);
|
1031 |
pdfModel.setCancelled(fofoOrder.getCancelledTimestamp() != null);
|
| 1020 |
List<String> tncs = new ArrayList<>();
|
1032 |
List<String> tncs = new ArrayList<>();
|
| 1021 |
tncs.add("I agree that goods received are in good working condition");
|
1033 |
tncs.add("I agree that goods received are in good working condition");
|
| 1022 |
tncs.add("Goods once sold cannot be exchanged or taken back");
|
1034 |
tncs.add("Goods once sold cannot be exchanged or taken back");
|
| 1023 |
tncs.add("Warranty for the goods received by me is the responsibility of the manufacturer only.");
|
1035 |
tncs.add("Warranty for the goods received by me is the responsibility of the manufacturer only.");
|
| Line 1041... |
Line 1053... |
| 1041 |
customCustomer.setFirstName(customer.getFirstName());
|
1053 |
customCustomer.setFirstName(customer.getFirstName());
|
| 1042 |
customCustomer.setLastName(customer.getLastName());
|
1054 |
customCustomer.setLastName(customer.getLastName());
|
| 1043 |
customCustomer.setEmailId(customer.getEmailId());
|
1055 |
customCustomer.setEmailId(customer.getEmailId());
|
| 1044 |
customCustomer.setMobileNumber(customer.getMobileNumber());
|
1056 |
customCustomer.setMobileNumber(customer.getMobileNumber());
|
| 1045 |
customCustomer.setGstNumber(fofoOrder.getCustomerGstNumber());
|
1057 |
customCustomer.setGstNumber(fofoOrder.getCustomerGstNumber());
|
| - |
|
1058 |
if (fofoOrder.getCustomerAddressId() != 0) {
|
| 1046 |
CustomerAddress customerAddress = customerAddressRepository.selectById(fofoOrder.getCustomerAddressId());
|
1059 |
CustomerAddress customerAddress = customerAddressRepository.selectById(fofoOrder.getCustomerAddressId());
|
| 1047 |
customCustomer.setAddress(this.createCustomAddress(customerAddress));
|
1060 |
customCustomer.setAddress(this.createCustomAddress(customerAddress));
|
| - |
|
1061 |
} else {
|
| - |
|
1062 |
customCustomer.setAddress(this.createCustomAddressWithoutId(customCustomer));
|
| - |
|
1063 |
}
|
| 1048 |
return customCustomer;
|
1064 |
return customCustomer;
|
| - |
|
1065 |
|
| 1049 |
}
|
1066 |
}
|
| 1050 |
|
1067 |
|
| 1051 |
@Override
|
1068 |
@Override
|
| 1052 |
public InvoicePdfModel getInvoicePdfModel(int fofoId, int orderId) throws ProfitMandiBusinessException {
|
1069 |
public InvoicePdfModel getInvoicePdfModel(int fofoId, int orderId) throws ProfitMandiBusinessException {
|
| 1053 |
FofoOrder fofoOrder = fofoOrderRepository.selectByFofoIdAndOrderId(fofoId, orderId);
|
1070 |
FofoOrder fofoOrder = fofoOrderRepository.selectByFofoIdAndOrderId(fofoId, orderId);
|
| Line 1399... |
Line 1416... |
| 1399 |
|
1416 |
|
| 1400 |
private void createPaymentOptions(FofoOrder fofoOrder, Set<CustomPaymentOption> customPaymentOptions) throws ProfitMandiBusinessException {
|
1417 |
private void createPaymentOptions(FofoOrder fofoOrder, Set<CustomPaymentOption> customPaymentOptions) throws ProfitMandiBusinessException {
|
| 1401 |
for (CustomPaymentOption customPaymentOption : customPaymentOptions) {
|
1418 |
for (CustomPaymentOption customPaymentOption : customPaymentOptions) {
|
| 1402 |
if (customPaymentOption.getAmount() > 0) {
|
1419 |
if (customPaymentOption.getAmount() > 0) {
|
| 1403 |
PaymentOptionTransaction paymentOptionTransaction = new PaymentOptionTransaction();
|
1420 |
PaymentOptionTransaction paymentOptionTransaction = new PaymentOptionTransaction();
|
| - |
|
1421 |
LOGGER.error("error", fofoOrder.getId());
|
| 1404 |
paymentOptionTransaction.setReferenceId(fofoOrder.getId());
|
1422 |
paymentOptionTransaction.setReferenceId(fofoOrder.getId());
|
| 1405 |
paymentOptionTransaction.setPaymentOptionId(customPaymentOption.getPaymentOptionId());
|
1423 |
paymentOptionTransaction.setPaymentOptionId(customPaymentOption.getPaymentOptionId());
|
| 1406 |
paymentOptionTransaction.setReferenceType(PaymentOptionReferenceType.ORDER);
|
1424 |
paymentOptionTransaction.setReferenceType(PaymentOptionReferenceType.ORDER);
|
| 1407 |
paymentOptionTransaction.setAmount(customPaymentOption.getAmount());
|
1425 |
paymentOptionTransaction.setAmount(customPaymentOption.getAmount());
|
| 1408 |
paymentOptionTransaction.setFofoId(fofoOrder.getFofoId());
|
1426 |
paymentOptionTransaction.setFofoId(fofoOrder.getFofoId());
|
| Line 1551... |
Line 1569... |
| 1551 |
customAddress.setCountry(customerAddress.getCountry());
|
1569 |
customAddress.setCountry(customerAddress.getCountry());
|
| 1552 |
customAddress.setPhoneNumber(customerAddress.getPhoneNumber());
|
1570 |
customAddress.setPhoneNumber(customerAddress.getPhoneNumber());
|
| 1553 |
return customAddress;
|
1571 |
return customAddress;
|
| 1554 |
}
|
1572 |
}
|
| 1555 |
|
1573 |
|
| - |
|
1574 |
private CustomAddress createCustomAddressWithoutId(CustomCustomer customerAddress) {
|
| - |
|
1575 |
CustomAddress customAddress = new CustomAddress();
|
| - |
|
1576 |
customAddress.setName(customerAddress.getFirstName());
|
| - |
|
1577 |
customAddress.setLastName(customerAddress.getLastName());
|
| - |
|
1578 |
customAddress.setLine1("");
|
| - |
|
1579 |
customAddress.setLine2("");
|
| - |
|
1580 |
customAddress.setLandmark("");
|
| - |
|
1581 |
customAddress.setCity("");
|
| - |
|
1582 |
customAddress.setPinCode("");
|
| - |
|
1583 |
customAddress.setState("");
|
| - |
|
1584 |
customAddress.setCountry("");
|
| - |
|
1585 |
customAddress.setPhoneNumber(customerAddress.getMobileNumber());
|
| - |
|
1586 |
return customAddress;
|
| - |
|
1587 |
}
|
| - |
|
1588 |
|
| 1556 |
private void validatePaymentOptionsAndTotalAmount(Set<CustomPaymentOption> customPaymentOptions, float totalAmount) throws ProfitMandiBusinessException {
|
1589 |
private void validatePaymentOptionsAndTotalAmount(Set<CustomPaymentOption> customPaymentOptions, float totalAmount) throws ProfitMandiBusinessException {
|
| 1557 |
Set<Integer> paymentOptionIds = new HashSet<>();
|
1590 |
Set<Integer> paymentOptionIds = new HashSet<>();
|
| 1558 |
|
1591 |
|
| 1559 |
float calculatedAmount = 0;
|
1592 |
float calculatedAmount = 0;
|
| 1560 |
for (CustomPaymentOption customPaymentOption : customPaymentOptions) {
|
1593 |
for (CustomPaymentOption customPaymentOption : customPaymentOptions) {
|
| Line 1630... |
Line 1663... |
| 1630 |
if (!customerAddress.getState().equalsIgnoreCase(customCustomer.getAddress().getState())) {
|
1663 |
if (!customerAddress.getState().equalsIgnoreCase(customCustomer.getAddress().getState())) {
|
| 1631 |
List<FofoOrderItem> fofoOrderItems = fofoOrderItemRepository.selectByOrderId(fofoOrder.getId());
|
1664 |
List<FofoOrderItem> fofoOrderItems = fofoOrderItemRepository.selectByOrderId(fofoOrder.getId());
|
| 1632 |
resetTaxation(fofoOrder.getFofoId(), customerAddress, fofoOrderItems);
|
1665 |
resetTaxation(fofoOrder.getFofoId(), customerAddress, fofoOrderItems);
|
| 1633 |
}
|
1666 |
}
|
| 1634 |
this.setCustomerAddress(customerAddress, customCustomer.getAddress());
|
1667 |
this.setCustomerAddress(customerAddress, customCustomer.getAddress());
|
| 1635 |
customerAddressRepository.persist(customerAddress);
|
- |
|
| 1636 |
fofoOrder.setCustomerGstNumber(customCustomer.getGstNumber());
|
1668 |
fofoOrder.setCustomerGstNumber(customCustomer.getGstNumber());
|
| 1637 |
}
|
1669 |
}
|
| 1638 |
|
1670 |
|
| 1639 |
private void resetTaxation(int fofoId, CustomerAddress customerAddress, List<FofoOrderItem> fofoOrderItems) throws ProfitMandiBusinessException {
|
1671 |
private void resetTaxation(int fofoId, CustomerAddress customerAddress, List<FofoOrderItem> fofoOrderItems) throws ProfitMandiBusinessException {
|
| 1640 |
int retailerAddressId = retailerRegisteredAddressRepository.selectAddressIdByRetailerId(fofoId);
|
1672 |
int retailerAddressId = retailerRegisteredAddressRepository.selectAddressIdByRetailerId(fofoId);
|