• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 313
  • Last Modified:

Design approach for invoice

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

  • 2
  • 2
1 Solution
(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.

Priest04Author Commented:
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,

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)

some combination, etc. But I dont know if this is the best approach,
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:

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.
Priest04Author Commented:
Thanks for sharing your thoughts, marklorenz.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now