class StockAdjustmentWindow(WindowController):
    def __init__(self, **kw):
        super(StockAdjustmentWindow, self).__init__(**kw)
        self.window.title = "Stock Adjustment"
        self.trans = Transaction()
        
        v= VBox (parent=self.window)

        columns = (Column(name="Code", attribute="product.code", readOnly=True),
                   Column(name="Name", attribute="product.name", readOnly=True))

        self.searcher = Search(parent=v, columns=columns,
                               cls=Stock, searcher=self.trans,
                               onAction=self.listValues)

        columns = (Column(name="Code", attribute="product.code", readOnly=True),
                   Column(name="Name", attribute="product.name", readOnly=True),
                   Column(name="Level", attribute="level"))
        self.stockEditor = Grid(parent=v, columns=columns)
        actionContainer = HBox(parent=v, expand=False)
        save = Button(parent=actionContainer, label="Save", onAction=self.save)
        discard = Button(parent=actionContainer, label="Discard", onAction=self.discard)

    def commitValue(self, value):
        self.stockEditor.commitValue(value)

    def listValues(self, sender):
        self.commitValue(sender.value)

    def save(self, *ignore):
        self.trans.save()

    def discard(self, *ignore):
        self.trans.discard()
        self.commitValue(None)
    def __init__(self, **kw):
        super(StockAdjustmentWindow, self).__init__(**kw)
        self.window.title = "Stock Adjustment"
        self.trans = Transaction()

        v = VBox(parent=self.window)

        columns = (Column(name="Code", attribute="product.code",
                          readOnly=True),
                   Column(name="Name", attribute="product.name",
                          readOnly=True))

        self.searcher = Search(parent=v,
                               columns=columns,
                               cls=Stock,
                               searcher=self.trans,
                               onAction=self.listValues)

        columns = (Column(name="Code", attribute="product.code",
                          readOnly=True),
                   Column(name="Name", attribute="product.name",
                          readOnly=True),
                   Column(name="Level", attribute="level"))
        self.stockEditor = Grid(parent=v, columns=columns)
        actionContainer = HBox(parent=v, expand=False)
        save = Button(parent=actionContainer, label="Save", onAction=self.save)
        discard = Button(parent=actionContainer,
                         label="Discard",
                         onAction=self.discard)
Example #3
0
 def setUp(self):
     super(TestPointOfSale, self).setUp()
     self.pettyCashName = 'Piece of POS'
     self.pos = PointOfSale(name=self.pettyCashName)
     self.client = Client(subject=Person(name='Cacho', surname='Moo'))
     self.category = CustomerAccount(name='FonCyT')
     self.account = MovementAccount(name='Impuestos', code="1")
     self.subAccount = MovementAccount(name='IVA',
                                       code="11",
                                       parent=self.account)
     self.trans = Transaction()
     self.qual = Qualifier()
     self.trans.track(self.pos, self.category, self.account,
                      self.subAccount, self.client, self.client.subject)
     self.trans.save()
    def __init__(self, **kwargs):
        super(LoadPettyCashEntry, self).__init__(**kwargs)
        self.trans = Transaction()

        # it assured existence point of sale
        pointOfSale = self.trans.search('PointOfSale')
        if not pointOfSale:
            from pointOfSale import main as pofMain
            pofMain()
            pointOfSale = self.trans.search('PointOfSale')
            if pointOfSale:
                #mensaje error, que estas haciendo
                pass

        self.pos = pointOfSale[0]
        self.buildUI()
    def testOverwriting(self):
        """
        Load the product from the database, edit it, save: if you
        look for it again with a different transaction, you should see
        the edit
        """
        p1 ,= self.tr.search(aProduct);
        p1.name = 'two'
        p2 ,= self.other_tr.search(aProduct);
        p2.name = 'three'
        self.tr.save();
        self.other_tr.save()

        t = Transaction()
        p ,= t.search(aProduct)
        self.assertEqual(p.name, p2.name)
Example #6
0
    def __init__(self, **kw):
        super(ReceiptWindow, self).__init__(**kw)
        self.window.title = "Receipt Generation"
        self.trans = Transaction()
        self.target=Receipt(actualDate=today())
        self.trans.track(self.target)

        v = cimarron.skin.VBox(parent=self.window, expand=True, fill=True)
        h1 = cimarron.skin.HBox(parent=v, expand=False, fill=True)
        h2 = cimarron.skin.HBox(parent=v, expand=False, fill=False)
        v1 = cimarron.skin.VBox(parent=v)
        actionContainer = cimarron.skin.HBox(parent=v, expand=False, fill=True)

        columns = (cimarron.skin.Column(name="Name", attribute="name"),
                   cimarron.skin.Column(name="Surname", attribute="surname"))
        self.person = cimarron.skin.SearchEntry(parent=h1, cls=Person,
                                                searcher=self.trans, columns=columns,
                                                attribute="person")
        cimarron.skin.Label(parent=h2, text="Date:")
        self.actualDate = cimarron.skin.Entry(parent=h2, attribute="actualDate")
        
        cimarron.skin.Label(parent=h2, text="Amount:")
        self.amount = cimarron.skin.Entry(parent=h2,  attribute="amount")
        
        cimarron.skin.Label(parent=v1, text="Concept:", expand=False, fill=False)
        self.concept = cimarron.skin.MultiLine(parent=v1, attribute="concept")
        
        save = cimarron.skin.Button(parent=actionContainer, label="Save", onAction=self.save)
        discard = cimarron.skin.Button(parent=actionContainer, label="Discard", onAction=self.discard)
        self.refresh()
    def testOverwriting(self):
        """
        Load the product from the database, edit it, save: if you
        look for it again with a different transaction, you should see
        the edit
        """
        p1, = self.tr.search(aProduct)
        p1.name = 'two'
        p2, = self.other_tr.search(aProduct)
        p2.name = 'three'
        self.tr.save()
        self.other_tr.save()

        t = Transaction()
        p, = t.search(aProduct)
        self.assertEqual(p.name, p2.name)
class TestPointOfSale(testWithDatabase):
    def setUp(self):
        super(TestPointOfSale, self).setUp()
        self.pettyCashName = 'Piece of POS'
        self.pos = PointOfSale(name=self.pettyCashName)
        self.client = Client(person=Person(name='Cacho',
                                                surname='Moo'))
        self.category = CustomerAccount(name='FonCyT')
        self.account = MovementAccount(name='Impuestos', code="1")
        self.subAccount = MovementAccount(name='IVA', code="11",
                                          parent=self.account)
        self.trans = Transaction()
        self.qual = Qualifier()
        self.trans.track(self.pos, self.category, self.account, self.subAccount,
                         self.client, self.client.person)
        self.trans.save()
def main():
    t = Transaction()
    s = CRUDController.fromXmlFile('point_of_sale.xml')
    s.store = t
    a = Application()
    s.parent = Application()
    s.show()
    a.run()
Example #10
0
    def testNew(self):
        transaction = Transaction()
        documentTypes = DocumentType.values(transaction)

        printer = Printer(transaction=transaction)

        for documentNumber in printer.documentNumbers:
            self.assert_(documentNumber.documentType in documentTypes)
            self.assertEqual(documentNumber.number, '00001')
Example #11
0
class ReceiptWindow(cimarron.skin.WindowController):
    def __init__(self, **kw):
        super(ReceiptWindow, self).__init__(**kw)
        self.window.title = "Receipt Generation"
        self.trans = Transaction()
        self.target = Receipt(actualDate=today())
        self.trans.track(self.target)

        v = cimarron.skin.VBox(parent=self.window, expand=True, fill=True)
        h1 = cimarron.skin.HBox(parent=v, expand=False, fill=True)
        h2 = cimarron.skin.HBox(parent=v, expand=False, fill=False)
        v1 = cimarron.skin.VBox(parent=v)
        actionContainer = cimarron.skin.HBox(parent=v, expand=False, fill=True)

        columns = (cimarron.skin.Column(name="Name", attribute="name"),
                   cimarron.skin.Column(name="Surname", attribute="surname"))
        self.person = cimarron.skin.SearchEntry(parent=h1,
                                                cls=Person,
                                                searcher=self.trans,
                                                columns=columns,
                                                attribute="person")
        cimarron.skin.Label(parent=h2, text="Date:")
        self.actualDate = cimarron.skin.Entry(parent=h2,
                                              attribute="actualDate")

        cimarron.skin.Label(parent=h2, text="Amount:")
        self.amount = cimarron.skin.Entry(parent=h2, attribute="amount")

        cimarron.skin.Label(parent=v1,
                            text="Concept:",
                            expand=False,
                            fill=False)
        self.concept = cimarron.skin.MultiLine(parent=v1, attribute="concept")

        save = cimarron.skin.Button(parent=actionContainer,
                                    label="Save",
                                    onAction=self.save)
        discard = cimarron.skin.Button(parent=actionContainer,
                                       label="Discard",
                                       onAction=self.discard)
        self.refresh()

    def refresh(self):
        super(ReceiptWindow, self).refresh()
        for entry in self.person, self.amount, self.concept, self.actualDate:
            entry.newTarget(self.value)

    def save(self, *ignore):
        self.trans.save()

    def discard(self, *ignore):
        self.trans.discard()
        self.newTarget(Receipt(actualDate=today()))
        self.trans.track(self.target)
Example #12
0
 def setUp(self):
     super(TestAccountingEntry, self).setUp()
     self.trans = Transaction()
     ##customer
     self.customer = CustomerAccount(name="Juan Customer")
     
     self.acEntry = AccountingEntry( number=1, pos=PointOfSale(), customerAccount=self.customer)
     self.trans.track(self.acEntry)
     ##from
     self.debit = MovementAccount(name="Sales")
     ##to
     self.credit = MovementAccount(name="Petty Cash")
     
     self.amount = 175.5
     self.otherAmount = 180
     
     self.trans.track(self.debit)
     self.trans.track(self.credit)
     self.trans.track(self.customer)
