Beispiel #1
0
    def setPrices(self, visit):
        price_dict = visit.getPriceDict()

        self.ui.operationSpinBox.setValue(price_dict["operation_price"] * (100+SqlHandler.getALV(1))/100.)
        self.ui.accessoriesSpinBox.setValue(price_dict["accesories_price"] * (100+SqlHandler.getALV(1))/100.)
        self.ui.labSpinBox.setValue( price_dict["lab_price"] * (100+SqlHandler.getALV(1))/100.)
        self.ui.medicineSpinBox.setValue(price_dict["medicine_price"] * (100+SqlHandler.getALV(2))/100.)
        self.ui.dietSpinBox.setValue(price_dict["diet_price"] * (100+SqlHandler.getALV(3))/100.)
Beispiel #2
0
    def getData(self):
        print("DEBUG: getData")
        data = {}
        data['visit'] = self.visit
        if self.ui.clinic_radio_button.isChecked():
            data['clinic_payment'] = self.ui.clinicPriceSpinBox.value() / ((100+SqlHandler.getALV(1))/100.)
            data['km'] = 0.0
            data['km_payment'] = 0.0
        else:
            data['clinic_payment'] = self.ui.visitPriceSpinBox.value() / ((100+SqlHandler.getALV(1))/100.)
            data['km'] = self.ui.KmSpinBox.value()
            data['km_payment'] = self.ui.KmPriceSpinBox.value() / ((100+SqlHandler.getALV(1))/100.)

        data['operations_payment'] = self.ui.operationSpinBox.value() / ((100+SqlHandler.getALV(1))/100.)
        data['lab_payment'] = self.ui.labSpinBox.value() / ((100+SqlHandler.getALV(1))/100.)
        data['accessories_payment'] = self.ui.accessoriesSpinBox.value() / ((100+SqlHandler.getALV(1))/100.)
        data['extra_percent'] = self.ui.precentSlider.value()
        data['medicines_payment'] = self.ui.medicineSpinBox.value() / ((100+SqlHandler.getALV(2))/100.)
        data['diet_payment'] = self.ui.dietSpinBox.value() / ((100+SqlHandler.getALV(3))/100.)
        data['payment_method'] = (self.ui.paymentComboBox.itemData(self.ui.paymentComboBox.currentIndex()))
        data['due_date'] = self.qdateToPy(self.ui.DueDateEdit.date())
        data['paid_time'] = self.qdateToPy(self.ui.paidDateEdit.date())
        data['paid_value'] = self.ui.paidSpinBox.value()
        data['index_number'] = self.ui.indexNumberLabel.text()
        data['other_info'] = self.ui.otherInfoTextEdit.toPlainText()
        data['satus'] = 0 #status TODO: implement if needed
        
        print('operations_payment ',data['operations_payment'])
        
        return data
Beispiel #3
0
 def updateEndPrice(self):
     price_ALV1 = self.getALV1Price() * (100+SqlHandler.getALV(1))/100.
     price_ALV2 = self.getALV2Price() * (100+SqlHandler.getALV(2))/100.
     price_ALV3 = self.getALV3Price() * (100+SqlHandler.getALV(3))/100.
     
     self.ui.price_ALV1_total_label.setText('%.2f' % price_ALV1)
     self.ui.ALV1_total.setText('%.2f' % (price_ALV1-self.getALV1Price()))
     
     self.ui.price_ALV2_total_label.setText('%.2f' % price_ALV2)
     self.ui.ALV2_total.setText('%.2f' % (price_ALV2-self.getALV2Price()))
     
     self.ui.price_ALV3_total_label.setText('%.2f' % price_ALV3)
     self.ui.ALV3_total.setText('%.2f' % (price_ALV3-self.getALV3Price()))
     
     self.ui.endPriceLabel.setText('%.2f' % (price_ALV1 + price_ALV2 + price_ALV3))
