Database Relationship Help

Developing Invoicing and Inventory management database with FM Pro 11.  Tables are Customers, Invoices, LineItems, Part Categories, Parts, Customer Discounts.  Customer Discounts are related to Customers with Customer No as the FK.  Invoices are related to Customers with the Customer No. as the FK. Line Items are related to Invoices with the Invoice No. as the FK.  Parts are related to Part Categories with the Category as the FK.  The problem is with the Customer Discounts, which fields are Customer No., Parts Category, and Discount Amt.  Everything works fine except the I cannot figure out the relationship structure that allows the customer discount to be applied based on the Part Category and the Customer No. in the line items table for each line item.  Any help would be GREATLY appreciated! Screenshot of relationship diagram included.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

aushiu suhaud ashsauda
I assume you are going to have a calculation field in the 'InvoiceLineItems' table that calculates the sub total based on the Discount & Qty Sold ?

If so, add an instance of 'CustomerDiscount' onto 'Parts' related by 'PartCategory'

Make a calculation in the context of 'LineItems'  There could be a separate calculation field called 'Discount' in LineItems or you could do it all in the SubTotal calculation

There will be a discount if LineItems_Parts_CustomerDiscount::CustomerNo = Customers::CustomerNo

In the InvoiceLineItems Table, create a global fields for $CuntomerNo and $PartsCategory that are a calculated un-stored field, then create a dual relationship to the Parts discount table from the LineItems table. And that should work

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

sstiltonAuthor Commented:
Still not working.  It will get the correct category, but then it applies the discount of the first customer record with that category.  Each customer may have a different discount rate for the same category.  For example customer1 may have a discount rate of 10% for category1 and customer2 may have a discount rate of 15% for category1.  This is the trouble I have had.  I can get either the correct category or the correct discount, but I haven't been able to get the correct category and discount for the each customer.
sstiltonAuthor Commented:
The last post was for TomDWallace I did not see comments from jvaldes.
sstiltonAuthor Commented:
Genuis!  Worked great! Thank you!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
FileMaker Pro

From novice to tech pro — start learning today.