Пример #1
0
class factuurOverigeList(Container):
    def __init__(self, width, height, facturen, manager):
        super(factuurOverigeList, self).__init__(width, height)
        self.manager = manager
        self.header = Label(width, 1, "Leveranciers en overige", curses.A_REVERSE)
        self.factuurOverigeListbox = Listbox(width, height-2)
        self.groups = {}
        self.ordering = []
        for factuur in reversed(facturen):
            if factuur["leverancier"] not in self.groups.keys():
                self.groups[factuur["leverancier"]] = []
                self.ordering.append(factuur["leverancier"])
            self.groups[factuur["leverancier"]].append(factuur)
        for key in self.ordering:
            self.factuurOverigeListbox.append(factuurOverigeListItem(width, str(key), self.groups[key][::-1], manager))

        self.factuurOverigeListboxIndex = self.addChild(0,2, self.factuurOverigeListbox)
        self.headerIndex = self.addChild(0,0, self.header)

    def keyEvent(self, key):
        if key == curses.KEY_BACKSPACE:
            self.manager.pop()
        else:
            super(factuurOverigeList,self).keyEvent(key)

    def resize(self, width, height):
        self.width = width
        self.height = height
        self.header.resize(width, 1)
        self.factuurOverigeListbox.resize(width, height-2)
Пример #2
0
class factuurList(Container):
    def __init__(self, width, height, facturen, manager):
        super(factuurList, self).__init__(width, height)
        if 'vereniging_id' in facturen[0]:
            self.name = getVerenigingNaam(facturen[0]['vereniging_id']).encode('utf-8')
        else:
            self.name = "Leveranciers en overige"
        self.manager = manager
        self.header = Label(width, 1, self.name, curses.A_REVERSE)
        self.factuurListbox = Listbox(width, height-2)
        for factuur in reversed(facturen):
            self.factuurListbox.append(factuurListItem(width, factuur, manager))

        self.factuurListboxIndex = self.addChild(0,2, self.factuurListbox)
        self.headerIndex = self.addChild(0,0, self.header)

    def keyEvent(self, key):
        if key == curses.KEY_BACKSPACE:
            self.manager.pop()
        else:
            super(factuurList,self).keyEvent(key)

    def resize(self, width, height):
        self.width = width
        self.height = height
        self.header.resize(width, 1)
        self.factuurListbox.resize(width, height-2)
Пример #3
0
 def __init__(self, width, height, vereniging_list, manager):
     super(verenigingList, self).__init__(width, height)
     self.manager = manager
     self.header = Label(width, 1, "Madmin ReTeX", curses.A_REVERSE)
     self.listbox = Listbox(width, height - 2)
     for vereniging_info in vereniging_list:
         self.listbox.append(
             verenigingListItem(width, vereniging_info, manager))
     self.headerId = self.addChild(0, 0, self.header)
     self.listboxId = self.addChild(0, 2, self.listbox)
Пример #4
0
    def __init__(self, width, height, facturen, manager):
        super(factuurList, self).__init__(width, height)
        if 'vereniging_id' in facturen[0]:
            self.name = getVerenigingNaam(facturen[0]['vereniging_id']).encode('utf-8')
        else:
            self.name = "Leveranciers en overige"
        self.manager = manager
        self.header = Label(width, 1, self.name, curses.A_REVERSE)
        self.factuurListbox = Listbox(width, height-2)
        for factuur in reversed(facturen):
            self.factuurListbox.append(factuurListItem(width, factuur, manager))

        self.factuurListboxIndex = self.addChild(0,2, self.factuurListbox)
        self.headerIndex = self.addChild(0,0, self.header)
Пример #5
0
    def __init__(self, width, height):
        super(FactuurInput, self).__init__(width, height)

        self.factuurData = FactuurData(1, 1)
        self.factuurListHeader = FactuurInputHeader(1, 1)
        self.factuurRegelList = FactuurRegelList(1, 1)
        self.statusLine = Label(1, 1, "")
        self.submitButton = Button(1, 1, self.sendFactuur, "Submit")

        self.factuurListHeaderIdx = self.addChild(0, 0, self.factuurListHeader)
        self.statusLineIdx = self.addChild(0, 0, self.statusLine)
        self.submitButtonIdx = self.addChild(0, 0, self.submitButton)
        self.factuurDataIdx = self.addChild(0, 0, self.factuurData)
        self.factuurRegelListIdx = self.addChild(0, 0, self.factuurRegelList)

        self.resize(width, height)
Пример #6
0
    def __init__(self, width, height, facturen, manager):
        super(factuurOverigeList, self).__init__(width, height)
        self.manager = manager
        self.header = Label(width, 1, "Leveranciers en overige", curses.A_REVERSE)
        self.factuurOverigeListbox = Listbox(width, height-2)
        self.groups = {}
        self.ordering = []
        for factuur in reversed(facturen):
            if factuur["leverancier"] not in self.groups.keys():
                self.groups[factuur["leverancier"]] = []
                self.ordering.append(factuur["leverancier"])
            self.groups[factuur["leverancier"]].append(factuur)
        for key in self.ordering:
            self.factuurOverigeListbox.append(factuurOverigeListItem(width, str(key), self.groups[key][::-1], manager))

        self.factuurOverigeListboxIndex = self.addChild(0,2, self.factuurOverigeListbox)
        self.headerIndex = self.addChild(0,0, self.header)
Пример #7
0
class verenigingList(Container):
    def __init__(self, width, height, vereniging_list, manager):
        super(verenigingList, self).__init__(width, height)
        self.manager = manager
        self.header = Label(width, 1, "Madmin Factuurinfo", curses.A_REVERSE)
        self.listbox = Listbox(width, height - 2)
        for vereniging_info in vereniging_list:
            self.listbox.append(verenigingListItem(width,vereniging_info,manager))
        self.listbox.append(leverancierListItem(width,manager))
        self.headerId = self.addChild(0,0, self.header)
        self.listboxId = self.addChild(0,2,self.listbox)

    def resize(self, width, height):
        self.width = width
        self.height = height
        self.header.resize(width, 1)
        self.listbox.resize(width, height-2)
Пример #8
0
    def __init__(self, width, height):
        super(FactuurData,self).__init__(width, height)

        # Layout settings
        self.labelWidth = 23
        self.minValueWidth = 20

        self.otherPartyLabel = Label(0,1,"Vereniging/Leverancier")
        self.otherPartyValue = VerenigingLine(1)

        self.leverDatumLabel = Label(0,1,"Leverdatum")
        self.leverDatumValue = Textline(0)

        self.separatorFill = Fill(0,0,'|')

        self.verantwoordelijkeLabel = Label(0,1,"Verantwoordelijke")
        self.verantwoordelijkeValue = Textline(0)

        self.specialBudgetLabel = Label(0,1,"Speciaal budget")
        self.specialBudgetValue = BudgetLine(1)

        self.typeValue = Optionbox(1,1)
        self.typeValue.addOption('inkoop')
        self.typeValue.addOption('verkoop')

        self.btwValue = Optionbox(1,1)
        self.btwValue.addOption('zonderbtw')
        self.btwValue.addOption('metbtw')

        self.typeValueIdx = self.addChild(0,0,self.typeValue)
        self.btwValueIdx = self.addChild(0,0, self.btwValue)
        self.otherPartyLabelIdx = self.addChild(0,0,self.otherPartyLabel)
        self.otherPartyValueIdx = self.addChild(0,0,self.otherPartyValue)
        self.leverDatumLabelIdx = self.addChild(0,0,self.leverDatumLabel)
        self.leverDatumValueIdx = self.addChild(0,0,self.leverDatumValue)
        self.separatorFillIdx = self.addChild(0,0,self.separatorFill)
        self.verantwoordelijkeLabelIdx = self.addChild(0,0,self.verantwoordelijkeLabel)
        self.verantwoordelijkeValueIdx = self.addChild(0,0,self.verantwoordelijkeValue)
        self.specialBudgetLabelIdx = self.addChild(0,0,self.specialBudgetLabel)
        self.specialBudgetValueIdx = self.addChild(0,0,self.specialBudgetValue)

        self.resize(width, 0)
Пример #9
0
    def __init__(self, width, height):
        super(FactuurInputHeader, self).__init__(width, height)

        self.totalWeight = 0
        self.fieldLabel = []
        self.fieldLabelIdx = []
        for i in range(0, len(_regelLayout)):
            self.totalWeight += _regelLayout[i][1]
            self.fieldLabel.append(Label(0,0,_regelLayout[i][0], curses.A_BOLD))
            self.fieldLabelIdx.append(self.addChild(0,0,self.fieldLabel[-1]))

        self.resize(width, height)
Пример #10
0
    def __init__(self, width, height):
        super(FactuurData, self).__init__(width, height)

        # Layout settings
        self.labelWidth = 23
        self.minValueWidth = 20

        self.otherPartyLabel = Label(0, 1, "Vereniging/Leverancier")
        self.otherPartyValue = VerenigingLine(1)

        self.leverDatumLabel = Label(0, 1, "Leverdatum")
        self.leverDatumValue = Textline(0)

        self.separatorFill = Fill(0, 0, '|')

        self.verantwoordelijkeLabel = Label(0, 1, "Verantwoordelijke")
        self.verantwoordelijkeValue = Textline(0)

        self.specialBudgetLabel = Label(0, 1, "Speciaal budget")
        self.specialBudgetValue = BudgetLine(1)

        self.typeValue = Optionbox(1, 1)
        self.typeValue.addOption('inkoop')
        self.typeValue.addOption('verkoop')

        self.btwValue = Optionbox(1, 1)
        self.btwValue.addOption('metbtw')
        self.btwValue.addOption('zonderbtw')

        self.typeValueIdx = self.addChild(0, 0, self.typeValue)
        self.btwValueIdx = self.addChild(0, 0, self.btwValue)
        self.otherPartyLabelIdx = self.addChild(0, 0, self.otherPartyLabel)
        self.otherPartyValueIdx = self.addChild(0, 0, self.otherPartyValue)
        self.leverDatumLabelIdx = self.addChild(0, 0, self.leverDatumLabel)
        self.leverDatumValueIdx = self.addChild(0, 0, self.leverDatumValue)
        self.separatorFillIdx = self.addChild(0, 0, self.separatorFill)
        self.verantwoordelijkeLabelIdx = self.addChild(
            0, 0, self.verantwoordelijkeLabel)
        self.verantwoordelijkeValueIdx = self.addChild(
            0, 0, self.verantwoordelijkeValue)
        self.specialBudgetLabelIdx = self.addChild(0, 0,
                                                   self.specialBudgetLabel)
        self.specialBudgetValueIdx = self.addChild(0, 0,
                                                   self.specialBudgetValue)

        self.resize(width, 0)
Пример #11
0
    def __init__(self, width, height, factuurregel):
        super(factuurRegel, self).__init__(width, height)
        self.factuurRegel = factuurregel

        self.totalWeight = 0
        self.fieldLabel = []
        self.fieldLabelIdx = []
        for i in range(0, len(_regelLayout)):
            self.totalWeight += _regelLayout[i][2]
            self.fieldLabel.append(
                Label(0, 0,
                      _regelLayout[i][3](factuurregel[_regelLayout[i][1]])))
            self.fieldLabelIdx.append(self.addChild(0, 0, self.fieldLabel[-1]))

        self.resize(width, height)
