| Line 9... |
Line 9... |
| 9 |
from shop2020.clients.TransactionClient import TransactionClient
|
9 |
from shop2020.clients.TransactionClient import TransactionClient
|
| 10 |
from shop2020.purchase.main.model.Invoice import Invoice
|
10 |
from shop2020.purchase.main.model.Invoice import Invoice
|
| 11 |
from shop2020.purchase.main.model.LineItem import LineItem
|
11 |
from shop2020.purchase.main.model.LineItem import LineItem
|
| 12 |
from shop2020.purchase.main.model.Purchase import Purchase
|
12 |
from shop2020.purchase.main.model.Purchase import Purchase
|
| 13 |
from shop2020.purchase.main.model.PurchaseReturn import PurchaseReturn
|
13 |
from shop2020.purchase.main.model.PurchaseReturn import PurchaseReturn
|
| - |
|
14 |
from shop2020.purchase.main.model.PurchaseReturnSettlement import PurchaseReturnSettlement
|
| 14 |
from shop2020.purchase.main.model.RevisionedPurchaseOrder import \
|
15 |
from shop2020.purchase.main.model.RevisionedPurchaseOrder import \
|
| 15 |
RevisionedPurchaseOrder
|
16 |
RevisionedPurchaseOrder
|
| 16 |
from shop2020.purchase.main.model.Supplier import Supplier
|
17 |
from shop2020.purchase.main.model.Supplier import Supplier
|
| 17 |
from shop2020.purchase.main.model.PurchaseOrder import PurchaseOrder
|
18 |
from shop2020.purchase.main.model.PurchaseOrder import PurchaseOrder
|
| 18 |
from shop2020.thriftpy.generic.ttypes import ExceptionType
|
19 |
from shop2020.thriftpy.generic.ttypes import ExceptionType
|
| Line 720... |
Line 721... |
| 720 |
purchaseReturn.amount = t_purchaseReturn.amount
|
721 |
purchaseReturn.amount = t_purchaseReturn.amount
|
| 721 |
purchaseReturn.returnTimestamp = to_py_date(t_purchaseReturn.returnTimestamp)
|
722 |
purchaseReturn.returnTimestamp = to_py_date(t_purchaseReturn.returnTimestamp)
|
| 722 |
purchaseReturn.isSettled = False
|
723 |
purchaseReturn.isSettled = False
|
| 723 |
purchaseReturn.type = t_purchaseReturn.type
|
724 |
purchaseReturn.type = t_purchaseReturn.type
|
| 724 |
purchaseReturn.returnInventoryType = t_purchaseReturn.returnInventoryType
|
725 |
purchaseReturn.returnInventoryType = t_purchaseReturn.returnInventoryType
|
| - |
|
726 |
purchaseReturn.unsettledAmount = t_purchaseReturn.amount
|
| 725 |
session.commit()
|
727 |
session.commit()
|
| 726 |
return purchaseReturn.id
|
728 |
return purchaseReturn.id
|
| 727 |
except Exception as e:
|
729 |
except Exception as e:
|
| 728 |
print e
|
730 |
print e
|
| 729 |
raise PurchaseServiceException(101, 'Exception while creating Purchase Return for ' + purchaseReturn.vendorId + ' for Rs' + purchaseReturn.amount)
|
731 |
raise PurchaseServiceException(101, 'Exception while creating Purchase Return for ' + purchaseReturn.vendorId + ' for Rs' + purchaseReturn.amount)
|
| Line 831... |
Line 833... |
| 831 |
raise PurchaseServiceException(101, "No purchase return can be found with id:" + str(id))
|
833 |
raise PurchaseServiceException(101, "No purchase return can be found with id:" + str(id))
|
| 832 |
return purchaseReturn.to_thrift_object()
|
834 |
return purchaseReturn.to_thrift_object()
|
| 833 |
finally:
|
835 |
finally:
|
| 834 |
self.close_session()
|
836 |
self.close_session()
|
| 835 |
|
837 |
|
| - |
|
838 |
def markPurchasereturnSettled(self, id, settlementType, documentNumber, settlementBy, settledAmount):
|
| - |
|
839 |
try:
|
| - |
|
840 |
currentTime = datetime.datetime.now()
|
| - |
|
841 |
purchaseReturn = PurchaseReturn.get_by(id=id)
|
| - |
|
842 |
if not purchaseReturn:
|
| - |
|
843 |
raise PurchaseServiceException(101, "No purchase return can be found with id:" + str(id))
|
| - |
|
844 |
if settledAmount > purchaseReturn.unsettledAmount:
|
| - |
|
845 |
raise PurchaseServiceException(101, "Purchase Return Settled Amount Can't be Greater than Unsettled Amount Purchase Return id:" + str(id))
|
| - |
|
846 |
purchaseReturn.currentSettlementType = settlementType
|
| - |
|
847 |
purchaseReturn.latestSettlementDate = currentTime
|
| - |
|
848 |
if purchaseReturn.documentNumber :
|
| - |
|
849 |
purchaseReturn.documentNumber = purchaseReturn.documentNumber +";"+documentNumber
|
| - |
|
850 |
else:
|
| - |
|
851 |
purchaseReturn.documentNumber = documentNumber
|
| - |
|
852 |
unsettledAmount = purchaseReturn.unsettledAmount - settledAmount
|
| - |
|
853 |
purchaseReturn.unsettledAmount = purchaseReturn.unsettledAmount - settledAmount
|
| - |
|
854 |
if unsettledAmount ==0:
|
| - |
|
855 |
purchaseReturn.isSettled = 1
|
| - |
|
856 |
|
| - |
|
857 |
purchaseReturnSettlement = PurchaseReturnSettlement()
|
| - |
|
858 |
purchaseReturnSettlement.purchaseReturnId = id
|
| - |
|
859 |
purchaseReturnSettlement.settlementType = settlementType
|
| - |
|
860 |
purchaseReturnSettlement.settlementBy = settlementBy
|
| - |
|
861 |
purchaseReturnSettlement.settlementAmount = settledAmount
|
| - |
|
862 |
purchaseReturnSettlement.settlementDate = currentTime
|
| - |
|
863 |
purchaseReturnSettlement.documentNumber = documentNumber
|
| - |
|
864 |
session.commit()
|
| - |
|
865 |
return True
|
| - |
|
866 |
finally:
|
| - |
|
867 |
self.close_session()
|
| - |
|
868 |
|
| - |
|
869 |
def getPrSettlementsForPurchaseReturn(self, purchaseReturnId):
|
| - |
|
870 |
try:
|
| - |
|
871 |
settlements = PurchaseReturnSettlement.query.filter_by(purchaseReturnId=purchaseReturnId).all()
|
| - |
|
872 |
prSettlements = []
|
| - |
|
873 |
for settlement in settlements:
|
| - |
|
874 |
prSettlements.append(settlement.to_thrift_object())
|
| - |
|
875 |
return prSettlements
|
| - |
|
876 |
finally:
|
| - |
|
877 |
self.close_session()
|
| - |
|
878 |
|
| - |
|
879 |
def updatePurchaseReturn(self, t_purchaseReturn):
|
| - |
|
880 |
'''
|
| - |
|
881 |
Updating a Purchase Return
|
| - |
|
882 |
'''
|
| - |
|
883 |
try:
|
| - |
|
884 |
purchaseReturn = PurchaseReturn.get_by(id=t_purchaseReturn.id)
|
| - |
|
885 |
purchaseReturn.purchaseReturnType = t_purchaseReturn.purchaseReturnType
|
| - |
|
886 |
purchaseReturn.reasonText = t_purchaseReturn.reasonText
|
| - |
|
887 |
purchaseReturn.createdBy = t_purchaseReturn.createdBy
|
| - |
|
888 |
session.commit()
|
| - |
|
889 |
finally:
|
| - |
|
890 |
self.close_session()
|
| - |
|
891 |
|
| 836 |
def isAlive(self,):
|
892 |
def isAlive(self,):
|
| 837 |
"""
|
893 |
"""
|
| 838 |
For checking weather service is active alive or not. It also checks connectivity with database
|
894 |
For checking weather service is active alive or not. It also checks connectivity with database
|
| 839 |
"""
|
895 |
"""
|
| 840 |
try:
|
896 |
try:
|
| Line 846... |
Line 902... |
| 846 |
self.close_session()
|
902 |
self.close_session()
|
| 847 |
|
903 |
|
| 848 |
def __get_item_from_master(self, item_id):
|
904 |
def __get_item_from_master(self, item_id):
|
| 849 |
client = CatalogClient("catalog_service_server_host_master", "catalog_service_server_port").get_client()
|
905 |
client = CatalogClient("catalog_service_server_host_master", "catalog_service_server_port").get_client()
|
| 850 |
return client.getItem(item_id)
|
906 |
return client.getItem(item_id)
|
| - |
|
907 |
|