diff --git a/pom.xml b/pom.xml
new file mode 100644
index 000000000..b3c570e66
--- /dev/null
+++ b/pom.xml
@@ -0,0 +1,64 @@
+
+
+ 4.0.0
+
+ org.springframework.boot
+ spring-boot-starter-parent
+ 2.2.9.RELEASE
+
+
+ com.orders
+ orders
+ 0.0.1-SNAPSHOT
+ orders
+ Demo project for Spring Boot
+
+
+ 14
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter-data-jpa
+
+
+ org.springframework.boot
+ spring-boot-starter-web
+
+
+
+ org.springframework.boot
+ spring-boot-devtools
+ runtime
+ true
+
+
+ com.h2database
+ h2
+
+
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
+
+ org.junit.vintage
+ junit-vintage-engine
+
+
+
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+
+
+
+
+
diff --git a/src/main/java/com/orders/OrdersApplication.java b/src/main/java/com/orders/OrdersApplication.java
new file mode 100644
index 000000000..8a5dc96a9
--- /dev/null
+++ b/src/main/java/com/orders/OrdersApplication.java
@@ -0,0 +1,13 @@
+package com.orders;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+@SpringBootApplication
+public class OrdersApplication {
+
+ public static void main(String[] args) {
+ SpringApplication.run(OrdersApplication.class, args);
+ }
+
+}
\ No newline at end of file
diff --git a/src/main/java/com/orders/SeedData.java b/src/main/java/com/orders/SeedData.java
new file mode 100644
index 000000000..01bc6ba0a
--- /dev/null
+++ b/src/main/java/com/orders/SeedData.java
@@ -0,0 +1,4 @@
+package com.orders;
+
+public class SeedData {
+}
\ No newline at end of file
diff --git a/src/main/java/com/orders/config/H2ServerConfiguration.java b/src/main/java/com/orders/config/H2ServerConfiguration.java
new file mode 100644
index 000000000..c94c9355a
--- /dev/null
+++ b/src/main/java/com/orders/config/H2ServerConfiguration.java
@@ -0,0 +1,74 @@
+package src.main.java.com.orders.config;
+
+
+import org.h2.tools.Server;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+import java.sql.SQLException;
+
+/**
+ * Configures H2 access through the JetBrains IntelliJ IDEA IDE.
+ *
+ * Adapted from https://techdev.io/en/developer-blog/querying-the-embedded-h2-database-of-a-spring-boot-application
+ * necessary for using the database tool built into intellij
+ */
+@Configuration
+public class H2ServerConfiguration
+{
+
+ /**
+ * TCP port for remote connections, default 9092.
+ */
+ @Value("${h2.tcp.port:9092}")
+ private String h2TcpPort;
+
+ /**
+ * Web port, default 8082.
+ */
+ @Value("${h2.web.port:8082}")
+ private String h2WebPort;
+
+ /**
+ * TCP connection to connect with SQL clients to the embedded h2 database.
+ *
+ * Connect to "jdbc:h2:tcp://localhost:9092/mem:testdb", username "sa", password empty.
+ *
+ * @return The created TcpServer needed to access H2.
+ * @throws SQLException If the server cannot be created.
+ */
+ @Bean
+ @ConditionalOnExpression("${h2.tcp.enabled:true}")
+ public Server h2TcpServer() throws
+ SQLException
+ {
+ return Server.createTcpServer("-tcp",
+ "-tcpAllowOthers",
+ "-tcpPort",
+ h2TcpPort)
+ .start();
+ }
+
+ /**
+ * Web console for the embedded h2 database.
+ *
+ * Go to http://localhost:8082 and connect to the database "jdbc:h2:mem:testdb", username "sa", password empty.
+ *
+ * @return The created web server needed to access H2.
+ * @throws SQLException If the server cannot be created.
+ */
+ @Bean
+ @ConditionalOnExpression("${h2.web.enabled:true}")
+ public Server h2WebServer() throws
+ SQLException
+ {
+ return Server.createWebServer("-web",
+ "-webAllowOthers",
+ "-webPort",
+ h2WebPort)
+ .start();
+ }
+}
+
diff --git a/src/main/java/com/orders/models/Agent.java b/src/main/java/com/orders/models/Agent.java
new file mode 100644
index 000000000..5618264d0
--- /dev/null
+++ b/src/main/java/com/orders/models/Agent.java
@@ -0,0 +1,82 @@
+package com.orders.models;
+
+import javax.persistence.*;
+import java.util.ArrayList;
+import java.util.List;
+
+@Entity
+@Table(name = "agents")
+public class Agent {
+
+ @Id
+ @GeneratedValue(strategy = GenerationType.AUTO)
+ private long agentcode;
+ private String agentname;
+ private String workingarea;
+ private double commission;
+ private String phone;
+ private String country;
+
+ @OneToMany(mappedBy = "agent", cascade = CascadeType.ALL, orphanRemoval = true)
+ private List customers = new ArrayList<>();
+
+ public Agent(){
+
+ }
+
+ public Agent(String agentname, String workingarea, double commission, String phone, String country) {
+ this.agentname = agentname;
+ this.workingarea = workingarea;
+ this.commission = commission;
+ this.phone = phone;
+ this.country = country;
+ }
+
+ public long getAgentcode() {
+ return agentcode;
+ }
+
+ public void setAgentcode(long agentcode) {
+ this.agentcode = agentcode;
+ }
+
+ public String getAgentname() {
+ return agentname;
+ }
+
+ public void setAgentname(String agentname) {
+ this.agentname = agentname;
+ }
+
+ public String getWorkingarea() {
+ return workingarea;
+ }
+
+ public void setWorkingarea(String workingarea) {
+ this.workingarea = workingarea;
+ }
+
+ public double getCommission() {
+ return commission;
+ }
+
+ public void setCommission(double commission) {
+ this.commission = commission;
+ }
+
+ public String getPhone() {
+ return phone;
+ }
+
+ public void setPhone(String phone) {
+ this.phone = phone;
+ }
+
+ public String getCountry() {
+ return country;
+ }
+
+ public void setCountry(String country) {
+ this.country = country;
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/com/orders/models/Customer.java b/src/main/java/com/orders/models/Customer.java
new file mode 100644
index 000000000..0470a2e73
--- /dev/null
+++ b/src/main/java/com/orders/models/Customer.java
@@ -0,0 +1,151 @@
+package com.orders.models;
+
+import javax.persistence.*;
+import java.util.ArrayList;
+import java.util.List;
+
+@Entity
+@Table( name = "customers")
+public class Customer {
+
+ @Id
+ @GeneratedValue(strategy = GenerationType.AUTO)
+ @Column(nullable = false)
+ private long custcode;
+
+ @Column(nullable = false)
+ private String custname;
+
+ private String custcity;
+ private String workingarea;
+ private String custcountry;
+ private String grade;
+ private double openingamt;
+ private double receiveamt;
+ private double paymentamt;
+ private double outstandingamt;
+ private String phone;
+
+ @ManyToOne
+ @JoinColumn(name = "agentcode", nullable = false)
+ private Agent agent;
+
+ @OneToMany(mappedBy = "customer", cascade = CascadeType.ALL, orphanRemoval = true)
+ private List orders = new ArrayList<>();
+
+ public Customer(){
+
+ }
+
+ public Customer(String custname, String custcity, String workingarea,
+ String custcountry, String grade, double openingamt,
+ double receiveamt, double paymentamt,
+ double outstandingamt, String phone, Agent agent) {
+ this.custname = custname;
+ this.custcity = custcity;
+ this.workingarea = workingarea;
+ this.custcountry = custcountry;
+ this.grade = grade;
+ this.receiveamt = receiveamt;
+ this.paymentamt = paymentamt;
+ this.outstandingamt = outstandingamt;
+ this.phone = phone;
+ this.agent = agent;
+ }
+
+ public Agent getAgent() {
+ return agent;
+ }
+
+ public void setAgent(Agent agent) {
+ this.agent = agent;
+ }
+
+ public long getCustcode() {
+ return custcode;
+ }
+
+ public void setCustcode(long custcode) {
+ this.custcode = custcode;
+ }
+
+ public String getCustname() {
+ return custname;
+ }
+
+ public void setCustname(String custname) {
+ this.custname = custname;
+ }
+
+ public String getCustcity() {
+ return custcity;
+ }
+
+ public void setCustcity(String custcity) {
+ this.custcity = custcity;
+ }
+
+ public String getWorkingarea() {
+ return workingarea;
+ }
+
+ public void setWorkingarea(String workingarea) {
+ this.workingarea = workingarea;
+ }
+
+ public String getCustcountry() {
+ return custcountry;
+ }
+
+ public void setCustcountry(String custcountry) {
+ this.custcountry = custcountry;
+ }
+
+ public String getGrade() {
+ return grade;
+ }
+
+ public void setGrade(String grade) {
+ this.grade = grade;
+ }
+
+ public double getOpeningamt() {
+ return openingamt;
+ }
+
+ public void setOpeningamt(double openingamt) {
+ this.openingamt = openingamt;
+ }
+
+ public double getReceiveamt() {
+ return receiveamt;
+ }
+
+ public void setReceiveamt(double receiveamt) {
+ this.receiveamt = receiveamt;
+ }
+
+ public double getPaymentamt() {
+ return paymentamt;
+ }
+
+ public void setPaymentamt(double paymentamt) {
+ this.paymentamt = paymentamt;
+ }
+
+ public double getOutstandingamt() {
+ return outstandingamt;
+ }
+
+ public void setOutstandingamt(double outstandingamt) {
+ this.outstandingamt = outstandingamt;
+ }
+
+ public String getPhone() {
+ return phone;
+ }
+
+ public void setPhone(String phone) {
+ this.phone = phone;
+ }
+}
diff --git a/src/main/java/com/orders/models/Order.java b/src/main/java/com/orders/models/Order.java
new file mode 100644
index 000000000..00532287f
--- /dev/null
+++ b/src/main/java/com/orders/models/Order.java
@@ -0,0 +1,85 @@
+package com.orders.models;
+
+import javax.persistence.*;
+import java.util.HashSet;
+import java.util.Set;
+
+@Entity
+@Table(name = "orders")
+public class Order {
+
+ @Id
+ @GeneratedValue(strategy = GenerationType.AUTO)
+ private long ordnum;
+
+ private double ordamount;
+ private double advanceamount;
+ private String orderdescription;
+
+ @ManyToOne
+ @JoinColumn(name = "custcode", nullable = false)
+ private Customer customer;
+
+ @ManyToMany
+ @JoinTable(name = "orderspayments",joinColumns = @JoinColumn(name =
+ "ordnum"), inverseJoinColumns = @JoinColumn(name = "paymentid"))
+ private Set payments = new HashSet<>();
+
+ public Order(){
+
+ }
+
+ public Order(double ordamount, double advanceamount, String orderdescription) {
+ this.ordamount = ordamount;
+ this.advanceamount = advanceamount;
+ this.orderdescription = orderdescription;
+ }
+
+ public long getOrdnum() {
+ return ordnum;
+ }
+
+ public void setOrdnum(long ordnum) {
+ this.ordnum = ordnum;
+ }
+
+ public double getOrdamount() {
+ return ordamount;
+ }
+
+ public void setOrdamount(double ordamount) {
+ this.ordamount = ordamount;
+ }
+
+ public double getAdvanceamount() {
+ return advanceamount;
+ }
+
+ public void setAdvanceamount(double advanceamount) {
+ this.advanceamount = advanceamount;
+ }
+
+ public String getOrderdescription() {
+ return orderdescription;
+ }
+
+ public void setOrderdescription(String orderdescription) {
+ this.orderdescription = orderdescription;
+ }
+
+ public Customer getCustomer() {
+ return customer;
+ }
+
+ public void setCustomer(Customer customer) {
+ this.customer = customer;
+ }
+
+ public Set getPayments() {
+ return payments;
+ }
+
+ public void setPayments(Set payments) {
+ this.payments = payments;
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/com/orders/models/Payment.java b/src/main/java/com/orders/models/Payment.java
new file mode 100644
index 000000000..7399eea26
--- /dev/null
+++ b/src/main/java/com/orders/models/Payment.java
@@ -0,0 +1,52 @@
+package com.orders.models;
+
+import javax.persistence.*;
+import java.util.HashSet;
+import java.util.Set;
+
+@Entity
+@Table(name = "payments")
+public class Payment {
+
+ @Id
+ @GeneratedValue(strategy = GenerationType.AUTO)
+ private long paymentid;
+
+ @Column(unique = true, nullable = false)
+ private String type;
+
+ @ManyToMany(mappedBy = "payments")
+ private Set orders= new HashSet<>();
+
+ public Payment(){
+
+ }
+
+ public Payment(String type) {
+ this.type = type;
+ }
+
+ public long getPaymentid() {
+ return paymentid;
+ }
+
+ public void setPaymentid(long paymentid) {
+ this.paymentid = paymentid;
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ public Set getOrders() {
+ return orders;
+ }
+
+ public void setOrders(Set orders) {
+ this.orders = orders;
+ }
+}
diff --git a/src/main/java/com/orders/repositories/AgentsRepository.java b/src/main/java/com/orders/repositories/AgentsRepository.java
new file mode 100644
index 000000000..7ca454f43
--- /dev/null
+++ b/src/main/java/com/orders/repositories/AgentsRepository.java
@@ -0,0 +1,6 @@
+package com.orders.repositories;
+import com.orders.models.Agent;
+import org.springframework.data.repository.CrudRepository;
+
+public interface AgentsRepository extends CrudRepository {
+}
diff --git a/src/main/java/com/orders/repositories/CustomersRepository.java b/src/main/java/com/orders/repositories/CustomersRepository.java
new file mode 100644
index 000000000..92b9fe6a8
--- /dev/null
+++ b/src/main/java/com/orders/repositories/CustomersRepository.java
@@ -0,0 +1,6 @@
+package com.orders.repositories;
+import com.orders.models.Customer;
+import org.springframework.data.repository.CrudRepository;
+
+public interface CustomersRepository extends CrudRepository {
+}
diff --git a/src/main/java/com/orders/repositories/OrdersRepository.java b/src/main/java/com/orders/repositories/OrdersRepository.java
new file mode 100644
index 000000000..fb738262f
--- /dev/null
+++ b/src/main/java/com/orders/repositories/OrdersRepository.java
@@ -0,0 +1,7 @@
+package com.orders.repositories;
+
+import com.orders.models.Order;
+import org.springframework.data.repository.CrudRepository;
+
+public interface OrdersRepository extends CrudRepository {
+}
diff --git a/src/main/java/com/orders/repositories/PaymentRepository.java b/src/main/java/com/orders/repositories/PaymentRepository.java
new file mode 100644
index 000000000..f3a5b0bf4
--- /dev/null
+++ b/src/main/java/com/orders/repositories/PaymentRepository.java
@@ -0,0 +1,6 @@
+package com.orders.repositories;
+import com.orders.models.Payment;
+import org.springframework.data.repository.CrudRepository;
+
+public interface PaymentRepository extends CrudRepository {
+}
diff --git a/src/main/java/com/orders/services/OrderService.java b/src/main/java/com/orders/services/OrderService.java
new file mode 100644
index 000000000..d70486ed1
--- /dev/null
+++ b/src/main/java/com/orders/services/OrderService.java
@@ -0,0 +1,7 @@
+package com.orders.services;
+import com.orders.models.Order;
+
+public interface OrderService {
+
+ Order save(Order order);
+}
\ No newline at end of file
diff --git a/src/main/java/com/orders/services/OrderServiceImplementation.java b/src/main/java/com/orders/services/OrderServiceImplementation.java
new file mode 100644
index 000000000..6b4f11c55
--- /dev/null
+++ b/src/main/java/com/orders/services/OrderServiceImplementation.java
@@ -0,0 +1,19 @@
+package com.orders.services;
+
+
+import com.orders.models.Order;
+import com.orders.repositories.OrdersRepository;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+@Service(value = "orderService")
+public class OrderServiceImplementation implements OrderService {
+
+ @Autowired
+ OrdersRepository orderrepos;
+
+ @Override
+ public Order save(Order order) {
+ return orderrepos.save(order);
+ }
+}
diff --git a/src/main/java/com/orders/services/PaymentService.java b/src/main/java/com/orders/services/PaymentService.java
new file mode 100644
index 000000000..d252144bd
--- /dev/null
+++ b/src/main/java/com/orders/services/PaymentService.java
@@ -0,0 +1,9 @@
+package com.orders.services;
+
+import com.orders.models.Payment;
+
+public interface PaymentService {
+
+ Payment save(Payment payment);
+
+}
diff --git a/src/main/java/com/orders/services/PaymentServiceImplementation.java b/src/main/java/com/orders/services/PaymentServiceImplementation.java
new file mode 100644
index 000000000..d66b67ad5
--- /dev/null
+++ b/src/main/java/com/orders/services/PaymentServiceImplementation.java
@@ -0,0 +1,19 @@
+package com.orders.services;
+
+
+import com.orders.models.Payment;
+import com.orders.repositories.PaymentRepository;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+@Service( value = "paymentService")
+public class PaymentServiceImplementation implements PaymentService{
+
+ @Autowired
+ PaymentRepository paymentrepos;
+
+ @Override
+ public Payment save(Payment payment) {
+ return paymentrepos.save(payment);
+ }
+}
diff --git a/src/resources/application.properties b/src/resources/application.properties
new file mode 100644
index 000000000..6a6876e9b
--- /dev/null
+++ b/src/resources/application.properties
@@ -0,0 +1,19 @@
+spring.h2.console.enabled=true
+spring.h2.console.path=/h2-console
+#
+### We set a port that is not frequently used
+server.port=${PORT:2019}
+#
+### Feature that determines what happens when no accessors are found for a type
+### (and there are no annotations to indicate it is meant to be serialized).
+spring.jackson.serialization.fail-on-empty-beans=false
+#
+### keeps a transaction inside of the same entity manager
+### This property register an EntityManager to the current thread,
+### so you will have the same EntityManager until the web request is finished.
+spring.jpa.open-in-view=true
+#
+### What do with the schema
+### drop n create table again, good for testing
+spring.jpa.hibernate.ddl-auto=create
+spring.datasource.initialization-mode=always
diff --git a/web/WEB-INF/web.xml b/web/WEB-INF/web.xml
new file mode 100644
index 000000000..d80081d13
--- /dev/null
+++ b/web/WEB-INF/web.xml
@@ -0,0 +1,6 @@
+
+
+
\ No newline at end of file
diff --git a/web/index.jsp b/web/index.jsp
new file mode 100644
index 000000000..8f7f48c0a
--- /dev/null
+++ b/web/index.jsp
@@ -0,0 +1,16 @@
+<%--
+ Created by IntelliJ IDEA.
+ User: stacey
+ Date: 9/9/2020
+ Time: 2:36 AM
+ To change this template use File | Settings | File Templates.
+--%>
+<%@ page contentType="text/html;charset=UTF-8" language="java" %>
+
+
+ $Title$
+
+
+ $END$
+
+