Пример #12
0
    def __init__(self, width, height):
        super(FactuurInput, self).__init__(width, height)

        self.factuurData = FactuurData(1,1)
        self.factuurListHeader = FactuurInputHeader(1,1)
        self.factuurRegelList = FactuurRegelList(1,1)
        self.statusLine = Label(1,1,"")
        self.submitButton = Button(1,1,self.sendFactuur,"Submit")

        self.factuurListHeaderIdx = self.addChild(0,0, self.factuurListHeader)
        self.statusLineIdx = self.addChild(0,0,self.statusLine)
        self.submitButtonIdx = self.addChild(0,0,self.submitButton)
        self.factuurDataIdx = self.addChild(0,0, self.factuurData)
        self.factuurRegelListIdx = self.addChild(0,0,self.factuurRegelList)

        self.resize(width, height)
Пример #13
0
    def __init__(self, width, height, factuur, manager):
        super(FactuurBewerk, self).__init__(width, height)

        self.factuurInfoBox = FactuurInfoBox(1,1, factuur)
        self.factuurListHeader = FactuurInputHeader(1,1)
        self.factuurRegelList = FactuurRegelList(1,1)
        self.statusLine = Label(1,1,"")
        self.submitButton = Button(1,1,self.sendEdit,"Submit")

        self.factuurListHeaderIdx = self.addChild(0,0, self.factuurListHeader)
        self.statusLineIdx = self.addChild(0,0,self.statusLine)
        self.submitButtonIdx = self.addChild(0,0,self.submitButton)
        self.factuurInfoBoxIdx = self.addChild(0,0, self.factuurInfoBox)
        self.factuurRegelListIdx = self.addChild(0,0,self.factuurRegelList)

        self.factuur = factuur
        self.manager = manager

        self.resize(width, height)
Пример #14
0
    def __init__(self, width, height, factuur):
        super(factuurInfobox, self).__init__(width, height)

        #Associated data object
        self.factuur = factuur

        #Layout settings
        self.labelWidth = 19
        self.minValueWidth = 20

        if 'vereniging_id' in factuur:
            self.otherPartyLabel = Label(0, 1, "Vereniging:")
            self.otherPartyValue = Label(
                0, 1,
                getVerenigingNaam(factuur['vereniging_id']).encode('utf-8'))
        else:
            self.otherPartyLabel = Label(0, 1, "Leverancier:")
            self.otherPartyValue = Label(
                0, 1, factuur['leverancier'].encode('utf-8'))
        self.volgnummerLabel = Label(0, 1, "Volgnummer:")
        self.volgnummerValue = Label(0, 1, str(factuur['volgnummer']))

        self.factuurDatumLabel = Label(0, 1, "Factuurdatum:")
        self.factuurDatumValue = Label(0, 1,
                                       factuur['factuurdatum'].encode('utf-8'))
        self.leverDatumLabel = Label(0, 1, "Leverdatum:")
        self.leverDatumValue = Label(0, 1,
                                     factuur['leverdatum'].encode('utf-8'))

        self.separatorFill = Fill(0, 0, '|')
        self.separatorFillIdx = self.addChild(0, 0, self.separatorFill)

        self.hasVerantwoordelijke = False
        if 'verantwoordelijke' in factuur:
            self.hasVerantwoordelijke = True
            self.verantwoordelijkeLabel = Label(0, 1, "Verantwoordelijke:")
            self.verantwoordelijkeValue = Label(
                0, 1, factuur['verantwoordelijke'].encode('utf-8'))

        self.otherPartyLabelIdx = self.addChild(0, 0, self.otherPartyLabel)
        self.otherPartyValueIdx = self.addChild(0, 0, self.otherPartyValue)
        self.volgnummerLabelIdx = self.addChild(0, 0, self.volgnummerLabel)
        self.volgnummerValueIdx = self.addChild(0, 0, self.volgnummerValue)
        self.factuurDatumLabelIdx = self.addChild(0, 0, self.factuurDatumLabel)
        self.factuurDatumValueIdx = self.addChild(0, 0, self.factuurDatumValue)
        self.leverDatumLabelIdx = self.addChild(0, 0, self.leverDatumLabel)
        self.leverDatumValueIdx = self.addChild(0, 0, self.leverDatumValue)
        if self.hasVerantwoordelijke:
            self.verantwoordelijkeLabelIdx = self.addChild(
                0, 0, self.verantwoordelijkeLabel)
            self.verantwoordelijkeValueIdx = self.addChild(
                0, 0, self.verantwoordelijkeValue)

        self.resize(width, 0)
Пример #15
0
class factuurInfobox(Container):
    def __init__(self, width, height, factuur):
        super(factuurInfobox, self).__init__(width, height)

        #Associated data object
        self.factuur = factuur

        #Layout settings
        self.labelWidth = 19
        self.minValueWidth = 20

        if 'vereniging_id' in factuur:
            self.otherPartyLabel = Label(0, 1, "Vereniging:")
            self.otherPartyValue = Label(
                0, 1,
                getVerenigingNaam(factuur['vereniging_id']).encode('utf-8'))
        else:
            self.otherPartyLabel = Label(0, 1, "Leverancier:")
            self.otherPartyValue = Label(
                0, 1, factuur['leverancier'].encode('utf-8'))
        self.volgnummerLabel = Label(0, 1, "Volgnummer:")
        self.volgnummerValue = Label(0, 1, str(factuur['volgnummer']))

        self.factuurDatumLabel = Label(0, 1, "Factuurdatum:")
        self.factuurDatumValue = Label(0, 1,
                                       factuur['factuurdatum'].encode('utf-8'))
        self.leverDatumLabel = Label(0, 1, "Leverdatum:")
        self.leverDatumValue = Label(0, 1,
                                     factuur['leverdatum'].encode('utf-8'))

        self.separatorFill = Fill(0, 0, '|')
        self.separatorFillIdx = self.addChild(0, 0, self.separatorFill)

        self.hasVerantwoordelijke = False
        if 'verantwoordelijke' in factuur:
            self.hasVerantwoordelijke = True
            self.verantwoordelijkeLabel = Label(0, 1, "Verantwoordelijke:")
            self.verantwoordelijkeValue = Label(
                0, 1, factuur['verantwoordelijke'].encode('utf-8'))

        self.otherPartyLabelIdx = self.addChild(0, 0, self.otherPartyLabel)
        self.otherPartyValueIdx = self.addChild(0, 0, self.otherPartyValue)
        self.volgnummerLabelIdx = self.addChild(0, 0, self.volgnummerLabel)
        self.volgnummerValueIdx = self.addChild(0, 0, self.volgnummerValue)
        self.factuurDatumLabelIdx = self.addChild(0, 0, self.factuurDatumLabel)
        self.factuurDatumValueIdx = self.addChild(0, 0, self.factuurDatumValue)
        self.leverDatumLabelIdx = self.addChild(0, 0, self.leverDatumLabel)
        self.leverDatumValueIdx = self.addChild(0, 0, self.leverDatumValue)
        if self.hasVerantwoordelijke:
            self.verantwoordelijkeLabelIdx = self.addChild(
                0, 0, self.verantwoordelijkeLabel)
            self.verantwoordelijkeValueIdx = self.addChild(
                0, 0, self.verantwoordelijkeValue)

        self.resize(width, 0)

    def resize(self, width, height):
        #ignore height, we determine that ourselves
        self.width = width

        if (self.width - 1) / 2 - self.labelWidth >= self.minValueWidth:
            #two column layout
            colWidth = (self.width - 1) / 2
            colOffset = colWidth + 1
            valueWidth = max(0, colWidth - self.labelWidth)

            self.separatorFill.resize(1, 2)
            self.setChildPos(self.separatorFillIdx, colWidth, 0)

            self.otherPartyLabel.resize(self.labelWidth, 1)
            self.setChildPos(self.otherPartyLabelIdx, 0, 0)
            self.otherPartyValue.resize(valueWidth, 1)
            self.setChildPos(self.otherPartyValueIdx, self.labelWidth, 0)

            self.volgnummerLabel.resize(self.labelWidth, 1)
            self.setChildPos(self.volgnummerLabelIdx, 0, 1)
            self.volgnummerValue.resize(valueWidth, 1)
            self.setChildPos(self.volgnummerValueIdx, self.labelWidth, 1)

            self.factuurDatumLabel.resize(self.labelWidth, 1)
            self.setChildPos(self.factuurDatumLabelIdx, colOffset, 0)
            self.factuurDatumValue.resize(valueWidth, 1)
            self.setChildPos(self.factuurDatumValueIdx,
                             colOffset + self.labelWidth, 0)

            self.leverDatumLabel.resize(self.labelWidth, 1)
            self.setChildPos(self.leverDatumLabelIdx, colOffset, 1)
            self.leverDatumValue.resize(self.labelWidth, 1)
            self.setChildPos(self.leverDatumValueIdx,
                             colOffset + self.labelWidth, 1)

            if self.hasVerantwoordelijke:
                self.height = 3
                self.verantwoordelijkeLabel.resize(self.labelWidth, 1)
                self.setChildPos(self.verantwoordelijkeLabelIdx, 0, 2)
                self.verantwoordelijkeValue.resize(width - self.labelWidth, 1)
                self.setChildPos(self.verantwoordelijkeValueIdx,
                                 self.labelWidth, 2)
            else:
                self.height = 2
        else:
            #one column layout
            valueWidth = max(0, width - self.labelWidth)

            self.separatorFill.resize(0, 0)
            self.setChildPos(self.separatorFillIdx, 0, 0)

            self.otherPartyLabel.resize(self.labelWidth, 1)
            self.setChildPos(self.otherPartyLabelIdx, 0, 0)
            self.otherPartyValue.resize(valueWidth, 1)
            self.setChildPos(self.otherPartyValueIdx, self.labelWidth, 0)

            self.volgnummerLabel.resize(self.labelWidth, 1)
            self.setChildPos(self.volgnummerLabelIdx, 0, 1)
            self.volgnummerValue.resize(valueWidth, 1)
            self.setChildPos(self.volgnummerValueIdx, self.labelWidth, 1)

            self.factuurDatumLabel.resize(self.labelWidth, 1)
            self.setChildPos(self.factuurDatumLabelIdx, 0, 2)
            self.factuurDatumValue.resize(valueWidth, 1)
            self.setChildPos(self.factuurDatumValueIdx, self.labelWidth, 2)

            self.leverDatumLabel.resize(self.labelWidth, 1)
            self.setChildPos(self.leverDatumLabelIdx, 0, 3)
            self.leverDatumValue.resize(valueWidth, 1)
            self.setChildPos(self.leverDatumValueIdx, self.labelWidth, 3)

            if self.hasVerantwoordelijke:
                self.height = 5
                self.verantwoordelijkeLabel.resize(self.labelWidth, 1)
                self.setChildPos(self.verantwoordelijkeLabelIdx, 0, 4)
                self.verantwoordelijkeValue.resize(valueWidth, 1)
                self.setChildPos(self.verantwoordelijkeValueIdx,
                                 self.labelWidth, 4)
            else:
                self.height = 4
