Exemplo n.º 1
0
    def __saveToPdf(self):
        if self.__quotationUI.customerNameValue.text() not in self.__customerInfo:
            dialog = CustomerDialog(self.__quotationUI.customerNameValue.text(), self.__quotationUI.customerAddressValue.text())
            dialog.exec_()
        if not self.__validateInputs():
            return

        self.__manager.saveQuotationInfo(
            self.__quotationUI.customerNameValue.text(),
            self.__quotationUI.customerAddressValue.text(),
            int(self.__quotationUI.quotationNoValue.text()),
            self.__quotationUI.validUntilValue.date().toPython(),
            self.__quotationUI.quotationDateValue.date().toPython(),
            float(self.__quotationUI.beforeTaxValue.text()),
            float(self.__quotationUI.afterTaxValue.text()),
            self.__quotationUI.remarksValue.toPlainText())

        for (itemCode, particular, hsnCode, quantity, rate, cgst, sgst, igst) in zip(self.__itemCodes, self.__particulars, self.__hsnCode, self.__quantity, self.__rate, self.__allCgst, self.__allSgst, self.__allIgst):
            self.__manager.saveQuotationItemInfo(
                self.__quotationUI.quotationNoValue.text(),
                itemCode,
                particular,
                hsnCode,
                quantity,
                float(rate),
                float(cgst),
                float(sgst),
                float(igst))
        try:
            quotationDirectory = _os.path.join(_os.path.dirname(_os.path.dirname(_os.path.dirname(__file__))),
                          'quotation', self.__quotationUI.quotationNoValue.text())
            _os.makedirs(quotationDirectory)
        except:
            return _QtGui.QMessageBox.critical(self, 'ERROR', 'Bill No is already generated.', buttons=_QtGui.QMessageBox.Ok)

        quotationDetails = self.__getQuotationDetails()
        canvas = _Canvas(_os.path.join(quotationDirectory, '{0}.pdf'.format(self.__quotationUI.quotationNoValue.text())), pagesize=_letter)
        QuotationTemplate(canvas, quotationDetails)
        canvas.save()

        if self.__quotationUI.printCheckBox.isChecked():
            self.handlePrint()
        self.__discardChanges()
        self.__quotationNo += 1
        self.__quotationUI.quotationNoValue.setText(str(self.__quotationNo))
Exemplo n.º 2
0
 def createPDF(self, billNo):
     try:
         billDirectory = _os.path.join(
             _os.path.dirname(_os.path.dirname(_os.path.dirname(__file__))),
             self._type, billNo)
         _os.makedirs(billDirectory)
     except:
         pass
     today = _datetime.datetime.today().strftime('%Y_%m_%d-%H_%M_%S')
     canvas = _Canvas(_os.path.join(billDirectory, '{0}.pdf'.format(today)),
                      pagesize=_letter)
     invoiceTemplate.InvoiceTemplate(canvas, self.__getSalesDetails(billNo),
                                     'Original')
     canvas.save()
     _QtGui.QMessageBox.information(self,
                                    'Saved',
                                    'Sales Information PDF created.',
                                    buttons=_QtGui.QMessageBox.Ok)
Exemplo n.º 3
0
    def __handlePreview(self):
        if self._salesInvoiceUI.customerNameValue.text().strip() and  self._salesInvoiceUI.customerNameValue.text() not in self.__customerInfo:
            dialog = CustomerDialog(self._salesInvoiceUI.customerNameValue.text(), self._salesInvoiceUI.customerAddressValue.text())
            dialog.exec_()
        if not self.__validateInputs():
            return

        import tempfile, shutil
        salesDirectory = tempfile.mkdtemp()
        pdfPath = _os.path.join(salesDirectory, '{0}.pdf'.format(self._salesInvoiceUI.billNoValue.text()))
        canvas = _Canvas(
            pdfPath,
            pagesize=_letter)
        salesDetails = self.__getSalesDetails()
        invoiceTemplate.InvoiceTemplate(canvas, salesDetails, '')
        canvas.save()
        dialog = _utils.PreviewDialog(self, pdfPath)
        dialog.setWindowTitle('')
        dialog.exec_()
        shutil.rmtree(salesDirectory)
