나는 다음과 같은 모델이 있습니다- 가상 속성
create_table "material_costs", :force => true do |t|
t.string "material"
t.integer "height"
t.integer "width"
t.decimal "cost", :precision => 4, :scale => 2
t.datetime "created_at"
t.datetime "updated_at"
end
이 어떻게 나에게 각 재료의 평방 인치 당 비용을 제공하는 모델에서 가상 속성을 만들 것입니까? 또한
내가 한 부가가치세 값 보유하고 다른 모델 :
create_table "taxes", :force => true do |t|
t.string "name"
t.decimal "rate", :precision => 10, :scale => 0
t.datetime "created_at"
t.datetime "updated_at"
end
어떻게 각각의 재료 아이템 즉, 부가가치세 (VAT) 세율에 추가해야 나에게 평방 인치 당 총 가격을 제공하기 위해 나는이 모델을 사용 하는가를?
편집 - 내가 이제 다음 모델의 VAT 값 저장 : - :
가def calculate_quote
@moulding = Moulding.find(params[:id], :select => 'cost, width')
@mount = MaterialCost.find(1).total_cost_per_square_mm
@glass = MaterialCost.find(2).total_cost_per_square_mm
@backing_board = MaterialCost.find(3).total_cost_per_square_mm
@wastage = AppOption.find(2, :select => 'value')
@markup = AppOption.find(3, :select => 'value')
respond_to do |format|
format.json { render :json => { :moulding => @moulding, :mount => @mount, :glass => @glass, :backing_board => @backing_board, :wastage => @wastage, :markup => @markup } }
end
end
'whichTax.rate'를 사용하여 올바른 요금을 어떻게 내야합니까? – freshest
@freshest : 내 편집을 참조하십시오. 그게 전혀 도움이 되나요? –
모든 것을 모델로 옮기는 방법이 있습니까? 그래서 MaterialCost 모델로부터 총 비용을 얻었을 때 부가가치세가 이미 적용되었습니다. – freshest