I need help!!! and google isn't helping

nullable

New member
I need help!!! I am new to grails - trying to have a subtotal, taxes and total in my gsp for a Purchase Order app i created.
Where do i do accomplish this, in controller or gsp? and how?

Code:
class PODetails {

	static belongTo = [po:PO]
	
    static constraints = {
    }

	Double quantity
	String item
	String description 
	Double unitCost
		
}
 

dave

Administrator
Staff member
Take a step back, think about the logical flow of your requirements. Grails is great at allowing you to build quickly according to your needs, as opposed to having to build 'around' your requirements of even changing the ideal requirements...

Anyway.. Think where this data should be held, against the purchase order or the items that make up a purchase order...

Then when you're happy you understand what you need, think which stage the data commits and calculations should be carried out.

You may have a scenario where you update the totals after each item is added.. or you may create the whole purchase order and add its items in a batch, then calculate totals, then save..

There's no single answer for what you're wanting to do I'm afraid - it depends is the answer :) But I do suggest mapping it out on paper first and then you should find doing the grails side is easy once you thoroughly understand what you want to accomplish.
 

nullable

New member
Thanks Dave,
I will try want you have recommend, but how do I create a subtotal and add taxes in the gsp view?
 

dave

Administrator
Staff member
Well as tax rates change, I would be tempted to store the taxrate, tax due and total in your purchase order object (PO)...

Calculate the tax/totals prior to saving.

And also rename your PO domain object to PurchaseOrder, the few seconds renaming will save you much more time in the long run when you come back to your code.
 
Top