Create a revision of the company info when it has related invoices (refs: #ba1a26)
This commit is contained in:
parent
016cb0b21d
commit
fb20d2825f
16
stoptime.rb
16
stoptime.rb
|
@ -915,6 +915,7 @@ module StopTime::Controllers
|
||||||
end
|
end
|
||||||
invoice = Invoice.create(:number => number)
|
invoice = Invoice.create(:number => number)
|
||||||
invoice.customer = Customer.find(customer_id)
|
invoice.customer = Customer.find(customer_id)
|
||||||
|
invoice.company_info = CompanyInfo.last
|
||||||
|
|
||||||
# Handle the hourly rated tasks first by looking at the selected time
|
# Handle the hourly rated tasks first by looking at the selected time
|
||||||
# entries.
|
# entries.
|
||||||
|
@ -976,9 +977,9 @@ module StopTime::Controllers
|
||||||
@format = "html"
|
@format = "html"
|
||||||
end
|
end
|
||||||
@invoice = Invoice.find_by_number(@number)
|
@invoice = Invoice.find_by_number(@number)
|
||||||
|
|
||||||
@company = CompanyInfo.first
|
|
||||||
@customer = Customer.find(customer_id)
|
@customer = Customer.find(customer_id)
|
||||||
|
|
||||||
|
@company = @invoice.company_info
|
||||||
@tasks = @invoice.summary
|
@tasks = @invoice.summary
|
||||||
@period = @invoice.period
|
@period = @invoice.period
|
||||||
|
|
||||||
|
@ -1248,7 +1249,16 @@ module StopTime::Controllers
|
||||||
# (Views#company_form).
|
# (Views#company_form).
|
||||||
# If the provided information was invalid, the errors are retrieved.
|
# If the provided information was invalid, the errors are retrieved.
|
||||||
def post
|
def post
|
||||||
@company = CompanyInfo.first
|
@company = CompanyInfo.find(@input.revision || :last)
|
||||||
|
# If we are editing the current info and it is already associated
|
||||||
|
# with some invoices, create a new revision.
|
||||||
|
@history_warn = true if @company != CompanyInfo.last
|
||||||
|
if @company == CompanyInfo.last and @company.invoices.length > 0
|
||||||
|
old_company = @company
|
||||||
|
@company = old_company.clone # FIXME: depends on rails versioN!
|
||||||
|
@company.original = old_company
|
||||||
|
end
|
||||||
|
|
||||||
attrs = ["name", "contact_name",
|
attrs = ["name", "contact_name",
|
||||||
"address_street", "address_postal_code", "address_city",
|
"address_street", "address_postal_code", "address_city",
|
||||||
"country", "country_code",
|
"country", "country_code",
|
||||||
|
|
Loading…
Reference in New Issue