Пример #16
0
    def __init__(self, width, height, factuur, manager):
        super(factuurDetail, self).__init__(width, height)

        #Associated data object
        self.factuur = factuur
        self.manager = manager

        self.infobox = factuurInfobox(width, 0, factuur)
        self.infoboxIdx = self.addChild(0, 0, self.infobox)

        self.factuurRegelHeader = factuurRegelHeader(width, 1)
        self.factuurRegelHeaderIdx = self.addChild(0, 0,
                                                   self.factuurRegelHeader)

        self.factuurRegelBox = Listbox(width, 0)
        self.factuurRegelBoxIdx = self.addChild(0, 0, self.factuurRegelBox)

        self.factuurBorrelTotaal = 0
        self.factuurKantineTotaal = 0
        self.factuurEmballageTotaal = 0
        self.factuurOverigeTotaal = 0
        self.factuurBorrelTotaalOnafgerond = 0
        self.factuurKantineTotaalOnafgerond = 0
        self.factuurEmballageTotaalOnafgerond = 0
        self.factuurOverigeTotaalOnafgerond = 0

        for regel in factuur['regels']:
            self.factuurRegelBox.append(factuurRegel(width, 1, regel))
            if 'prd_id' in regel:
                type = getProductType(regel['prd_id'])
                if type == 'kantine':
                    self.factuurKantineTotaal += copysign(
                        regel['totaalprijs'], regel['aantal'])
                    self.factuurKantineTotaalOnafgerond += regel[
                        'stukprijs'] * regel['aantal']
                elif type == 'borrel':
                    self.factuurBorrelTotaal += copysign(
                        regel['totaalprijs'], regel['aantal'])
                    self.factuurBorrelTotaalOnafgerond += regel[
                        'stukprijs'] * regel['aantal']
                elif type == 'emballage':
                    self.factuurEmballageTotaal += copysign(
                        regel['totaalprijs'], regel['aantal'])
                    self.factuurEmballageTotaalOnafgerond += regel[
                        'stukprijs'] * regel['aantal']
                else:
                    self.factuurOverigeTotaal += copysign(
                        regel['totaalprijs'], regel['aantal'])
                    self.factuurOverigeTotaalOnafgerond += regel[
                        'stukprijs'] * regel['aantal']
            else:
                self.factuurOverigeTotaal += copysign(regel['totaalprijs'],
                                                      regel['aantal'])
                self.factuurOverigeTotaalOnafgerond += regel[
                    'stukprijs'] * regel['aantal']

        self.factuurBorrelTotaalLabel = Label(
            0, 0,
            "Borreltotaal: " + moneyConvert(int(self.factuurBorrelTotaal)))
        self.factuurBorrelTotaalLabelIdx = self.addChild(
            0, 0, self.factuurBorrelTotaalLabel)
        self.factuurBorrelmargeTotaalLabel = Label(
            0, 0, "Borrelmargetotaal: " +
            moneyConvert(int(floor(self.factuurBorrelTotaal / 1.03))))
        self.factuurBorrelmargeTotaalLabelIdx = self.addChild(
            0, 0, self.factuurBorrelmargeTotaalLabel)
        self.factuurKantineTotaalLabel = Label(
            0, 0,
            "Kantinetotaal: " + moneyConvert(int(self.factuurKantineTotaal)))
        self.factuurKantineTotaalLabelIdx = self.addChild(
            0, 0, self.factuurKantineTotaalLabel)
        self.factuurEmballageTotaalLabel = Label(
            0, 0, "Emballagetotaal: " +
            moneyConvert(int(self.factuurEmballageTotaal)))
        self.factuurEmballageTotaalLabelIdx = self.addChild(
            0, 0, self.factuurEmballageTotaalLabel)
        self.factuurOverigeTotaalLabel = Label(
            0, 0,
            "Overigetotaal: " + moneyConvert(int(self.factuurOverigeTotaal)))
        self.factuurOverigeTotaalLabelIdx = self.addChild(
            0, 0, self.factuurOverigeTotaalLabel)
        self.factuurTotaalLabel = Label(
            0, 0, "Totaal: " + moneyConvert(
                int(self.factuurBorrelTotaal + self.factuurKantineTotaal +
                    self.factuurEmballageTotaal + self.factuurOverigeTotaal)))
        self.factuurTotaalLabelIdx = self.addChild(0, 0,
                                                   self.factuurTotaalLabel)

        # added details:

        self.factuurBorrelTotaalOnafgerondLabel = Label(
            0, 0, "Borreltotaal-onafgerond: " +
            moneyConvert(int(self.factuurBorrelTotaalOnafgerond)))
        self.factuurBorrelTotaalOnafgerondLabelIdx = self.addChild(
            0, 0, self.factuurBorrelTotaalOnafgerondLabel)
        self.factuurKantineTotaalOnafgerondLabel = Label(
            0, 0, "Kantinetotaal-onafgerond: " +
            moneyConvert(int(self.factuurKantineTotaalOnafgerond)))
        self.factuurKantineTotaalOnafgerondLabelIdx = self.addChild(
            0, 0, self.factuurKantineTotaalOnafgerondLabel)
        self.factuurEmballageTotaalOnafgerondLabel = Label(
            0, 0, "Emballagetotaal-onafgerond: " +
            moneyConvert(int(self.factuurEmballageTotaalOnafgerond)))
        self.factuurEmballageTotaalOnafgerondLabelIdx = self.addChild(
            0, 0, self.factuurEmballageTotaalOnafgerondLabel)
        self.factuurOverigeTotaalOnafgerondLabel = Label(
            0, 0, "Overigetotaal-onafgerond: " +
            moneyConvert(int(self.factuurOverigeTotaalOnafgerond)))
        self.factuurOverigeTotaalOnafgerondLabelIdx = self.addChild(
            0, 0, self.factuurOverigeTotaalOnafgerondLabel)
        self.factuurTotaalOnafgerondLabel = Label(
            0, 0, "Totaal-onafgerond: " + moneyConvert(
                int(self.factuurBorrelTotaalOnafgerond +
                    self.factuurKantineTotaalOnafgerond +
                    self.factuurEmballageTotaalOnafgerond +
                    self.factuurOverigeTotaalOnafgerond)))
        self.factuurTotaalOnafgerondLabelIdx = self.addChild(
            0, 0, self.factuurTotaalOnafgerondLabel)

        self.factuurAfrondingLabel = Label(
            0, 0, "Afronding: " + moneyConvert(
                int(self.factuurBorrelTotaalOnafgerond -
                    self.factuurBorrelTotaal +
                    self.factuurKantineTotaalOnafgerond -
                    self.factuurKantineTotaal +
                    self.factuurEmballageTotaalOnafgerond -
                    self.factuurEmballageTotaal +
                    self.factuurOverigeTotaalOnafgerond -
                    self.factuurOverigeTotaal)))
        self.factuurAfrondingLabelIdx = self.addChild(
            0, 0, self.factuurAfrondingLabel)

        self.resize(width, height)
Пример #17
0
class factuurDetail(Container):
    def __init__(self, width, height, factuur, manager):
        super(factuurDetail, self).__init__(width, height)

        #Associated data object
        self.factuur = factuur
        self.manager = manager

        self.infobox = factuurInfobox(width, 0, factuur)
        self.infoboxIdx = self.addChild(0, 0, self.infobox)

        self.factuurRegelHeader = factuurRegelHeader(width, 1)
        self.factuurRegelHeaderIdx = self.addChild(0, 0,
                                                   self.factuurRegelHeader)

        self.factuurRegelBox = Listbox(width, 0)
        self.factuurRegelBoxIdx = self.addChild(0, 0, self.factuurRegelBox)

        self.factuurBorrelTotaal = 0
        self.factuurKantineTotaal = 0
        self.factuurEmballageTotaal = 0
        self.factuurOverigeTotaal = 0
        self.factuurBorrelTotaalOnafgerond = 0
        self.factuurKantineTotaalOnafgerond = 0
        self.factuurEmballageTotaalOnafgerond = 0
        self.factuurOverigeTotaalOnafgerond = 0

        for regel in factuur['regels']:
            self.factuurRegelBox.append(factuurRegel(width, 1, regel))
            if 'prd_id' in regel:
                type = getProductType(regel['prd_id'])
                if type == 'kantine':
                    self.factuurKantineTotaal += copysign(
                        regel['totaalprijs'], regel['aantal'])
                    self.factuurKantineTotaalOnafgerond += regel[
                        'stukprijs'] * regel['aantal']
                elif type == 'borrel':
                    self.factuurBorrelTotaal += copysign(
                        regel['totaalprijs'], regel['aantal'])
                    self.factuurBorrelTotaalOnafgerond += regel[
                        'stukprijs'] * regel['aantal']
                elif type == 'emballage':
                    self.factuurEmballageTotaal += copysign(
                        regel['totaalprijs'], regel['aantal'])
                    self.factuurEmballageTotaalOnafgerond += regel[
                        'stukprijs'] * regel['aantal']
                else:
                    self.factuurOverigeTotaal += copysign(
                        regel['totaalprijs'], regel['aantal'])
                    self.factuurOverigeTotaalOnafgerond += regel[
                        'stukprijs'] * regel['aantal']
            else:
                self.factuurOverigeTotaal += copysign(regel['totaalprijs'],
                                                      regel['aantal'])
                self.factuurOverigeTotaalOnafgerond += regel[
                    'stukprijs'] * regel['aantal']

        self.factuurBorrelTotaalLabel = Label(
            0, 0,
            "Borreltotaal: " + moneyConvert(int(self.factuurBorrelTotaal)))
        self.factuurBorrelTotaalLabelIdx = self.addChild(
            0, 0, self.factuurBorrelTotaalLabel)
        self.factuurBorrelmargeTotaalLabel = Label(
            0, 0, "Borrelmargetotaal: " +
            moneyConvert(int(floor(self.factuurBorrelTotaal / 1.03))))
        self.factuurBorrelmargeTotaalLabelIdx = self.addChild(
            0, 0, self.factuurBorrelmargeTotaalLabel)
        self.factuurKantineTotaalLabel = Label(
            0, 0,
            "Kantinetotaal: " + moneyConvert(int(self.factuurKantineTotaal)))
        self.factuurKantineTotaalLabelIdx = self.addChild(
            0, 0, self.factuurKantineTotaalLabel)
        self.factuurEmballageTotaalLabel = Label(
            0, 0, "Emballagetotaal: " +
            moneyConvert(int(self.factuurEmballageTotaal)))
        self.factuurEmballageTotaalLabelIdx = self.addChild(
            0, 0, self.factuurEmballageTotaalLabel)
        self.factuurOverigeTotaalLabel = Label(
            0, 0,
            "Overigetotaal: " + moneyConvert(int(self.factuurOverigeTotaal)))
        self.factuurOverigeTotaalLabelIdx = self.addChild(
            0, 0, self.factuurOverigeTotaalLabel)
        self.factuurTotaalLabel = Label(
            0, 0, "Totaal: " + moneyConvert(
                int(self.factuurBorrelTotaal + self.factuurKantineTotaal +
                    self.factuurEmballageTotaal + self.factuurOverigeTotaal)))
        self.factuurTotaalLabelIdx = self.addChild(0, 0,
                                                   self.factuurTotaalLabel)

        # added details:

        self.factuurBorrelTotaalOnafgerondLabel = Label(
            0, 0, "Borreltotaal-onafgerond: " +
            moneyConvert(int(self.factuurBorrelTotaalOnafgerond)))
        self.factuurBorrelTotaalOnafgerondLabelIdx = self.addChild(
            0, 0, self.factuurBorrelTotaalOnafgerondLabel)
        self.factuurKantineTotaalOnafgerondLabel = Label(
            0, 0, "Kantinetotaal-onafgerond: " +
            moneyConvert(int(self.factuurKantineTotaalOnafgerond)))
        self.factuurKantineTotaalOnafgerondLabelIdx = self.addChild(
            0, 0, self.factuurKantineTotaalOnafgerondLabel)
        self.factuurEmballageTotaalOnafgerondLabel = Label(
            0, 0, "Emballagetotaal-onafgerond: " +
            moneyConvert(int(self.factuurEmballageTotaalOnafgerond)))
        self.factuurEmballageTotaalOnafgerondLabelIdx = self.addChild(
            0, 0, self.factuurEmballageTotaalOnafgerondLabel)
        self.factuurOverigeTotaalOnafgerondLabel = Label(
            0, 0, "Overigetotaal-onafgerond: " +
            moneyConvert(int(self.factuurOverigeTotaalOnafgerond)))
        self.factuurOverigeTotaalOnafgerondLabelIdx = self.addChild(
            0, 0, self.factuurOverigeTotaalOnafgerondLabel)
        self.factuurTotaalOnafgerondLabel = Label(
            0, 0, "Totaal-onafgerond: " + moneyConvert(
                int(self.factuurBorrelTotaalOnafgerond +
                    self.factuurKantineTotaalOnafgerond +
                    self.factuurEmballageTotaalOnafgerond +
                    self.factuurOverigeTotaalOnafgerond)))
        self.factuurTotaalOnafgerondLabelIdx = self.addChild(
            0, 0, self.factuurTotaalOnafgerondLabel)

        self.factuurAfrondingLabel = Label(
            0, 0, "Afronding: " + moneyConvert(
                int(self.factuurBorrelTotaalOnafgerond -
                    self.factuurBorrelTotaal +
                    self.factuurKantineTotaalOnafgerond -
                    self.factuurKantineTotaal +
                    self.factuurEmballageTotaalOnafgerond -
                    self.factuurEmballageTotaal +
                    self.factuurOverigeTotaalOnafgerond -
                    self.factuurOverigeTotaal)))
        self.factuurAfrondingLabelIdx = self.addChild(
            0, 0, self.factuurAfrondingLabel)

        self.resize(width, height)

    def keyEvent(self, key):
        if key == curses.KEY_BACKSPACE:
            self.manager.pop()
        elif key == ord('c'):
            print "test"
        else:
            super(factuurDetail, self).keyEvent(key)

    def resize(self, width, height):
        self.width = width
        self.height = height
        swidth = int(width / 3.)
        hwidth = 2 * int(width / 3.)
        voffset = 0
        self.infobox.resize(width, 0)
        self.setChildPos(self.infoboxIdx, 0, voffset)
        voffset += self.infobox.size()[1]
        self.factuurRegelHeader.resize(width, 1)
        self.setChildPos(self.factuurRegelHeaderIdx, 0, voffset)
        voffset += 1
        self.factuurRegelBox.resize(width, height - voffset - 4)
        self.setChildPos(self.factuurRegelBoxIdx, 0, voffset)

        # left colomn
        self.factuurBorrelTotaalLabel.resize(swidth, 1)
        self.setChildPos(self.factuurBorrelTotaalLabelIdx, 0, height - 4)
        self.factuurKantineTotaalLabel.resize(swidth, 1)
        self.setChildPos(self.factuurKantineTotaalLabelIdx, 0, height - 3)
        self.factuurEmballageTotaalLabel.resize(swidth, 1)
        self.setChildPos(self.factuurEmballageTotaalLabelIdx, 0, height - 2)
        self.factuurOverigeTotaalLabel.resize(swidth, 1)
        self.setChildPos(self.factuurOverigeTotaalLabelIdx, 0, height - 1)

        # middle column
        self.factuurBorrelTotaalOnafgerondLabel.resize(swidth, 1)
        self.setChildPos(self.factuurBorrelTotaalOnafgerondLabelIdx, swidth,
                         height - 4)
        self.factuurKantineTotaalOnafgerondLabel.resize(swidth, 1)
        self.setChildPos(self.factuurKantineTotaalOnafgerondLabelIdx, swidth,
                         height - 3)
        self.factuurEmballageTotaalOnafgerondLabel.resize(swidth, 1)
        self.setChildPos(self.factuurEmballageTotaalOnafgerondLabelIdx, swidth,
                         height - 2)
        self.factuurOverigeTotaalOnafgerondLabel.resize(swidth, 1)
        self.setChildPos(self.factuurOverigeTotaalOnafgerondLabelIdx, swidth,
                         height - 1)

        #right column

        self.factuurBorrelmargeTotaalLabel.resize(swidth, 1)
        self.setChildPos(self.factuurBorrelmargeTotaalLabelIdx, hwidth,
                         height - 4)
        self.factuurTotaalLabel.resize(swidth, 1)
        self.setChildPos(self.factuurTotaalLabelIdx, hwidth, height - 3)
        self.factuurTotaalOnafgerondLabel.resize(swidth, 1)
        self.setChildPos(self.factuurTotaalOnafgerondLabelIdx, hwidth,
                         height - 2)
        self.factuurAfrondingLabel.resize(swidth, 1)
        self.setChildPos(self.factuurAfrondingLabelIdx, hwidth, height - 1)
