STO - Utilitaires de facturation
[En rédaction]
Amf
- generateAMFNights(List<Object[]> events, String resultDayformat) -
_facUtils.generateAMFNights(List<Object[]> events, String resultDayformat)
- Generates one result line for each given event that will span over two consecutive days. Events in array must have the following properties 1 - key 2 - group 3 - start date 4 - end date 5 - priority 6 - type
_facUtils.generateAMFNights(_events, "dd/MM"));
- isAmfDayCancelled(DateTime date, List
cancellationEvents, String department) - _facUtils.isAmfDayCancelled(DateTime date, List<String> cancellationEvents, String department)
- Check if there are any cancelling events for the given department at a given date. Returns true if there is at least one cancelling event during that day.
_facUtils.isAmfDayCancelled(date, cancellingEventsTypes, department));
// This will check if there is at least one event of one of the types listed in cancellingEventsTypes
// for the department.
- getAMFFromGroup(String group, Date atDate) -
_facUtils.getAMFFromGroup(String group, Date atDate)
- Retrieves the AMF employee that is responsable of the given group at a given date.
_facUtils.getAMFFromGroup(group, date));
AMF
- getAMFEvents(List{String} extraTypes) -
_facUtils.getAMFEvents(List{String} extraTypes)
- Returns all P.THEORIQUE, P.C_SUPPLEMENT, any type from the list and all absence events that are related to an AMF and the given child in the period
int allAmfEvs = _facUtils.getAMFEvents(["P.C_SPECIAL"]);
- getAMFTypedEvents(List
types) - _facUtils.getAMFTypedEvents(List<String> types)
- Returns all given types events that are related to an AMF and the given child in the period. The returned entries are objects containing : id, department, start, end, priority, type.
int allAmfEvs = _facUtils.getAMFTypedEvents(['A.NONFAC', 'A.MALADIE']);
- getAMFTypedEvents(List
types, String departement) - _facUtils.getAMFTypedEvents(List<String> types, String departement)
- Returns all given types events that are related to an AMF in the period. The returned entries are objects containing : id, department, start, end, priority, type.
int allAmfEvs = _facUtils.getAMFEmployeeTypedEvents(['A.NONFAC', 'A.MALADIE'], "710A1002");
- getAMFEvents(List{String} extraTypes, boolean currentChildOnly) -
_facUtils.getAMFEvents(List{String} extraTypes, boolean currentChildOnly)
- Returns all P.THEORIQUE, P.C_SUPPLEMENT, any type from the list and all absence events that are related to an AMF and either the given child or all children in the period
int allAmfEvs = _facUtils.getAMFEvents(["P.C_SPECIAL"], false);
- getAMFEvents() -
_facUtils.getAMFEvents()
- Returns all P.THEORIQUE, P.C_SUPPLEMENT and all absence events that are related to an AMF and the given child in the period
int allAmfEvs = _facUtils.getAMFEvents();
Child
- getDossier(Child childEntry) -
_facUtils.getDossier(Child childEntry)
- Returns the cached dossier of the given Child. The current plan execution child is available throught the ‘_child’ variable.
_facUtils.getDossier(_child);
- getChildMonthAge() -
_facUtils.getChildMonthAge()
- Returns number of full monthes that occured between the current child birth date and the current period start date.
_facUtils.getChildMonthAge();
- getChildMonthAge(Date atDate) -
_facUtils.getChildMonthAge(Date atDate)
- Returns the age of the child in full month between the birthdate and the given date.
int nbMonth = _facUtils.getChildMonthAge(new Date().toJavaDate());
- getFrateriePosition() -
_facUtils.getFrateriePosition()
- Returns the position of the child in the fratrie. Without any override,
this will count the number of children at the start of the period that
have an active
SECTION
page.
_facUtils.getFrateriePosition();
- getFrateriePosition() -
_facUtils.getFrateriePosition()
- Returns the position of the child in the fratrie. Without any override,
this will count the number of children at the start of the period that
have an active
SECTION
page.
_facUtils.getFrateriePosition(rabaisFratrieForAllSiblings, keepChildrenAtSamePosition, rabaisFratrieMustHaveSameAddress);
rabaisFratrieForAllSiblings - true if then all the siblings will have the same position, false then each sibling will get a different index,starting from 1 keepChildrenAtSamePosition - false if position depends on the date of birth and the alphabetical order of the first name rabaisFratrieMustHaveSameAddress - true if siblings must have the same address in order to get the rabais fratrie
Computation Periods
- isAdaptation() -
_facUtils.isAdaptation()
- Returns true if the current period is an adaptation period, based on the
number of adaptation days in the current
SECTION
pages. If one of the page is an adaptation, the whole period yields true.
_facUtils.isAdaptation();
- isFirstPresenceEver() -
_facUtils.isFirstPresenceEver()
- Returns true if there is no
SECTION
page that starts before the date on the last day of the past month and the line has not already been applied during the current month
_facUtils.isFirstPresenceEver();
- isFirstPeriodEver() -
_facUtils.isFirstPeriodEver()
- Returns true if there is no
SECTION
page that starts before the current period start boundary.
Be careful, if the beginning of the month starts with a restriction period, then the following period considers that it is not the first period.
_facUtils.isFirstPeriodEver();
- generateAMFDepassementHours(List<Object[]> timingEvents, String requestedEventType, int day, String minHour, String maxHour, String format, boolean generateIfMultiDays, List
canCancelHours) - _facUtils.generateAMFDepassementHours(List<Object[]> timingEvents, String requestedEventType, int day, String minHour, String maxHour, String format, boolean generateIfMultiDays, List<String> canCancelHours)
- Generate a result every time a child is present but was not supposed to be. This happen when the child arrives early or leaves late, based on the real events.
_facUtils.generateAMFDepassementHours(amfEvents, "P.REELLE", DateTimeConstants.MONDAY, null, null, "yy-MM-dd", true, cancellingEventsTypes);
//This will generate all the hours on mondays where the P.REELLE events are not expected and not cancelled by events from cancellingEventsTypes.
- getAbsenceDurationAtPeriod(List
types) - _facUtils.getAbsenceDurationAtPeriod(List<String> types)
- Based on the given event type, this function retrieves all events that span over the current period and computes at the end date the number of days that have been elapsed since the start of the event. This allows to define for exemple special rabais based on sickness durations.
int duration = _facUtils.getAbsenceDurationAtPeriod(["A.C_MALADIE", "A.C_ACCIDENT"]);
- generatePresenceMinutesByGroup(List
eventTypes) - _facUtils.generatePresenceMinutesByGroup(List<String> eventTypes)
- Generate a line of result for each group giving the count of minutes of presence of the current child. The types given as argument allow to know which types must be retrieved in the events of the child during the current period to slice and count.
_facUtils.generatePresenceMinutesByGroup(["P.REELLE", "P.THEORIQUE"]);
- isAdaptation() -
_facUtils.isAdaptation()
- Returns The list of departement that are in adaptation for the current period but only if the current period is the first one of the section page.
var deps = _facUtils.getAdaptationDepartement();
for(var key in deps) {
var res = _facUtils.newLineResult();
res.setDepartement(deps[key]);
res.set("MONTANT", new BigDecimal(100));
res.setArticle("DIV01");
}
- isReservation() -
_facUtils.isReservation()
- Returns true if the current period is a reservation period, based on the
RESERVATION
field in the currentSECTION
pages. If one active page is a reservation then the period yields true.
_facUtils.isReservation();
- isMajored() -
_facUtils.isMajored()
- By default, returns true if the current period income has a state field with a value of “2”. This is widely used for exemple to separate children that live within the structure associated cities and the one that leave further and need to be given extra fees.
_facUtils.isMajored();
Debitor
- getDebitorsByDay() -
_facUtils.getDebitorsByDay()
- Returns a map that contains for each day the relevant debitor that is selected in the DONNEES_FACTURATION page. This can be used to select which debitor should be selected for the facturation of the given day
//This will retrieve for exemple a sharing between debitors 00001 and 00002 as
//1 => 00001, 2 => 00001, 3 => 00002, 4 => 00002, 5 => 00002
int debsByDay = _facUtils.getDebitorsByDay();
Discounts
- applyFirstAvailableDiscount(List{String}) -
_facUtils.applyFirstAvailableDiscount(List{String})
- Iterates over all the line result entries of the given discount list and applies the first available one to the current lines result values. All the discounts must be line numbers. If a discount line yields multiple results, then the first one will be taken
_facUtils.applyAvailableDiscount(["A01". "A02"]);
- applyAvailableDiscounts(List{String}, boolean) -
_facUtils.applyAvailableDiscounts(List{String}, boolean)
- Iterates over all the line result entries of the given discount list and applies the available one to the current lines values. All the discounts must be line numbers. If a discount line yields multiple results, then the first one will be taken. This function might stop after applying the first discount if the second parameters of the function says so
//Applies A01 if found, otherwise A02 if found.
_facUtils.applyAvailableDiscounts(["A01". "A02"], true);
//Applies both A01 and A02 if found.
_facUtils.applyAvailableDiscounts(["A01". "A02"], true);
- getRabaisFraterie(int position) -
_facUtils.getRabaisFraterie(int position)
- Based on the given integer position, returns the BigDecimal value of the discount that matches the position using the FAC-RABAIS-FRATRIE tabelle in UNI85
_facUtils.getSlotPrice("1", null, "TARIF_PRE");
Events
- generateEventsByDay(SlotGroup slotGroup, List
events, Predicate predicate, Integer day, String format) - _facUtils.generateEventsByDay(SlotGroup slotGroup, List<Gtpevt> events, Predicate<Gtpdep> predicate, Integer day, String format)
- Generates a result that contains the start date of the event for each attendance slot corresponding to the additional/breakdown events
// Creates a line if a supplement of an extracurricular group corresponding to the slot id "MON_H1".
_facUtils.generateEventsByDayForSlot(new _global.SlotGroup("MONS01", ["MON_H1"],[]), _global.supplements, _global.isParaScolaire, DateTimeConstants.MONDAY, "yy-MM-dd");
- generateEventsByDay(List
events, Predicate predicate, String article) - _facUtils.generateEventsByDay(List<Gtpevt> events, Predicate<Gtpdep> predicate, String article)
- Generates results that contain the length in decimal hours of the event as amount but only if it matches the given predicate.
Group
- isHolidays(Gtpdep grp) -
_facUtils.isHolidays(Gtpdep grp)
- Predicate on group type that will yield true if the group type is ‘holidays’
var isHoly = _facUtils.isHolidays(_facUtils.getGroup("VA1"));
- getGroup(String groupId) -
_facUtils.getGroup(String groupId)
- Allows to fetch a group entity from its id
var myGroup = _facUtils.getGroup("VA1");
Income
- getIncomesByDay() -
_facUtils.getIncomesByDay()
- Returns a map that contains for each day the relevant income that is the sum of the incomes of the selected intervenants in the DONNEES_FACTURATION page for each day through the “INTERV_” fields. The computations are performed at the beginning of the computation period.
//This will retrieve for exemple
//1 => 0, 2 => 1500, 3 => 0, 4 => 6000, 5 => 6000
int incomeByDay = _facUtils.getIncomesByDay();
- getStatusByDay() -
_facUtils.getStatusByDay()
- Returns a map that contains for each day the associated billing status
//This will retrieve for exemple
//1 => 1, 2 => 2, 3 => 1, 4 => 2, 5 => 2
int statusByDay = _facUtils.getStatusByDay();
Prestation Computations
- generateFraisKilometriques(String articleId, String dateFormat) -
_facUtils.generateFraisKilometriques(String articleId, String dateFormat)
- Generates a result every time the km fees type appears on some day within the current period. If the event isn’t cancelled by another absence event, then the function yields it
_facUtils.generateFraisKilometriques("P3200.1", "yy-MM-dd");
//This yields for example a result with amount 1 and "21/06/12" as details label if this event isn't cancelled
- generateFraisForType(String typeFrais, String articleId, String dateFormat) -
_facUtils.generateFraisForType(String typeFrais, String articleId, String dateFormat)
- Generates a result every time the requested fee type appears on some day within the current period. If the event isn’t cancelled by another absence event, then the function yields it.
_facUtils.generateFraisForType("FRAIS_KILOMETRIQUES", "P3200.1", "yy-MM-dd");
//This yields for example a result with amount 1 and "21/06/12" as details label if this event isn't cancelled
- generateFraisBricolage(String articleId, String dateFormat) -
_facUtils.generateFraisBricolage(String articleId, String dateFormat)
- Generates a result every time the bricolage fees type appears on some day within the current period. If the event isn’t cancelled by another absence event, then the function yields it
_facUtils.generateFraisBricolage("P3200.2", "yy-MM-dd");
//This yields for example a result with amount 1 and "21/06/12" as details label if this event isn't cancelled
- generatePrestationForSlot(String slotId, String prestation, Predicate{Gtpdep}, String dateFormat) -
_facUtils.generatePrestationForSlot(String slotId, String prestation, Predicate{Gtpdep}, String dateFormat)
- Generates a result every time the wanted slot and prestation appears on the given day in the current period. If the prestation isn’t cancelled by another absence event, then the function yields it
_facUtils.generatePrestationForSlot(MON_H3", "REP01PS", null, "EEE dd/MM");
//This yields for exemple a result with amount 1 and "Lun 06/12" as details label if this event isn't cancelled
- generatePrestationForEvent(String eventType, Predicate{Gtpdep}, String dateFormat) -
_facUtils.generatePrestationForEvent(String eventType, Predicate{Gtpdep}, String dateFormat)
- Generates a result every time the requested event type appears on some day within the current period. If the event isn’t cancelled by another absence event, then the function yields it
_facUtils.generatePrestationForEvent("P.PRESTATION.MIDI", null, "EEE dd/MM");
//This yields for exemple a result with amount 1 and "Lun 06/12" as details label if this event isn't cancelled
Resulting lines
- clonePreviousLines(String linesIdToClone) -
_facUtils.clonePreviousLines(String linesIdToClone)
- Clone the lines from the given previous lines and set them as current line result. This can be useful sometimes when we want to perform divide and conquer plan strategy instead of storing all computations in the same line.
//Generating 3 result lines that are copys of "PS0100"
_facUtils.clonePreviousLines("PS0100");
- generateAmountLine(Map{String, Integer}) -
_facUtils.generateAmountLine(Map{String, Integer})
- With the given map department -> amount, this function generates a result for each department and associates the corresponding number as its main result amount.
//Any map with some results
var deps = {
"ONE" : 3,
"TWO" : 15
};
_facUtils.generateAmountLine(deps);
- newLineResult() -
_facUtils.newLineResult()
- Returns a new result object. A result object if filled allows to generate some bill lines.
//Generating 3 result lines
for(var i = 0; i < 3; i++) {
ver newRes = _facUtils.newLineResult();
newRes.set('MONTANT', BigDecimal.ONE);
newRes.setSpecificLabel("Result #" + i);
}
Results that are created through this call are automatically added to the global result set of the plan and are associated with the current line of the plan.
- newLineResult(boolean) -
_facUtils.newLineResult(boolean)
- Returns a new result object. A result object if filled allows to generate some bill lines. This line might not be automatically added to the final results
//Generating 3 result lines but not persisting them
for(var i = 0; i < 3; i++) {
ver newRes = _facUtils.newLineResult(false);
newRes.set('MONTANT', BigDecimal.ONE);
newRes.setSpecificLabel("Result #" + i);
}
Results that are created through this call are automatically added if requested to the global result set of the plan and are associated with the current line of the plan.
Section
- getIrregularPages(Date periodStart) -
_facUtils.getIrregularPages(Date periodStart)
- Get all the active pages that have a minimal number of hours set in the
HEURES_MINIMALES
field.
_facUtils.getIrregularPages(startDate);
- getAMFIrregularPages(Date periodStart, List
cancellationEvents) - _facUtils.getAMFIrregularPages(Date periodStart, List<String> cancellationEvents)
- Get the active AMF section pages with irregular hours at a given date that are not cancelled by the given even type. If there are multiple AMF section page at the given date, return the all that are not cancelled by events of type cancellationEvents. If there is no AMF page with irregular hours, this will return an empty list.
_facUtils.getAMFIrregularPages(startDate, cancellationEventsTypes);
Section Computations
- getSlotDuration() -
_facUtils.getSlotDuration()
- Returns the duration in minute of the given slot in the active group of the current period. If there is no active group, then it returns 0. If the slot is not found in the slot list, it returns 0.
- getDepartementFromSection() -
_facUtils.getDepartementFromSection()
- Returns the debitor department as
G_group
withgroup
beeing the group value of the active section page during the current period.
result.setDepartement(_facUtils.getDepartementFromSection());
- getCurrentSection(boolean allowEmpty) -
_facUtils.getCurrentSection(boolean allowEmpty)
- Returns the given SECTION DossierPage if exists. If it doesn’t exist, then it crashed if asked to do so, or return null if allowed. Note that the returned page is based on the current line allowed categories. Thus, if we’re working on Prescolaire pages, only the prescolaire pages can be returned. This allows to automatically fetch the right page from a multi page children.
//Setting the current line as 1 if the current page is a reservation
var sec = _facUtils.getCurrentSection(true);
if(sec.getValueAsBoolean("RESERVATION")) {
result.set("MONTANT", BigDecimal.ONE);
}
Slot Computations
- hasSlotCombinaison(SlotGroup config, int dayOfWeek, Predicate{Gtpdep}, Date atDate) -
_facUtils.hasSlotCombinaison(SlotGroup config, int dayOfWeek, Predicate{Gtpdep}, Date atDate)
- Returns true if the combinaison of wanted and excluded slots appear on the given day in the pages defined at the given date.
var SlotGroup = Java.type("saierp.dbcode.business.gtp.tasks.cre.SlotGroup");
var isUsed = _facUtils.hasSlotCombinaison(new SlotGroup("SOMEID", ["MON_H1"], ["MON_H2"]), DateTimeConstants.MONDAY, null, null);
- getNonCancelledPresenceSlotInPeriod(List
slots, List groups) - _facUtils.getNonCancelledPresenceSlotInPeriod(List<String> slots, List<String> groups)
- Returns the list of days in which the presence period events are not cancelled by absence ones.
var presenceDays = getNonCancelledPresenceSlotInPeriod(["MON_H1_SLOT", "TUE_H2_SLOT"], ["GR1", "GR2"]);
- computeSlotTotal(String prefix, String article) -
_facUtils.computeSlotTotal(String prefix, String article)
- Based on the given prefix, fetches all lines that ends with
prefix
+01
to07
and sum their amounts by departement and specific labels. It then loads the value of theprefix
+PU
line and generate final lines with the departement amount as number, the specific label, and the total amount as the number times the PU amount
//The following line will multiply SOME_01, SOME_02, .... SOME_07 lines
//by SOME_PU and output the result using "PA_1000.1" article on the final bill
_facUtils.computeSlotTotal("SOME_", "PA_1000.1");
- computeDaysForSlot(SlotGroup config, int dayOfWeek, Predicate{Gtpdep}) -
_facUtils.computeDaysForSlot(SlotGroup config, int dayOfWeek, Predicate{Gtpdep})
- Computes the number of times the combinaison of wanted and excluded slots appear on the given day in the current period. This is based on the getCurrentSection function that allows empty period. It returns this number as an integer.
var SlotGroup = Java.type("saierp.dbcode.business.gtp.tasks.cre.SlotGroup");
var amounr = _facUtils.computeDaysForSlot(new SlotGroup("SOMEID", ["MON_H1"], ["MON_H2"]), DateTimeConstants.MONDAY, null);
- getSlotPrice(String slotId, Predicate
groupCondition, String tabelleOverride) - _facUtils.getSlotPrice(String slotId, Predicate<Gtpdep> groupCondition, String tabelleOverride)
- If the group condition matches the current section page of the current child, or null if there is no condition, then this function retrieves in UNI85 the given slotId combo entry from the specified tabelle. If the tabelle is null or empty, it uses the ‘TARIF_category’ tabelle based on the current section category field value. The row value is based on the child parents’s income at the start of the period.
_facUtils.getSlotPrice("1", null, "TARIF_PRE");
- generateDaysForSlot(SlotGroup config, int dayOfWeek, Predicate{Gtpdep}, String dateFormat) -
_facUtils.generateDaysForSlot(SlotGroup config, int dayOfWeek, Predicate{Gtpdep}, String dateFormat)
- Generates a result every time the combinaison of wanted and excluded slots appear on the given day in the current period. This is based on the getCurrentSection function that allows empty period. Each result is associated with the given day formatted as given set in the SpecificLabel of the line
var SlotGroup = Java.type("saierp.dbcode.business.gtp.tasks.cre.SlotGroup");
_facUtils.generateDaysForSlot(new SlotGroup("SOMEID", ["MON_H1"], ["MON_H2"]), DateTimeConstants.MONDAY, null, "EEE dd/MM");
//This yields for exemple a result with amount 1 and "Lun 06/12" as details label
- getGroupRelevantSlots(String groupId, int dayOfWeek) -
_facUtils.getGroupRelevantSlots(String groupId, int dayOfWeek)
- The retrieves the list of slots (not the modules) for the given group and day. The date of the retrieval is the first day of the perdiod.
var slotLists = _facUtils.getGroupRelevantSlots("GR1", DateTimeConstants.MONDAY);
- hasSlotCombinaison(SlotGroup config, int dayOfWeek, Predicate{Gtpdep}) -
_facUtils.hasSlotCombinaison(SlotGroup config, int dayOfWeek, Predicate{Gtpdep})
- Returns true if the combinaison of wanted and excluded slots appear on the given day in the current period. This is based on the getCurrentSection function that allows empty period.
var SlotGroup = Java.type("saierp.dbcode.business.gtp.tasks.cre.SlotGroup");
var isUsed = _facUtils.hasSlotCombinaison(new SlotGroup("SOMEID", ["MON_H1"], ["MON_H2"]), DateTimeConstants.MONDAY, null);
Utils
- getTabellePrice(String tabelle, Date atDate, BigDecimal rowValue, String comboKey) -
_facUtils.getTabellePrice(String tabelle, Date atDate, BigDecimal rowValue, String comboKey)
- Returns the value from the given tabelle or throws an exception otherwise
_facUtils.getTabellePrice("TARIF_PRE", new Date().toJavaDate(), Bigdecimal.valueOf("14"), "1");
- isPreScolaire(Gtpdep group) -
_facUtils.isPreScolaire(Gtpdep group)
- Based on the given Gtpdep group entity, defines if the group is associated with Prescolaire type of schooling. This is useful to construct Predicate objects to be used in the plan
var myGroup = someGroup;
_global.isPreScolaire = new java.util.function.Predicate(function(group) { return _facUtils.isPreScolaire(group);})
- isPreScolaire(Gtpdep group) -
_facUtils.isPreScolaire(Gtpdep group)
- Based on the given Gtpdep group entity, defines if the group is associated with Parascolaire type of schooling. This is useful to construct Predicate objects to be used in the plan
var myGroup = someGroup;
_global.isParaScolaire = new java.util.function.Predicate(function(group) { return _facUtils.isParaScolaire(group);})
- getCategory() -
_facUtils.getCategory()
- Retrieves based on the current
SECTION
page the associated category.
var articleId = "2000" + getCategory();
- getPeriodDaysSize() -
_facUtils.getPeriodDaysSize()
- Returns as an integer the number of full days during the current period
var periodDays = _facUtils.getPeriodDaysSize();
- getMonthDaysSize() -
_facUtils.getMonthDaysSize()
- Returns as an integer the number of full days during the month of the current period
var periodDays = _facUtils.getMonthDaysSize();
- getSummedResultForSubPeriods(String lineId) -
_facUtils.getSummedResultForSubPeriods(String lineId)
- Get the sum of all the lines of a given type that have been computed so far. This will search in all the previous subperiod and in the current period if the line has been computed and return the sum of all the computation.
_facUtils.getSummedResultForSubPeriods("PF1000003");
//This will return the result of all the lines PF1000003 that have been computed so far.
- countActiveMonths() -
_facUtils.countActiveMonths()
- Defines the number of months in the period in which the child has some active pages.
//This example computes the number of active months for the child during
the current scholar year
var startYear = _month > 7 ? _year : _year - 1;
var startP = new DateTime(_startYear, 8, 1 ,0, 0,0);
var endYear = _month > 7 ? _year + 1 : _year;
var endP = new DateTime(endYear, 7, 31, 0, 0, 0);
var nbMonthes = _facUtils.countActiveMonths(startP, endP);
- computeSubPeriods(DateTime start, DateTime end) -
_facUtils.computeSubPeriods(DateTime start, DateTime end)
- Computes all the sub-periods between the two given boundaries.
_facUtils.computeSubPeriods(startDate, endDate));
- sortCurrentLinesByDetails() -
_facUtils.sortCurrentLinesByDetails()
- Sorts the current line results based on details alphabetical order
_facUtils.sortCurrentLinesByDetails();