I have attached an excel file with Sheet1 , Sheet2 and Sheet3 , each Sheet has its own Output Sheet (for reference or understanding).
I have added a note comment to the Output Sheets indicating what actions we need to do.
Please let me know if there is anything i can do. TestFile.xlsx (14.4 KB)
dt.AsEnumerable.GroupBy(Function(r) r("Invoice").ToString).ToList().ForEach(Sub(g)
If (g.Sum(Function(r) CInt(r("amount").ToString))=0) Then
g.ToList.ForEach(Sub(r2) r2("Status")="Match")
Else
g.ToList.ForEach(Sub(r2) r2("Status")="Open Item")
End If
End Sub
)
For Purchase Invoice and Payments Combination , if the Invoice no. is matched then the sum of Amount Column should be 0 and Update the Status as Match else Update Open Item in Status.
I just changed the value of Category Column for row 14 from purchase invoice to payments.
But still it is showing it as Match.
But as per the condition it is open item.
@Yoichi
Sometimes the payments value is refunded and so Amount value can be positive😊
Also for Sheet 2 we have to first check the combination of A and B value for Category column.
Here also i have replaced the value from A to B for row 14 and still it is showing as Match
Can’t we set a rule such that the bot first creates a combination of purchase invoice and payments, filters the matched invoice, and then verifies that the sum of the amount column is zero and updates the status?
If we can allow to check combination of a row and next row, it’s possible like Sheet2. However as invoice number is not ordered in this sheet, it’s complicated I think.
The following is modified sample with checking category for Sheet2.
Dim arrWords As String() =dt.AsEnumerable.Select(Function(r) r("Category").ToString).ToArray()
dt.AsEnumerable.GroupBy(Function(r) arrWords.Select(Function(s) System.Text.RegularExpressions.Regex.Match(r("Category").ToString,s).Value).Where(Function(s) s<>"").OrderBy(Function(s) s.Length).First()).Where(Function(g) g.Count>1).ToList.ForEach(Sub (g)
If g.Sum(Function(r) CInt(r("Amount").ToString))=0 Then
g.ToList.ForEach(Sub(r2) r2("Status")="Match")
Else
g.ToList.ForEach(Sub(r2) r2("Status")="Open Item")
End If
End Sub
)
Thank you so much it is working really well.
But it doesn’t update the status as open item, only match value is updating.
I have added few row items in my file to check this scenario.