This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module AdminCommand | |
module GuardJobs | |
class Cancel < BaseCommand | |
def call | |
if job.present? && job.filled? | |
if current_user.guard? && current_user.id != guard_job.guard_id | |
return false | |
end | |
guard_job.update(guard_id: nil) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module AdminCommand | |
module Jobs | |
class Assign < BaseCommand | |
include Concerns::Common::Collection | |
include Concerns::Common::WithUser | |
include Concerns::Jobs::GuardFilters | |
GUARD_ERROR = "Error: Job Is Already Filled" | |
LICENCE_ERROR ="Error: Guard Has Unmet Licence Requirements" | |
# TODO: Revisit guard_job creation and relations. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module ClientCommand | |
module Jobs | |
class CancelFilled < BaseCommand | |
include Concerns::Common::WithUser | |
def call | |
job.cancel_client_filled! do | |
JobItemCommand::CreateCancellationPenaltyCharge::call(job: job) | |
if refund.save | |
AdminCommand::StripeRefund::Create::call(job: job) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import { FlatList, ActivityIndicator, Text, View } from 'react-native'; | |
export default class FetchExample extends React.Component { | |
constructor(props){ | |
super(props); | |
this.state ={ isLoading: true} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module ClientCommand | |
module Jobs | |
class CancelFilled < BaseCommand | |
include Concerns::Common::WithUser | |
def call | |
job.cancel_client_filled! do | |
JobItemCommand::CreateCancellationPenaltyCharge::call(job: job) | |
if refund.save | |
AdminCommand::StripeRefund::Create::call(job: job) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Before Refactoring | |
def max_refund_exceeded | |
return unless quantity.present? | |
job_hours = self.job.number_of_hours | |
amendment_hours = self.job.job_items.where(type: ['JobItems::Lateness', 'JobItems::Refund']).map(&:quantity).sum | |
errors[:base] << "You've exceeded maximum refund" unless amendment_hours + quantity <= job_hours | |
end | |
# After Refactoring #1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, {Component} from 'react'; | |
import {Platform, StyleSheet, Text, View} from 'react-native'; | |
import { Provider } from 'react-redux'; | |
import { createStore, applyMiddleware, compose} from 'redux'; | |
import thunkMiddleware from 'redux-thunk'; | |
import createLogger from 'redux-logger'; | |
import reducer from './app/reducers'; | |
import DashboardContainer from './app/containers/DashboardContainer'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class JobItem < ApplicationRecord | |
VAT_RATE = 0.2 | |
AMENDMENT_FORM_LABELS = ['Lateness', 'Full Refund'].freeze | |
AMENDMENT_TYPES = ['JobItems::Lateness', 'JobItems::Refund'].freeze | |
CHARGABLE_TYPES = ['JobItems::GuardBooking', 'JobItems::LateBookingPenalty'].freeze | |
REFUNDABLE_TYPES = ['JobItems::Lateness', 'JobItems::Refund'].freeze | |
PERCENTAGE_TYPES = ['JobItems::CancelationPenalty', 'JobItems::LateBookingPenalty'].freeze | |
HOURS_TYPES = ['JobItems::GuardBooking', 'JobItems::Lateness',].freeze |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def licences_query(users) | |
return users unless params[:licence_ids] | |
users_scope = users | |
licence_ids = params[:licence_ids] | |
if params[:licence_ids].is_a? String | |
licence_ids = params[:licence_ids].split(',').map{|chr| chr.to_i} | |
end | |
# 4 - Door Supervision |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Current Version | |
def used_credit_amount | |
used_credit = jobs.where(paid_on_credit: true) | |
.where.not(state: 'unpaid') | |
.where.not(state: 'complete') | |
.map(&:total_charge).sum | |
completed_jobs_on_credit = jobs.completed_paid_on_credit_by_client(self) | |
completed_jobs_on_credit.each do |job| | |
if job.client_invoice.status == 'unpaid' |