Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6050409
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T07:41:06+00:00 2026-05-23T07:41:06+00:00

An invoice can contain 1 or more orders, how to archive this? Example of

  • 0

An invoice can contain 1 or more orders, how to archive this?

Example of Invoice:

OrderID |      Order Date    |   Amount
   31            10/02/2011         £1.50
   43            12/02/2011         £1.50
   74            13/02/2011         £5.00
                                   =======
                            Total   £8.00 

If the Total is minus (eg: -8.00), it mean client owes me money.
Without minus, I pay client some money.

Here what I came up with:

Orders Table

CREATE TABLE IF NOT EXISTS `orders` (
  `OrderID` int(11) NOT NULL AUTO_INCREMENT,
  `Total` decimal(6,2) NOT NULL,
  `OrderDate` datetime NOT NULL,
  `Status` int(11) NOT NULL,
  `userID` int(11) NOT NULL,
  `InvoiceID` int(11) NOT NULL,
  PRIMARY KEY (`OrderID`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=4 ;

Invoice Table

CREATE TABLE IF NOT EXISTS `invoice` (
  `InvoiceID` int(11) NOT NULL DEFAULT '0',
  `InvoiceDate` datetime NOT NULL,
  `Amount` decimal(6,2) NOT NULL,
  `Status` int(11) NOT NULL,
  PRIMARY KEY (`InvoiceID`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

invoice.Status (0 Processing, 1 Invoice Sent, 2 Cancelled, 3 Completed)
or what better status can be?

Payment Table

CREATE TABLE IF NOT EXISTS `payment` (
  `PaymentID` int(11) NOT NULL AUTO_INCREMENT,
  `InvoiceID` int(11) NOT NULL,
  `Amount` decimal(6,2) NOT NULL,
  `DatePayment` datetime NOT NULL,
  `PaymentType` int(11) NOT NULL,
  PRIMARY KEY (`PaymentID`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;

payment.PaymentType = (1: Payment Received From Customer (Owes Money), 2: Payment Sent To Customer)

Database Result:

mysql> select * from orders;
+---------+-------+---------------------+--------+--------+-----------+
| OrderID | Total | OrderDate           | Status | userID | InvoiceID |
+---------+-------+---------------------+--------+--------+-----------+
|       1 | 20.00 | 2011-06-18 15:51:51 |      1 |    123 |         1 |
|       2 | 10.00 | 2011-06-19 15:51:57 |      1 |    123 |         1 |
|       3 |  5.00 | 2011-06-20 15:52:00 |      1 |    123 |         1 |
+---------+-------+---------------------+--------+--------+-----------+

mysql> select * from invoice;
+-----------+---------------------+--------+--------+
| InvoiceID | InvoiceDate         | Amount | Status |
+-----------+---------------------+--------+--------+
|         1 | 2011-06-30 15:55:21 |  35.00 |      1 |
+-----------+---------------------+--------+--------+

mysql> select * from payment;
+-----------+-----------+--------+---------------------+-------------+
| PaymentID | InvoiceID | Amount | DatePayment         | PaymentType |
+-----------+-----------+--------+---------------------+-------------+
|         1 |         1 |  35.00 | 2011-06-29 15:56:16 |           1 |
+-----------+-----------+--------+---------------------+-------------+

Im I on the right path? What can be improved/changed or suggestion?

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T07:41:06+00:00Added an answer on May 23, 2026 at 7:41 am

    Looks good.

    The only thing I would add are some details like transaction id / check number to the payment table. This way you keep all the payment details together.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In Magento you can cancel an order or invoice, and set it to a
I am using cakephp containable to retrieve related models $this->Order->find('first', array( 'conditions'=>$conditions, 'contain' =>
When using Drupal and UberCart, I can view an invoice by going to: admin/store/orders/10006/invoice,
i return such type IQueryable< IGrouping<int, Invoice>> List() how can i work with it?
My Invoice model has an address_id attribute, and I don't want this address_id to
this is my invoice table: Invoice Table: invoice_id creation_date due_date payment_date status enum('not paid','paid','expired')
This is a database design question. I want to build an invoice web application,
I have a heterogeneous List that can contain any arbitrary type of object. I
I want to create an invoice of every 2 week. An invoice can have
I need a way to create an invoice from multiple orders every month? In

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.