Payroll software and start moneyd on click?

Hi guys,

So we just thought we would share what we have been working on recently.

We are trying to develop a new payroll system that allows employees to be paid in a minutely basis, with a simple spsp payment, this is calculated against the hourly wage stored in the SQL DB every minute before releasing payment in xrp to the employee payment pointer, Taxman payment pointer and a pension payment pointer.

We got our proof of concept up and working and are now trying to develop it to conform with HMRC standards. Currently HMRC have put there blockchain project on hold until after the Brexit scenario, so we need to revert our system back to the old fashioned way in order to facilitate RTI FPS payments. we have a solution for sending the info in the FPS payment (XML Document) for when they start there blockchain project back up, but struggling to find away to incorporate the traditional way.

In order to make it simple for companies to set up, we have incorporated moneyd and a wallet generator into the application so to minimise software required by the employers.
We have had some success. But then these options were not going to work how we envisaged.

We tried running concurrently in the package.json script which works but either our application and moneyd xrp:start but if the was no configuration them obviously moneyd would crash.
And if we ran configure then we couldnt start with out restarting the application.

"scripts": {
"start": "concurrently \"./bin/www\" \"./bin/moneyd.js xrp:start --testnet\""

},

So we tried a few other process,

function moneydconfig(){
const { spawn } = require('child_process');
const ls = spawn('moneyd', ['xrp:configure','--testnet']);

ls.stdout.on('data', (data) => {
  console.log(`stdout: ${data}`);
});

ls.stderr.on('data', (data) => {
  console.log(`stderr: ${data}`);
});

ls.on('close', (code) => {
  console.log(`child process exited with code ${code}`);
});

}

but we have currently settled on using a shelljs, this give us the option of running start, clean up or configure at the click of a button, only once moneyd starts it blocks access to the other processes carried out by the application. Does anybody have any suggestions or a solution as to how we could overcome this?
Also when trying to exit the clean up command this exits everything and not just moneyd.

const shell = require('shelljs')
const HOME = require('os').homedir()
const path = require('path')
const configpathtestnet = path.join(HOME, '.moneyd.test.json')
const configpathlivenet = path.join(HOME, '.moneyd.json')


//show json data on canvas
	router.get('/config', function(req, res) {
		var action  = req.query.action;
		console.log(action);
		if (action == 1) {
			shell.exec('moneyd xrp:cleanup --testnet')
			res.redirect('/wallet');
		} else if (action == 2) {
			fs.unlink(configpathtestnet, function (err) {
				if (err) {
					console.log("erro to delete moneyd config file " + err);
				} else {
					// if no error, file has been deleted successfully
				console.log('File deleted!');
				shell.exec('moneyd xrp:configure --testnet --advanced')
				res.redirect('/wallet');
				}
			})
		} else if (action == 3) {
			shell.exec('moneyd xrp:start --testnet')
			res.redirect('/wallet');
		// } else if (action == 4) {
		// 	shell.exec('node ./ILPaw06/bin/www')
		// 	res.redirect('/');
		} else {
			res.redirect('/');
		}
		if (action == 4) {
			shell.exec('moneyd xrp:cleanup')
			res.redirect('/wallet');
	} else if (action == 5) {
		fs.unlink(configpathlivenet, function (err) {
			if (err) {
				console.log("erro to delete moneyd config file " + err);
			} else {
				// if no error, file has been deleted successfully
			console.log('File deleted!');
			shell.exec('moneyd xrp:configure --advanced')
			res.redirect('/wallet');
			}
		})
	} else if (action == 6) {
		shell.exec('moneyd xrp:start ')
		res.redirect('/wallet');
	// } else if (action == 4) {
	// 	shell.exec('node ./ILPaw06/bin/www')
	// 	res.redirect('/');
	} else {
		res.redirect('/');
	}
});

In views/templates the following for starting on click.

