[Pykafe-commits] SF.net SVN: pykafe: [125] trunk/pykafe/server
Status: Pre-Alpha
Brought to you by:
jnmbk
From: <jn...@us...> - 2007-06-11 01:19:31
|
Revision: 125 http://pykafe.svn.sourceforge.net/pykafe/?rev=125&view=rev Author: jnmbk Date: 2007-06-10 18:19:29 -0700 (Sun, 10 Jun 2007) Log Message: ----------- cafeteria seems OK Modified Paths: -------------- trunk/pykafe/server/payment.py trunk/pykafe/server/server.py Modified: trunk/pykafe/server/payment.py =================================================================== --- trunk/pykafe/server/payment.py 2007-06-11 00:38:03 UTC (rev 124) +++ trunk/pykafe/server/payment.py 2007-06-11 01:19:29 UTC (rev 125) @@ -87,9 +87,8 @@ def retranslateUi(self, PaymentDialog): PaymentDialog.setWindowTitle(QtGui.QApplication.translate("PaymentDialog", "Payment", None, QtGui.QApplication.UnicodeUTF8)) self.groupBox.setTitle(QtGui.QApplication.translate("PaymentDialog", "Cafeteria Costs", None, QtGui.QApplication.UnicodeUTF8)) - self.cafeteriaWidget.headerItem().setText(0,QtGui.QApplication.translate("PaymentDialog", "Date", None, QtGui.QApplication.UnicodeUTF8)) - self.cafeteriaWidget.headerItem().setText(1,QtGui.QApplication.translate("PaymentDialog", "Product", None, QtGui.QApplication.UnicodeUTF8)) - self.cafeteriaWidget.headerItem().setText(2,QtGui.QApplication.translate("PaymentDialog", "Price", None, QtGui.QApplication.UnicodeUTF8)) + self.cafeteriaWidget.headerItem().setText(0,QtGui.QApplication.translate("PaymentDialog", "Product", None, QtGui.QApplication.UnicodeUTF8)) + self.cafeteriaWidget.headerItem().setText(1,QtGui.QApplication.translate("PaymentDialog", "Price", None, QtGui.QApplication.UnicodeUTF8)) self.label_2.setText(QtGui.QApplication.translate("PaymentDialog", "Total Cost:", None, QtGui.QApplication.UnicodeUTF8)) self.label.setText(QtGui.QApplication.translate("PaymentDialog", "Used Time:", None, QtGui.QApplication.UnicodeUTF8)) self.label_3.setText(QtGui.QApplication.translate("PaymentDialog", "guest", None, QtGui.QApplication.UnicodeUTF8)) Modified: trunk/pykafe/server/server.py =================================================================== --- trunk/pykafe/server/server.py 2007-06-11 00:38:03 UTC (rev 124) +++ trunk/pykafe/server/server.py 2007-06-11 01:19:29 UTC (rev 125) @@ -395,6 +395,7 @@ #TODO: Call this function after adding and deleting if first: self.members = [] + self.ui.members_treeWidget.clear() memberList = Database().run("select * from members where is_cashier='0'") for memberInformation in memberList: self.members.append(Member(self.ui.members_treeWidget, memberInformation[:7])) @@ -869,10 +870,27 @@ paymentDialog = QtGui.QDialog(self.parent()) paymentUi = Ui_PaymentDialog() paymentUi.setupUi(paymentDialog) - paymentUi.totalCost.setValue(client.session.calculateTotal(self.config)) + totalCost = client.session.calculateTotal(self.config) + cost = client.session.calculatePrice(self.config) + paymentUi.totalCost.setValue(totalCost) paymentUi.label_3.setText("%s: %s" % (client.name, client.session.user)) time = client.session.startTime.secsTo(QtCore.QDateTime.currentDateTime()) paymentUi.usedTime.setTime(QtCore.QTime().addSecs(time)) for order in client.session.orders: - QtGui.QTreeWidgetItem(paymentUi.cafeteriaWidget, order) + print order + QtGui.QTreeWidgetItem(paymentUi.cafeteriaWidget, [order[0], currency(order[1])]) paymentDialog.show() + payingType, credit = Database().runOnce("select paying_type, debt from members where username=?",(client.session.user,))[0] + if payingType == _("Pre Paid"): + credit = Database().runOnce("select debt from members where username = ?", (client.session.user,))[0][0] + if totalCost > credit: + QtGui.QMessageBox.warning(self.parent(), _("Low credit"), _("%s's credit has finished! Has %s debt.") % (client.session.user, currency(totalCost - credit))) + logger.add(logger.logTypes.warning, _("Member has low credit"), client.name, client.session.user, totalCost - credit) + else: + logger.add(logger.logTypes.information, _("Money paid"), client.name, client.session.user, totalCost) + Database().runOnce("insert into safe values(?,?,?)", (QtCore.QDateTime.currentDateTime().toTime_t(), self.config.last_cashier, cost)) + self.initMembers() + Database().runOnce("update members set debt=? where username=?", (totalCost - credit, client.session.user)) + else: + Database().runOnce("insert into safe values(?,?,?)", (QtCore.QDateTime.currentDateTime().toTime_t(), self.config.last_cashier, cost)) + logger.add(logger.logTypes.information, _("Money paid"), client.name, client.session.user, totalCost) \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |