/
test.js
68 lines (57 loc) · 2.46 KB
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
const modulecontroller = require('supermarketjs/BussinesRulesSupermarket/ControllerCash');
const getProducts = require('supermarketjs/BussinesRulesSupermarket/Catalogue');
//getProducts.getCatalogueProducts().then(data => {
// console.log(data)
//})
//getProducts.getCatalogueProductsExpression("Juice").then(data => {
// console.log(data)
//})
modulecontroller.startsale().then(datast => {
console.log(datast)
modulecontroller.registerproductforsale("Ice Cream", 2).then(datad1 => { console.log(datad1) });
modulecontroller.registerproductforsale("Biscuit", 2).then(datad1 => { console.log(datad1) });
modulecontroller.registerproductforsale("Apple Juice", 2).then(datad1 => { console.log(datad1) });
modulecontroller.registerproductforsale("Ketchup", 2).then(datad2 => {
console.log(datad2)
modulecontroller.closesale().then(datac => {
//modulecontroller.cancelSale().then(datacan => {
// console.log(datacan);
//})
console.log(datac);
modulecontroller.payCard('5566413601388085', 589875549, 3).then(databool => {
if (databool == true) {
console.log("Card accepted, and the sale was registered successfully");
printticket(datac).then(datad => {
})
}
if (databool == false) {
console.log("Rejected card!!!");
}
})
//modulecontroller.payCash(1000).then(datapc => {
// if (datac.TotalS > 1000) {
// console.log("The total of the sale is greater than the amount delivered");
// }
// else {
// console.log("Redelivered: " + datapc)
// printticket(datac).then(datad => {
// })
// }
//})
})
})
})
async function printticket(dtsale) {
console.log("\n\n Your ticket:\n");
console.log("----------------------\n")
console.log("S U P E R M A R K E T")
console.log("\n----------------------\n")
for (var ds of await dtsale.ArrayDTDetailSale) {
console.log(ds.ProductDS + " x " + ds.QuantityDS + " " + ds.AmountDS)
}
console.log("\n----------------------")
console.log("Subtotal: " + dtsale.SubtotalS);
console.log("Taxes: " + dtsale.TaxesS);
console.log("Total: " + dtsale.TotalS);
console.log("\n----------------------")
}