psdi.app.mr

Class MRStatusHandler

  • All Implemented Interfaces:
    MboConstants


    public class MRStatusHandler
    extends StatusHandler
    Handles status changes for the Material Requisition business object. All status changes to the MR object should go through the status change methods contained in this object. The Status Change methods contain the necessary business rules that] must be followed in order to have a smooth status change. It is inappropriate to change the status of the MR object without going through this object.
    To browse the attributes of the MR Table see the MR Attribute table
    . To browse the attributes of the MRLine Table see the MRLine Attribute table.
    • Field Detail

      • statusChangeMatrix

        public static boolean[][] statusChangeMatrix
        A statusChangeMatrix for the legal status changes that can be made.

        Status   WAPPR   APPR    CLOSE   CANCEL   DRAFT 
        WAPPR false true false true true
        APPR true false true true true
        CLOSE false false false false false
        CANCEL false false false false false
        DRAFT false false false false false
        The above table must be read from right to left only.
        For example , if you want to change the status from CLOSE to WAPPR , look at the left for the CLOSE row and look at the intersecting WAPPR column. The value is false. This means that this status change is not allowed.
    • Constructor Detail

      • MRStatusHandler

        public MRStatusHandler(MR sm)
        Constructor to construct the Status Handler object
    • Method Detail

      • changeStatus

        public void changeStatus(java.lang.String currentStatus,
                                 java.lang.String desiredStatus,
                                 java.util.Date date,
                                 java.lang.String memo)
                          throws MXException,
                                 java.rmi.RemoteException
        Change the status from the specified state to a desired state. Changes the status of the MR based on some business rules. The canChangeStatus method imposes certain restrictions on whether a status change can be done on an MR or not.
        Overrides:
        changeStatus in class StatusHandler
        Parameters:
        currentStatus - The Current external status of the MR
        desiredStatus - The desired external status of the MR
        date - The effective date of the status change
        memo - Optional memo string for the status change
        Throws:
        MXException - Thrown if the status change is not allowed
        java.rmi.RemoteException
        See Also:
        MRStatusHandler.canChangeStatus(java.lang.String, java.lang.String, long)
      • canChangeStatus

        public void canChangeStatus(java.lang.String currentStatus,
                                    java.lang.String desiredStatus,
                                    long accessModifier)
                             throws MXException,
                                    java.rmi.RemoteException
        Can a certain status change be performed ? Checks to see if the specified status change can be performed.
        • If the MR is a recurring MR ,no status change is allowed.
        • If the current MR status is Waiting for approval ,this MR can either be approved or cancelled.
          • If this MR is being approved, its lines are validated.All the lines must abide by the following rules
            • Must have at least an itemnum or description
            • Must have an itemnum if a storeroom is specified.
            • Must have either a vendor or a storeroom.
          • If this MR is being cancelled,
            • This MR must not have any associated MATRECTRANS or MATUSETRANS records.
            • Must not have any associated approved POs
        • If the current MR status is Approved ,this MR can either be closed or cancelled or unapproved.
          • If the MR needs to be closed, all the lines that belong to this MR must have been received.
          • If the MR needs to be either unapproved or cancelled, this MR must not have any associated approved POs.
        Overrides:
        canChangeStatus in class StatusHandler
        Parameters:
        currentStatus - The current external status of this mr
        desiredStatus - The desired external status of this mr
        accessModifier - If this flag is set to NOACCESSCHECK, signature security is not checked
        Throws:
        MXException - thrown when the status change cannot be performed.
        java.rmi.RemoteException
        See Also:
        MRLine.validateCombination(), MRStatusHandler.approveMR(java.lang.String, java.util.Date)
      • canUnapprove

        public void canUnapprove(java.lang.String currentInternalStatus)
                          throws MXException,
                                 java.rmi.RemoteException
        Can this MR be unapproved ?
        The MR cannot be unapproved if there is any associated PO. In other words if any Purchase Order was created from this MR this MR cannot be unapproved.
        Throws:
        MXException
        java.rmi.RemoteException
      • canApprove

        public void canApprove(java.lang.String currentInternalStatus)
                        throws MXException,
                               java.rmi.RemoteException
        Can this MR be approved ? The MR can be approved only if the current status of the MR is "Waiting for Approval". Make sure that some field values on the MRLine are valid.
        • An MRLine must at least have an itemnum or a description.
        • An MRLine cannot have a storeloc specified if there is no itemnum specified.
        • An MRLine must at least have one of these two fields filled in, vendor or storeloc.
        Throws:
        MXException
        java.rmi.RemoteException
        See Also:
        MRLine.validateCombination()
      • canClose

        public void canClose(java.lang.String currentInternalStatus)
                      throws MXException,
                             java.rmi.RemoteException
        Can the MR be closed?
        An MR can be closed only if all the lines have been completed. In other words, all the lines must have their "complete" flags set to true.
        Throws:
        MXException
        java.rmi.RemoteException
      • canCancel

        public void canCancel(java.lang.String currentInternalStatus)
                       throws MXException,
                              java.rmi.RemoteException
        Can an MR be cancelled ?
        If there are any transactions in matusetrans and/or matrectrans against an mr or mrline, the MR cannot be cancelled. Cannot cancel the MR if any approved PO's exist with mrnum in poline.mrnum
        Throws:
        MXException
        java.rmi.RemoteException
      • checkStatusChangeAuthorization

        public void checkStatusChangeAuthorization(java.lang.String desiredExternalStatus)
                                            throws MXException,
                                                   java.rmi.RemoteException
        Checks to see if the user is authorised to make a status changes. In other words , it checks if the user has the required privilege to change the status. After ensuring that the user has the required privilege, this methods checks if the status change is legal.
        Specified by:
        checkStatusChangeAuthorization in class StatusHandler
        Parameters:
        currentExternalStatus - The current external status of the MR.
        desiredExternalStatus - The desired external status of the MR.
        Throws:
        MXException
        java.rmi.RemoteException
        See Also:
        checkUserSecurity, possibleStatusChange
      • checkUserSecurity

        public void checkUserSecurity(java.lang.String desiredMaxStatus)
                               throws MXException,
                                      java.rmi.RemoteException
        Check out the users security rights to call the specified status. Note the status passed in is the INTERNAL status code.
        Note that the SigOption Option Name doesn't always match the status name.
        Parameters:
        status - The status to check if we can change to.
        Throws:
        MXAccessException - Throws an access exception "notauthorized" if the check fails.
        MXException
        java.rmi.RemoteException
      • approveMR

        protected void approveMR(java.lang.String desiredStatus,
                                 java.util.Date date)
                          throws MXException,
                                 java.rmi.RemoteException
        Approve the MR after making sure that certain business rules have been enforced.
        • Do not approve an MR if it has no lines.
        • The reorder process takes care of the creation of a Purchase Requisition from this MR and the approval process of the Purchase Requisition eventually creates a Purchase Order. The creation of the Purchase Order can be controlled by the maxvar called AUTOPOEXT
        • For items that are ordered from a storeroom(non direct-req items), reservations are created.
        Parameters:
        - - The desired status to which the MR should be changed to.
        - - The date on which this status change is done which is usually the current date.
        Throws:
        MXException
        java.rmi.RemoteException
        See Also:
        MRStatusHandler.reserveItems()
      • unapproveMR

        protected void unapproveMR(java.lang.String desiredStatus,
                                   java.util.Date date)
                            throws MXException,
                                   java.rmi.RemoteException
        Change the status of the MR to the status that was passed in. Delete the associated reservations(INVRESERVE records) that were created for this MR.
        Parameters:
        - - The desired status to which the MR should be changed to.
        - - The date on which this status change is done which is usually the current date.
        Throws:
        MXException
        java.rmi.RemoteException
        See Also:
        MRStatusHandler.deleteReservations()
      • cancelMR

        protected void cancelMR(java.lang.String desiredStatus,
                                java.util.Date date)
                         throws MXException,
                                java.rmi.RemoteException
        Change the status of the MR to the status that was passed in. Delete the associated reservations(INVRESERVE records) that were created for this MR.
        Parameters:
        - - The desired status to which the MR should be changed to.
        - - The date on which this status change is done which is usually the current date.
        Throws:
        MXException
        java.rmi.RemoteException
        See Also:
        MRStatusHandler.deleteReservations()
      • deleteReservationsWhenCancel

        protected void deleteReservationsWhenCancel()
                                             throws MXException,
                                                    java.rmi.RemoteException
        Delete the reservations
        Throws:
        MXException
        java.rmi.RemoteException
      • closeMR

        protected void closeMR(java.lang.String desiredStatus,
                               java.util.Date date)
                        throws MXException,
                               java.rmi.RemoteException
        Change the status of the MR to CLOSED. Delete the associated reservations(INVRESERVE records) that were created for this MR.
        Parameters:
        - - The desired status to which the MR should be changed to.
        - - The date on which this status change is done which is usually the current date.
        Throws:
        MXException
        java.rmi.RemoteException
        See Also:
        MRStatusHandler.deleteReservations()
      • reserveItems

        protected void reserveItems()
                             throws MXException,
                                    java.rmi.RemoteException
        Reserve the Material Requisition line items. Create INVRESERVE records for all lines except for those lines that order something from a vendor(DIRECTREQ lines). Also, reservations are not created from service lines. The following attributes are copied from MR,MRLine to INVRESERVE.

        From To
        MR.REQUESTEDBY INVRESERVE.REQUESTEDBY
        MR.MRDATE INVRESERVE.MRDATE
        MRLINE.MRNUM INVRESERVE.MRNUM
        MRLINE.MRLINENUM INVRESERVE.MRLINENUM
        MRLINE.ASSETNUM INVRESERVE.ASSETNUM
        MRLINE.WONUM INVRESERVE.WONUM
        MRLINE.DESCRIPTION INVRESERVE.DESCRIPTION
        MRLINE.DIRECTREQ INVRESERVE.DIRECTREQ
        MRLINE.ITEMNUM INVRESERVE.ITEMNUM
        MRLINE.STORELOC INVRESERVE.STORELOC
        MRLINE.GLDEBITACCT INVRESERVE.GLDEBITACCT
        MRLINE.REQUIREDDATE INVRESERVE.REQUIREDDATE
        MRLINE.QTY INVRESERVE.QTY
        MRLINE.LONGDESCRIPTION INVRESERVE.LONGDESCRIPTION
        Throws:
        MXException
        java.rmi.RemoteException
      • deleteReservations

        protected void deleteReservations()
                                   throws MXException,
                                          java.rmi.RemoteException
        Delete the reservations that were made for this MR. When an MR is unapproved or closed or cancelled the reservations that were earlier made must be deleted. In other words the INVRESERVE records must go.
        Throws:
        MXException
        java.rmi.RemoteException
      • updateMboForStatus

        public void updateMboForStatus(java.lang.String status)
                                throws MXException,
                                       java.rmi.RemoteException
        Called to set the state of the Mbo for the specified status. Updates the mr's field flags based on the status.
        Overrides:
        updateMboForStatus in class StatusHandler
        Parameters:
        status - current status of the mr
        Throws:
        MXException
        java.rmi.RemoteException
      • canAddInvReserve

        public boolean canAddInvReserve(MboRemote mrlineMbo)
                                 throws MXException,
                                        java.rmi.RemoteException
        Returns false if the difference between the quantities on the MRLine and the MATUSETRANS for the mrnum, mrlinenum is zero.
        Throws:
        MXException
        java.rmi.RemoteException