class TestPointOfSale(testWithDatabase):
    def setUp(self):
        super(TestPointOfSale, self).setUp()
        self.pettyCashName = 'Piece of POS'
        self.pos = PointOfSale(name=self.pettyCashName)
        self.client = Client(subject=Person(name='Cacho',
                                                surname='Moo'))
        self.category = CustomerAccount(name='FonCyT')
        self.account = MovementAccount(name='Impuestos', code="1")
        self.subAccount = MovementAccount(name='IVA', code="11",
                                          parent=self.account)
        self.trans = Transaction()
        self.qual = Qualifier()
        self.trans.track(self.pos, self.category, self.account, self.subAccount,
                         self.client, self.client.subject)
        self.trans.save()

    def testRegisterDocument(self):
        self.pos.registerDocument(documentClass=Invoice,
                                  number='some number',
                                  type='X',
                                  detail='blah blah blah',
                                  amount=100,
                                  actualDate=now(),
                                  otherParty=self.client
                                  )
        self.trans.save()
    def testTotal(self):
        self.testRegisterDocument()
        self.assertEqual(self.pos.total(), 100)
Example #14
0
class TestPointOfSale(testWithDatabase):
    def setUp(self):
        super(TestPointOfSale, self).setUp()
        self.pettyCashName = 'Piece of POS'
        self.pos = PointOfSale(name=self.pettyCashName)
        self.client = Client(subject=Person(name='Cacho', surname='Moo'))
        self.category = CustomerAccount(name='FonCyT')
        self.account = MovementAccount(name='Impuestos', code="1")
        self.subAccount = MovementAccount(name='IVA',
                                          code="11",
                                          parent=self.account)
        self.trans = Transaction()
        self.qual = Qualifier()
        self.trans.track(self.pos, self.category, self.account,
                         self.subAccount, self.client, self.client.subject)
        self.trans.save()

    def testRegisterDocument(self):
        self.pos.registerDocument(documentClass=Invoice,
                                  number='some number',
                                  type='X',
                                  detail='blah blah blah',
                                  amount=100,
                                  actualDate=now(),
                                  otherParty=self.client)
        self.trans.save()

    def testTotal(self):
        self.testRegisterDocument()
        self.assertEqual(self.pos.total(), 100)
    def __init__(self, **kwargs):
        super(LoadPettyCashEntry, self).__init__(**kwargs)
        self.trans = Transaction()

        # it assured existence point of sale
        pointOfSale = self.trans.search('PointOfSale')
        if not pointOfSale:
            from pointOfSale import main as pofMain
            pofMain()
            pointOfSale = self.trans.search('PointOfSale')        
            if pointOfSale:
                #mensaje error, que estas haciendo
                pass
        
        self.pos = pointOfSale[0]
        self.buildUI()
 def setUp(self):
     super(TestAccountingEntry, self).setUp()
     self.trans = Transaction()
     ##customer
     self.customer = CustomerAccount(name="Juan Customer")
     
     self.acEntry = AccountingEntry( number=1, pos=PointOfSale(), customerAccount=self.customer)
     self.trans.track(self.acEntry)
     ##from
     self.debit = MovementAccount(name="Sales")
     ##to
     self.credit = MovementAccount(name="Petty Cash")
     
     self.amount = 175.5
     self.otherAmount = 180
     
     self.trans.track(self.debit)
     self.trans.track(self.credit)
     self.trans.track(self.customer)
Example #17
0
from fvl.cimarron.skin import CRUDController, Application
from fvl.luca.transaction import Transaction

t = Transaction()
s = CRUDController.fromXmlFile('person.xml')
s.store = t
a = Application()
s.parent = a
s.show()
a.run()
 def setUp(self):
     self.tr = Transaction()
     self.other_tr = Transaction()
Example #19
0
 def __init__(self, **kwargs):
     super(LoadPettyCashEntry, self).__init__(**kwargs)
     self.trans = Transaction()
     self.pos, = self.trans.search('PointOfSale')
     self.buildUI()
