From 89493989c124c24cc6f22de978eef0df72800e23 Mon Sep 17 00:00:00 2001
From: Peter Hormanns <peter.hormanns@jalin.de>
Date: Tue, 30 Apr 2013 12:03:19 +0200
Subject: [PATCH] remove not needed database tables

---
 hsarback/database/database_update.sql                     |   41 ++++++
 /dev/null                                                 |  179 -----------------------------
 hsarback/database/schema.sql                              |   73 ++----------
 hsarback/src/de/hsadmin/mods/cust/Customer.java           |   11 -
 hsarback/database/data.sql                                |    6 -
 hsarback/database/dropschema.sql                          |    2 
 hsarback/src/de/hsadmin/mods/dom/DomainOptionValues.java  |    2 
 hsarback/src/de/hsadmin/mods/cust/CustomerModuleImpl.java |    5 
 hsarback/src/de/hsadmin/mods/cust/BankAccount.java        |   16 +-
 9 files changed, 58 insertions(+), 277 deletions(-)

diff --git a/hsarback/database/data.sql b/hsarback/database/data.sql
index e359fd1..4aa7a45 100644
--- a/hsarback/database/data.sql
+++ b/hsarback/database/data.sql
@@ -86,12 +86,6 @@
 	SELECT bp_id, false, false, false, '', '', '', '' FROM business_partner WHERE member_id=10000;
 
 --
--- table: billdata 
---
-INSERT INTO billdata (bp_id)
-	SELECT bp_id FROM business_partner WHERE member_id=10000;
-
---
 -- Table: inet_addr 
 --
 INSERT INTO inet_addr (inet_addr, description)
diff --git a/hsarback/database/database_update.sql b/hsarback/database/database_update.sql
index 1d70974..0da723a 100644
--- a/hsarback/database/database_update.sql
+++ b/hsarback/database/database_update.sql
@@ -26,11 +26,42 @@
 UPDATE bank_account SET autodebit_op = false WHERE autodebit_op IS NULL;
 ALTER TABLE bank_account ALTER COLUMN autodebit_op SET NOT NULL;
 
-ALTER TABLE basepacket ADD COLUMN article_number integer NOT NULL DEFAULT 1;
+ALTER TABLE business_partner ADD COLUMN free boolean NOT NULL DEFAULT false;
+ALTER TABLE business_partner ADD COLUMN indicator_vat character varying(20) NOT NULL DEFAULT 'GROSS';
+ALTER TABLE business_partner ADD COLUMN exempt_vat boolean NOT NULL DEFAULT false;
+ALTER TABLE business_partner ADD UNIQUE(bp_id);
+ 
+DROP TABLE billdata CASCADE;
+
+ALTER TABLE basepacket ADD COLUMN article_number integer NOT NULL DEFAULT 0;
 ALTER TABLE basepacket ALTER COLUMN article_number DROP DEFAULT;
 
-ALTER TABLE component ADD COLUMN article_number integer NOT NULL DEFAULT 1;
+ALTER TABLE component ADD COLUMN article_number integer NOT NULL DEFAULT 0;
 ALTER TABLE component ALTER COLUMN article_number DROP DEFAULT;
+ALTER TABLE component DROP CONSTRAINT ckt_component;
+ALTER TABLE component 
+	ADD CONSTRAINT ckt_component CHECK (
+    	(0 <= min_quantity) AND 
+    	(min_quantity <= default_quantity) AND 
+    	(default_quantity <= max_quantity) AND 
+    	(include_quantity <= default_quantity) AND 
+    	(0 <= include_quantity) AND 
+    	(mod(min_quantity, increment_quantity) = 0) AND 
+    	(mod(max_quantity, increment_quantity) = 0) AND 
+    	(mod(default_quantity, increment_quantity) = 0) AND 
+    	(mod(include_quantity, increment_quantity) = 0)
+    );
+
+ALTER TABLE packet DROP COLUMN order_number;
+ALTER TABLE packet DROP COLUMN webserver_group;
+
+ALTER TABLE domain DROP COLUMN domain_status;
+ALTER TABLE domain DROP COLUMN domain_status_changed;
+ALTER TABLE domain DROP COLUMN domain_filed;
+ALTER TABLE domain DROP COLUMN domain_until;
+ALTER TABLE domain DROP COLUMN domain_reminder;
+ALTER TABLE domain DROP COLUMN domain_free;
+ALTER TABLE domain DROP COLUMN domain_template;
 
 CREATE TABLE price_list (
   id serial PRIMARY KEY,                                                                   
@@ -43,7 +74,8 @@
 	price_list integer REFERENCES price_list(id),
 	PRIMARY KEY (customer, price_list)
 );
