Recommendation for Domain Driven Design modelling - domain-driven-design

I'm trying to model two type of invoice in ddd.
Purchase invoice and sales invoice.
Simply behaviour is purchase invoice increases stock quantities and sales invoice decreases.
Which one is rigt for ddd?
1- Defining PurchaseInvoice and SalesInvoice separately that implement business logic in two different aggregate?
2- Defining one Invoice aggregate and implement business logic help with dicriminator field?

Sounds to me like Purchase and Sales are two completely different Bounded Context. Which means that an Invoice Entity could exist in both. A discriminator is a smell that you're dealing with two different things. So neither 1 or 2 seems to be the best option. I'd rather go with an Invoice in the Purchase Bounded Context and an Invoice in the Purchase Bounded Context.

Related

Shopware 6 dynamically change VAT

Is it possible to change rate of VAT on checkout page?
For example I want to add condition if user is guest and commercial then use 20% rate else 0%
That is currently not possible, but there is a feature currently being implemented which allows for custom tax calculations.
Search for "Interface for tax services" in the public roadmap.
That feature is designed to allow to connect to external tax providers for more complex tax calculation e.g. the US, but it should also allow to change the taxes by rule etc.
However keep in mind that in that case the prices in the store prior to the checkout page may not be accurate, this can have some legal implications depending on the country where the shop is operating.
There is a module* which allows to determine automatically based on the VAT ID entered if the B2B customer should pay tax, and doesn't bill tax to customers with a valid VAT ID.
*I am not affiliated with that module, but also did not test it.

Pure effect of an independent variable on the dependent variable

I have a statistics course assignment regarding the "pure" effect of the mileage on second hand cars' sales price.
The dataset contains several factors which may affect the sales price of cars on an exchange website, including:
Year manufactured
Mileage
Make
Type (Sedan, Wagon, SUV, etc)
Color
Complete logbook service (Y/N)
Fuel efficiency
Seller Zip Code
My understanding of the analysis of the "pure" effect of one independent variable on the dependent variable should limit all the other variables as the same, as in same make, manufacturing year range, type, color, etc. However, if I do that just for a single combination of cars of the same characteristics, I'd give up many data points.
So what's the best approach to tackle this kind of problem? Should I do many sets of single-variable linear regressions between mileage and sales price on many combinations of similar cars and average the effect?
Sorry there isn't any data here. I just want to have a road map of solving the problem. Thanks very much.

Difference Between Sales Order and Purchase Order in the Transactions Table

So, I imagine this is a pretty elementary question I'm asking here.
But in relation to the Production.TransactionHistory table in the AdventureWorks 2017 dbo, whether the transcation type is a Sales Order or a Purchase Order, the Product Cost is the cost that Adventure Works incurred, correct?

Designing a domain model (class diagram) for a financial software [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
During my preparation for an exam in software engineering, I came across the following task in an old exam:
For a client, you create a new financial software whose task is, among other things, to perform tax calculations. The following requirements have been communicated to you by the Client:
The system must be able to:
calculate and display VAT for different countries and tax rates (Germany 19%, Austria 20%, Switzerland 8%).
calculate and display the income tax according to country-specific tax tables (separate table for Germany, Austria, Switzerland).
The system must allow the user to:
enter the tax relevant data (gross amount for VAT, annual income for income tax)
print the result of the tax calculation on a network printer.
send the result of the tax calculation to the appropriate tax office.
Task 1: Capture the requirements communicated by the client in a domain model (class diagram) with the following information: classes, attributes, methods, relationships, multiplicities, relationship name.
Solution:
I am not sure how to define the right classes, relationships and multiplicities. But I tried it and came to the following incomplete solution:
First Update:
Second Update:
Could someone help me with this? Thanks :)
Review of your diagram
I propose you to read your first diagram, and leave it as an exercise to cross-check if it really meets the requirements:
"A tax rate is composed of a country" (top composition). So countries do not exist independently of tax codes. Is this really what you meant? And does anything in the requirements tell that there is only one tax rate per country?
"A tax rate is composed of an (optional) income tax rate, and an (optional) VAT rate" (double composition in the middle). Ouh!?
"Every income tax rate has its own tax category(ies)" (bottom composition). Isn't the idea of categories to group similar income tax rates?
"A tax rate aggregates tax administrations, and a tax administration may appear in several aggregates" (aggregation). Why should an administration be aggregated in tax codes?
First recommentation: read in your course the difference between association, aggregation and composition. THe use of aggreegation and composition are in principle exceptional and there must be strong reasons to use use it.
Some more questions:
Where are the names of the relations?
What requirement justifies the tax administration? If it is justified, should'nt it be related to a country?
Is printing some elements really part of the domain model or does it already belong to some user-interface?
Second recommendation: only show elements taht you can reasonably derive from the requirements, and avoid any user-interface related behaviors.
Edit: your final diagram following our exchanges in the comment section represents much better what you wanted to represent initially. You could add the multiplicity 1..* rate for 1 category. You could also add a separator, in order to show classes consistently with a property and operation sections, even if one of the two is empty. The design is still basic, since all properties/attributes are public which is not recommended (but for I suppose you did this to avoid a lot of extra getters/setters in your design).
Alternate approach:
Your narrative describes one single use-case, which is perform tax calculation and consists of entering the calculation data, printing it and sending it. The actors are probably some clerc of your customer and perhaps tax offices.
I find the following candidates for classes chronologically, when reading the narrative: VAT, country, tax rate, income tax, "country-specific tax tables", gross amount, annual income, tax calculation, tax office. Let's have a closer look:
Tax office is very unclear: is there a network printer per tax office? how is the relevant tax office determined? are there one office per country, or can the organisation be more complex?
VAT and income tax are very different:
for VAT there are different rates per country. The applicable rate is always known, and the calculation is based on the applicable rate and the gross value.
For income tax the narrative speaks of country-specific tax tables: this means that the rate might not be known in advance, but depend on the taxable income level. (e.g. in Austria there is a minimum, and beyond it's flat rate; but in France, there is a normal rate, and a reduced rate for the first 500K€). In reality, income tax is much more complicated, since it may also depend on the legal form of the enterprise, or what is done with the income (re-invested vs. distributed), but let's keep it simple for the exercise. The wording leaves an ambiguity whether there is one table per country or several.
You could nevertheless generalize the concept of tax, if you'd want, considering in this exercise, that its amount is calculated for a base amount (gross amount or annual income).
The tax calculation is not fully clear: is it just the user interface, or is the calculation actually some domain object. This would give us:
This would lead to a diagram like:

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