Ejemplo n.º 1
0
def raise_events(xform, cases):
    requisition_cases = [RequisitionCase.wrap(c._doc) for c in cases if c.type == const.REQUISITION_CASE_TYPE]
    if requisition_cases and requisition_cases[0].requisition_status == RequisitionStatus.APPROVED:
        requisition_approved.send(sender=None, requisitions=requisition_cases)
    if requisition_cases and requisition_cases[0].requisition_status == RequisitionStatus.RECEIVED:
        requisition_receipt.send(sender=None, requisitions=requisition_cases)

    if requisition_cases and requisition_cases[0].requisition_status == RequisitionStatus.REQUESTED:
        requisition_modified.send(sender=None, cases=requisition_cases)
Ejemplo n.º 2
0
def raise_events(xform, cases):
    supply_points = [SupplyPointCase.wrap(c._doc) for c in cases if c.type == const.SUPPLY_POINT_CASE_TYPE]
    case_updates = get_case_updates(xform)
    for sp in supply_points:
        created = any(filter(lambda update: update.id == sp._id and update.creates_case(), case_updates))
        supply_point_modified.send(sender=None, supply_point=sp, created=created)
    requisition_cases = [RequisitionCase.wrap(c._doc) for c in cases if c.type == const.REQUISITION_CASE_TYPE]
    if requisition_cases and requisition_cases[0].requisition_status == RequisitionStatus.APPROVED:
        requisition_approved.send(sender=None, requisitions=requisition_cases)
    if requisition_cases and requisition_cases[0].requisition_status == RequisitionStatus.RECEIVED:
        requisition_receipt.send(sender=None, requisitions=requisition_cases)

    if requisition_cases and requisition_cases[0].requisition_status == RequisitionStatus.REQUESTED:
        requisition_modified.send(sender=None, cases=requisition_cases)
Ejemplo n.º 3
0
def raise_events(xform, cases):
    requisition_cases = [
        RequisitionCase.wrap(c._doc) for c in cases
        if c.type == const.REQUISITION_CASE_TYPE
    ]
    if requisition_cases and requisition_cases[
            0].requisition_status == RequisitionStatus.APPROVED:
        requisition_approved.send(sender=None, requisitions=requisition_cases)
    if requisition_cases and requisition_cases[
            0].requisition_status == RequisitionStatus.RECEIVED:
        requisition_receipt.send(sender=None, requisitions=requisition_cases)

    if requisition_cases and requisition_cases[
            0].requisition_status == RequisitionStatus.REQUESTED:
        requisition_modified.send(sender=None, cases=requisition_cases)
Ejemplo n.º 4
0
def raise_events(xform, cases):
    """
    Raise requisition events associated with cases
    """
    # todo: nothing calls this and it can be removed today, though openlmis code depends
    # on it being called during case processing
    requisition_cases = [
        RequisitionCase.wrap(c._doc) for c in cases
        if c.type == REQUISITION_CASE_TYPE
    ]
    if requisition_cases and requisition_cases[
            0].requisition_status == RequisitionStatus.APPROVED:
        requisition_approved.send(sender=None, requisitions=requisition_cases)
    if requisition_cases and requisition_cases[
            0].requisition_status == RequisitionStatus.RECEIVED:
        requisition_receipt.send(sender=None, requisitions=requisition_cases)

    if requisition_cases and requisition_cases[
            0].requisition_status == RequisitionStatus.REQUESTED:
        requisition_modified.send(sender=None, cases=requisition_cases)
 def testApproveRequisition(self):
     requisition_cases = []
     config = self.domain.commtrack_settings
     for spp in self.spps.values():
         transaction = Requisition(
             config=config,
             product_id=spp.product,
             case_id=spp._id,
             action_name=config.get_action_by_type(RequisitionActions.REQUEST).action_name,
             value=20,
         )
         req = create_requisition(self.user._id, spp, transaction)
         requisition_cases.append(req)
     self.assertTrue(requisition_approved.send(sender=None, requisitions=requisition_cases))
 def fixmetestApproveRequisition(self):
     from corehq.apps.commtrack.stockreport import Requisition
     requisition_cases = []
     config = CommtrackConfig.for_domain(self.domain)
     for spp in self.spps.values():
         transaction = Requisition(
             config=config,
             product_id=spp.product,
             case_id=spp._id,
             action_name=config.get_action_by_type(RequisitionActions.REQUEST).action_name,
             value=20,
         )
         req = create_requisition(self.user._id, spp, transaction)
         requisition_cases.append(req)
     self.assertTrue(requisition_approved.send(sender=None, requisitions=requisition_cases))
Ejemplo n.º 7
0
 def fixmetestApproveRequisition(self):
     from corehq.apps.commtrack.stockreport import Requisition
     requisition_cases = []
     config = CommtrackConfig.for_domain(self.domain)
     for spp in self.spps.values():
         transaction = Requisition(
             config=config,
             product_id=spp.product,
             case_id=spp._id,
             action_name=config.get_action_by_type(
                 RequisitionActions.REQUEST).action_name,
             value=20,
         )
         req = create_requisition(self.user._id, spp, transaction)
         requisition_cases.append(req)
     self.assertTrue(
         requisition_approved.send(sender=None,
                                   requisitions=requisition_cases))