Subversion Repositories SmartDukaan

Rev

Rev 1886 | Rev 2591 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1886 Rev 2536
Line 13... Line 13...
13
    mark_orders_as_manifested, close_session, accept_order, bill_order, mark_orders_as_picked_up,\
13
    mark_orders_as_manifested, close_session, accept_order, bill_order, mark_orders_as_picked_up,\
14
    mark_orders_as_delivered, mark_orders_as_failed, add_jacket_number,\
14
    mark_orders_as_delivered, mark_orders_as_failed, add_jacket_number,\
15
    order_outofstock, batch_orders, update_non_delivery_reason, enqueue_transaction_info_email,\
15
    order_outofstock, batch_orders, update_non_delivery_reason, enqueue_transaction_info_email,\
16
    get_undelivered_orders, get_order_for_customer, get_valid_order_count,\
16
    get_undelivered_orders, get_order_for_customer, get_valid_order_count,\
17
    get_cust_count_with_successful_txn, get_valid_orders_amount_range,\
17
    get_cust_count_with_successful_txn, get_valid_orders_amount_range,\
18
    get_valid_orders
18
    get_valid_orders, toggle_doa_flag, request_pickup_number, authorize_pickup
19
 
19
 
20
from shop2020.model.v1.order.impl.Convertors import to_t_transaction,\
20
from shop2020.model.v1.order.impl.Convertors import to_t_transaction,\
21
    to_t_alert, to_t_order, to_t_lineitem
21
    to_t_alert, to_t_order, to_t_lineitem
22
from shop2020.thriftpy.model.v1.order.ttypes import Transaction, OrderStatus,\
22
from shop2020.thriftpy.model.v1.order.ttypes import Transaction, OrderStatus,\
23
    LineItem, Order
23
    LineItem, Order
Line 488... Line 488...
488
        """
488
        """
489
        try:
489
        try:
490
            return [to_t_order(order) for order in get_valid_orders(limit)]
490
            return [to_t_order(order) for order in get_valid_orders(limit)]
491
        finally:
491
        finally:
492
            close_session()
492
            close_session()
493
            
-
 
494
    def closeSession(self, ):
-
 
495
        close_session()
-
 
496
    
-
 
497
    
-
 
498
    
-
 
