mirror of
https://github.com/CatalaLang/catala.git
synced 2024-11-08 17:10:22 +03:00
71bb67163c
Command used: `sed -i 's/\([-+*/><=]=\?\)[.$@^€$]/\1/g' **/*/*.catala_*` The overload test, of course, is kept unchanged and ensures that explicit operators still work.
134 lines
4.1 KiB
Plaintext
134 lines
4.1 KiB
Plaintext
## Section 132
|
||
|
||
```catala-metadata
|
||
# We only formalize part (c) here
|
||
declaration enumeration DiscountType:
|
||
-- Property
|
||
-- Services
|
||
|
||
declaration scope QualifiedEmployeeDiscount:
|
||
input customer_price content money
|
||
input employee_price content money
|
||
output gross_profit_percentage content decimal
|
||
output qualified_employee_discount content money
|
||
output employee_discount content money
|
||
context aggregate_cost content money
|
||
input discount_type content DiscountType
|
||
internal is_property content boolean
|
||
internal is_services content boolean
|
||
|
||
scope QualifiedEmployeeDiscount:
|
||
definition is_property equals match discount_type with pattern
|
||
-- Property: true
|
||
-- Services: false
|
||
definition is_services equals match discount_type with pattern
|
||
-- Property: false
|
||
-- Services: true
|
||
```
|
||
|
||
### (c) Qualified employee discount defined
|
||
For purposes of this section—
|
||
|
||
#### (1) Qualified employee discount
|
||
|
||
The term “qualified employee discount” means any employee discount with respect
|
||
to qualified property or services to the extent such discount does not exceed—
|
||
(A) in the case of property, the gross profit percentage of the price at which
|
||
the property is being offered by the employer to customers, or
|
||
|
||
```catala
|
||
scope QualifiedEmployeeDiscount :
|
||
definition qualified_employee_discount
|
||
under condition is_property consequence
|
||
equals
|
||
if employee_discount >
|
||
customer_price * gross_profit_percentage
|
||
then customer_price * gross_profit_percentage
|
||
else employee_discount
|
||
```
|
||
|
||
(B) in the case of services, 20 percent of the price at which the services are
|
||
being offered by the employer to customers.
|
||
|
||
```catala
|
||
scope QualifiedEmployeeDiscount :
|
||
definition qualified_employee_discount
|
||
under condition is_services consequence
|
||
equals
|
||
if employee_discount >
|
||
customer_price * 20%
|
||
then customer_price * 20%
|
||
else employee_discount
|
||
|
||
scope QualifiedEmployeeDiscount under condition is_services:
|
||
# When selling a service, one does not need the aggregate cost.
|
||
# We provide a default value here so that the computations run smooth.
|
||
definition aggregate_cost equals $0
|
||
definition gross_profit_percentage equals 0%
|
||
```
|
||
|
||
#### (2) Gross profit percentage
|
||
|
||
##### (A) In general
|
||
|
||
The term “gross profit percentage” means the percent which—
|
||
|
||
(i) the excess of the aggregate sales price of property sold by the employer
|
||
to customers over the aggregate cost of such property to the employer, is of
|
||
|
||
(ii) the aggregate sale price of such property.
|
||
|
||
```catala
|
||
scope QualifiedEmployeeDiscount under condition is_property:
|
||
assertion customer_price >= aggregate_cost
|
||
|
||
definition gross_profit_percentage equals
|
||
(customer_price - aggregate_cost) / customer_price
|
||
```
|
||
|
||
##### (B) Determination of gross profit percentage
|
||
|
||
Gross profit percentage shall be determined on the basis of—
|
||
|
||
(i) all property offered to customers in the ordinary course of the line of
|
||
business of the employer in which the employee is performing services (or a
|
||
reasonable classification of property selected by the employer), and
|
||
|
||
(ii) the employer’s experience during a representative period.
|
||
|
||
```catala
|
||
# (i) and (ii) are subjective criteria for determining the gross profit
|
||
# percentage ; we do not formalize them
|
||
```
|
||
|
||
##### (3) Employee discount defined
|
||
|
||
The term “employee discount” means the amount by which—
|
||
|
||
(A) the price at which the property or services are provided by the employer to
|
||
an employee for use by such employee, is less than
|
||
|
||
(B) the price at which such property or services are being offered by the
|
||
employer to customers.
|
||
|
||
```catala
|
||
scope QualifiedEmployeeDiscount:
|
||
assertion customer_price >= employee_price
|
||
|
||
definition employee_discount equals
|
||
customer_price - employee_price
|
||
```
|
||
|
||
##### (4) Qualified property or services
|
||
|
||
The term “qualified property or services” means any property (other than real
|
||
property and other than personal property of a kind held for investment) or
|
||
services which are offered for sale to customers in the ordinary course of
|
||
the line of business of the employer in which the employee is performing
|
||
services.
|
||
|
||
```catala
|
||
# Again, this is for subjectively determining what item qualifies for a
|
||
# discount, not formalizing
|
||
```
|