Пример #18
0
class FactuurBewerk(Container):
    def __init__(self, width, height, factuur, manager):
        super(FactuurBewerk, self).__init__(width, height)

        self.factuurInfoBox = FactuurInfoBox(1,1, factuur)
        self.factuurListHeader = FactuurInputHeader(1,1)
        self.factuurRegelList = FactuurRegelList(1,1)
        self.statusLine = Label(1,1,"")
        self.submitButton = Button(1,1,self.sendEdit,"Submit")

        self.factuurListHeaderIdx = self.addChild(0,0, self.factuurListHeader)
        self.statusLineIdx = self.addChild(0,0,self.statusLine)
        self.submitButtonIdx = self.addChild(0,0,self.submitButton)
        self.factuurInfoBoxIdx = self.addChild(0,0, self.factuurInfoBox)
        self.factuurRegelListIdx = self.addChild(0,0,self.factuurRegelList)

        self.factuur = factuur
        self.manager = manager

        self.resize(width, height)

    def resize(self, width, height):
        self.width = width
        self.height = height

        vOffset = 0

        self.factuurInfoBox.resize(width, 1)
        self.setChildPos(self.factuurInfoBoxIdx, 0, 0)
        vOffset += self.factuurInfoBox.size()[1]

        self.factuurListHeader.resize(width, 1)
        self.setChildPos(self.factuurListHeaderIdx, 0, vOffset)
        vOffset += 1

        self.factuurRegelList.resize(width, height - vOffset-1)
        self.setChildPos(self.factuurRegelListIdx, 0, vOffset)
        vOffset = height-1

        self.submitButton.resize(min(width, 6), 1)
        self.setChildPos(self.submitButtonIdx, 1, vOffset)
        self.statusLine.resize(width-min(width, 8), 1)
        self.setChildPos(self.statusLineIdx, min(width, 8), vOffset)


    def sendEdit(self):
        result = self.generateRegels()

        if not result[0]:
            self.statusLine.setText(result[2])
            return

        if not result[1]:
            self.statusLine.setText("Insufficient input given")
            return

        try:
            data = {}
            data["factuur_id"] = self.factuur["id"]
            data["regels"] = result[2]
            submitResult = remote_call('/factuur/bewerk', jsondata = data)
        except ServerCallException:
            self.statusLine.setText("Kon geen verbinding maken met server.")
            return

        if 'error' in submitResult:
            self.statusLine.setText(submitResult['error'].encode('utf-8'))
            return

        self.statusLine.setText("")
        unsetCursor()
        self.manager.pop()

        self.resize(self.width, self.height)

    def generateRegels(self):

        result = self.factuurRegelList.generateFactuurRegels(self.factuur['type'] == 'inkoop')

        if not result[0] or not result[1]:
            return result

        return (True, True, result[2])
Пример #19
0
    def __init__(self, width, height, factuur, manager):
        super(factuurDetail, self).__init__(width, height)

        #Associated data object
        self.factuur = factuur
        self.manager = manager

        self.infobox = factuurInfobox(width,0,factuur)
        self.infoboxIdx = self.addChild(0,0,self.infobox)

        self.factuurRegelHeader = factuurRegelHeader(width,1)
        self.factuurRegelHeaderIdx = self.addChild(0,0,self.factuurRegelHeader)

        self.factuurRegelBox = Listbox(width, 0)
        self.factuurRegelBoxIdx = self.addChild(0,0,self.factuurRegelBox)

        self.factuurBorrelTotaal = 0
        self.factuurBorrelmargeTotaal = 0
        self.factuurKantineTotaal = 0
        self.factuurEmballageTotaal = 0
        self.factuurOverigeTotaal = 0
        self.factuurBorrelTotaalOnafgerond = 0
        self.factuurKantineTotaalOnafgerond = 0
        self.factuurEmballageTotaalOnafgerond = 0
        self.factuurOverigeTotaalOnafgerond = 0

        for regel in factuur['regels']:
            self.factuurRegelBox.append(factuurRegel(width,1,regel))
            if 'prd_id' in regel:
                type = getProductType(regel['prd_id'])
                if type=='kantine':
                    self.factuurKantineTotaal += copysign(regel['totaalprijs'], regel['aantal'])
                    self.factuurKantineTotaalOnafgerond += regel['stukprijs'] * regel['aantal']
                elif type=='borrel':
                    self.factuurBorrelTotaal += copysign(regel['totaalprijs'], regel['aantal'])
                    self.factuurBorrelTotaalOnafgerond += regel['stukprijs'] * regel['aantal']
                    self.factuurBorrelmargeTotaal += floor(regel['stukprijs']/1.03) * regel['aantal']
                elif type=='emballage':
                    self.factuurEmballageTotaal += copysign(regel['totaalprijs'], regel['aantal'])
                    self.factuurEmballageTotaalOnafgerond += regel['stukprijs'] * regel['aantal']
                else:
                    self.factuurOverigeTotaal += copysign(regel['totaalprijs'], regel['aantal'])
                    self.factuurOverigeTotaalOnafgerond += regel['stukprijs'] * regel['aantal']
            else:
                self.factuurOverigeTotaal += copysign(regel['totaalprijs'], regel['aantal'])
                self.factuurOverigeTotaalOnafgerond += regel['stukprijs'] * regel['aantal']

        self.factuurBorrelTotaalLabel = Label(0,0,"Borreltotaal: " + moneyConvert(int(self.factuurBorrelTotaal)))
        self.factuurBorrelTotaalLabelIdx = self.addChild(0,0,self.factuurBorrelTotaalLabel)
        self.factuurBorrelmargeTotaalLabel = Label(0,0,"Borrelmargetotaal: " + moneyConvert(int(self.factuurBorrelmargeTotaal)))
        self.factuurBorrelmargeTotaalLabelIdx = self.addChild(0,0,self.factuurBorrelmargeTotaalLabel)
        self.factuurKantineTotaalLabel = Label(0,0,"Kantinetotaal: " + moneyConvert(int(self.factuurKantineTotaal)))
        self.factuurKantineTotaalLabelIdx = self.addChild(0,0,self.factuurKantineTotaalLabel)
        self.factuurEmballageTotaalLabel = Label(0,0,"Emballagetotaal: " + moneyConvert(int(self.factuurEmballageTotaal)))
        self.factuurEmballageTotaalLabelIdx = self.addChild(0,0,self.factuurEmballageTotaalLabel)
        self.factuurOverigeTotaalLabel = Label(0,0,"Overigetotaal: " + moneyConvert(int(self.factuurOverigeTotaal)))
        self.factuurOverigeTotaalLabelIdx = self.addChild(0,0,self.factuurOverigeTotaalLabel)
        self.factuurTotaalLabel = Label(0,0,"Totaal: " + moneyConvert(int(self.factuurBorrelTotaal+self.factuurKantineTotaal+self.factuurEmballageTotaal+self.factuurOverigeTotaal)))
        self.factuurTotaalLabelIdx = self.addChild(0,0,self.factuurTotaalLabel)

        # added details:

        self.factuurBorrelTotaalOnafgerondLabel = Label(0,0,"Borreltotaal-onafgerond: " + moneyConvert(int(self.factuurBorrelTotaalOnafgerond)))
        self.factuurBorrelTotaalOnafgerondLabelIdx = self.addChild(0,0,self.factuurBorrelTotaalOnafgerondLabel)
        self.factuurKantineTotaalOnafgerondLabel = Label(0,0,"Kantinetotaal-onafgerond: " + moneyConvert(int(self.factuurKantineTotaalOnafgerond)))
        self.factuurKantineTotaalOnafgerondLabelIdx = self.addChild(0,0,self.factuurKantineTotaalOnafgerondLabel)
        self.factuurEmballageTotaalOnafgerondLabel = Label(0,0,"Emballagetotaal-onafgerond: " + moneyConvert(int(self.factuurEmballageTotaalOnafgerond)))
        self.factuurEmballageTotaalOnafgerondLabelIdx = self.addChild(0,0,self.factuurEmballageTotaalOnafgerondLabel)
        self.factuurOverigeTotaalOnafgerondLabel = Label(0,0,"Overigetotaal-onafgerond: " + moneyConvert(int(self.factuurOverigeTotaalOnafgerond)))
        self.factuurOverigeTotaalOnafgerondLabelIdx = self.addChild(0,0,self.factuurOverigeTotaalOnafgerondLabel)
        self.factuurTotaalOnafgerondLabel = Label(0,0,"Totaal-onafgerond: " + moneyConvert(int(self.factuurBorrelTotaalOnafgerond+self.factuurKantineTotaalOnafgerond+self.factuurEmballageTotaalOnafgerond+self.factuurOverigeTotaalOnafgerond)))
        self.factuurTotaalOnafgerondLabelIdx = self.addChild(0,0,self.factuurTotaalOnafgerondLabel)

        self.factuurAfrondingLabel = Label(0,0,"Afronding: " + moneyConvert(int(self.factuurBorrelTotaalOnafgerond - self.factuurBorrelTotaal + self.factuurKantineTotaalOnafgerond - self.factuurKantineTotaal + self.factuurEmballageTotaalOnafgerond - self.factuurEmballageTotaal + self.factuurOverigeTotaalOnafgerond - self.factuurOverigeTotaal)))
        self.factuurAfrondingLabelIdx = self.addChild(0,0,self.factuurAfrondingLabel)

        self.resize(width, height)
