beanie 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (54) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +17 -0
  3. data/CONTRIBUTORS +1 -0
  4. data/Gemfile +3 -0
  5. data/LICENSE +339 -0
  6. data/LICENSE.txt +22 -0
  7. data/README.md +30 -0
  8. data/Rakefile +1 -0
  9. data/VERSION +1 -0
  10. data/beanie.gemspec +23 -0
  11. data/lib/beanie/api.rb +117 -0
  12. data/lib/beanie/bank_account.rb +34 -0
  13. data/lib/beanie/bank_statement.rb +34 -0
  14. data/lib/beanie/bank_statement_data.rb +35 -0
  15. data/lib/beanie/beanie_alert.rb +56 -0
  16. data/lib/beanie/billable.rb +35 -0
  17. data/lib/beanie/company.rb +40 -0
  18. data/lib/beanie/company_member.rb +34 -0
  19. data/lib/beanie/config_type.rb +50 -0
  20. data/lib/beanie/config_value.rb +34 -0
  21. data/lib/beanie/contact.rb +55 -0
  22. data/lib/beanie/contact_address.rb +35 -0
  23. data/lib/beanie/contact_note.rb +34 -0
  24. data/lib/beanie/customer.rb +34 -0
  25. data/lib/beanie/document.rb +60 -0
  26. data/lib/beanie/fixed_asset.rb +34 -0
  27. data/lib/beanie/journal.rb +34 -0
  28. data/lib/beanie/journal_item.rb +34 -0
  29. data/lib/beanie/nominal_account.rb +34 -0
  30. data/lib/beanie/nominal_account_category.rb +64 -0
  31. data/lib/beanie/product.rb +40 -0
  32. data/lib/beanie/product_category.rb +34 -0
  33. data/lib/beanie/product_price.rb +34 -0
  34. data/lib/beanie/purchase_invoice.rb +36 -0
  35. data/lib/beanie/purchase_order.rb +35 -0
  36. data/lib/beanie/purchase_order_item.rb +47 -0
  37. data/lib/beanie/sales_invoice.rb +65 -0
  38. data/lib/beanie/sales_invoice_item.rb +35 -0
  39. data/lib/beanie/sales_order.rb +34 -0
  40. data/lib/beanie/sales_order_item.rb +118 -0
  41. data/lib/beanie/stock_adjustment.rb +57 -0
  42. data/lib/beanie/stock_category.rb +34 -0
  43. data/lib/beanie/stock_item.rb +46 -0
  44. data/lib/beanie/stock_location.rb +34 -0
  45. data/lib/beanie/stock_supplier.rb +35 -0
  46. data/lib/beanie/supplier.rb +35 -0
  47. data/lib/beanie/tax_registration.rb +50 -0
  48. data/lib/beanie/vat_record.rb +56 -0
  49. data/lib/beanie/vat_return.rb +45 -0
  50. data/lib/beanie/version.rb +32 -0
  51. data/lib/beanie/work_centre.rb +62 -0
  52. data/lib/beanie/work_centre_group.rb +44 -0
  53. data/lib/beanie.rb +130 -0
  54. metadata +124 -0
