Sha256: 522adbde09e75b53fabf82dbc6a63cb4a9b4b303a74c7a55b547e36df08bae08
Contents?: true
Size: 1.36 KB
Versions: 1
Compression:
Stored size: 1.36 KB
Contents
module Skr module Handlers class InvoiceFromTimeEntries < ::Lanes::API::ControllerBase def initialize(model, authentication, params, data) @options = data @entry_ids = data['time_entry_ids'] @project = CustomerProject.find( data['customer_project_id'] ) @location = Location.default # should be set on project maybe? @sku_loc = @project.sku.sku_locs.find_by(location: @location) end def perform_creation invoice = Invoice.new( notes: @options['notes'], po_num: @options['po_num'] || @project.po_num, customer: @project.customer, customer_project: @project ) @entry_ids.each do | entry_id | entry = TimeEntry.find(entry_id) invoice.lines.build( time_entry: entry, sku_loc: @sku_loc, price: @project.rates['hourly'], description: entry.description, qty: ((entry.end_at - entry.start_at) / 1.hour) ) end std_api_reply :create, { invoice: invoice }, success: invoice.save end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
stockor-0.4.0 | lib/skr/handlers/invoice_from_time_entries.rb |