Ejemplo n.º 1
0
def printSelectedAccounts(om_gui):
    '''
    iterate over te accounts table, and print letters to those who
    have been selected to get an invoice
    '''

    if om_gui.ui.accounts_tableWidget.rowCount() == 0:
        om_gui.advise("Please load the table first", 1)
        return
    firstPage = True
    no_printed = 0
    for row in range(om_gui.ui.accounts_tableWidget.rowCount()):
        for col in range(11, 14):
            item = om_gui.ui.accounts_tableWidget.item(row, col)
            if item.checkState():
                tone = ("A", "B", "C")[col - 11]
                sno = int(om_gui.ui.accounts_tableWidget.item(row, 1).text())
                LOGGER.info("Account tone %s letter to %s", tone, sno)
                printpt = patient_class.patient(sno)

                doc = AccountLetter(printpt.title, printpt.fname, printpt.sname,
                                    (printpt.addr1,
                                     printpt.addr2,
                                     printpt.addr3,
                                     printpt.town,
                                     printpt.county),
                                    printpt.pcde, printpt.fees)
                doc.setTone(tone)

                if firstPage:
                    # -raise a print dialog for the first letter of the run
                    # -only
                    if not doc.dialogExec():
                        # - user has abandoned the print run
                        return
                    chosenPrinter = doc.printer
                    chosenPageSize = doc.printer.pageSize()
                    firstPage = False
                else:
                    doc.printer = chosenPrinter
                    doc.printer.setPaperSize(chosenPageSize)
                doc.requireDialog = False
                if tone == "B":
                    doc.setPreviousCorrespondenceDate(printpt.billdate)
                if doc.print_():
                    printpt.updateBilling(tone)
                    printpt.addHiddenNote(
                        "printed", "account - tone %s" % tone)

                    patient_write_changes.discreet_changes(
                        printpt, ("billct", "billdate", "billtype"))

                    patient_write_changes.toNotes(sno,
                                                  printpt.HIDDENNOTES)

                    commitPDFtoDB(om_gui,
                                  "Account tone%s" % tone, printpt.serialno)

                    no_printed += 1
    om_gui.advise("%d letters printed" % no_printed, 1)
Ejemplo n.º 2
0
def takePayment(om_gui):
    '''
    raise a dialog, and take some money
    '''
    if om_gui.pt.serialno == 0:
        om_gui.advise("No patient Selected <br />Monies will be " +
                      "allocated to Other Payments, and no receipt offered")
    dl = PaymentDialog(om_gui)
    dl.set_treatment_default_amount(om_gui.pt.fees)
    dl.hide_treatment(om_gui.pt.serialno == 0)
    if dl.exec_():
        if om_gui.pt.serialno == 0:
            paymentPt = patient_class.patient(22963)
        else:
            paymentPt = om_gui.pt

        name = "%s %s" % (paymentPt.sname, paymentPt.fname[:1])
        if paymentPt.dnt2 != 0:
            dent = paymentPt.dnt2
        else:
            dent = paymentPt.dnt1

        LOGGER.debug("TAKING PAYMENT for patient %s" % paymentPt.serialno)

        if cashbook.paymenttaken(paymentPt.serialno, name, dent,
                                 paymentPt.cset, dl.tx_cash, dl.tx_cheque,
                                 dl.tx_card, dl.sundry_cash, dl.sundry_cheque,
                                 dl.sundry_card, dl.hdp, dl.other, dl.refund):

            paymentPt.addHiddenNote(
                "payment", " treatment %s sundries %s" %
                (dl.tx_total_text, dl.sundry_total_text))

            om_gui.updateHiddenNotesLabel()

            if om_gui.pt.serialno != 0:
                LOGGER.debug("loaded patient == payment patient")
                om_printing.printReceipt(om_gui, {
                    "Treatments and Services": dl.tx_total_text,
                    "Sundry Items": dl.sundry_total_text,
                    "Unspecified Items": dl.other_text,
                    "REFUND": dl.refund_text
                },
                                         total=dl.grand_total_text)

                #-- always refer to money in terms of pence
                print "adjusting money"
                if om_gui.pt.cset[:1] == "N":
                    om_gui.pt.money2 += dl.tx_total
                else:
                    om_gui.pt.money3 += dl.tx_total
                om_gui.pt.money11 -= dl.refund

            else:
                LOGGER.debug(
                    "Payment patient is not loaded. skipping receipt offer.")

            patient_write_changes.toNotes(paymentPt.serialno,
                                          paymentPt.HIDDENNOTES)

            LOGGER.debug("writing payment notes")
            if patient_write_changes.discreet_changes(
                    paymentPt,
                ("money2", "money3", "money11")) and om_gui.pt.serialno != 0:
                LOGGER.debug("updating patient's stored money values")
                om_gui.pt.dbstate.money2 = om_gui.pt.money2
                om_gui.pt.dbstate.money3 = om_gui.pt.money3
                om_gui.pt.dbstate.money11 = om_gui.pt.money11

            paymentPt.clearHiddenNotes()
            om_gui.updateDetails()
            om_gui.updateHiddenNotesLabel()
            LOGGER.info("PAYMENT ALL DONE!")
        else:
            LOGGER.warning("payment failed to write to database!")
            message = "%s<br />%s" % (
                _("error applying payment.... sorry!"),
                _("This shouldn't happen - please report as an urgent bug"))
            om_gui.advise(message, 2)
