//No Insurance void MainWindow::on_radio_noinsu_clicked() { if(selectedBorrower||selectedCopy){ QDate end = ui->date_rent_return->date(); int NbOfDay = ui->date_rent_start->date().daysTo(end); ui->label_rent_totalCost->setText(QString::number(calculatePrice(selectedCopy->getVehicle()->getDailyCost(),false,NbOfDay,selectedCopy->getKilometers()))); } }
//Start date changed void MainWindow::on_date_rent_return_userDateChanged(const QDate &date) { if(selectedBorrower||selectedCopy){ QDate start = ui->date_rent_start->date(); int NbOfDay = start.daysTo(date); ui->label_rent_totalCost->setText(QString::number(calculatePrice(selectedCopy->getVehicle()->getDailyCost(),ui->radio_insu->isChecked(),NbOfDay,selectedCopy->getKilometers()))); } }
//Damage level changed void MainWindow::on_comboBox_currentIndexChanged(int index) { //Mute warnings int i = index; i++; int NbOfDays = QDate(selectedRent->getBegin().getYear(),selectedRent->getBegin().getMonth(),selectedRent->getBegin().getDay()).daysTo(QDate(selectedRent->getEnd().getYear(),selectedRent->getEnd().getMonth(),selectedRent->getEnd().getDay())); ui->label_return_realPrice->setText(QString::number(calculatePrice(selectedRent->getCopy()->getVehicle()->getDailyCost(),selectedRent->getInsurance(),NbOfDays,selectedRent->getCopy()->getKilometers(),ui->combo_fuel->currentIndex()*50,ui->comboBox->currentIndex(),QDate(selectedRent->getEnd().getYear(),selectedRent->getEnd().getMonth(),selectedRent->getEnd().getDay()).daysTo(QDate::currentDate())))); }
void LaminatTask::initWidget(Stock *stock) { if (stock == NULL) { return; } size = sizeW->getSize(); ui->size->setText(size.toString()); ui->stockInfo->stockChanged(stock); loadStockVar(stock); calculatePrice(); calculateTotal(); }
PurchaseEditor::PurchaseEditor( QWidget *parent ) : KDialog( parent ) { ui = new PurchaseEditorUI( this ); setMainWidget( ui ); setCaption( i18n("Purchase") ); setButtons( KDialog::Ok|KDialog::Cancel ); setDefaultButton(KDialog::None); ui->btnAddItem->setDefault(true); //Set Validators for input boxes QRegExp regexpC("[0-9]{1,13}"); //(EAN-13 y EAN-8) .. y productos sin codigo de barras? QRegExpValidator * validatorEAN13 = new QRegExpValidator(regexpC, this); ui->editCode->setValidator(validatorEAN13); ui->editTax->setValidator(new QDoubleValidator(0.00, 999999999999.99, 3,ui->editTax)); ui->editExtraTaxes->setValidator(new QDoubleValidator(0.00, 999999999999.99, 3,ui->editExtraTaxes)); ui->editCost->setValidator(new QDoubleValidator(0.00, 999999999999.99, 3, ui->editCost)); ui->editPoints->setValidator(new QIntValidator(0,999999999, ui->editPoints)); ui->editFinalPrice->setValidator(new QDoubleValidator(0.00,999999999999.99, 3, ui->editFinalPrice)); ui->editItemsPerBox->setValidator(new QDoubleValidator(0.00,999999999999.99, 2, ui->editItemsPerBox)); ui->editPricePerBox->setValidator(new QDoubleValidator(0.00,999999999999.99, 2, ui->editPricePerBox)); ui->editQty->setValidator(new QDoubleValidator(0.00,999999999999.99, 2, ui->editQty)); connect( ui->btnPhoto , SIGNAL( clicked() ), this, SLOT( changePhoto() ) ); connect( ui->btnCalculatePrice , SIGNAL( clicked() ), this, SLOT( calculatePrice() ) ); connect( ui->editItemsPerBox , SIGNAL( textEdited(const QString &) ), this, SLOT( calculatePrice() ) ); connect( ui->editPricePerBox , SIGNAL( textEdited(const QString &) ), this, SLOT( calculatePrice() ) ); connect( ui->editCost , SIGNAL( textEdited(const QString &) ), this, SLOT( calculatePrice() ) ); connect( ui->editTax , SIGNAL( textEdited(const QString &) ), this, SLOT( calculatePrice() ) ); connect( ui->editExtraTaxes , SIGNAL( textEdited(const QString &) ), this, SLOT( calculatePrice() ) ); connect( ui->editUtility , SIGNAL( textEdited(const QString &) ), this, SLOT( calculatePrice() ) ); connect( ui->editCode, SIGNAL(textEdited(const QString &)), SLOT(checkIfCodeExists())); connect( ui->editCode, SIGNAL(returnPressed()), ui->editQty, SLOT(setFocus())); connect( ui->btnAddItem, SIGNAL( clicked() ), this, SLOT( addItemToList() ) ); connect(ui->groupBoxedItem, SIGNAL(toggled(bool)), this, SLOT(focusItemsPerBox(bool)) ); connect(ui->btnRemoveItem, SIGNAL( clicked() ), SLOT( deleteSelectedItem() ) ); ui->chIsAGroup->setDisabled(true); status = estatusNormal; productExists = false; productsHash.clear(); resetEdits(); totalBuy = 0.0; itemCount = 0.0; totalTaxes = 0.0; QTimer::singleShot(500, this, SLOT(setupTable())); }
//Click rent table void MainWindow::on_tableWidget_3_clicked(const QModelIndex &index) { int id = ui->tableWidget_2->item(index.row(),0)->text().toInt(); //set selected selectedRent = _rentContainer[id-1]; //diplay std::string buffer1 = selectedRent->getBorrower()->getFirstName()+" "+selectedRent->getBorrower()->getLastName(); std::string buffer2 = selectedRent->getCopy()->getVehicle()->getBrand()+" "+selectedRent->getCopy()->getVehicle()->getName(); ui->label_return_name->setText(buffer1.c_str()); ui->label_return_vehicle->setText(buffer2.c_str()); ui->label_return_inod->setText(QString::number(QDate(selectedRent->getBegin().getYear(),selectedRent->getBegin().getMonth(),selectedRent->getBegin().getDay()).daysTo(QDate(selectedRent->getEnd().getYear(),selectedRent->getEnd().getMonth(),selectedRent->getEnd().getDay())))); ui->label_return_rnod->setText(QString::number(QDate(selectedRent->getBegin().getYear(),selectedRent->getBegin().getMonth(),selectedRent->getBegin().getDay()).daysTo(QDate::currentDate()))); int NbOfDays = QDate(selectedRent->getBegin().getYear(),selectedRent->getBegin().getMonth(),selectedRent->getBegin().getDay()).daysTo(QDate(selectedRent->getEnd().getYear(),selectedRent->getEnd().getMonth(),selectedRent->getEnd().getDay())); ui->label_retur_firstPrice->setText(QString::number(calculatePrice(selectedRent->getCopy()->getVehicle()->getDailyCost(),selectedRent->getInsurance(),NbOfDays,selectedRent->getCopy()->getKilometers()))); ui->label_return_realPrice->setText(QString::number(calculatePrice(selectedRent->getCopy()->getVehicle()->getDailyCost(),selectedRent->getInsurance(),NbOfDays,selectedRent->getCopy()->getKilometers(),ui->combo_fuel->currentIndex()*50,ui->comboBox->currentIndex(),QDate(selectedRent->getEnd().getYear(),selectedRent->getEnd().getMonth(),selectedRent->getEnd().getDay()).daysTo(QDate::currentDate())))); ui->pushButton_4->setEnabled(true); ui->pushButton_3->setEnabled(true); }
//Edit bill void MainWindow::on_pushButton_3_clicked() { //Generate the bill and change the page //Borrower info ui->label_bill_fname->setText(selectedRent->getBorrower()->getFirstName().c_str()); ui->label_bill_lname->setText(selectedRent->getBorrower()->getLastName().c_str()); ui->label_bill_add->setText(selectedRent->getBorrower()->getAddress().display().c_str()); ui->label_bill_phone->setText(selectedRent->getBorrower()->getPhoneNumber().c_str()); //Vehicule info ui->label_bill_brand->setText(selectedRent->getCopy()->getVehicle()->getBrand().c_str()); ui->label_bill_model->setText(selectedRent->getCopy()->getVehicle()->getName().c_str()); switch(selectedRent->getCopy()->getVehicle()->getType()){ case Vehicle::car: ui->label_bill_type->setText("Car"); break; case Vehicle::moto: ui->label_bill_type->setText("Motorcycle"); break; } ui->label_bill_km->setText(QString::number(selectedRent->getCopy()->getKilometers())); //Bill info ui->label_bill_dc->setText(QString::number(selectedRent->getCopy()->getVehicle()->getDailyCost())); int NbOfDays = QDate(selectedRent->getBegin().getYear(),selectedRent->getBegin().getMonth(),selectedRent->getBegin().getDay()).daysTo(QDate(selectedRent->getEnd().getYear(),selectedRent->getEnd().getMonth(),selectedRent->getEnd().getDay())); ui->label_bill_nbod->setText(QString::number(NbOfDays)); int price = selectedRent->getCopy()->getVehicle()->getDailyCost()*NbOfDays*1.0; if(selectedRent->getInsurance()){ float insuranceCost = (price*10.0)/100.0; ui->label_bill_insu->setText(QString::number(insuranceCost)); } else ui->label_bill_insu->setText(QString::number(0)); ui->label_bill_kilo->setText(QString::number((floor(selectedRent->getCopy()->getKilometers()/50000.0)*price)/10*-1)); int daysOver = QDate(selectedRent->getEnd().getYear(),selectedRent->getEnd().getMonth(),selectedRent->getEnd().getDay()).daysTo(QDate::currentDate()); if(daysOver>0) ui->label_bill_ot->setText(QString::number(daysOver*50)); else ui->label_bill_ot->setText(QString::number(0)); ui->label_bill_fuel->setText(QString::number(selectedRent->getFuelMalus())); if(!selectedRent->getInsurance()){ switch(selectedRent->getCopy()->getStatus()){ case Copy::NEW: ui->label_bill_dam->setText(QString::number(0)); break; case Copy::DAMAGED: ui->label_bill_dam->setText(QString::number(1000)); break; case Copy::UNUSABLE: ui->label_bill_dam->setText(QString::number(5000)); break; } } //Display total ui->label_bill_tot->setText(QString::number(calculatePrice(selectedRent->getCopy()->getVehicle()->getDailyCost(),selectedRent->getInsurance(),NbOfDays,selectedRent->getCopy()->getKilometers(),ui->combo_fuel->currentIndex()*50,ui->comboBox->currentIndex(),QDate(selectedRent->getEnd().getYear(),selectedRent->getEnd().getMonth(),selectedRent->getEnd().getDay()).daysTo(QDate::currentDate())))); ui->stackedWidget->setCurrentIndex(1); }
TEST(SilverCustomer, it_can_calculate_a_silver_price_with_shipping) { double amount = 1.0; double shipping = 5.0; DOUBLES_EQUAL( shipping + SILVER_RATIO, calculatePrice(customer, amount, shipping), 0.01 ); }
TEST(SilverCustomer, it_can_calculate_a_different_silver_price) { double amount = 0.0; double shipping = 0.0; DOUBLES_EQUAL( 0.00, calculatePrice(customer, amount, shipping), 0.01 ); }