alter table quote_letters add notes varchar(2000) not null default '' after num_line_items;

alter table purchase_order_items add quantity int(10) not null default 0 after name;
alter table purchase_order_items add description varchar(2000) not null default '' after quantity;

alter table purchase_orders add number varchar(14) not null default '' after id;

update purchase_orders set number = concat(2014, job_id, '-', id);

CREATE TABLE `invoice_items` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `job_id` int(11) unsigned NOT NULL,
  `line_number` smallint(5) unsigned NOT NULL DEFAULT '0',
  `name` varchar(255) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
  `description` varchar(2000) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
  `quantity` int(10) unsigned NOT NULL DEFAULT '0',
  `cost` decimal(9,2) unsigned NOT NULL DEFAULT '0.00',
  `insert_date` datetime NOT NULL,
  `change_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB;

CREATE TABLE `invoices` (
  `job_id` int(11) unsigned NOT NULL,
  `issue_date` date DEFAULT NULL,
  `payment_term_days` tinyint(3) unsigned DEFAULT NULL,
  `due_date` date DEFAULT NULL,
  `num_line_items` tinyint(4) unsigned NOT NULL,
  `notes` varchar(2000) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
  `postage_cost` decimal(9,2) unsigned NOT NULL DEFAULT '0.00',
  `postage_tax_cost` decimal(9,2) unsigned NOT NULL DEFAULT '0.00',
  `fulfillment_cost` decimal(9,2) unsigned NOT NULL,
  `fulfillment_tax_cost` decimal(9,2) unsigned NOT NULL,
  `shipping_cost` decimal(9,2) unsigned NOT NULL,
  `shipping_tax_cost` decimal(9,2) unsigned NOT NULL,
  `item_cost` decimal(9,2) unsigned NOT NULL DEFAULT '0.00',
  `subtotal` decimal(9,2) unsigned NOT NULL DEFAULT '0.00',
  `item_tax_cost` decimal(9,2) unsigned NOT NULL DEFAULT '0.00',
  `total_tax_cost` decimal(9,2) unsigned NOT NULL,
  `total` decimal(9,2) unsigned NOT NULL,
  `status` varchar(25) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
  `payment_amount` decimal(10,2) unsigned NOT NULL DEFAULT '0.00',
  `payment_date` date DEFAULT NULL,
  `payment_notes` varchar(2000) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
  `insert_date` datetime NOT NULL,
  `change_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`job_id`)
) ENGINE=InnoDB;