Ejemplo n.º 3
0
def takePayment(om_gui):
    '''
    raise a dialog, and take some money
    '''
    if om_gui.pt.serialno == 0:
        om_gui.advise("No patient Selected <br />Monies will be "+ \
        "allocated to Other Payments, and no receipt offered")
    dl = PaymentDialog(om_gui)
    dl.set_treatment_default_amount(om_gui.pt.fees)
    dl.hide_treatment(om_gui.pt.serialno == 0)
    if dl.exec_():
        if om_gui.pt.serialno == 0:
            paymentPt = patient_class.patient(22963)
        else:
            paymentPt = om_gui.pt

        name = "%s %s"% (paymentPt.sname, paymentPt.fname[:1])
        if paymentPt.dnt2 != 0:
            dent = paymentPt.dnt2
        else:
            dent = paymentPt.dnt1

        LOGGER.debug("TAKING PAYMENT for patient %s"% paymentPt.serialno)

        if cashbook.paymenttaken(paymentPt.serialno, name, dent,paymentPt.cset,
        dl.tx_cash, dl.tx_cheque, dl.tx_card,
        dl.sundry_cash, dl.sundry_cheque, dl.sundry_card,
        dl.hdp, dl.other, dl.refund):

            paymentPt.addHiddenNote("payment",
            " treatment %s sundries %s"% (
                dl.tx_total_text, dl.sundry_total_text))

            om_gui.updateHiddenNotesLabel()

            if om_gui.pt.serialno != 0:
                LOGGER.debug("loaded patient == payment patient")
                om_printing.printReceipt(om_gui,{
                "Treatments and Services" : dl.tx_total_text,
                "Sundry Items" : dl.sundry_total_text,
                "Unspecified Items" : dl.other_text,
                "REFUND" : dl.refund_text},
                total=dl.grand_total_text)

                #-- always refer to money in terms of pence
                print "adjusting money"
                if om_gui.pt.cset[:1] == "N":
                    om_gui.pt.money2 += dl.tx_total
                else:
                    om_gui.pt.money3 += dl.tx_total
                om_gui.pt.money11 -= dl.refund

            else:
                LOGGER.debug(
                "Payment patient is not loaded. skipping receipt offer.")

            patient_write_changes.toNotes(paymentPt.serialno,
                                          paymentPt.HIDDENNOTES)

            LOGGER.debug("writing payment notes")
            if patient_write_changes.discreet_changes(paymentPt,
            ("money2", "money3", "money11")) and om_gui.pt.serialno != 0:
                LOGGER.debug("updating patient's stored money values")
                om_gui.pt.dbstate.money2 = om_gui.pt.money2
                om_gui.pt.dbstate.money3 = om_gui.pt.money3
                om_gui.pt.dbstate.money11 = om_gui.pt.money11

            paymentPt.clearHiddenNotes()
            om_gui.updateDetails()
            om_gui.updateHiddenNotesLabel()
            LOGGER.info("PAYMENT ALL DONE!")
        else:
            LOGGER.warning("payment failed to write to database!")
            message = "%s<br />%s"% (
                _("error applying payment.... sorry!"),
                _("This shouldn't happen - please report as an urgent bug")
                )
            om_gui.advise(message, 2)
