Project

canmoia

0.0
No commit activity in last 3 years
No release in over 3 years
The core domain concerns for Orders (Work Orders and Purchase Orders).
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Project Readme

canmöia

Summary

Canmöia (can = order, möia = work, work order). The core functionality of the Order domain

Requirements

  • Ruby 2.0.0
  • Workflow Gem
  • Currently only support mongoid models

Getting Started

Add to your Gemfile:

gem 'canmoia'

You must have a model named User and a model named Item for this to work properly. Then add the concern you want to your model:

class Order
  include Mongoid::Document
  include Canmoia::Order
end

You now have a fully working Order:

order = Order.new
order.items << Item.new(value: 100)
order.items << Item.new(value: 150)

# Automatically computes total upon validation
order.valid?
order.total      # 250.00

# Manage basic order states (workflow gem basics)
# To override behaviour just define close! method on model
order.close!
order.closed?    # true

order.accept!
order.accepted?  # true
order.state      # accepted


# Automagically generated associations
order.client    # your User model
order.items      # your Item model

You might also try the Work Order concern:

class Order
  include Mongoid::Document
  # Canmoia::Order is automatically included
  include Canmoia::Work
end

# Automagically generated associations
order.responsible

# Autmatically notifications!
# When closing a order:
order.close!

# Canmoia will automatically try to notify
# the domain resposables for the event
# Trigerring this methods:
# OrderMailer.close_notification_to_responsible(order, order.responsible).deliver
# OrderMailer.close_notification_to_client(order, order.client).deliver
#
# Generalizing:
# #{YourModel}Mailer.#{event}_notification_to_#{recipient}

Documentation

Sometime on the future might be a wiki page

Concerns

Order (Canmoia::Order)

The current states and transitions are: Order will always start at opened state (italics)

state event transitions to
opened close reviewing
opened cancel canceled
reviewing accept accepted
reviewing reject rejected
reviewing cancel canceled
accepted complete completed
accepted cancel canceled
rejected complete completed
rejected cancel canceled
rejected retry reviewing
completed - -
canceled - -

Work Order (Canmoia::Work)

You can specify to which events canmöia should send notifications:

class Order
  include Mongoid::Document
  # Canmoia::Order is automatically included
  include Canmoia::Work

  # BTW this are the defaults!
  notify :responsible, :on => [:open, :close]
  notify :client     , :on => [:open, :accept, :reject, :cancel]
end

Features

Notification (Canmoia::Notification)

Include workflow and rock with only notification functionalities!

class Order
  include Mongoid::Document
  include Workflow
  include Canmoia::Notification

  workflow do

    state :opened do
        event :close, :transitions_to => :checkout
    end

    state :checkout

  end

  #  Remember, will trigger: OrderMailer.close_notification_to_responsible(order, order.responsible).deliver
  notify :responsible, :on => :close
end

TODO

Mail Generator

Automatically add default mail templates for notification kinds to the view_path

Purchase Order

Add suport for Purchase Order Concern (Canmoia::Purchasable)

Reviewable Feature

Extract review order feature from Order concern (Canmoia::Reviewable)

This project rocks and uses WTFP-LICENSE.