7shifts Integration Time Clock and Sales

Yep.

The Punch ID is the same as the user login pin code in Samba.

Im removing all the rules, actions and scripts from the system and trying to add them again in correct order.

Can you check just to be sure because I noticed in your setup you had Autogenerate punch id enabled.

You can remove everything to do with time clock too. My file should contain all that you need.

The file in this topic unfortunately did not have it all in there. I noticed this when i installed the Time Clock file in your tutorial.

I actually thought it did have all the things required too. That was before i imported Tick Clock file and noticed it added a whole bunch of other ones too.

image

Punch ID is set to 21081. in SambaPOS Shivan pin is set to the same.

Ok So i removed all the actions, rules and scripts.

Went into config tasks and installed TIme Clock.

Then imported your db tools file.

Inserted my API.

Tried to test the script and got “Syntax Error”

I have not added the addition Execute Script yet.

Tested clocking in and out.

Refreshed 7 shift, and punch is not there.

Hmmm.

Please do not install the time clock. That will break it.

Ok. I will remove it all again and just import your file.

What do you mean by that?

Let me install my file on a blank db ill test it that way.

Following 7shifts integrated time clock

OH LOL that one is wrong. Use the one at first of this post.

EDIT I unlisted that one… i thought I had already.

You dont have to add any actions all you need to do is edit the time offset and put your api key in then make sure pins match.

Yep I did that too. I just downloaded ithe one at the top of this post.

These are the actions it imports.
image

These are the rules


image
And the script
image

It did not create any Auto Command buttons either.
Havent tried a fresh DB just yet.

Will try that now.

Follow this:

and use that file.

Yep thats the one i downloaded.
image

I just created a new DB.

Imported the file at the top of this topic.

As soon as I login im presented with…

Now I updated the script with the API.

The script works I just tested it. Just for curiosity try this.

var apikey = 'BLV9VJGFKM9HHQ565GWLZ5NQY5JK9TET'; 
var method1 = 'time_punches';
var method2 = 'users';
var method3 = 'receipts';

function getuser(pincode) {
  var getusers = web.PostData('https://api.7shifts.com/v1/'+method2+'/','',''+apikey+'','');
  var user = JSON.parse(getusers);
  for(var i=0; i<user.data.length; i++){
   if(user.data[i].user.employee_id == pincode)
   return user.data[i].user.id;
   }  
}

function punch(userpin,pmethod,timein) {
	var userid = getuser(userpin);
 	var execpunch = web.PostJson('https://api.7shifts.com/v1/'+method1+'/','{ "time_punch": { "user_id": '+userid+', "location_id": 25721, "'+pmethod+'": "'+timein+'"}}',''+apikey+'','');
 	var punchid = JSON.parse(execpunch);
	var punchidresult = punchid.data.time_punch.id;
 	Data.Set('punchid',punchidresult);
 	return punchidresult;
}

function updatepunch(punchid,punchtype,time) {
	var update = web.PutJson('https://api.7shifts.com/v1/'+method1+'/'+punchid+'','{ "time_punch": { "'+punchtype+'": "'+time+'"}}',''+apikey+'','');
	return update;
}

function createReceipt(ttotal,date,tid) {
	var create = web.PostJson('https://api.7shifts.com/v1/'+method3+'/','{ "receipt": { "total": '+ttotal+',"open_date": "'+date+'", "location_id": 25721, "external_id": '+tid+'}}',''+apikey+'','');
	return create;
}	

I set it so admin is immune. You can change that if you want admin to punch. You need to generate your default buttons too for nav screen.

This does not have a Time Clock screen… It works when user logs in and it puts a button on POS screen for clock out.

This is what I get when i test the script. NOTE: I just used the script you posted now.

Am i suppose to see any clock in or clock out notifications?

Also remove the work period is open check on the User Login rule.