Ejemplo n.º 4
0
def takePayment(om_gui):
    '''
    raise a dialog, and take some money
    '''
    if om_gui.pt.serialno == 0:
        try:
            paymentPt = patient_class.patient(22963)
        except PatientNotFoundError:
            om_gui.advise(_("Please choose a patient"), 1)
            return
        om_gui.advise(
            "%s <br />%s" %
            (_("No patient Selected"),
             _("Monies will be allocated to Other Payments, and no receipt "
               "offered")), 1)
    else:
        paymentPt = om_gui.pt

    dl = PaymentDialog(om_gui)
    dl.set_treatment_default_amount(paymentPt.fees)
    dl.hide_treatment(om_gui.pt.serialno == 0)
    payment_taken = False
    name = "%s %s" % (paymentPt.sname, paymentPt.fname[:1])
    if paymentPt.dnt2 != 0:
        dent = paymentPt.dnt2
    else:
        dent = paymentPt.dnt1

    while not payment_taken:
        if not dl.exec_():
            break
        if (dl.tx_total > paymentPt.fees and QtWidgets.QMessageBox.question(
                dl, _("Confirm"),
                _("Overpayment of treatment fees, is this correct?"),
                QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No,
                QtWidgets.QMessageBox.No) == QtWidgets.QMessageBox.No):
            continue

        LOGGER.debug("TAKING PAYMENT for patient %s", paymentPt.serialno)

        if cashbook.paymenttaken(paymentPt.serialno, name, dent,
                                 paymentPt.cset, dl.tx_cash, dl.tx_cheque,
                                 dl.tx_card, dl.sundry_cash, dl.sundry_cheque,
                                 dl.sundry_card, dl.hdp, dl.other, dl.refund):

            paymentPt.addHiddenNote(
                "payment", " treatment %s sundries %s" %
                (dl.tx_total_text, dl.sundry_total_text))

            om_gui.updateHiddenNotesLabel()

            if om_gui.pt.serialno != 0:
                LOGGER.debug("loaded patient == payment patient")
                om_printing.printReceipt(om_gui, {
                    "Treatments and Services": dl.tx_total_text,
                    "Sundry Items": dl.sundry_total_text,
                    "Unspecified Items": dl.other_text,
                    "REFUND": dl.refund_text
                },
                                         total=dl.grand_total_text)

                # always refer to money in terms of pence
                LOGGER.debug("adjusting money")
                if om_gui.pt.cset[:1] == "N":
                    om_gui.pt.money2 += dl.tx_total
                else:
                    om_gui.pt.money3 += dl.tx_total
                om_gui.pt.money11 -= dl.refund

            else:
                LOGGER.debug(
                    "Payment patient is not loaded. skipping receipt offer.")

            LOGGER.debug("writing payment notes")
            om_gui.pt.reset_billing()
            if patient_write_changes.discreet_changes(
                    paymentPt,
                ("money2", "money3", "money11", "billdate", "billct",
                 "billtype")) and om_gui.pt.serialno != 0:
                LOGGER.debug("updating patient's stored money values")
                om_gui.pt.dbstate.money2 = om_gui.pt.money2
                om_gui.pt.dbstate.money3 = om_gui.pt.money3
                om_gui.pt.dbstate.money11 = om_gui.pt.money11
                om_gui.pt.dbstate.reset_billing()

            om_gui.updateDetails()
            om_gui.updateHiddenNotesLabel()
            LOGGER.info("PAYMENT ALL DONE!")
            payment_taken = True