Jump to content

Payroll Calculation Questions


Recommended Posts

I have two tables, one a general employee table (Payroll master) with emplyee id, payrate, etc.  Another with weekly hours (Payroll journal).  I have a submission datapage to enter hours.  And in a Tabular datapage with a View of both these tables, I can calculate the weekly pay based on rate and hours.  However, I can't seem to figure out how to capture this calculated field in the payroll journal table so its archived.  I have tried JS but it doesn't work (I try to pull in the pay rate from master table in a virtual field based on employee ID, and use the entered value for regular hours).

 

<SCRIPT LANGUAGE="JavaScript">

 

 

function calculateregpay()

 {

   var v_reghr = parseFloat(document.getElementById("InsertRecordPayroll_journal_Regular_Hours").value);

   var v_regpay  = parseFloat(document.getElementById("InsertRecordPayroll_master_Pay_rate").value);

   var v_totalreghr  = (v_reghr * v_ regpay);

   document.getElementById("InsertRecordPayroll_journal_Regular_Pay").value = (v_ totalreghr).toFixed(2);

 }

 

 /* On submitting the webform, the function calculate is executed */

 

 

document.getElementById("caspioform").onsubmit=calculateregpay;

 

</SCRIPT>

Link to comment
Share on other sites

did you try preloading a value on page load, of 0, for hours?

 

Also, I have a similar need, but instead of doing this, I've disabled deletions, and editing either value after submission. This way, a user cannot change values after the fact, and if a user deletes, but it was paid, it was only "marked for deletion" and omitted from reports, but not truly deleted. I think this accomplishes "Archiving," though I'm curious what you think. THanks

Link to comment
Share on other sites

Hello pgjacob,

 

If I understand correctly, there are two misprints in the code:

 

var v_totalreghr  = (v_reghr * v_ regpay);

document.getElementById("InsertRecordPayroll_journal_Regular_Pay").value = (v_ totalreghr).toFixed(2);

 

Spaces break the code.

 

And, if you use a Virtual field, the id of Virtual field is "cbParamVirtual1" (you can see more details about Ids and Names).

 

I hope, it helps.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...