| Line 64... |
Line 64... |
| 64 |
import com.spice.profitmandi.dao.entity.fofo.InventoryItem;
|
64 |
import com.spice.profitmandi.dao.entity.fofo.InventoryItem;
|
| 65 |
import com.spice.profitmandi.dao.entity.fofo.InvoiceNumberGenerationSequence;
|
65 |
import com.spice.profitmandi.dao.entity.fofo.InvoiceNumberGenerationSequence;
|
| 66 |
import com.spice.profitmandi.dao.entity.fofo.PrebookingListing;
|
66 |
import com.spice.profitmandi.dao.entity.fofo.PrebookingListing;
|
| 67 |
import com.spice.profitmandi.dao.entity.fofo.PrebookingOrder;
|
67 |
import com.spice.profitmandi.dao.entity.fofo.PrebookingOrder;
|
| 68 |
import com.spice.profitmandi.dao.entity.fofo.PrebookingOrderItem;
|
68 |
import com.spice.profitmandi.dao.entity.fofo.PrebookingOrderItem;
|
| 69 |
import com.spice.profitmandi.dao.entity.fofo.PurchaseReturnItem;
|
- |
|
| 70 |
import com.spice.profitmandi.dao.entity.fofo.ScanRecord;
|
69 |
import com.spice.profitmandi.dao.entity.fofo.ScanRecord;
|
| 71 |
import com.spice.profitmandi.dao.entity.user.Address;
|
70 |
import com.spice.profitmandi.dao.entity.user.Address;
|
| 72 |
import com.spice.profitmandi.dao.entity.user.Counter;
|
71 |
import com.spice.profitmandi.dao.entity.user.Counter;
|
| 73 |
import com.spice.profitmandi.dao.entity.user.PrivateDealUser;
|
72 |
import com.spice.profitmandi.dao.entity.user.PrivateDealUser;
|
| 74 |
import com.spice.profitmandi.dao.enumuration.dtr.OtpType;
|
73 |
import com.spice.profitmandi.dao.enumuration.dtr.OtpType;
|
| Line 572... |
Line 571... |
| 572 |
}
|
571 |
}
|
| 573 |
return serialNumbers;
|
572 |
return serialNumbers;
|
| 574 |
}
|
573 |
}
|
| 575 |
|
574 |
|
| 576 |
@Override
|
575 |
@Override
|
| 577 |
public PdfModel getInvoicePdfModel(int fofoId, int orderId) throws ProfitMandiBusinessException {
|
576 |
public PdfModel getInvoicePdfModel(int orderId) throws ProfitMandiBusinessException {
|
| - |
|
577 |
FofoOrder fofoOrder = fofoOrderRepository.selectByOrderId(orderId);
|
| - |
|
578 |
return this.getInvoicePdfModel(fofoOrder);
|
| 578 |
|
579 |
}
|
| - |
|
580 |
|
| 579 |
FofoOrder fofoOrder = fofoOrderRepository.selectByFofoIdAndOrderId(fofoId, orderId);
|
581 |
private PdfModel getInvoicePdfModel(FofoOrder fofoOrder) throws ProfitMandiBusinessException{
|
| 580 |
|
582 |
|
| 581 |
List<PaymentOptionTransaction> paymentOptionTransactions = paymentOptionTransactionRepository.selectByReferenceIdAndType(fofoOrder.getId(), PaymentOptionReferenceType.ORDER);
|
583 |
List<PaymentOptionTransaction> paymentOptionTransactions = paymentOptionTransactionRepository.selectByReferenceIdAndType(fofoOrder.getId(), PaymentOptionReferenceType.ORDER);
|
| 582 |
|
584 |
|
| 583 |
List<CustomPaymentOption> paymentOptions = new ArrayList<>();
|
585 |
List<CustomPaymentOption> paymentOptions = new ArrayList<>();
|
| 584 |
|
586 |
|
| Line 594... |
Line 596... |
| 594 |
pdfModel.setAuther("profitmandi");
|
596 |
pdfModel.setAuther("profitmandi");
|
| 595 |
pdfModel.setTitle("Retailer Invoice");
|
597 |
pdfModel.setTitle("Retailer Invoice");
|
| 596 |
pdfModel.setInvoiceDate(fofoOrder.getFormattedDate());
|
598 |
pdfModel.setInvoiceDate(fofoOrder.getFormattedDate());
|
| 597 |
|
599 |
|
| 598 |
// insurance calculation
|
600 |
// insurance calculation
|
| 599 |
List<InsurancePolicy> insurancePolicies = insurancePolicyRepository.selectByRetailerIdInvoiceNumber(fofoId, fofoOrder.getInvoiceNumber());
|
601 |
List<InsurancePolicy> insurancePolicies = insurancePolicyRepository.selectByRetailerIdInvoiceNumber(fofoOrder.getFofoId(), fofoOrder.getInvoiceNumber());
|
| 600 |
Set<CustomInsurancePolicy> customInsurancePolicies = new HashSet<>();
|
602 |
Set<CustomInsurancePolicy> customInsurancePolicies = new HashSet<>();
|
| 601 |
final float totalInsuranceTaxRate = 18;
|
603 |
final float totalInsuranceTaxRate = 18;
|
| 602 |
for(InsurancePolicy insurancePolicy : insurancePolicies){
|
604 |
for(InsurancePolicy insurancePolicy : insurancePolicies){
|
| 603 |
float taxableInsurancePrice = insurancePolicy.getSaleAmount() / (1 + totalInsuranceTaxRate / 100);
|
605 |
float taxableInsurancePrice = insurancePolicy.getSaleAmount() / (1 + totalInsuranceTaxRate / 100);
|
| 604 |
CustomInsurancePolicy customInsurancePolicy = new CustomInsurancePolicy();
|
606 |
CustomInsurancePolicy customInsurancePolicy = new CustomInsurancePolicy();
|
| Line 634... |
Line 636... |
| 634 |
customCustomer.setAddress(this.createCustomAddress(customerAddress));
|
636 |
customCustomer.setAddress(this.createCustomAddress(customerAddress));
|
| 635 |
pdfModel.setCustomer(customCustomer);
|
637 |
pdfModel.setCustomer(customCustomer);
|
| 636 |
pdfModel.setInvoiceNumber(fofoOrder.getInvoiceNumber());
|
638 |
pdfModel.setInvoiceNumber(fofoOrder.getInvoiceNumber());
|
| 637 |
pdfModel.setTotalAmount(fofoOrder.getTotalAmount());
|
639 |
pdfModel.setTotalAmount(fofoOrder.getTotalAmount());
|
| 638 |
|
640 |
|
| 639 |
Retailer retailer = retailerRepository.selectById(fofoId);
|
641 |
Retailer retailer = retailerRepository.selectById(fofoOrder.getFofoId());
|
| 640 |
PrivateDealUser privateDealUser = null;
|
642 |
PrivateDealUser privateDealUser = null;
|
| 641 |
try{
|
643 |
try{
|
| 642 |
privateDealUser = privateDealUserRepository.selectById(retailer.getId());
|
644 |
privateDealUser = privateDealUserRepository.selectById(retailer.getId());
|
| 643 |
}catch(ProfitMandiBusinessException profitMandiBusinessException){
|
645 |
}catch(ProfitMandiBusinessException profitMandiBusinessException){
|
| 644 |
LOGGER.error("Private Deal User not found : ", profitMandiBusinessException);
|
646 |
LOGGER.error("Private Deal User not found : ", profitMandiBusinessException);
|
| Line 695... |
Line 697... |
| 695 |
customFofoOrderItem.setHsnCode(fofoOrderItem.getHsnCode());
|
697 |
customFofoOrderItem.setHsnCode(fofoOrderItem.getHsnCode());
|
| 696 |
customerFofoOrderItems.add(customFofoOrderItem);
|
698 |
customerFofoOrderItems.add(customFofoOrderItem);
|
| 697 |
}
|
699 |
}
|
| 698 |
pdfModel.setOrderItems(customerFofoOrderItems);
|
700 |
pdfModel.setOrderItems(customerFofoOrderItems);
|
| 699 |
return pdfModel;
|
701 |
return pdfModel;
|
| - |
|
702 |
|
| - |
|
703 |
}
|
| - |
|
704 |
|
| - |
|
705 |
@Override
|
| - |
|
706 |
public PdfModel getInvoicePdfModel(int fofoId, int orderId) throws ProfitMandiBusinessException {
|
| - |
|
707 |
FofoOrder fofoOrder = fofoOrderRepository.selectByFofoIdAndOrderId(fofoId, orderId);
|
| - |
|
708 |
return this.getInvoicePdfModel(fofoOrder);
|
| 700 |
}
|
709 |
}
|
| 701 |
|
710 |
|
| 702 |
public String getBillingAddress(CustomerAddress customerAddress) {
|
711 |
public String getBillingAddress(CustomerAddress customerAddress) {
|
| 703 |
StringBuilder address = new StringBuilder();
|
712 |
StringBuilder address = new StringBuilder();
|
| 704 |
if ((customerAddress.getLine1() != null) && (!customerAddress.getLine1().isEmpty())) {
|
713 |
if ((customerAddress.getLine1() != null) && (!customerAddress.getLine1().isEmpty())) {
|
| Line 859... |
Line 868... |
| 859 |
customerAddress = customerAddressRepository.selectByParams(
|
868 |
customerAddress = customerAddressRepository.selectByParams(
|
| 860 |
customAddress.getName(), customAddress.getLine1(), customAddress.getLine2(),
|
869 |
customAddress.getName(), customAddress.getLine1(), customAddress.getLine2(),
|
| 861 |
customAddress.getLandmark(),customAddress.getCity(), customAddress.getPinCode(),
|
870 |
customAddress.getLandmark(),customAddress.getCity(), customAddress.getPinCode(),
|
| 862 |
customAddress.getState(), customAddress.getPhoneNumber(), customAddress.getCountry(), customerId);
|
871 |
customAddress.getState(), customAddress.getPhoneNumber(), customAddress.getCountry(), customerId);
|
| 863 |
}catch(ProfitMandiBusinessException profitMandiBusinessException){
|
872 |
}catch(ProfitMandiBusinessException profitMandiBusinessException){
|
| 864 |
LOGGER.warn("Customer address not found : ", profitMandiBusinessException);
|
873 |
LOGGER.warn("Customer address not found with [{}]", customAddress);
|
| 865 |
customerAddress = new CustomerAddress();
|
874 |
customerAddress = new CustomerAddress();
|
| 866 |
this.setCustomerAddress(customerAddress, customAddress);
|
875 |
this.setCustomerAddress(customerAddress, customAddress);
|
| 867 |
customerAddress.setCustomerId(customerId);
|
876 |
customerAddress.setCustomerId(customerId);
|
| 868 |
}
|
877 |
}
|
| 869 |
customerAddressRepository.persist(customerAddress);
|
878 |
customerAddressRepository.persist(customerAddress);
|
| Line 1018... |
Line 1027... |
| 1018 |
private LocalDate validateCustomerDateOfBirth(String customerDateOfBirthString) throws ProfitMandiBusinessException{
|
1027 |
private LocalDate validateCustomerDateOfBirth(String customerDateOfBirthString) throws ProfitMandiBusinessException{
|
| 1019 |
LocalDate customerDateOfBirth = null;
|
1028 |
LocalDate customerDateOfBirth = null;
|
| 1020 |
try{
|
1029 |
try{
|
| 1021 |
customerDateOfBirth = StringUtils.toDate(customerDateOfBirthString);
|
1030 |
customerDateOfBirth = StringUtils.toDate(customerDateOfBirthString);
|
| 1022 |
}catch(DateTimeException dateTimeException){
|
1031 |
}catch(DateTimeException dateTimeException){
|
| 1023 |
LOGGER.error("Unable to parse dateOfBirth", dateTimeException);
|
1032 |
LOGGER.error("Unable to parse dateOfBirth message {}", dateTimeException.getMessage());
|
| 1024 |
throw new ProfitMandiBusinessException("dateOfBirth", customerDateOfBirthString, "FFORDR_1012");
|
1033 |
throw new ProfitMandiBusinessException("dateOfBirth", customerDateOfBirthString, "FFORDR_1012");
|
| 1025 |
}
|
1034 |
}
|
| 1026 |
return customerDateOfBirth;
|
1035 |
return customerDateOfBirth;
|
| 1027 |
}
|
1036 |
}
|
| 1028 |
|
1037 |
|
| Line 1134... |
Line 1143... |
| 1134 |
private Customer createAndGetCustomer(CustomCustomer customCustomer) throws ProfitMandiBusinessException{
|
1143 |
private Customer createAndGetCustomer(CustomCustomer customCustomer) throws ProfitMandiBusinessException{
|
| 1135 |
Customer customer = null;
|
1144 |
Customer customer = null;
|
| 1136 |
try{
|
1145 |
try{
|
| 1137 |
customer = customerRepository.selectByMobileNumber(customCustomer.getMobileNumber());
|
1146 |
customer = customerRepository.selectByMobileNumber(customCustomer.getMobileNumber());
|
| 1138 |
}catch(ProfitMandiBusinessException profitMandiBusinessException){
|
1147 |
}catch(ProfitMandiBusinessException profitMandiBusinessException){
|
| 1139 |
LOGGER.error("Error : ", profitMandiBusinessException);
|
1148 |
LOGGER.error("Customer not found with mobileNumber [{}]", customCustomer.getMobileNumber());
|
| 1140 |
customer = new Customer();
|
1149 |
customer = new Customer();
|
| 1141 |
}
|
1150 |
}
|
| 1142 |
customer.setFirstName(customCustomer.getFirstName());
|
1151 |
customer.setFirstName(customCustomer.getFirstName());
|
| 1143 |
customer.setLastName(customCustomer.getLastName());
|
1152 |
customer.setLastName(customCustomer.getLastName());
|
| 1144 |
customer.setEmailId(customCustomer.getEmailId());
|
1153 |
customer.setEmailId(customCustomer.getEmailId());
|