Wrong quantity defined for salary rule odoo 9 - odoo-9

Can you help me how get number of hours from working days with python code?
Example:

Try this:
if contract.paid_hourly:
result = 1 * worked_days.WORK01.number_of_hours
else:
result = 100

Related

DolphinDB Calculate the time difference between TIMESTAMP and DATETIME?

I tried the script in DolphinDB:
t =table(
array(DATETIME, 0) as MDTime,
array(TIMESTAMP, 0) as ReceivedTime
)
share t as testShareTable;
select * from testShareTable;
select avg(ReceivedTime - MDTime) as DelayTime from testShareTable;
The table is
But the output is not as expected
Any suggestions to modify the code? Btw, I'd like to add 8 hours to ReceivedTime. How can I obtain the result?
Modified the last line of code:
select avg(temporalAdd(ReceivedTime,8H) - timestamp(MDTime)) as DelayTime from testShareTable;

Carbon its parsing my date range +1 day

I have the date range
{"from":"2018-02-12T23:00:00.703Z","to":"2018-02-13T22:59:59.703Z"}
When I do a
$periodFrom = Carbon::parse($request->from);
$periodTo = Carbon::parse($request->to);
And then I want to get the number of dates between those dates I do
$days = $periodTo->diffInDays($periodFrom);
And for some reason its giving me 0 days instead of 1 day
Edit:
You can do this:
$days = round($periodTo->diffInHours($periodFrom) / 24);
Instead of round() you can also use ceil() method, it depends on what exactly result you want to get for 1.2 days, 1.8 days etc.
If you want to get 1 day instead of 0, but for all other cases you want to get just full days (8 for 8.9 for example), do this:
$diff = $periodTo->diffInHours($periodFrom);
$days = $diff === 0 ? 1 : $diff;

if value more than DAX Query

I am trying to make a simple DAX query where if the value is more than 8 it should be consider as a 8
As an example
if value is 24 consider as 8
So whenever the value is 8 or more than 8, it should be 8.
How i can do that in a DAX query or in a POWER Query !
I have search a lot here ---
https://msdn.microsoft.com/en-us/library/ee634907.aspx
but did not find any solution !
Do anyone knows any solution to this problem !
Power Query
// Add new custom field
Max8 =
if [FieldName] > 8
then 8
else [FieldName]
DAX
// Calculated column
Max8 =
IF(
'TableName'[FieldName] > 8
,8
,'TableName'[FieldName]
)
// As a measure to test another measure's return value
Max8:=
IF(
[MeasureName] > 8
,8
,[MeasureName]
)
Use the two parameter version of the MIN function:
MIN('TableName'[FieldName], 8)
This gives you the smaller of 'TableName'[FieldName] and 8.
I solved a similar situation by using AND and Nested IF
RANK = IF(AND(STUDENT[SCORE] >= 50, STUDENT[SCORE] <=100),"One" , "Two")

Finding start and end date of month

I found code example for finding the start and end day of the current month I'm in. I tried to jump start this code, but am having a hard time figuring out what I have gone wrong.
month = params[:month].to_i
date_start = DateTime.new Date.today.year, params[:month], 1
date_end = (date_start >> 1) + 1 # will add a month and a day
#trips = Trip.all :date => date_start..date_end
I'm not 100% sure what to feed into params. Hope someone can help.
I am not sure if I understand your question correctly, maybe what you need is this? :
month = 9
date_start = Date.new(Time.now.year, month, 1)
date_end = date_start.next_month - 1
params should contains month(numeric) i.e between 1 - 12
For e.g params = {:month => '4'}
Also in second line use month instead of params[:month]

need help in sum of time in rdlc

I am working on attendance management system.
In my project i want to display total worked hours of the employee in the daily report.
In my database table i have already calculated working hours for the each employee.
Now i want to display Total worked hours of each and every entry at the bottom of the report.
e.g
EmployeeId EmployeeName WorkedHours
1 ABC 04:00:25
2 XYZ 07:23:01
3 PQR 11:02:15
SO i want to display total of all 3 employees at the end of report in RDLC.
like Total: 22:25:42
Please let me know how can i achieve it?
You just need to add =Sum(Fields!WorkedHours.Value) in footer row for "WorkedHours" column.
see the link in MSDN http://msdn.microsoft.com/en-us/library/ms252113(v=vs.80).aspx
You can use the TimeStamp class gether with the Sum function,
follow an example:
=TimeSpan.FromMinutes(Sum(Fields!Dirigindo.Value))
Try This out and see if it works
=(SUM(Cint(Split(Fields!WORKEDHOUR.value,":").GetValue(0))) + (SUM(Cint(Split(Fields!WORKEDHOUR.Value,":").GetValue(1))) + Sum(Cint(split(Fields!WORKEDHOUR.Value,":").GetValue(2)))\60)\60 ).ToString + ":" + ((SUM(Cint(Split(Fields!WORKEDHOUR.Value,":").GetValue(1))) + Sum(Cint(split(Fields!WORKEDHOUR.Value,":").GetValue(2)))\60) Mod 60).ToString + ":" + (Sum(Cint(split(Fields!WORKEDHOUR.Value,":").GetValue(2))) Mod 60).ToString
Facing the same issue here is your final answer.
Step1: Go to your textbox expression and past below code
=Code.MinutesToHoursMinutes(SUM(Hour(Fields!TTShortTime.Value)*60)+SUM(Minute(Fields!TTShortTime.Value)))
Step2: Goto your rdlc report properties => Tab Code, Here past below function
Function MinutesToHoursMinutes(ByVal vMins As Integer) As String
Dim Mins As Integer
Dim Hours As Integer
vMins = IIF(vMins <= 0, 0, vMins)
Hours = Floor(vMins / 60)
Mins = vMins - (Hours * 60)
MinutesToHoursMinutes = IIF(Hours < 9, "0" & CStr(Hours), CStr(Hours)) & ":" & IIF(Mins < 9, "0" &
CStr(Mins), CStr(Mins))
Return MinutesToHoursMinutes
End Function
Here in Step1 we get hours and convert it into minutes then get minutes and sum with hour calculated minutes.
then passes it to function which returns string format like hh:mm

Resources