Exemplo n.º 4
0
    def __handlePreview(self):
        if self.__quotationUI.customerNameValue.text().strip() and  self.__quotationUI.customerNameValue.text() not in self.__customerInfo:
            dialog = CustomerDialog(self.__quotationUI.customerNameValue.text(), self.__quotationUI.customerAddressValue.text())
            dialog.setWindowTitle('Save Customer Information')
            dialog.exec_()
        if not self.__validateInputs():
            return
        quotationDetails = self.__getQuotationDetails()

        quotationDirectory = tempfile.mkdtemp()
        pdfPath = _os.path.join(quotationDirectory, '{0}.pdf'.format(self.__quotationUI.quotationNoValue.text()))
        canvas = _Canvas(
            pdfPath,
            pagesize=_letter)
        QuotationTemplate(canvas, quotationDetails)
        canvas.save()
        dialog = _utils.PreviewDialog(self, pdfPath)
        dialog.setWindowTitle('Quotation Preview')
        dialog.exec_()
        shutil.rmtree(quotationDirectory)
Exemplo n.º 5
0
    def createPDF(self, quotationNo):
        '''
        Creates pdf for the passed quotation no
        '''
        try:
            quotationDirectory = _os.path.join(
                _os.path.dirname(_os.path.dirname(_os.path.dirname(__file__))),
                'quotation', quotationNo)
            _os.makedirs(quotationDirectory)
        except:
            pass
        today = _datetime.datetime.today().strftime('%Y_%m_%d-%H_%M_%S')
        canvas = _Canvas(_os.path.join(quotationDirectory,
                                       '{0}.pdf'.format(today)),
                         pagesize=_letter)
        QuotationTemplate(canvas, self.__getQuotationDetails(quotationNo))
        canvas.save()

        _QtGui.QMessageBox.information(self,
                                       'Saved',
                                       'Quotation Information PDF created.',
                                       buttons=_QtGui.QMessageBox.Ok)
Exemplo n.º 6
0
     '3',
     'cgstPs':
     '0',
     'sgst':
     '3%',
     'sgstRs':
     '3',
     'sgstPs':
     '0',
     'igst':
     '3%',
     'igstRs':
     '3',
     'igstPs':
     '0',
     'taxPs':
     '0',
     'amountWithTaxRs':
     '6',
     'amountWithTaxPs':
     '0',
     'amountWord': [
         'Eight lakh and Twenty two thousand and',
         ' Twenty-two rupees and  zero paise only'
     ],
     'fileName':
     'ergerge.pdf'
 }
 canvas = _Canvas('ergerge.pdf', pagesize=_letter)
 bill = InvoiceTemplate(canvas, billInfo)
 canvas.save()
Exemplo n.º 7
0
    def __saveToPdf(self):
        if self._salesInvoiceUI.customerNameValue.text() not in self.__customerInfo:
            dialog = CustomerDialog(
                self._salesInvoiceUI.customerNameValue.text(),
                self._salesInvoiceUI.customerAddressValue.text(),
                self._salesInvoiceUI.gstinValue.text(),
                self._salesInvoiceUI.stateCodeValue.text())
            dialog.setWindowTitle('Preview')
            dialog.exec_()
        if not self.__validateInputs():
            return

        self._manager.saveSalesInfo(
            self._salesInvoiceUI.customerNameValue.text(),
            self._salesInvoiceUI.customerAddressValue.text(),
            self._salesInvoiceUI.gstinValue.text(),
            int(self._salesInvoiceUI.stateCodeValue.text()),
            self._salesInvoiceUI.comboBox.currentText(),
            self._salesInvoiceUI.billNoValue.text(),
            self._salesInvoiceUI.billDateValue.date().toPython(),
            self._salesInvoiceUI.poNoValue.text(),
            self._salesInvoiceUI.poDateValue.text(),
            self._salesInvoiceUI.vendorCodeValue.text(),
            self._salesInvoiceUI.paymentTermsValue.text(),
            self._salesInvoiceUI.dcNoValue.text(),
            self._salesInvoiceUI.dcDateValue.text(),
            self._salesInvoiceUI.vehicleNoValue.text(),
            self._salesInvoiceUI.dispatchedValue.text(),
            float(self._salesInvoiceUI.beforeTaxValue.text()),
            float(self._salesInvoiceUI.afterTaxValue.text()),
            float(self._salesInvoiceUI.amountPaidValue.text()),
            self._salesInvoiceUI.remarksValue.toPlainText(),
        '')

        for (itemCode, particular, hsnCode, quantity, rate, cgst, sgst, igst) in zip(self.__itemCodes, self.__particulars, self.__hsnCode, self.__quantity,
                                                         self.__rate, self.__allCgst, self.__allSgst, self.__allIgst):
            self._manager.saveSalesItemInfo(
                self._salesInvoiceUI.billNoValue.text(),
                itemCode,
                particular,
                hsnCode,
                quantity,
                float(rate),
                float(cgst),
                float(sgst),
                float(igst))
        try:
            salesDirectory = _os.path.join(_os.path.dirname(_os.path.dirname(_os.path.dirname(__file__))),
                     self.__type, self._salesInvoiceUI.billNoValue.text())
            _os.makedirs(salesDirectory)
        except:
            return _QtGui.QMessageBox.critical(self, 'ERROR', 'Bill No is already generated.', buttons=_QtGui.QMessageBox.Ok)

        salesDetails = self.__getSalesDetails()
        pdfPath = _os.path.join(salesDirectory, '{0}.pdf'.format(self._salesInvoiceUI.billNoValue.text()))
        canvas = _Canvas(
            pdfPath,
            pagesize=_letter)
        invoiceTemplate.InvoiceTemplate(canvas, salesDetails, 'original')
        canvas.save()
        pdfPath = _os.path.join(salesDirectory, '{0}_duplicate.pdf'.format(self._salesInvoiceUI.billNoValue.text()))
        canvas = _Canvas(
            pdfPath,
            pagesize=_letter)
        invoiceTemplate.InvoiceTemplate(canvas, salesDetails, 'duplicate')
        canvas.save()
        pdfPath = _os.path.join(salesDirectory, '{0}_triplicate.pdf'.format(self._salesInvoiceUI.billNoValue.text()))
        canvas = _Canvas(
            pdfPath,
            pagesize=_letter)
        invoiceTemplate.InvoiceTemplate(canvas, salesDetails, 'triplicate')
        canvas.save()
        pdfPath = _os.path.join(salesDirectory, '{0}_extraCopy.pdf'.format(self._salesInvoiceUI.billNoValue.text()))
        canvas = _Canvas(
            pdfPath,
            pagesize=_letter)
        invoiceTemplate.InvoiceTemplate(canvas, salesDetails, 'extra copy')
        canvas.save()


        if self._salesInvoiceUI.deliveryChallan.isChecked():
            dcDirectory = _os.path.join(_os.path.dirname(_os.path.dirname(_os.path.dirname(__file__))),
                                  'Delivery Challan', self._salesInvoiceUI.billNoValue.text())
            try:
                _os.makedirs(dcDirectory)
            except:
                return _QtGui.QMessageBox.critical(self, 'ERROR', 'Delivery Challan is already generated.',
                                                   buttons=_QtGui.QMessageBox.Ok)
            removeKeys = ('customerName', 'customerAddress', 'gstin', 'stateCode',
                          'billNo', 'billDate', 'poNo', 'poDate', 'vendorCode',
                          'paymentTerms', 'dcNo', 'dcDate', 'vehicleNo', 'dispatchedThrough')
            for dictKey in removeKeys:
                if dictKey in salesDetails:
                    continue
                del salesDetails[dictKey]
            pdfPath = _os.path.join(dcDirectory, '{0}.pdf'.format(self._salesInvoiceUI.billNoValue.text()))
            canvas = _Canvas(
                pdfPath,
                pagesize=_letter)
            deliveryChallanTemplate.DeliveryChallanTemplate(canvas, salesDetails)
            canvas.save()

        if self._salesInvoiceUI.printCheckBox.isChecked():
            self.handlePrint()
        _QtGui.QMessageBox.information(self, 'Saved', 'Entered Sales Invoice saved successfully', buttons=_QtGui.QMessageBox.Ok)
        self.__discardChanges()
