Method: Osm::Invoice#delete

Defined in:
lib/osm/invoice.rb

#delete(api) ⇒ Boolean

Delete the invoice from OSM

Returns:

  • (Boolean)

    Whether the invoice was deleted from OSM



155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
# File 'lib/osm/invoice.rb', line 155

def delete(api)
  Osm::Model.require_ability_to(api, :write, :finance, section_id)
  return false if finalised?

  data = api.perform_query("finances.php?action=deleteInvoice&sectionid=#{section_id}", {
    'invoiceid' => id,
  })
  if (data.is_a?(Hash) && data['ok'].eql?(true))
    # The cached invoices for the section will be out of date - remove them
    cache_delete(api, ['invoice_ids', section_id])
    cache_delete(api, ['invoice', self.id])
    return true
  end
  return false
end