application "Income and Expense"
{
type = public
date format = "dd-MMM-yyyy"
section "Home"
{
form Income
{
Income_Source
(
displayname = "Income Source"
type = text
)
Amount_of_Income
(
displayname = "Amount of Income"
type = number
width = 20
)
on add
{
on success
{
thisapp.updateincome();
}
}
on edit
{
on success
{
thisapp.updateincome();
}
}
on delete
{
on success
{
thisapp.updateincome();
}
}
}
list "Income View"
{
show all rows from Income
(
Income_Source as "Income Source"
Amount_of_Income as "Amount of Income"
)
}
form Expense
{
Type_of_Expense
(
displayname = "Type of Expense"
type = text
)
Expense_Amount
(
displayname = "Expense Amount"
type = number
width = 20
)
on add
{
on success
{
thisapp.updateexpense();
}
}
on edit
{
on success
{
thisapp.updateexpense();
}
}
on delete
{
on success
{
thisapp.updateexpense();
}
}
}
list "Expense View"
{
show all rows from Expense
(
Type_of_Expense as "Type of Expense"
Expense_Amount as "Expense Amount"
)
}
form Amount_In_Hand
{
displayname = "Amount In Hand"
Total_Income
(
displayname = "Total Income"
type = number
width = 20
)
Total_Expense
(
displayname = "Total Expense"
type = number
width = 20
)
Amount_In_Hand
(
type = formula
value = (Total_Income - Total_Expense)
)
}
summary "Amount In Hand View"
{
show all rows from Amount_In_Hand
(
Total_Income as "Total Income"
Total_Expense as "Total Expense"
Amount_In_Hand as "Amount In Hand"
)
}
}
functions
{
void updateincome()
{
x = 0;
for each rec in Income
{
x = (x + rec.Amount_of_Income);
}
aih = Amount_In_Hand [ID != 0];
aih.Total_Income = x;
}
void updateexpense()
{
x = 0;
for each rec in Expense
{
x = (x + rec.Expense_Amount);
}
aih = Amount_In_Hand [ID != 0];
aih.Total_Expense = x;
}
}
}