##############################################################################
# Packages
library(exams)
library(manacc)
library(tidyverse)
library(knitr)
library(kableExtra)
library(randomNames)


##############################################################################
# Initialization
question_id <- "EN00000034"
wdir <- getwd()
parameters <- teachR::param_quest(wdir, question_id, alttype = "mcq", altlevel = "3 Apply")
for (i in 1:length(parameters)) assign(names(parameters)[[i]], parameters[[i]])
options(xtable.comment = FALSE, xtable.floating = FALSE, xtable.timestamp = "")
set.seed(seed)


##############################################################################
# Preparation
basepar <- manacc::income_statements(basevol = 10000, profitable = c(TRUE,TRUE))
company <- basepar$company[[1]]
product <- basepar$product[[1]]
singular <- basepar$singular[[1]]
plural <- basepar$plural[[1]]

person <- manacc::make_persons(2)
currentmonth <- lubridate::month(Sys.Date(), label = TRUE, abbr = FALSE)
lastmonth <- lubridate::month(Sys.Date()-30, label = TRUE, abbr = FALSE)

base1 <- ceiling(sum(basepar$fprod) / 400 * 2/(3*2))
base2 <- ceiling(sum(basepar$fprod) / 400 * 1/(3*2))

allocation <- manacc::ata_2cp_2co_sequential(magnitudes = c(base1,base2), allocation_rates = c(base2,base1))

activity <- data.frame(
  Department = c("Planning","Maintenance",paste(basepar$reference, basepar$plural, sep = " ")),
  Accumulated = c(allocation$accumulated, basepar$vprod),
  Volumes = c(0, 0, basepar$vol),
  Labor = as.numeric(allocation$allocation_bases[1,]),
  Surface = as.numeric(allocation$allocation_bases[2,])
) %>%
  tibble::column_to_rownames("Department") %>%
  t() %>%
  as.data.frame() %>%
  dplyr::mutate_all(writR::dbl) %>%
  tibble::rownames_to_column("Activity") %>%
  mutate(Activity = c(paste0("Accumulated costs (", currency, "s)"),"Volumes produced (units)","Labor hours","Surface occupied (m2)"))

allocation_bases <- activity[c(3,4),]
allocation_bases[1,2] <- ""
allocation_bases[2,2] <- ""
allocation_bases[2,3] <- ""
allocation_bases[,"Total allocation base"] <- writR::dbl(c(sum(allocation$allocation_bases[1,2:4]), sum(allocation$allocation_bases[2,3:4])))


##############################################################################
# Answers

if (reqexpl != "" & exasolu == "exam" & type_table != "html") lines <- paste0("\\vspace{",15,"cm}") else lines <- rep(" \\ ", 2)
#lines <- rep("\\ ", 2)

rightar <- paste0(currencysymb, writR::dbl(round(allocation$solution[2],2)), " per m2.")
wrongar <- sample(unique(paste0(currencysymb, writR::dbl(round(allocation$wrong_ar2,2)), sample(c(" per labor hour"," per labor hour"," per m2"," per m2"," per m2"),5, replace = FALSE),".")),4)

questions <- c(rightar, wrongar)

solutions <- c(TRUE, rep(FALSE,4))

explanations <- c(
  "",
  "",
  "",
  "",
  ""
)


##############################################################################
# Randomize order (do not edit)
alea <- sample(c(1, sample(2:length(questions), (alternatives-1))), alternatives)
questions <- questions[alea]
solutions <- solutions[alea]
explanations <- explanations[alea]

Question

r txt_question_id r person$first_name[[1]] r person$last_name[[1]], management accountant working for r company, gathered the following information about production costs and activity in r lastmonth:

if (type_table == "html"){
  activity %>%
    knitr::kable(format = type_table, booktabs = TRUE, align = "lrrrr") %>%
    kable_styling(bootstrap_options = c("striped")) %>%
    kableExtra::column_spec(c(1), bold = TRUE)
} else {
  activity %>%
    knitr::kable(format = type_table, booktabs = TRUE, align = "lrrrr") %>%
    kable_styling(latex_options = c("striped","scale_down")) %>%
    kableExtra::column_spec(c(1), bold = TRUE)
}

\ "Planning" and "Maintenance" are two support departments. Planning is in charge of organizing production shifts and its workload is roughly proportional to labor hours. Maintenance is responsible for cleaning the factory and its work is proportional to the surface occupied. "r names(activity)[4]" and "r names(activity)[5]" refer to operating departments each specialized in a different product line.
\ The company applies the sequential method to allocate indirect product costs, starting by allocating the costs of the planning department. What is the allocation rate of the maintenance department? r reqexpl r points

if (reqexpl == "") exams::answerlist(questions, markup = "markdown") else writeLines(lines)

Solution

Based on the information provided, it is reasonable to use the labour hours to allocate planning costs and surface occupied to allocate maintenance costs. The labor hours worked in planning and the surface occupied by maintenance are self-services which must be ignored. Then, since the company starts by allocating planning, the surfaces occupied by planning must be ignored as well. In the sequential method of allocation, planning sends costs to maintenance but no cost should flow backward, from maintenance to planning. This leads to the following allocation bases:

if (type_table == "html"){
  allocation_bases %>% as_tibble() %>%
    knitr::kable(format = type_table, booktabs = TRUE, align = "lrrrrr") %>%
    kable_styling(bootstrap_options = c("striped")) %>%
    kableExtra::column_spec(c(1,6), bold = TRUE)
} else {
  allocation_bases %>% as_tibble() %>%
    knitr::kable(format = type_table, booktabs = TRUE, align = "lrrrrr") %>%
    kable_styling(latex_options = "striped","scale_down") %>%
    kableExtra::column_spec(c(1,6), bold = TRUE)
}

\ In the sequential allocation method, allocation rates must be computed one after the other. To find the allocation rate of the maintenance department, we must therefore start by computing the allocation rate of the planning department to compute the allocation from planning to maintenance which adds to the amount initially accumulated:

$$ AR_{planning} = \frac{\text{Amount initially accumulated}}{\text{Total allocation base}} = \frac{r activity[1,2]}{r allocation_bases[1,6]} = r writR::dbl(allocation$solution[1]) \text{ per labor hour} $$

Then, we can compute the allocation rate of the maintenance department:

$$ \begin{aligned} AR_{maintenance} & = \frac{\text{Amount initially accumulated + Allocation from planning}}{\text{Total allocation base}} \ & = \frac{r activity[1,3] + r activity[3,3] \times r writR::dbl(allocation$solution[1])}{r allocation_bases[2,6]} \ & = r writR::dbl(allocation$solution[2]) \text{ per m2} \end{aligned} $$

if (reqexpl == "") exams::answerlist(ifelse(solutions, "True", "False"), explanations, markup = "markdown") else writeLines(c("\\ ","\\ "))

Meta-information

extype: r extype exsolution: r exams::mchoice2string(solutions, single = TRUE) exname: r question_id



NicolasJBM/manacc documentation built on Jan. 16, 2020, 1:42 p.m.