@@ -0,0 +1,46 @@
1
+ #
2
+ # Copyright (c) 2017-2018, AltoYield Limited. All rights reserved.
3
+ #
4
+ # This is free software; you can redistribute it and/or modify it
5
+ # under the terms of the GNU General Public License as published by
6
+ # the Free Software Foundation; either version 2, or (at your option)
7
+ # any later version.
8
+ #
9
+ # It is distributed in the hope that it will be useful, but WITHOUT
10
+ # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
+ # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12
+ # for more details.
13
+ #
14
+ # You should have received a copy of the GNU General Public License along
15
+ # with this product; see the file COPYING. If not, write to the Free
16
+ # Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
17
+ #
18
+ # THIS SOFTWARE IS PROVIDED BY ALTOYIELD LIMITED "AS IS" AND ANY EXPRESS
19
+ # OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20
+ # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21
+ # ARE DISCLAIMED. IN NO EVENT SHALL ALTOYIELD LIMITED BE LIABLE FOR
22
+ # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23
+ # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24
+ # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25
+ # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
26
+ # STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
27
+ # IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28
+ # POSSIBILITY OF SUCH DAMAGE.
29
+ #
30
+ module Beanie
31
+ class StockItem < Api
32
+ attr_accessor :id, :description, :item_type, :name, :sku, :stock_category_id, :unit_of_measure
33
+
34
+ TYPE_PURCHASED = 0
35
+ TYPE_RAW_MATERIAL = 1
36
+ TYPE_WORK_IN_PROGRESS = 2
37
+ TYPE_FINISHED_GOODS = 3
38
+
39
+ TYPE_NAMES = [
40
+ ["Purchased for Resale", TYPE_PURCHASED],
41
+ ["Raw Materials", TYPE_RAW_MATERIAL],
42
+ ["Work In Progress", TYPE_WORK_IN_PROGRESS],
43
+ ["Finished Goods", TYPE_FINISHED_GOODS]
44
+ ].freeze
45
+ end
46
+ end
@@ -0,0 +1,34 @@
1
+ #
2
+ # Copyright (c) 2017-2018, AltoYield Limited. All rights reserved.
3
+ #
4
+ # This is free software; you can redistribute it and/or modify it
5
+ # under the terms of the GNU General Public License as published by
6
+ # the Free Software Foundation; either version 2, or (at your option)
7
+ # any later version.
8
+ #
9
+ # It is distributed in the hope that it will be useful, but WITHOUT
10
+ # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
+ # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12
+ # for more details.
13
+ #
14
+ # You should have received a copy of the GNU General Public License along
15
+ # with this product; see the file COPYING. If not, write to the Free
16
+ # Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
17
+ #
18
+ # THIS SOFTWARE IS PROVIDED BY ALTOYIELD LIMITED "AS IS" AND ANY EXPRESS
19
+ # OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20
+ # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21
+ # ARE DISCLAIMED. IN NO EVENT SHALL ALTOYIELD LIMITED BE LIABLE FOR
22
+ # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23
+ # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24
+ # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25
+ # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
26
+ # STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
27
+ # IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28
+ # POSSIBILITY OF SUCH DAMAGE.
29
+ #
30
+ module Beanie
31
+ class StockLocation < Api
32
+ attr_accessor :id, :description, :name
33
+ end
34
+ end
@@ -0,0 +1,35 @@
1
+ #
2
+ # Copyright (c) 2017-2018, AltoYield Limited. All rights reserved.
3
+ #
4
+ # This is free software; you can redistribute it and/or modify it
5
+ # under the terms of the GNU General Public License as published by
6
+ # the Free Software Foundation; either version 2, or (at your option)
7
+ # any later version.
8
+ #
9
+ # It is distributed in the hope that it will be useful, but WITHOUT
10
+ # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
+ # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12
+ # for more details.
13
+ #
14
+ # You should have received a copy of the GNU General Public License along
15
+ # with this product; see the file COPYING. If not, write to the Free
16
+ # Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
17
+ #
18
+ # THIS SOFTWARE IS PROVIDED BY ALTOYIELD LIMITED "AS IS" AND ANY EXPRESS
19
+ # OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20
+ # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21
+ # ARE DISCLAIMED. IN NO EVENT SHALL ALTOYIELD LIMITED BE LIABLE FOR
22
+ # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23
+ # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24
+ # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25
+ # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
26
+ # STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
27
+ # IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28
+ # POSSIBILITY OF SUCH DAMAGE.
29
+ #
30
+ module Beanie
31
+ class StockSupplier < Api
32
+ attr_accessor :id, :priority, :supplier_partno, :lot_size, :lead_time, :last_price
33
+ attr_accessor :stock_item_id, :supplier_id
34
+ end
35
+ end
@@ -0,0 +1,35 @@
1
+ #
2
+ # Copyright (c) 2017-2018, AltoYield Limited. All rights reserved.
3
+ #
4
+ # This is free software; you can redistribute it and/or modify it
5
+ # under the terms of the GNU General Public License as published by
6
+ # the Free Software Foundation; either version 2, or (at your option)
7
+ # any later version.
8
+ #
9
+ # It is distributed in the hope that it will be useful, but WITHOUT
10
+ # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
+ # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12
+ # for more details.
13
+ #
14
+ # You should have received a copy of the GNU General Public License along
15
+ # with this product; see the file COPYING. If not, write to the Free
16
+ # Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
17
+ #
18
+ # THIS SOFTWARE IS PROVIDED BY ALTOYIELD LIMITED "AS IS" AND ANY EXPRESS
19
+ # OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20
+ # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21
+ # ARE DISCLAIMED. IN NO EVENT SHALL ALTOYIELD LIMITED BE LIABLE FOR
22
+ # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23
+ # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24
+ # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25
+ # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
26
+ # STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
27
+ # IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28
+ # POSSIBILITY OF SUCH DAMAGE.
29
+ #
30
+ module Beanie
31
+ class Supplier < Api
32
+ attr_accessor :id, :balance, :state, :supplier_vat, :terms, :lead_time, :minimum_order_amount
33
+ attr_accessor :contact_id, :currency
34
+ end
35
+ end
@@ -0,0 +1,50 @@
1
+ #
2
+ # Copyright (c) 2017-2018, AltoYield Limited. All rights reserved.
3
+ #
4
+ # This is free software; you can redistribute it and/or modify it
5
+ # under the terms of the GNU General Public License as published by
6
+ # the Free Software Foundation; either version 2, or (at your option)
7
+ # any later version.
8
+ #
9
+ # It is distributed in the hope that it will be useful, but WITHOUT
10
+ # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
+ # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12
+ # for more details.
13
+ #
14
+ # You should have received a copy of the GNU General Public License along
15
+ # with this product; see the file COPYING. If not, write to the Free
16
+ # Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
17
+ #
18
+ # THIS SOFTWARE IS PROVIDED BY ALTOYIELD LIMITED "AS IS" AND ANY EXPRESS
19
+ # OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20
+ # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21
+ # ARE DISCLAIMED. IN NO EVENT SHALL ALTOYIELD LIMITED BE LIABLE FOR
22
+ # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23
+ # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24
+ # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25
+ # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
26
+ # STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
27
+ # IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28
+ # POSSIBILITY OF SUCH DAMAGE.
29
+ #
30
+ module Beanie
31
+ class TaxRegistration < Api
32
+ attr_accessor :id, :tax_type, :number, :nominal_account_id
33
+
34
+ TAX_TYPE_CORPORATE = 0
35
+ TAX_TYPE_SALES = 1
36
+ TAX_TYPE_PAYROLL = 2
37
+
38
+ TAX_TYPE_NAMES = [
39
+ ["Corporation Tax", TAX_TYPE_CORPORATE],
40
+ ["VAT", TAX_TYPE_SALES],
41
+ ["PAYE", TAX_TYPE_PAYROLL]
42
+ ].freeze
43
+
44
+ #
45
+ # Tax Type as a name
46
+ def tax_type_name
47
+ TAX_TYPE_NAMES[tax_type][0]
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,56 @@
1
+ #
2
+ # Copyright (c) 2017-2018, AltoYield Limited. All rights reserved.
3
+ #
4
+ # This is free software; you can redistribute it and/or modify it
5
+ # under the terms of the GNU General Public License as published by
6
+ # the Free Software Foundation; either version 2, or (at your option)
7
+ # any later version.
8
+ #
9
+ # It is distributed in the hope that it will be useful, but WITHOUT
10
+ # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
+ # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12
+ # for more details.
13
+ #
14
+ # You should have received a copy of the GNU General Public License along
15
+ # with this product; see the file COPYING. If not, write to the Free
16
+ # Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
17
+ #
18
+ # THIS SOFTWARE IS PROVIDED BY ALTOYIELD LIMITED "AS IS" AND ANY EXPRESS
19
+ # OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20
+ # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21
+ # ARE DISCLAIMED. IN NO EVENT SHALL ALTOYIELD LIMITED BE LIABLE FOR
22
+ # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23
+ # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24
+ # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25
+ # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
26
+ # STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
27
+ # IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28
+ # POSSIBILITY OF SUCH DAMAGE.
29
+ #
30
+ module Beanie
31
+ class VatRecord < Api
32
+ attr_accessor :id, :amount, :record_type, :vat_return_id, :sales_tax_rate
33
+
34
+ TYPE_SALES = 0
35
+ TYPE_PURCHASES = 1
36
+ TYPE_GOODS_FROM = 2
37
+ TYPE_GOODS_TO = 3
38
+ TYPE_SERVICES_FROM = 4
39
+ TYPE_SERVICES_TO = 5
40
+
41
+ TYPE_NAMES = [
42
+ ["Sales", TYPE_SALES],
43
+ ["Purchases", TYPE_PURCHASES],
44
+ ["Goods From", TYPE_GOODS_FROM],
45
+ ["Goods To", TYPE_GOODS_TO],
46
+ ["Services From", TYPE_SERVICES_FROM],
47
+ ["Services To", TYPE_SERVICES_TO]
48
+ ].freeze
49
+
50
+ #
51
+ # Conver the record type into a string
52
+ def record_type_name
53
+ TYPE_NAMES[self.record_type][0]
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,45 @@
1
+ #
2
+ # Copyright (c) 2017-2018, AltoYield Limited. All rights reserved.
3
+ #
4
+ # This is free software; you can redistribute it and/or modify it
5
+ # under the terms of the GNU General Public License as published by
6
+ # the Free Software Foundation; either version 2, or (at your option)
7
+ # any later version.
8
+ #
9
+ # It is distributed in the hope that it will be useful, but WITHOUT
10
+ # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
+ # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12
+ # for more details.
13
+ #
14
+ # You should have received a copy of the GNU General Public License along
15
+ # with this product; see the file COPYING. If not, write to the Free
16
+ # Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
17
+ #
18
+ # THIS SOFTWARE IS PROVIDED BY ALTOYIELD LIMITED "AS IS" AND ANY EXPRESS
19
+ # OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20
+ # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21
+ # ARE DISCLAIMED. IN NO EVENT SHALL ALTOYIELD LIMITED BE LIABLE FOR
22
+ # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23
+ # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24
+ # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25
+ # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
26
+ # STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
27
+ # IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28
+ # POSSIBILITY OF SUCH DAMAGE.
29
+ #
30
+ module Beanie
31
+ class VatReturn < Api
32
+ attr_accessor :id, :start_date, :end_date, :return_type, :purchase, :sales
33
+ attr_accessor :goods_from, :goods_to, :services_from, :services_to
34
+
35
+ RETURN_TYPE_ORIGINAL = 0
36
+ RETURN_TYPE_SUPPLEMENTARY = 1
37
+ RETURN_TYPE_AMENDED = 2
38
+
39
+ RETURN_TYPES = [
40
+ ["Original Return", RETURN_TYPE_ORIGINAL],
41
+ ["Supplementary Return", RETURN_TYPE_SUPPLEMENTARY],
42
+ ["Amended Return", RETURN_TYPE_AMENDED]
43
+ ].freeze
44
+ end
45
+ end
@@ -0,0 +1,32 @@
1
+ #
2
+ # Copyright (c) 2017-2018, AltoYield Limited. All rights reserved.
3
+ #
4
+ # This is free software; you can redistribute it and/or modify it
5
+ # under the terms of the GNU General Public License as published by
6
+ # the Free Software Foundation; either version 2, or (at your option)
7
+ # any later version.
8
+ #
9
+ # It is distributed in the hope that it will be useful, but WITHOUT
10
+ # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
+ # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12
+ # for more details.
13
+ #
14
+ # You should have received a copy of the GNU General Public License along
15
+ # with this product; see the file COPYING. If not, write to the Free
16
+ # Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
17
+ #
18
+ # THIS SOFTWARE IS PROVIDED BY ALTOYIELD LIMITED "AS IS" AND ANY EXPRESS
19
+ # OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20
+ # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21
+ # ARE DISCLAIMED. IN NO EVENT SHALL ALTOYIELD LIMITED BE LIABLE FOR
22
+ # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23
+ # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24
+ # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25
+ # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
26
+ # STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
27
+ # IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28
+ # POSSIBILITY OF SUCH DAMAGE.
29
+ #
30
+ module Beanie
31
+ VERSION = "0.0.1"
32
+ end
@@ -0,0 +1,62 @@
1
+ #
2
+ # Copyright (c) 2017-2018, AltoYield Limited. All rights reserved.
3
+ #
4
+ # This is free software; you can redistribute it and/or modify it
5
+ # under the terms of the GNU General Public License as published by
6
+ # the Free Software Foundation; either version 2, or (at your option)
7
+ # any later version.
8
+ #
9
+ # It is distributed in the hope that it will be useful, but WITHOUT
10
+ # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
+ # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12
+ # for more details.
13
+ #
14
+ # You should have received a copy of the GNU General Public License along
15
+ # with this product; see the file COPYING. If not, write to the Free
16
+ # Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
17
+ #
18
+ # THIS SOFTWARE IS PROVIDED BY ALTOYIELD LIMITED "AS IS" AND ANY EXPRESS
19
+ # OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20
+ # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21
+ # ARE DISCLAIMED. IN NO EVENT SHALL ALTOYIELD LIMITED BE LIABLE FOR
22
+ # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23
+ # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24
+ # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25
+ # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
26
+ # STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
27
+ # IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28
+ # POSSIBILITY OF SUCH DAMAGE.
29
+ #
30
+ module Beanie
31
+ class WorkCentre < Api
32
+ attr_accessor :id, :name, :location, :description, :work_centre_group_id
33
+
34
+ #
35
+ # Find all work centres under a specific work centre group
36
+ def self.find_all_by_group(work_centre_group_id)
37
+ all = []
38
+ data = self.get(:url => "/work_centre_groups/#{work_centre_group_id}/work_centres")
39
+ data['work_centres'].each do |wc_data|
40
+ wc = new
41
+ wc.populate(wc_data, :id, :name, :location, :description)
42
+ all << wc
43
+ end
44
+ all
45
+ end
46
+
47
+ #
48
+ # Get the provisioning data
49
+ def provisioning
50
+ response = WorkCentre.get(:url => "/work_centres/#{@id}/provisioning")
51
+ response["data"]
52
+ end
53
+
54
+ #
55
+ # Update/set the provisioning data
56
+ def provisioning=(data)
57
+ pdata = {:data => data}
58
+ response = WorkCentre.post(pdata, :url => "/work_centres/#{@id}/provisioning")
59
+ p response
60
+ end
61
+ end
62
+ end
@@ -0,0 +1,44 @@
1
+ #
2
+ # Copyright (c) 2017-2018, AltoYield Limited. All rights reserved.
3
+ #
4
+ # This is free software; you can redistribute it and/or modify it
5
+ # under the terms of the GNU General Public License as published by
6
+ # the Free Software Foundation; either version 2, or (at your option)
7
+ # any later version.
8
+ #
9
+ # It is distributed in the hope that it will be useful, but WITHOUT
10
+ # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
+ # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12
+ # for more details.
13
+ #
14
+ # You should have received a copy of the GNU General Public License along
15
+ # with this product; see the file COPYING. If not, write to the Free
16
+ # Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
17
+ #
18
+ # THIS SOFTWARE IS PROVIDED BY ALTOYIELD LIMITED "AS IS" AND ANY EXPRESS
19
+ # OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20
+ # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21
+ # ARE DISCLAIMED. IN NO EVENT SHALL ALTOYIELD LIMITED BE LIABLE FOR
22
+ # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23
+ # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24
+ # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25
+ # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
26
+ # STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
27
+ # IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28
+ # POSSIBILITY OF SUCH DAMAGE.
29
+ #
30
+ module Beanie
31
+ class WorkCentreGroup < Api
32
+ attr_accessor :id, :code, :name, :description
33
+
34
+ #
35
+ # Find a work centre group by code
36
+ def self.find_by_code(code)
37
+ data = self.get(:code => code)
38
+ wcg_data = data['work_centre_group']
39
+ wcg = new
40
+ wcg.populate(wcg_data, :id, :code, :name, :description)
41
+ wcg
42
+ end
43
+ end
44
+ end
data/lib/beanie.rb ADDED
@@ -0,0 +1,130 @@
1
+ #
2
+ # Copyright (c) 2017-2018, AltoYield Limited. All rights reserved.
3
+ #
4
+ # This is free software; you can redistribute it and/or modify it
5
+ # under the terms of the GNU General Public License as published by
6
+ # the Free Software Foundation; either version 2, or (at your option)
7
+ # any later version.
8
+ #
9
+ # It is distributed in the hope that it will be useful, but WITHOUT
10
+ # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
+ # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12
+ # for more details.
13
+ #
14
+ # You should have received a copy of the GNU General Public License along
15
+ # with this product; see the file COPYING. If not, write to the Free
16
+ # Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
17
+ #
18
+ # THIS SOFTWARE IS PROVIDED BY ALTOYIELD LIMITED "AS IS" AND ANY EXPRESS
19
+ # OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20
+ # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21
+ # ARE DISCLAIMED. IN NO EVENT SHALL ALTOYIELD LIMITED BE LIABLE FOR
22
+ # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23
+ # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24
+ # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25
+ # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
26
+ # STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
27
+ # IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28
+ # POSSIBILITY OF SUCH DAMAGE.
29
+ #
30
+ # Ruby bindings for the Beanie API
31
+ # Docs at http://bean.ie/docs/api/ruby
32
+ require 'cgi'
33
+ require 'openssl'
34
+ require 'rest-client'
35
+ require 'json'
36
+
37
+ require File.dirname(__FILE__) + '/beanie/api'
38
+ require File.dirname(__FILE__) + '/beanie/bank_account'
39
+ require File.dirname(__FILE__) + '/beanie/bank_statement_data'
40
+ require File.dirname(__FILE__) + '/beanie/bank_statement'
41
+ require File.dirname(__FILE__) + '/beanie/beanie_alert'
42
+ require File.dirname(__FILE__) + '/beanie/billable'
43
+ require File.dirname(__FILE__) + '/beanie/company_member'
44
+ require File.dirname(__FILE__) + '/beanie/company'
45
+ require File.dirname(__FILE__) + '/beanie/config_type'
46
+ require File.dirname(__FILE__) + '/beanie/config_value'
47
+ require File.dirname(__FILE__) + '/beanie/contact_address'
48
+ require File.dirname(__FILE__) + '/beanie/contact_note'
49
+ require File.dirname(__FILE__) + '/beanie/contact'
50
+ require File.dirname(__FILE__) + '/beanie/customer'
51
+ require File.dirname(__FILE__) + '/beanie/document'
52
+ require File.dirname(__FILE__) + '/beanie/fixed_asset'
53
+ require File.dirname(__FILE__) + '/beanie/journal_item'
54
+ require File.dirname(__FILE__) + '/beanie/journal'
55
+ require File.dirname(__FILE__) + '/beanie/nominal_account_category'
56
+ require File.dirname(__FILE__) + '/beanie/nominal_account'
57
+ require File.dirname(__FILE__) + '/beanie/product_category'
58
+ require File.dirname(__FILE__) + '/beanie/product_price'
59
+ require File.dirname(__FILE__) + '/beanie/product'
60
+ require File.dirname(__FILE__) + '/beanie/purchase_invoice'
61
+ require File.dirname(__FILE__) + '/beanie/purchase_order_item'
62
+ require File.dirname(__FILE__) + '/beanie/purchase_order'
63
+ require File.dirname(__FILE__) + '/beanie/sales_invoice_item'
64
+ require File.dirname(__FILE__) + '/beanie/sales_invoice'
65
+ require File.dirname(__FILE__) + '/beanie/sales_order_item'
66
+ require File.dirname(__FILE__) + '/beanie/sales_order'
67
+ require File.dirname(__FILE__) + '/beanie/stock_adjustment'
68
+ require File.dirname(__FILE__) + '/beanie/stock_category'
69
+ require File.dirname(__FILE__) + '/beanie/stock_item'
70
+ require File.dirname(__FILE__) + '/beanie/stock_location'
71
+ require File.dirname(__FILE__) + '/beanie/stock_supplier'
72
+ require File.dirname(__FILE__) + '/beanie/supplier'
73
+ require File.dirname(__FILE__) + '/beanie/tax_registration'
74
+ require File.dirname(__FILE__) + '/beanie/vat_record'
75
+ require File.dirname(__FILE__) + '/beanie/vat_return'
76
+ require File.dirname(__FILE__) + '/beanie/version'
77
+ require File.dirname(__FILE__) + '/beanie/work_centre_group'
78
+ require File.dirname(__FILE__) + '/beanie/work_centre'
79
+
80
+ module Beanie
81
+ @@base_uri = 'https://bean.ie'
82
+ @@token = nil
83
+
84
+ class << self
85
+ attr_accessor :api_key, :api_version, :secret_key
86
+ end
87
+
88
+ def self.api_url(url='', api_base_uri=nil)
89
+ (api_base_uri || @base_uri) + url
90
+ end
91
+
92
+ def self.connect(opts = {})
93
+ @api_key = opts[:api_key] if opts[:api_key]
94
+ @secret_key = opts[:secret_key] if opts[:secret_key]
95
+ p opts
96
+ puts "API KEY: #{@api_key}"
97
+ puts "SECRET: #{@secret_key}"
98
+ end
99
+
100
+ def self.get_token
101
+ unless @@token
102
+ #
103
+ # We need to get an authentication token from the server
104
+ unless @api_key and @secret_key
105
+ raise AuthenticationError.new('No API Key / Secret Key provided.' \
106
+ 'Set your API Key using "Beanie.api_key = <API-KEY>". ' \
107
+ 'Set your Secret Key using "Beanie.secret_key = <SECRET>". ' \
108
+ 'You can generate API keys from the Beanie web interface. ' \
109
+ 'See https://bean.ie/en/apikey for details or email support@bean.ie ' \
110
+ 'for further assistance.')
111
+ end
112
+ url = "#{@@base_uri}/api/authenticate"
113
+ data = {:api_key => @api_key, :secret_key => @secret_key}
114
+ response = RestClient.post(url, data.to_json, :content_type => :json, :accept => :json)
115
+ puts "Token response: #{response.code} (data: #{response.body})"
116
+ raise AuthenticationError.new('Authentication failure.') unless response.code == 202
117
+ data = JSON.parse(response.body)
118
+ @@token = data['token']
119
+ end
120
+ @@token
121
+ end
122
+
123
+ def self.base_uri
124
+ @@base_uri
125
+ end
126
+
127
+ def self.base_uri=(uri)
128
+ @@base_uri = uri
129
+ end
130
+ end