-
Notifications
You must be signed in to change notification settings - Fork 69
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update time entry status to billed once the invoice is sent to the client #292
Update time entry status to billed once the invoice is sent to the client #292
Conversation
Current Code Coverage Percent of this PR:98.17 %Files having coverage below 100%
|
I will review it tomorrow. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@murtaza-bagwala Suggested some changes. We will also need to add unit test for update_timesheet_entry_status!
@@ -47,7 +47,7 @@ def send_invoice | |||
authorize invoice | |||
|
|||
invoice.send_to_email(subject: invoice_email_params[:subject], recipients: invoice_email_params[:recipients]) | |||
|
|||
invoice.update_timesheet_entry_status |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
invoice.update_timesheet_entry_status | |
invoice.update_timesheet_entry_status! |
app/models/invoice.rb
Outdated
@@ -62,4 +62,9 @@ class Invoice < ApplicationRecord | |||
def sub_total | |||
@_sub_total ||= invoice_line_items.sum { |line_item| line_item[:rate] * line_item[:quantity] } | |||
end | |||
|
|||
def update_timesheet_entry_status |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
def update_timesheet_entry_status | |
def update_timesheet_entry_status! |
app/models/invoice.rb
Outdated
@@ -62,4 +62,9 @@ class Invoice < ApplicationRecord | |||
def sub_total | |||
@_sub_total ||= invoice_line_items.sum { |line_item| line_item[:rate] * line_item[:quantity] } | |||
end | |||
|
|||
def update_timesheet_entry_status | |||
timesheet_entry_ids = invoice_line_items.map { |line_item| line_item.timesheet_entry_id } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
timesheet_entry_ids = invoice_line_items.map { |line_item| line_item.timesheet_entry_id } | |
timesheet_entry_ids = invoice_line_items.pluck(:timesheet_entry_id) |
app/models/invoice.rb
Outdated
|
||
def update_timesheet_entry_status | ||
timesheet_entry_ids = invoice_line_items.map { |line_item| line_item.timesheet_entry_id } | ||
TimesheetEntry.where(id: timesheet_entry_ids).update(bill_status: :billed) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TimesheetEntry.where(id: timesheet_entry_ids).update(bill_status: :billed) | |
TimesheetEntry.where(id: timesheet_entry_ids).each(&:billed!) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM after addressing changes suggested by Shivam
Notion card
Summary
https://www.notion.so/saeloun/6afc9500b2cc42af86be55f37894fb09?v=b4528f26f4424af7beaf036262796cb3&p=430921c655ed4421a3187268d6707283
Preview
NA
Type of change
Please delete options that are not relevant.
How Has This Been Tested?
Checklist:
closes #257