Implemented section 1015 under Catala

This commit is contained in:
Denis Merigoux 2020-05-28 15:04:24 +02:00
parent 4daca51ee3
commit 4f8ec8191e
5 changed files with 235 additions and 58 deletions

View File

@ -0,0 +1,175 @@
@@Section 1015@@
@@Begin metadata@@
/*
declaration enumeration AcquisitionMethod:
-- Gift
-- Trust
declaration structure Acquisition:
data method content AcquisitionMethod
data moment content date
data no_sale_or_exchange_before content boolean
declaration structure Value:
data fair_market content amount depends on date
data last_acquisition content amount
data net_appreciation content amount
declaration structure Transferor:
data basis content amount
data basis_known content optional amount
data acquisition content Acquisition
data gain_or_loss content amount depends on date
declaration scope BasisOfGift:
context acquisition content Acquisition
context basis_subsection_a content amount
context basis content amount
context basis_bonus_after_1976 content amount
context transferor content Transferor
context gift_tax_paid content amount
*/
@@End metadata@@
@(a) Gifts after December 31, 1920@
If the property was acquired by gift after December 31, 1920, the basis shall be the same as it would be in the hands of the donor or the last preceding owner by whom it was not acquired by gift, except that if such basis (adjusted for the period before the date of the gift as provided in section 1016) is greater than the fair market value of the property at the time of the gift, then for the purpose of determining loss the basis shall be such fair market value.
/*
scope BasisOfGift:
definition basis_subsection_a equals
if transferor.basis >= value.fair_market of acquisition.moment then
value.fair_market of acquisition.moment
else
transferor.basis
definition basis under condition
acquisition.moment > |01/31/1920| and
acquisition.method = Gift
consequence equals basis_subsection_a
*/
If the facts necessary to determine the basis in the hands of the donor or the last preceding owner are unknown to the donee, the Secretary shall, if possible, obtain such facts from such donor or last preceding owner, or any other person cognizant thereof. If the Secretary finds it impossible to obtain such facts, the basis in the hands of such donor or last preceding owner shall be the fair market value of such property as found by the Secretary as of the date or approximate date at which, according to the best information that the Secretary is able to obtain, such property was acquired by such donor or last preceding owner.
/*
scope BasisOfGift under condition
acquisition.moment > |01/31/1920| and
acquisition.method = Gift:
definition transferor.basis equals
match transferor.known_basis with pattern
-- Some of basis : basis
-- None : value.fair_market of transferor.acquisition.moment
*/
@(b) Transfer in trust after December 31, 1920@
If the property was acquired after December 31, 1920, by a transfer in trust (other than by a transfer in trust by a gift, bequest, or devise), the basis shall be the same as it would be in the hands of the grantor increased in the amount of gain or decreased in the amount of loss recognized to the grantor on such transfer under the law applicable to the year in which the transfer was made.
/*
scope BasisOfGift under condition
acquisition.moment > |01/31/1920| and
acquisition.method = Trust:
definition basis equals
transferor.basis + transferor.gain_or_loss of acquisition.moment
*/
@(c) Gift or transfer in trust before January 1, 1921@
If the property was acquired by gift or transfer in trust on or before December 31, 1920, the basis shall be the fair market value of such property at the time of such acquisition.
/*
scope BasisOfGift under condition acquisition.moment <= |01/31/1920|:
definition basis equals
value.fair_market of acquisition.moment
*/
@@(d) Increased basis for gift tax paid@@+
@(1) In general@ If—
(A) the property is acquired by gift on or after September 2, 1958, the basis shall be the basis determined under subsection (a), increased (but not above the fair market value of the property at the time of the gift) by the amount of gift tax paid with respect to such gift, or
/*
scope BasisOfGift under condition
acquisition.moment >= |09/02/1958| and
acquisition.method = Gift:
definition basis equals
basis_subsection_a + (
if gift_tax_paid >= value.fair_market of acquisition.moment then
value.fair_market of acquisition.moment
else
gift_tax_paid
)
*/
(B) the property was acquired by gift before September 2, 1958, and has not been sold, exchanged, or otherwise disposed of before such date, the basis of the property shall be increased on such date by the amount of gift tax paid with respect to such gift, but such increase shall not exceed an amount equal to the amount by which the fair market value of the property at the time of the gift exceeded the basis of the property in the hands of the donor at the time of the gift.
/*
scope BasisOfGift under condition
acquisition.moment < |09/02/1958| and
acquisition.method = Gift and
acquisition.no_sale_or_exchange_before:
definition basis equals
basis_subsection_a + (
if
gift_tax_paid >=
value.fair_market of acquisition.moment - transferor.basis
then
value.fair_market of acquisition.moment - transferor.basis
else
gift_tax_paid
)
*/
@(2) Amount of tax paid with respect to gift@
For purposes of paragraph (1), the amount of gift tax paid with respect to any gift is an amount which bears the same ratio to the amount of gift tax paid under chapter 12 with respect to all gifts made by the donor for the calendar year (or preceding calendar period) in which such gift is made as the amount of such gift bears to the taxable gifts (as defined in section 2503(a) but computed without the deduction allowed by section 2521) made by the donor during such calendar year or period. For purposes of the preceding sentence, the amount of any gift shall be the amount included with respect to such gift in determining (for the purposes of section 2503(a)) the total amount of gifts made during the calendar year or period, reduced by the amount of any deduction allowed with respect to such gift under section 2522 (relating to charitable deduction) or under section 2523 (relating to marital deduction).
/*
# We don't formalize the amount of gift tax since it would require formalizing other sections of the code
*/
@(3) Gifts treated as made one-half by each spouse@
For purposes of paragraph (1), where the donor and his spouse elected, under section 2513 to have the gift considered as made one-half by each, the amount of gift tax paid with respect to such gift under chapter 12 shall be the sum of the amounts of tax paid with respect to each half of such gift (computed in the manner provided in paragraph (2)).
/*
# Same here
*/
@(4) Treatment as adjustment to basis@
For purposes of section 1016(b), an increase in basis under paragraph (1) shall be treated as an adjustment under section 1016(a).
/*
# Same here
*/
@(5) Application to gifts before 1955@
With respect to any property acquired by gift before 1955, references in this subsection to any provision of this title shall be deemed to refer to the corresponding provision of the Internal Revenue Code of 1939 or prior revenue laws which was effective for the year in which such gift was made.
/*
# Same here
*/
@@(6) Special rule for gifts made after December 31, 1976@@++
@(A) In general@
In the case of any gift made after December 31, 1976, the increase in basis provided by this subsection with respect to any gift for the gift tax paid under chapter 12 shall be an amount (not in excess of the amount of tax so paid) which bears the same ratio to the amount of tax so paid as—
(i) the net appreciation in value of the gift, bears to
(ii) the amount of the gift.
/*
scope BasisOfGift under condition
acquisition.moment > |09/02/1976| and
acquisition.method = Gift:
definition basis_bonus_after_1976 equals
gift_tax_paid * (
value.net_appreciation /
value.last_acquisition # is it really? "amount" is imprecise
)
*/
@(B) Net appreciation@
For purposes of paragraph (1), the net appreciation in value of any gift is the amount by which the fair market value of the gift exceeds the donors adjusted basis immediately before the gift.
/*
scope BasisOfGift:
definition value.net_appreciation equals
value.fair_market_value of acquisition.moment - transferor.basis
*/
@(e) Gifts between spouses@
In the case of any property acquired by gift in a transfer described in section 1041(a), the basis of such property in the hands of the transferee shall be determined under section 1041(b)(2) and not this section.
/*
# Same here
*/