-INSERT INTO customer_price_list_mapping (SELECT bp_id, 1 FROM business_partner);
+INSERT INTO customer_price_list_mapping 
+	(SELECT bp_id, (SELECT id FROM price_list WHERE name LIKE 'Default%') FROM business_partner);
 
 CREATE TABLE price (                                                                
 	id serial PRIMARY KEY,
@@ -52,5 +84,6 @@
 	vat decimal(4,2) NOT NULL,
 	price_list integer REFERENCES price_list(id)                                             
 );
-INSERT INTO price VALUES (1, 0, 0, 0, 1); 
+INSERT INTO price (article_number, price, vat, price_list) 
+	VALUES (0, 0, 0, (SELECT id FROM price_list WHERE name LIKE 'Default%')); 
 
diff --git a/hsarback/database/dropschema.sql b/hsarback/database/dropschema.sql
index 5acf9e3..a2f5486 100644
--- a/hsarback/database/dropschema.sql
+++ b/hsarback/database/dropschema.sql
@@ -3,8 +3,6 @@
 DROP TABLE price_list ;
 DROP TABLE bank_account ;
 DROP SEQUENCE bank_account_bank_account_id_seq ;
-DROP TABLE billdata ;
-DROP SEQUENCE billdata_billdata_id_seq ;
 DROP TABLE contact ;
 DROP SEQUENCE contact_contact_id_seq ;
 DROP TABLE database ;
diff --git a/hsarback/database/schema.sql b/hsarback/database/schema.sql
index 33d435f..089fbdd 100644
--- a/hsarback/database/schema.sql
+++ b/hsarback/database/schema.sql
@@ -5,13 +5,14 @@
 CREATE TABLE bank_account (
     bank_account_id integer DEFAULT nextval(('"bank_account_bank_account_id_seq"'::text)::regclass) NOT NULL,
     bp_id integer NOT NULL,
-    autodebit_ga boolean NOT NULL DEFAULT false,
-    autodebit_ar boolean NOT NULL DEFAULT false,
-    autodebit_op boolean NOT NULL DEFAULT false,
-    bank_customer character varying(50) NOT NULL DEFAULT '',
-    bank_account character varying(10) NOT NULL DEFAULT '',
-    bank_code character varying(8) NOT NULL DEFAULT '',
-    bank_name character varying(50) NOT NULL DEFAULT ''
+    autodebit_ga boolean NOT NULL,
+    autodebit_ar boolean NOT NULL,
+    autodebit_op boolean NOT NULL,
+    bank_customer character varying(50),
+    bank_account character varying(10),
+    bank_code character varying(8),
+    bank_name character varying(50),
+    CONSTRAINT ckt_bank_account CHECK (((((((bank_customer IS NOT NULL) AND (bank_account IS NOT NULL)) AND (bank_code IS NOT NULL)) AND (bank_name IS NOT NULL)) AND (((autodebit_ga = true) OR (autodebit_ar = true)) OR (autodebit_op = true))) OR (((autodebit_ga = false) AND (autodebit_ar = false)) AND (autodebit_op = false))))
 );
 
 
@@ -76,35 +77,6 @@
 
 
 --
--- Name: billdata; Type: TABLE; Schema: public; Owner: -; Tablespace: 
---
-
-CREATE TABLE billdata (
-    billdata_id integer DEFAULT nextval(('"billdata_billdata_id_seq"'::text)::regclass) NOT NULL,
-    bp_id integer NOT NULL,
-    tariff_domain_discount_since date,
-    tariff_domain_discount_until date,
-    tariff_traffic_discount_since date,
-    tariff_traffic_discount_until date,
-    tariff_quota_discount_since date,
-    tariff_quota_discount_until date,
-    tariff_discount_since date,
-    tariff_discount_until date
-);
-
-
---
--- Name: billdata_billdata_id_seq; Type: SEQUENCE; Schema: public; Owner: -
---
-
-CREATE SEQUENCE billdata_billdata_id_seq
-    INCREMENT BY 1
-    NO MAXVALUE
-    NO MINVALUE
-    CACHE 1;
-
-
---
 -- Name: business_partner; Type: TABLE; Schema: public; Owner: -; Tablespace: 
 --
 
