Running Balance of Bonuses & Charges

149 views
Skip to first unread message

Elizabeth Dixon

unread,
Feb 16, 2025, 2:41:39 PM2/16/25
to mementodatabase
I have a Staff library, an Awards library and a Charges library, and an Account library. The Awards and Charges library have link to entry fields to the Staff library and to the Account library.

The employee receives awards in the form of bonuses.  This is recorded in the Awards library to track his/her type of award.  It is in the form of an internal type of currency called Bonuses that they can spend on items within the company.

The employee receives fines in the form of charges.  This is recorded in the Charges library.  It also is in the form of an internal type of currency called Charges 

I need to have a running balance of Bonuses and Charges.  I have been researching this problem for some time now and just saw Mmm's example but not sure how to get it to work.  And I think David's script running balance script also might work too but was confused on how to do it within the 4 libraries.

Example:  Employee A
In the Awards library there are two entries for Employee A.
Received a Bonus of 50 on Jan 1st
Received a Bonus of 25 on Jan 31st

Based on Mmm's script I think it would look like this:
First entry 
50.00 the bonus amount on Jan 1
50.00 is now the current bonuses balance on Jan 1

Second entry
25.00 the bonus amount on Jan 31
75.00 is now the current bonuses balance on in the Awards library on Jan 31

In the Fines library
Received a Charge of 10.00 on Feb 1
Received a Charge of 12.00 on Feb 15
First entry
10.00 is the charge amount on Feb 1
10.00 is now the current charges balance on Feb 1

Second entry
12.00 is the charge amount on Feb 15
22.00 is now the current charges balance on Feb 15

Then I need a running balance in the Account library for Employee A to show
Total bonuses minus total charges.
$75.00 - $22.00 = $53.00

Maybe I am doing this all wrong.  Can I please have help on how to achieve this?

Beth




Er Mo

unread,
Feb 16, 2025, 3:48:59 PM2/16/25
to mementodatabase
Hallo Beth
Ich würde das in einer Bibliothek zusammenfassen . Also Prämie und Gebühren in Plus und Minus . Ein Auswahlfeld für Prämie und Gebühren und von diesen Abhängig machen was für Felder angezeigt werden ( zB Eingabe der Prämir oder Eingabe der Gebühr ) So ergibt die Summe für diesen Mitarbeiter den Kontostand .

Hello Beth
I would summarize this in a library. So bonuses and fees in plus and minus. A selection field for bonuses and fees and make the fields displayed dependent on these (e.g. entering the bonus or entering the fee). This way the total for this employee gives the account balance.

Ernst

Elizabeth Dixon

unread,
Feb 16, 2025, 3:58:46 PM2/16/25
to Er Mo, mementodatabase

Hallo Ernst, also in der Account-Bibliothek, richtig?  Mmms Skript dort einrichten?  Ok, das werde ich versuchen.  :)

Hi Ernst, so in the Account library right?  Set up Mmm's script there?  Ok, I will try that.  :)

Beth


--
You received this message because you are subscribed to the Google Groups "mementodatabase" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mementodataba...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/mementodatabase/a17f33dd-5a5c-491e-9635-630bcf371ff6n%40googlegroups.com.

Mmm

unread,
Feb 17, 2025, 5:23:31 AM2/17/25
to mementodatabase
Если ссылаетесь на какой-то скрипт, добавляйте ссылку на сообщение, если этот скрипт из другой темы.
Со стороны может сложно понять о чем речь.

Скрипт МММ для решения не нужен.

Вариант решения с полями JS.
Поля размещаются в библиотеке "Account".
На примере Awards.

let lb = 'Awards'; //имя библиотеки  "Awards"
let fd = 'Account'; //имя поля-записи библиотеки "Account" в библиотеке "Awards"
let abc = 'Bonus'; //имя числового поля с количеством бонусов

let sum = 0;
let e = entry();

let ee = e.linksFrom(lb, fd); //массив записей библиотеки  "Awards", которые ссылаются на текущую запись библиотеки "Account"

if (ee.length === 1) {
    sum = ee[0].field(abc):
} else if (ee.length > 0) {
    ee.map(a => sum += Number(a.field(abc))); //имя числового поля с количеством бонусов
}

/*
//Округление до 2 знаков, если нужно
if (sum > 0) {
    sum = sum.toFixed(2);
}
*/

sum;

Второе поле JS для Charges сделайте самостоятельно. 
Третье поле JS показывает разницу между полями 1 и 2.

Скрипты полей JS должны выполняться в реальном времени.

Скрипт не проверял, нет возможности создавать тестовые библиотеки.

воскресенье, 16 февраля 2025 г. в 23:58:46 UTC+3, mement...@gmail.com:

Mmm

unread,
Feb 18, 2025, 11:04:12 AM2/18/25
to mementodatabase
Тестовый вариант:



понедельник, 17 февраля 2025 г. в 13:23:31 UTC+3, Mmm:

Elizabeth Dixon

unread,
Feb 18, 2025, 11:01:45 PM2/18/25
to Mmm, mementodatabase

Thanks Mmm!  Testing your libraries now.  :)

Beth


Mmm

unread,
Feb 20, 2025, 10:42:27 AM2/20/25
to mementodatabase
Решение найдено? Тестовые библиотеки из облака можно удалять?

среда, 19 февраля 2025 г. в 07:01:45 UTC+3, mement...@gmail.com:

Elizabeth Dixon

unread,
Feb 20, 2025, 10:52:14 AM2/20/25
to Mmm, mementodatabase

Hi Mmm, things are crazy around the house at the moment , I downloaded so ok to remove from cloud.  Will take me a few days to get back to that issue.

Beth



Reply all
Reply to author
Forward
0 new messages