Пример #20
0
class factuurDetail(Container):
    def __init__(self, width, height, factuur, manager):
        super(factuurDetail, self).__init__(width, height)

        #Associated data object
        self.factuur = factuur
        self.manager = manager

        self.infobox = factuurInfobox(width,0,factuur)
        self.infoboxIdx = self.addChild(0,0,self.infobox)

        self.factuurRegelHeader = factuurRegelHeader(width,1)
        self.factuurRegelHeaderIdx = self.addChild(0,0,self.factuurRegelHeader)

        self.factuurRegelBox = Listbox(width, 0)
        self.factuurRegelBoxIdx = self.addChild(0,0,self.factuurRegelBox)

        self.factuurBorrelTotaal = 0
        self.factuurBorrelmargeTotaal = 0
        self.factuurKantineTotaal = 0
        self.factuurEmballageTotaal = 0
        self.factuurOverigeTotaal = 0
        self.factuurBorrelTotaalOnafgerond = 0
        self.factuurKantineTotaalOnafgerond = 0
        self.factuurEmballageTotaalOnafgerond = 0
        self.factuurOverigeTotaalOnafgerond = 0

        for regel in factuur['regels']:
            self.factuurRegelBox.append(factuurRegel(width,1,regel))
            if 'prd_id' in regel:
                type = getProductType(regel['prd_id'])
                if type=='kantine':
                    self.factuurKantineTotaal += copysign(regel['totaalprijs'], regel['aantal'])
                    self.factuurKantineTotaalOnafgerond += regel['stukprijs'] * regel['aantal']
                elif type=='borrel':
                    self.factuurBorrelTotaal += copysign(regel['totaalprijs'], regel['aantal'])
                    self.factuurBorrelTotaalOnafgerond += regel['stukprijs'] * regel['aantal']
                    self.factuurBorrelmargeTotaal += floor(regel['stukprijs']/1.03) * regel['aantal']
                elif type=='emballage':
                    self.factuurEmballageTotaal += copysign(regel['totaalprijs'], regel['aantal'])
                    self.factuurEmballageTotaalOnafgerond += regel['stukprijs'] * regel['aantal']
                else:
                    self.factuurOverigeTotaal += copysign(regel['totaalprijs'], regel['aantal'])
                    self.factuurOverigeTotaalOnafgerond += regel['stukprijs'] * regel['aantal']
            else:
                self.factuurOverigeTotaal += copysign(regel['totaalprijs'], regel['aantal'])
                self.factuurOverigeTotaalOnafgerond += regel['stukprijs'] * regel['aantal']

        self.factuurBorrelTotaalLabel = Label(0,0,"Borreltotaal: " + moneyConvert(int(self.factuurBorrelTotaal)))
        self.factuurBorrelTotaalLabelIdx = self.addChild(0,0,self.factuurBorrelTotaalLabel)
        self.factuurBorrelmargeTotaalLabel = Label(0,0,"Borrelmargetotaal: " + moneyConvert(int(self.factuurBorrelmargeTotaal)))
        self.factuurBorrelmargeTotaalLabelIdx = self.addChild(0,0,self.factuurBorrelmargeTotaalLabel)
        self.factuurKantineTotaalLabel = Label(0,0,"Kantinetotaal: " + moneyConvert(int(self.factuurKantineTotaal)))
        self.factuurKantineTotaalLabelIdx = self.addChild(0,0,self.factuurKantineTotaalLabel)
        self.factuurEmballageTotaalLabel = Label(0,0,"Emballagetotaal: " + moneyConvert(int(self.factuurEmballageTotaal)))
        self.factuurEmballageTotaalLabelIdx = self.addChild(0,0,self.factuurEmballageTotaalLabel)
        self.factuurOverigeTotaalLabel = Label(0,0,"Overigetotaal: " + moneyConvert(int(self.factuurOverigeTotaal)))
        self.factuurOverigeTotaalLabelIdx = self.addChild(0,0,self.factuurOverigeTotaalLabel)
        self.factuurTotaalLabel = Label(0,0,"Totaal: " + moneyConvert(int(self.factuurBorrelTotaal+self.factuurKantineTotaal+self.factuurEmballageTotaal+self.factuurOverigeTotaal)))
        self.factuurTotaalLabelIdx = self.addChild(0,0,self.factuurTotaalLabel)

        # added details:

        self.factuurBorrelTotaalOnafgerondLabel = Label(0,0,"Borreltotaal-onafgerond: " + moneyConvert(int(self.factuurBorrelTotaalOnafgerond)))
        self.factuurBorrelTotaalOnafgerondLabelIdx = self.addChild(0,0,self.factuurBorrelTotaalOnafgerondLabel)
        self.factuurKantineTotaalOnafgerondLabel = Label(0,0,"Kantinetotaal-onafgerond: " + moneyConvert(int(self.factuurKantineTotaalOnafgerond)))
        self.factuurKantineTotaalOnafgerondLabelIdx = self.addChild(0,0,self.factuurKantineTotaalOnafgerondLabel)
        self.factuurEmballageTotaalOnafgerondLabel = Label(0,0,"Emballagetotaal-onafgerond: " + moneyConvert(int(self.factuurEmballageTotaalOnafgerond)))
        self.factuurEmballageTotaalOnafgerondLabelIdx = self.addChild(0,0,self.factuurEmballageTotaalOnafgerondLabel)
        self.factuurOverigeTotaalOnafgerondLabel = Label(0,0,"Overigetotaal-onafgerond: " + moneyConvert(int(self.factuurOverigeTotaalOnafgerond)))
        self.factuurOverigeTotaalOnafgerondLabelIdx = self.addChild(0,0,self.factuurOverigeTotaalOnafgerondLabel)
        self.factuurTotaalOnafgerondLabel = Label(0,0,"Totaal-onafgerond: " + moneyConvert(int(self.factuurBorrelTotaalOnafgerond+self.factuurKantineTotaalOnafgerond+self.factuurEmballageTotaalOnafgerond+self.factuurOverigeTotaalOnafgerond)))
        self.factuurTotaalOnafgerondLabelIdx = self.addChild(0,0,self.factuurTotaalOnafgerondLabel)

        self.factuurAfrondingLabel = Label(0,0,"Afronding: " + moneyConvert(int(self.factuurBorrelTotaalOnafgerond - self.factuurBorrelTotaal + self.factuurKantineTotaalOnafgerond - self.factuurKantineTotaal + self.factuurEmballageTotaalOnafgerond - self.factuurEmballageTotaal + self.factuurOverigeTotaalOnafgerond - self.factuurOverigeTotaal)))
        self.factuurAfrondingLabelIdx = self.addChild(0,0,self.factuurAfrondingLabel)

        self.resize(width, height)

    def keyEvent(self, key):
        if key == curses.KEY_BACKSPACE:
            self.manager.pop()
        elif key == ord('c'):
            print "test"
        else:
            super(factuurDetail,self).keyEvent(key)

    def resize(self, width, height):
        self.width = width
        self.height = height
        swidth = int(width/3.)
        hwidth = 2*int(width/3.)
        voffset = 0
        self.infobox.resize(width, 0)
        self.setChildPos(self.infoboxIdx,0,voffset)
        voffset += self.infobox.size()[1]
        self.factuurRegelHeader.resize(width, 1)
        self.setChildPos(self.factuurRegelHeaderIdx, 0, voffset)
        voffset += 1
        self.factuurRegelBox.resize(width, height - voffset - 4)
        self.setChildPos(self.factuurRegelBoxIdx, 0, voffset)

        # left colomn
        self.factuurBorrelTotaalLabel.resize(swidth, 1)
        self.setChildPos(self.factuurBorrelTotaalLabelIdx, 0, height-4)
        self.factuurKantineTotaalLabel.resize(swidth, 1)
        self.setChildPos(self.factuurKantineTotaalLabelIdx, 0, height-3)
        self.factuurEmballageTotaalLabel.resize(swidth, 1)
        self.setChildPos(self.factuurEmballageTotaalLabelIdx, 0, height-2)
        self.factuurOverigeTotaalLabel.resize(swidth, 1)
        self.setChildPos(self.factuurOverigeTotaalLabelIdx, 0, height-1)

        # middle column
        self.factuurBorrelTotaalOnafgerondLabel.resize(swidth, 1)
        self.setChildPos(self.factuurBorrelTotaalOnafgerondLabelIdx, swidth, height-4)
        self.factuurKantineTotaalOnafgerondLabel.resize(swidth, 1)
        self.setChildPos(self.factuurKantineTotaalOnafgerondLabelIdx, swidth, height-3)
        self.factuurEmballageTotaalOnafgerondLabel.resize(swidth, 1)
        self.setChildPos(self.factuurEmballageTotaalOnafgerondLabelIdx, swidth, height-2)
        self.factuurOverigeTotaalOnafgerondLabel.resize(swidth, 1)
        self.setChildPos(self.factuurOverigeTotaalOnafgerondLabelIdx, swidth, height-1)

        #right column

        self.factuurBorrelmargeTotaalLabel.resize(swidth, 1)
        self.setChildPos(self.factuurBorrelmargeTotaalLabelIdx, hwidth, height-4)
        self.factuurTotaalLabel.resize(swidth, 1)
        self.setChildPos(self.factuurTotaalLabelIdx, hwidth, height-3)
        self.factuurTotaalOnafgerondLabel.resize(swidth, 1)
        self.setChildPos(self.factuurTotaalOnafgerondLabelIdx, hwidth, height-2)
        self.factuurAfrondingLabel.resize(swidth, 1)
        self.setChildPos(self.factuurAfrondingLabelIdx, hwidth, height-1)
