def handle_label(self, source, **options): """Create a bundled order""" try: bundle = simplest_bundle(source) if bundle: log_action(bundle, 'ADDITION', message=u'Bündel für %s erzeugt: %s, %d orders' % (source, bundle.pk, bundle.orders.count())) except Exception, ex: print "Fehler beim Buendeln von Auftraegen, Exception %s" % ex
def handle(self, **options): """Transfer bundled orders""" bundles = BundledOrder.objects.filter(status='bundled') for bundle in bundles: try: result = bundle.transfer() except Exception, exc: bundle.status = 'erroneous' bundle.save() log_action(bundle, 'CHANGE', message=str(exc)) print "Fehler beim Transfer von Buendeln, Exception %s" % exc raise bundle.status = 'transfered' bundle.save()
def test_log_action(self): """Test the log_action function.""" # test the most simplest form. log_action(self.place1, CHANGE) log_action(self.place2, ADDITION, self.user2) log_action(self.place2, ADDITION, self.user2, "this is a message") log_action(self.place2, ADDITION, self.user2, "this is a message", u"this is the repr")
def handle_label(self, customer, **options): """Create an invoice""" orders = Order.objects.filter(customer=customer, status='shipped') if orders.count() == 0: print "No orders for '%s' with status 'shipped'" % (customer) return guid = str(uuid4()) positionen = [] for order in orders: if order.additional_expenses: positionen.append(ic.orders.StapelPosition('%s-%03d' % (guid, len(positionen)), 1, artnr=99998, infotext_kunde=u'Dropshipping-Gebühren (Auftrag %s)' % order.designator, preis=huTools.monetary.euro_to_cent(huTools.monetary.netto(order.additional_expenses)))) for orderline in order.orderlines(): position = ic.orders.StapelPosition( '%s-%03d' % (guid, len(positionen)), orderline['menge'], artnr=orderline['artnr'], infotext_kunde='%s (Auftrag %s)' % (orderline['name'], order.designator), preis=huTools.monetary.euro_to_cent(huTools.monetary.netto(orderline['preis']))) positionen.append(position) log_action(order, 'CHANGE', message=u"Auftrag zur Rechnung '%s' hinzugefügt" % guid) auftrag = ic.orders.StapelAuftrag(guid, customer, positionen, erfasst_von='RobotRock', versandkosten=0, auftragsart='SF', anlieferdatum_von=datetime.date.today(), anlieferdatum_bis=datetime.date.today()) ic.orders.send_order(auftrag.serialize()) orders.update(status='charged')