1. Introduction

GR8 CRM is a set of Grails Web Application Framework plugins that makes it easy to develop web applications with CRM functionality.

You can find more information about GR8 CRM on the main documentation site http://gr8crm.github.io.

1.1. Customer Relationship Management

Customer relationship management (CRM) is a system for managing a company’s interactions with current and future customers. It involves using technology to organize, automate and synchronize sales, marketing, customer service, and technical support. Wikipedia

The GR8 CRM "Ecosystem" currently contains over 40 Grails plugins. For a complete list of plugins see http://gr8crm.github.io.

Each GR8 CRM plugin defines a Bounded Context that focus on one specific domain, for example contact, project or document.

2. Order Management Plugin

This plugin provide storage and services for managing orders in GR8 CRM applications.

Note that this plugin does not contain any user interface components. This plugin contains domain classes and services only. The plugin crm-order-ui provides a Twitter Bootstrap based user interface for managing orders. crm-order-ui depends on crm-order so you only need to include crm-order-ui in your BuildConfig.groovy if you want end-user order management features.

3. Domain Model

Order Domain Model

3.1. CrmOrder

An order have a order head with customer details and zero-or-many order lines that specify the products ordered. The order head is stored in CrmOrder and each order line is stored in a CrmOrderItem instance. The association CrmOrder.items references all order lines for an order.

Table 1. CrmOrder
Property Type Description

number

String

Order number

orderDate

java.sql.Date

Order date

deliveryDate

java.sql.Date

Delivery date (expected or actual)

orderType

CrmOrderType

Type of order

orderStatus

CrmOrderStatus

Current order status

deliveryType

CrmDeliveryType

How the products should be delivered to the customer (standard, express, etc.)

customerNumber

String

Customer number (if applicable)

customerFirstName

String

Customer first name

customerLastName

String

Customer last name

customerCompany

String

Customer company name (if applicable)

customerTel

String

Customer telephone

customerEmail

String

Customer email

invoice

CrmEmbeddedAddress

Invoice address

delivery

CrmEmbeddedAddress

Delivery address

currency

String

Currency code

totalAmount

Double

Total order amount

totalVat

Double

Total VAT amount

3.2. CrmOrderItem

Each order line specifies product and price information.

Table 2. CrmOrderItem
Property Type Description

orderIndex

Integer

Line number

productId

String

A number that uniquely identifies the product

productName

String

Name of product

comment

String

Optional comments

quantity

Double

Quantity of products ordered

unit

String

Unit of quantity

price

Double

Price for one item excluding VAT

discount

Double

Discount (in percent of price if value < 1 and in real currency if value >= 1)

vat

Double

Value Added Tax (in percent)

4. CrmOrderService

Like most other GR8 CRM plugins this plugin have a main service with methods for creating, searching and updating orders.

4.1. Create order type

CrmOrderType createOrderType(Map params, boolean save = false)

Order type is mandatory on an order and different order types can be created with createOrderType().

4.2. Create order status

CrmOrderStatus createOrderStatus(Map params, boolean save = false)

Order status is mandatory on an order and different order statuses can be created with createOrderStatus().

4.3. Create delivery type

CrmDeliveryType createDeliveryType(Map params, boolean save = false)

Delivery type is mandatory on an order and different delivery types can be created with createDeliveryType().

4.4. Create a new order

CrmOrder saveOrder(CrmOrder order, Map params)

To create a new order you call the saveOrder method with a map of property values and either an existing CrmOrder instance or null to have the method create an instance for you.

CreateWebOrder.groovy
def t = crmOrderService.createOrderType(name: "Web Order", true)
def s = crmOrderService.createOrderStatus(name: "Order", true)
def d = crmOrderService.createDeliveryType(name: "Air mail", true)

def order = crmOrderService.saveOrder(null, [orderType: t, orderStatus: s, deliveryType: d,
    customerFirstName: "Joe", customerLastName: "Average", customerCompany: "Company Inc.",
    'invoice.address1': "Main Road 1234", 'invoice.postalCode': "12345", 'invoice.city': "Stockholm",
    customerTel: "+4685551234", customerEmail: "joe.average@company.com", currency: "SEK",
    'items.orderIndex': 1, 'items.productNumber': "iPhone4s", 'items.productName': "iPhone 4S 16 GB Black Unlocked",
    'items.unit': "item", 'items.quantity': 1, 'items.price': 3068.8, 'items.vat': 0.25])

println "Order #$order created with status ${order.status} for ${order.customer}, ${order.invoice}"

5. Changes

2.4.2

Fix for default currency

2.4.1

Fix for data binding problem with associations (order items)

2.4.0

First version compatible with Grails 2.4.4

2.0.1

New method CrmOrderService#orderPayed(…​) to set payed amount and payment status on an order

2.0.0

First public release

6. License

This plugin is licensed with Apache License version 2.0

7. Source Code

The source code for this plugin is available at https://github.com/technipelago/grails-crm-order

8. Contributing

Please report issues or suggestions.

Want to improve the plugin: Fork the repository and send a pull request.