Skip to content

Instantly share code, notes, and snippets.

@RuanAragao
Created April 24, 2021 15:21
Show Gist options
  • Save RuanAragao/66c1e81828c6b81ba1ffd8e73c349a49 to your computer and use it in GitHub Desktop.
Save RuanAragao/66c1e81828c6b81ba1ffd8e73c349a49 to your computer and use it in GitHub Desktop.
Simple Transfer
let account = {
10000: {
name: 'CENTRALBANK',
sold: 1000.000
},
10100: {
name: 'RUAN ARAGÃO',
sold: 0.000
},
10101: {
name: 'CARLOS SOUSA',
sold: 0.000
}
}
function transition(origin, destination, mount) {
const origin_number = origin;
const destination_number = destination;
origin = account[origin];
destination = account[destination];
if (typeof origin != "undefined" && typeof destination != "undefined") {
if (origin.sold >= mount) {
origin.sold = origin.sold - mount;
destination.sold = destination.sold + mount;
const ticket = `
\$ CENTRAL BANK \$
----------------------
CLIENTE: ${origin.name}
CONTA: ${origin_number}
======================
** TRANSFERIDO PARA **
CLIENTE: ${destination.name}
CONTA: ${destination_number}
VALOR: R$ ${mount}
`;
console.log(ticket);
return true;
}
console.log('sold insufficient');
return false;
}
console.log('accounts not exists');
return false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment