-
-
Save anonymous/49dfa640b9d9f177b4cc to your computer and use it in GitHub Desktop.
Example rules
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
engine << [ "Order", "subtotal", 10 ] | |
engine << [ "Guest", "service_fee_markup", 10 ] | |
engine << [ "Guest", "service_fee_fixed", 10 ] | |
engine << [ "Host", "service_fee_markup", 10 ] | |
engine << [ "Host", "service_fee_fixed", 10 ] | |
engine << [ "Guest", "trans_fee_markup", 10 ] | |
engine << [ "Guest", "trans_fee_fixed_amount", 10 ] | |
engine << [ "Host", "trans_fee_markup", 10 ] | |
engine << [ "Host", "trans_fee_fixed_amount", 10 ] | |
engine.rule "guest_service_fee_markup_amount" do | |
forall { | |
has :Order, "subtotal", :subtotal | |
has :Guest, "service_fee_markup", :service_fee_markup | |
} | |
make { | |
action { |token| | |
engine << [ "Guest", "service_fee_markup_amount", ( token[:subtotal]*token[:service_fee_markup]/CosembleWEBAPP::Application::UNIT_ONE_HUNDRED ).round ] | |
} | |
} | |
end | |
engine.rule "total" do | |
forall { | |
has :Order, "subtotal", :subtotal | |
has :Guest, "service_fee_markup_amount", :service_fee_markup_amount | |
has :Guest, "service_fee_fixed", :service_fee_fixed | |
} | |
make { | |
action { |token| | |
engine << [ "Order", "total", token[:subtotal]+token[:service_fee_markup_amount]+token[:service_fee_fixed] ] | |
} | |
} | |
end | |
engine.rule "host_service_fee_markup_amount" do | |
forall { | |
has :Order, "subtotal", :subtotal | |
has :Host, "service_fee_markup", :service_fee_markup | |
} | |
make { | |
action { |token| | |
engine << [ "Host", "service_fee_markup_amount", ( token[:subtotal]*token[:service_fee_markup]/CosembleWEBAPP::Application::UNIT_ONE_HUNDRED ).round ] | |
} | |
} | |
end | |
engine.rule "guest_trans_fee_markup_amount" do | |
forall { | |
has :Order, "total", :total | |
has :Guest, "trans_fee_markup", :trans_fee_markup | |
} | |
make { | |
action { |token| | |
engine << [ "Guest", "trans_fee_markup_amount", ( token[:total]*token[:trans_fee_markup]/CosembleWEBAPP::Application::UNIT_ONE_HUNDRED ).round ] | |
} | |
} | |
end | |
engine.rule "host_trans_fee_markup_amount" do | |
forall { | |
has :Order, "total", :total | |
has :Host, "trans_fee_markup", :trans_fee_markup | |
} | |
make { | |
action { |token| | |
engine << [ "Host", "trans_fee_markup_amount", ( token[:total]*token[:trans_fee_markup]/CosembleWEBAPP::Application::UNIT_ONE_HUNDRED ).round ] | |
} | |
} | |
end | |
engine.rule "guest_trans_fee" do | |
forall { | |
has :Guest, "trans_fee_markup_amount", :service_fee_markup_amount | |
has :Guest, "trans_fee_fixed", :service_fee_fixed | |
} | |
make { | |
action { |token| | |
engine << [ "Guest", "trans_fee", token[:service_fee_markup_amount]+token[:service_fee_fixed] ] | |
} | |
} | |
end | |
engine.rule "host_trans_fee" do | |
forall { | |
has :Host, "trans_fee_markup_amount", :trans_fee_markup_amount | |
has :Host, "trans_fee_fixed", :trans_fee_fixed | |
} | |
make { | |
action { |token| | |
engine << [ "Host", "trans_fee", token[:trans_fee_markup_amount]+token[:trans_fee_fixed] ] | |
} | |
} | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment