Subversion Repositories SmartDukaan

Rev

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

Rev 21622 Rev 21844
Line 2... Line 2...
2
Created on 29-Jul-2011
2
Created on 29-Jul-2011
3
 
3
 
4
@author: Chandranshu
4
@author: Chandranshu
5
'''
5
'''
6
from elixir import metadata, setup_all, session
6
from elixir import metadata, setup_all, session
-
 
7
from expiringdict import ExpiringDict
7
from shop2020.clients.CatalogClient import CatalogClient
8
from shop2020.clients.CatalogClient import CatalogClient
8
from shop2020.clients.InventoryClient import InventoryClient
9
from shop2020.clients.InventoryClient import InventoryClient
9
from shop2020.clients.TransactionClient import TransactionClient
10
from shop2020.clients.TransactionClient import TransactionClient
10
from shop2020.purchase.main.model.Invoice import Invoice
11
from shop2020.purchase.main.model.Invoice import Invoice
11
from shop2020.purchase.main.model.LineItem import LineItem
12
from shop2020.purchase.main.model.LineItem import LineItem
Line 33... Line 34...
33
import traceback
34
import traceback
34
 
35
 
35
 
36
 
36
logging.basicConfig(level=logging.DEBUG)
37
logging.basicConfig(level=logging.DEBUG)
37
 
38
 
-
 
39
 
-
 
40
HOURS=3600
-
 
41
CACHE_THREE_HOURS = ExpiringDict(max_len=10, max_age_seconds=3*HOURS)
-
 
42
 
-
 
43
 
-
 
44
    
-
 
45
def fetchStateMaster():
-
 
46
    if not CACHE_THREE_HOURS.get("statemaster"):
-
 
47
        try:
-
 
48
            inventory_client = InventoryClient().get_client()
-
 
49
            CACHE_THREE_HOURS["statemaster"] = inventory_client.getStateMaster()
-
 
50
            
-
 
51
        except:
-
 
52
            print "Could not fetch"
-
 
53
    return CACHE_THREE_HOURS.get("statemaster")
-
 
54
 
38
class PurchaseServiceHandler:
55
class PurchaseServiceHandler:
39
    '''
56
    '''
40
    classdocs
57
    classdocs
41
    '''
58
    '''
42
 
59
 
Line 426... Line 443...
426
                    t_po_lineitem.brand = item.brand
443
                    t_po_lineitem.brand = item.brand
427
                    t_po_lineitem.modelNumber = item.modelNumber
444
                    t_po_lineitem.modelNumber = item.modelNumber
428
                    t_po_lineitem.modelName = item.modelName
445
                    t_po_lineitem.modelName = item.modelName
429
                    t_po_lineitem.color = item.color
446
                    t_po_lineitem.color = item.color
430
                    t_po_lineitem.itemId = item.id
447
                    t_po_lineitem.itemId = item.id
-
 
448
                    t_po_lineitem.hsnCode = item.hsnCode
431
                    if quantity <0: #TODO Check this logic
449
                    if quantity <0: #TODO Check this logic
432
                        quantity=0
450
                        quantity=0
433
                    t_po_lineitem.quantity = quantity
451
                    t_po_lineitem.quantity = quantity
434
                    t_po_lineitem.availableQuantity = 0
452
                    t_po_lineitem.availableQuantity = 0
435
                    if availability.has_key(item.id):
453
                    if availability.has_key(item.id):
Line 479... Line 497...
479
    def getSuppliers(self,):
497
    def getSuppliers(self,):
480
        """
498
        """
481
        Returns all the valid suppliers
499
        Returns all the valid suppliers
482
        """
500
        """
483
        try:
501
        try:
484
            return [Supplier.to_thrift_object(supplier) for supplier in Supplier.query.filter(Supplier.id > 220).all()]
502
            return [Supplier.to_thrift_object(supplier) for supplier in Supplier.query.filter(Supplier.gstin != None).all()]
485
        finally:
503
        finally:
486
            self.close_session()
504
            self.close_session()
487
 
505
 
488
    def unFulfillPO(self, purchaseId, itemId, quantity):
506
    def unFulfillPO(self, purchaseId, itemId, quantity):
489
        """
507
        """
Line 703... Line 721...
703
            supplierObj.headName = supplier.headName
721
            supplierObj.headName = supplier.headName
704
            supplierObj.name = supplier.name
722
            supplierObj.name = supplier.name
705
            supplierObj.pan = supplier.pan
723
            supplierObj.pan = supplier.pan
706
            supplierObj.phone = supplier.phone
724
            supplierObj.phone = supplier.phone
707
            supplierObj.registeredAddress = supplier.registeredAddress
725
            supplierObj.registeredAddress = supplier.registeredAddress
708
            supplierObj.tin = supplier.tin
726
            supplierObj.gstin = supplier.gstin
709
            supplierObj.stateId = supplierObj.stateId
727
            supplierObj.stateId = supplierObj.stateId
710
            supplierObj.poValidityLimit = supplier.poValidityLimit
728
            supplierObj.poValidityLimit = supplier.poValidityLimit
711
            session.commit()
729
            session.commit()
712
        finally:
730
        finally:
713
            self.close_session()
731
            self.close_session()