My case is:
I have a voucher, which has header (date, name, final value) and details which is created from items table.
Items table consist of (goods_id, quantity, price....),
Goods_id is the PK of goods table which has the full information about my stock goods
So, how to create a master form(Voucher) contains Items, every Item related to goods table?
Remaining just as abstract as the question I would suggest to use a nested form with a partial as described in this RailsCast.
Related
I have a table "Tbl_Invoice" with invoice details [Primary key "InvID"] and another table "Tbl_Invoice_Details" with the invoiced item details (items, quantity purchased, rate, amount, total) [primary key "InvDetID" and foreign key "InvID" linked to invoice table]. In the main form "Frm_Invoice" with data source "Tbl_Invoice", I have included a subform with item details from the "Tbl_Invoice_Details".
I have two problems -
The subform shows the total of all the items purchased in the footer (using the sum function from the menu bar). But I am unable to bring the total of the subform to the main form where the discount is calculated, tax added, rounded off (if necessary) and calculates the invoice amount.
I want to create a duplicate record (total invoice with items, etc.) only the customer name, invoice no., date changes. I am using two separate append queries, one for the invoice details and the other for the invoiced item details. Both works. The problem is I am unable to link the new records in the subform/subtable "Tbl_Invoice_Details" with the new record in the main form / main table "Tbl_Invoice".
I am a newbie and do not have much knowledge of VBA. Please help!
As for your second question, use the RecordsetClone of the main form and the subform respectively to copy the main record and the subrecords:
Duplicate records in Subform to New record
For Question one look at the two images, i have attached.
Name of subform in my case is BILLINGDETAILS
Name of control in subform is TOTALPAID,with caption Text2(caption is not relevant to the outcome)
Look closely at how the TOTALPAID control in subform is referenced from the Main form.
For your question two, if you can share the tables relationship window and image of the form link fields , you will get someone in this forum that will answer it.
I have a database table (order's table) that is densely populated with order information as it happens from users with their ids, and I want to get the sum of fees based on different currencies, and render them as a key-value pair report, at the frontend but in a tabular form, and I don't even know how to go about it. Below is an example of the table before I proceed
Orders Table
So how do I craft this such that I will have a comprehensive sum of like currencies and show it in a tablular form in the frontend of the app, such that I have this table below:
comprehensive summary of like currencies based on sum of whatever existed in the orders table above
How do I go about this? Any help will be appreciated. All am thinking of is a key-value pair logic to render that object on the frontend.
From Rails perspective, you need to prepare data that will be rendered in your view. From database perspective, you want to group your orders by currency and sum their charged and network fees. Using a query like this:
Order.group(:currency)
.select("currency, SUM(charged_fee) AS total_charged, SUM(network_fee) AS total_network")
If you simply want to render that, assign it to an instance variable inside some action in a controller and use it in a view. You will be able to access your totals by calling
order.total_charged
order.total_network
for each of the orders.
Hope this makes it clearer for you.
I'm a learning developer building a Product & Inventory tracking platform for the company I work at and my Rails application has a Products table. Within the Products table are a bunch of basic entries, such as SKU, Description, UPC, Manufacturer, etc.
What I want to do is have an option within the Create page to insert custom parameters into something like a text_area to create Product specific entries, for example if I have only a small set of products that would benefit from a Voltage column and don't want to flood my migration with a bunch of lesser used options. What I'm picturing:
'Voltage|120 Volts'
'Housing Material|Steel'
'Duct Size|4"'
and then these could be their own rows in the Product's Show page.
Is anybody aware of a Gem or template that already accomplishes this, or would I need to dive in the deep end myself? I fear something like this is out of my skillset currently.
You can have one hstore column in the migration which will allow you to store multiple dynamic values in the single column as a hash.
You can read more about hstore from here.
I used hstore to store dynamic variants of product in the table.
I have a model called Application, and I need users to be able to add their classes and grades to a column in the database. Is there a way to do this without creating a separate model?
I need users able to press "Add Grades" as many times as they like, creating two new form fields to enter in the class name and grade they got.
I recommend creating a grades model - it is the Rails way. A Grade can belong to an Application. An Application can have many Grades. Each Grade can then have two attributes - a class and a grade.
Alternatively, you can store all your grades for a single application in a single column, but you'll be responsible for the format that they're saved in, ensuring that they are serialized at some point prior to being saved, parsing when you load each Application, etc. Finally, you'll be coming up with additional fields to deal with the parsed grades.
All of this can be avoided by simply creating the Grade model and setting up the appropriate relationship with the Application model.
I have a database table with questions for a competition. These are created for specific competitions from an edit page that our staff can use, so each competition may have different questions.
The Questions table has details like the field name, the type (ie checkbox) and the validation type (ie Required and Compare etc).
Is there any way when trying to build the competition view for the customer to dynamically render the questions to the view (as each competition will have different questions)?
I was thinking a dynamic model or something? I am not really sure. Any ideas are welcome.
I am a little confused about how to fit my objects into this model structure. So do I create the editor template for the question of the Answer?
Basically when an admin user set's up a competition they have an entry in the competition table with the basic comp into then they can create a number of Questions which go into the CompetitionQuestion table which is linked back to the Comp table, each comp has any number of questions - this table holds details like the field name, the type (ie checkbox) and the validation type (ie Required and Compare etc) as mentioned above.
But when the competition view is rendered for a person to enter it it pulls info from the Comp Model (which is fine) then I need to loop through the CompetitionQuestion's (don't know how to create model for this) and render out each question for the specific comp - these are then saved when the person enters in the Entry (basic user and comp details) and EntryAnswer (answer to each question) tables.
So do I link the EditorTemplate up to the CompetitionQuestion object or the EntryAnswer object?
Ah so confused right now :(
What you are looking for is Editor templates.
It's template that you can create to match your custom objects.
Here is a good tutorial on how to proceed.
http://coding-in.net/asp-net-mvc-3-how-to-use-editortemplates/