Пример #1
0
void InvoiceWizard::invoiceMembers() {
	PPSPerson pers;
	Invoice invoice;
	XmlPdf *pdf;
	QString fileName;

	QProgressDialog bar(this);
	int max = memberUidList->count();
	bar.setRange(0, max);
	bar.setCancelButtonText(tr("&Cancel"));
	bar.setWindowTitle(tr("Create Invoices"));
	bar.setWindowModality(Qt::WindowModal);
	bar.show();

	for (int i = 0; i < max; i++) {
		QListWidgetItem *item = memberUidList->item(i);
		bar.setValue(i);
		if (pers.load(item->text().toInt())) {
			if (bar.wasCanceled()) break;
			bar.setLabelText(tr("Create Invoice for %1 %2 (%3 of %4)").arg(pers.familyName()).arg(pers.givenName()).arg(i).arg(max) );
			invoice.create(&pers);

			// Send invoice by SnailMail and not EMail if "print" is checked, the user likes to become SnailsMails or he has no EMailaddress
			// The "invoice" template is the one without an invoiceSlip, the "reminder" has attached one normally
			if (checkPrint->isChecked() || invoice.addressEmail().isEmpty() || (pers.isLoaded() && (pers.notify() == PPSPerson::SnailMail))) {
				if (fileName.isEmpty()) {
					fileName = getSaveFileName();
				}
				pdf = invoice.createPdf("reminder");
				pdf->print( fileName.arg(invoice.memberUid()) );
			} else {
				pdf = invoice.createPdf("invoice");
				pdf->send(invoice.addressEmail());
			}
		}
	}
	bar.setValue(max);
}
Пример #2
0
void DocumentFMController::getDocumentData()
{
     Invoice invoice;
     invoice.setDocumentType(symbol);
     invoice.setSymbol(view->getLineDocumentSymbol()->text());
     MethodOfPayment mop;
     mop.setId((view->getWayToPay()->itemData(view->getWayToPay()->currentIndex()).toInt()));
     invoice.setMethodOfPayment(mop);
     invoice.setDocumentPlace(view->getLineDocumentPlace()->text());
     invoice.setDocumentDate(view->getDateIssue());
     invoice.setSaleDate(view->getSaleOrStoreDate());
     invoice.setPaymentDate(view->getPaymentDate()->date());
     invoice.setTotal(view->getLineGoodsValueDiscount());
     invoice.setDiscount(view->getDiscountOrWaybillNo()->text().toDouble());
     if(ApplicationManager::getInstance()->containsModule(ModuleManager::Order))
     invoice.setOrder(view->getLineOrderSymbol()->text());
     invoice.setIssueName(view->getLineIssueName());
     invoice.setReceiveName(view->getLineReceiveName());
     invoice.setPaid(view->isPaid());
     invoice.setStoreResult(view->isStoreUpdating());
     invoice.setDocumentPositions(manager->getDocumentPosition());
     manager->getInvoicePolicy()->setDocumentData(invoice);
}
Пример #3
0
int main() {
  Invoice invoiceOne;

  cout << invoiceOne.getNumber() << '-' << invoiceOne.getDescription() << '-'
       << invoiceOne.getQuantity() << '-' << invoiceOne.getPrice() << endl;

  invoiceOne.setNumber("Hello");
  invoiceOne.setDescription("World");
  invoiceOne.setQuantity(33);
  invoiceOne.setPrice(99);

  cout << invoiceOne.getNumber() << '-' << invoiceOne.getDescription() << '-'
       << invoiceOne.getQuantity() << '-' << invoiceOne.getPrice() << endl;

  Invoice invoiceTwo;

  cout << invoiceTwo.getNumber() << '-' << invoiceTwo.getDescription() << '-'
       << invoiceTwo.getQuantity() << '-' << invoiceTwo.getPrice() << endl;

  invoiceTwo.setQuantity(-55);
  invoiceTwo.setPrice(-99);

  cout << invoiceTwo.getNumber() << '-' << invoiceTwo.getDescription() << '-'
       << invoiceTwo.getQuantity() << '-' << invoiceTwo.getPrice() << endl;

  return 0;
}
Пример #4
0
void InvoiceWizard::createInvoices() {
	PPSPerson pers;
	Invoice invoice;
	XmlPdf *pdf;
	QString fileName;
	bool reminder = (_invoiceState == INVOICE_STATE_TYPE_OUTSTANDING) || (_invoiceState == INVOICE_STATE_TYPE_REMINDER);

	int num = _previewModel.rowCount();
	int cnt = 0;
	QProgressDialog bar(this);
	bar.setRange(0, num);
	bar.setCancelButtonText(tr("&Cancel"));
	bar.setWindowTitle(tr("Create Invoices"));
	bar.setWindowModality(Qt::WindowModal);
	bar.show();

	for (qint32 i = 0; i < num; i++) {
		if (bar.wasCanceled()) {
			break;
		}
		bar.setValue(cnt++);

		qint32 uid = _previewModel.index(i, 0).data(Qt::DisplayRole).toInt();
		if (pers.load(uid)) {
			if (bar.wasCanceled()) break;
			bar.setLabelText(tr("Create Invoice for %1 %2 (%3 of %4)").arg(pers.familyName()).arg(pers.givenName()).arg(cnt).arg(num) );
			if (reminder) {
				invoice.loadLast(uid);
				invoice.setReminded(invoice.reminded() + 1);
				invoice.setLastReminded(QDate::currentDate());
				invoice.save();
			} else {
				invoice.create(&pers);
			}

			// Send invoice by SnailMail and not EMail if "print" is checked, the user likes to become SnailsMails or he has no EMailaddress
			// The "invoice" template is the one without an invoiceSlip, the "reminder" has attached one normally
			if (checkPrint->isChecked() || invoice.addressEmail().isEmpty() || (!noSnailMail->isChecked() && pers.isLoaded() && (pers.notify() == PPSPerson::SnailMail))) {
				if (fileName.isEmpty()) {
					fileName = getSaveFileName();
				}
				pdf = invoice.createPdf("reminder");
				pdf->print( fileName.arg(invoice.memberUid()) );
			} else {
				pdf = invoice.createPdf("invoice");
				pdf->send(invoice.addressEmail());
			}
		}
	}
	bar.setValue(num);
	updatePreviewTable();
}
Пример #5
0
bool
RecurringMaster::postOne(const Gltx& gltx, Id card_id)
{
    QDate nextDue = _curr.nextDue();
    Card card;
    _quasar->db()->lookup(card_id, card);

    General general;
    ItemAdjust adjustment;
    Invoice invoice;
    Receive receive;
    Cheque cheque;
    unsigned int i;

    switch (gltx.dataType()) {
    case DataObject::GENERAL:
	_quasar->db()->lookup(_curr.gltxId(), general);
	_quasar->db()->setActive(general, true);
	general.setNumber("#");
	general.setShiftId(INVALID_ID);
	general.setPostDate(nextDue);
	general.setPrinted(false);
	general.setPaid(false);
	general.payments().clear();

	if (!_quasar->db()->create(general)) {
	    QMessageBox::critical(this, tr("Error"), tr("Create failed"));
	    return false;
	}
	break;
    case DataObject::ITEM_ADJUST:
	_quasar->db()->lookup(_curr.gltxId(), adjustment);
	_quasar->db()->setActive(adjustment, true);
	adjustment.setNumber("#");
	adjustment.setShiftId(INVALID_ID);
	adjustment.setPostDate(nextDue);
	adjustment.setPrinted(false);
	adjustment.setPaid(false);
	adjustment.payments().clear();

	if (!_quasar->db()->create(adjustment)) {
	    QMessageBox::critical(this, tr("Error"), tr("Create failed"));
	    return false;
	}
	break;
    case DataObject::INVOICE:
	_quasar->db()->lookup(_curr.gltxId(), invoice);
	_quasar->db()->setActive(invoice, true);
	invoice.setNumber("#");
	invoice.setCustomerId(card_id);
	invoice.setCustomerAddress(card.address());
	invoice.setShiftId(INVALID_ID);
	invoice.setPostDate(nextDue);
	invoice.setPrinted(false);
	invoice.setPaid(false);
	invoice.payments().clear();

	// Recalculate item costs
	for (i = 0; i < invoice.items().size(); ++i) {
	    InvoiceItem& line = invoice.items()[i];
	    if (line.voided || line.item_id == INVALID_ID) continue;

	    Id store = invoice.storeId();
	    fixed qty = fabs(line.quantity);
	    fixed sign = line.quantity.sign();

	    Item item;
	    _quasar->db()->lookup(line.item_id, item);

	    fixed sell_cost;
	    _quasar->db()->itemSellingCost(item, line.size, store, qty,
					   line.ext_price, sell_cost);
	    line.inv_cost = sell_cost * sign;
	}

	// Fix gltx_card lines
	for (i = 0; i < invoice.cards().size(); ++i)
	    invoice.cards()[i].card_id = card_id;

	if (!_quasar->db()->create(invoice)) {
	    QMessageBox::critical(this, tr("Error"), tr("Create failed"));
	    return false;
	}
	break;
    case DataObject::RECEIVE:
	_quasar->db()->lookup(_curr.gltxId(), receive);
	_quasar->db()->setActive(receive, true);
	receive.setNumber("#");
	receive.setVendorId(card_id);
	receive.setVendorAddress(card.address());
	receive.setShiftId(INVALID_ID);
	receive.setPostDate(nextDue);
	receive.setInvoiceDate(nextDue);
	receive.setPrinted(false);
	receive.setPaid(false);
	receive.setClosed(false);
	receive.payments().clear();

	// Fix gltx_card lines
	for (i = 0; i < receive.cards().size(); ++i)
	    receive.cards()[i].card_id = card_id;

	if (!_quasar->db()->create(receive)) {
	    QMessageBox::critical(this, tr("Error"), tr("Create failed"));
	    return false;
	}
	break;
    case DataObject::CHEQUE:
	_quasar->db()->lookup(_curr.gltxId(), cheque);
	_quasar->db()->setActive(cheque, true);
	cheque.setNumber("#");
	cheque.setCardId(card_id);
	cheque.setAddress(card.address());
	cheque.setShiftId(INVALID_ID);
	cheque.setPostDate(nextDue);
	cheque.setPrinted(false);
	cheque.setPaid(false);
	cheque.payments().clear();

	if (!_quasar->db()->create(cheque)) {
	    QMessageBox::critical(this, tr("Error"), tr("Create failed"));
	    return false;
	}
	break;
    default:
	QString message = tr("Can't post %1 transactions yet")
	    .arg(gltx.dataTypeName());
	QMessageBox::critical(this, tr("Error"), message);
	return false;
    }

    return true;
}