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. Invoice Management Plugin

This plugin provide storage and services for managing invoices 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-invoice-ui provides a Twitter Bootstrap based user interface for managing invoices.

crm-invoice-ui depends on crm-invoice so you only need to include crm-invoice-ui in your BuildConfig.groovy if you want end-user invoice management features.

3. Domain Model

Invoice Domain Model

3.1. CrmInvoice

An invoice have an invoice head with customer details and zero-or-many invoice items that specify the products included by the invoice. The invoice head is stored in CrmInvoice and each invoice item is stored in a CrmInvoiceItem instance. The association CrmInvoice.items references all items for an invoice.

Table 1. CrmInvoice
Property Type Description

number

String

Invoice number

invoiceDate

java.sql.Date

Invoice date

deliveryDate

java.sql.Date

Delivery date (expected or actual)

dueDate

java.sql.Date

Payment due date

paymentDate

java.sql.Date

Actutal payment date

invoiceStatus

CrmInvoiceStatus

Current invoice status

customerTel

String

Customer telephone

customerEmail

String

Customer email

invoice

CrmEmbeddedAddress

Invoice address

delivery

CrmEmbeddedAddress

Delivery address

currency

String

Currency code

totalAmount

Double

Total invoice amount

totalVat

Double

Total VAT amount

3.2. CrmInvoiceItem

Each invoice item specifies product and price information.

Table 2. CrmInvoiceItem
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 invoiced

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. CrmInvoiceService

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

4.1. Create invoice status

CrmInvoiceStatus createInvoiceStatus(Map params, boolean save = false)

Invoice status is mandatory on an invoice and different invoice statuses can be created with createInvoiceStatus().

4.2. Create a new invoice

CreateInvoice.groovy
def s = crmInvoiceService.createInvoiceStatus(name: "Created", true)
def t = crmInvoiceService.createPaymentTerm(name: "14days", true)

def invoice = crmInvoiceService.createInvoice(invoiceStatus: s, paymentTerm: t, customer: "ACME Inc.", customerTel: "+4685551234", customerEmail: "customer@acme.com")
crmInvoiceService.addInvoiceItem(invoice, [orderIndex: 1, productNumber: "iPhone6s", productName: "iPhone 6s 64GB Space Grey",
    unit: "item", quantity: 1, price: 699, vat: 0.2])
invoice.save(failOnError: true)

println "Invoice number #$invoice created for ${invoice.customer}"

5. Changes

2.4.1

Payment properties are now included in the databinding white list

2.4.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-invoice

8. Contributing

Please report issues or suggestions.

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