| Line 952... |
Line 952... |
| 952 |
pdfModel.setTncs(tncs);
|
952 |
pdfModel.setTncs(tncs);
|
| 953 |
return pdfModel;
|
953 |
return pdfModel;
|
| 954 |
|
954 |
|
| 955 |
}
|
955 |
}
|
| 956 |
|
956 |
|
| 957 |
private InvoicePdfModel getInsuranceInvoicePdfModel(FofoOrder fofoOrder) throws ProfitMandiBusinessException {
|
- |
|
| 958 |
|
- |
|
| 959 |
List<PaymentOptionTransaction> paymentOptionTransactions = paymentOptionTransactionRepository
|
- |
|
| 960 |
.selectByReferenceIdAndType(fofoOrder.getId(), PaymentOptionReferenceType.INSURANCE);
|
- |
|
| 961 |
|
- |
|
| 962 |
List<CustomPaymentOption> paymentOptions = new ArrayList<>();
|
- |
|
| 963 |
|
- |
|
| 964 |
InvoicePdfModel pdfModel = new InvoicePdfModel();
|
- |
|
| 965 |
for (PaymentOptionTransaction paymentOptionTransaction : paymentOptionTransactions) {
|
- |
|
| 966 |
CustomPaymentOption cpi = new CustomPaymentOption();
|
- |
|
| 967 |
cpi.setAmount(paymentOptionTransaction.getAmount());
|
- |
|
| 968 |
cpi.setPaymentOption(
|
- |
|
| 969 |
paymentOptionRepository.selectById(paymentOptionTransaction.getPaymentOptionId()).getName());
|
- |
|
| 970 |
paymentOptions.add(cpi);
|
- |
|
| 971 |
}
|
- |
|
| 972 |
|
- |
|
| 973 |
pdfModel.setTitle("Retailer Invoice");
|
- |
|
| 974 |
|
- |
|
| 975 |
pdfModel.setPaymentOptions(paymentOptions);
|
- |
|
| 976 |
pdfModel.setAuther("SmartDukaan");
|
- |
|
| 977 |
pdfModel.setInvoiceDate(FormattingUtils.formatDate(fofoOrder.getCreateTimestamp()));
|
- |
|
| 978 |
|
- |
|
| 979 |
// insurance calculation
|
- |
|
| 980 |
List<InsurancePolicy> insurancePolicies = insurancePolicyRepository
|
- |
|
| 981 |
.selectByRetailerIdInvoiceNumber(fofoOrder.getFofoId(), fofoOrder.getInvoiceNumber());
|
- |
|
| 982 |
Set<CustomInsurancePolicy> customInsurancePolicies = new HashSet<>();
|
- |
|
| 983 |
final float totalInsuranceTaxRate = 18;
|
- |
|
| 984 |
for (InsurancePolicy insurancePolicy : insurancePolicies) {
|
- |
|
| 985 |
float taxableInsurancePrice = insurancePolicy.getSaleAmount() / (1 + totalInsuranceTaxRate / 100);
|
- |
|
| 986 |
CustomInsurancePolicy customInsurancePolicy = new CustomInsurancePolicy();
|
- |
|
| 987 |
customInsurancePolicy.setDescription("Damage Protection Plan for device IMEI #"
|
- |
|
| 988 |
+ insurancePolicy.getSerialNumber() + "\n Certificate No. " + insurancePolicy.getPolicyNumber());
|
- |
|
| 989 |
customInsurancePolicy.setHsnCode("998716");
|
- |
|
| 990 |
customInsurancePolicy.setRate(taxableInsurancePrice);
|
- |
|
| 991 |
customInsurancePolicy.setIgstRate(18);
|
- |
|
| 992 |
customInsurancePolicy.setIgstAmount(taxableInsurancePrice * 18 / 100);
|
- |
|
| 993 |
customInsurancePolicy.setCgstRate(9);
|
- |
|
| 994 |
customInsurancePolicy.setCgstAmount(taxableInsurancePrice * 9 / 100);
|
- |
|
| 995 |
customInsurancePolicy.setSgstRate(9);
|
- |
|
| 996 |
customInsurancePolicy.setSgstAmount(taxableInsurancePrice * 9 / 100);
|
- |
|
| 997 |
customInsurancePolicy.setNetAmount(insurancePolicy.getSaleAmount());
|
- |
|
| 998 |
customInsurancePolicies.add(customInsurancePolicy);
|
- |
|
| 999 |
}
|
- |
|
| 1000 |
pdfModel.setInsurancePolicies(customInsurancePolicies);
|
- |
|
| 1001 |
|
- |
|
| 1002 |
pdfModel.setCustomer(getCustomCustomer(fofoOrder));
|
- |
|
| 1003 |
pdfModel.setInvoiceNumber(fofoOrder.getInvoiceNumber());
|
- |
|
| 1004 |
pdfModel.setTotalAmount(fofoOrder.getTotalAmount());
|
- |
|
| 1005 |
|
- |
|
| 1006 |
Retailer retailer = retailerRepository.selectById(fofoOrder.getFofoId());
|
- |
|
| 1007 |
PrivateDealUser privateDealUser = null;
|
- |
|
| 1008 |
try {
|
- |
|
| 1009 |
privateDealUser = privateDealUserRepository.selectById(retailer.getId());
|
- |
|
| 1010 |
} catch (ProfitMandiBusinessException profitMandiBusinessException) {
|
- |
|
| 1011 |
LOGGER.error("Private Deal User not found : ", profitMandiBusinessException);
|
- |
|
| 1012 |
}
|
- |
|
| 1013 |
|
- |
|
| 1014 |
User user = userRepository.selectById(userAccountRepository.selectUserIdByRetailerId(retailer.getId()));
|
- |
|
| 1015 |
CustomRetailer customRetailer = new CustomRetailer();
|
- |
|
| 1016 |
customRetailer.setBusinessName(retailer.getName());
|
- |
|
| 1017 |
customRetailer.setMobileNumber(user.getMobileNumber());
|
- |
|
| 1018 |
// customRetailer.setTinNumber(retailer.getNumber());
|
- |
|
| 1019 |
if (privateDealUser == null) {
|
- |
|
| 1020 |
customRetailer.setGstNumber(null);
|
- |
|
| 1021 |
} else {
|
- |
|
| 1022 |
if (null != privateDealUser.getCounterId()) {
|
- |
|
| 1023 |
Counter counter = counterRepository.selectById(privateDealUser.getCounterId());
|
- |
|
| 1024 |
customRetailer.setGstNumber(counter.getGstin());
|
- |
|
| 1025 |
} else {
|
- |
|
| 1026 |
customRetailer.setGstNumber(null);
|
- |
|
| 1027 |
}
|
- |
|
| 1028 |
}
|
- |
|
| 1029 |
Address retailerAddress = addressRepository
|
- |
|
| 1030 |
.selectById(retailerRegisteredAddressRepository.selectAddressIdByRetailerId(retailer.getId()));
|
- |
|
| 1031 |
customRetailer.setAddress(this.createCustomAddress(retailerAddress));
|
- |
|
| 1032 |
pdfModel.setRetailer(customRetailer);
|
- |
|
| 1033 |
|
- |
|
| 1034 |
Set<CustomOrderItem> customerFofoOrderItems = new HashSet<>();
|
- |
|
| 1035 |
|
- |
|
| 1036 |
pdfModel.setOrderItems(customerFofoOrderItems);
|
- |
|
| 1037 |
String partnerAddressStateCode = stateRepository.selectByName(pdfModel.getRetailer().getAddress().getState())
|
- |
|
| 1038 |
.getCode();
|
- |
|
| 1039 |
String customerAddressStateCode = stateRepository.selectByName(pdfModel.getCustomer().getAddress().getState())
|
- |
|
| 1040 |
.getCode();
|
- |
|
| 1041 |
pdfModel.setPartnerAddressStateCode(partnerAddressStateCode);
|
- |
|
| 1042 |
pdfModel.setCustomerAddressStateCode(customerAddressStateCode);
|
- |
|
| 1043 |
pdfModel.setCancelled(fofoOrder.getCancelledTimestamp() != null);
|
- |
|
| 1044 |
List<String> tncs = new ArrayList<>();
|
- |
|
| 1045 |
tncs.add("I agree that goods received are in good working condition");
|
- |
|
| 1046 |
tncs.add("Goods once sold cannot be exchanged or taken back");
|
- |
|
| 1047 |
tncs.add("Warranty for the goods received by me is the responsibility of the manufacturer only.");
|
- |
|
| 1048 |
tncs.add("Customer needs to activate the handset at the time of delivery to be eligible for the discount");
|
- |
|
| 1049 |
tncs.add(
|
- |
|
| 1050 |
"Tempered Glass Replacement will be done only for the Mobile Phone which was purchased from SmartDukaan");
|
- |
|
| 1051 |
tncs.add(
|
- |
|
| 1052 |
"Customers requesting Tempered Glass Replacement will have to bring the broken tempered glass, either pasted on the phone or along with the phone");
|
- |
|
| 1053 |
tncs.add("Service fee of Rs.20 will be chargeable for each Tempered Glass Replacement");
|
- |
|
| 1054 |
if (pdfModel.getInsurancePolicies() != null && pdfModel.getInsurancePolicies().size() > 0) {
|
- |
|
| 1055 |
tncs.add("Damage protection provided is the responisibility of Protection Provider only");
|
- |
|
| 1056 |
}
|
- |
|
| 1057 |
pdfModel.setTncs(tncs);
|
- |
|
| 1058 |
return pdfModel;
|
- |
|
| 1059 |
|
- |
|
| 1060 |
}
|
- |
|
| 1061 |
|
957 |
|
| 1062 |
private CustomCustomer getCustomCustomer(FofoOrder fofoOrder) throws ProfitMandiBusinessException {
|
958 |
private CustomCustomer getCustomCustomer(FofoOrder fofoOrder) throws ProfitMandiBusinessException {
|
| 1063 |
Customer customer = customerRepository.selectById(fofoOrder.getCustomerId());
|
959 |
Customer customer = customerRepository.selectById(fofoOrder.getCustomerId());
|
| 1064 |
CustomCustomer customCustomer = new CustomCustomer();
|
960 |
CustomCustomer customCustomer = new CustomCustomer();
|
| 1065 |
customCustomer.setFirstName(customer.getFirstName());
|
961 |
customCustomer.setFirstName(customer.getFirstName());
|
| Line 1076... |
Line 972... |
| 1076 |
public InvoicePdfModel getInvoicePdfModel(int fofoId, int orderId) throws ProfitMandiBusinessException {
|
972 |
public InvoicePdfModel getInvoicePdfModel(int fofoId, int orderId) throws ProfitMandiBusinessException {
|
| 1077 |
FofoOrder fofoOrder = fofoOrderRepository.selectByFofoIdAndOrderId(fofoId, orderId);
|
973 |
FofoOrder fofoOrder = fofoOrderRepository.selectByFofoIdAndOrderId(fofoId, orderId);
|
| 1078 |
return this.getInvoicePdfModel(fofoOrder);
|
974 |
return this.getInvoicePdfModel(fofoOrder);
|
| 1079 |
}
|
975 |
}
|
| 1080 |
|
976 |
|
| 1081 |
@Override
|
- |
|
| 1082 |
public InvoicePdfModel getInsuranceInvoicePdfModel(int fofoId, int orderId) throws ProfitMandiBusinessException {
|
- |
|
| 1083 |
FofoOrder fofoOrder = fofoOrderRepository.selectByFofoIdAndOrderId(fofoId, orderId);
|
- |
|
| 1084 |
return this.getInvoicePdfModel(fofoId, orderId);
|
- |
|
| 1085 |
}
|
- |
|
| 1086 |
|
- |
|
| 1087 |
public String getBillingAddress(CustomerAddress customerAddress) {
|
977 |
public String getBillingAddress(CustomerAddress customerAddress) {
|
| 1088 |
StringBuilder address = new StringBuilder();
|
978 |
StringBuilder address = new StringBuilder();
|
| 1089 |
if ((customerAddress.getLine1() != null) && (!customerAddress.getLine1().isEmpty())) {
|
979 |
if ((customerAddress.getLine1() != null) && (!customerAddress.getLine1().isEmpty())) {
|
| 1090 |
address.append(customerAddress.getLine1());
|
980 |
address.append(customerAddress.getLine1());
|
| 1091 |
address.append(", ");
|
981 |
address.append(", ");
|