lib/skr/models/invoice.rb in stockor-0.4.0 vs lib/skr/models/invoice.rb in stockor-0.5.0
- old
+ new
@@ -29,10 +29,12 @@
has_visible_id
has_random_hash_code
has_gl_transaction
is_order_like
+ export_methods :total_hours
+
belongs_to :sales_order, export: true
belongs_to :customer_project, export: true
belongs_to :customer, export: true
belongs_to :location, export: true
belongs_to :pick_ticket, inverse_of: :invoice, export: true
@@ -112,21 +114,23 @@
def is_locked?
GlPeriod.is_date_locked?(self.invoice_date)
end
+ def total_hours
+ lines.reduce(BigDecimal.new('0')){|t, l|
+ l.time_entry ? t + l.qty : t
+ }
+ end
+
private
# set the state if the amount_paid was changed
def apply_payment(pymnt)
if self.fully_paid? && self.may_mark_paid?
self.mark_paid!
elsif self.payments.total > 0 && self.may_mark_partialy_paid?
- Lanes.logger_debug('paying')
-
- #self.mark_partialy_paid!
-
- Lanes.logger_debug('paid')
+ self.mark_partialy_paid!
end
end
def set_defaults