@@ -156,10 +128,12 @@
     include_quantity integer NOT NULL,
     admin_only boolean NOT NULL,
     CONSTRAINT ckt_component CHECK (
-    	(min_quantity <= max_quantity) AND 
+    	(0 <= min_quantity) AND 
     	(min_quantity <= default_quantity) AND 
     	(default_quantity <= max_quantity) AND 
-    	(include_quantity <= max_quantity) AND 
+    	(include_quantity <= default_quantity) AND 
+    	(0 <= include_quantity) AND 
+    	(mod(min_quantity, increment_quantity) = 0) AND 
     	(mod(max_quantity, increment_quantity) = 0) AND 
     	(mod(default_quantity, increment_quantity) = 0) AND 
     	(mod(include_quantity, increment_quantity) = 0)
@@ -563,14 +537,6 @@
 
 
 --
--- Name: pk_billdata; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
---
-
-ALTER TABLE ONLY billdata
-    ADD CONSTRAINT pk_billdata PRIMARY KEY (billdata_id);
-
-
---
 -- Name: pk_business_partner; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
 --
 
@@ -677,13 +643,6 @@
 --
 
 CREATE UNIQUE INDEX basepacket_in_1 ON basepacket USING btree (basepacket_code);
-
-
---
--- Name: billdata_in_1; Type: INDEX; Schema: public; Owner: -; Tablespace: 
---
-
-CREATE UNIQUE INDEX billdata_in_1 ON billdata USING btree (bp_id);
 
 
 --
@@ -853,14 +812,6 @@
 
 ALTER TABLE ONLY component
     ADD CONSTRAINT fk_bcomp_bpack FOREIGN KEY (basepacket_id) REFERENCES basepacket(basepacket_id) ON UPDATE RESTRICT ON DELETE RESTRICT;
-
-
---
--- Name: fk_billdata_reference_business; Type: FK CONSTRAINT; Schema: public; Owner: -
---
-
-ALTER TABLE ONLY billdata
-    ADD CONSTRAINT fk_billdata_reference_business FOREIGN KEY (bp_id) REFERENCES business_partner(bp_id) ON UPDATE RESTRICT ON DELETE RESTRICT;
 
 
 --
diff --git a/hsarback/src/de/hsadmin/mods/cust/BankAccount.java b/hsarback/src/de/hsadmin/mods/cust/BankAccount.java
index 725a286..07477a4 100644
--- a/hsarback/src/de/hsadmin/mods/cust/BankAccount.java
+++ b/hsarback/src/de/hsadmin/mods/cust/BankAccount.java
@@ -41,17 +41,17 @@
 	@Column(name = "autodebit_op", columnDefinition = "boolean", nullable = false)
 	private Boolean autoDebitOP = Boolean.FALSE;
 
-	@Column(name = "bank_customer", columnDefinition = "character varying(50)", nullable = false)
-	private String bankCustomer = "";
+	@Column(name = "bank_customer", columnDefinition = "character varying(50)")
+	private String bankCustomer;
 
-	@Column(name = "bank_account", columnDefinition = "character varying(10)", nullable = false)
-	private String bankAccount = "";
+	@Column(name = "bank_account", columnDefinition = "character varying(10)")
+	private String bankAccount;
 
-	@Column(name = "bank_code", columnDefinition = "character varying(8)", nullable = false)
-	private String bankCode = "";
+	@Column(name = "bank_code", columnDefinition = "character varying(8)")
+	private String bankCode;
 
-	@Column(name = "bank_name", columnDefinition = "character varying(50)", nullable = false)
-	private String bankName = "";
+	@Column(name = "bank_name", columnDefinition = "character varying(50)")
+	private String bankName;
 
 	public static String createQueryFromStringKey(String humanKey) {
 		return "customer.name = " + humanKey;
diff --git a/hsarback/src/de/hsadmin/mods/cust/Customer.java b/hsarback/src/de/hsadmin/mods/cust/Customer.java
index 41d2a5a..3d87efe 100644
--- a/hsarback/src/de/hsadmin/mods/cust/Customer.java
+++ b/hsarback/src/de/hsadmin/mods/cust/Customer.java
@@ -96,9 +96,6 @@
 	@OneToOne(fetch = EAGER, cascade = ALL, mappedBy = "customer")
 	private BankAccount bankAccount;
 
-	@OneToOne(fetch = EAGER, cascade = ALL, mappedBy = "customer")
-	private CustomersTariff billData;
-
 	@OneToMany(fetch = LAZY, cascade = ALL, mappedBy = "customer")
 	@OrderBy("name")
 	private Set<Pac> pacs;
@@ -242,14 +239,6 @@
 
 	public void setBankAccount(BankAccount bankAccount) {
 		this.bankAccount = bankAccount;
-	}
-
-	public CustomersTariff getBillData() {
-		return billData;
-	}
-
-	public void setBillData(CustomersTariff tariff) {
-		this.billData = tariff;
 	}
 
 	public Set<Pac> getPacs() {
diff --git a/hsarback/src/de/hsadmin/mods/cust/CustomerModuleImpl.java b/hsarback/src/de/hsadmin/mods/cust/CustomerModuleImpl.java
index aca3596..d961137 100644
--- a/hsarback/src/de/hsadmin/mods/cust/CustomerModuleImpl.java
+++ b/hsarback/src/de/hsadmin/mods/cust/CustomerModuleImpl.java
@@ -37,11 +37,6 @@
 			bankAccount.setCustomer(newCustomer);
 			newCustomer.setBankAccount(bankAccount);
 		}
-		CustomersTariff billData = newCustomer.getBillData();
-		if (billData == null) {
-			billData = new CustomersTariff(newCustomer);
-			newCustomer.setBillData(billData);
-		}
 		GenericModuleImpl helperModule = new GenericModuleImpl(getTransaction());
 		UnixUser custAccount = new UnixUser();
 		custAccount.setComment(TextUtil.replaceUmlautCharacters(custComment));
diff --git a/hsarback/src/de/hsadmin/mods/cust/CustomersTariff.java b/hsarback/src/de/hsadmin/mods/cust/CustomersTariff.java
deleted file mode 100644
index 73e811a..0000000
--- a/hsarback/src/de/hsadmin/mods/cust/CustomersTariff.java
+++ /dev/null
@@ -1,179 +0,0 @@
-package de.hsadmin.mods.cust;
-
-import static javax.persistence.FetchType.EAGER;
-
-import java.io.Serializable;
-import java.util.Date;
-
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.EntityManager;
-import javax.persistence.GeneratedValue;
-import javax.persistence.GenerationType;
-import javax.persistence.Id;
-import javax.persistence.JoinColumn;
-import javax.persistence.OneToOne;
-import javax.persistence.Table;
-import javax.persistence.Temporal;
-
-import de.hsadmin.core.model.AbstractEntity;
-import de.hsadmin.mods.user.UnixUser;
-
-@Entity(name = "CustomersTariffs")
-@Table(name = "billdata")
-public class CustomersTariff extends AbstractEntity implements Serializable {
-	
-	private static final long serialVersionUID = -3628577459027111705L;
-
-	@Id
-	@GeneratedValue(strategy = GenerationType.IDENTITY)
-	@Column(name = "billdata_id", columnDefinition = "integer")
-	private long id;
-
-	@JoinColumn(name = "bp_id", columnDefinition = "integer")
-	@OneToOne(fetch = EAGER)
-	private Customer customer;
-
-	@Column(name = "tariff_domain_discount_since", columnDefinition = "date")
-	@Temporal(javax.persistence.TemporalType.DATE)
-	private Date domainDiscountSince;
-
-	@Column(name = "tariff_domain_discount_until", columnDefinition = "date")
-	@Temporal(javax.persistence.TemporalType.DATE)
-	private Date domainDiscountUntil;
-
-	@Column(name = "tariff_traffic_discount_since", columnDefinition = "date")
-	@Temporal(javax.persistence.TemporalType.DATE)
-	private Date trafficDiscountSince;
-
-	@Column(name = "tariff_traffic_discount_until", columnDefinition = "date")
-	@Temporal(javax.persistence.TemporalType.DATE)
-	private Date trafficDiscountUntil;
-
-	@Column(name = "tariff_quota_discount_since", columnDefinition = "date")
-	@Temporal(javax.persistence.TemporalType.DATE)
-	private Date quotaDiscountSince;
-
-	@Column(name = "tariff_quota_discount_until", columnDefinition = "date")
-	@Temporal(javax.persistence.TemporalType.DATE)
-	private Date quotaDiscountUntil;
-
-	@Column(name = "tariff_discount_since", columnDefinition = "date")
-	@Temporal(javax.persistence.TemporalType.DATE)
-	private Date discountSince;
-
-	@Column(name = "tariff_discount_until", columnDefinition = "date")
-	@Temporal(javax.persistence.TemporalType.DATE)
-	private Date discountUntil;
-
-	public CustomersTariff() {
-	}
-
-	public CustomersTariff(Customer cust) {
-		this.customer = cust;
-	}
-
-	public static String createQueryFromStringKey(String humanKey) {
-		return "customer.name = '" + humanKey + "'";
-	}
-
-	@Override
-	public String createStringKey() {
-		return getCustomer().getName();
-	}
-
-	@Override
-	public long id() {
-		return id;
-	}
-
-	public long getId() {
-		return id;
-	}
-
-	public void setId(long id) {
-		this.id = id;
-	}
-
-	public Customer getCustomer() {
-		return customer;
-	}
-
-	public void setCustomer(Customer customer) {
-		this.customer = customer;
-	}
-
-	public Date getDomainDiscountSince() {
-		return domainDiscountSince;
-	}
-
-	public void setDomainDiscountSince(Date domainDiscountSince) {
-		this.domainDiscountSince = domainDiscountSince;
-	}
-
-	public Date getDomainDiscountUntil() {
-		return domainDiscountUntil;
-	}
-
-	public void setDomainDiscountUntil(Date domainDiscountUntil) {
-		this.domainDiscountUntil = domainDiscountUntil;
-	}
-
-	public Date getTrafficDiscountSince() {
-		return trafficDiscountSince;
-	}
-
-	public void setTrafficDiscountSince(Date trafficDiscountSince) {
-		this.trafficDiscountSince = trafficDiscountSince;
-	}
-
-	public Date getTrafficDiscountUntil() {
-		return trafficDiscountUntil;
-	}
-
-	public void setTrafficDiscountUntil(Date trafficDiscountUntil) {
-		this.trafficDiscountUntil = trafficDiscountUntil;
-	}
-
-	public Date getQuotaDiscountSince() {
-		return quotaDiscountSince;
-	}
-
-	public void setQuotaDiscountSince(Date quotaDiscountSince) {
-		this.quotaDiscountSince = quotaDiscountSince;
-	}
-
-	public Date getQuotaDiscountUntil() {
-		return quotaDiscountUntil;
-	}
-
-	public void setQuotaDiscountUntil(Date quotaDiscountUntil) {
-		this.quotaDiscountUntil = quotaDiscountUntil;
-	}
-
-	public Date getDiscountSince() {
-		return discountSince;
-	}
-
-	public void setDiscountSince(Date discountSince) {
-		this.discountSince = discountSince;
-	}
-
-	public Date getDiscountUntil() {
-		return discountUntil;
-	}
-
-	public void setDiscountUntil(Date discountUntil) {
-		this.discountUntil = discountUntil;
-	}
-
-	@Override
-	public boolean isNew() {
-		return id == 0;
-	}
-
-	@Override
-	public UnixUser owningUser(EntityManager em) {
-		return customer.owningUser(em);
-	}
-}
diff --git a/hsarback/src/de/hsadmin/mods/dom/DomainOptionValues.java b/hsarback/src/de/hsadmin/mods/dom/DomainOptionValues.java
index 8854de5..3018fe3 100644
--- a/hsarback/src/de/hsadmin/mods/dom/DomainOptionValues.java
+++ b/hsarback/src/de/hsadmin/mods/dom/DomainOptionValues.java
@@ -24,7 +24,7 @@
 		list.add(new BooleanListValue("includes"));
 		list.add(new BooleanListValue("indexes"));
 		list.add(new BooleanListValue("multiviews"));
-		list.add(new BooleanListValue("php"));
+//		list.add(new BooleanListValue("php"));
 		return list;
 	}
 

--
Gitblit v1.9.0-SNAPSHOT