Solved

Design approach for invoice

Posted on 2008-10-20
6
287 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
  • 2
  • 2
6 Comments
 
LVL 12

Expert Comment

by:marklorenz
Comment Utility
(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
Comment Utility
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
Comment Utility
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
Comment Utility
Thanks for sharing your thoughts, marklorenz.

Goran
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

As an accountant it is essential that I am able to provide accurate and timely information to management and staff.  One of the challenges that I have faced is the need to report on a time period, whether it be a month, quarter, or year, and wanting…
You can provide a virtual interface for remote stakeholders in a SWOT analysis through a Google Drawing template. By making real time viewing and collaboration possible, your team can build a stronger product.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

743 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now