void NewSale::makeNewSale() { bool endOfSale = false; pos->newSale(); while (!endOfSale) { cout << "Enter product code: "; int productCode; cin >> productCode; Product* product = pos->getProductByCode(productCode); if (product == 0) { cout << "Unknown product." << endl; continue; } cout << "Product description: " << product->getDescription() << endl; cout << "Enter quantity: "; double quantity; cin >> quantity; try { pos->enterSaleItem(quantity, product); cout << "Sale total: " << pos->getSaleTotal() << endl; } catch (ValidationError& err) { cout << err.getMessage() << endl; } cout << "0: End sale\n1: Continue adding items"; int command; cin >> command; if (command == 0) { pos->endSale(); endOfSale = true; } } }
InvoiceLine InvoiceLine::fromProduct(const Product &p) { InvoiceLine line; line.setName(p.getName()); line.setDescription(p.getDescription()); line.setPrice(p.getPrice()); line.setQte(1); line.setOffPercentage(0); line.setBaseProductId(p.getId()); return line; }