View File

@ -1,5 +1,9 @@
@@Section 132@@
/*
# We only formalize part (c) here
*/
@@Begin metadata@@
/*
declaration enumeration DiscountType:

View File

@ -3,3 +3,5 @@
@@Include: preamble.catala@@
@@Include: section_132.catala@@
@@Include: section_1015.catala@@

View File

@ -154,8 +154,7 @@ source_file_or_master: BEGIN_CODE DECLARATION SCOPE CONSTRUCTOR COLON YEAR
## DECLARATION SCOPE constructor COLON
##
Unexpected token
To get a better error messsage, file an issue at https://github.com/CatalaLang/catala/issues with this parser error token: ERROR#224
Scope declarations must have at least one context element
source_file_or_master: BEGIN_CODE DECLARATION SCOPE CONSTRUCTOR YEAR
##
@ -341,16 +340,16 @@ source_file_or_master: BEGIN_CODE SCOPE CONSTRUCTOR COLON ASSERTION CARDINAL THE
## This implies that, although the LR(1) items shown above provide an
## accurate view of the past (what has been recognized so far), they
## may provide an INCOMPLETE view of the future (what was expected next).
## In state 39, spurious reduction of production primitive_expression -> CARDINAL
## In state 47, spurious reduction of production base_expression -> primitive_expression
## In state 88, spurious reduction of production mult_expression -> base_expression
## In state 83, spurious reduction of production sum_expression -> mult_expression
## In state 93, spurious reduction of production compare_expression -> sum_expression
## In state 120, spurious reduction of production logical_expression -> compare_expression
## In state 104, spurious reduction of production expression -> logical_expression
## In state 189, spurious reduction of production assertion_base -> expression
## In state 190, spurious reduction of production assertion -> option(condition_consequence) assertion_base
## In state 191, spurious reduction of production scope_item -> ASSERTION assertion
## In state 39, spurious reduction of production primitive_expression -> CARDINAL
## In state 47, spurious reduction of production base_expression -> primitive_expression
## In state 88, spurious reduction of production mult_expression -> base_expression
## In state 83, spurious reduction of production sum_expression -> mult_expression
## In state 93, spurious reduction of production compare_expression -> sum_expression
## In state 120, spurious reduction of production logical_expression -> compare_expression
## In state 104, spurious reduction of production expression -> logical_expression
## In state 189, spurious reduction of production assertion_base -> expression
## In state 190, spurious reduction of production assertion -> option(condition_consequence) assertion_base
## In state 191, spurious reduction of production scope_item -> ASSERTION assertion
##
Unexpected token after a scope item
@ -514,8 +513,8 @@ source_file_or_master: BEGIN_CODE SCOPE CONSTRUCTOR COLON ASSERTION FIXED IDENT
## This implies that, although the LR(1) items shown above provide an
## accurate view of the past (what has been recognized so far), they
## may provide an INCOMPLETE view of the future (what was expected next).
## In state 54, spurious reduction of production separated_nonempty_list(DOT,ident) -> ident
## In state 53, spurious reduction of production qident -> option(qident_prefix) separated_nonempty_list(DOT,ident)
## In state 54, spurious reduction of production separated_nonempty_list(DOT,ident) -> ident
## In state 53, spurious reduction of production qident -> option(qident_prefix) separated_nonempty_list(DOT,ident)
##
Unexpected token
@ -624,12 +623,12 @@ source_file_or_master: BEGIN_CODE SCOPE CONSTRUCTOR COLON ASSERTION IF NOW RULE
## This implies that, although the LR(1) items shown above provide an
## accurate view of the past (what has been recognized so far), they
## may provide an INCOMPLETE view of the future (what was expected next).
## In state 47, spurious reduction of production base_expression -> primitive_expression
## In state 88, spurious reduction of production mult_expression -> base_expression
## In state 83, spurious reduction of production sum_expression -> mult_expression
## In state 93, spurious reduction of production compare_expression -> sum_expression
## In state 120, spurious reduction of production logical_expression -> compare_expression
## In state 104, spurious reduction of production expression -> logical_expression
## In state 47, spurious reduction of production base_expression -> primitive_expression
## In state 88, spurious reduction of production mult_expression -> base_expression
## In state 83, spurious reduction of production sum_expression -> mult_expression
## In state 93, spurious reduction of production compare_expression -> sum_expression
## In state 120, spurious reduction of production logical_expression -> compare_expression
## In state 104, spurious reduction of production expression -> logical_expression
##
Unexpected token
@ -661,12 +660,12 @@ source_file_or_master: BEGIN_CODE SCOPE CONSTRUCTOR COLON ASSERTION IF NOW THEN
## This implies that, although the LR(1) items shown above provide an
## accurate view of the past (what has been recognized so far), they
## may provide an INCOMPLETE view of the future (what was expected next).
## In state 47, spurious reduction of production base_expression -> primitive_expression
## In state 88, spurious reduction of production mult_expression -> base_expression
## In state 83, spurious reduction of production sum_expression -> mult_expression
## In state 93, spurious reduction of production compare_expression -> sum_expression
## In state 120, spurious reduction of production logical_expression -> compare_expression
## In state 104, spurious reduction of production expression -> logical_expression
## In state 47, spurious reduction of production base_expression -> primitive_expression
## In state 88, spurious reduction of production mult_expression -> base_expression
## In state 83, spurious reduction of production sum_expression -> mult_expression
## In state 93, spurious reduction of production compare_expression -> sum_expression
## In state 120, spurious reduction of production logical_expression -> compare_expression
## In state 104, spurious reduction of production expression -> logical_expression
##
Unexpected token
@ -723,12 +722,12 @@ source_file_or_master: BEGIN_CODE SCOPE CONSTRUCTOR COLON ASSERTION LPAREN NOW T
## This implies that, although the LR(1) items shown above provide an
## accurate view of the past (what has been recognized so far), they
## may provide an INCOMPLETE view of the future (what was expected next).
## In state 47, spurious reduction of production base_expression -> primitive_expression
## In state 88, spurious reduction of production mult_expression -> base_expression
## In state 83, spurious reduction of production sum_expression -> mult_expression
## In state 93, spurious reduction of production compare_expression -> sum_expression
## In state 120, spurious reduction of production logical_expression -> compare_expression
## In state 104, spurious reduction of production expression -> logical_expression
## In state 47, spurious reduction of production base_expression -> primitive_expression
## In state 88, spurious reduction of production mult_expression -> base_expression
## In state 83, spurious reduction of production sum_expression -> mult_expression
## In state 93, spurious reduction of production compare_expression -> sum_expression
## In state 120, spurious reduction of production logical_expression -> compare_expression
## In state 104, spurious reduction of production expression -> logical_expression
##
Unmatched parenthesis that should have ended before this
@ -759,12 +758,12 @@ source_file_or_master: BEGIN_CODE SCOPE CONSTRUCTOR COLON ASSERTION MATCH NOW WI
## This implies that, although the LR(1) items shown above provide an
## accurate view of the past (what has been recognized so far), they
## may provide an INCOMPLETE view of the future (what was expected next).
## In state 47, spurious reduction of production base_expression -> primitive_expression
## In state 88, spurious reduction of production mult_expression -> base_expression
## In state 83, spurious reduction of production sum_expression -> mult_expression
## In state 93, spurious reduction of production compare_expression -> sum_expression
## In state 103, spurious reduction of production logical_expression -> logical_unop compare_expression
## In state 139, spurious reduction of production match_arm -> constructor_binding COLON logical_expression
## In state 47, spurious reduction of production base_expression -> primitive_expression
## In state 88, spurious reduction of production mult_expression -> base_expression
## In state 83, spurious reduction of production sum_expression -> mult_expression
## In state 93, spurious reduction of production compare_expression -> sum_expression
## In state 103, spurious reduction of production logical_expression -> logical_unop compare_expression
## In state 139, spurious reduction of production match_arm -> constructor_binding COLON logical_expression
##
Unexpected token
@ -966,7 +965,7 @@ source_file_or_master: BEGIN_CODE SCOPE CONSTRUCTOR COLON ASSERTION NOW INCREASI
## This implies that, although the LR(1) items shown above provide an
## accurate view of the past (what has been recognized so far), they
## may provide an INCOMPLETE view of the future (what was expected next).
## In state 47, spurious reduction of production base_expression -> primitive_expression
## In state 47, spurious reduction of production base_expression -> primitive_expression
##
Unexpected token
@ -1166,14 +1165,14 @@ source_file_or_master: BEGIN_CODE SCOPE CONSTRUCTOR COLON ASSERTION UNDER_CONDIT
## This implies that, although the LR(1) items shown above provide an
## accurate view of the past (what has been recognized so far), they
## may provide an INCOMPLETE view of the future (what was expected next).
## In state 39, spurious reduction of production primitive_expression -> CARDINAL
## In state 47, spurious reduction of production base_expression -> primitive_expression
## In state 88, spurious reduction of production mult_expression -> base_expression
## In state 83, spurious reduction of production sum_expression -> mult_expression
## In state 93, spurious reduction of production compare_expression -> sum_expression
## In state 120, spurious reduction of production logical_expression -> compare_expression
## In state 104, spurious reduction of production expression -> logical_expression
## In state 154, spurious reduction of production condition -> UNDER_CONDITION expression
## In state 39, spurious reduction of production primitive_expression -> CARDINAL
## In state 47, spurious reduction of production base_expression -> primitive_expression
## In state 88, spurious reduction of production mult_expression -> base_expression
## In state 83, spurious reduction of production sum_expression -> mult_expression
## In state 93, spurious reduction of production compare_expression -> sum_expression
## In state 120, spurious reduction of production logical_expression -> compare_expression
## In state 104, spurious reduction of production expression -> logical_expression
## In state 154, spurious reduction of production condition -> UNDER_CONDITION expression
##
Unexpected token after a condition
@ -1204,8 +1203,8 @@ source_file_or_master: BEGIN_CODE SCOPE CONSTRUCTOR COLON ASSERTION VARIES IDENT
## This implies that, although the LR(1) items shown above provide an
## accurate view of the past (what has been recognized so far), they
## may provide an INCOMPLETE view of the future (what was expected next).
## In state 54, spurious reduction of production separated_nonempty_list(DOT,ident) -> ident
## In state 53, spurious reduction of production qident -> option(qident_prefix) separated_nonempty_list(DOT,ident)
## In state 54, spurious reduction of production separated_nonempty_list(DOT,ident) -> ident
## In state 53, spurious reduction of production qident -> option(qident_prefix) separated_nonempty_list(DOT,ident)
##
Unexpected token
@ -1224,7 +1223,7 @@ source_file_or_master: BEGIN_CODE SCOPE CONSTRUCTOR COLON ASSERTION VARIES IDENT
## This implies that, although the LR(1) items shown above provide an
## accurate view of the past (what has been recognized so far), they
## may provide an INCOMPLETE view of the future (what was expected next).
## In state 47, spurious reduction of production base_expression -> primitive_expression
## In state 47, spurious reduction of production base_expression -> primitive_expression
##
Unexpected token
@ -1395,8 +1394,8 @@ source_file_or_master: BEGIN_CODE SCOPE CONSTRUCTOR COLON DEFINITION IDENT WITH_
## This implies that, although the LR(1) items shown above provide an
## accurate view of the past (what has been recognized so far), they
## may provide an INCOMPLETE view of the future (what was expected next).
## In state 54, spurious reduction of production separated_nonempty_list(DOT,ident) -> ident
## In state 53, spurious reduction of production qident -> option(qident_prefix) separated_nonempty_list(DOT,ident)
## In state 54, spurious reduction of production separated_nonempty_list(DOT,ident) -> ident
## In state 53, spurious reduction of production qident -> option(qident_prefix) separated_nonempty_list(DOT,ident)
##
Only the identifier you wish to define should follow the definition introducing token
@ -1518,8 +1517,8 @@ source_file_or_master: BEGIN_CODE SCOPE CONSTRUCTOR COLON RULE IDENT WITH_V
## This implies that, although the LR(1) items shown above provide an
## accurate view of the past (what has been recognized so far), they
## may provide an INCOMPLETE view of the future (what was expected next).
## In state 54, spurious reduction of production separated_nonempty_list(DOT,ident) -> ident
## In state 53, spurious reduction of production qident -> option(qident_prefix) separated_nonempty_list(DOT,ident)
## In state 54, spurious reduction of production separated_nonempty_list(DOT,ident) -> ident
## In state 53, spurious reduction of production qident -> option(qident_prefix) separated_nonempty_list(DOT,ident)
##
Unexpected token

View File

@ -380,10 +380,7 @@ let message s =
"Unexpected token\n\
To get a better error messsage, file an issue at \
https://github.com/CatalaLang/catala/issues with this parser error token: ERROR#223\n"
| 230 ->
"Unexpected token\n\
To get a better error messsage, file an issue at \
https://github.com/CatalaLang/catala/issues with this parser error token: ERROR#224\n"
| 230 -> "Scope declarations must have at least one context element\n"
| 231 ->
"Unexpected token\n\
To get a better error messsage, file an issue at \