Example #20
0
class LoadPettyCashEntry(WindowController):
    def __init__(self, **kwargs):
        super(LoadPettyCashEntry, self).__init__(**kwargs)
        self.trans = Transaction()
        self.pos, = self.trans.search('PointOfSale')
        self.buildUI()

    def buildUI(self):
        self.window.title = 'Caja chica - Carga'
        v = VBox(parent=self.window)

        f0 = Frame(parent=v, label='Cuenta')
        h0 = HBox(parent=f0)
        right0 = VBox(parent=h0)
        columns = (Column(name='Nombre',
                          attribute='name',
                          operator=Qualifier.like), )
        self.account = SearchEntry(parent=right0,
                                   columns=columns,
                                   searcher=self.trans,
                                   cls=CustomerAccount)

        f1 = Frame(parent=v, label='Operacion')
        h1 = HBox(parent=f1)
        left1 = VBox(parent=h1)
        right1 = VBox(parent=h1)

        # Label(parent=left1, text='Fecha')
        # fecha = Entry(parent=right1)

        Label(parent=left1, text='Categoria')
        columns = (
            Column(name='Cod', attribute='code'),
            Column(name='Nombre', attribute='name', operator=Qualifier.like),
        )
        self.category = SearchEntry(parent=right1,
                                    columns=columns,
                                    searcher=self.trans,
                                    cls=MovementAccount)

        f2 = Frame(parent=v, label='Comprobante')
        h2 = HBox(parent=f2)
        left2 = VBox(parent=h2)
        right2 = VBox(parent=h2)

        Label(parent=left2, text='Tipo')
        columns = (Column(name='Nombre',
                          attribute='name',
                          operator=Qualifier.like), )
        self.docType = SearchEntry(parent=right2,
                                   columns=columns,
                                   searcher=DocumentType,
                                   onAction=self.setThirdLabel)

        Label(parent=left2, text='Numero')
        self.docNumber = Entry(parent=right2)

        Label(parent=left2, text='Fecha')
        self.docDate = Entry(parent=right2, emptyValue=now())
        self.docDate.commitValue(self.docDate.value)

        self.thirdLabel = Label(parent=left2)
        columns = (Column(name='Apellido',
                          attribute='person.surname',
                          operator=Qualifier.like), )
        self.otherParty = SearchEntry(parent=right2,
                                      columns=columns,
                                      searcher=self.trans)
        self.otherParty.disable()

        # f3 = Frame(parent=v, label='Montos')
        h3 = HBox(parent=v)

        # Label(parent=h3, text='Ingreso')
        # self.moneyIn = Entry(parent=h3)

        # Label(parent=h3, text='Egreso')
        # self.moneyOut = Entry(parent=h3)

        Label(parent=h3, text='Monto')
        self.amount = Entry(parent=h3)

        Label(parent=h3, text='Descripcion')
        self.description = Entry(parent=h3)

        h4 = HBox(parent=v)
        Button(parent=h4, label='Guardar', onAction=self.save)
        Button(parent=h4, label='Descartar')

    def setThirdLabel(self, *ignore):
        if self.docType.value:
            if self.docType.value['other']:
                self.thirdLabel.text = self.docType.value['other'].__name__
                self.otherParty.cls = self.docType.value['other']
                self.otherParty.enable()
            else:
                self.thirdLabel.text = "Documento interno"

    def save(self, *ignore):
        # build a document of the right kind
        # cls = self.docType.value['cls']
        # document = cls(amount=self.amount.value, number=self.docNumber.value,
        #                type=self.docType.value['type'], )
        # set the other side
        # document.setattr(self.docType.value['attr'], self.provider.value)
        cls = self.docType.value['cls']
        document = cls(number=self.docNumber.value,
                       type=self.docType.value['type'],
                       detail=self.description.value,
                       amount=self.amount.value,
                       actualDate=self.docDate.value)
        self.trans.track(document)
        document.pettyRegister(self.pos, self.otherParty.value,
                               self.category.value, self.account.value)
        # register w/ the trans!
        # save it
        self.trans.save()
 def __init__(self, **kwargs):
     super(LoadPettyCashEntry, self).__init__(**kwargs)
     self.trans = Transaction()
     self.pos ,= self.trans.search('PointOfSale')
     self.buildUI()
class LoadPettyCashEntry(WindowController):
    def __init__(self, **kwargs):
        super(LoadPettyCashEntry, self).__init__(**kwargs)
        self.trans = Transaction()
        self.pos ,= self.trans.search('PointOfSale')
        self.buildUI()
        
    def buildUI(self):
        self.window.title = 'Caja chica - Carga'
        v = VBox(parent=self.window)


        f0 = Frame(parent=v, label='Cuenta')
        h0 = HBox(parent=f0)
        right0 = VBox(parent=h0)
        columns= (Column(name='Nombre', attribute='name',
                         operator=Qualifier.like),)
        self.account = SearchEntry(parent=right0, columns=columns,
                                   searcher=self.trans, cls=CustomerAccount)


        f1 = Frame(parent=v, label='Operacion')
        h1 = HBox(parent=f1)
        left1 = VBox(parent=h1)
        right1 = VBox(parent=h1)

        # Label(parent=left1, text='Fecha')
        # fecha = Entry(parent=right1)
        
        Label(parent=left1, text='Categoria')
        columns= (Column(name='Cod', attribute='code'),
                  Column(name='Nombre', attribute='name',
                         operator=Qualifier.like),)
        self.category = SearchEntry(parent=right1, columns=columns,
                                    searcher=self.trans, cls=MovementAccount)


        f2 = Frame(parent=v, label='Comprobante')
        h2 = HBox(parent=f2)
        left2 = VBox(parent=h2)
        right2 = VBox(parent=h2)

        Label(parent=left2, text='Tipo')
        columns= (Column(name='Nombre', attribute='name',
                         operator=Qualifier.like),)
        self.docType = SearchEntry(parent=right2, columns=columns,
                                   searcher=DocumentType,
                                   onAction=self.setThirdLabel)

        Label(parent=left2, text='Numero')
        self.docNumber = Entry(parent=right2)

        Label(parent=left2, text='Fecha')
        self.docDate = Entry(parent=right2, emptyValue=now())
        self.docDate.commitValue(self.docDate.value)

        self.thirdLabel = Label(parent=left2)
        columns= (Column(name='Apellido', attribute='person.surname',
                         operator=Qualifier.like),)
        self.otherParty = SearchEntry(parent=right2, columns=columns,
                                      searcher=self.trans)
        self.otherParty.disable()


        # f3 = Frame(parent=v, label='Montos')
        h3 = HBox(parent=v)

        # Label(parent=h3, text='Ingreso')
        # self.moneyIn = Entry(parent=h3)

        # Label(parent=h3, text='Egreso')
        # self.moneyOut = Entry(parent=h3)

        Label(parent=h3, text='Monto')
        self.amount = Entry(parent=h3)

        Label(parent=h3, text='Descripcion')
        self.description = Entry(parent=h3)


        h4 = HBox(parent=v)
        Button(parent=h4, label='Guardar', onAction=self.save)
        Button(parent=h4, label='Descartar')

    def setThirdLabel(self, *ignore):
        if self.docType.value:
            if self.docType.value['other']:
                self.thirdLabel.text = self.docType.value['other'].__name__
                self.otherParty.cls = self.docType.value['other']
                self.otherParty.enable()
            else:
                self.thirdLabel.text = "Documento interno"
    

    def save(self, *ignore):
        # build a document of the right kind
        # cls = self.docType.value['cls']
        # document = cls(amount=self.amount.value, number=self.docNumber.value,
        #                type=self.docType.value['type'], )
        # set the other side
        # document.setattr(self.docType.value['attr'], self.provider.value)
        cls = self.docType.value['cls']
        document = cls(number=self.docNumber.value,
                       type=self.docType.value['type'],
                       detail=self.description.value,
                       amount=self.amount.value,
                       actualDate=self.docDate.value)
        self.trans.track(document)
        document.pettyRegister(self.pos,
                               self.otherParty.value,
                               self.category.value,
                               self.account.value)
        # register w/ the trans!
        # save it
        self.trans.save()
