on ‎2019 Mar 27 2:39 PM
Hi Expert,
i am creating single order and single order entry but after the process its creating 6 Order entries but i need only one order entry.
Below is the code.
final OrderModel order = modelService.create(OrderModel.class);
ProductModel productModel = new ProductModel();
List<ViolationModel> voilations= new ArrayList<ViolationModel>();
order.setCode(orderCodeGenerator.generate().toString());
order.setDate(new Date());
final CurrencyModel currency = commerceCommonI18NService.getCurrentCurrency();
order.setCurrency(currency);
final CustomerModel currentCustomer = (CustomerModel) userService.getCurrentUser();
order.setUser(currentCustomer);
//modelService.save(order);
final OrderEntryModel orderEntryModel = modelService.create(OrderEntryModel.class);
if (model.getCode().startsWith("CAR-PRODUCT") )
{
CarInfoProductModel carInfoModel = (CarInfoProductModel) model;
productModel = postalPortalPublicProsecutionDao.getProductForCode(carInfoModel.getCode());
voilations = postalPortalPublicProsecutionDao.getCarViolation(carInfoModel.getCarplateNo());
}
if (model.getCode().startsWith("POBOX") )
{
POBoxRentalModel poBoxRentalModel = (POBoxRentalModel) model;
productModel = postalPortalPublicProsecutionDao.getProductForCode(poBoxRentalModel.getCode());
}
order.setStatus(OrderStatus.CREATED);
order.setTotalPrice(Double.valueOf(100));
order.setCreationtime(new Date());
order.setPaymentStatus(PaymentStatus.NOTPAID);
orderEntryModel.setTotalPrice(Double.valueOf(100));
orderEntryModel.setProduct(productModel);
orderEntryModel.setQuantity(Long.valueOf(1));
orderEntryModel.setUnit(unitService.getUnitForCode("pieces"));
modelService.save(order);
orderEntryModel.setOrder(order);
modelService.save(orderEntryModel);
Request clarification before answering.
| User | Count |
|---|---|
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.