Class: Sellsy::Invoice

Inherits:
Object
  • Object
show all
Defined in:
lib/sellsy/invoices.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#amountObject

Returns the value of attribute amount.



9
10
11
# File 'lib/sellsy/invoices.rb', line 9

def amount
  @amount
end

#client_idObject

Returns the value of attribute client_id.



6
7
8
# File 'lib/sellsy/invoices.rb', line 6

def client_id
  @client_id
end

#idObject

Returns the value of attribute id.



5
6
7
# File 'lib/sellsy/invoices.rb', line 5

def id
  @id
end

#packaging_nameObject

Returns the value of attribute packaging_name.



7
8
9
# File 'lib/sellsy/invoices.rb', line 7

def packaging_name
  @packaging_name
end

#shipping_nameObject

Returns the value of attribute shipping_name.



8
9
10
# File 'lib/sellsy/invoices.rb', line 8

def shipping_name
  @shipping_name
end

#tax_rateObject

Returns the value of attribute tax_rate.



11
12
13
# File 'lib/sellsy/invoices.rb', line 11

def tax_rate
  @tax_rate
end

#unit_amountObject

Returns the value of attribute unit_amount.



10
11
12
# File 'lib/sellsy/invoices.rb', line 10

def unit_amount
  @unit_amount
end

Instance Method Details

#create(invoice) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
# File 'lib/sellsy/invoices.rb', line 13

def create(invoice)
  command = {
      'method' => 'Document.create',
      'params' => {
          'document' => {
              'doctype' => 'invoice',
              # 'parentId' => 'parentId',
              'thirdid' => invoice.client_id
              # 'displayedDate' => 'displayedDate',
              # 'subject' => 'document_subject',
              # 'notes' => 'document_notes',
              # 'tags' => 'document_tags',
              # 'displayShipAddress' => 'displayshippaddress_enum',
              # 'rateCategory' => 'rateCategory',
              # 'globalDiscount' => 'globalDiscount',
              # 'globalDiscountUnit' => 'globalDiscountUnit',
              # 'hasDoubleVat' => 'hasDoubleVat',
              # 'currency' => 'currency',
              # 'doclayout' => 'doclayout',
              # 'payMediums' => 'payMediums'
          },
          # 'paydate' => {
          # 'id' => 'paydate_id',
          # 'xdays' => 'paydate_xdays',
          # 'endmonth' => 'paydate_endmonth',
          # 'scaledDetails' => 'paydate_scaledDetails',
          # 'custom' => 'paydate_custom'
          # },
          # 'thirdaddress' => {
          #     'id' => 'thirdaddress_id'
          # },
          # 'shipaddress' => {
          #     'id' => 'shipaddress_id'
          # },
          'row' => {
              '1' => {
                  'row_type' => 'packaging',
                  'row_packaging' => invoice.packaging_name,
                  'row_name' => 'row_name',
                  'row_unitAmount' => invoice.unit_amount,
                  'row_tax' => invoice.tax_rate
                  # 'row_taxid' => 'row_taxid',
                  # 'row_tax2id' => 'row_tax2id',
                  # 'row_qt' => 'row_quantity',
                  # 'row_isOption' => 'row_option',
                  # 'row_discount' => 'row_discount',
                  # 'row_discountUnit' => 'row_discountUnit'
              },
              '2' => {
                  'row_type' => 'shipping',
                  'row_shipping' => invoice.shipping_name,
                  # 'row_name' => 'row_name',
                  'row_unitAmount' => invoice.unit_amount,
                  'row_tax' => invoice.tax_rate,
                  # 'row_taxid' => 'row_taxid',
                  'row_tax2id' => invoice.quantity
                  # 'row_qt' => 'row_quantity',
                  # 'row_isOption' => 'row_option',
                  # 'row_discount' => 'row_discount',
                  # 'row_discountUnit' => 'row_discountUnit'
              }
              # '3' => {
              # 'row_type' => 'item',
              # 'row_linkedid' => 'catalogue_id_link',
              # 'row_declid' => 'catalogue_declid_link',
              # 'row_name' => 'row_name',
              # 'row_notes' => 'row_notes',
              # 'row_unit' => 'row_unit',
              # 'row_unitAmount' => 'row_unit_amount',
              # 'row_tax' => 'row_taxrate',
              # 'row_taxid' => 'row_taxid',
              # 'row_tax2id' => 'row_tax2id',
              # 'row_qt' => 'row_quantity',
              # 'row_isOption' => 'row_option',
              # 'row_purchaseAmount' => 'row_purchaseAmount',
              # 'row_discount' => 'row_discount',
              # 'row_discountUnit' => 'row_discountUnit'
              # },
              # '4' => {
              # 'row_type' => 'once',
              # 'row_name' => 'row_name',
              # 'row_notes' => 'row_notes',
              # 'row_unit' => 'row_unit',
              # 'row_unitAmount' => 'row_unit_amount',
              # 'row_tax' => 'row_taxrate',
              # 'row_taxid' => 'row_taxid',
              # 'row_tax2id' => 'row_tax2id',
              # 'row_qt' => 'row_quantity',
              # 'row_isOption' => 'row_option',
              # 'row_discount' => 'row_discount',
              # 'row_discountUnit' => 'row_discountUnit'
              # }
          }
      }
  }

  Sellsy::Api.request command
end

#updateObject



112
113
114
# File 'lib/sellsy/invoices.rb', line 112

def update

end