Example #23
0
class TestAccountingEntry(testWithDatabase):
    def setUp(self):
        super(TestAccountingEntry, self).setUp()
        self.trans = Transaction()
        ##customer
        self.customer = CustomerAccount(name="Juan Customer")
        
        self.acEntry = AccountingEntry( number=1, pos=PointOfSale(), customerAccount=self.customer)
        self.trans.track(self.acEntry)
        ##from
        self.debit = MovementAccount(name="Sales")
        ##to
        self.credit = MovementAccount(name="Petty Cash")
        
        self.amount = 175.5
        self.otherAmount = 180
        
        self.trans.track(self.debit)
        self.trans.track(self.credit)
        self.trans.track(self.customer)

    def testAddEntryDebit(self):
        """
        Checks if all the accounting entry has been made with the correct
        movements
        """
        self.acEntry.debit(amount=self.amount, account=self.debit)
        qual = Qualifier()

        a = self.trans.search("Movement", qual.entry.number.equal(self.acEntry.number))

        self.assertEqual(a[0].entry,self.acEntry)
        self.assertEqual(a[0].operation,0)
        self.assertEqual(a[0].account,self.debit)


    def testAddEntryCredit(self):
        self.acEntry.credit(amount=self.amount, account=self.credit)
        qual = Qualifier()

        a = self.trans.search("Movement", qual.entry.number.equal(
                              self.acEntry.number))

        self.assertEqual(a[0].entry, self.acEntry)
        self.assertEqual(a[0].operation, 1)
        self.assertEqual(a[0].account, self.credit)

    def testBalanceIsRight(self): 
        self.acEntry.debit(amount=self.amount, account=self.debit)
        self.acEntry.credit(amount=self.amount, account=self.credit)

        balance = self.acEntry.balance()
        
        self.assertEqual(balance, 0.0)


    def testBalanceIsWrongNegative(self):
        self.acEntry.debit(amount=self.amount, account=self.debit)
        self.acEntry.credit(amount=self.otherAmount, account=self.credit)

        balance = self.acEntry.balance()

        self.assert_(balance < 0)

    def testBalanceIsWrongPositive(self):
        self.acEntry.debit(amount=self.otherAmount, account=self.debit)
        self.acEntry.credit(amount=self.amount, account=self.credit)

        balance = self.acEntry.balance()

        self.assert_(balance > 0)

    def testDebitSum(self):
        self.acEntry.debit(amount=self.otherAmount, account=self.debit)
        self.acEntry.debit(amount=self.otherAmount, account=self.debit)
        self.acEntry.debit(amount=self.otherAmount, account=self.debit)

        self.assertEqual(self.otherAmount * 3, self.acEntry.debitSum())
    def testCreditSum(self):
        self.acEntry.credit(amount=self.otherAmount, account=self.credit)
        self.acEntry.credit(amount=self.otherAmount, account=self.credit)
        self.acEntry.credit(amount=self.otherAmount, account=self.credit)

        self.assertEqual(self.otherAmount * 3, self.acEntry.creditSum())
