@@ -49,7 +49,7 @@ def _get_invoices_domain(self):
49
49
"""
50
50
domain = [
51
51
('company_id' , '=' , self .company_id .id ), ('state' , '=' , 'posted' ),
52
- ('date' , '>=' , self .date_from ), ('date' , '<' , self .date_to ),
52
+ ('date' , '>=' , self .date_from ), ('date' , '<= ' , self .date_to ),
53
53
('partner_id.vat' , '!=' , False ),
54
54
('l10n_latam_document_type_id.code' , '!=' , '0' ),
55
55
('l10n_latam_document_type_id.code' , '!=' , False )
@@ -140,18 +140,23 @@ def _get_form_2181_data(self):
140
140
141
141
for rut_partner , invoices in data .items ():
142
142
amount_total = {}
143
- group_by_subtotal_values = list (inv .tax_totals .get ('groups_by_subtotal' ).values ())[0 ] if list (inv .tax_totals .get ('groups_by_subtotal' ).values ()) else []
144
143
for inv in invoices :
144
+ group_by_subtotal_values = list (inv .tax_totals .get ('groups_by_subtotal' ).values ())[0 ] if list (inv .tax_totals .get ('groups_by_subtotal' ).values ()) else []
145
145
for item in group_by_subtotal_values :
146
146
tax_group_id = item .get ('tax_group_id' )
147
147
if tax_group_id in taxes_group_ids :
148
- inv_amount = item .get ('tax_group_amount' )
148
+ # los comprobantes exentos tienen 0.0 en tax_group_amount, entonces tomamos tax_group_base_amount
149
+ inv_amount = item .get ('tax_group_amount' ) if not tax_group_id == self .env .ref ('l10n_uy_account.tax_group_vat_exempt' ).id else item .get ('tax_group_base_amount' )
149
150
# No estaba ene especifcacion pero vimos via un ejemplo que los montos reportados siempre son en
150
151
# pesos. aun qu el comprobamte sea de otra moneda, es por eso que hacemos esta conversion
151
152
if inv .currency_id != UYU_currency :
152
- inv_amount = inv_amount * inv .l10n_uy_currency_rate
153
+ inv_amount = inv_amount * ( inv .l10n_uy_currency_rate or ( inv . currency_id . _convert ( 1.0 , inv . company_id . currency_id , inv . company_id , inv . date , round = False )))
153
154
key = (tax_group_id , 'sale' if 'out_' in inv .move_type else 'purchase' )
154
- amount_total [key ] = amount_total .get (key , 0.0 ) + (amount_total .get (tax_group_id , 0.0 )) + inv_amount
155
+ sing = '+' if inv .move_type in ['out_invoice' , 'in_invoice' , 'out_receipt' , 'in_receipt' ] else '-'
156
+ if sing == '+' :
157
+ amount_total [key ] = amount_total .get (key , 0.0 ) + (amount_total .get (tax_group_id , 0.0 )) + inv_amount
158
+ else :
159
+ amount_total [key ] = amount_total .get (key , 0.0 ) + (amount_total .get (tax_group_id , 0.0 )) - inv_amount
155
160
for tax in amount_total :
156
161
157
162
if not tax_code .get (tax ):
0 commit comments