Solved

Design approach for invoice

Posted on 2008-10-20
6
296 Views
Last Modified: 2013-11-13
I have came across to several suggestions how to achieve the same thing, so I would like to hear from you what are your thought about it? I need it to compare with my thought to see if I am doing something the way t shouldnt be done.

Entities: Article, Buyer, Order, OrderDetails. Order - Buyer (1-0..1), Order-OrderDetails (1-m), OrderDetails-Article (1-1).

1) What design approach would you use, how would you connect them, what patterns would you use, etc?
2) Displaying all orders in a grid,, but having a total ammount column for each order - how would you handle this - strictly in OOP fashion

Thanks,
Goran
0
Comment
Question by:Priest04
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
6 Comments
 
LVL 12

Expert Comment

by:marklorenz
ID: 22769321
(1) Your design should support your requirements, including the ones you list in (2).  My suggested design from my retail experience (sorry if I've mistaken what some of your terms mean):

Inventory - collection of Articles for sale
InventoryItem - a type of Product for sale, e.g. a style of shirt from a particular manufacturer
Company - a business with Employees, including Buyers
Buyer - and Employee that handles PurchaseOrders to resupply the Inventory as sales are made
Article - a particular InventoryItem, with a size, location, markdown, ... associated with it; e.g. a medium green shirt in Warehouse B
Order - a collection of OrderLineItems made by a Buyer and sent to a Supplier
OrderLineItem - a purchase of a quantity of InventoryItems provided by a Supplier
Employee - a Role a Person takes when working for a Company

Inventory has zero or more Articles (what's in stock)
Article has one and only one InventoryItem
Company has zero or more Employees
Person has one or more Roles
Buyer is an Employee
Employee is a Role
Buyer has zero or more Orders
Supplier has one or more Articles
Order has one or more OrderLineItems

To do subtotals:
Each OrderLineItem.getTotal() gives the amount for a line item.
Order.getTotal() aggregates the OrderLineItems totals.

Mark
0
 
LVL 18

Author Comment

by:Priest04
ID: 22809456
Hello, marklorenz, sorry I havent respond sooner, higher forces.

Modelling is not the problem, Everything you have said about it stands, the problem is coding approach. AI will give you an example about Totals ou have mentioned. A requirement is to display orders. It should look like this:

Order Number      OrderDate      CustomerName      TotalAmmountOfOrder
________________________________________________________

1                           5/8/2008       SomeCustomer      19.254

AS it can be seen, data is from 3 Tables - Order, OrderDetails and Customer. There should be next options for displaying data

1) display ALL orders from ALL customers
2) display ALL order from ONE customer
3 display ALL orders in this month,
etc

Now, what coding approach should I take? Or better, what is the best practice? I am not interested in some workarounds, I know how to make it work, but I need best practice.

th easiest way, and with best perfrormance, would be to have an Entyti OrdersView and to create properties that needs to be displayed. Having a couple of methods like

GetOrdersForCustomer(int cusomerID)
GetOrdersForMonth(int month)
GetAllOrders()

some combination, etc. But I dont know if this is the best approach,
0
 
LVL 12

Accepted Solution

by:
marklorenz earned 500 total points
ID: 22889481
OK, sorry I didn't understand your dilemma the first time.  Let me try again.

The proper way to distribute responsibilities is to have the proper object handle the proper requests. So, in your example, let me postulate this design:

A Business has zero of more Customers.  Each Customer has zero or more Orders.  An Order is a temporal event - i.e. occurs at a particular point in time.  The Business has a calendar.

Given this, you would want to support something like:

aCustomer.getOutstandingOrders()
aBusiness.getOrderDuring( aTimePeriod )

A Customer knows it's ID, so no need to pass it in.  The time period can be a year, month, day, hour, minute, leveraging Java classes like GregorianCalendar.

In this way, you ask the proper object, like a Customer, for information about that object, like all outstanding Orders.

Let me know if this satisfies your questions.
0
 
LVL 18

Author Comment

by:Priest04
ID: 22900706
Thanks for sharing your thoughts, marklorenz.

Goran
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Great Plain (GP 2013) 8 100
Documentation Migration from AD 2003 to AD 2012 Urgent 3 121
MS Project Critical Path 4 114
Which version of Microsoft Project does my client need? 3 162
Cobalt Digital Marketing began using the Scrum Framework development process in summer 2009.  We hired a consultant to train the teams, observe meetings, and answer questions. He recommended that we begin using one-week sprints for several reason…
In Agile (http://en.wikipedia.org/wiki/Agile_software_development), time and again people ask this question "How would you estimate a release for a product?". When it comes from management they want to know the following: Calculate the man hours wh…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question