Beispiel #4
0
    def genTableRow(self, operation):
        counter = 0
        tmp_rows = ''
        tmp_rows += self.genTableRowPrue(name=operation.base.name,
                                         count=operation.count,
                                         type_="kpl",
                                         price=operation.price,
                                         alv=SqlHandler.getALV(1))
        counter += 1
        if (hasattr(operation.base, 'item')):
            print("operation.base.item: ", operation.base.item)
            tmp_rows += self.genTableRowPrue(
                name=('- ' + operation.base.item.name),
                count=operation.count,
                type_=operation.base.item.count_type,
                price=operation.base.item.price,
                alv=operation.base.item.getALV())
            counter += 1
        if (hasattr(operation, 'items')):
            print("items listing strt")
            for surgeryitem in operation.items:
                total_count = operation.count * surgeryitem.count

                tmp_rows += self.genTableRowPrue(
                    name=('- ' + surgeryitem.item.name),
                    count=total_count,
                    type_=surgeryitem.item.count_type,
                    price=surgeryitem.item.price,
                    alv=surgeryitem.item.getALV())
                counter += 1

        return (tmp_rows, counter)
Beispiel #5
0
 def genTableRow(self, operation):
     counter = 0
     tmp_rows = ''
     tmp_rows += self.genTableRowPrue(name = operation.base.name,
                                     count = operation.count,
                                     type_ = "kpl",
                                     price = operation.price,
                                     alv = SqlHandler.getALV(1))
     counter += 1
     if(hasattr(operation.base, 'item')):
         print("operation.base.item: ", operation.base.item)
         tmp_rows += self.genTableRowPrue(name = ('- ' + operation.base.item.name),
                                          count = operation.count,
                                          type_ = operation.base.item.count_type,
                                          price = operation.base.item.price,
                                          alv = operation.base.item.getALV())
         counter += 1
     if(hasattr(operation, 'items')):
         print("items listing strt")
         for surgeryitem in operation.items:
             total_count = operation.count*surgeryitem.count
             
             tmp_rows += self.genTableRowPrue(name = ('- ' + surgeryitem.item.name),
                                             count = total_count,
                                             type_ = surgeryitem.item.count_type,
                                             price = surgeryitem.item.price,
                                             alv = surgeryitem.item.getALV())
             counter += 1
     
     return (tmp_rows, counter)
Beispiel #6
0
 def setAlv1Names(self):
     alv = str(SqlHandler.getALV(1))
     self.ui.ALV1_1.setText(alv + '%')
     self.ui.ALV1_2.setText(alv + '%')
     self.ui.ALV1_3.setText(alv + '%')
     self.ui.ALV1_4.setText(alv + '%')
     #self.ui.ALV1_5.setText(alv + '%')
     self.ui.ALV1_6.setText(alv + '%')
     self.ui.ALV1_7.setText(alv + '%')
Beispiel #7
0
    def setBasicInfo(self):
        self.setPaymnetMethods()
        self.setDueDates()
        self.setAlv1Names()
        self.setAlv2Names()
        self.setAlv3Names()
        
        if self.item != None:
            if self.item.getType() != 'Visit':
                self.ui.ownerLabel.setText(self.item.visit.owner.name)   

                if self.item.km < 0.001 and self.item.km_payment < 0.001:
                    self.ui.clinic_radio_button.setChecked(True)
                    self.ui.clinicPriceSpinBox.setValue(self.item.clinic_payment * ((100+SqlHandler.getALV(1))/100.))
                else:
                    self.ui.clinic_radio_button.setChecked(False)
                    self.ui.KmSpinBox.setValue(self.item.km)

                    self.ui.visitPriceSpinBox.setValue(self.item.clinic_payment * ((100+SqlHandler.getALV(1))/100.))
                    self.ui.KmPriceSpinBox.setValue(self.item.km_payment * ((100+SqlHandler.getALV(1))/100.))

                self.ui.operationSpinBox.setValue(self.item.operations_payment * ((100+SqlHandler.getALV(1))/100.))
                self.ui.accessoriesSpinBox.setValue(self.item.accessories_payment * ((100+SqlHandler.getALV(1))/100.))
                self.ui.labSpinBox.setValue(self.item.lab_payment * ((100+SqlHandler.getALV(1))/100.))
                self.ui.medicineSpinBox.setValue(self.item.medicines_payment * ((100+SqlHandler.getALV(2))/100.))
                self.ui.dietSpinBox.setValue(self.item.diet_payment * ((100+SqlHandler.getALV(3))/100.))
                self.ui.paidSpinBox.setValue(self.item.paid_value) #this has all alvs so it cant be out of them

                self.ui.otherInfoTextEdit.setPlainText(self.item.other_info)
                self.ui.paymentComboBox.setCurrentIndex(self.ui.paymentComboBox.findData(self.item.payment_method))
                self.ui.paidDateEdit.setDate(self.item.paid_time)
                self.ui.DueDateEdit.setDate(self.item.due_date)
                self.ui.precentSlider.setValue(self.item.extra_percent)
                self.ui.indexNumberLabel.setText(str(self.item.index_number)) 
                
            else:
                self.ui.ownerLabel.setText(self.item.owner.name)
                self.setDefaultClinicPrice()
                self.setPrices(self.item) #item is visit
            
        else:
            self.errorMessage("ERROR: BillTab: setBasicInfo: item is None")