Пример #21
0
    def __init__(self, width, height, factuur):
        super(factuurInfobox, self).__init__(width, height)

        #Associated data object
        self.factuur = factuur

        #Layout settings
        self.labelWidth = 19
        self.minValueWidth = 20

        if 'vereniging_id' in factuur:
            self.otherPartyLabel = Label(0,1,"Vereniging:")
            self.otherPartyValue = Label(0,1,getVerenigingNaam(factuur['vereniging_id']).encode('utf-8'))
        else:
            self.otherPartyLabel = Label(0,1,"Leverancier:")
            self.otherPartyValue = Label(0,1,factuur['leverancier'].encode('utf-8'))
        self.volgnummerLabel = Label(0,1,"Volgnummer:")
        self.volgnummerValue = Label(0,1,str(factuur['volgnummer']))

        self.factuurDatumLabel = Label(0,1,"Factuurdatum:")
        self.factuurDatumValue = Label(0,1,factuur['factuurdatum'].encode('utf-8'))
        self.leverDatumLabel = Label(0,1, "Leverdatum:")
        self.leverDatumValue = Label(0,1,factuur['leverdatum'].encode('utf-8'))

        self.separatorFill = Fill(0,0,'|')
        self.separatorFillIdx = self.addChild(0,0,self.separatorFill)

        self.hasVerantwoordelijke = False
        if 'verantwoordelijke' in factuur:
            self.hasVerantwoordelijke = True
            self.verantwoordelijkeLabel = Label(0,1,"Verantwoordelijke:")
            self.verantwoordelijkeValue = Label(0,1,factuur['verantwoordelijke'].encode('utf-8'))

        self.otherPartyLabelIdx = self.addChild(0,0,self.otherPartyLabel)
        self.otherPartyValueIdx = self.addChild(0,0,self.otherPartyValue)
        self.volgnummerLabelIdx = self.addChild(0,0,self.volgnummerLabel)
        self.volgnummerValueIdx = self.addChild(0,0,self.volgnummerValue)
        self.factuurDatumLabelIdx = self.addChild(0,0,self.factuurDatumLabel)
        self.factuurDatumValueIdx = self.addChild(0,0,self.factuurDatumValue)
        self.leverDatumLabelIdx = self.addChild(0,0,self.leverDatumLabel)
        self.leverDatumValueIdx = self.addChild(0,0,self.leverDatumValue)
        if self.hasVerantwoordelijke:
            self.verantwoordelijkeLabelIdx = self.addChild(0,0,self.verantwoordelijkeLabel)
            self.verantwoordelijkeValueIdx = self.addChild(0,0,self.verantwoordelijkeValue)

        self.resize(width, 0)
Пример #22
0
class factuurInfobox(Container):
    def __init__(self, width, height, factuur):
        super(factuurInfobox, self).__init__(width, height)

        #Associated data object
        self.factuur = factuur

        #Layout settings
        self.labelWidth = 19
        self.minValueWidth = 20

        if 'vereniging_id' in factuur:
            self.otherPartyLabel = Label(0,1,"Vereniging:")
            self.otherPartyValue = Label(0,1,getVerenigingNaam(factuur['vereniging_id']).encode('utf-8'))
        else:
            self.otherPartyLabel = Label(0,1,"Leverancier:")
            self.otherPartyValue = Label(0,1,factuur['leverancier'].encode('utf-8'))
        self.volgnummerLabel = Label(0,1,"Volgnummer:")
        self.volgnummerValue = Label(0,1,str(factuur['volgnummer']))

        self.factuurDatumLabel = Label(0,1,"Factuurdatum:")
        self.factuurDatumValue = Label(0,1,factuur['factuurdatum'].encode('utf-8'))
        self.leverDatumLabel = Label(0,1, "Leverdatum:")
        self.leverDatumValue = Label(0,1,factuur['leverdatum'].encode('utf-8'))

        self.separatorFill = Fill(0,0,'|')
        self.separatorFillIdx = self.addChild(0,0,self.separatorFill)

        self.hasVerantwoordelijke = False
        if 'verantwoordelijke' in factuur:
            self.hasVerantwoordelijke = True
            self.verantwoordelijkeLabel = Label(0,1,"Verantwoordelijke:")
            self.verantwoordelijkeValue = Label(0,1,factuur['verantwoordelijke'].encode('utf-8'))

        self.otherPartyLabelIdx = self.addChild(0,0,self.otherPartyLabel)
        self.otherPartyValueIdx = self.addChild(0,0,self.otherPartyValue)
        self.volgnummerLabelIdx = self.addChild(0,0,self.volgnummerLabel)
        self.volgnummerValueIdx = self.addChild(0,0,self.volgnummerValue)
        self.factuurDatumLabelIdx = self.addChild(0,0,self.factuurDatumLabel)
        self.factuurDatumValueIdx = self.addChild(0,0,self.factuurDatumValue)
        self.leverDatumLabelIdx = self.addChild(0,0,self.leverDatumLabel)
        self.leverDatumValueIdx = self.addChild(0,0,self.leverDatumValue)
        if self.hasVerantwoordelijke:
            self.verantwoordelijkeLabelIdx = self.addChild(0,0,self.verantwoordelijkeLabel)
            self.verantwoordelijkeValueIdx = self.addChild(0,0,self.verantwoordelijkeValue)

        self.resize(width, 0)

    def resize(self, width, height):
        #ignore height, we determine that ourselves
        self.width = width

        if (self.width - 1)/2 - self.labelWidth >= self.minValueWidth:
            #two column layout
            colWidth = (self.width-1)/2
            colOffset = colWidth+1
            valueWidth = max(0, colWidth-self.labelWidth)

            self.separatorFill.resize(1,2)
            self.setChildPos(self.separatorFillIdx, colWidth,0)

            self.otherPartyLabel.resize(self.labelWidth,1)
            self.setChildPos(self.otherPartyLabelIdx,0,0)
            self.otherPartyValue.resize(valueWidth, 1)
            self.setChildPos(self.otherPartyValueIdx,self.labelWidth,0)

            self.volgnummerLabel.resize(self.labelWidth,1)
            self.setChildPos(self.volgnummerLabelIdx,0,1)
            self.volgnummerValue.resize(valueWidth, 1)
            self.setChildPos(self.volgnummerValueIdx,self.labelWidth,1)

            self.factuurDatumLabel.resize(self.labelWidth,1)
            self.setChildPos(self.factuurDatumLabelIdx, colOffset,0)
            self.factuurDatumValue.resize(valueWidth,1)
            self.setChildPos(self.factuurDatumValueIdx, colOffset + self.labelWidth,0)

            self.leverDatumLabel.resize(self.labelWidth,1)
            self.setChildPos(self.leverDatumLabelIdx, colOffset,1)
            self.leverDatumValue.resize(self.labelWidth,1)
            self.setChildPos(self.leverDatumValueIdx, colOffset + self.labelWidth, 1)

            if self.hasVerantwoordelijke:
                self.height = 3
                self.verantwoordelijkeLabel.resize(self.labelWidth,1)
                self.setChildPos(self.verantwoordelijkeLabelIdx, 0, 2)
                self.verantwoordelijkeValue.resize(width-self.labelWidth,1)
                self.setChildPos(self.verantwoordelijkeValueIdx, self.labelWidth, 2)
            else:
                self.height = 2
        else:
            #one column layout
            valueWidth = max(0, width-self.labelWidth)

            self.separatorFill.resize(0,0)
            self.setChildPos(self.separatorFillIdx, 0,0)

            self.otherPartyLabel.resize(self.labelWidth, 1)
            self.setChildPos(self.otherPartyLabelIdx,0,0)
            self.otherPartyValue.resize(valueWidth, 1)
            self.setChildPos(self.otherPartyValueIdx,self.labelWidth,0)

            self.volgnummerLabel.resize(self.labelWidth, 1)
            self.setChildPos(self.volgnummerLabelIdx,0,1)
            self.volgnummerValue.resize(valueWidth, 1)
            self.setChildPos(self.volgnummerValueIdx,self.labelWidth,1)

            self.factuurDatumLabel.resize(self.labelWidth, 1)
            self.setChildPos(self.factuurDatumLabelIdx,0,2)
            self.factuurDatumValue.resize(valueWidth, 1)
            self.setChildPos(self.factuurDatumValueIdx,self.labelWidth,2)

            self.leverDatumLabel.resize(self.labelWidth,1)
            self.setChildPos(self.leverDatumLabelIdx,0,3)
            self.leverDatumValue.resize(valueWidth,1)
            self.setChildPos(self.leverDatumValueIdx,self.labelWidth,3)

            if self.hasVerantwoordelijke:
                self.height = 5
                self.verantwoordelijkeLabel.resize(self.labelWidth, 1)
                self.setChildPos(self.verantwoordelijkeLabelIdx,0,4)
                self.verantwoordelijkeValue.resize(valueWidth,1)
                self.setChildPos(self.verantwoordelijkeValueIdx,self.labelWidth,4)
            else:
                self.height = 4