499
    '''
-
 
500
if __name__ == "__main__":
-
 
501
    order = OrderServiceHandler()
-
 
502
    t = order.getTransaction(4)
-
 
503
    print t
-
 
504
    
493
    
505
    
-
 
506
    these methods commented right now. may be used later
-
 
507
    def getAllTransactions(self, status, from_date, to_date, warehouse_id):
494
    def toggleDOAFlag(self, orderId):
508
        """
-
 
509
        Parameters:
-
 
510
         - status
-
 
511
         - from_date
-
 
512
         - to_date
-
 
513
        """
495
        """
-
 
496
        Toggle the DOA flag of an order. This should be used to flag an order for follow-up and unflag it when the follow-up is complete.
-
 
497
        Returns the final flag status.
514
        current_status, current_from_date, current_to_date = get_status_fdate_tdate(status, from_date, to_date)
498
        Throws an exception if the order with the given id couldn't be found or if the order status is not DELVIERY_SUCCESS.
515
        
499
        
516
        transactions = get_all_transactions(current_status, current_from_date, current_to_date, warehouse_id)
-
 
517
        t_transaction = []
-
 
518
        for transaction in transactions:
-
 
519
            t_transaction.append(to_t_transaction(transaction))
-
 
520
        return t_transaction
-
 
521
 
-
 
522
    def getTransactionsForShipmentStatus(self, status, from_date, to_date):
-
 
523
        """
-
 
524
        Parameters:
-
 
525
         - status
-
 
526
         - from_date
-
 
527
         - to_date
-
 
528
        """
-
 
529
        current_status, current_from_date, current_to_date = get_status_fdate_tdate(status, from_date, to_date)
-
 
530
            
-
 
531
        transactions = get_transactions_for_shipment_status(current_status, current_from_date, current_to_date)
-
 
532
        t_transaction = []
-
 
533
        for transaction in transactions:
-
 
534
            t_transaction.append(to_t_transaction(transaction))
-
 
535
        return t_transaction
-
 
536
 
-
 
537
    def getTransactionsForCustomerAndShipmentStatus(self, customerId, from_date, to_date, status):
-
 
538
        """
-
 
539
        Parameters:
-
 
540
         - customerId
-
 
541
         - from_date
-
 
542
         - to_date
-
 
543
         - status
-
 
544
        """
-
 
545
        current_status, current_from_date, current_to_date = get_status_fdate_tdate(status, from_date, to_date)
-
 
546
      
-
 
547
        transactions = get_transactions_for_customer_shipment(customerId, current_from_date, current_to_date, current_status)
-
 
548
        t_transaction = []
-
 
549
        for transaction in transactions:
-
 
550
            t_transaction.append(to_t_transaction(transaction))
-
 
551
        return t_transaction
-
 
552
 
-
 
553
    def getOrderInfo(self, transactionId):
-
 
554
        """
-
 
555
            Get and set individual objects in it
-
 
556
        *
-
 
557
        
-
 
558
        Parameters:
-
 
559
         - transactionId
-
 
560
        """
-
 
561
        lineitems = get_line_items(transactionId)
-
 
562
        order_info = OrderInfo()
-
 
563
        order_info.lineitems = []
-
 
564
        for lineitem in lineitems:
-
 
565
            order_info.lineitems.append(to_t_lineitem(lineitem))
-
 
566
            order_info.id = lineitem.transaction.id
-
 
567
        
-
 
568
        return order_info
-
 
569
    
-
 
570
    def getShippingInfo(self, transactionId):
-
 
571
        """
-
 
572
        Parameters:
-
 
573
         - transactionId
-
 
574
        """
-
 
575
        shipments = get_shipments(transactionId)
-
 
576
        shipment_info = ShipmentInfo()
-
 
577
        shipment_info.shipments = []
-
 
578
        for shipment in shipments:
-
 
579
            shipment_info.shipments.append(to_t_shipment(shipment))
-
 
580
            shipment_info.id = shipment.id
-
 
581
        return shipment_info
-
 
582
    def getBillingInfo(self, transactionId):
-
 
583
        """
-
 
584
        Parameters:
-
 
585
         - transactionId
-
 
586
        """
-
 
587
        billings = get_billings(transactionId)
-
 
588
        billing_info = BillingInfo()
-
 
589
        billing_info.billings = []
-
 
590
        if billings:
-
 
591
            for billing in billings:
-
 
592
                billing_info.billings.append(to_t_billing(billing))
-
 
593
                billing_info.id = billing.line_item.transaction.id
-
 
594
        return billing_info
-
 
595
    
-
 
596
    def addBilling(self, transactionId, billing):
-
 
597
        """
-
 
598
        Parameters:
-
 
599
         - tranactionId
-
 
600
         - billing
-
 
601
        """
-
 
602
        return set_billing(transactionId, billing)
-
 
603
    
-
 
604
    def setShippingTracker(self, transactionId, shippingId, trackingId, airwayBillNo, provider):
-
 
605
        """
-
 
606
        Parameters:
-
 
607
         - transactionId
-
 
608
         - shippingId
-
 
609
         - trackingId
-
 
610
         - airwayBillNo
-
 
611
         - provider
-
 
612
        """
-
 
613
        return set_shipping_tracker_info(transactionId, shippingId, trackingId, airwayBillNo, provider)
-
 
614
    
-
 
615
    def setShippingDate(self, transactionId, shippingId, timestamp):
-
 
616
        """
-
 
617
        Parameters:
-
 
618
         - transactionId
-
 
619
         - shippingId
-
 
620
         - timestamp
-
 
621
        """
-
 
622
        return set_shipping_date(transactionId, shippingId, to_py_date(timestamp))
-
 
623
    
-
 
624
    def setDeliveryDate(self, transactionId, shippingid, timestamp):
-
 
625
        """
-
 
626
        Parameters:
500
        Parameters:
627
         - transactionId
-
 
628
         - shippingid
-
 
629
         - timestamp
501
         - orderId
630
        """
502
        """
-
 
503
        try:
631
        return set_delivery_date(transactionId, shippingid, timestamp)
504
            return toggle_doa_flag(orderId)
-
 
505
        finally:
-
 
506
            close_session()
632
 
507
 
633
    def getAlerts(self, transactionId, valid):
508
    def requestPickupNumber(self, orderId):
634
        """
509
        """
635
        Parameters:
510
        Sends out an email to the account manager of the original courier provider used to ship the order.
636
         - transactionId
511
        If the order status was DELIVERY_SUCCESS, it is changed to be DOA_PICKUP_REQUESTED.
637
         - valid
-
 
638
        """
-
 
639
        alerts = get_alerts(transactionId, valid)
512
        If the order status was DOA_PICKUP_REQUESTED, it is left unchanged.
640
        
-
 
641
        t_alerts = []
-
 
642
        
-
 
643
        for alert in alerts:
513
        For any other status, it returns false.
644
            t_alerts.append(to_t_alert(alert)) 
514
        Throws an exception if the order with the given id couldn't be found.
645
        
515
        
646
        return t_alerts
-
 
647
 
-
 
648
    def setAlert(self, transactionId, unset, type, comment):
-
 
649
        """
-
 
650
        Parameters:
516
        Parameters:
651
         - transactionId
-
 
652
         - unset
-
 
653
         - type
-
 
654
         - comment
517
         - orderId
655
        """
518
        """
-
 
519
        try:
656
        set_alert(transactionId, unset, type, comment)
520
            return request_pickup_number(orderId)
-
 
521
        finally:
-
 
522
            close_session()
657
 
523
 
658
    def getExtraInfo(self, transaction_id):
524
    def authorizePickup(self, orderId, pickupNumber):
659
        """
-
 
660
        Parameters:
-
 
661
         - transaction_id
-
 
662
        """
525
        """
-
 
526
        If the order status is DOA_PICKUP_REQUESTED, it does the following
-
 
527
            1. Sends out an email to the customer with the dispatch advice that he has to print as an attachment.
-
 
528
            2. Changes order status to be DOA_PICKUP_AUTHORIZED.
-
 
529
            3. Returns true
663
        extra_info = get_extra_info(transaction_id)
530
        If the order is any other status, it returns false.
-
 
531
        Throws an exception if the order with the given id couldn't be found.
664
        
532
        
665
        return to_t_extra_item_info(extra_info, transaction_id)
-
 
666
        
-
 
667
 
-
 
668
    def setExtraInfo(self, transaction_id, sku_id, model, colour, vendor):
-
 
669
        """
-
 
670
        Parameters:
533
        Parameters:
671
         - transaction_id
-
 
672
         - sku_id
-
 
673
         - model
534
         - orderId
674
         - colour
535
         - pickupNumber
675
         - vendor
-
 
676
        """
536
        """
-
 
537
        try:
677
        set_extra_info(transaction_id, sku_id, model, vendor, colour)
538
            return authorize_pickup(orderId, pickupNumber)
678
 
-
 
679
    '''
539
        finally:
-
 
540
            close_session()    
680
    
541
            
-
 
542
    def closeSession(self, ):
-
 
543
        close_session()