mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-12-26 09:42:46 +08:00
Merge pull request #6298 from okriuchykhin/ok_SCI_9282
Fix column placement in stock consumption export, add missing localization [SCI-9282]
This commit is contained in:
commit
dc40b4354d
4 changed files with 13 additions and 12 deletions
|
@ -14,6 +14,7 @@ module FailedDeliveryNotifiableJob
|
|||
logger.error e.message
|
||||
logger.error e.backtrace.join("\n")
|
||||
create_failed_notification!
|
||||
raise e
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -6,20 +6,18 @@ class ZipExportJob < ApplicationJob
|
|||
def perform(user_id:, params: {})
|
||||
@user = User.find(user_id)
|
||||
I18n.backend.date_format = @user.settings[:date_format] || Constants::DEFAULT_DATE_FORMAT
|
||||
ZipExport.transaction do
|
||||
@zip_export = ZipExport.create!(user: @user)
|
||||
zip_input_dir = FileUtils.mkdir_p(Rails.root.join("tmp/temp_zip_#{Time.now.to_i}").to_s).first
|
||||
zip_dir = FileUtils.mkdir_p(Rails.root.join('tmp/zip-ready').to_s).first
|
||||
full_zip_name = File.join(zip_dir, zip_name)
|
||||
|
||||
ZipExport.transaction do
|
||||
@zip_export = ZipExport.create!(user: @user)
|
||||
fill_content(zip_input_dir, params)
|
||||
@zip_export.zip!(zip_input_dir, full_zip_name)
|
||||
@zip_export.zip_file.attach(io: File.open(full_zip_name), filename: zip_name)
|
||||
generate_notification!
|
||||
ensure
|
||||
FileUtils.rm_rf([zip_input_dir, full_zip_name], secure: true)
|
||||
end
|
||||
ensure
|
||||
FileUtils.rm_rf([zip_input_dir, full_zip_name], secure: true)
|
||||
I18n.backend.date_format = nil
|
||||
end
|
||||
|
||||
|
|
|
@ -49,12 +49,13 @@ module RepositoryStockLedgerZipExport
|
|||
def generate_record_data(record)
|
||||
consumption_type = record.reference_type == 'MyModuleRepositoryRow' ? 'Task' : 'Inventory'
|
||||
|
||||
if record.amount.positive?
|
||||
added_amount = record.amount.to_d
|
||||
added_amount_unit = record.unit
|
||||
else
|
||||
if (consumption_type == 'Task' && record.amount.positive?) ||
|
||||
(consumption_type == 'Inventory' && record.amount.negative?)
|
||||
consumed_amount = record.amount.abs.to_d
|
||||
consumed_amount_unit = record.unit
|
||||
else
|
||||
added_amount = record.amount.to_d
|
||||
added_amount_unit = record.unit
|
||||
end
|
||||
|
||||
breadcrumbs_data = Array.new(4, '')
|
||||
|
@ -70,8 +71,8 @@ module RepositoryStockLedgerZipExport
|
|||
record.user.full_name,
|
||||
record.created_at.strftime(record.user.date_format),
|
||||
record.repository_row.repository.team.name,
|
||||
record.unit,
|
||||
record.balance.to_d
|
||||
record.balance.to_d,
|
||||
record.unit
|
||||
]
|
||||
|
||||
if consumption_type == 'Task'
|
||||
|
|
|
@ -3328,6 +3328,7 @@ en:
|
|||
recent_changes: "Recent changes"
|
||||
system_message: "SciNote system message"
|
||||
deliver: 'Exportable content'
|
||||
deliver_error: 'Exportable content'
|
||||
experiment_annotation_title: "%{user} mentioned you in experiment %{experiment}."
|
||||
experiment_annotation_message_html: "Project: %{project} | Experiment: %{experiment}"
|
||||
project_comment_annotation_title: "%{user} mentioned you in a comment on project %{project}."
|
||||
|
|
Loading…
Reference in a new issue