How to get the total amount of discounts applied to a cart - sap-commerce-cloud

I'm trying find out how I can get the total discounts that have been
applied to a shopping cart in Hybris 6.4.
For example one may product may have a 10% and another 20%, if these have been added to the cart how can I find out what the total amount discounts in the full cart is.
What's the best way to do this?
Thanks

You can find it as Total Discounts(cart.getTotalDiscounts()) in hmc/backoffice.
To know more how totalDiscounts being calculated, debug DefaultCalculationService.

Related

Why when the market price is below a limit buy, why is it not fullfilled?

I am writing a trading bot in C++. I am making limit orders that allow for 1% leniency. As you can see there is a market price of 2.2532, and I made a limit buy at 2.2757. Logically, if the limit buy should be activated once the market price is at or below the limit price. However, as you can see from the pictures below, this is not the case. I posted pictures of both the order book and the trade history. What I am wondering is why. Does this have something to do with the order book? I also noticed when placing market values generally there is a fairly large discrepancy between the price of the market and the average price it is filled at.
Since getting the market price on Binance does not seem to actually tell you if the market order will be full-filled at that price, or if the limit order can go through at a price around there. Is there a way to actually programmatically/mathematically find out if a limit order will go through. Or, find out what the actual average price of a market order will be if bought in that moment?
UPDATE
So when I go to place a market order, I get this message:
Your order price will be 8% higher than the latest market price. Please proceed cautiously. When I want to buy at the market price. Partially I want to know why. But also, is there a way to get the exact number in which this price will be? Also, Is there a way to get this on the API exactly what the next market buy/sell will be?
After some more research on the question. According to investopedia
A trade will only occur when someone is willing to sell the security at the bid price, or buy it at the ask price.
Meaning, the price at which the asset will be sold at has less to do with the current market price, and a lot more to do with the order book. Looking at the pictures above, at that time according to limit orders the lowest someone was willing to sell the asset was, was 2.500 and the highest someone was willing to buy the asset for was 2.499. These are the ask price and bid price respectively. Since no one was willing to buy at the ask price or sell at the bid price, the transaction did not go through. Notice that the quantities are also important for knowing how much of the order will be filled, for your future reference.
For those that might be a little confused, you need to buy at the lowest someone is willing to sell. You need to sell at the highest someone is willing to buy. These come from the limit orders.
Back to the original question, the update on the 8% difference makes sense, the ask price probably dropped a little. However, if you notice 2.2532 * 1.08 is 2.433456 which is much closer to the 2.5 price above than the limit buy created at 2.2757 meaning the 8% notification makes sense.
I will now explain how you would calculate this using mathematics and coding. You need to pull from the order book ticker. This api request is /api/v3/ticker/bookTicker
I am going to use the example of wanting a market buy for GRTUSD. The dictionary you get back from the link https://api.binance.us/api/v3/ticker/bookTicker?symbol=GRTUSD is {"symbol":"GRTUSD","bidPrice":"0.1391","bidQty":"3613.45000000","askPrice":"0.1393","askQty":"5183.18000000"}
Some quick math shows that 5183.18000000 of GRT is the equivalent of a little over 722 USD at the ask price. This means if I placed a market buy for GRTUSD. As long as the amount of USD I was investing at that moment was equivalent to or less than 722 USD it would get filled at the ask price of 0.1393

Product discounted price in product page - Hybris Commerce 6.6

I have target discounted price for an SKU, with no product group or customer group filters, just a "target price" delimited by dates, that I want to show in the product page. This is maintained in the product management screen, and it's not promotions related.
As far as I can tell Hybris only calculates the discount when the product is placed in an order (the target price does show correctly in the cart page).
I tried creating a virtual cart in the product detail page, but unless I save the cart, Hybris doesn't allow me to calculate the discount. I don't want to save a cart each time a person goes into a product page.
What's the correct approach for this? Seems a pretty normal requirement.
Thank you
You can use Price Rows with validity period (start and end date). Import all prices with validity date to system. List product prices in PDP on custom section with custom code.
A voucher/discount is applied to a cart, not to a product. Even if a voucher is only applicable for a specific product, hybris will only calculate a discount for an order/cart.

