use of org.broadleafcommerce.common.currency.domain.BroadleafCurrency in project BroadleafCommerce by BroadleafCommerce.
the class CheckoutTest method testCheckout.
@Test(groups = { "checkout" }, dependsOnGroups = { "createCartForCustomer", "testShippingInsert" }, dataProvider = "USCurrency", dataProviderClass = BroadleafCurrencyProvider.class)
@Transactional
public void testCheckout(BroadleafCurrency usCurrency) throws Exception {
HashMap currencyConsiderationContext = new HashMap();
currencyConsiderationContext.put("aa", "bb");
CurrencyConversionContext.setCurrencyConversionContext(currencyConsiderationContext);
CurrencyConversionContext.setCurrencyConversionService(new CurrencyConversionService() {
@Override
public Money convertCurrency(Money source, Currency destinationCurrency, int destinationScale) {
return source;
}
});
String userName = "customer1";
Customer customer = customerService.readCustomerByUsername(userName);
Order order = orderService.createNewCartForCustomer(customer);
usCurrency = currencyService.save(usCurrency);
order.setCurrency(usCurrency);
Address address = buildAddress();
FulfillmentGroup group = buildFulfillmentGroup(order, address);
addSampleItemToOrder(order, group);
order.setTotalShipping(new Money(0D));
addPaymentToOrder(order, address);
// execute pricing for this order
orderService.save(order, true);
CheckoutResponse response = checkoutService.performCheckout(order);
assert (order.getTotal().greaterThan(order.getSubTotal()));
}
use of org.broadleafcommerce.common.currency.domain.BroadleafCurrency in project BroadleafCommerce by BroadleafCommerce.
the class OrderToPaymentRequestDTOServiceImpl method translateOrder.
@Override
public PaymentRequestDTO translateOrder(Order order) {
if (order != null) {
final Long id = order.getId();
final BroadleafCurrency currency = order.getCurrency();
PaymentRequestDTO requestDTO = new PaymentRequestDTO().orderId(id.toString());
if (LOG.isTraceEnabled()) {
LOG.trace(String.format("Translating Order (ID:%s) into a PaymentRequestDTO for the configured " + "gateway.", id));
}
if (currency != null) {
requestDTO.orderCurrencyCode(currency.getCurrencyCode());
}
populateCustomerInfo(order, requestDTO);
populateShipTo(order, requestDTO);
populateBillTo(order, requestDTO);
populateTotals(order, requestDTO);
populateDefaultLineItemsAndSubtotal(order, requestDTO);
return requestDTO;
}
return null;
}
use of org.broadleafcommerce.common.currency.domain.BroadleafCurrency in project BroadleafCommerce by BroadleafCommerce.
the class BroadleafCurrencyProvider method provideFRCurrency.
@DataProvider(name = "FRCurrency")
public static Object[][] provideFRCurrency() {
BroadleafCurrency currency = new BroadleafCurrencyImpl();
currency.setCurrencyCode("EUR");
currency.setDefaultFlag(true);
currency.setFriendlyName("EURO Dollar");
return new Object[][] { { currency } };
}
use of org.broadleafcommerce.common.currency.domain.BroadleafCurrency in project BroadleafCommerce by BroadleafCommerce.
the class BroadleafCurrencyDaoImpl method findCurrencyByCode.
/**
* @return The locale for the passed in code
*/
@Override
public BroadleafCurrency findCurrencyByCode(String currencyCode) {
Query query = em.createNamedQuery("BC_READ_CURRENCY_BY_CODE");
query.setParameter("currencyCode", currencyCode);
query.setHint(org.hibernate.ejb.QueryHints.HINT_CACHEABLE, true);
List<BroadleafCurrency> currencyList = query.getResultList();
if (currencyList.size() >= 1) {
return currencyList.get(0);
}
return null;
}
use of org.broadleafcommerce.common.currency.domain.BroadleafCurrency in project BroadleafCommerce by BroadleafCommerce.
the class BroadleafCurrencyDaoImpl method findDefaultBroadleafCurrency.
@Override
public BroadleafCurrency findDefaultBroadleafCurrency() {
Query query = em.createNamedQuery("BC_READ_DEFAULT_CURRENCY");
query.setHint(org.hibernate.ejb.QueryHints.HINT_CACHEABLE, true);
List<BroadleafCurrency> currencyList = query.getResultList();
if (currencyList.size() >= 1) {
return currencyList.get(0);
}
return null;
}
Aggregations