1
+ module FreeAgent
2
+ class Estimate < Resource
3
+ resource :estimate
4
+
5
+ resource_methods :default
6
+
7
+ attr_accessor :contact , :reference , :estimate_type , :status , :currency , :estimate_itmes , :project , :invoice
8
+
9
+ decimal_accessor :net_value , :sales_tax_value , :sales_tax_rate , :second_sales_tax_rate
10
+
11
+ date_accessor :dated_on , :created_at , :updated_at
12
+
13
+ def self . recent
14
+ Estimate . filter ( :view => 'recent' )
15
+ end
16
+
17
+ def self . draft
18
+ Estimate . filter ( :view => 'draft' )
19
+ end
20
+
21
+ def self . non_draft
22
+ Estimate . filter ( :view => 'non_draft' )
23
+ end
24
+
25
+ def self . sent
26
+ Estimate . filter ( :view => 'sent' )
27
+ end
28
+
29
+ def self . approved
30
+ Estimate . filter ( :view => 'approved' )
31
+ end
32
+
33
+ def self . rejected
34
+ Estimate . filter ( :view => 'rejected' )
35
+ end
36
+
37
+ def self . invoiced
38
+ Estimate . filter ( :view => 'invoiced' )
39
+ end
40
+
41
+ def self . find_all_by_contact ( contact )
42
+ Estimate . filter ( :contact => contact )
43
+ end
44
+
45
+ def self . find_all_by_project ( project )
46
+ Estimate . filter ( :project => project )
47
+ end
48
+
49
+ def self . find_all_by_invoice ( invoice )
50
+ Estimate . filter ( :invoice => invoice )
51
+ end
52
+
53
+ def mark_as_sent
54
+ FreeAgent . client . put ( "estimates/#{ id } /transitions/mark_as_sent" , nil )
55
+ end
56
+
57
+ def mark_as_draft
58
+ FreeAgent . client . put ( "estimates/#{ id } /transitions/mark_as_draft" , nil )
59
+ end
60
+
61
+ def mark_as_approved
62
+ FreeAgent . client . put ( "estimates/#{ id } /transitions/mark_as_approved" , nil )
63
+ end
64
+
65
+ def mark_as_rejected
66
+ FreeAgent . client . put ( "estimates/#{ id } /transitions/mark_as_rejected" , nil )
67
+ end
68
+ end
69
+ end
0 commit comments