Giving Stripe Customers Credit

I'm working with Stripe. Our users subscribe to our service and they are billed every 2 weeks. We need to implement a way to give them $5 credit every time they refer someone to use our service.
Solutions I have considered so far:
Stripe coupons: Stripe has great documentation. Unfortunately, for
coupons there are many ambiguities. I tried working with coupons but
so far it seems like a coupon can only be applied once for each
invoice, and you can't apply multiple coupons for one invoice. This will not work with us since a user can earn $5 multiple times during the billing period.
Issuing refund: the problem with this is that we have to pay the user actual money while what we actually want is to give them credit to use in our service.
Am I missing anything with coupons? Are there any other solutions/suggestions?
If I understand your use case correctly, I think the best way would be to create an invoice item with an amount of -500 for each referral. When you create an invoice item, by default it is set as "pending" and will automatically be included in the next invoice, i.e. at the end of the current billing period.
Be aware that if the invoice's total is negative (in the case of many referrals), then the total will be added to the customer's account_balance and reduce the amount of the next invoice as well. If this isn't what you want, you'd need to reset the customer's account_balance to zero, or make sure that you don't create invoice items that will make the invoice's total go below zero.
More information about invoice items can be found here: https://stripe.com/docs/subscriptions/guide#adding-invoice-items. The guide only mentions invoice items with positive values (i.e. additional charges), but you can use negative values as well.
Have you considered just checking for available credit in transactions before you charge?
That way you can just store how much credit people currently have in some database, and just apply the balance on transactions. AKA charge them for full_price - total_credits.

NetSuite: How to change the total tax amount in a workflow?

I'm trying to divide my total shipping & handling costs into 3 different buckets, shipping, handling and tax (on the handling).
I currently have a workflow that sets the shipping cost correctly, handling cost correctly (on a Credit Card Sale) but for some reason it doesn't set the tax total correctly.
I think I'm using the wrong field, because in my workflow I tried to just set "Tax Total" = 0.00 and it doesn't work, the tax total is just the same as it was originally. Is there a different field I need to be setting?
Did you check if your line items have a tax code associate with it or it there is a Tax Item applied to the whole transaction?
As far as I know, the 'Tax Total' is computed by NetSuite so it is probably over-writing the value that is being set by the workflow.

MS Access 2003 - Calculating an average based on qty sold/per site with supply %

Here is another question I have about being able to calculate this scenario in Access, or even at all for that matter:
I have a query that find the TOP 5 items sold in a given timeframe, and it groups by site. I use this to create a comparative chart between the site for ppt presentations. I do a lot of these but I have a problem with the presentation that I foresee they will have a problem with and it makes for bad metrics:
Some stores are bigger than others, and get much more supply. So a straight aggregate total of just qty of toping selling items, and comparing the locations is stacking the deck a little.
So if Site A gets 80% of the supply, and sells 500, Site B gets 15% supply and sell 75, and site C get 5% supply and sells 50 items, then Site C actually has the best sales for their size. I have exactly what I need in terms in the first chart (from my queries and such) to show the aggregate total, but what do I need to represent the idea mentioned above.
The factors that I have that go into this are:
ItemID - group by
Item - group by
qty sold - sum/descending (which is the variable that determines the Top 5)
Store/Location - Group By
and then I run a seperate query to get the total deliveries (supply) to each site
I realize that this may just be a lack of mathmatical understanding on my part, but can anyone help with this?
thanks
The first issue that I see isn't about SQL savvy; it's how to serve your data customer. What does he or she want to see? Metrics is a term with a holy ring, and for good reason: it's supposed to be what is used for the big business decisions, and it's scary easy to measure the wrong thing.
So I'd make sure I know what my customer wants. If you can't model it on a spreadsheet, you won't be able to develop your reporting effectively.
Every deck of cards is loaded. You have to know how they want it loaded.

Resources