Example #1
0
    def pay_membership_fee(self, member, year, date=None):
        """
        Pay the annual membership fee for this GAS member.
        
        Fee amount is determined by the ``gas.membership_fee`` attribute.
        
        If the gas member belongs to another ``gas``, 
        a ``MalformedTransaction`` exception is raised.
        """
        gas = self.subject.instance
        if member.gas != gas:
            raise MalformedTransaction(ugettext("A person can't pay membership fees to a GAS that (s)he is not member of"))

        person = member.person
        source_account = self.system['/members/' + person.uid]
        target_account = self.system['/cash']

        amount = gas.membership_fee
        description = ugettext("year %(year)s --> %(person)s") % {'person': person.report_name, 'year': year,}
        issuer = self.subject
        if not date:
            date = datetime.datetime.now()  #_date.today

        transaction = register_simple_transaction(source_account, target_account, 
            amount, description, issuer, date, kind=GasAccountingProxy.MEMBERSHIP_FEE
        )
        transaction.add_references([person, gas])
Example #2
0
    def withdraw_from_member_account(self, member, new_amount, refs, order, date=None):
        """
        Withdraw a given amount ``new_amount`` of money from the account of a member
        of this GAS and bestow it to the GAS's cash.
        
        If this operation would make that member's account negative, raise a warning.

        If ``member`` is not a member of this GAS, a ``MalformedTransaction`` exception is raised.
        
        References for this transaction may be passed as the ``refs`` argument
        (e.g. a list of GAS member orders this withdrawal is related to).
        """
        # Only for test Control if yet exist some transaction for this refs.
        #computed_amount, existing_txs = self.get_amount_by_gas_member(member, order)
        #log.debug("ACCOUNTING %(computed_amount)s %(existing_txs)s" % {'computed_amount': computed_amount, 'existing_txs': existing_txs})

        gas = self.subject.instance
        if member.gas != gas:
            raise MalformedTransaction(ugettext("A GAS can withdraw only from its members' accounts"))
        source_account = self.system['/members/' + member.person.uid]
        target_account = self.system['/cash']
        #'gas': gas.id_in_des,
        #WAS: description = "%(person)s %(order)s" % {'person': member.person.report_name, 'order': order.report_name}
        #NOTE LF: person is a repetition of gasmember person bound
        description = order.common_name
        issuer = self.subject
        log.debug("registering transaction: issuer=%s descr=%s source=%s target=%s" % (
            issuer, description, source_account, target_account
        ))
        transaction = register_simple_transaction(source_account, target_account, new_amount, 
            description, issuer, date=date, kind=GasAccountingProxy.GAS_WITHDRAWAL
        )
        if refs:
            transaction.add_references(refs)
Example #3
0
 def withdraw_from_member_account(self, member, amount, refs=None):
     """
     Withdraw a given amount ``amount`` of money from the account of a member
     of this GAS and bestow it to the GAS's cash.
     
     If this operation would make that member's account negative, raise a warning.
     
     If ``member`` is not a member of this GAS, a ``MalformedTransaction`` exception is raised.
     
     References for this transaction may be passed as the ``refs`` argument
     (e.g. a list of GAS member orders this withdrawal is related to).
     """
     # TODO: if this operation would make member's account negative, raise a warning
     gas = self.subject.instance
     if not member.person.is_member(gas):
         raise MalformedTransaction(
             "A GAS can withdraw only from its members' accounts")
     source_account = self.system['/members/' + member.uid]
     target_account = self.system['/cash']
     description = "Withdrawal from member %(member)s account by GAS %(gas)s" % {
         'gas': gas,
         'member': member,
     }
     issuer = gas
     transaction = register_simple_transaction(source_account,
                                               target_account,
                                               amount,
                                               description,
                                               issuer,
                                               date=None,
                                               kind='GAS_WITHDRAWAL')
     if refs:
         transaction.add_references(refs)
