How to enter additional information (attributes) in the Print / Invoice
I would like to add other information to print / Invoice.
I want to add.
Name of Client:
TaxVat:
Product Name:
Product Price:
Product Attributes:
thank you
http://www.magentocommerce.com/wiki/5_-_modules_and_development/orders/editing_an_invoice_pdf
This should take you through the process of modifying the PDF that is generated by the admin panel
Related
In my spree store I have changed the currency settings from USD to AUD and this seems to work mostly but for the existing users when and item is added to the cart the cart shows the old USD price despite showing the new AUD price before adding to cart.
Inspecting the order in the rails console shows the order is set to USD still, new users have their orders set to AUD. How can I change it so all users are now on the new currency?
In order.rb there is a before_validation
before_validation :set_currency
and code for this method is
def set_currency
self.currency = Spree::Config[:currency] if self[:currency].nil?
end
here currency is set to default currency only if it's not present, So if you want all the active orders to get modified with the new currency that you set through general settings, you can modify the above method to ensure it always set currency before validation.
def set_currency
self.currency = Spree::Config[:currency]
end
Please let me know if you still face any issues
I am new on RAILS, so don't hit me.
I consider such problem:
- author
has_many :books
- book
belongs_to :author
In console I create a new author, per example:
ar = Author.new(fname: "Frank", lname: "Herbert")
ID of this record is not set before save.
Then I create some books from object ar:
ar.books.new(title: "Dune"), ar.books.new(title: "The Green Brain")
No errors. But when I list books:
ar.books.all
got an empty list.
I figured out that first I have to save ar, and then I can add books.
Is there a way to save ar with books, no need saving ar without books before?
Sure you can!
You need to call ar.books to look up for books that you have added. When you call ar.books.all ActiveRecord tries to find something in database (obviously it returns empty array). So just:
author = Author.new(fname: "Frank", lname: "Herbert")
author.books.build(title: "Dune")
author.save
It will save author & books as you expect. By the way use build method instead of new. In this way you show that you are going to create record soon.
Follow below code:
First create Author and then create books with author as foreign key.
ar = Author.new(fname: "Frank", lname: "Herbert")
ar.save
ar.books.create(title: "Dune")
ar.books.create(title: "The Green Brain")
OR
ar = Author.new(fname: "Frank", lname: "Herbert")
ar.books.build(title: "Dune")
ar.books.build(title: "The Green Brain")
ar.save
I am newbie in rails ,i don't know how implement this feature in application . please suggest me any basic idea.
if any user create a book ->
1) Book name should be auto suggested like Google search(if user enter a name , it should be automatically search correct name from Google and suggest to user ).
2) Author name also be auto suggested like Google Search(if user enter a name , it should be automatically search correct name from Google and suggest to user ).
Book Model has following attributes .
> Book.new
=>Book(id: integer, user_id: integer, author: string, name: string, published_at: datetime)
I seem to have run into a problem with trying to use a model in another model in Rails.
I am pulling a list of users from Active Directory with LDAP in a dropdown. I want to parse the cn that I get from Ldap into a firstname and lastname.
The problem I am running into is that I need to find a record in the users model. The parsing is being done in observations.rb.
Observation.rb:
def parse_employee
#emp_name = '' #initialize
self.employee_raw = self.employee_raw[2...-2] # get rid of the quotes and brackets
#emp_name = self.employee_raw.split(' ') # split first/last names
#emp_first_name = #emp_name[0] #Grab the first name
#emp_last_name = #emp_name[1] # grab the surname
#user = User.where("last_name like ?", #emp_last_name)
self.employee_id = #user.id
end
I've played with this quite a bit and it appears that I can't reference other models from within a model.
To sum up, what I am trying to do is
1. Have the user select the appropriate person from a dropdown that is pulled via LDAP from active directory.
2. Use the first and last names to find the appropriate user in my user table (Right now I'm just trying to get it to work with the last name as that is unique enough)
3. When I find the correct user in the user table, enter that id in the employee_id field in my observations table.
I am using Cucumber, Webrat, and Pickle in conjunction.
When I write a scenario, I can do something like this:
Given a product exists with title: "Bread"
When I go to the edit page for that product
And I fill in "Title" with "Milk"
And I press "Save changes"
Then I should see "Successfully edited product."
And I should be on that car's page
Notice the for that product. This is something pickle provides which is very convenient for referencing the record for a product I'm checking the existence of. That last line, though, is not working.
Basically I am trying to make sure I am the show page for that record, but since I do not have an ID for it, I don't know how to reference it.
Any help?
Thanks!
To have a reference to the created product or anything else you can use naming that's provided by pickle:
Given product: "bread" exists with title: "Bread"
...
Then I should be on the showing page for the product "bread"
To handle this url you will need to add couple lines into /features/support/paths.rb:
when %r{^the showing page for the (.+)$}
polymorphic_path(model($1))
Also it could be useful to handle edit path for the model like this:
Then I should be on the edit page for the product "bread"
paths.rb:
when %r{^the edit page for the (.+)$}
polymorphic_path(model($1), :action => 'edit')