Refer below query.
CREATE TABLE Invoice(InvoiceID INT,InvoiceNo INT,AccountID INT,VendorID INT,InvoiceAmt INT,AlreadyPaid INT,BalanceAmt INT,NewPaymentInvoiceWiseAdjustment INT)
INSERT INTO Invoice VALUES(81,135,2101007001,322,412650,200000,212650,0)
INSERT INTO Invoice VALUES(82,136,2101007001,322,648150,0,648150,0)
INSERT INTO Invoice VALUES(83,137,2101007001,322,957600,0,957600,0)
INSERT INTO Invoice VALUES(84,138,2101007001,322,1425060,0,1425060,0)
INSERT INTO Invoice VALUES(85,139,2101007001,322,679770,0,679770,0)
DECLARE @Amount INT = 1500000
DECLARE @Total INT = 1500000
DECLARE @Sum INT = 0
DECLARE @Counter INT, @TotalCount INT, @InvoiceID INT, @BalanceAmt INT
SET @Counter = 1
SET @TotalCount = (SELECT COUNT(*) FROM Invoice)
WHILE (@Counter <= @TotalCount)
BEGIN
SET @InvoiceID = (SELECT InvoiceID FROM (SELECT ROW_NUMBER() OVER( ORDER BY (SELECT 0)) RowId,* FROM Invoice) t WHERE t.RowId = @Counter)
SET @BalanceAmt = (SELECT BalanceAmt FROM (SELECT ROW_NUMBER() OVER( ORDER BY (SELECT 0)) RowId,* FROM Invoice) t WHERE t.RowId = @Counter)
SET @Amount = @Amount - @BalanceAmt
IF @Amount > 0
BEGIN
UPDATE Invoice
SET NewPaymentInvoiceWiseAdjustment = @BalanceAmt
WHERE InvoiceID = @InvoiceID
SET @Sum += @BalanceAmt
END
ELSE
BEGIN
IF @Sum <= @Total
BEGIN
UPDATE Invoice
SET NewPaymentInvoiceWiseAdjustment = @Total - @Sum
WHERE InvoiceID = @InvoiceID
SET @Sum += @BalanceAmt
END
END
SET @Counter = @Counter + 1
CONTINUE;
END