Пример #23
0
class FactuurData(Container):
    def __init__(self, width, height):
        super(FactuurData, self).__init__(width, height)

        # Layout settings
        self.labelWidth = 23
        self.minValueWidth = 20

        self.otherPartyLabel = Label(0, 1, "Vereniging/Leverancier")
        self.otherPartyValue = VerenigingLine(1)

        self.leverDatumLabel = Label(0, 1, "Leverdatum")
        self.leverDatumValue = Textline(0)

        self.separatorFill = Fill(0, 0, '|')

        self.verantwoordelijkeLabel = Label(0, 1, "Verantwoordelijke")
        self.verantwoordelijkeValue = Textline(0)

        self.specialBudgetLabel = Label(0, 1, "Speciaal budget")
        self.specialBudgetValue = BudgetLine(1)

        self.typeValue = Optionbox(1, 1)
        self.typeValue.addOption('inkoop')
        self.typeValue.addOption('verkoop')

        self.btwValue = Optionbox(1, 1)
        self.btwValue.addOption('metbtw')
        self.btwValue.addOption('zonderbtw')

        self.typeValueIdx = self.addChild(0, 0, self.typeValue)
        self.btwValueIdx = self.addChild(0, 0, self.btwValue)
        self.otherPartyLabelIdx = self.addChild(0, 0, self.otherPartyLabel)
        self.otherPartyValueIdx = self.addChild(0, 0, self.otherPartyValue)
        self.leverDatumLabelIdx = self.addChild(0, 0, self.leverDatumLabel)
        self.leverDatumValueIdx = self.addChild(0, 0, self.leverDatumValue)
        self.separatorFillIdx = self.addChild(0, 0, self.separatorFill)
        self.verantwoordelijkeLabelIdx = self.addChild(
            0, 0, self.verantwoordelijkeLabel)
        self.verantwoordelijkeValueIdx = self.addChild(
            0, 0, self.verantwoordelijkeValue)
        self.specialBudgetLabelIdx = self.addChild(0, 0,
                                                   self.specialBudgetLabel)
        self.specialBudgetValueIdx = self.addChild(0, 0,
                                                   self.specialBudgetValue)

        self.resize(width, 0)

    def resize(self, width, height):
        #  ignore height, selfdetermined
        self.width = width

        self.typeValue.resize(int(width / 2.), 1)
        self.btwValue.resize(int(width / 2.), 1)
        self.setChildPos(self.typeValueIdx, 0, 0)
        self.setChildPos(self.btwValueIdx, int(width / 2.), 0)

        if (self.width - 1) / 2 - self.labelWidth >= self.minValueWidth:
            #two column layout
            colWidth = (self.width - 1) / 2
            colOffset = colWidth + 1
            valueWidth = max(0, colWidth - self.labelWidth)

            self.separatorFill.resize(1, 2)
            self.setChildPos(self.separatorFillIdx, colWidth, 1)

            self.otherPartyLabel.resize(self.labelWidth, 1)
            self.setChildPos(self.otherPartyLabelIdx, 0, 1)
            self.otherPartyValue.resize(valueWidth, 1)
            self.setChildPos(self.otherPartyValueIdx, self.labelWidth, 1)

            self.leverDatumLabel.resize(self.labelWidth, 1)
            self.setChildPos(self.leverDatumLabelIdx, 0, 2)
            self.leverDatumValue.resize(valueWidth, 1)
            self.setChildPos(self.leverDatumValueIdx, self.labelWidth, 2)

            self.verantwoordelijkeLabel.resize(self.labelWidth, 1)
            self.setChildPos(self.verantwoordelijkeLabelIdx, colOffset, 1)
            self.verantwoordelijkeValue.resize(valueWidth, 1)
            self.setChildPos(self.verantwoordelijkeValueIdx,
                             colOffset + self.labelWidth, 1)

            self.specialBudgetLabel.resize(self.labelWidth, 1)
            self.setChildPos(self.specialBudgetLabelIdx, colOffset, 2)
            self.specialBudgetValue.resize(valueWidth, 1)
            self.setChildPos(self.specialBudgetValueIdx,
                             colOffset + self.labelWidth, 2)

            self.height = 3
        else:
            valueWidth = max(0, self.width - self.labelWidth)

            self.separatorFill.resize(0, 0)
            self.setChildPos(self.separatorFillIdx, 0, 0)

            self.otherPartyLabel.resize(self.labelWidth, 1)
            self.setChildPos(self.otherPartyLabelIdx, 0, 1)
            self.otherPartyValue.resize(valueWidth, 1)
            self.setChildPos(self.otherPartyValueIdx, self.labelWidth, 1)

            self.leverDatumLabel.resize(self.labelWidth, 1)
            self.setChildPos(self.leverDatumLabelIdx, 0, 2)
            self.leverDatumValue.resize(valueWidth, 1)
            self.setChildPos(self.leverDatumValueIdx, self.labelWidth, 2)

            self.verantwoordelijkeLabel.resize(self.labelWidth, 1)
            self.setChildPos(self.verantwoordelijkeLabelIdx, 0, 3)
            self.verantwoordelijkeValue.resize(valueWidth, 1)
            self.setChildPos(self.verantwoordelijkeValueIdx, self.labelWidth,
                             3)

            self.specialBudgetLabel.resize(self.labelWidth, 1)
            self.setChildPos(self.specialBudgetLabelIdx, 0, 4)
            self.specialBudgetValue.resize(valueWidth, 1)
            self.setChildPos(self.specialBudgetValueIdx, self.labelWidth, 4)

            self.height = 5

    def generateFactuur(self):
        if self.otherPartyValue.text == "":
            return (False, False, "Mis vereniging/leverancier")
        if self.leverDatumValue.text == "":
            return (False, False, "Mis leverdatum")

        try:
            datetime.datetime.strptime(self.leverDatumValue.text, "%Y-%m-%d")
        except ValueError:
            return (False, False, "Ongeldige leverdatum")

        result = {}

        result['type'] = self.typeValue.text
        result['dobtw'] = self.btwValue.text

        if self.otherPartyValue.currentID is not None:
            result['vereniging'] = self.otherPartyValue.currentID
            if self.specialBudgetValue.currentID is not None:
                result['saldo_speciaal'] = self.specialBudgetValue.currentID
        else:
            result['leverancier'] = self.otherPartyValue.text

        result['leverdatum'] = self.leverDatumValue.text
        result['factuurdatum'] = datetime.datetime.today().strftime("%Y-%m-%d")

        if self.verantwoordelijkeValue.text != "":
            result['verantwoordelijke'] = self.verantwoordelijkeValue.text

        return (True, True, result)
Пример #24
0
class FactuurInput(Container):
    def __init__(self, width, height):
        super(FactuurInput, self).__init__(width, height)

        self.factuurData = FactuurData(1,1)
        self.factuurListHeader = FactuurInputHeader(1,1)
        self.factuurRegelList = FactuurRegelList(1,1)
        self.statusLine = Label(1,1,"")
        self.submitButton = Button(1,1,self.sendFactuur,"Submit")

        self.factuurListHeaderIdx = self.addChild(0,0, self.factuurListHeader)
        self.statusLineIdx = self.addChild(0,0,self.statusLine)
        self.submitButtonIdx = self.addChild(0,0,self.submitButton)
        self.factuurDataIdx = self.addChild(0,0, self.factuurData)
        self.factuurRegelListIdx = self.addChild(0,0,self.factuurRegelList)

        self.resize(width, height)

    def resize(self, width, height):
        self.width = width
        self.height = height

        vOffset = 0

        self.factuurData.resize(width, 1)
        self.setChildPos(self.factuurDataIdx, 0, 0)
        vOffset += self.factuurData.size()[1]

        self.factuurListHeader.resize(width, 1)
        self.setChildPos(self.factuurListHeaderIdx, 0, vOffset)
        vOffset += 1

        self.factuurRegelList.resize(width, height - vOffset-1)
        self.setChildPos(self.factuurRegelListIdx, 0, vOffset)
        vOffset = height-1

        self.submitButton.resize(min(width, 6), 1)
        self.setChildPos(self.submitButtonIdx, 1, vOffset)
        self.statusLine.resize(width-min(width, 8), 1)
        self.setChildPos(self.statusLineIdx, min(width, 8), vOffset)


    def sendFactuur(self):
        result = self.generateFactuur()

        if not result[0]:
            self.statusLine.setText(result[2])
            return

        if not result[1]:
            self.statusLine.setText("Insufficient input given")
            return

        try:
            submitResult = remote_call('/factuur/create', jsondata = result[2])
        except ServerCallException:
            self.statusLine.setText("Kon geen verbinding maken met server.")
            return

        if 'error' in submitResult:
            self.statusLine.setText(submitResult['error'].encode('utf-8'))
            return

        self.statusLine.setText("")
        self.remChild(self.factuurRegelListIdx) #warning: fragile
        self.remChild(self.factuurDataIdx)
        self.factuurData = FactuurData(1,1)
        self.factuurDataIdx = self.addChild(0,0,self.factuurData)
        self.factuurRegelList = FactuurRegelList(1,1)
        self.factuurRegelListIdx = self.addChild(0,0,self.factuurRegelList)
        self.resize(self.width, self.height)

    def generateFactuur(self):
        result = self.factuurData.generateFactuur()

        if not result[0] or not result[1]:
            return result

        factuur = result[2]

        result = self.factuurRegelList.generateFactuurRegels(factuur['type'] == 'inkoop', factuur['dobtw'] == 'metbtw')

        if not result[0] or not result[1]:
            return result

        factuur['regels'] = result[2]

        return (True, True, factuur)
Пример #25
0
class factuurDetail(Container):
    def __init__(self, width, height, factuur, manager):
        super(factuurDetail, self).__init__(width, height)

        #Associated data object
        self.factuur = factuur
        self.manager = manager

        self.infobox = factuurInfobox(width, 0, factuur)
        self.infoboxIdx = self.addChild(0, 0, self.infobox)

        self.factuurRegelHeader = factuurRegelHeader(width, 1)
        self.factuurRegelHeaderIdx = self.addChild(0, 0,
                                                   self.factuurRegelHeader)

        self.factuurRegelBox = Listbox(width, 0)
        self.factuurRegelBoxIdx = self.addChild(0, 0, self.factuurRegelBox)

        self.factuurBorrelTotaal = 0
        self.factuurKantineTotaal = 0
        self.factuurEmballageTotaal = 0
        self.factuurOverigeTotaal = 0

        for regel in factuur['regels']:
            self.factuurRegelBox.append(factuurRegel(width, 1, regel))
            if 'prd_id' in regel:
                type = getProductType(regel['prd_id'])
                if type == 'kantine':
                    self.factuurKantineTotaal += copysign(
                        regel['totaalprijs'], regel['aantal'])
                elif type == 'borrel':
                    self.factuurBorrelTotaal += copysign(
                        regel['totaalprijs'], regel['aantal'])
                elif type == 'emballage':
                    self.factuurEmballageTotaal += copysign(
                        regel['totaalprijs'], regel['aantal'])
                else:
                    self.factuurOverigeTotaal += copysign(
                        regel['totaalprijs'], regel['aantal'])
            else:
                self.factuurOverigeTotaal += copysign(regel['totaalprijs'],
                                                      regel['aantal'])

        self.factuurBorrelTotaalLabel = Label(
            0, 0,
            "Borreltotaal: " + moneyConvert(int(self.factuurBorrelTotaal)))
        self.factuurBorrelTotaalLabelIdx = self.addChild(
            0, 0, self.factuurBorrelTotaalLabel)
        self.factuurBorrelmargeTotaalLabel = Label(
            0, 0, "Borrelmargetotaal: " +
            moneyConvert(int(round(self.factuurBorrelTotaal / 1.03))))
        self.factuurBorrelmargeTotaalLabelIdx = self.addChild(
            0, 0, self.factuurBorrelmargeTotaalLabel)
        self.factuurKantineTotaalLabel = Label(
            0, 0,
            "Kantinetotaal: " + moneyConvert(int(self.factuurKantineTotaal)))
        self.factuurKantineTotaalLabelIdx = self.addChild(
            0, 0, self.factuurKantineTotaalLabel)
        self.factuurEmballageTotaalLabel = Label(
            0, 0, "Emballagetotaal: " +
            moneyConvert(int(self.factuurEmballageTotaal)))
        self.factuurEmballageTotaalLabelIdx = self.addChild(
            0, 0, self.factuurEmballageTotaalLabel)
        self.factuurOverigeTotaalLabel = Label(
            0, 0,
            "Overigetotaal: " + moneyConvert(int(self.factuurOverigeTotaal)))
        self.factuurOverigeTotaalLabelIdx = self.addChild(
            0, 0, self.factuurOverigeTotaalLabel)
        self.factuurTotaalLabel = Label(
            0, 0, "Totaal: " + moneyConvert(
                int(self.factuurBorrelTotaal + self.factuurKantineTotaal +
                    self.factuurEmballageTotaal + self.factuurOverigeTotaal)))
        self.factuurTotaalLabelIdx = self.addChild(0, 0,
                                                   self.factuurTotaalLabel)

        self.resize(width, height)

    def keyEvent(self, key):
        if key == curses.KEY_BACKSPACE:
            self.manager.pop()
        else:
            super(factuurDetail, self).keyEvent(key)

    def resize(self, width, height):
        self.width = width
        self.height = height
        hwidth = int(width / 2.)
        voffset = 0
        self.infobox.resize(width, 0)
        self.setChildPos(self.infoboxIdx, 0, voffset)
        voffset += self.infobox.size()[1]
        self.factuurRegelHeader.resize(width, 1)
        self.setChildPos(self.factuurRegelHeaderIdx, 0, voffset)
        voffset += 1
        self.factuurRegelBox.resize(width, height - voffset - 3)
        self.setChildPos(self.factuurRegelBoxIdx, 0, voffset)
        self.factuurBorrelTotaalLabel.resize(hwidth, 1)
        self.setChildPos(self.factuurBorrelTotaalLabelIdx, 0, height - 3)
        self.factuurBorrelmargeTotaalLabel.resize(hwidth, 1)
        self.setChildPos(self.factuurBorrelmargeTotaalLabelIdx, hwidth,
                         height - 3)
        self.factuurKantineTotaalLabel.resize(hwidth, 1)
        self.setChildPos(self.factuurKantineTotaalLabelIdx, 0, height - 2)
        self.factuurEmballageTotaalLabel.resize(hwidth, 1)
        self.setChildPos(self.factuurEmballageTotaalLabelIdx, hwidth,
                         height - 2)
        self.factuurOverigeTotaalLabel.resize(hwidth, 1)
        self.setChildPos(self.factuurOverigeTotaalLabelIdx, 0, height - 1)
        self.factuurTotaalLabel.resize(hwidth, 1)
        self.setChildPos(self.factuurTotaalLabelIdx, hwidth, height - 1)
