For many of those situations, you can check out the evaluate function. You can store the calculation expression for a given item in a pricing table and then you look up the calculation and use evaluate to apply it to the current record.
For your matrix solution, I'd try real hard to generate a calculated expression that produces the same results as the matrix as that will be easier to implement. If that isn't possible, you can use a separate look up to look up the values from your matrix and an auto-enter calculation can select from either source (Price list or pricing matrix) based on values you've entered in the invoice line item record for that item.
Let me make sure I understand. I am fairly new to Filemaker.
Make a pricing table. In this table I will have ALL the products.
Enter the Product on the Invoice(using a Lines portal).
How would the customer know whether to enter a width or length? What about whether the products have certain limitation?
This is not something that will be simple to set up. But all of that can be looked up from the products (pricing) table--including text that instructs the user as to what should be entered.
In simple form, you can have a table like this:
ProductID Price Instructions
234 .05 * Length * width Enter length and width in inches
LineItems::ProductID = Products::ProductID
An auto-enter calculation might look like this:
Evaluate ( Products::Price )
Where length and width are fields defined in the LineItems table.
Another option that may work is to define the calculations in the LineItems table, but control which calculation is used by a value or value looked up from the Products table.
Regardless of how you set it up, a good basic table structure with the correct relationships is essential. Just to get you started on the right foot, here's a demo file, created by Comment, that shows the typical table structure for an invoice system. It does not use the above method for calculating prices, but does show the basic layout and table structure you can use: