Beispiel #1
0
    def fertig(self):
        (filename, kb) = self.belegErzeugen()
        printed = False

        if not self.vorgang.getPayed() or self.vorgang.isBio() or self.rechnungdrucken:
            c = cups.Connection()
            c.printFile(c.getDefault(), filename, 'Rechnung %s' % kb['renr'], config('printer_plain'))
            printed = True

        if self.vorgang.isBio():
            # BIO-Beleg
            originale = [self.vorgang.ID,]
            if self.vorgang.originale:
                originale = self.vorgang.originale
                
            for idx in range(len(originale)):
                handle = originale[idx]
                vorgang = self.speicher.ladeVorgang(handle)
                filename = BioBeleg(vorgang, filename='BIO_%s_%02i.pdf' % (kb['renr'], idx))
                c = cups.Connection()
                c.printFile(c.getDefault(), filename, 'Bio-Beleg %s' % kb['renr'], config('printer_plain'))
                
                if vorgang.getBioLieferschein():
                    l = self.speicher.ladeBioLieferschein(vorgang.getBioLieferschein())
                    if not l['abholdatum']:
                        l['abholdatum'] = datetime.date.today()
                        self.speicher.speichereBioLieferschein(l)

        self.mainwindow.addRecentInvoice(self.vorgang)
        self.gegeben = 0.0
        if not printed:
            self.mainwindow.belegAnzeigen(filename)
            self.mainwindow.WIDGETS['abfuellung'].neuerVorgang()
        else:
            self.mainwindow.reset()
Beispiel #2
0
from lib.Config import config
from threading import Timer, Thread, Lock, Event
conf = config("tse")

import sys
import time
import logging
sys.path.insert(0, conf['library'])
import worm

TSEException = worm.WormException
log = logging.getLogger('bib.TSE')


class TSE():
    _tse = None
    _thread = None
    _stop = None
    _lock = None

    def __init__(self):
        self.master = False
        if not self.__class__._tse:
            log.info('start new TSE controller thread!')
            self.__class__._tse = worm.Worm(
                clientid=conf['clientid'], time_admin_pin=conf['timeadminpin'])
            self.__class__._lock = Lock()
            self.__class__._stop = Event()
            self.__class__._thread = Thread(target=self.worker)
            self.__class__._thread.start()
            self.master = True
Beispiel #3
0
def send_sms(vorgang):
    import socket, os

    conf = config('sms')

    HOST = conf['host']
    PORT = conf['port']

    SENT = conf['sentfolder']

    if not os.path.exists(SENT):
        os.makedirs(SENT)
    sent = open(
        os.path.join(SENT,
                     datetime.datetime.now().isoformat().replace(':', '-')),
        'wb')

    userkey = conf['userkey']
    password = conf['password']
    originator = conf[
        'number']  # diese Nummer ist bei aspsms.com für uns freigeschaltet

    recipients = vorgang.getTelefon().split(' / ')
    recipient = None
    for r in recipients:
        if r.startswith('01'):
            recipient = '+49' + r[1:]
            break

    if not recipient:
        raise ValueError('Keine Handynummer eingetragen!')

    recipient = recipient.replace('-', '').replace('.', '')

    text = u"Ihr Saft ist fertig. Möglichst zeitnahe Abholung bitte telefonisch absprechen. Gesamtbetrag: %s (%i Liter). Mosterei Wurst" % (
        getMoneyValue(vorgang.getSumme()), vorgang.getLiterzahl())

    text = text.replace(u'€', 'EUR')
    text = text.replace('<', '&lt;').replace('>', '&gt;')

    msgid = vorgang.ID
    if not msgid:
        msgid = '0000'

    CONTENT = u"""<?xml version="1.0" encoding="UTF-8"?>
    <aspsms>
      <Userkey>""" + str(userkey) + u"""</Userkey>
      <Password>""" + str(password) + u"""</Password>
      <Originator>""" + str(originator) + u"""</Originator>
      <Recipient>
        <PhoneNumber>""" + str(recipient) + u"""</PhoneNumber>
        <TransRefNumber>""" + str(msgid) + u"""</TransRefNumber>
      </Recipient>
      <MessageData>""" + str(text) + u"""</MessageData>
      <Action>SendTextSMS</Action>
      <URLBufferedMessageNotification>http://sms.mosterei-wurst.de/feedback.py?status=buffered&amp;vorgang=</URLBufferedMessageNotification> 
      <URLDeliveryNotification>http://sms.mosterei-wurst.de/feedback.py?status=delivered&amp;vorgang=</URLDeliveryNotification>
      <URLNonDeliveryNotification>http://sms.mosterei-wurst.de/feedback.py?status=error&amp;vorgang=</URLNonDeliveryNotification>
    </aspsms>
    """

    sent.write(CONTENT.encode('utf-8'))

    length = len(CONTENT)
    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    s.connect((HOST, PORT))
    s.send(b"POST /xmlsvr.asp HTTP/1.0\r\n")
    s.send(b"Content-Type: text/xml\r\n")
    s.send(("Content-Length: " + str(length) + "\r\n\r\n").encode('ascii'))
    s.send(CONTENT.encode('utf-8'))
    datarecv = s.recv(1024)
    sent.write(('''
    Reply Received: 
    ''' + str(datarecv)).encode('utf-8'))
    s.close()
    sent.close()
Beispiel #4
0
 def drucken(self):
     if self.datum != datetime.date.today():
         if QtWidgets.QMessageBox.No == QtWidgets.QMessageBox.warning(self, u'Datum ist nicht heute', u'Das gewählte Datum ist nicht das heutige Datum! Trotzdem drucken?', buttons=QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No, defaultButton=QtWidgets.QMessageBox.No):
             return
       
     tmp = tempfile.NamedTemporaryFile(mode='wb', delete=False)
     tmp.write(DatumEtiketten(self.anzahl, self.skip, self.datum))
     tmp.close()
     
     c = cups.Connection()
     c.printFile(c.getDefault(), tmp.name, 'Etiketten %s' % self.datum.isoformat(), config('printer_labels'))
     #subprocess.call(['/usr/bin/xdg-open', tmp.name], shell=False)
     # xdg-open beendet sich sofort!
     os.unlink(tmp.name)
     self.reset()
     self.mainwindow.reset()
Beispiel #5
0
 def rechnung(self):
     c = cups.Connection()
     c.printFile(c.getDefault(), self.aktueller_beleg, os.path.basename(self.aktueller_beleg), config('printer_plain'))