What happens is that I have a list with three fields, which are: Cuenta
, importe_A
e importe_B
.
Example of information:
Cuenta = "1000.2.15.3"
Importe A = 230
Importe B = 500
Cuenta = "1000.2.15.4"
Importe A = 100
Importe B = 30
Cuenta "1000.2.16.4"
Importe A = 160
Importe B = 35
What I want to do, is to bring the amount of the accounts according to their level, and the upper level must bring the sum of the daughter accounts.
For example the 1000.2.15.4
account has four levels (where the level 1
would be 1000
, the level 2
2
, the 3
15
and the 4
4
), each level of the account is separated by .
An example of input / output data that I intend are:
Entry
The amount_A of account 1000.2.15.4 is 100
The Amount_A of account 1000.2.15.3 is 230
The amount_A of account 1000.2.16.4 is 160
Exit
the sum of the amount_A of account 1000.2.15 is 330
the sum of the amount_A of account 1000.2.16 is 160
the sum of the amount_A of account 1000.2 is 490
the sum of the amount_A of account 1000 is 490
Each account has the sum of the amount according to the matching parent account and so on until the last parent is reached, that is until the account no longer has "."
My question is, will there be a way to separate the accounts by "." to obtain the parents, and add the amount of each account in their respective parent?
I managed to separate the accounts with a split ('.') but I can not make the sum of their amounts in the parent accounts.