Example #4
0
    def withdraw_from_member_account(self,
                                     member,
                                     new_amount,
                                     refs,
                                     order,
                                     date=None,
                                     comment=""):
        """
        Withdraw a given amount ``new_amount`` of money from the account of a member
        of this GAS and bestow it to the GAS's cash.
        
        If this operation would make that member's account negative, raise a warning.

        If ``member`` is not a member of this GAS, a ``MalformedTransaction`` exception is raised.
        
        References for this transaction may be passed as the ``refs`` argument
        (e.g. a list of GAS member orders this withdrawal is related to).
        """
        # Only for test Control if yet exist some transaction for this refs.
        #computed_amount, existing_txs = self.get_amount_by_gas_member(member, order)
        #log.debug("ACCOUNTING %(computed_amount)s %(existing_txs)s" % {'computed_amount': computed_amount, 'existing_txs': existing_txs})

        gas = self.subject.instance
        if member.gas != gas:
            raise MalformedTransaction(
                ugettext("A GAS can withdraw only from its members' accounts"))
        source_account = self.system['/members/' + member.person.uid]
        target_account = self.system['/cash']
        #'gas': gas.id_in_des,
        #WAS: description = "%(person)s %(order)s" % {'person': member.person.report_name, 'order': order.report_name}
        #NOTE LF: person is a repetition of gasmember person bound
        description = order.common_name
        if comment:
            description = u"%s (%s)" % (description, comment)
        issuer = self.subject
        log.debug(
            "registering transaction: issuer=%s descr=%s source=%s target=%s" %
            (issuer, description, source_account, target_account))
        transaction = register_simple_transaction(
            source_account,
            target_account,
            new_amount,
            description,
            issuer,
            date=date,
            kind=GasAccountingProxy.GAS_WITHDRAWAL)
        if refs:
            transaction.add_references(refs)
Example #5
0
    def pay_membership_fee(self, member, year, date=None):
        """
        Pay the annual membership fee for this GAS member.
        
        Fee amount is determined by the ``gas.membership_fee`` attribute.
        
        If the gas member belongs to another ``gas``, 
        a ``MalformedTransaction`` exception is raised.
        """
        gas = self.subject.instance
        if member.gas != gas:
            raise MalformedTransaction(
                ugettext(
                    "A person can't pay membership fees to a GAS that (s)he is not member of"
                ))

        person = member.person
        source_account = self.system['/members/' + person.uid]
        target_account = self.system['/cash']

        amount = gas.membership_fee
        description = ugettext("year %(year)s --> %(person)s") % {
            'person': person.report_name,
            'year': year,
        }
        issuer = self.subject
        if not date:
            date = datetime.datetime.now()  #_date.today

        transaction = register_simple_transaction(
            source_account,
            target_account,
            amount,
            description,
            issuer,
            date,
            kind=GasAccountingProxy.MEMBERSHIP_FEE)
        transaction.add_references([person, gas])
 def withdraw_from_member_account(self, member, amount, refs=None):
     """
     Withdraw a given amount ``amount`` of money from the account of a member
     of this GAS and bestow it to the GAS's cash.
     
     If this operation would make that member's account negative, raise a warning.
     
     If ``member`` is not a member of this GAS, a ``MalformedTransaction`` exception is raised.
     
     References for this transaction may be passed as the ``refs`` argument
     (e.g. a list of GAS member orders this withdrawal is related to).
     """
     # TODO: if this operation would make member's account negative, raise a warning
     gas = self.subject.instance
     if not member.person.is_member(gas):
         raise MalformedTransaction("A GAS can withdraw only from its members' accounts")
     source_account = self.system['/members/' + member.uid]
     target_account = self.system['/cash']
     description = "Withdrawal from member %(member)s account by GAS %(gas)s" % {'gas': gas, 'member': member,}
     issuer = gas 
     transaction = register_simple_transaction(source_account, target_account, amount, description, issuer, date=None, kind='GAS_WITHDRAWAL')
     if refs:
         transaction.add_references(refs)