Skip to content

Commit

Permalink
fix(gbdialog): VBA is running financial simulations.
Browse files Browse the repository at this point in the history
  • Loading branch information
Rodrigo Rodriguez (pragmatismo.io) committed Dec 2, 2018
1 parent 2dd359a commit 9fb431c
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 109 deletions.
1 change: 1 addition & 0 deletions packages/core.gbapp/dialogs/WhoAmIDialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ export class WhoAmIDialog extends IGBDialog {
}

await step.replaceDialog('/ask', { isReturning: true });

return await step.next();
}
]));
Expand Down
2 changes: 1 addition & 1 deletion packages/core.gbapp/services/GBMinService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ export class GBMinService {
} else {
const user = await min.userProfile.get(context, {});

if (step.activeDialog || user.dialog) {
if (step.activeDialog) {
await step.continueDialog();
} else {
await step.beginDialog('/answer', {
Expand Down
6 changes: 3 additions & 3 deletions packages/core.gbapp/services/GBVMService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,6 @@ export class GBVMService implements IGBCoreService {
new WaterfallDialog('/hear', [
async step => {
step.activeDialog.state.cbId = step.options['id'];
step.activeDialog.state.idResolve = step.options['idResolve'];

return await step.prompt('textPrompt', {});
},
Expand All @@ -185,9 +184,10 @@ export class GBVMService implements IGBCoreService {
const cbId = step.activeDialog.state.cbId;
const cb = min.cbMap[cbId];
cb.bind({ step: step, context: step.context }); // TODO: Necessary or min.sandbox
await cb();

await step.endDialog();

return await step.next();
return await cb(step.result);
}
])
);
Expand Down
170 changes: 65 additions & 105 deletions packages/default.gbdialog/bot.vbs
Original file line number Diff line number Diff line change
Expand Up @@ -34,114 +34,74 @@
talk ("How many installments do you want to pay your Credit?")
installments = hear ()

talk ("What is the amount requested?")
ammount = hear ()

talk ("What is the initial payment value?")
valorEntrada = hear ()


talk ("What is the best due date?")
dueDate = hear ()

juros =0
coeficiente1=0

if installments <12 then
juros = 1.60
coeficiente = 0.09748
end if

if installments > 12 and installments< 18 then
juros = 1.66
coeficiente = 0.06869
end if

if installments > 18 and installments< 36 then
juros = 1.64
coeficiente = 0.05397
end if

if installments > 36 and installments< 48 then
juros = 1.62
coeficiente = 0.03931
end if

if installments > 48 and installments< 60 then
juros = 1.70
coeficiente = 0.03270
end if

if installments =60 then
juros = 1.79
coeficiente = 0.02916
end if

if installments > 60 then
talk ("The maximum number of payments is 60")
end if


nInstallments = parseInt(installments)
vAmmount = parseFloat(ammount)
first = parseFloat(vAmmount) * 0.3 ' 30% of the value
tac = 800
coeficiente = 1.3

taxaJuros = parseFloat(juros)
valorFinanciado = ammount - valorEntrada + tac
valorParcela = valorFinanciado * coeficiente
valorTotalDoBem = valorParcela * nInstallments + valorEntrada

talk("Your credit analysis is done.")

talk("First payment" + valorEntrada)
talk("valorParcela" + valor)
talk("taxaJuros" + taxaJuros)
talk("valorFinanciado" + valorFinanciado)
talk("valorTotalDoBem" + valorTotalDoBem)


text = hear()

if email = "" then

text = hear()


if email = "" then
talk ()
text = hear()

i1 = 10
end if
else
text = hear()
if email = "" then
talk ()
text = hear()

i2 = 10

talk ()
text = hear()

talk ()
text = hear()
talk ("What is the amount requested?")
ammount = hear ()

if ammount >100000 then
talk ("We are sorry, we can only accept proposals bellow 100k")
else

talk ("What is the best due date?")
dueDate = hear ()

interestRate = 0
adjustment = 0

if installments < 12 then
interestRate = 1.60
adjustment = 0.09748
end if

if installments > 12 and installments < 18 then
interestRate = 1.66
adjustment = 0.06869
end if

if installments > 18 and installments < 36 then
interestRate = 1.64
adjustment = 0.05397
end if

if installments > 36 and installments < 48 then
interestRate = 1.62
adjustment = 0.03931
end if

if installments > 48 and installments < 60 then
interestRate = 1.70
adjustment = 0.03270
end if

if installments = 60 then
interestRate = 1.79
adjustment = 0.02916
end if

if installments > 60 then
talk ("The maximum number of payments is 60")
end if


nInstallments = parseInt(installments)
vAmmount = parseFloat(ammount)
initialPayment = parseFloat(vAmmount) * 0.3 ' 30% of the value
tac = 800
adjustment = 1.3

totalValue = ammount - initialPayment + tac
paymentValue = totalValue * adjustment
finalValue = paymentValue * nInstallments + initialPayment

talk("Congratulations! Your credit analysis is **done**:")
talk("First payment: **" + initialPayment + "**")
talk("Payment value: **" + paymentValue + "**")
talk("Interest Rate: **" + interestRate + "%**")
talk("Total Value: **" + totalValue + "**")
talk("Final Value: **" + finalValue + "**")

end if
end if

talk ()
text = hear()

i = 10

if i > 10 then
text = hear()
text = hear()
else
text = hear()
text = hear()
end if

%>

0 comments on commit 9fb431c

Please sign in to comment.