Skip to content

Commit

Permalink
Merge d2b23ae into a971450
Browse files Browse the repository at this point in the history
  • Loading branch information
marinaGD authored Dec 7, 2018
2 parents a971450 + d2b23ae commit 0343ab0
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 3 deletions.
2 changes: 2 additions & 0 deletions br_payment_cnab/models/payment_information.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ def name_get(self):

discount_value = fields.Float('Discount Value')

data_referencia_icms = fields.Date('Período de referência (ICMS)')

mov_type = fields.Selection(
[('0', 'Inclusion'),
('5', 'Modification'),
Expand Down
10 changes: 9 additions & 1 deletion br_payment_cnab/models/payment_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,13 @@ def validate_payment_type_01(self, payment_mode, vals):
errors += self.validate_bank_account(vals)
return errors

# ICMS
def validate_payment_type_09(self, payment_mode, vals):
errors = []
if not vals.get('data_referencia_icms'):
errors += ['Preencha o período de referência!']
return errors

# TED
def validate_payment_type_02(self, payment_mode, vals):
errors = []
Expand Down Expand Up @@ -235,7 +242,8 @@ def get_information_vals(self, payment_mode_id, vals):
'fine_value': vals.get('fine_value'),
'interest_value': vals.get('interest_value'),
'numero_referencia': payment_mode_id.numero_referencia,
'l10n_br_environment': payment_mode_id.l10n_br_environment
'l10n_br_environment': payment_mode_id.l10n_br_environment,
'data_referencia_icms': vals.get('data_referencia_icms')
}

def action_generate_payment_order_line(self, payment_mode, vals):
Expand Down
1 change: 1 addition & 0 deletions br_payment_cnab/serialize/cnab240.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ def _get_segmento(self, line, lot_sequency, num_lot):
'valor_receita': self._string_to_monetary(line.amount_total),
'numero_referencia': self._string_to_num(
information_id.numero_referencia),
'data_referencia': information_id.data_referencia_icms,
}
return segmento

Expand Down
2 changes: 1 addition & 1 deletion br_payment_cnab/views/payment_information.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
<field name="warning_code"/>
<field name="agency_name"/>
<field name="operation_code"/>
<field name="message1"/>
<field name="data_referencia_icms"/>
<field name="fine_value" widget="monetary"/>
<field name="interest_value" widget="monetary"/>
<field name="mov_type"/>
Expand Down
5 changes: 4 additions & 1 deletion br_payment_cnab_voucher/models/account_voucher.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ class AccountVoucher(models.Model):
states={'draft': [('readonly', False)]})
fine_value = fields.Float(
'Fine Value', readonly=True, states={'draft': [('readonly', False)]})

data_referencia_icms = fields.Date(
'Período de referência (ICMS)', readonly=True,
states={'draft': [('readonly', False)]})
_sql_constraints = [
('account_voucher_barcode_uniq', 'unique (barcode)',
_('O código de barras deve ser único!'))
Expand Down Expand Up @@ -126,6 +128,7 @@ def _prepare_payment_order_vals(self):
'invoice_date': self.date,
'barcode': self.barcode,
'linha_digitavel': self.linha_digitavel,
'data_referencia_icms': self.data_referencia_icms,
# TODO Ajustar o valor de multa e de juros
# 'fine_value': self.fine_value,
# 'interest_value': self.interest_value,
Expand Down
1 change: 1 addition & 0 deletions br_payment_cnab_voucher/views/account_voucher.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<field name="payment_mode_id" domain="[('type', '=', 'payable')]" />
<field name="payment_type" invisible="1" />
<field name="bank_account_id" attrs="{'invisible': [('payment_type', 'not in', ('01', '02'))]}" domain="[('partner_id', '=', partner_id)]"/>
<field name="data_referencia_icms" attrs="{'invisible': [('payment_type', '!=', '09')]}"/>
</field>
<field name="tax_amount" position="before">
<field name="interest_value" widget="monetary"/>
Expand Down

0 comments on commit 0343ab0

Please sign in to comment.