Пример #26
0
class FactuurData(Container):
    def __init__(self, width, height):
        super(FactuurData,self).__init__(width, height)

        # Layout settings
        self.labelWidth = 23
        self.minValueWidth = 20

        self.otherPartyLabel = Label(0,1,"Vereniging/Leverancier")
        self.otherPartyValue = VerenigingLine(1)

        self.leverDatumLabel = Label(0,1,"Leverdatum")
        self.leverDatumValue = Textline(0)

        self.separatorFill = Fill(0,0,'|')

        self.verantwoordelijkeLabel = Label(0,1,"Verantwoordelijke")
        self.verantwoordelijkeValue = Textline(0)

        self.specialBudgetLabel = Label(0,1,"Speciaal budget")
        self.specialBudgetValue = BudgetLine(1)

        self.typeValue = Optionbox(1,1)
        self.typeValue.addOption('inkoop')
        self.typeValue.addOption('verkoop')

        self.btwValue = Optionbox(1,1)
        self.btwValue.addOption('zonderbtw')
        self.btwValue.addOption('metbtw')

        self.typeValueIdx = self.addChild(0,0,self.typeValue)
        self.btwValueIdx = self.addChild(0,0, self.btwValue)
        self.otherPartyLabelIdx = self.addChild(0,0,self.otherPartyLabel)
        self.otherPartyValueIdx = self.addChild(0,0,self.otherPartyValue)
        self.leverDatumLabelIdx = self.addChild(0,0,self.leverDatumLabel)
        self.leverDatumValueIdx = self.addChild(0,0,self.leverDatumValue)
        self.separatorFillIdx = self.addChild(0,0,self.separatorFill)
        self.verantwoordelijkeLabelIdx = self.addChild(0,0,self.verantwoordelijkeLabel)
        self.verantwoordelijkeValueIdx = self.addChild(0,0,self.verantwoordelijkeValue)
        self.specialBudgetLabelIdx = self.addChild(0,0,self.specialBudgetLabel)
        self.specialBudgetValueIdx = self.addChild(0,0,self.specialBudgetValue)

        self.resize(width, 0)

    def resize(self, width, height):
        #  ignore height, selfdetermined
        self.width = width

        self.typeValue.resize(int(width/2.),1)
        self.btwValue.resize(int(width/2.),1)
        self.setChildPos(self.typeValueIdx, 0,0)
        self.setChildPos(self.btwValueIdx, int(width/2.), 0)

        if (self.width-1)/2 - self.labelWidth >= self.minValueWidth:
            #two column layout
            colWidth = (self.width-1)/2
            colOffset = colWidth+1
            valueWidth = max(0, colWidth - self.labelWidth)

            self.separatorFill.resize(1,2)
            self.setChildPos(self.separatorFillIdx, colWidth, 1)

            self.otherPartyLabel.resize(self.labelWidth, 1)
            self.setChildPos(self.otherPartyLabelIdx, 0, 1)
            self.otherPartyValue.resize(valueWidth, 1)
            self.setChildPos(self.otherPartyValueIdx, self.labelWidth, 1)

            self.leverDatumLabel.resize(self.labelWidth, 1)
            self.setChildPos(self.leverDatumLabelIdx, 0, 2)
            self.leverDatumValue.resize(valueWidth, 1)
            self.setChildPos(self.leverDatumValueIdx, self.labelWidth, 2)

            self.verantwoordelijkeLabel.resize(self.labelWidth, 1)
            self.setChildPos(self.verantwoordelijkeLabelIdx, colOffset, 1)
            self.verantwoordelijkeValue.resize(valueWidth, 1)
            self.setChildPos(self.verantwoordelijkeValueIdx, colOffset + self.labelWidth, 1)

            self.specialBudgetLabel.resize(self.labelWidth, 1)
            self.setChildPos(self.specialBudgetLabelIdx, colOffset, 2)
            self.specialBudgetValue.resize(valueWidth, 1)
            self.setChildPos(self.specialBudgetValueIdx, colOffset + self.labelWidth, 2)

            self.height = 3
        else:
            valueWidth = max(0, self.width - self.labelWidth)

            self.separatorFill.resize(0,0)
            self.setChildPos(self.separatorFillIdx, 0,0)

            self.otherPartyLabel.resize(self.labelWidth, 1)
            self.setChildPos(self.otherPartyLabelIdx, 0, 1)
            self.otherPartyValue.resize(valueWidth, 1)
            self.setChildPos(self.otherPartyValueIdx, self.labelWidth, 1)

            self.leverDatumLabel.resize(self.labelWidth, 1)
            self.setChildPos(self.leverDatumLabelIdx, 0, 2)
            self.leverDatumValue.resize(valueWidth, 1)
            self.setChildPos(self.leverDatumValueIdx, self.labelWidth, 2)

            self.verantwoordelijkeLabel.resize(self.labelWidth, 1)
            self.setChildPos(self.verantwoordelijkeLabelIdx, 0, 3)
            self.verantwoordelijkeValue.resize(valueWidth, 1)
            self.setChildPos(self.verantwoordelijkeValueIdx, self.labelWidth, 3)

            self.specialBudgetLabel.resize(self.labelWidth, 1)
            self.setChildPos(self.specialBudgetLabelIdx, 0, 4)
            self.specialBudgetValue.resize(valueWidth, 1)
            self.setChildPos(self.specialBudgetValueIdx, self.labelWidth, 4)

            self.height = 5

    def generateFactuur(self):
        if self.otherPartyValue.text == "":
            return (False, False, "Mis vereniging/leverancier")
        if self.leverDatumValue.text == "":
            return (False, False, "Mis leverdatum")

        try:
            datetime.datetime.strptime(self.leverDatumValue.text, "%Y-%m-%d")
        except ValueError:
            return (False, False, "Ongeldige leverdatum")

        result = {}

        result['type'] = self.typeValue.text
        result['dobtw'] = self.btwValue.text

        if self.otherPartyValue.currentID is not None:
            result['vereniging'] = self.otherPartyValue.currentID
            if self.specialBudgetValue.currentID is not None:
                result['saldo_speciaal'] = self.specialBudgetValue.currentID
        else:
            result['leverancier'] = self.otherPartyValue.text

        result['leverdatum'] = self.leverDatumValue.text
        result['factuurdatum'] = datetime.datetime.today().strftime("%Y-%m-%d")

        if self.verantwoordelijkeValue.text != "":
            result['verantwoordelijke'] = self.verantwoordelijkeValue.text

        return (True, True, result)
Пример #27
0
class FactuurInput(Container):
    def __init__(self, width, height):
        super(FactuurInput, self).__init__(width, height)

        self.factuurData = FactuurData(1, 1)
        self.factuurListHeader = FactuurInputHeader(1, 1)
        self.factuurRegelList = FactuurRegelList(1, 1)
        self.statusLine = Label(1, 1, "")
        self.submitButton = Button(1, 1, self.sendFactuur, "Submit")

        self.factuurListHeaderIdx = self.addChild(0, 0, self.factuurListHeader)
        self.statusLineIdx = self.addChild(0, 0, self.statusLine)
        self.submitButtonIdx = self.addChild(0, 0, self.submitButton)
        self.factuurDataIdx = self.addChild(0, 0, self.factuurData)
        self.factuurRegelListIdx = self.addChild(0, 0, self.factuurRegelList)

        self.resize(width, height)

    def resize(self, width, height):
        self.width = width
        self.height = height

        vOffset = 0

        self.factuurData.resize(width, 1)
        self.setChildPos(self.factuurDataIdx, 0, 0)
        vOffset += self.factuurData.size()[1]

        self.factuurListHeader.resize(width, 1)
        self.setChildPos(self.factuurListHeaderIdx, 0, vOffset)
        vOffset += 1

        self.factuurRegelList.resize(width, height - vOffset - 1)
        self.setChildPos(self.factuurRegelListIdx, 0, vOffset)
        vOffset = height - 1

        self.submitButton.resize(min(width, 6), 1)
        self.setChildPos(self.submitButtonIdx, 1, vOffset)
        self.statusLine.resize(width - min(width, 8), 1)
        self.setChildPos(self.statusLineIdx, min(width, 8), vOffset)

    def sendFactuur(self):
        result = self.generateFactuur()

        if not result[0]:
            self.statusLine.setText(result[2])
            return

        if not result[1]:
            self.statusLine.setText("Insufficient input given")
            return

        try:
            submitResult = remote_call('/factuur/create', jsondata=result[2])
        except ServerCallException:
            self.statusLine.setText("Kon geen verbinding maken met server.")
            return

        if 'error' in submitResult:
            self.statusLine.setText(submitResult['error'].encode('utf-8'))
            return

        self.statusLine.setText("")
        self.remChild(self.factuurRegelListIdx)  #warning: fragile
        self.remChild(self.factuurDataIdx)
        self.factuurData = FactuurData(1, 1)
        self.factuurDataIdx = self.addChild(0, 0, self.factuurData)
        self.factuurRegelList = FactuurRegelList(1, 1)
        self.factuurRegelListIdx = self.addChild(0, 0, self.factuurRegelList)
        self.resize(self.width, self.height)

    def generateFactuur(self):
        result = self.factuurData.generateFactuur()

        if not result[0] or not result[1]:
            return result

        factuur = result[2]

        result = self.factuurRegelList.generateFactuurRegels(
            factuur['type'] == 'inkoop')

        if not result[0] or not result[1]:
            return result

        factuur['regels'] = result[2]

        return (True, True, factuur)