Skip to main content

billing-company-product

Description​

This bucket is used to store temporarily CSV files imported by the Admin at ActiveAdmin’s Billings > Global Billing Company Products page. This file is later on processed by a service, which will parse and import the products contained in the CSV files.

File lifecycles​

  1. uala-admin/app/admin/billing_company_product.rb This ActiveAdmin class is responsible for uploading the CSV file to S3 buckets and triggering the ImportBillingCompanyProductsJob. This job is tasked with downloading the CSV from S3 and processing it by parsing the file.

  2. uala-main/app/main_jobs/import_billing_company_products_job.rb This job triggers the import service (BillingCompanyProducts::ImportService). It also monitors for any potential errors and handles the enqueueing of notification emails, which are sent just after the import service completes.

  3. uala-main/app/services/billing_company_products/import_service.rb This service manages the download of the file, reads and parses it, and stores the parsed products (BillingProduct) in the database.

  4. uala-main/app/services/notifications/email_service.rb This is a generic class responsible for processing notification emails.

listing-registry

Description​

The bucket exists for the purpose of storing products and product images to be imported through ActiveAdmin UI.

File lifecycles​

  1. uala-admin/app/admin/warehouse/product.rb uses it to store CSVs uploaded by ActiveAdmin users in order to import warehouse products images, enqueuing a Warehouse::CsvImageImportJob job that calls Warehouse::CsvImageImportService, which downloads the CSV file using Warehouse::FileLoaderService, that is a basically a simple HTTP URL downloader, it isn't related to S3.

  2. uala-admin/app/admin/warehouse/manufacturer.rb uses it to store CSVs uploaded by ActiveAdmin users in order to import products by manufacturer, enqueuing a ImportProductsJob, which calls ListingImporter which downloads the file straight away using File.open(Uri.parse(@csv_file_path)). After that, ImportProductsJob sends the link of the file uploaded via S3 to the ActiveAdmin user who started the product import as summary.

order-recaps

Description​

This bucket is used for holding Order Recap Excel file (.xlsx) while sending Order Recap email

Names in different environments​

  • Production: order-recaps
  • development: be-devenvs-order-recaps

Usage​

  1. uala-main/app/jobs/notify_order_job.rb

uala-main/app/jobs/notify_order_job.rb​

  1. triggered in

    • uala-main/app/controllers/api/v1/orders_controller.rb
    • create
    • update
  2. both trigger uala-main/app/jobs/notify_order_job

  3. uala-main/app/jobs/notify_order_job.rb

    • Orders::GenerateRecapSpreadsheetService to generate a spreadsheet
    • #_upload_to_aws, to upload it to AWS S3
    • saves the file url in table Order.recap_spreadsheet
    • Notifications::EmailService#anonymous_notify_order_recap to send an email to
  4. Notifications::EmailService#anonymous_notify_order_recap

    • email is sent to both Venue and Supplier

admin-alert-files

Description​

This bucket is used for holding AA import report (success) or alert (failure) TXT files

Names in different environments​

  • Production: admin-alert-files
  • development: be-devenvs-admin-alert-files

Usage​

  1. uala-main/app/jobs/import_customers_job.rb
  2. uala-main/app/jobs/import_products_job.rb

uala-main/app/jobs/import_customers_job.rb​

  1. triggered in uala-admin/app/admin/customer.rb
    • #import_customers
  2. calls uala-main/app/jobs/import_customers_job.rb
  3. in uala-main/app/jobs/import_customers_job.rb
  • calls Customers::ImportCustomersService.run to import customers
    • success: email to AA user with no files
    • failure: it generates a TXT file contains all errors occur during importing
      • calls #_upload_to_aws to upload the TXT file to AWS S3
  1. calls Notifications::EmailService#admin_alert to send email to AA user

uala-main/app/jobs/import_products_job.rb​

  1. triggered inuala-admin/app/admin/warehouse/manufacturer.rb
  • #import_products
  1. calls uala-main/app/jobs/import_products_job.rb
  2. in uala-main/app/jobs/import_products_job.rb
    • calls ListingImporter.import to import products
      • it calls #_bucket_file_link to upload that TXT file to AWS S3, the TXT file content is different based on:
        • success: TXT file contains import results
        • failure: TXT file contains import errors
  3. calls Notifications::EmailService#admin_alert to send email to AA user

Notes and comments​

  • seems generating these TXT files is a bit redundant
    • we can just send out emails with all info we needed, unless:
      • we need to keep it somewhere for record (Datadog Logs might be a better place?)
      • sharing it with others

invoice.uala.it

Description​

The bucket exists for the purpose of storing different types of PDF documents. Such as:

  • receipts for checkouts
  • appointments daily recaps
    • generates by Api::V1::AppointmentsController#daily_recap
    • folder name appointments_daily_recaps
  • billing company invoices internal docs
    • URL stores in BillingCompanyInvoice#pdf_path
    • generates by BillingCompanyInvoice#generate_pdf
    • folder name companys
  • billing company invoices external docs
    • URL stores in BillingCompanyInvoice#external_doc
    • generates by BillingCompanyInvoice#generate_pdf
    • folder name companys
  • billing company transfers
    • URL stores in BillingCompanyTransfer#pdf_path
    • generates by BillingCompanyTransfer#dispose!
    • folder name companys
  • marketing promotions documents with promotion codes
    • URL stores in MarketingPromotion#pdf_path
    • generates by MarketingPromotion#generate_missing_pdf!
    • folder name promotions
  • treatments presents
    • URL stores in TreatmentPresent#pdf_path)
    • generates by TreatmentsPresent#generate_missing_pdf!
    • folder name presents
  • venue acceptance forms
    • URL stores in VenueAcceptanceForm#pdf_path
    • generates by VenueAcceptanceForm#generate_pdf
    • folder name acceptances
  • billing company payment summaries
    • URL stores in BillingCompanyPaymentSummary#pdf_path
    • generates by Billing::GenerateBillingCompanyPaymentSummaryJob
    • folder name companys

Checkout receipts flow​

Upload​

The process of uploading the receipts contains two steps:

  • After FE call the endpoint POST /api/v1/venues/5/checkouts.json that is responsible for creation of new checkout (Api::V1::CheckoutsController#create) we call Cash::Checkouts::CreateInteractor that calls ::Checkouts::CreateService. In this service we have a method #_set_pdf_path that is calling after checkout creation. The method is responsible for creation of the unique PDF file name that will be used for further operations. The file name is a full public url or the future file in the S3 bucket and looks like https://<bucket name>.s3.eu-central-1.amazonaws.com/s/checkout-<id of checkout>-<date of creation>-<unique hash>.pdf. The file name is saved in the column pdf_path of the checkout.
  • After the checkout is created FE calls PUT /api/v1/venues/<venue id>/checkouts/<checkout id>/preview.json (Api::V1::CheckoutsController#update_preview) we call CheckoutReceiptPdf.generate_and_attach! for the checkout. It generates the same file name that we already have in the checkout and uploads the file that BE generates by parameters that received from FE. These parameters are saved in the checkout's column preview

Download​

To download the receipt you need to call the endpoint GET /api/v1/venues/<venue id>/checkouts/<checkout id>/preview_pdf_download (Api::V1::CheckoutsController#preview_pdf_download) that returns the JSON object with the link to the file. In this case we returning the full public url of the file

Bucket name in different environments​

  • development - be-devenvs-billing-registry
  • production - invoices.uala.it - for all countries

labels-registry

Description​

It shows up in only 1 file: uala-admin/app/admin/treatment.rb#import_labels It uploads a CSV file provided by Admin users to S3, naming starts with labels-importing, then involves ImportLabelsJob (uala-main/app/jobs/import_labels_job.rb) > Treatments::ImportTreatmentsService (uala-main/app/services/treatments/import_treatments_service.rb) to import labels

fiscal-archives

Description​

Used by:

  • Venues::PtPos::StoreFiscalArchiveInteractor to store SAF-T reports for Portuguese venues, the URL of the file is stored in the table fiscal_archives. The URL is sent to FE to download the file directly (Custom export and Fiscal export in Profile).

  • Cash::FiscalTransactionsExportJob, the file is generated only for German venues by the button FISCAL TRANSACTION EXPORT (inside the Company Report / Sales Proceeds of the SaaS), the uploaded CSV file is sent by mail to the venue.

  • Fiskaly::DSFinVK::ExportDownloadInteractor and Fiskaly::KassenSichV::TSSExportFileRetrieveInteractor for German venues reports. The file URL is stored in the table fiscal_archives. The file can be downloaded directly from its URL from the Fiscal archives Active Admin page (uala-admin/app/admin/fiscal_archive.rb). The URL is sent to FE to download the file directly (Custom export in Profile).

  • Venues::Nf525::GenerateMonthlyFiscalArchiveInteractor and Venues::Nf525::GenerateYearlyFiscalArchiveInteractor to store French fiscal reports. The file can be downloaded directly from its URL from the Fiscal archives Active Admin page (uala-admin/app/admin/fiscal_archive.rb). The URL is sent to FE to download the file directly (Custom export in Profile).

Bucket name in different environments​

  • development - be-devenvs-fiscal-archives
  • production - fiscal-archives