class LoadPettyCashEntry(WindowController):
    def __init__(self, **kwargs):
        super(LoadPettyCashEntry, self).__init__(**kwargs)
        self.trans = Transaction()

        # it assured existence point of sale
        pointOfSale = self.trans.search('PointOfSale')
        if not pointOfSale:
            from pointOfSale import main as pofMain
            pofMain()
            pointOfSale = self.trans.search('PointOfSale')        
            if pointOfSale:
                #mensaje error, que estas haciendo
                pass
        
        self.pos = pointOfSale[0]
        self.buildUI()
        
    def buildUI(self):
        self.window.title = 'Caja chica - Carga: "' + self.pos.name +'"'
        v = VBox(parent=self.window)
        f0 = Frame(parent=v, label='Cuenta')
        h0 = HBox(parent=f0)
        right0 = VBox(parent=h0)
        columns= (Column(name='Nombre', attribute='name',
                         operator=Qualifier.like),)
        self.account = SearchEntry(parent=right0, columns=columns,
                                   searcher=self.trans, cls=CustomerAccount)


        f1 = Frame(parent=v, label='Operacion')
        h1 = HBox(parent=f1)
        left1 = VBox(parent=h1)
        right1 = VBox(parent=h1)

        # Label(parent=left1, text='Fecha')
        # fecha = Entry(parent=right1)
        
        Label(parent=left1, text='Categoria')
        columns= (Column(name='Cod', attribute='code'),
                  Column(name='Nombre', attribute='name',
                         operator=Qualifier.like),)
        self.category = SearchEntry(parent=right1, columns=columns,
                                    searcher=self.trans, cls=MovementAccount)


        f2 = Frame(parent=v, label='Comprobante')
        h2 = HBox(parent=f2)
        left2 = VBox(parent=h2)
        right2 = VBox(parent=h2)

        Label(parent=left2, text='Tipo')
        columns= (Column(name='Nombre', attribute='name',
                         operator=Qualifier.like),)
        self.docType = SearchEntry(parent=right2, columns=columns,
                                   searcher=DocumentType,
                                   onAction=self.setThirdLabel)

        Label(parent=left2, text='Numero')
        self.docNumber = Entry(parent=right2)

        Label(parent=left2, text='Fecha')
        self.docDate = Entry(parent=right2, emptyValue=now())
        self.docDate.commitValue(self.docDate.value)

        self.thirdLabel = Label(parent=left2)
        columns= (Column(name='Apellido', attribute='person.surname',
                         operator=Qualifier.like),)
        self.otherParty = SearchEntry(parent=right2, columns=columns,
                                      searcher=self.trans)
        self.otherParty.disable()


        # f3 = Frame(parent=v, label='Montos')
        h3 = HBox(parent=v)

        # Label(parent=h3, text='Ingreso')
        # self.moneyIn = Entry(parent=h3)

        # Label(parent=h3, text='Egreso')
        # self.moneyOut = Entry(parent=h3)

        Label(parent=h3, text='Monto')
        self.amount = Entry(parent=h3)

        Label(parent=h3, text='Descripcion')
        self.description = Entry(parent=h3)


        h4 = HBox(parent=v)
        Button(parent=h4, label='Guardar', onAction=self.save)
        Button(parent=h4, label='Descartar', onAction=self.discard)

    def setThirdLabel(self, *ignore):
        if self.docType.value:
            if self.docType.value['other']:
                self.thirdLabel.text = self.docType.value['other'].__name__
                self.otherParty.cls = self.docType.value['other']
                self.otherParty.enable()
            else:
                self.thirdLabel.text = "Documento interno"
    

    def save(self, *ignore):
        # build a document of the right kind
        # cls = self.docType.value['cls']
        # document = cls(amount=self.amount.value, number=self.docNumber.value,
        #                type=self.docType.value['type'], )
        # set the other side
        # document.setattr(self.docType.value['attr'], self.provider.value)
        cls = self.docType.value['cls']
        document = cls(number=self.docNumber.value,
                       type=self.docType.value['type'],
                       detail=self.description.value,
                       amount=self.amount.value,
                       actualDate=self.docDate.value)
        self.trans.track(document)
        document.pettyRegister(self.pos,
                               self.otherParty.value,
                               self.category.value,
                               self.account.value)
        # register w/ the trans!
        # save it
        self.trans.save()

    def discard(self, *ignore):
        self.trans.discard()
        for i in self.__dict__:
            if isinstance(self.__dict__[i],Entry) or isinstance(self.__dict__[i],SearchEntry):
                if hasattr(self.__dict__[i],'emptyValue'):
                    self.__dict__[i].commitValue(self.__dict__[i].emptyValue)
                else:
                    self.__dict__[i].commitValue(None)
                    self.__dict__[i].refresh()

        #this is made apart beacause is not generic, thirdLabel is the only
        #label in self that changes and otherParty is the only widget Disabled
        self.thirdLabel.text = ''
        self.otherParty.disable()
