### Setup Frontend Dependencies Source: https://github.com/antiwork/flexile/blob/main/README.md Installs frontend dependencies using pnpm for Node.js projects. ```shell cd frontend && pnpm i ``` -------------------------------- ### Setup Backend Dependencies Source: https://github.com/antiwork/flexile/blob/main/README.md Installs backend dependencies using Bundler and Foreman for Ruby projects. ```shell cd backend && bundle i && gem install foreman ``` -------------------------------- ### Complete Worker Invitation Script Example Source: https://github.com/antiwork/flexile/blob/main/docs/import.md A comprehensive Ruby script combining all steps: finding admin user, defining worker data, processing invitations, and handling results for importing workers into Flexile. ```ruby puts "👋 Starting worker invitation script" # Find the company admin user - replace with actual admin email admin = User.find_by(email: "admin@company.com") puts "👤 Found admin user | email = #{admin.email}" # Find the company and company administrator company = admin.companies.first company_administrator = admin.company_administrators.first puts "🏢 Found company | name = #{company.name}" puts "👔 Found company administrator | id = #{company_administrator.id}" # Define workers data workers = [ { name: "Example Project Worker", email: "project.worker@example.com", role: "Sr. SWE", start_date: Date.parse("2024-07-01"), pay_rate: 3208.33, pay_type: "project_based" }, { name: "Example Hourly Worker", email: "hourly.worker@example.com", role: "Accounting", start_date: Date.parse("2024-05-15"), pay_rate: 25.00, pay_type: "hourly" } ] puts "📋 Processing #{workers.length} workers" workers.each do |worker| puts "👤 Processing worker | name = #{worker[:name]} | email = #{worker[:email]}" worker_params = { email: worker[:email], started_at: worker[:start_date], pay_rate_in_subunits: (worker[:pay_rate] * 100).to_i, pay_rate_type: worker[:pay_type].downcase, role: worker[:role], } puts "📝 Inviting worker with params | #{worker_params}" result = InviteWorker.new( current_user: admin, company: company, company_administrator: company_administrator, worker_params: worker_params ).perform if result[:success] puts "✅ Successfully invited worker | name = #{worker[:name]}" else puts "❌ Failed to invite worker | name = #{worker[:name]} | error = #{result[:error_message]}" end end puts "🎉 Finished processing all workers" ``` -------------------------------- ### Flexile QuickBooks Integration States Source: https://github.com/antiwork/flexile/blob/main/docs/quickbooks.md Defines the different states an integration can be in, from initial setup to being out of sync or deleted. These states reflect the connection status and data synchronization health with QuickBooks. ```Ruby initialized - The integration has been created and connected to QuickBooks but the user has not finished setting up the expense and bank accounts active - The integration is successfully connected and syncing data out_of_sync - The integration became unauthorized and needs to be reconnected deleted - The integration has been disconnected from QuickBooks ``` -------------------------------- ### Access Flexile Rails Console Source: https://github.com/antiwork/flexile/blob/main/docs/stock-buybacks.md Connect to the Flexile application's Rails console to execute administrative commands. This is the entry point for many management tasks. ```bash heroku run rails console -a flexile ``` -------------------------------- ### Access Flexile Console Source: https://github.com/antiwork/flexile/blob/main/docs/import.md Connect to the Flexile application's console using Heroku CLI to execute commands and scripts. ```bash heroku run rails console -a flexile ``` -------------------------------- ### Enable Stock Buybacks for Company Source: https://github.com/antiwork/flexile/blob/main/docs/stock-buybacks.md Updates a company's settings to allow stock buybacks. This is a prerequisite for creating tender offers. ```ruby Company.find(COMPANY_ID).update!(stock_buybacks_allowed: true) ``` -------------------------------- ### Pull Funds via ACH using Stripe Source: https://github.com/antiwork/flexile/blob/main/docs/dividends.md Initiates a payment intent to pull funds via ACH using Stripe. It requires a Stripe setup intent and confirms the payment method, amount, currency, and other details. ```ruby company = Company.find(5) stripe_setup_intent = company.bank_account.stripe_setup_intent intent = Stripe::PaymentIntent.create({ payment_method_types: ["us_bank_account"], payment_method: stripe_setup_intent.payment_method, customer: stripe_setup_intent.customer, confirm: true, amount: 2_600_000, # set manually currency: "USD", expand: ["latest_charge"], capture_method: "automatic" }) ``` -------------------------------- ### Process and Invite Workers Source: https://github.com/antiwork/flexile/blob/main/docs/import.md Iterates through the defined worker data, prepares invitation parameters, and calls the `InviteWorker` service to send invitations. It logs the success or failure of each invitation. ```ruby workers.each do |worker| puts "👤 Processing worker | name = #{worker[:name]} | email = #{worker[:email]}" worker_params = { email: worker[:email], started_at: worker[:start_date], pay_rate_in_subunits: (worker[:pay_rate] * 100).to_i, pay_rate_type: worker[:pay_type].downcase, role: worker[:role], } puts "📝 Inviting worker with params | #{worker_params}" result = InviteWorker.new( current_user: admin, company: company, company_administrator: company_administrator, worker_params: worker_params ).perform if result[:success] puts "✅ Successfully invited worker | name = #{worker[:name]}" else puts "❌ Failed to invite worker | name = #{worker[:name]} | error = #{result[:error_message]}" end end puts "🎉 Finished processing all workers" ``` -------------------------------- ### Move Money from Stripe to Wise Source: https://github.com/antiwork/flexile/blob/main/docs/dividends.md Creates a Stripe payout to move funds from Stripe to Wise. It specifies the amount, currency, description, and statement descriptor for the payout. ```ruby payout = Stripe::Payout.create({ amount: 275_276_75, currency: "usd", description: "Dividends for ...", statement_descriptor: "Flexile" }) ``` -------------------------------- ### Access Heroku Console Source: https://github.com/antiwork/flexile/blob/main/docs/support.md Provides the command to access the Rails console for the Heroku application 'flexile'. This is useful for debugging and administrative tasks. ```bash heroku run rails console -a flexile ``` -------------------------------- ### Access Flexile Console Source: https://github.com/antiwork/flexile/blob/main/docs/dividends.md Command to access the Rails console for the Flexile application hosted on Heroku. This is typically used for administrative tasks and debugging. ```bash heroku run rails console -a flexile ``` -------------------------------- ### Manual Resync of Data in Ruby Source: https://github.com/antiwork/flexile/blob/main/docs/quickbooks.md Demonstrates how to manually trigger a resynchronization of data with QuickBooks using background jobs. It first schedules a general integration sync and then iterates through active contractors to sync their data individually. ```ruby company = Company.find(COMPANY_ID) integration = company.quickbooks_integration QuickbooksIntegrationSyncScheduleJob.perform_async(integration.id) company.company_contractors.active.each do |contractor| QuickbooksDataSyncJob.perform_async(contractor.id, 'CompanyContractor') end ``` -------------------------------- ### Process Dividends Source: https://github.com/antiwork/flexile/blob/main/docs/dividends.md Finalizes dividend processing and creates a new dividend round. ```ruby dividend_computation.finalize_and_create_dividend_round ``` -------------------------------- ### Sync Payments to QuickBooks BillPayments Source: https://github.com/antiwork/flexile/blob/main/docs/quickbooks.md Starts a background job to sync Flexile payments to QuickBooks as BillPayments when a payment's status changes to SUCCEEDED. This action creates a BillPayment in QuickBooks and applies it to the corresponding Bill, also establishing a link between the Flexile payment and the QuickBooks BillPayment. ```ruby QuickbooksDataSyncJob.perform_async(payment_id, 'Payment') ``` -------------------------------- ### Process Investor Payments for Buybacks Source: https://github.com/antiwork/flexile/blob/main/docs/stock-buybacks.md Processes payments for equity buybacks by enqueuing jobs for eligible investors. It checks for verified tax IDs, residency status, and onboarding completion before scheduling payments. ```ruby tender_offer = TenderOffer.find(TENDER_OFFER_ID) equity_buyback_round = tender_offer.equity_buyback_round delay = 0 equity_buyback_round.equity_buybacks.each do |equity_buyback| investor = equity_buyback.company_investor user = investor.user next if !user.has_verified_tax_id? || user.restricted_payout_country_resident? || user.sanctioned_country_resident? || user.tax_information_confirmed_at.nil? || !investor.completed_onboarding? InvestorEquityBuybacksPaymentJob.perform_in((delay * 2).seconds, equity_buyback.id) delay += 1 end ``` -------------------------------- ### Create New Tender Offer Source: https://github.com/antiwork/flexile/blob/main/docs/stock-buybacks.md Creates a new tender offer for a specified company with details such as name, description, dates, and pricing parameters. Requires the company to have stock buybacks enabled. ```ruby company = Company.find(COMPANY_ID) tender_offer = company.tender_offers.create!( name: "Q4 2024 Stock Buyback", description: "Quarterly stock buyback program", start_date: Date.current, end_date: 30.days.from_now, total_amount_in_cents: 1_000_000_00, number_of_shares: 100_000, minimum_price_cents: 10_00, maximum_price_cents: 15_00 ) ``` -------------------------------- ### Define Worker Data Structure Source: https://github.com/antiwork/flexile/blob/main/docs/import.md Defines an array of worker objects in Ruby, each containing details like name, email, role, start date, pay rate, and pay type. This data is used for inviting workers. ```ruby # Define workers data workers = [ { name: "Example Project Worker", email: "project.worker@example.com", role: "Sr. SWE", start_date: Date.parse("2024-07-01"), pay_rate: 3208.33, pay_type: "project_based" }, { name: "Example Hourly Worker", email: "hourly.worker@example.com", role: "Accounting", start_date: Date.parse("2024-05-15"), pay_rate: 25.00, pay_type: "hourly" } ] puts "📋 Processing #{workers.length} workers" ``` -------------------------------- ### Mark Dividend as Ready for Payments Source: https://github.com/antiwork/flexile/blob/main/docs/dividends.md Marks a dividend round as ready for payment by updating the 'ready_for_payment' attribute to true. This is typically done after investors have signed up or onboarded. ```ruby dividend_round = Company.find(1823).dividend_rounds.order(id: :desc).first dividend_round.update!(ready_for_payment: true) ``` -------------------------------- ### Backup Company Data as JSON (Ruby) Source: https://github.com/antiwork/flexile/blob/main/docs/support.md Backs up company data, including company details and associated users, into a JSON file. The filename is dynamically generated based on the company ID. ```ruby company = Company.find(123) File.write("company_#{company.id}.json", { company: company.as_json, users: company.users.as_json }.to_json) ``` -------------------------------- ### Process All Eligible Investors for Payments Source: https://github.com/antiwork/flexile/blob/main/docs/dividends.md Processes all eligible investors for dividend payments by scheduling a job for each investor. It filters investors based on tax ID verification, country restrictions, and onboarding status. ```ruby delay = 0 CompanyInvestor.joins(:dividends) .includes(:user) .where(dividends: { dividend_round_id: dividend_round_id, status: [Dividend::ISSUED, Dividend::RETAINED] }) .group(:id) .each do |investor| print "." user = investor.user next if !user.has_verified_tax_id? || user.restricted_payout_country_resident? || user.sanctioned_country_resident? || user.tax_information_confirmed_at.nil? || !investor.completed_onboarding? InvestorDividendsPaymentJob.perform_in((delay * 2).seconds, investor.id) delay += 1 end; nil ``` -------------------------------- ### Calculate Fees Source: https://github.com/antiwork/flexile/blob/main/docs/dividends.md Calculates fees for dividends based on a percentage and a fixed amount, then returns the sum of fees. It handles potential rounding and ensures fees are capped. ```ruby company = Company.find(5) dividends = company.dividend_rounds.last.dividends fees = dividends.map do |dividend| calculated_fee = ((dividend.total_amount_in_cents.to_d * 2.9.to_d/100.to_d) + 30.to_d).round.to_i [30_00, calculated_fee].min end fees.sum / 100.0 ``` -------------------------------- ### Enable Equity and Create Dividends via CSV Source: https://github.com/antiwork/flexile/blob/main/docs/dividends.md Ruby code to enable equity for a company and process dividend creation from CSV data. It includes a service to invite investors, save dividend records, and send notifications. The script handles data parsing and dividend processing, with options for first round and return of capital. ```ruby Company.find(1823).update!(equity_enabled: true) ``` ```ruby data = <<~CSV name,full_legal_name,investment_address_1,investment_address_2,investment_address_city,investment_address_region,investment_address_postal_code,investment_address_country,email,investment_date,investment_amount,tax_id,entity_name,dividend_amount John Doe,John Michael Doe,123 Main St,,San Francisco,CA,94102,US,john@example.com,2024-01-15,10000.00,123-45-6789,,500.00 Jane Smith,Jane Elizabeth Smith,456 Oak Ave,Apt 2B,New York,NY,10001,US,jane@example.com,2024-02-20,25000.00,987-65-4321,,1250.00 CSV service = CreateInvestorsAndDividends.new( company_id: 1823, csv_data: data, dividend_date: Date.new(2025, 6, 4), is_first_round: true, # defaults to false is_return_of_capital: true # defaults to false ) service.process ``` -------------------------------- ### Resend Investor Invitations Source: https://github.com/antiwork/flexile/blob/main/docs/dividends.md Ruby script to resend invitation emails to investors who have not yet signed up for Flexile. It identifies investors with a 'PENDING_SIGNUP' dividend status and triggers the invitation process. ```ruby company = Company.find(1823) dividend_date = Date.parse("June 4, 2025") primary_admin_user = company.primary_admin.user company.investors.joins(:dividends) .where(dividends: { status: Dividend::PENDING_SIGNUP }) .find_each do |user| user.invite!( primary_admin_user, subject: "Action required: start earning distributions on your investment in #{company.name}", reply_to: primary_admin_user.email, template_name: "investor_invitation_instructions", dividend_date: dividend_date ) end ``` -------------------------------- ### View Tender Offer Results Source: https://github.com/antiwork/flexile/blob/main/docs/stock-buybacks.md Retrieves and displays key results of a tender offer, including total amount, accepted price, total bids, and accepted bids. ```ruby tender_offer = TenderOffer.find(TENDER_OFFER_ID) puts "Total Amount: $#{tender_offer.total_amount_in_cents / 100.0}" puts "Accepted Price: $#{tender_offer.accepted_price_cents / 100.0}" if tender_offer.accepted_price_cents puts "Total Bids: #{tender_offer.bids.count}" puts "Accepted Bids: #{tender_offer.bids.where('accepted_shares > 0').count}" ``` -------------------------------- ### Manually Create Dividends for Investors Source: https://github.com/antiwork/flexile/blob/main/docs/dividends.md Ruby script to manually create dividend records for specific investors who may not be in the automatically generated list or have updated email addresses. It finds the user, creates the dividend entry, and sends a 'dividend issued' email. ```ruby company = Company.find(1823) dividend_round = company.dividend_rounds.find(3) dividend_data = { "email" => 18.44, } dividend_data.each do |email, amount| user = User.find_by!(email: email) company_investor = user.company_investors.find_by!(company: company) dividend_cents = (amount * 100.to_d).to_i company_investor.dividends.create!( dividend_round: dividend_round, company: company, status: user.current_sign_in_at.nil? ? Dividend::PENDING_SIGNUP : Dividend::ISSUED, total_amount_in_cents: dividend_cents, qualified_amount_cents: dividend_cents ) investor_dividend_round = company_investor.investor_dividend_rounds.find_or_create_by!(dividend_round_id: dividend_round_id) investor_dividend_round.send_dividend_issued_email puts "Created dividend for #{email}: $#{amount}" rescue => e puts "Error creating dividend for #{email}: #{e.message}" end ``` -------------------------------- ### QuickBooks Webhook Events Handled by Flexile Source: https://github.com/antiwork/flexile/blob/main/docs/quickbooks.md Flexile subscribes to specific QuickBooks webhook events to manage data synchronization and unlink integration records when necessary. The `Quickbooks::EventHandler` service processes these events. ```Ruby Vendor - Merge, Update, Delete Bill - Update, Delete BillPayment - Update, Delete ``` -------------------------------- ### Retry Failed Payments (Ruby) Source: https://github.com/antiwork/flexile/blob/main/docs/support.md Retries payments that have failed for dividends. It iterates through dividends with a 'payment_failed' status and enqueues a job to process them. ```ruby Dividend.where(status: "payment_failed").find_each { |d| InvestorDividendsPaymentJob.perform_async(d.company_investor_id) } ``` -------------------------------- ### QuickBooks Data Synchronization Job Source: https://github.com/antiwork/flexile/blob/main/docs/quickbooks.md This Ruby job handles the synchronization of data between Flexile and QuickBooks. It is responsible for creating QuickBooks Vendors from Flexile contractors, Bills from invoices, and BillPayments from payments. ```Ruby class QuickbooksDataSyncJob < ApplicationJob queue_as :default def perform(*args) # Implementation for syncing data to QuickBooks end end ``` -------------------------------- ### Check Investor Dividends (Ruby) Source: https://github.com/antiwork/flexile/blob/main/docs/support.md Retrieves all dividends associated with a specific user, identified by their email address. This allows for checking an investor's dividend history. ```ruby u = User.find_by(email: "investor@example.com") u.dividends ``` -------------------------------- ### Find Admin User and Company Details Source: https://github.com/antiwork/flexile/blob/main/docs/import.md This Ruby script finds the company's admin user by email and retrieves associated company and administrator details. It's a prerequisite for inviting workers. ```ruby puts "👋 Starting worker invitation script" # Find the company admin user - replace with actual admin email admin = User.find_by(email: "admin@company.com") puts "👤 Found admin user | email = #{admin.email}" # Find the company and company administrator company = admin.companies.first company_administrator = admin.company_administrators.first puts "🏢 Found company | name = #{company.name}" puts "👔 Found company administrator | id = #{company_administrator.id}" ``` -------------------------------- ### Check Integration Errors in Ruby Source: https://github.com/antiwork/flexile/blob/main/docs/quickbooks.md Provides a Ruby code snippet to retrieve and display the 'sync_error' column from the QuickBooks integration record for a given company. This is useful for debugging synchronization issues. ```ruby integration = Company.find(COMPANY_ID).quickbooks_integration puts integration.sync_error if integration.sync_error.present? ``` -------------------------------- ### Update Company Trusted Flag (Ruby) Source: https://github.com/antiwork/flexile/blob/main/docs/support.md Updates the 'is_trusted' flag to true for a company identified by its name. This operation modifies the company record in the database. ```ruby Company.find_by(name: "Keepers, LLC").update!(is_trusted: true) ``` -------------------------------- ### Sync Contractors to QuickBooks Vendors Source: https://github.com/antiwork/flexile/blob/main/docs/quickbooks.md Triggers background jobs to synchronize contractor data from Flexile to QuickBooks as Vendors. This includes creating new vendors or updating existing ones based on changes in contractor information like email, name, tax ID, address, or pay rate. It also links Flexile contractors to QuickBooks vendors via an integration record and triggers further processing. ```ruby QuickbooksIntegrationSyncScheduleJob.perform_async(integration_id) QuickbooksDataSyncJob.perform_async(contractor_id, 'CompanyContractor') ``` -------------------------------- ### Contractor Data Synchronization Logic Source: https://github.com/antiwork/flexile/blob/main/docs/quickbooks.md This Ruby code snippet outlines the conditions under which contractor information is synchronized with QuickBooks. Changes to specific fields like email, name, address, and pay rate trigger an update. ```Ruby # Synchronized when a contractor finishes the onboarding setup # ... # Synchronized when a contractor updates: # - email # - unconfirmed_email # - preferred_name # - legal_name # - tax_id # - business_name # - city # - state # - street_address # - zip_code # - country_code # ... # Synchronized when a company administrator updates the contractor's pay_rate_in_subunits ``` -------------------------------- ### Validate Data and Send Emails Source: https://github.com/antiwork/flexile/blob/main/docs/dividends.md Validates data and sends CSV reports via email using AdminMailer. It prepares attachments for per investor and share class, per investor, and final reports. ```ruby dividend_computation = DividendComputation.last attached = { "per_investor_and_share_class.csv" => { mime_type: "text/csv", content: dividend_computation.to_csv }, "per_investor.csv" => { mime_type: "text/csv", content: dividend_computation.to_per_investor_csv }, "final.csv" => { mime_type: "text/csv", content: dividend_computation.to_final_csv } } AdminMailer.custom( to: ["sahil.lavingia@gmail.com", "howard@antiwork.com"], subject: "Test", body: "Attached", attached: attached ).deliver_now ``` -------------------------------- ### Check Recent Payments (Ruby) Source: https://github.com/antiwork/flexile/blob/main/docs/support.md Retrieves recent payments associated with a specific company. It joins the 'dividends' and 'payments' tables and filters payments created within the last week. ```ruby company = Company.find(123) company.dividends.joins(:payments).where(payments: { created_at: 1.week.ago.. }) ``` -------------------------------- ### Generate Equity Buybacks from Tender Offer Source: https://github.com/antiwork/flexile/blob/main/docs/stock-buybacks.md Generates equity buyback records based on a completed tender offer and its calculated equilibrium price. This process creates a buyback round and individual buyback records for accepted bids. ```ruby tender_offer = TenderOffer.find(TENDER_OFFER_ID) generator = TenderOffers::GenerateEquityBuybacks.new(tender_offer: tender_offer) generator.perform ``` -------------------------------- ### Notify Investors with Retained Dividends Source: https://github.com/antiwork/flexile/blob/main/docs/dividends.md Notifies investors with retained dividends about the reason for retention. It checks the status and reason for retained dividends and sends appropriate emails (e.g., sanctioned country, below threshold). ```ruby dividend_round.investor_dividend_rounds.each do |investor_dividend_round| dividends = dividend_round.dividends.where(company_investor_id: investor_dividend_round.company_investor_id) status = dividends.pluck(:status).uniq next unless status == [Dividend::RETAINED] retained_reason = dividends.pluck(:retained_reason).uniq if retained_reason == [Dividend::RETAINED_REASON_COUNTRY_SANCTIONED] investor_dividend_round.send_sanctioned_country_email elsif retained_reason == [Dividend::RETAINED_REASON_BELOW_THRESHOLD] investor_dividend_round.send_payout_below_threshold_email end end; nil ``` -------------------------------- ### Generate Dividend Computation Source: https://github.com/antiwork/flexile/blob/main/docs/dividends.md Ruby code to generate a dividend computation for a company. This service calculates dividend amounts based on specified parameters like total amount and return of capital status, and outputs preferred and common dividend totals. ```ruby company = Company.find(5) service = DividendComputationGeneration.new( company, amount_in_usd: 2_570_000, return_of_capital: false ) service.process puts service.instance_variable_get(:@preferred_dividend_total) puts service.instance_variable_get(:@common_dividend_total) puts service.instance_variable_get(:@preferred_dividend_total) + service.instance_variable_get(:@common_dividend_total) ``` -------------------------------- ### Sync Invoices to QuickBooks Bills Source: https://github.com/antiwork/flexile/blob/main/docs/quickbooks.md Initiates a background job to sync Flexile invoices to QuickBooks as Bills when an invoice becomes payable. This process maps invoice line items and expenses to Bill lines in QuickBooks and creates a record linking the Flexile invoice to the QuickBooks Bill. ```ruby QuickbooksDataSyncJob.perform_async(invoice_id, 'Invoice') ``` -------------------------------- ### Payment Data Synchronization Logic Source: https://github.com/antiwork/flexile/blob/main/docs/quickbooks.md This Ruby code snippet specifies that payment data is synchronized to QuickBooks when a payment's status changes to 'SUCCEEDED'. This ensures that successful payments are accurately reflected in QuickBooks. ```Ruby # Synchronized when a payment changes its status to SUCCEEDED ``` -------------------------------- ### Consolidated Payment Data Synchronization Logic Source: https://github.com/antiwork/flexile/blob/main/docs/quickbooks.md This Ruby code snippet explains that consolidated payment data is synchronized to QuickBooks when its status changes to 'SUCCEEDED'. This reflects the successful processing of multiple payments grouped together. ```Ruby # Synchronized when a consolidated payment changes its status to SUCCEEDED ``` -------------------------------- ### Consolidated Invoice Data Synchronization Logic Source: https://github.com/antiwork/flexile/blob/main/docs/quickbooks.md This Ruby code snippet details that consolidated invoice data is synchronized to QuickBooks upon its creation. This process likely bundles multiple individual invoices for streamlined accounting. ```Ruby # Synchronized when a consolidated invoice is created ``` -------------------------------- ### Calculate Tender Offer Equilibrium Price Source: https://github.com/antiwork/flexile/blob/main/docs/stock-buybacks.md Calculates the equilibrium price for a tender offer after its end date. This service sorts bids, determines the optimal price to maximize share purchases within constraints, and updates bid and tender offer records. ```ruby tender_offer = TenderOffer.find(TENDER_OFFER_ID) calculator = TenderOffers::CalculateEquilibriumPrice.new( tender_offer: tender_offer, total_amount_cents: tender_offer.total_amount_in_cents, total_shares: tender_offer.number_of_shares ) equilibrium_price = calculator.perform ``` -------------------------------- ### QuickBooks Journal Entry Payload Generation Source: https://github.com/antiwork/flexile/blob/main/docs/quickbooks.md This Ruby code snippet refers to the generation of a QuickBooks journal entry payload. This is used to clear amounts from a clearing account when a consolidated payment is processed, ensuring accurate financial reconciliation. ```Ruby # Create a new QBO JournalEntry to clear the ConsolidatedInvoice and Invoice amounts from the Flexile.com Money Out Clearing account via the ConsolidatedPayment#quickbooks_journal_entry_paylod ``` -------------------------------- ### Notify Investors of Tender Offer Closure Source: https://github.com/antiwork/flexile/blob/main/docs/stock-buybacks.md Sends closing notification emails to investors who participated in a tender offer. Emails contain results, shares sold, price per share, and total amount received. ```ruby tender_offer = TenderOffer.find(TENDER_OFFER_ID) company_investors_with_bids = CompanyInvestor.joins(:tender_offer_bids) .where(tender_offer_bids: { tender_offer_id: tender_offer.id }) .distinct company_investors_with_bids.each do |investor| CompanyInvestorMailer.tender_offer_closed( investor.id, tender_offer_id: tender_offer.id ).deliver_now end ``` -------------------------------- ### Invoice Data Synchronization Logic Source: https://github.com/antiwork/flexile/blob/main/docs/quickbooks.md This Ruby code snippet indicates when invoice data is synchronized to QuickBooks. The synchronization occurs when an invoice reaches a payable state, likely meaning it has been approved and is ready for payment processing. ```Ruby # Synchronized when an invoice becomes payable ``` -------------------------------- ### Process Consolidated Payments in QuickBooks Source: https://github.com/antiwork/flexile/blob/main/docs/quickbooks.md Handles the synchronization of consolidated payments, creating either a single BillPayment for a consolidated invoice or individual BillPayments for each payment within a consolidated payment. It also generates a Journal Entry in QuickBooks to manage the clearing account for these transactions. ```ruby QuickbooksDataSyncJob.perform_async(consolidated_payment_id, 'ConsolidatedPayment') ``` -------------------------------- ### Create Postgres User Source: https://github.com/antiwork/flexile/blob/main/README.md Manually creates a PostgreSQL user with login, database creation, superuser privileges, and a specified password. ```bash psql postgres -c "CREATE USER username WITH LOGIN CREATEDB SUPERUSER PASSWORD 'password';" ``` -------------------------------- ### Configure Wise API Credentials Source: https://github.com/antiwork/flexile/blob/main/README.md Sets the Wise profile ID and API key in the .env file for integration with Wise services. ```dotenv WISE_PROFILE_ID=12345678 # Should be a number WISE_API_KEY=your_full_api_token_here ``` -------------------------------- ### Generate Stripe Customer ID Source: https://github.com/antiwork/flexile/blob/main/README.md Creates a new Stripe customer with a name, email, and a mock API key for testing purposes. ```bash stripe customers create \ --name "Customer Name" \ --email "customer@example.com" \ --api-key "sk_test_mock" ``` -------------------------------- ### Configure Stripe API Keys Source: https://github.com/antiwork/flexile/blob/main/README.md Sets the Stripe publishable and secret keys in the .env file for application integration. ```dotenv NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY=pk_test_your_publishable_key_here STRIPE_SECRET_KEY=sk_test_your_secret_key_here ``` -------------------------------- ### Create and Attach Prefilled 1099-NEC PDF Source: https://github.com/antiwork/flexile/blob/main/docs/irs.md This Ruby code illustrates the process of creating a tax document record, serializing its data, generating a prefilled PDF using the `hexapdf` gem, and attaching it to the document. It handles PDF template paths and form data serialization. ```ruby # Create document record document = Document.create!( name: Document::FORM_1099_NEC, document_type: :tax_document, year: tax_year, company: company, user_compliance_info: user_compliance_info ) # Serialize data for PDF prefilling serializer = document.fetch_serializer serialized_data = serializer.serialized_attributes # Generate prefilled PDF pdf_service = PrefilledPdfService.new( template_path: "config/data/tax_forms/1099-NEC.pdf", form_data: serialized_data ) pdf_content = pdf_service.generate # Attach to document document.attachments.attach( io: StringIO.new(pdf_content), filename: "#{document.name}_#{tax_year}_#{company.name}.pdf", content_type: "application/pdf" ) ``` -------------------------------- ### Configure Resend API Key Source: https://github.com/antiwork/flexile/blob/main/README.md Sets the Resend API key in the .env file for email sending integration. ```dotenv RESEND_API_KEY=re_your_api_key_here ``` -------------------------------- ### Run Playwright End-to-End Tests Source: https://github.com/antiwork/flexile/blob/main/README.md Executes all end-to-end tests written using the Playwright framework. ```shell pnpm playwright test ``` -------------------------------- ### Run Rails Specs Source: https://github.com/antiwork/flexile/blob/main/README.md Executes all RSpec tests for a Ruby on Rails application. ```shell bundle exec rspec ``` -------------------------------- ### Run Single Rails Spec Source: https://github.com/antiwork/flexile/blob/main/README.md Executes a specific RSpec test file and line number for a Ruby on Rails application. ```shell bundle exec rspec spec/system/roles/show_spec.rb:7 ``` -------------------------------- ### Scheduled IRS Data Generation Jobs Source: https://github.com/antiwork/flexile/blob/main/docs/irs.md Scheduled Sidekiq jobs designed to generate various IRS tax forms before their respective deadlines. These jobs automate the data preparation process for tax filings. ```Ruby class Irs::Form1099divDataGenerator # ... implementation ... end class Irs::Form1099necDataGenerator # ... implementation ... end class Irs::Form1042sDataGenerator # ... implementation ... end ``` -------------------------------- ### Generate and Email 1042-S Tax Report using Ruby Source: https://github.com/antiwork/flexile/blob/main/docs/irs.md This Ruby code snippet illustrates the process of generating a 1042-S tax report for a specified company and tax year using the `Irs::Form1042sDataGenerator` class. The generated text file is then attached to an email and dispatched via `AdminMailer.custom`, intended for submission through the IRS FIRE system. ```Ruby company = Company.find(company_id) tax_year = 2025 is_test = false attached = { "IRS-1042-S-#{tax_year}.txt" => Irs::Form1042sDataGenerator.new(company: company, tax_year: tax_year, is_test: is_test).process } AdminMailer.custom(to: ["your-email@example.com"], subject: "[Flexile] #{company.name} 1042-S #{tax_year} IRS FIRE tax report #{is_test ? "test " : ""}file", body: "Attached", attached: attached).deliver_now ``` -------------------------------- ### Generate Tax Forms with Flexile Source: https://github.com/antiwork/flexile/blob/main/docs/irs.md This service is used to regenerate tax forms for contractors or investors when adjustments are needed. It involves marking the old document as deleted and creating a new one. ```Ruby class GenerateTaxFormService def initialize(document) @document = document end def regenerate @document.mark_deleted! # Logic to generate a new tax form # ... end end ``` -------------------------------- ### Metabase Reports for 1042 Annual Tax Reports Source: https://github.com/antiwork/flexile/blob/main/docs/irs.md SQL queries used within Metabase to generate reports on annual tax filings, specifically focusing on dividends paid to foreign investors. ```SQL SELECT DATE_TRUNC('month', payment_date) AS month, SUM(amount) AS total_dividends FROM dividend_payments WHERE recipient_is_foreign = TRUE GROUP BY month ORDER BY month; ``` ```SQL SELECT SUM(amount) AS total_dividends_paid_to_foreign_investors FROM dividend_payments WHERE recipient_is_foreign = TRUE; ``` -------------------------------- ### Generate and Email 1099-NEC Tax Report using Ruby Source: https://github.com/antiwork/flexile/blob/main/docs/irs.md This Ruby code snippet demonstrates how to generate a 1099-NEC tax report for a given company and tax year using the `Irs::Form1099necDataGenerator` class. It then attaches the generated text file to an email and sends it using `AdminMailer.custom`, suitable for filing via the IRS FIRE system. ```Ruby company = Company.find(company_id) tax_year = 2025 is_test = false attached = { "IRS-1099-NEC-#{tax_year}.txt" => Irs::Form1099necDataGenerator.new(company: company, tax_year: tax_year, is_test: is_test).process } AdminMailer.custom(to: ["your-email@example.com"], subject: "[Flexile] #{company.name} 1099-NEC #{tax_year} IRS FIRE tax report #{is_test ? "test " : ""}file", body: "Attached", attached: attached).deliver_now ``` -------------------------------- ### Mark Tax Forms as Filed with Signatures Source: https://github.com/antiwork/flexile/blob/main/docs/irs.md This Ruby code demonstrates how to mark tax documents as filed by creating signature records for each relevant document. It queries documents based on company, tax year, and form name. ```ruby # Mark all relevant documents as filed Document.where( company: company, tax_year: tax_year, name: Document::FORM_1099_NEC, ).includes(user_compliance_info: :user).find_each do |document| document.signatures.create!(title: "Signer", user: document.user_compliance_info.user, signed_at: Time.current) end ``` -------------------------------- ### Generate Combined IRS File for 1099-NEC Source: https://github.com/antiwork/flexile/blob/main/docs/irs.md This Ruby snippet shows how to generate a combined IRS file for 1099-NEC forms. It utilizes the `Form1099necDataGenerator` to create the file and then prepares it for download. ```ruby # Run generator for appropriate form generator = Irs::Form1099necDataGenerator.new(company: company, tax_year: tax_year) output_file = generator.generate_combined_irs_file # Download file File.open(output_file, "r") do |file| send_data file.read, filename: "1099NEC_#{company.name}_#{tax_year}.txt", type: "text/plain" end ``` -------------------------------- ### Use Flexile Trademark in Marketing Materials Source: https://github.com/antiwork/flexile/blob/main/TRADEMARK_GUIDELINES.md When describing your product that includes Flexile software, you must use a specific legend in your marketing materials or product descriptions to acknowledge Flexile's trademark. ```Text Flexile is a trademark of Gumroad, Inc. ``` -------------------------------- ### Generate 1099-NEC Form Data Source: https://github.com/antiwork/flexile/blob/main/docs/irs.md This Ruby code snippet demonstrates how to generate data for a 1099-NEC tax form. It retrieves user compliance information and company details, then instantiates a `Form1099necDataGenerator` to produce the necessary form data. ```ruby user_compliance_info = UserComplianceInfo.find(user_compliance_info_id) company = company_id ? Company.find(company_id) : user_compliance_info.user.company_workers.first.company # Generate form data generator = Irs::Form1099necDataGenerator.new(user_compliance_info:, company:, tax_year:) form_data = generator.generate ``` -------------------------------- ### Display Trademark Symbol and Legend Source: https://github.com/antiwork/flexile/blob/main/TRADEMARK_GUIDELINES.md When using a Flexile trademark, display the appropriate symbol (® or ™) on its first prominent mention and include a specific notice at the foot of the page. ```Text Flexile is a trademark of Gumroad, Inc. ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.