DROP PROCEDURE IF EXISTS sp_autoVoucherPosting;

CREATE PROCEDURE sp_autoVoucherPosting()
BEGIN

    DROP TEMPORARY TABLE IF EXISTS TMP_AUTO_VOUCH_MESSAGE;
    CREATE TEMPORARY TABLE TMP_AUTO_VOUCH_MESSAGE(
        SL int NOT NULL AUTO_INCREMENT,
        TYP CHAR(10) NOT NULL,
        VAL CHAR(100) NOT NULL,
        PRIMARY KEY (SL) USING BTREE
    );

    /* VOUCHER POSTING FOR service AVAILED IN HOSPITAL (ADD & REVERT) */
    CALL sp_srvcAutoVoucherEntry();

    /* VOUCHER POSTING FOR service PAYMENTS and REFUNDS */
    CALL sp_srvcPaymntVoucherPosting();

    /* VOUCHER POSTING FOR PRODUCTS PURCHASED */
    CALL sp_purchaseVoucherPosting();

    /* VOUCHER POSTING FOR PURCHASE RETURNS */
    CALL sp_purchaseReturnVoucherPosting();

    /* VOUCHER POSTING FOR PAYMENT OF PURCHASES */
    CALL sp_purchasePaymentVoucherPosting();

    /* ACCOUNTS BALANCE UPDATION */
    CALL sp_updateAccBalance();

	SELECT * FROM TMP_AUTO_VOUCH_MESSAGE;
END;