Exemple #1
0
    def get(self):
        from units.documents import create_context, create_bill, create_pdf_bill
        from models.requisites import RequisitesDB
        from datetime import datetime
        from units.export import send_mail_by_queue

        sender = RequisitesDB.get_one({'inn': '772160030650'})
        recipient = RequisitesDB.get_one({'inn': '7729687715'})
        bill_num = 156
        date = datetime.now()
        items = [{
            'name': u'Услуги по поддержке сайта за май 2014г',
            'unit': u'мес.',
            'count': 1,
            'price': 10000
        }, {
            'name': u'Оплата хостинга',
            'unit': u'мес.',
            'count': 6,
            'price': 250
        }, {
            'name': u'За красивые глаза',
            'unit': u'шт.',
            'count': 2,
            'price': 666.6
        }]

        context = create_context(sender, recipient, bill_num, date, items)
        self.write(create_bill(context))
        self.xsrf_token
        self.flush()
        create_pdf_bill(context, 'asdf.pdf')
        send_mail_by_queue('*****@*****.**', u'Привет!',
                           create_bill(context))
Exemple #2
0
 def get(self):
     from units.documents import create_context, create_bill, create_pdf_bill
     from models.requisites import RequisitesDB
     from datetime import datetime
     from units.export import send_mail_by_queue
     
     sender = RequisitesDB.get_one({'inn': '772160030650'})
     recipient = RequisitesDB.get_one({'inn': '7729687715'})
     bill_num = 156
     date = datetime.now()
     items = [{  'name': u'Услуги по поддержке сайта за май 2014г',
                 'unit': u'мес.',      
                 'count': 1,
                 'price': 10000  },
              {  'name': u'Оплата хостинга',
                 'unit': u'мес.',      
                 'count': 6,
                 'price': 250  },
              {  'name': u'За красивые глаза',
                 'unit': u'шт.',      
                 'count': 2,
                 'price': 666.6  }]
     
     context = create_context(sender, recipient, bill_num, date, items)
     self.write(create_bill(context))
     self.xsrf_token
     self.flush()
     create_pdf_bill(context, 'asdf.pdf')
     send_mail_by_queue('*****@*****.**', u'Привет!', create_bill(context))
Exemple #3
0
 def post(self, *args, **kwargs):
     recipient_form = RequisitesForm(self.request.arguments)
     bill_content_form = BillContentForm(self.request.arguments)
     if not (recipient_form.validate() and bill_content_form.validate()):
         if not recipient_form.validate():
             logging.debug(u'Форма получателя не валидна.')
         if not bill_content_form.validate():
             logging.debug(u'Форма содержимого не валидна.')
         self.context.update({'title': u'Создание счёта',
                              'module_name': url_base,
                              'sender': RequisitesDB.get_one({'inn': '772160030650'}),
                              'recipient': recipient_form,
                              'bill_content': bill_content_form,
                              'bill_num': Counter.next_key('bill'),
                              'date': datetime.now(),
                              })
         self.render(tmpl('create'))
     else:
         req = RequisitesDB.create_from_data(recipient_form.data)
         contr = ContactorDB.create(self.user_id, req['_id'])['_id']
         items_from_form = bill_content_form.data['items']
         items = []
         for i in items_from_form:
             if i['count'] > 0.0 and i['name']:
                 items.append(i)
         cont = ContentDB.create(items)['_id']
         bill_num = Counter.next_key('bill')
         date = datetime.now()
         sender_user = UserDB.get_one({'id': 1})
         bill = BillDB.create_simple(sender_user['_id'], contr, cont, bill_num, date)
         logging.debug(u'Счёт сохранен.')
         self.redirect('/%s/full/%s' % (url_base, bill['_id']))
Exemple #4
0
 def get(self):
     
     self.context.update({'title': u'Создание счёта',
                          'module_name': url_base,
                          'sender': RequisitesDB.get_one({'inn': '772160030650'}),
                          'recipient': RequisitesForm(),
                          'bill_content': BillContentForm(),
                          'bill_num': Counter.next_key('bill'),
                          'date': datetime.now(),
                          })
     self.render(tmpl('create'))
Exemple #5
0
    def get(self):

        self.context.update({
            'title':
            u'Создание счёта',
            'module_name':
            url_base,
            'sender':
            RequisitesDB.get_one({'inn': '772160030650'}),
            'recipient':
            RequisitesForm(),
            'bill_content':
            BillContentForm(),
            'bill_num':
            Counter.next_key('bill'),
            'date':
            datetime.now(),
        })
        self.render(tmpl('create'))
Exemple #6
0
 def post(self, *args, **kwargs):
     recipient_form = RequisitesForm(self.request.arguments)
     bill_content_form = BillContentForm(self.request.arguments)
     if not (recipient_form.validate() and bill_content_form.validate()):
         if not recipient_form.validate():
             logging.debug(u'Форма получателя не валидна.')
         if not bill_content_form.validate():
             logging.debug(u'Форма содержимого не валидна.')
         self.context.update({
             'title':
             u'Создание счёта',
             'module_name':
             url_base,
             'sender':
             RequisitesDB.get_one({'inn': '772160030650'}),
             'recipient':
             recipient_form,
             'bill_content':
             bill_content_form,
             'bill_num':
             Counter.next_key('bill'),
             'date':
             datetime.now(),
         })
         self.render(tmpl('create'))
     else:
         req = RequisitesDB.create_from_data(recipient_form.data)
         contr = ContactorDB.create(self.user_id, req['_id'])['_id']
         items_from_form = bill_content_form.data['items']
         items = []
         for i in items_from_form:
             if i['count'] > 0.0 and i['name']:
                 items.append(i)
         cont = ContentDB.create(items)['_id']
         bill_num = Counter.next_key('bill')
         date = datetime.now()
         sender_user = UserDB.get_one({'id': 1})
         bill = BillDB.create_simple(sender_user['_id'], contr, cont,
                                     bill_num, date)
         logging.debug(u'Счёт сохранен.')
         self.redirect('/%s/full/%s' % (url_base, bill['_id']))
Exemple #7
0
 def name(self):
     try:
         return RequisitesDB.get_one({'_id': self['requisites']}, ['name'])['name']
     except:
         logging.error(u'Ошибка с целостностью данных: нет реквизитов для user_id = %s' % self['_id'])
         return 'ERROR'