INSERT INTO PaymentTypeMaster (id, payment_class_id, name) VALUES
(9, 2, 'Direct Repayment'),
(10, 2, 'Direct Value-dated Payment');

-- -----------------------------------------------------
-- Table AccountChargeTypeMaster
-- -----------------------------------------------------
DROP TABLE IF EXISTS AccountChargeTypeMaster;

CREATE TABLE AccountChargeTypeMaster (
  id TINYINT UNSIGNED NOT NULL AUTO_INCREMENT,
  product_category_id TINYINT UNSIGNED NOT NULL,
  name VARCHAR(100) NOT NULL,
  ui_name VARCHAR(100) DEFAULT NULL,
  system_defined TINYINT(1) NOT NULL DEFAULT 1,
  PRIMARY KEY (id),
  FOREIGN KEY (product_category_id)
    REFERENCES ProductCategoryMaster (id)
    ON DELETE NO ACTION
    ON UPDATE CASCADE
) ENGINE=InnoDB CHARACTER SET utf8;
CREATE UNIQUE INDEX accountchargetype_name_idx ON AccountChargeTypeMaster(product_category_id, name);

-- -----------------------------------------------------
-- Table LoanPaymentDemand
-- -----------------------------------------------------
DROP TABLE IF EXISTS LoanPaymentDemand;

CREATE TABLE LoanPaymentDemand (
  payment_id INTEGER UNSIGNED UNSIGNED NOT NULL,
  demand_id INTEGER UNSIGNED NOT NULL,
  parked_amount DECIMAL(15,6) NOT NULL,
  PRIMARY KEY (payment_id, demand_id),
  FOREIGN KEY (payment_id)
    REFERENCES LoanPayment (id)
    ON DELETE NO ACTION
    ON UPDATE CASCADE,
  FOREIGN KEY (demand_id)
    REFERENCES LoanDemand (id)
    ON DELETE NO ACTION
    ON UPDATE CASCADE
) ENGINE=InnoDB CHARACTER SET utf8;
