Skip to content

Commit ec2e5ec

Browse files
authored
Merge pull request #318 from binaural-dev/17.0_feat-ta_58193_dll_integration_l10n_ve_iot_mf
FEAT #58193: l10n_ve_iot_mf
2 parents 5456f0e + d19427d commit ec2e5ec

30 files changed

+1553
-2172
lines changed

l10n_ve_invoice/models/account_move.py

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
from datetime import datetime
1+
from datetime import datetime, date, timedelta
22
import json
33
import logging
4-
4+
import calendar
55
from odoo import api, fields, models, _
66
from odoo.exceptions import ValidationError, UserError
77
from odoo.tools import format_date
@@ -32,6 +32,39 @@ class AccountMove(models.Model):
3232
compute="_compute_is_debit_journal",
3333
store=True
3434
)
35+
36+
entry_in_period = fields.Boolean(
37+
compute="_compute_entry_in_period",
38+
)
39+
40+
@api.depends("invoice_date", "entry_in_period", "state")
41+
def _compute_entry_in_period(self):
42+
"""Computing that allows determining whether a debit or credit note is within the current fiscal period."""
43+
today = date.today()
44+
taxpayer_type = self.env.company.taxpayer_type
45+
period_limit = self._get_period_limit(today, taxpayer_type)
46+
47+
for move in self:
48+
move.entry_in_period = False
49+
50+
if move.state == "cancel":
51+
continue
52+
53+
if move.move_type == "out_refund" or (move.move_type == "out_invoice" and move.debit_origin_id):
54+
if (move.invoice_date.year, move.invoice_date.month) == (period_limit.year, period_limit.month) and move.invoice_date <= period_limit:
55+
if taxpayer_type == "special" and move.invoice_date.day < 15 < period_limit.day:
56+
move.entry_in_period = False
57+
else:
58+
move.entry_in_period = True
59+
60+
def _get_period_limit(self, today, taxpayer_type):
61+
"""Returns the tax period deadline according to the taxpayer type."""
62+
if taxpayer_type == "special":
63+
if today.day < 15:
64+
return today.replace(day=15)
65+
last_day = calendar.monthrange(today.year, today.month)[1]
66+
return date(today.year, today.month, last_day)
67+
3568
@api.constrains("invoice_line_ids")
3669
def _check_price_in_zero(self):
3770
from_pos = self.env.context.get('from_pos', False)

l10n_ve_invoice/views/account_move.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,11 @@
66
<field name="arch" type="xml">
77
<field name="invoice_has_outstanding" position="after">
88
<field name="is_contingency" invisible="1" />
9+
<field name="entry_in_period" invisible="1" />
910
</field>
11+
<xpath expr="//header/button[@name='button_cancel'][2]" position="attributes">
12+
<attribute name="invisible">not entry_in_period and (not id or state != 'draft' or move_type == 'entry')</attribute>
13+
</xpath>
1014
<xpath expr="//field[@name='invoice_user_id']" position="attributes">
1115
<attribute name="invisible">1</attribute>
1216
</xpath>

l10n_ve_iot_mf/__manifest__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
""",
88
"license": "LGPL-3",
99
"category": "Accounting",
10-
"version": "17.0.0.0.9",
10+
"version": "17.0.0.1.1",
1111
"author": "binaural-dev",
1212
"website": "https://binauraldev.com",
1313
"depends": [

l10n_ve_iot_mf/controllers/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def getPinpadPort(self, **kw):
2828
iot_id = request.env["iot.box"].sudo().search([("has_pinpad_machine", "=", True)])
2929
response = {}
3030
for iot in iot_id:
31-
response[iot.identifier] = [iot.pinpad_port_id.name] if iot.pinpad_port_id else []
31+
response[iot.identifier] = iot.pinpad_port_id.mapped(lambda x: x.name)
3232
return json.dumps(response)
3333

3434
@http.route(

0 commit comments

Comments
 (0)