| 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.PurchaseOrder import PurchaseOrder
|
13 |
from shop2020.purchase.main.model.PurchaseOrder import PurchaseOrder
|
| - |
|
14 |
from shop2020.purchase.main.model.PurchaseReturn import PurchaseReturn
|
| 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.thriftpy.generic.ttypes import ExceptionType
|
18 |
from shop2020.thriftpy.generic.ttypes import ExceptionType
|
| 18 |
from shop2020.thriftpy.model.v1.inventory.ttypes import WarehouseType, \
|
19 |
from shop2020.thriftpy.model.v1.inventory.ttypes import WarehouseType, \
|
| Line 506... |
Line 507... |
| 506 |
invoice = purchase.invoiceNumber
|
507 |
invoice = purchase.invoiceNumber
|
| 507 |
except:
|
508 |
except:
|
| 508 |
return None
|
509 |
return None
|
| 509 |
finally:
|
510 |
finally:
|
| 510 |
self.close_session()
|
511 |
self.close_session()
|
| - |
|
512 |
|
| - |
|
513 |
def createPurchaseReturn(self, t_purchaseReturn):
|
| - |
|
514 |
'''
|
| - |
|
515 |
For creating a new Purchase Return
|
| - |
|
516 |
'''
|
| - |
|
517 |
try:
|
| - |
|
518 |
purchaseReturn = PurchaseReturn(t_purchaseReturn.vendorId,t_purchaseReturn.amount)
|
| - |
|
519 |
purchaseReturn.vendorId = t_purchaseReturn.vendorId
|
| - |
|
520 |
purchaseReturn.amount = t_purchaseReturn.amount
|
| - |
|
521 |
purchaseReturn.returnTimestamp = to_py_date(t_purchaseReturn.returnTimestamp)
|
| - |
|
522 |
purchaseReturn.isSettled = False
|
| - |
|
523 |
session.commit()
|
| - |
|
524 |
return purchaseReturn.id
|
| - |
|
525 |
except Exception as e:
|
| - |
|
526 |
print e
|
| - |
|
527 |
raise PurchaseServiceException(101, 'Exception while creating Purchase Return for ' + purchaseReturn.vendorId + ' for Rs' + purchaseReturn.amount)
|
| - |
|
528 |
finally:
|
| - |
|
529 |
self.close_session()
|
| - |
|
530 |
|
| - |
|
531 |
def getUnsettledPurchaseReturns(self):
|
| - |
|
532 |
'''
|
| - |
|
533 |
For getting all unsettled Purchase Returns
|
| - |
|
534 |
'''
|
| - |
|
535 |
try:
|
| - |
|
536 |
purchaseReturns = PurchaseReturn.query.filter_by(isSettled = False).all()
|
| - |
|
537 |
return [purchasereturn.to_thrift_object() for purchasereturn in purchaseReturns]
|
| - |
|
538 |
except Exception as e:
|
| - |
|
539 |
print e
|
| - |
|
540 |
raise PurchaseServiceException(101, 'Exception while fetching all Unsettled Purchase Returns')
|
| - |
|
541 |
finally:
|
| - |
|
542 |
self.close_session()
|
| - |
|
543 |
|
| - |
|
544 |
def settlePurchaseReturn(self, returnId):
|
| - |
|
545 |
'''
|
| - |
|
546 |
For marking a Purchase Return as settled
|
| - |
|
547 |
'''
|
| - |
|
548 |
try:
|
| - |
|
549 |
purchaseReturn = PurchaseReturn.query.filter_by(id = returnId).one()
|
| - |
|
550 |
purchaseReturn.isSettled = True
|
| - |
|
551 |
session.commit()
|
| - |
|
552 |
except Exception as e:
|
| - |
|
553 |
print e
|
| - |
|
554 |
raise PurchaseServiceException(101, 'Exception while settling Purchase Return Id : ' + id)
|
| - |
|
555 |
finally:
|
| - |
|
556 |
self.close_session()
|
| 511 |
|
557 |
|
| 512 |
def isAlive(self, ):
|
558 |
def isAlive(self, ):
|
| 513 |
"""
|
559 |
"""
|
| 514 |
For checking weather service is active alive or not. It also checks connectivity with database
|
560 |
For checking weather service is active alive or not. It also checks connectivity with database
|
| 515 |
"""
|
561 |
"""
|