Example #25
0
class ReceiptGui(WindowController):
    def __init__(self, **kwargs):
        super(ReceiptGui, self).__init__(**kwargs)
        self.trans = Transaction()
        self.pos ,= self.trans.search('PointOfSale')
        self.buildUI()

    def buildUI(self):
        self.window.title = 'Generacion de Recibo'

        v1 = VBox(parent=self.window, expand=True, fill=True)
        h0 = HBox(parent=v1, expand=False, fill=True)
        v0left = VBox(parent=h0, expand=False, fill=True)
        v0right = VBox(parent=h0, expand=False, fill=True)
        v2 = VBox(parent=v1)
        actionContainer = HBox(parent=v1, expand=False, fill=True)

        Label(parent=v0left, text='Cuenta Contable:')
        columns= (Column(name='Cod', attribute='code'),
                  Column(name='Nombre', attribute='name',
                         operator=Qualifier.like),)
        self.category = SearchEntry(parent=v0right, columns=columns,
                                    searcher=self.trans, cls=MovementAccount)

        Label(parent=v0left, text='Cliente:')
        columns = (Column(name='Nombre', attribute='person.name',
                          operator=Qualifier.like),
                   Column(name='Apellido', attribute='person.surname',
                          operator=Qualifier.like),)
        self.otherParty = SearchEntry(parent=v0right, cls=Client,
                                      searcher=self.trans,
                                      columns=columns)


        Label(parent=v0left, text='Numero:')
        self.docNumber = Entry(parent=v0right)

        Label(parent=v0left, text='Fecha:')
        self.actualDate = Entry(parent=v0right,emptyValue=now())
        self.actualDate.commitValue(self.actualDate.value)

        Label(parent=v0left, text='Monto:')
        self.amount = Entry(parent=v0right)
        
        Label(parent=v2, text='Concepto:', expand=False, fill=False)
        self.concept = MultiLine(parent=v2)
        
        save = Button(parent=actionContainer, label='Guardar',
                      onAction=self.save)

        discard = Button(parent=actionContainer, label='Descartar',
                         onAction=self.discard)


    def save(self, *ignore):
        receipt = Receipt(number=self.docNumber.value,
                          type='X',
                          detail=self.concept.value,
                          amount=self.amount.value,
                          actualDate=self.actualDate.value)
        self.trans.track(receipt)
        #we use pettyRegister beacause we store the same data that pettyCash
        #doing a receipt
        receipt.pettyRegister(self.pos,
                              self.otherParty.value,
                              self.category.value,
                              None)
                             # self.account.value) this goes instead
                             #of the above none, do we want this data?
        self.trans.save()

    def discard(self, *ignore):
        self.trans.discard()
        for i in self.__dict__:
            if isinstance(self.__dict__[i],Entry) or isinstance(self.__dict__[i],SearchEntry) or isinstance(self.__dict__[i],MultiLine):
                if hasattr(self.__dict__[i],'emptyValue'):
                    self.__dict__[i].commitValue(self.__dict__[i].emptyValue)
                else:
                    self.__dict__[i].commitValue(None)
                    self.__dict__[i].refresh()
class LoadPettyCashEntry(WindowController):
    def __init__(self, **kwargs):
        super(LoadPettyCashEntry, self).__init__(**kwargs)
        self.trans = Transaction()

        # it assured existence point of sale
        pointOfSale = self.trans.search('PointOfSale')
        if not pointOfSale:
            from pointOfSale import main as pofMain
            pofMain()
            pointOfSale = self.trans.search('PointOfSale')
            if pointOfSale:
                #mensaje error, que estas haciendo
                pass

        self.pos = pointOfSale[0]
        self.buildUI()

    def buildUI(self):
        self.window.title = 'Caja chica - Carga: "' + self.pos.name + '"'
        v = VBox(parent=self.window)
        f0 = Frame(parent=v, label='Cuenta')
        h0 = HBox(parent=f0)
        right0 = VBox(parent=h0)
        columns = (Column(name='Nombre',
                          attribute='name',
                          operator=Qualifier.like), )
        self.account = SearchEntry(parent=right0,
                                   columns=columns,
                                   searcher=self.trans,
                                   cls=CustomerAccount)

        f1 = Frame(parent=v, label='Operacion')
        h1 = HBox(parent=f1)
        left1 = VBox(parent=h1)
        right1 = VBox(parent=h1)

        # Label(parent=left1, text='Fecha')
        # fecha = Entry(parent=right1)

        Label(parent=left1, text='Categoria')
        columns = (
            Column(name='Cod', attribute='code'),
            Column(name='Nombre', attribute='name', operator=Qualifier.like),
        )
        self.category = SearchEntry(parent=right1,
                                    columns=columns,
                                    searcher=self.trans,
                                    cls=MovementAccount)

        f2 = Frame(parent=v, label='Comprobante')
        h2 = HBox(parent=f2)
        left2 = VBox(parent=h2)
        right2 = VBox(parent=h2)

        Label(parent=left2, text='Tipo')
        columns = (Column(name='Nombre',
                          attribute='name',
                          operator=Qualifier.like), )
        self.docType = SearchEntry(parent=right2,
                                   columns=columns,
                                   searcher=DocumentType,
                                   onAction=self.setThirdLabel)

        Label(parent=left2, text='Numero')
        self.docNumber = Entry(parent=right2)

        Label(parent=left2, text='Fecha')
        self.docDate = Entry(parent=right2, emptyValue=now())
        self.docDate.commitValue(self.docDate.value)

        self.thirdLabel = Label(parent=left2)
        columns = (Column(name='Apellido',
                          attribute='person.surname',
                          operator=Qualifier.like), )
        self.otherParty = SearchEntry(parent=right2,
                                      columns=columns,
                                      searcher=self.trans)
        self.otherParty.disable()

        # f3 = Frame(parent=v, label='Montos')
        h3 = HBox(parent=v)

        # Label(parent=h3, text='Ingreso')
        # self.moneyIn = Entry(parent=h3)

        # Label(parent=h3, text='Egreso')
        # self.moneyOut = Entry(parent=h3)

        Label(parent=h3, text='Monto')
        self.amount = Entry(parent=h3)

        Label(parent=h3, text='Descripcion')
        self.description = Entry(parent=h3)

        h4 = HBox(parent=v)
        Button(parent=h4, label='Guardar', onAction=self.save)
        Button(parent=h4, label='Descartar', onAction=self.discard)

    def setThirdLabel(self, *ignore):
        if self.docType.value:
            if self.docType.value['other']:
                self.thirdLabel.text = self.docType.value['other'].__name__
                self.otherParty.cls = self.docType.value['other']
                self.otherParty.enable()
            else:
                self.thirdLabel.text = "Documento interno"

    def save(self, *ignore):
        # build a document of the right kind
        # cls = self.docType.value['cls']
        # document = cls(amount=self.amount.value, number=self.docNumber.value,
        #                type=self.docType.value['type'], )
        # set the other side
        # document.setattr(self.docType.value['attr'], self.provider.value)
        cls = self.docType.value['cls']
        document = cls(number=self.docNumber.value,
                       type=self.docType.value['type'],
                       detail=self.description.value,
                       amount=self.amount.value,
                       actualDate=self.docDate.value)
        self.trans.track(document)
        document.pettyRegister(self.pos, self.otherParty.value,
                               self.category.value, self.account.value)
        # register w/ the trans!
        # save it
        self.trans.save()

    def discard(self, *ignore):
        self.trans.discard()
        for i in self.__dict__:
            if isinstance(self.__dict__[i], Entry) or isinstance(
                    self.__dict__[i], SearchEntry):
                if hasattr(self.__dict__[i], 'emptyValue'):
                    self.__dict__[i].commitValue(self.__dict__[i].emptyValue)
                else:
                    self.__dict__[i].commitValue(None)
                    self.__dict__[i].refresh()

        #this is made apart beacause is not generic, thirdLabel is the only
        #label in self that changes and otherParty is the only widget Disabled
        self.thirdLabel.text = ''
        self.otherParty.disable()
