Skip to content

Commit

Permalink
Add send order
Browse files Browse the repository at this point in the history
  • Loading branch information
lgaticaq committed May 4, 2016
1 parent 9b93886 commit bbb5925
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,26 @@ const fillForm = (work, destinatary=null, zone=null, commune=null) => {
}
};

const createPreview = () => {
$('input[name=cmdAceptar]').click();
};

const confirm = () => {
$('input[name=cmdconfirmar]').click();
};

const sendEmail = () => {
$('#cmdenviar').click();
};

const confirmSendEmail = () => {
$('#cmdcontinuar').click();
};

const exit = () => {
$('#cmdsalir').click();
};

const byLastInvoice = (user, work) => {
return new Promise((resolve, reject) => {
new Nightmare()
Expand All @@ -75,6 +95,11 @@ const byLastInvoice = (user, work) => {
.evaluate(gotToLast)
.evaluate(selectLast)
.evaluate(fillForm, work)
.evaluate(createPreview)
.evaluate(confirm)
.evaluate(sendEmail)
.evaluate(confirmSendEmail)
.evaluate(exit)
.run(err => {
if (err) return reject(err);
resolve();
Expand All @@ -95,6 +120,11 @@ const byDestinatary = (user, work, destinatary, zone, commune) => {
.evaluate(gotToDestinatary)
.evaluate(selectRetention)
.evaluate(fillForm, work, destinatary, zone, commune)
.evaluate(createPreview)
.evaluate(confirm)
.evaluate(sendEmail)
.evaluate(confirmSendEmail)
.evaluate(exit)
.run(err => {
if (err) return reject(err);
resolve();
Expand Down

0 comments on commit bbb5925

Please sign in to comment.