Using C # To dynamically compile the wage calculation formula,

Source: Internet
Author: User

Using C # To dynamically compile the wage calculation formula,
1. wage calculation formula

Every enterprise will certainly use wage calculation. Wage Payment is a very sacred task, and wage calculation is a very important task. Excel has a very powerful formula function, which helps many financial personnel calculate their salaries. However, if the number of employees in an enterprise is large and the formula for calculating their salaries is complex, the Excel user must have a very high hand, but it is also very difficult to maintain the Excel.

Therefore, many enterprises of a certain scale have a set of wage systems, and the well-performed wage systems will provide the editing function of the wage formula, which is very similar to the Excel Formula, in this way, financial personnel are easy to use. Assume that a factory has the following basic wage fields:

Serial number

Field

Description

1

Basic salary

The basic salary of an employee.

2

Status

New entry, trial, finalization, and formal launch.

3

Employee nature

Disabled and normal.

4

Working days per month

The number of working days in the current month.

5

Days before turning positive

The number of days before the employee turns positive in the current month.

6

Days after turning positive

The number of days after the employee turns positive in the current month.

7

Total overtime hours

Overtime hours for non-holiday and Saturday.

8

Total weekend overtime hours

Total number of overtime hours on weekends.

9

Total overtime hours on holidays

Total overtime hours on holidays.

10

Total peak hours

The total number of hours for the normal top shift.

11

Total weekend class hours

The total number of hours for the top shift on weekends.

12

Total hours of the holiday class

The total number of hours of the holiday class.

13

Actual attendance days

The actual number of days of attendance.

14

High temperature allowance

High temperature allowance provided by the factory to employees.

15

Education Subsidy

The allowance provided by the factory to highly educated employees.

16

Bonus points

Different Fund points are set for each employee level.

17

Each bonus

Based on the monthly performance, fund points, and each bonus point.

18

Odor allowance

The smell allowance provided by the factory to employees.

19

Dust allowance

The dust allowance provided by the factory to employees.

20

Time off

The number of hours of the event month.

21

Sick leave hour

The number of hours of sick leave each month.

22

Absenteeism hour

The number of absenteeism hours per month.

23

Meal fee

The monthly meal fee for employees in the canteen.

24

Meal supplement

Meal subsidies provided by the factory to employees.

25

Pay-as-you-go

Sales commission, handling Commission, etc.

Salary formula:

Serial number

Project

Formula

1

Basic pay-as-you-go

1. Status = positive, 1310/month working days * Days Before positive + basic salary/month working days * Days After positive.

2, status! = Finalize, pay-as-you-go basic salary = basic salary/working days per month * Actual attendance days.

2

Regular overtime

Staff type = Persons with disabilities, overtime at ordinary times = 0; otherwise, overtime at ordinary times = basic salary/21.75/8 * total overtime hours x 1.5.

3

Total weekend overtime fee

Staff type = disabled, weekend overtime = 0, otherwise weekend overtime = basic salary/21.75/8 * total weekend overtime hours * 2.

4

Overtime on holidays

Staff nature = Persons with disabilities, overtime for holidays = 0,

Otherwise, the overtime fee on holidays = basic salary/21.75/8 * total overtime on holidays x 3.

5

Daily top shift fee

Nature of employees = Persons with disabilities, daily top shift cost = 0,

Otherwise, the daily peak fee = basic salary/21.75/8 * total hourly peak fee x 1.5.

6

Weekend Class fee

Staff nature = Persons with disabilities, weekend top shift cost = 0,

Otherwise, the weekend Class fee = basic salary/21.75/8 * total weekend class hours x 2.

7

Top course fee on holidays

Nature of employees = Persons with disabilities, top class fee for holidays = 0,

Otherwise, the top class fee for holidays = basic salary/21.75/8 * total number of hours for the top class on holidays * 3.

8

Real-time high temperature allowance

Staff nature = Persons with Disabilities, the real-time high-temperature allowance is 0,

Real-time high temperature allowance = high temperature allowance/monthly working days * Actual attendance days.

9

Real-time education subsidy

If the pay-as-you-go method includes "Commission", the value is 0,

Otherwise, the education is subsidized.

10

Bonus count

Status = change to positive, and pay-as-you-go mode = Sales Commission, (basic salary-1310)/month working days * Days before the change + Fund points * Each bonus point.

If the pay-as-you-go method includes a "Commission", the Fund points * each point of bonus will be paid.

11

Real-time odor allowance

Odor allowance/working days per month * Actual attendance days.

12

Real-time dust allowance

Real-time dust allowance = dust allowance/month working days * Actual attendance days.

13

Deduction of personal leave

Deduction of personal leave = basic salary/working days of the month/8 hours of personal leave.

14

Sick leave deduction

Sick leave deduction = basic salary/working days/8 * sick leave hours.

15

Cut off

Deduction of absenteeism = basic salary/working days of the month/8 x absenteeism hours.

 

2. Technical Implementation

To. net, the interpreter of the formula must be implemented, and the most powerful interpreter is undoubtedly. net compilation engine, the compilation engine can implement any function .. Net comes with the dynamic compilation logic, but it is not easy to organize a compilation logic and display it properly, and combine the appropriate extension functions.

The wage calculation formula mentioned above may change frequently. Manufacturers may add more rules or modify some rules based on their own needs, even the rules for each month are different. They are only the same as those for the previous month. In this case, it is reasonable to hand over the wage calculation formula to the financial personnel of the factory. This puts forward higher requirements for business system developers. It is more difficult for individual developers.

The CKRule rule engine provides this function. Its customer rule pool allows customers to customize formulas. Business system developers can implement dynamic formulas in just a few steps. 1. Configure keywords, comparison logic and conclusions/Operations, 2. load configurations in the business system, and set the interface, 3. You can edit rules in a friendly interface and save the rules to the database. 4. Load the customer rule pool in the main rule call.

In the tool, you can customize the type and pass in outgoing attributes:

Defines the keywords and operators of the customer rule pool.

The keyword can be the same as the input or output type, or can be created. The conclusion operation is used to adapt the user to Excel-like operations using the IIF syntax.

Set the master rule. In the master rule, you only need to call the rules in the database and then execute the rule pool. The Code is as follows:

Var _ table = LookDB (@"

Select

''As id,

Sindex as "" index "",

''As returnType,

'Get' + name as propname,

0 as codestyle,

''As ifcode,

0 as thencodeisscript,

'Result. '+ name +' = '+ CalcCode +'; 'as thencode,

0 as priority,

''As execstep

From poolset

");

InitPool (_ table );

ExePool ();

Business System implementation

As part of the business system, developers can define the interface as needed. To meet the needs of the original system. The formula setting interface can also be more user-friendly. After the formula is set, the new formula will be used for wage calculation.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.