Skip to content

Commit

Permalink
Bills on billed status can't be changed
Browse files Browse the repository at this point in the history
  • Loading branch information
jresinas committed May 17, 2018
1 parent 9a43702 commit 98625b4
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
3 changes: 2 additions & 1 deletion config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,5 @@ en:
text_sync_success: FacturaPlus synchronization was succesful
text_sync_fail: An error occurred while Redmine was synchronizing with FacturaPlus
text_biller_client_not_valid: Client and/or Biller selected are not valid. Please, be sure that Client is enabled for Biller in FacturaPlus
text_fields_missing: There are some required fields missing
text_fields_missing: There are some required fields missing
text_status_billed: The bill is billed and can't be modified
3 changes: 2 additions & 1 deletion config/locales/es.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,5 @@ es:
text_sync_success: La sincronización con FacturaPlus se ha realizado correctamente
text_sync_fail: Se ha producido un error durante la sincronización con FacturaPlus
text_biller_client_not_valid: El Cliente y/o Empresa seleccionados no son válidos. Por favor, asegúrese que el Cliente indicado está habilitado para la Empresa seleccionada en FacturaPlus.
text_fields_missing: Hay campos requeridos que no están siendo mostrados
text_fields_missing: Hay campos requeridos que no están siendo mostrados
text_status_billed: La factura ya está facturada y no puede modificarse
8 changes: 8 additions & 0 deletions lib/facturaplus/issue_patch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,14 @@ def facturaplus_bill_save
# No está facturable pero tiene un albarán asociado en FacturaPlus -> borrar albarán asociado
results += self.destroy_delivery_note
end
elsif tracker_id.to_s == Setting.plugin_redmine_facturaplus['bill_tracker'] and Setting.plugin_redmine_facturaplus['billed_statuses'].include?(status_id.to_s)
# El estado del ticket es un estado facturado, por lo que no se puede modificar -> ERROR
errors[:base] << I18n.t('facturaplus.text_status_billed')

# Patch to fix error when try to submit a NEW issue form after Rollback in facturaplus_bill_save method
self.destroy if @new_bill.present?

raise ActiveRecord::Rollback
elsif self.facturaplus_relation.present?
# No es una factura emitada por una empresa con FacturaPlus, pero tiene elementos de FacturaPlus asociados -> borramos los elementos asociados si NO está en estado facturado o NO está emitido por una empresa con FacturaPlus
results += self.destroy_order if !Setting.plugin_redmine_facturaplus['billed_statuses'].include?(status_id.to_s) or !Setting.plugin_redmine_facturaplus['billers'].include?(biller_field.value)
Expand Down

0 comments on commit 98625b4

Please sign in to comment.