Allowance sheet
Backend
1. Variables
ensure var VarSetOfTextVehicleType kind: setOfText
deploy: fixedOnDeploy
value: "<root>
<node key='keyTwoWheeler'>Two wheeler</node>
<node key='keyFourWheeler'>Four Wheeler</node>
</root>"
ensure var VarSetOfTextTourType kind: setOfText
deploy: fixedOnDeploy
value: "<root>
<node key='keyTourAndReturnToHqOnSameDay'>Tour and return to HQ on same day</node>
<node key='keyNightHalt'>Night Halt</node>
</root>"
ensure var VarSetOfTextExpenseStatus kind: setOfText
deploy: fixedOnDeploy
value: "<root>
<node key='pending'>Pending</node>
<node key='approved'>Approved</node>
<node key='rejected'>Rejected</node>
</root>"
2. AllowanceSheet
ensure spreadsheet: AllowanceSheet
withFields: ["Date", "Employee", "Terminated", "Divider"]
ofTypes: [date, pickUser, bool, divider]
removeRoleSet: [Owner]
readRoleSet: [Owner]
insertRoleSet: [Salesman]
updateRoleSet: [Salesman]
ensure form EntityAllowance label: "Allowance" commentRoleSet:[Employee]
ensure section: Details label: "Expense Details"
ensure field Date defaultValue: "now" label: "Date of submission"
ensure field Employee disabled: true roleDataSource: [$Self] defaultValue: $Self
ensure field Terminated
permissionMatrix: {
'defaultPermission': 'invisible'
}
ensure field Divider dividerKind: thick
// section, Lodging
ensure section: Lodging label: "Lodging & Boarding"
ensure field TransparentDivider1 kind: divider color.value: transparent
ensure field StayStartDate kind: date
ensure field StayEndDate kind: date
ensure field NumberOfDay kind: number disabled: true min: 0
ensure field LodgingAmount kind: decimal min: 0.0 max: 800.0 numberOfDigitsAfterPeriod: 2
ensure field TotalAmount01 kind: decimal label: "Total amount" disabled: true numberOfDigitsAfterPeriod: 2
ensure field HotelName kind: text
ensure field HotelLocation kind: location
ensure field LodgingReceiptCopy kind: image label: "Receipt copy" showLabel: true
// section, MotorCarRunning
ensure section: MotorCarRunning label: "Motor Car Running & Maintenance"
ensure field TransparentDivider2 kind: divider color.value: transparent
ensure field VehicleType kind: pickText sourceVar: VarSetOfTextVehicleType
ensure field StartKm kind: decimal min: 0.0
ensure field EndKm kind: decimal
ensure field KmsTravelled kind: decimal disabled: true
ensure field TotalAmount02 kind: decimal label: "Total amount" disabled: true helperText: "₹ 3 / Km"
ensure field MaintenanceCost kind: decimal min: 0.0
ensure field Attachment kind: image showLabel: true
// section, DearnessAllowanceCharges
ensure section: DearnessAllowanceCharges label: "Dearness Allowance"
ensure field TransparentDivider3 kind: divider color.value: transparent
ensure field TourType kind: pickText sourceVar: VarSetOfTextTourType
ensure field NumberOfNight kind: number
ensure field PlacesTravelled kind: text
ensure field TotalAmount03 kind: decimal label: "Total amount" disabled: true
ensure field DearnessAllowanceReceiptCopy kind: image label: "Receipt copy" showLabel: true
// section, CourierXerox
ensure section: CourierXerox label: "Courier/Xerox/stationery"
ensure field TransparentDivider4 kind: divider color.value: transparent
ensure field Amount01 kind: decimal label: "Amount" max: 500.0
ensure field CourierXeroxReceiptCopy kind: image label: "Receipt copy" showLabel: true
// section, PublicTransportation
ensure section: PublicTransportation label: "Public Transportation & Misc. Reimbursement"
ensure field TransparentDivider5 kind: divider color.value: transparent
ensure field Amount02 kind: decimal label: "Amount" max: 1000.0
ensure field PublicTransportationReceiptCopy kind: image label: "Receipt copy" showLabel: true
// section, Summary
ensure section: Summary
ensure field Divider01 kind: divider
ensure field GrandTotal kind: decimal disabled: true min: 0.0 numberOfDigitsAfterPeriod: 2
ensure field Remarks kind: paragraph
ensure field ManagerStatus kind: pickText
permissionMatrix: {
'defaultPermission': 'read',
'Owner': 'write',
'$Manager': 'write'
}
sourceVar: VarSetOfTextExpenseStatus
defaultOptionId: "pending"
ensure field TransparentDivider6 kind: divider color.value: transparent
3. Stack layout
ensure layout Editor kind: editor
composites: [
Details,
Lodging,
MotorCarRunning,
DearnessAllowanceCharges,
CourierXerox,
PublicTransportation,
Summary
]
hideLabelComposites: [Details, Summary]
editorLayoutRenderingMode: stack
ensure form EntityAllowance asideDefaultLayout: Editor
4. Formulas
ensure formula KmsTravelled
assignToField: MotorCarRunning.KmsTravelled
formula: "${f:EndKm} - ${f:StartKm}"
ensure formula Amount3
assignToField: MotorCarRunning.TotalAmount02
formula: "${f:MotorCarRunning.KmsTravelled} * 3"
ensure formula Amount7
assignToField: DearnessAllowanceCharges.TotalAmount03
formula: "
let tourType = ${f:TourType};
let ans;
if (tourType == 'keyTourAndReturnToHqOnSameDay') {
ans = 125;
} else {
ans = 250 * ${f:NumberOfNight};
}
ans"
ensure formula TotalAmount01
assignToField: Lodging.TotalAmount01
formula: "${f:NumberOfDay} * ${f:LodgingAmount}"
ensure formula NumberOfDay
assignToField: Lodging.NumberOfDay
formula: "
const fromDate = ${f:StayStartDate};
const toDate = ${f:StayEndDate};
if(fromDate && toDate) {
const date1 = new Date(fromDate);
const date2 = new Date(toDate);
const diffInMs = date2 - date1;
const diffInDays = diffInMs / (1000 * 60 * 60 * 24);
diffInDays
} else {
0;
}"
ensure formula GrandTotal
assignToField: Summary.GrandTotal
formula: "${f:TotalAmount01} + ${f:TotalAmount02} + ${f:TotalAmount03} + ${f:Amount01} + ${f:Amount02}"
Frontend
1. Actions
a. AddAllowance
// this action will insert allowance data to spreadsheet
ensure action AddAllowance kind: rowInsert
icon: "AddCircleOutlineRounded"
spreadsheet: AllowanceSheet
sendMessageToInbox: true
b. EditAllowanceSheet
ensure spreadsheet AllowanceSheet
ensure layoutSpreadsheet TableLayout kind: table
showComps: [
Details.Date,
Details.Employee,
Summary.GrandTotal,
Summary.Remarks,
Summary.ManagerStatus
]
ensure action EditAllowanceSheet kind: spreadsheetEditor
icon: "ViewListRounded"
spreadsheet: AllowanceSheet
layoutSpreadsheet: TableLayout
2. Group actions
Actions are grouped here for demo. Merging the grouped actions from Attendance Sheet.
ensure group MyPortal
pinnedActions: [AddAttendance, ReportAttendance, AddAllowance]
pinnedActionSetMobile: [AddAttendance]
actionPermission: {
'AddAttendance': {
'menuGroup': '1',
'roles': [
'Owner'
]
},
'AddAllowance': {
'menuGroup': '1',
'roles': [
'Salesman'
]
},
'EditAttendanceSheet': {
'menuGroup': '2',
'roles': [
'Owner'
]
},
'EditAllowanceSheet': {
'menuGroup': '2',
'roles': [
'Owner'
]
},
'ReportAttendance': {
'menuGroup': '3',
'roles': [
'Owner'
]
}
}