DDD Events Between Aggregates Example - events

I have two aggregates
item and price adjustment.
A price adjustment will contain an item adjustment which will say, for a specific item, raise it by x percent (e.g. 10%)
my item has a list price which is what needs to be updated/adjusted.
so when the price adjustment is processed, it is going to find that item and needs to adjust that item's list price by the percentage specific. When the adjustment is complete, the item adjustment in the price adjustment needs to be marked as complete
My question is how is this updating of the list price and marking of the item adjustment being performed composed into events?
What is the correct way for me to both update the list price and mark the item adjustment as completed following events?
Is this a correct solution?:
call function on the item such as AdjustListPrice and pass in the price adjustment information such as the id and percentage to be adjusted by.
Then raise an event such as ItemListPriceAdjusted have the price adjustment listen so that it can mark the adjustment as complete and raise another event such as itemPriceadjustmentCompleted
if this is the correct way, should the new calculated list price be added to the ItemListPriceAdjusted price, or should just the adjustment percentage be added and this is then calculated when it is applied/read from the aggregate?
Thanks
Edit:
The option i currently went with is when the price adjustment is being processed, it will go through each of the item adjustments.
It will find the item that it targets and call the function
AdjustPrice(Guid priceAdjustmentId, decimal adjustmentPercentage)
This will calculate the new list price for that item and the item will emit an ItemPriceAdjusted event, which contains the price adjustment id, the and the new list price
The price adjustment will then listen for these events and mark the relevant item adjustment as complete, in turn emitting its own ItemAdjustmentCompleted Event

We are talking DDD here. So the first question I'd ask is what's happening in the business that you want to reflect with code.
It is highly unlikely that a business would decide to "adjust prices" by 10% on the whole assortment. That has something to deal with the pricing strategy. Which is individual to a product or a category of products. So, I'd start with asking the business first.
Next, if in the underlying business you have some dedicated people or departments to deal with the pricing, that would give you the context boundary. Most likely pricing is a separate domain from inventory (listing the products). Most likely there is some base price, the prime cost of a product. Then there are some additional costs, some margin to it which will form the profit. So, by "adjusting" a price - what are you going to achieve? Does it mean that a prime cost changed? Or a margin changed? Or some marketing campaign ended? Figure it out - and you'll get the answer to your question. You'll be able to derive the event name from it.
To sum up: store/fire/raise/dispatch an event that is relevant to THE business.

Related

how to reserve quantity partially for delivery order in odoo

I have one Product with on-Hand Quantity is 600.
and There are Two Delivery Orders, one is for 400 and other is for 500
but i want reserve both order partially by 300 each DO.
how can i do that in odoo9/10/11.
If I understood properly the question, you just have to edit the "TODO" column before validating the delivery orders and set up 300 units each.
By doing that you can do partial delivers of 300 units for each delivery order.
Then you have the option to select to "create backorder or not create backorder" depending on if you plan to deliver the remaining quantities later or not.
Note that "ToDo" column is only present if in the sale order you allow "partial delivery of goods" (can't remember the exact term in English).
Hope this helps, not 100% sure if this is what you are asking.

How to get stock movements data for a period of time in Square POS via API?

I'm considering to create analytical application to use with Square POS. For the app to work I need to fetch products sale statistics, as well as current stocks and stock movements for a period of time. What objects should I use for these purposes? Do I have to use itemizations in the Payment object for sale statistcs and Items + Inventory objects for current stock? What about stock movements (inventory replenishments, write-offs etc.)?
Your general approach sounds reasonable. Square doesn't track reasons for inventory (stock) changes (e.g. write-offs), only the amount is tracked. You can get the current stock amounts from the inventory endpoint for the merchant's entire catalog.You can track these changes either by polling the inventory endpoint at a fixed interval, or by subscribing to webhook notifications for the INVENTORY_UPDATED webhook, which will tell you when to check the inventory list for updates.

CS-Cart price not recalculated with multiple product options

I am creating a new cscart store and am running into problem with products that have more than one option, which doesn't calculate the price properly. On this example page, I have a product for which the price should change based on the meal plan and the size. I can get one or the other to work but not both together. Thus far, I have realized that, both options are calculated from the "base" price therefore when the price is adjusted based on the meal plan, the size doesn't do anything because the "base" price is, in theory, still set to $0.00. Any ideas on a way to set this up?
There are two possible ways out:
1) If you set the price for one meal, for example, then both options will work, because you will have the “base” price.
2) If you set the second option in dollars, not in percents, then it will also work.
--
Maria Tainkina
CS-Cart team

Expresso Store - Exclude Product from Order Quantity

I'm using Expresso-Store to process product orders for a non-profit. In addition to selling a range of handmade products we are offering visitors an option to donate.
I have most of the donation stuff working just fine. I used Justin Long's advice posted here: http://iamjustinlong.com/blog/single/accepting_donations_with_expresso_store/
As suggested I have created a channel for all the products and then a separate channel which holds a single "Donation" product with a cost of $1.00. The visitor adjusts the quantity of this item which results in a donation amount of $1.00 * qty.
The specific problem I'm running into is displaying the total quantity of items in the cart when there's also a "Donation" product added. Since the donation amount is determined by quantity * $1.00 but in reality it represents a single donation, my {order_qty} is way off since it includes the many multiples of Donation products.
I have a small cart icon that is displaying a number above and next to it with the {order_qty} but I need to exclude the donation product from this calculation. How might I go about this?
This would be fairly difficult to do using the current version. The best I can suggest is not to display the {order_qty} on your checkout page (most sites only display the total anyway).
However, in saying that, the next version of Store has first-class donations support, so it will soon be possible.

Programmatically apply a discount price in product list

I would like to programmatically display a discounted price on the product list/page so that each customer as a personal price shown based on a customer attribute (like gender for instance, and of course let it be assigned as new price for the user session) but I can't see a viable option via the magento catalog price rules involving customer attributes other than the assigned group.
I'm using the group to do different kind of discounts and categorization of the customers, so the path of "split the customers on the gender" (or similar) is not an option unfortunately, since I can't assign more than 1 group per customer.
At the moment I was thinking about setting up a custom observer to check for calls to the price generation and then let it consider my customer attributes when calculating the price.
Is that possible? if so, any pointers about?
Would you suggest something different?
Thanks a lot to everyone for your time.
As I was thinking before, I solved my issue creating a custom module with an observer looking for catalog_product_get_final_price calls, getting the customer details from the current customer session.
It works great, I just need to let it display the correct price in the catalog product list, but is minimal, as the price seems to be calculated correctly inside the product page and the cart

Resources