Beispiel #8
0
 def getALV1Price(self):
     price_ALV1 = 0.0
     if not self.ui.clinic_radio_button.isChecked():
         price_ALV1 += self.ui.KmPriceSpinBox.value()
         price_ALV1 += self.ui.visitPriceSpinBox.value()
     else:
         price_ALV1 += self.ui.clinicPriceSpinBox.value()
     
     price_ALV1 += self.ui.operationSpinBox.value()
     price_ALV1 += self.ui.accessoriesSpinBox.value()
     price_ALV1 += self.ui.labSpinBox.value()
     
     return (price_ALV1*(100 + self.ui.precentSlider.value())/100.0) / ((100+SqlHandler.getALV(1))/100.)
Beispiel #9
0
 def setAlv3Names(self):
     alv3 = str(SqlHandler.getALV(3))
     self.ui.ALV3_1.setText(alv3 + '%')
     self.ui.ALV3_2.setText(alv3 + '%')
Beispiel #10
0
 def setAlv2Names(self):
     alv2 = str(SqlHandler.getALV(2))
     self.ui.ALV2_1.setText(alv2 + '%')
     self.ui.ALV2_2.setText(alv2 + '%')
Beispiel #11
0
 def getALVMul(self, alv_type):
     if (alv_type):
         from models import SqlHandler
         return (1.0 + SqlHandler.getALV(alv_type) / 100.0)
     else:
         return 1.0
Beispiel #12
0
 def getALV2Price(self):
     return self.ui.medicineSpinBox.value() / ((100+SqlHandler.getALV(2))/100.)
Beispiel #13
0
 def setDefaultClinicPrice(self):
     self.ui.clinicPriceSpinBox.setValue(SqlHandler.getGlobalVar(key="clinicpayment") * (100+SqlHandler.getALV(1))/100.)
Beispiel #14
0
 def getALV(self=None):
     from models import SqlHandler
     return SqlHandler.getALV(g_item_alv_dict[ItemStrings.item])
Beispiel #15
0
 def getALV3Price(self):
     return self.ui.dietSpinBox.value() / ((100+SqlHandler.getALV(3))/100.)
