lib-cl-sii-python icon indicating copy to clipboard operation
lib-cl-sii-python copied to clipboard

rtc: Update AEC XML document validations

Open yaselc opened this issue 3 years ago • 12 comments

Add new validators to rtc.data_models described in the document "Instructivo Técnico Registro Público Electrónico de Transferencia de Crédito" (retrieved on 2021-03-03) Source: Instructivo Técnico Registro Público Electrónico de Transferencia de Crédito

  • rtc.data_models_aec: The cedente_rut should be the DTE's emisor_rut or the last cesionario_rut when the sequence is greater than 1
  • rtc.data_models: The fecha_cesion_dt should be before or equal to the current day
  • rtc.data_models: The fecha_ultimo_vencimiento should be after or equal to the fecha_emision of the DTE

yaselc avatar Mar 06 '21 00:03 yaselc

@yaselc please update PR regarding the referenced documentation

glarrain avatar Mar 10 '21 14:03 glarrain

Also, please update the PR description and all the commits messages so we have stable references (SII's hosted static files can not be trusted)

glarrain avatar Mar 23 '21 13:03 glarrain

Also, since this PR involves a critical part of validation, please run it against many many many real cases (you will need to code something for that I suppose).

I'd also like to know the difference (timedelta) between fecha_firma_dt and fecha_cesion_dt for all those cases. I've got a feeling that difference must be very little (for valid "cesiones" I mean).

What if we add a warning (for more than X seconds of difference) instead of the "validation" that we are removing?

@jtrh your thoughts on this please

glarrain avatar Mar 23 '21 13:03 glarrain

I'd also like to know the difference (timedelta) between fecha_firma_dt and fecha_cesion_dt for all those cases. I've got a feeling that difference must be very little (for valid "cesiones" I mean).

What if we add a warning (for more than X seconds of difference) instead of the "validation" that we are removing?

@jtrh your thoughts on this please

I would keep the validation of fecha_firma_dt and fecha_cesion_dt, but change it from an equality comparison to the following condition: the absolute value of the difference between the two datetimes must be ≤ 60 seconds.

jtrh avatar Mar 24 '21 05:03 jtrh

I would keep the validation of fecha_firma_dt and fecha_cesion_dt, but change it from an equality comparison to the following condition: the absolute value of the difference between the two datetimes must be ≤ 60 seconds.

Also, I would do the above change in a separate pull request. The other validations are nice-to-haves, but I think we should prioritize this one so we can speed up the fix of https://github.com/fyntex/fd-cl-data/issues/671.

jtrh avatar Mar 24 '21 05:03 jtrh

LGTM. @jtrh your call.

glarrain avatar Mar 30 '21 00:03 glarrain

I would keep the validation of fecha_firma_dt and fecha_cesion_dt, but change it from an equality comparison to the following condition: the absolute value of the difference between the two datetimes must be ≤ 60 seconds.

Also, I would do the above change in a separate pull request. The other validations are nice-to-haves, but I think we should prioritize this one so we can speed up the fix of fyntex/fd-cl-data#671.

@jtrh I moved this specific validation to PR #208, with an analysis of a representative set of AEC, because I still have doubts about it.

yaselc avatar Mar 31 '21 19:03 yaselc

CC: @jtrobles-cdd

jtrh avatar May 05 '21 23:05 jtrh

Is this PR ready for a new review?

jtrobles-cdd avatar May 06 '21 06:05 jtrobles-cdd

Codecov Report

Merging #199 (b1ca3c7) into develop (b97bb11) will increase coverage by 0.13%. The diff coverage is 91.48%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop     #199      +/-   ##
===========================================
+ Coverage    81.02%   81.16%   +0.13%     
===========================================
  Files           32       32              
  Lines         2525     2565      +40     
  Branches       375      384       +9     
===========================================
+ Hits          2046     2082      +36     
+ Misses         306      305       -1     
- Partials       173      178       +5     
Impacted Files Coverage Δ
cl_sii/rtc/data_models.py 91.03% <90.62%> (-0.32%) :arrow_down:
cl_sii/rtc/data_models_aec.py 90.09% <93.33%> (-0.36%) :arrow_down:
cl_sii/libs/tz_utils.py 67.64% <0.00%> (+2.94%) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update b97bb11...b1ca3c7. Read the comment docs.

codecov-commenter avatar May 14 '21 01:05 codecov-commenter

Is this PR ready for a new review?

It's now... thanks

ycouce-cdd avatar May 14 '21 02:05 ycouce-cdd

Taking into account what @ycouce-cdd and me discussed yesterday (2021-05-24), are there any validations that should be removed because they conflict with the SII's de facto rules?

It took me a long time to answer, sorry for that, but practice showed us that one thing is what the rules say and another is how they are applied. Obviously, it is not wise to implement validations that probably the SII's own system doesn't apply, it would only make sense if we wanted to generate our own AECs, but I would not use it to restrict the ones we accept. The smartest thing to do for now is to keep this PR on hold.

ycouce-cdd avatar Apr 04 '22 22:04 ycouce-cdd