Example #27
0
 def __init__(self, **kwargs):
     super(ReceiptGui, self).__init__(**kwargs)
     self.trans = Transaction()
     self.pos ,= self.trans.search('PointOfSale')
     self.buildUI()
class TestAccountingEntry(testWithDatabase):
    def setUp(self):
        super(TestAccountingEntry, self).setUp()
        self.trans = Transaction()
        ##customer
        self.customer = CustomerAccount(name="Juan Customer")
        
        self.acEntry = AccountingEntry( number=1, pos=PointOfSale(), customerAccount=self.customer)
        self.trans.track(self.acEntry)
        ##from
        self.debit = MovementAccount(name="Sales")
        ##to
        self.credit = MovementAccount(name="Petty Cash")
        
        self.amount = 175.5
        self.otherAmount = 180
        
        self.trans.track(self.debit)
        self.trans.track(self.credit)
        self.trans.track(self.customer)

    def testAddEntryDebit(self):
        """
        Checks if all the accounting entry has been made with the correct
        movements
        """
        self.acEntry.debit(amount=self.amount, account=self.debit)
        qual = Qualifier()

        a = self.trans.search("Movement", qual.entry.number.equal(self.acEntry.number))

        self.assertEqual(a[0].entry,self.acEntry)
        self.assertEqual(a[0].operation,0)
        self.assertEqual(a[0].account,self.debit)


    def testAddEntryCredit(self):
        self.acEntry.credit(amount=self.amount, account=self.credit)
        qual = Qualifier()

        a = self.trans.search("Movement", qual.entry.number.equal(
                              self.acEntry.number))

        self.assertEqual(a[0].entry, self.acEntry)
        self.assertEqual(a[0].operation, 1)
        self.assertEqual(a[0].account, self.credit)

    def testBalanceIsRight(self): 
        self.acEntry.debit(amount=self.amount, account=self.debit)
        self.acEntry.credit(amount=self.amount, account=self.credit)

        balance = self.acEntry.balance()
        
        self.assertEqual(balance, 0.0)


    def testBalanceIsWrongNegative(self):
        self.acEntry.debit(amount=self.amount, account=self.debit)
        self.acEntry.credit(amount=self.otherAmount, account=self.credit)

        balance = self.acEntry.balance()

        self.assertTrue(balance < 0)

    def testBalanceIsWrongPositive(self):
        self.acEntry.debit(amount=self.otherAmount, account=self.debit)
        self.acEntry.credit(amount=self.amount, account=self.credit)

        balance = self.acEntry.balance()

        self.assertTrue(balance > 0)

    def testDebitSum(self):
        self.acEntry.debit(amount=self.otherAmount, account=self.debit)
        self.acEntry.debit(amount=self.otherAmount, account=self.debit)
        self.acEntry.debit(amount=self.otherAmount, account=self.debit)

        self.assertEqual(self.otherAmount * 3, self.acEntry.debitSum())
    def testCreditSum(self):
        self.acEntry.credit(amount=self.otherAmount, account=self.credit)
        self.acEntry.credit(amount=self.otherAmount, account=self.credit)
        self.acEntry.credit(amount=self.otherAmount, account=self.credit)

        self.assertEqual(self.otherAmount * 3, self.acEntry.creditSum())