Need Help with Complementary Attributes for time and kilometer

Hello
Scenario: Car Rental Company rent cars with drivers, the customer call to book a car for 8 hours upto 250km per day for fixed amount and extra amount for additional hour or additional kilometers or both with fixed rate for extra hour or extra kilometer, there are different rate per customer
how to do that with complementary attributes
the inputs
start odometer
end odometer
start hour
end hour
calculated result give how many kilometers and how many hours
the result check customer rate and get 2 other results fixed amount for basic rate 8 hours and upto 250km, and extra rate for extra hours and extra kilometers one or both if the both are extra

example: the customer made 300 km and 10 hours
basic rate for that customer 200USD for 8 hours upto 250km
extra rate 20 USD per hour & 1 USD per kilometer
the calculation
200 USD Basic
40 USD for 2 extra hours
50 USD for extra 50 kilometer
Total 290 USD
the invoice should represent this calculation also
please help
Thanks

have you created any Complementary Attributes? Can we see the configuration?

You might need to create them on Proposals, Orders and Invoices. Consider using the API to do it.

i created it in products and services also in invoice for now until i have to calculation formula to follow in proposals and orders

i am still missing the calculation field to get the km and hours but i dont know how the computed should be

i am missing how to make correct formula to calculate the kilometer

click the little i next to the text “Computed field”

yes i already tried many but failed if you give me one example how to make km calculation from endodo - startodo i can understand what i am missing

($objectoffield->array_options['endodo'])-($objectoffield->array_options['startodo'])

Hello ksar
it’s not working as attached, after i changed kilo to float the error message gone but the result is 0




Hello,

Yes sorry i was to quick :
($objectoffield->array_options['options_endodo'])-($objectoffield->array_options['options_startodo'])

Hello, still not working


Seems that it doesn’t like the parenthesis

its working now thank you too much
i added all needed attributes
now the major point
i created complementary attributes for service, third party and invoice
default hours, default km, extra hour rate, extra km rate
in service i set default hours to 8 hours, default km 150, extra hour rate 200, extra km rate 15, default price 2800
in third party i set default hours 7, default km 130, extra hour rate 180, extra km rate 20, customer price 2000
this to set basic price for the service and different price per customer
i created invoice for that customer and select the service
1- first note the service default attributes shown not the customer defaults except customer price (how to trigger customer default not the service default - as customer price not default price)
2- i need to get the customer price in the default amount attribute
3- i need the attribute total to jump into unit price net before tax
all results shown in pdf file attached, need to hide qty and change unit price net with total
please help with thanks
(PROV12).pdf (132.5 KB)




I think there is an option or module to get individual prices pr. customer

Should be possible with calculated field but will require some hours to find the good one, you can start with this exemple :

(($reloadedobj = new Societe($db)) && ($reloadedobj->fetchNoCompute($objectoffield->socid) > 0)) ? $reloadedobj->array_options['options_xxxxxxxxx'] : '-1'

Same as 1

Impossible with extra field, need to develop a specific module.

Hello Kasr
i am realy appreciate your kind help, attached the llx_societe_extrafields which i want to reload in the invoice you may give me one example for how to reload default_hours than i can follow for the rest and 90% of the problem solved

(($reloadedobj = new Societe($db)) && ($reloadedobj->fetchNoCompute($objectoffield->socid) > 0)) ? $reloadedobj->array_options['options_default_hours'] : '-1'

the result -1 something not work
but i need to this extrafield value from the customer attributes to load like default hours for the products not to be calculated (attached)

let explain again
the default hours, default km, etc preloaded in the pictures is the attributes from the product itself, i need to load these attributes from the customer attributes not from product attributes then i can go with the other calculations