Beispiel #16
0
    def makePrintfile(self, bill, language='Finnish'):#TODO:add bill needed info
        
        self.html = ""
        try:
            f = open(self.path, 'r', encoding="utf-8")
        except  IOError:
            self.errorMessage("Can not open file named: " + self.path)
            return ""
        
        for i in f.readlines():
            self.html += i

        
        self.change("vet_name", bill.visit.vet.name)
        self.change("vet_number", str(bill.visit.vet.vet_number))
        self.change("vet_address", bill.visit.vet.address)
        if(not bill.visit.vet.postnumber == None):
            self.change("vet_postnumber", bill.visit.vet.postnumber.number)
        else:
            self.change("vet_postnumber","")
            
        if(not bill.visit.vet.post_office == None):
            self.change("vet_postaddress", bill.visit.vet.post_office.name)
        else:
            self.change("vet_postaddress","")
        #self.change("alv_number", bill.visit.vet.alv_number)#alv_number
        self.change("owner_name", bill.visit.owner.name)
        self.change("owner_address", bill.visit.owner.address)
        if(not bill.visit.owner.post_office == None):
            self.change("owner_postaddress", bill.visit.owner.post_office.name)
        else:
            self.change("owner_postaddress","");
            
        if(not bill.visit.owner.postnumber == None):
            self.change("owner_postnumber", bill.visit.owner.postnumber.number)
        else:
            self.change("owner_postnumber","")
        self.change("bill_number", bill.id) #TODO change id to some other
        self.change("bill_date", self.getDateNow()) #TODO change or add to Bill
        self.change("due_date", bill.due_date)
        self.change("penalty_interest", 8.00) #TODO change
        self.change("index_number", bill.index_number)
        self.change("payment_condition", "14 pv") #todo change
        self.change("bank_name", bill.visit.vet.bank_name)
        self.change("account_number", bill.visit.vet.IBAN)
        self.change("swif_bic", bill.visit.vet.SWIF)
        self.change("payment_method", bill.payment_method)
        
        
        self.html = self.html.replace("animal_info_area", self.genAnimalInfos(bill.visit.visitanimals))
        
        self.html = self.html.replace('visitanimal_summarys',self.summaryToHTML(bill.visit.visitanimals))
        
        operation_rows = ""
        operation_row_count = 0
        
        if(bill.clinic_payment > 0):
            if(bill.km == 0):
                operation_rows += self.genTableRowPrue("Klinikkamaksu", 1, "", bill.clinic_payment,  SqlHandler.getALV(1))
            else:
                operation_rows += self.genTableRowPrue("Käyntimaksu", 1, "", bill.clinic_payment,  SqlHandler.getALV(1))
            operation_row_count +=1
                
        if(bill.km_payment > 0):
            operation_rows += self.genTableRowPrue("Kilometrikorvaus " + str(bill.km) + "km", 1, "", bill.clinic_payment,  SqlHandler.getALV(1))
            operation_row_count +=1
              
        
        for va in bill.visit.visitanimals:
            if(len(bill.visit.visitanimals) > 1):
                (rows, count) = self.genAnimalTableRow(va.animal.name)
                operation_rows += rows
                operation_row_count += count

            for oper in va.operations:
                (rows, count) = self.genTableRow(oper)
                operation_rows += rows
                operation_row_count += count

            for item in va.items:
                (rows, count) = self.genItemTableRow(item)
                operation_rows += rows
                operation_row_count += count


        price_dict = bill.calcPricesFromVisit()
        
                
        if(not self.floatEqual(price_dict["operation_price"], bill.operations_payment)):
            print("DEBUG: PrintFileCreator: ", price_dict["operation_price"] ," ", bill.operations_payment)
            operation_rows += self.genTableRowPrue("Operaatioiden hintamuutos", 1, "", -price_dict["operation_price"] + bill.operations_payment,  SqlHandler.getALV(1))
            operation_row_count +=1
            
        if(not self.floatEqual(price_dict["accesories_price"], bill.accessories_payment)):
            operation_rows += self.genTableRowPrue("Tarvikkeiden hintamuutos", 1, "", -price_dict["accesories_price"] + bill.accessories_payment,  SqlHandler.getALV(1))
            operation_row_count +=1
        
        if(not self.floatEqual(price_dict["lab_price"], bill.lab_payment)):
            operation_rows += self.genTableRowPrue("Laboratorio hintamuutos", 1, "", -price_dict["lab_price"] + bill.lab_payment,  SqlHandler.getALV(1))
            operation_row_count +=1

        if(not self.floatEqual(price_dict["medicine_price"], bill.medicines_payment)):
            print("DEBUG: PrintFileCreator: ", price_dict["medicine_price"] ," ", bill.medicines_payment)
            operation_rows += self.genTableRowPrue("Lääkkeiden hintamuutos", 1, "", -price_dict["medicine_price"] + bill.medicines_payment,  SqlHandler.getALV(2))
            operation_row_count +=1
            
        if(not self.floatEqual(price_dict["diet_price"], bill.diet_payment)):
            operation_rows += self.genTableRowPrue("Rehujen hintamuutos", 1, "", -price_dict["diet_price"] + bill.diet_payment,  SqlHandler.getALV(3))
            operation_row_count +=1
            
            
        if(not self.floatEqual(0,bill.extra_percent) ):
            operation_rows += self.genTableRowPrue("Muu korotus (" + str(bill.extra_percent) + "%)", 1, "", bill.getExtraPartFromPrice(),  SqlHandler.getALV(1))
            operation_row_count +=1
        
        
        for i in range(0,self.table_row_count-operation_row_count):
            operation_rows += self.genEmptyTableRow()
        
        self.change("operations_lists", operation_rows, False)
        
        self.change("price_total", self.toStr(bill.getTotalPrice()))
        self.change("need_to_pay", self.toStr(bill.getTotalPrice()-bill.paid_value))
        self.change("alv_total", self.toStr(bill.getTotalALV()))
        
        self.change("vet_phonenumber", "") #TODO implement
        self.change("vet_email_address", "") #TODO implement
        
        self.change("other_info", bill.other_info)
        
        return self.html