<a href="/config?action=1" class="w3-button w3-blue w3-medium w3-border w3-border-white w3-round-large w3-padding-small">Clean Up Testnet</a>
<a href="/config?action=2" class="w3-button w3-blue w3-medium w3-border w3-border-white w3-round-large w3-padding-small">Config Testnet</a>
<a href="/config?action=3" class="w3-button w3-blue w3-medium w3-border w3-border-white w3-round-large w3-padding-small">Start Testnet</a>
<a href="/config?action=4" class="w3-button w3-blue w3-medium w3-border w3-border-white w3-round-large w3-padding-small">Clean Up</a>
<a href="/config?action=5" class="w3-button w3-blue w3-medium w3-border w3-border-white w3-round-large w3-padding-small">Config</a>
<a href="/config?action=6" class="w3-button w3-blue w3-medium w3-border w3-border-white w3-round-large w3-padding-small">Start</a>

Any suggestions on how to have the payroll software process run alongside moneyd would be appreciated?

Would also appreciate any ideas on how we could send the fiat value to HMRC with out us using a traditional bank account is this something we could do with the ILP-IOU or over XRPL?

Richard

Ok, so i managed to find a solution to starting moneyd in a new terminal on the click of a button. this now allows the main application to carry out the paying of employees.

this is how i overcame the issue, there are probably better methods out there someone can point me to but this works or me, even though it does through an error.

runmoneydstart.sh file

open_new_terminals_automatically()
{
    osascript -e "tell application \"Terminal\" to do script \" moneyd $1;\""
}

# call the function and pass arguments
open_new_terminals_automatically "xrp:start"

moneydstart.js

function moneydconfig(){

const spawn = require('child_process').spawn;

  let test = spawn('sh', ['./runmoneydstart.sh']);

 

}

Index.js

router.get('/config', function(req, res) {
	var action  = req.query.action;

	console.log(action);
	if (action == 1) {
		var test = require('../moneydtestcleanup.js');
		res.redirect('/wallet');
	} 
	else if (action == 2) {
		var test1 = require('../moneydtestconfig.js');
		fs.unlink(configpathtestnet, function (err) {
			if (err) {
				console.log("erro to delete moneyd config file " + err);
			} else {
				// if no error, file has been deleted successfully
			console.log('File deleted!');
			
			res.redirect('/wallet');
			}
		})
	} else if (action == 3) {
		var test2 = require('../moneydteststart.js');
		res.redirect('/wallet');
	
	} else {
		res.redirect('/');
	}
	if (action == 4) {
		var test3 = require('../moneydcleanup.js');
		res.redirect('/wallet');
} 
	else if (action == 5) {
	var test4 = require('../moneydconfig.js');
	fs.unlink(configpathlivenet, function (err) {
		if (err) {
			console.log("erro to delete moneyd config file " + err);
		} else {
			// if no error, file has been deleted successfully
		console.log('File deleted!');
		shell.exec('moneyd xrp:configure --advanced')
		res.redirect('/wallet');
		}
	})
} 
	else if (action == 6) {
	var test5 = require('../moneydstart.js');
	res.redirect('/wallet');

} else {
	res.redirect('/');
} });

views.ejs

<a href="/config?action=1" class="w3-button w3-blue w3-medium w3-border w3-border-white w3-round-large w3-padding-small">Clean Up Testnet</a>
<a href="/config?action=2" class="w3-button w3-blue w3-medium w3-border w3-border-white w3-round-large w3-padding-small">Config Testnet</a>
<a href="/config?action=3" class="w3-button w3-blue w3-medium w3-border w3-border-white w3-round-large w3-padding-small">Start Testnet</a>
<a href="/config?action=4" class="w3-button w3-blue w3-medium w3-border w3-border-white w3-round-large w3-padding-small">Clean Up</a>
<a href="/config?action=5" class="w3-button w3-blue w3-medium w3-border w3-border-white w3-round-large w3-padding-small">Config</a>
<a href="/config?action=6" class="w3-button w3-blue w3-medium w3-border w3-border-white w3-round-large w3-padding-small">Start</a>

Here is a video of it working and also clocking in and a payment, the pay out is set to 1 minute, as mentioned above payment made to 3 pointers, Alice, Alicetax and Alicepension. the amount to send is calculated against the cost of XRP at the time of payment against the Euro.

https://youtu.be/AMacBRrBeII

Apologise for the messages i leave my self or Pablo.