Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ADD] l10n_uy_edi: Descuentos globales #151

Open
wants to merge 1 commit into
base: 16.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion l10n_uy_edi/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
'author': 'ADHOC SA',
'category': 'Localization',
'license': 'LGPL-3',
'version': "16.0.1.6.0",
'version': "16.0.1.7.0",
'depends': [
'l10n_uy_account',
'account_debit_note',
Expand Down
11 changes: 11 additions & 0 deletions l10n_uy_edi/data/cfe_template.xml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,17 @@
<MontoItem t-out="item_line['MontoItem']"/>
</Item>
</Detalle>
<DscRcgGlobal>
<DRG_Item t-foreach="DscRcgGlobal" t-as="descuento">
<NroLinDR t-if="descuento.get('NroLinDR')" t-out="descuento['NroLinDR']"/>
<TpoMovDR t-if="descuento.get('TpoMovDR')" t-out="descuento['TpoMovDR']"/>
<TpoDR t-if="descuento.get('TpoDR')" t-out="descuento['TpoDR']"/>
<CodDR t-if="descuento.get('CodDR')" t-out="descuento['CodDR']"/>
<GlosaDR t-if="descuento.get('GlosaDR')" t-out="descuento['GlosaDR']"/>
<ValorDR t-if="descuento.get('ValorDR')" t-out="descuento['ValorDR']"/>
<IndFactDR t-if="descuento.get('IndFactDR')" t-out="descuento['IndFactDR']"/>
</DRG_Item>
</DscRcgGlobal>
<Referencia t-if="referencia_lines">
<Referencia t-foreach="referencia_lines" t-as="referencia">
<NroLinRef t-out="referencia['NroLinRef']"/>
Expand Down
32 changes: 32 additions & 0 deletions l10n_uy_edi/models/l10n_uy_cfe.py
Original file line number Diff line number Diff line change
Expand Up @@ -923,6 +923,38 @@ def _l10n_uy_create_cfe(self):

return {'cfe_str': cfe}

def _get_discount_of_lines(self):
#retorna el descuento total de las lineas de descuento globales
descuento = 0.0
descGloblal = self.line_ids.filtered(lambda x: x.price_unit < 0)
for desc in descGloblal:
descuento = descuento + desc.price_unit
return descuento

def _l10n_uy_get_cfe_discount(self):
values = []
for line in self.line_ids.filtered(lambda x: x.price_unit < 0):
item = {}
item.update ({
'NroLinDR': line.discount,
'TpoMovDR': 'D', #TODO por ahora solo implementemamos descuentos
'TpoDR': 2, #Nosotros tenemos descuentos (en la linea) solo por porcentaje
'CodDR': False, #preguntar si implementar o no
'GlosaDR': line.name, #descripcion del descuento, usamos directamente la descripcion
'ValorDR': line.sequence,
'IndFactDR': False, #este campo es obligatorio y tengo dudas
})
values.append(item)
return values

def uy_cfe_D6_ValorDR(self):
ValorDR = self.discount or 0 #revisar bien el valor ya que es en porcentaje
return ValorDR

def uy_cfe_D1_NroLinDR(self):
NroLinDR = self.sequence or 1 #nosotros no tenemos una linea de descuento en si
return NroLinDR

def _uy_get_cfe_lines(self):
self.ensure_one()
if self._is_uy_inv_type_cfe():
Expand Down