Here's the solution.
CREATE TRIGGER tri_InsertBalanceBulk ON AccountMaster
FOR INSERT
AS
BEGIN
DECLARE @TableVariable TABLE
(
AccountCode VARCHAR(100),
BalanceAmount NUMERIC(19,4)
)
INSERT INTO @TableVariable (AccountCode, BalanceAmount)
SELECT
AccountCode,
SUM(DebitAmount - CreditAmount)
FROM
Inserted
GROUP BY
AccountCode
UPDATE Balances
SET BalanceAmount = Balances.BalanceAmount + AccMaster.BalanceAmount
FROM Balances
INNER JOIN @TableVariable AccMaster
ON Balances.AccountCode = AccMaster.AccountCode
INSERT INTO Balances(AccountCode, BalanceAmount)
SELECT AccMaster.AccountCode, AccMaster.BalanceAmount
FROM @TableVariable AccMaster
WHERE AccMaster.AccountCode NOT IN (SELECT AccountCode FROM Balances)
END