Exemplo n.º 8
0
    #     'amount': '234',
    #     'amountBeforeRs': '34',
    #     'amountBeforePs': '0',
    #     'cgst': '3%',
    #     'cgstRs': '3',
    #     'cgstPs': '0',
    #     'sgst': '3%',
    #     'sgstRs': '3',
    #     'sgstPs': '0',
    #     'igst': '3%',
    #     'igstRs': '3',
    #     'igstPs': '0',
    #     'afterTaxPs': '0',
    #     'afterTaxRs': '23',
    #     'origTaxPs': '0',
    #     'amountWithTaxRs': '6',
    #     'amountWithTaxPs': '0',
    #     'amountWord': ['Eight lakh and Twenty two thousand and', ' Twenty-two rupees and  zero paise only'],
    # }
    billInfo = {'afterTaxRs': ' 1', 'customerName': u'Fgjiuoh', 'amountBeforePs': '00', 'amountBeforeRs': ' 1', 'particulars': [u'iufghiug'], 'origTaxPs': '', 'sgst': '0%', 'quotationDate': '21-Aug-18', 'cgstPs': '00', 'rates': [8787.0], 'hsnCodes': [u'iugiug1'], 'cgstRs': ' 0', 'cgst': '0%', 'igst': '0%', 'igstRs': ' 0', 'customerAddress': u'iougouigiu', 'quantities': [u'3'], 'validDate': '21-Aug-18', 'igstPs': '00', 'billNo': u'1', 'sgstPs': '00', 'amountWord': [u'd'], 'sgstRs': ' 0', 'amounts': [26361.0], 'afterTaxPs': '00'}
    {'afterTaxRs': ' 1572', 'customerName': u'Hariharah', 'amountBeforePs': '00', 'amountBeforeRs': ' 1156',
     'particulars': ['dfiugig'], 'origTaxPs': '', 'sgst': '9%', 'quotationDate': '04-Sep-18', 'cgstPs': '00',
     'rates': ['34.0'], 'hsnCodes': ['3i4'], 'cgstRs': ' 0', 'cgst': '9%', 'igst': '18%', 'igstRs': ' 0',
     'customerAddress': u'lig 46 old astc hudcp', 'quantities': ['34'], 'validDate': '04-Sep-18', 'igstPs': '00',
     'billNo': u'1', 'sgstPs': '00',
     'amountWord': [u'Rs.', u'One', u'Thousand', u'Five', u'Hundred', u'And', u'Seventy', u'Two', u'only'],
     'sgstRs': ' 0', 'amounts': ['1156.0'], 'afterTaxPs': '00'}

    canvas = _Canvas('quotation.pdf', pagesize=_letter)
    bill = QuotationTemplate(canvas, billInfo)
    canvas.save()
     '33AAFFD3275P1Z5',
     'stateCode':
     '33',
     'billNo':
     '1',
     'billDate':
     '24-12-2017',
     'poNo':
     '2',
     'poDate':
     '24-12-2017',
     'vendorCode':
     '2354',
     'paymentTerms':
     'casg',
     'dcNo':
     '3',
     'dcDate':
     '24-12-2017',
     'vehicleNo':
     '234',
     'dispatchedThrough':
     'KPN',
     'itemCodes':
     ['ergdghdiugheiurghdri', 'erg', 'rthr', 'erg', 'erge', 'erge', 'erge'],
     'particulars': ['4', '4', '4', '4', '4', '4', '4'],
     'quantities': ['4', '4', '4', '4', '4', '4', '4']
 }
 canvas = _Canvas('dc.pdf', pagesize=_letter)
 bill = DeliveryChallanTemplate(canvas, dcInfo)
 canvas.save()