Beispiel #17
0
 def getTotal(self):
     return self.getALV1Price()*((100+SqlHandler.getALV(1))/100.) + self.getALV2Price()*((100+SqlHandler.getALV(2))/100.) + self.getALV3Price()*((100+SqlHandler.getALV(3))/100.)
Beispiel #18
0
    def makePrintfile(self,
                      bill,
                      language='Finnish'):  #TODO:add bill needed info

        self.html = ""
        try:
            f = open(self.path, 'r', encoding="utf-8")
        except IOError:
            self.errorMessage("Can not open file named: " + self.path)
            return ""

        for i in f.readlines():
            self.html += i

        self.change("vet_name", bill.visit.vet.name)
        self.change("vet_number", str(bill.visit.vet.vet_number))
        self.change("vet_address", bill.visit.vet.address)
        if (not bill.visit.vet.postnumber == None):
            self.change("vet_postnumber", bill.visit.vet.postnumber.number)
        else:
            self.change("vet_postnumber", "")

        if (not bill.visit.vet.post_office == None):
            self.change("vet_postaddress", bill.visit.vet.post_office.name)
        else:
            self.change("vet_postaddress", "")
        #self.change("alv_number", bill.visit.vet.alv_number)#alv_number
        self.change("owner_name", bill.visit.owner.name)
        self.change("owner_address", bill.visit.owner.address)
        if (not bill.visit.owner.post_office == None):
            self.change("owner_postaddress", bill.visit.owner.post_office.name)
        else:
            self.change("owner_postaddress", "")

        if (not bill.visit.owner.postnumber == None):
            self.change("owner_postnumber", bill.visit.owner.postnumber.number)
        else:
            self.change("owner_postnumber", "")
        self.change("bill_number", bill.id)  #TODO change id to some other
        self.change("bill_date",
                    self.getDateNow())  #TODO change or add to Bill
        self.change("due_date", bill.due_date)
        self.change("penalty_interest", 8.00)  #TODO change
        self.change("index_number", bill.index_number)
        self.change("payment_condition", "14 pv")  #todo change
        self.change("bank_name", bill.visit.vet.bank_name)
        self.change("account_number", bill.visit.vet.IBAN)
        self.change("swif_bic", bill.visit.vet.SWIF)
        self.change("payment_method", bill.payment_method)

        self.html = self.html.replace(
            "animal_info_area", self.genAnimalInfos(bill.visit.visitanimals))

        self.html = self.html.replace(
            'visitanimal_summarys',
            self.summaryToHTML(bill.visit.visitanimals))

        operation_rows = ""
        operation_row_count = 0

        if (bill.clinic_payment > 0):
            if (bill.km == 0):
                operation_rows += self.genTableRowPrue("Klinikkamaksu", 1, "",
                                                       bill.clinic_payment,
                                                       SqlHandler.getALV(1))
            else:
                operation_rows += self.genTableRowPrue("Käyntimaksu", 1, "",
                                                       bill.clinic_payment,
                                                       SqlHandler.getALV(1))
            operation_row_count += 1

        if (bill.km_payment > 0):
            operation_rows += self.genTableRowPrue(
                "Kilometrikorvaus " + str(bill.km) + "km", 1, "",
                bill.clinic_payment, SqlHandler.getALV(1))
            operation_row_count += 1

        for va in bill.visit.visitanimals:
            if (len(bill.visit.visitanimals) > 1):
                (rows, count) = self.genAnimalTableRow(va.animal.name)
                operation_rows += rows
                operation_row_count += count

            for oper in va.operations:
                (rows, count) = self.genTableRow(oper)
                operation_rows += rows
                operation_row_count += count

            for item in va.items:
                (rows, count) = self.genItemTableRow(item)
                operation_rows += rows
                operation_row_count += count

        price_dict = bill.calcPricesFromVisit()

        if (not self.floatEqual(price_dict["operation_price"],
                                bill.operations_payment)):
            print("DEBUG: PrintFileCreator: ", price_dict["operation_price"],
                  " ", bill.operations_payment)
            operation_rows += self.genTableRowPrue(
                "Operaatioiden hintamuutos", 1, "",
                -price_dict["operation_price"] + bill.operations_payment,
                SqlHandler.getALV(1))
            operation_row_count += 1

        if (not self.floatEqual(price_dict["accesories_price"],
                                bill.accessories_payment)):
            operation_rows += self.genTableRowPrue(
                "Tarvikkeiden hintamuutos", 1, "",
                -price_dict["accesories_price"] + bill.accessories_payment,
                SqlHandler.getALV(1))
            operation_row_count += 1

        if (not self.floatEqual(price_dict["lab_price"], bill.lab_payment)):
            operation_rows += self.genTableRowPrue(
                "Laboratorio hintamuutos", 1, "",
                -price_dict["lab_price"] + bill.lab_payment,
                SqlHandler.getALV(1))
            operation_row_count += 1

        if (not self.floatEqual(price_dict["medicine_price"],
                                bill.medicines_payment)):
            print("DEBUG: PrintFileCreator: ", price_dict["medicine_price"],
                  " ", bill.medicines_payment)
            operation_rows += self.genTableRowPrue(
                "Lääkkeiden hintamuutos", 1, "",
                -price_dict["medicine_price"] + bill.medicines_payment,
                SqlHandler.getALV(2))
            operation_row_count += 1

        if (not self.floatEqual(price_dict["diet_price"], bill.diet_payment)):
            operation_rows += self.genTableRowPrue(
                "Rehujen hintamuutos", 1, "",
                -price_dict["diet_price"] + bill.diet_payment,
                SqlHandler.getALV(3))
            operation_row_count += 1

        if (not self.floatEqual(0, bill.extra_percent)):
            operation_rows += self.genTableRowPrue(
                "Muu korotus (" + str(bill.extra_percent) + "%)", 1, "",
                bill.getExtraPartFromPrice(), SqlHandler.getALV(1))
            operation_row_count += 1

        for i in range(0, self.table_row_count - operation_row_count):
            operation_rows += self.genEmptyTableRow()

        self.change("operations_lists", operation_rows, False)

        self.change("price_total", self.toStr(bill.getTotalPrice()))
        self.change("need_to_pay",
                    self.toStr(bill.getTotalPrice() - bill.paid_value))
        self.change("alv_total", self.toStr(bill.getTotalALV()))

        self.change("vet_phonenumber", "")  #TODO implement
        self.change("vet_email_address", "")  #TODO implement

        self.change("other_info", bill.other_info)

        return self.html
Beispiel #19
0
 def getALVMul(self, alv_type):
     if(alv_type):
         from models import SqlHandler
         return (1.0 + SqlHandler.getALV(alv_type) / 100.0)
     else:
         return 1.0