From d1cee3ebd0c0b20896b8189f56f0c4885a06bb4c Mon Sep 17 00:00:00 2001
From: einhverfr <einhverfr@4979c152-3d1c-0410-bac9-87ea11338e46>
Date: Fri, 4 Jan 2008 17:59:41 +0000
Subject: New tables by David Mora for payment tracking

git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/trunk@2027 4979c152-3d1c-0410-bac9-87ea11338e46
---
 sql/Pg-database.sql | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

(limited to 'sql/Pg-database.sql')

diff --git a/sql/Pg-database.sql b/sql/Pg-database.sql
index bcb4ff8d..1fedb884 100644
--- a/sql/Pg-database.sql
+++ b/sql/Pg-database.sql
@@ -724,6 +724,34 @@ CREATE TABLE ap (
 
 COMMENT ON COLUMN ap.entity_id IS $$ Used to be customer_id, but customer is now metadata. You need to push to entity $$;
 
+-- Payment stuff by David Mora
+
+CREATE TABLE payment (
+  id serial primary key,
+  reference text NOT NULL,
+  payment_class integer NOT NULL,
+  amount numeric NOT NULL,
+  payment_date date default current_date,
+  closed bool default FALSE,
+  person_id integer references person(id),
+  currency char(3),
+  notes text,
+  department_id integer default 0);
+
+COMMENT ON TABLE payment IS $$ This table will store the main data on a payment, prepayment, overpayment, etc... $$;
+COMMENT ON COLUMN payment.reference IS $$ This field will store the code for both receipts and payment orders, it will be differentiate by payment_class  $$;
+COMMENT ON COLUMN payment.closed IS $$ This will store the current state of a payment/receipt order $$;
+CREATE  INDEX payment_id_idx ON Payment(id);
+
+CREATE TABLE payment_links (
+  payment_id integer references Payment(id),
+  transaction_id integer NOT NULL,
+  amount numeric);
+COMMENT ON TABLE payment_links IS $$ This table will link payment to ar/ap transactions $$;
+COMMENT ON COLUMN payment_links.transaction_id IS $$ This column lacks some data integrity controls that must be implemented in the future $$;
+  
+
+
 --
 CREATE TABLE taxmodule (
   taxmodule_id serial PRIMARY KEY,
-- 
cgit v1.2.3

