#R codes ##Data Loading

#Profit&Loss A/c DATA```{r setup,include=TRUE}
# Load the readxl package
library(readxl)
## Warning: package 'readxl' was built under R version 4.4.3
library(gridExtra)
## Warning: package 'gridExtra' was built under R version 4.4.3
library(ggplot2)
## Warning: package 'ggplot2' was built under R version 4.4.3
#--------------------------------------
allcargo_pl <- read_excel("D:/FA using R/Project/Process/allcargo_pl.xlsx")
alcargo_bs <- read_excel("D:/FA using R/Project/Process/alcargo_bs.xlsx")
allcargo_cfs <- read_excel("D:/FA using R/Project/Process/allcargo_cfs.xlsx")

allcargo_pl<-as.data.frame(allcargo_pl)
# Clean column names 
colnames(allcargo_pl) <- make.names(colnames(allcargo_pl))
colnames(allcargo_pl) <- trimws(colnames(allcargo_pl))
#-----------------------------------
# Reshaping the data to long format using reshape function
allcargo_pl_long <- reshape(allcargo_pl, 
                            varying = c("X2024", "X2023", "X2022", "X2021", "X2020"), 
                            v.names = "Amount", 
                            timevar = "Year",
                            times = c("2024","2023","2022","2021", "2020"),
                            direction = "long")
#----------------------------------
# Reset row names if necessary
rownames(allcargo_pl_long) <- NULL



#----------------------------------------------------------------------
#----------------------------------------------------------------------
#Balance sheet
alcargo_bs<-as.data.frame(alcargo_bs)
# Clean column names (if needed)
colnames(alcargo_bs) <- make.names(colnames(alcargo_bs))
colnames(alcargo_bs) <- trimws(colnames(alcargo_bs))
#-----------------------------------
# Reshaping the data to long format using reshape function
alcargo_bs_long <- reshape(alcargo_bs, 
                           varying = c("X2024", "X2023", "X2022", "X2021", "X2020"), 
                           v.names = "Amount", 
                           timevar = "Year",
                           times = c("2024","2023","2022","2021", "2020"),
                           direction = "long")
#----------------------------------
# Reset row names if necessary
rownames(alcargo_bs_long) <- NULL


#--------------------------------------------------------------------------------
#Cash flow statement
allcargo_cfs<-as.data.frame(allcargo_cfs)
# Clean column names (if needed)
colnames(allcargo_cfs) <- make.names(colnames(allcargo_cfs))
colnames(allcargo_cfs) <- trimws(colnames(allcargo_cfs))
#-----------------------------------
# Reshaping the data to long format using reshape function
allcargo_cfs_long <- reshape(allcargo_cfs, 
                             varying = c("X2024", "X2023", "X2022", "X2021", "X2020"), 
                             v.names = "Amount", 
                             timevar = "Year",
                             times = c("2024","2023","2022","2021", "2020"),
                             direction = "long")
#----------------------------------
# Reset row names if necessary
rownames(allcargo_cfs_long) <- NULL


#--------------------------------------
vrl_pl <- read_excel("D:/FA using R/Project/Competitor/process/vrl_pl.xlsx")
vrl_pl<-as.data.frame(vrl_pl)
# Clean column names (if needed)
colnames(vrl_pl) <- make.names(colnames(vrl_pl))
colnames(vrl_pl) <- trimws(colnames(vrl_pl))
#-----------------------------------
# Reshaping the data to long format using reshape function
vrl_pl_long <- reshape(vrl_pl, 
                       varying = c("X2024", "X2023", "X2022", "X2021", "X2020"), 
                       v.names = "Amount", 
                       timevar = "Year",
                       times = c("2024","2023","2022","2021", "2020"),
                       direction = "long")
#----------------------------------
# Reset row names if necessary
rownames(vrl_pl_long) <- NULL

#-----------------------------------------------------------------------------------------------

vrl_bs <- read_excel("D:/FA using R/Project/Competitor/process/vrl_bs.xlsx")
vrl_bs<-as.data.frame(vrl_bs)
# Clean column names (if needed)
colnames(vrl_bs) <- make.names(colnames(vrl_bs))
colnames(vrl_bs) <- trimws(colnames(vrl_bs))
#-----------------------------------
# Reshaping the data to long format using reshape function
vrl_bs_long <- reshape(vrl_bs, 
                       varying = c("X2024", "X2023", "X2022", "X2021", "X2020"), 
                       v.names = "Amount", 
                       timevar = "Year",
                       times = c("2024","2023","2022","2021", "2020"),
                       direction = "long")
#----------------------------------

# Reset row names if necessary
rownames(vrl_bs_long) <- NULL
#-------------------------------------------------------------------------------------------

vrl_cfs <- read_excel("D:/FA using R/Project/Competitor/process/vrl_cfs.xlsx")
vrl_cfs<-as.data.frame(vrl_cfs)
# Clean column names (if needed)
colnames(vrl_cfs) <- make.names(colnames(vrl_cfs))
colnames(vrl_cfs) <- trimws(colnames(vrl_cfs))
#-----------------------------------
# Reshaping the data to long format using reshape function
vrl_cfs_long <- reshape(vrl_cfs, 
                        varying = c("X2024", "X2023", "X2022", "X2021", "X2020"), 
                        v.names = "Amount", 
                        timevar = "Year",
                        times = c("2024","2023","2022","2021", "2020"),
                        direction = "long")
#----------------------------------
# Reset row names if necessary
rownames(vrl_cfs_long) <- NULL

#——————————————

RATIOS CALCULATION

Activity ratio

Activity ratios measure how effectively a company uses its assets and resources to operate and generate revenue. These ratios help businesses evaluate their efficiency in managing assets like inventory, receivables, and fixed assets. They act as indicators of how "busy" or "productive" the business is in using what it owns.
#1 Trade Receivable turnover ratio
#Define groups from the items
num <-  c("revfromopr_net")  
den  <- c("Trade_Receiva")      

#Finding the sum of items in each group year wise
sum_num = tapply(allcargo_pl_long$Amount[allcargo_pl_long$ITEMS %in% num], allcargo_pl_long$Year[allcargo_pl_long$ITEMS %in% num], sum)
sum_den = tapply(alcargo_bs_long$Amount[alcargo_bs_long$Item %in% den], alcargo_bs_long$Year[alcargo_bs_long$Item %in% den], mean)

#Finding the ratio of sum in each group - year wise
trade_receivable_turnover_ratio <- sum_num / sum_den 

#creating dataframe
r1_ratio <- data.frame(
  Year = names(trade_receivable_turnover_ratio),
  Ratio = as.numeric(trade_receivable_turnover_ratio))

r1_ratio$Year <- as.numeric(r1_ratio$Year)

rp1_allcargo <- ggplot(r1_ratio, aes(x = Year, y = Ratio)) +
      geom_point(color = "black", size = 6) +
      geom_line(color = "blue", size =2) +
      labs(
    x = "Year",
    y = "Trade Receivable Turnover Ratio",
    title = "Trade Receivable Turnover Ratio Over Years")+
    geom_text(aes(label = round(Ratio,2)), vjust = -1, color = "black")+  # Display numbers above points
    scale_y_continuous(
    limits = c(0, 10),  # Set y-axis limits
    breaks = seq(0, 10, by =1), # Set the breaks on the y-axis
    labels = seq(0, 10,by =1))
## Warning: Using `size` aesthetic for lines was deprecated in ggplot2 3.4.0.
## ℹ Please use `linewidth` instead.
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.
#--------------------------------------------

#2 Fixed Asset turnover ratio
#Define groups from the items
nr <-  c("revfromopr_net")  
dr  <- c("FD_Asset")      

#Finding the sum of items in each group year wise
sum_nr = tapply(allcargo_pl_long$Amount[allcargo_pl_long$ITEMS %in% nr], allcargo_pl_long$Year[allcargo_pl_long$ITEMS %in% nr], sum)
sum_dr = tapply(alcargo_bs_long$Amount[alcargo_bs_long$Item %in% dr], alcargo_bs_long$Year[alcargo_bs_long$Item %in% dr], mean)

#Finding the ratio of sum in each group - year wise
fixed_asset_turnover_ratio <- sum_nr / sum_dr 

#creating dataframe
r2_ratio <- data.frame(
  Year = names(fixed_asset_turnover_ratio),
  Ratio = as.numeric(fixed_asset_turnover_ratio))

r2_ratio$Year <- as.numeric(r2_ratio$Year)

rp2_allcargo <- ggplot(r2_ratio, aes(x = Year, y = Ratio)) +
  geom_point(color = "black", size = 6) +
  geom_line(color = "blue", size =2) +
  labs(
    x = "Year",
    y = "Fixed Asset Turnover Ratio",
    title = "Fixed Asset Turnover Ratio Over Years")+
    geom_text(aes(label = round(Ratio,2)), vjust = -1, color = "black") +  # Display numbers above points
    scale_y_continuous(
    limits = c(0, 36),  # Set y-axis limits
    breaks = seq(0, 36, by =2), # Set the breaks on the y-axis
    labels = seq(0, 36,by =2))
#--------------------------------------------

#3 Total Asset turnover ratio
#Define groups from the items
nr1 <-  c("revfromopr_net")  
dr1  <- c("Tan_Asset","Intan_Asset","Cap_Work_In_Progress","Non_Curr_Invest","DeferredTaxAsset_Net","Lg_Tm_LoansAndAdvanc","Oth_Non_Curr_ Asset","Curr_Invest","Inventories","Trade_Receiva","CashAndCash_Equi","Sh_Tm_LoansAnd Advanc","Oth_Curr_Assets")      

#Finding the sum of items in each group year wise
sum_nr1 = tapply(allcargo_pl_long$Amount[allcargo_pl_long$ITEMS %in% nr1], allcargo_pl_long$Year[allcargo_pl_long$ITEMS %in% nr1], sum)
sum_dr1 = tapply(alcargo_bs_long$Amount[alcargo_bs_long$Item %in% dr1], alcargo_bs_long$Year[alcargo_bs_long$Item %in% dr1], sum)

#Finding the ratio of sum in each group - year wise#Finding the ratio of sum in each group - year wisesum
total_asset_turnover_ratio <- sum_nr1 / sum_dr1 

#creating dataframe
r3_ratio <- data.frame(
  Year = names(total_asset_turnover_ratio),
  Ratio = as.numeric(total_asset_turnover_ratio))

r3_ratio$Year <- as.numeric(r3_ratio$Year)

rp3_allcargo <- ggplot(r3_ratio, aes(x = Year, y = Ratio)) +
  geom_point(color = "black", size = 6) +
  geom_line(color = "blue", size =2) +
  labs(
    x = "Year",
    y = "Total Asset turnover ratio",
    title = "Total Asset turnover ratio Over Years")+
    geom_text(aes(label = round(Ratio,2)), vjust = -1, color = "black")+  # Display numbers above points
    scale_y_continuous(
    limits = c(0, 2),  # Set y-axis limits
    breaks = seq(0, 2, by =0.10), # Set the breaks on the y-axis
    labels = seq(0, 2,by =0.10))

Liquidity ratio

Liquidity ratios measure a company's ability to meet its short-term financial obligations, like paying bills or repaying loans, using its liquid assets—those that can be quickly converted to cash. These ratios show how financially healthy and stable a business is in the short run.
#--------------------------------------------
#4 Current ratio
#Define groups from the items
current_assets <- c("Curr_Invest","Inventories","Trade_Receiva","CashAndCash_Equi","Sh_Tm_LoansAnd Advanc","Oth_Curr_Assets")  
current_liabilities <- c("Sh_TM_Borrowings","Trade_Payables","Oth_CurR_Liab","Sh_Tm_Provi")      

#Finding the sum of items in each group year wise
sum_current_assets = tapply(alcargo_bs_long$Amount[alcargo_bs_long$Item %in% current_assets], alcargo_bs_long$Year[alcargo_bs_long$Item %in% current_assets], sum)
sum_current_liabilities = tapply(alcargo_bs_long$Amount[alcargo_bs_long$Item %in% current_liabilities], alcargo_bs_long$Year[alcargo_bs_long$Item %in% current_liabilities], sum)

#Finding the ratio of sum in each group - yearwise
current_ratio <- sum_current_assets / sum_current_liabilities

#creating dataframe
r4_ratio <- data.frame(
  Year = names(current_ratio),
  Ratio = as.numeric(current_ratio))

r4_ratio$Year <- as.numeric(r4_ratio$Year)

rp4_allcargo <- ggplot(r4_ratio, aes(x = Year, y = Ratio)) +
  geom_point(color = "black", size = 6) +
  geom_line(color = "blue", size =2) +
  labs(
    x = "Year",
    y = "Current ratio",
    title = "Current ratio for the years")+
    geom_text(aes(label = round(Ratio,2)), vjust = -1, color = "black")+  # Display numbers above points
    scale_y_continuous(
    limits = c(0, 2),  # Set y-axis limits
    breaks = seq(0, 2, by =0.10), # Set the breaks on the y-axis
    labels = seq(0, 2,by =0.10))

Current Ratio

Strengths:
1. In 2023, the ratio improved above parity, hinting at an instance where the company managed its working capital better.

Weaknesses:
1. The consistent trend of ratios near or below 1 in 2020, 2021, 2022, and again in 2024 signals a potential liquidity stress.
2. Low absolute levels of cash (for instance, only 19.63 in 2024 versus higher levels in earlier years) further underscore the risk that the firm might face short-term funding challenges.

#--------------------------------------------
#5 Quick Ratio== (cash+short-term Marketable Investment+ receivables) / current liabilities

allcargo_pl_longq_r<-data.frame(year = c(2020,2021,2022,2023,2024),
                                CashAndCash_Equi=c(48.38,41.06,76.71,82.4,19.63),
                                Curr_Invest=c(5.02,29.03,134.69,169.85,0),
                                Trade_Receiva=c(314.11,558,633.32,315.27,454.04),
                                tot_curr_liab=c(897.73,1223.54,1201.60,592.74,799.98))
#calculate cash and sh_t investment
allcargo_pl_longq_r$cash_and_sh_invest_rec <- allcargo_pl_longq_r$CashAndCash_Equi+allcargo_pl_longq_r$Curr_Invest+allcargo_pl_longq_r$Trade_Receiva
#calculate cash ratio
Quick_ratio <-(allcargo_pl_longq_r$cash_and_sh_invest_rec  / allcargo_pl_longq_r$tot_curr_liab)

# Create a dataframe for Quick Ratio
r5_allcargo_long<- data.frame(Year = allcargo_pl_longq_r$year, Ratio = Quick_ratio)

# Create ggplot for Quick Ratio
rp5_allcargo <- ggplot(r5_allcargo_long, aes(x = Year, y = Ratio)) +
  geom_point(color = "red", size = 5) +
  geom_line(aes(group = 1), color = "blue", linewidth = 2) +
  
  labs(x = "Year", y = "Quick Ratio",
       title = "Quick Ratio Over the Years",
       subtitle = "allcargo Logistics Limited (2020 - 2024)",
       caption = "Created by Pavan") +
    geom_text(aes(label = round(Ratio, 2)), vjust = -1, color = "black")+  # Display rounded values
    scale_y_continuous(
    limits = c(0, 1.5),  # Set y-axis limits
    breaks = seq(0, 1.5, by = 0.5),  # Set y-axis breaks
    labels = seq(0, 1.5, by = 0.5)  # Label y-axis
    
  )

# Print the plot
print(rp5_allcargo)

Quick Ratio

Strengths:

  1. Good Cash Management: The company maintains sufficient cash reserves and liquid assets, ensuring a strong quick ratio.

  2. Efficient Receivables Collection: Timely collection of accounts receivable supports quick liquidity management.

Weaknesses:

  1. Dependence on Inventory: If most current assets are tied up in inventory rather than cash or receivables, the quick ratio may suffer.

  2. Delayed Payments: Delays in receiving payments from clients could reduce the quick ratio and affect short-term liquidity.

#--------------------------------------------
#6 Cash ratio
#Cash Ratio = (cash+short-term Marketable Investment) / current liabilities
allcargo_pl_longc_r<-data.frame(year = c(2020,2021,2022,2023,2024),
                                CashAndCash_Equi=c(48.38,41.06,76.71,82.4,19.63),
                                Curr_Invest=c(5.02,29.03,134.69,169.85,0),
                                tot_curr_liab=c(897.73,1223.54,1201.60,592.74,799.98))
#calculate cash and sh_t investment
allcargo_pl_longc_r$cash_and_sh_investment <- allcargo_pl_longc_r$CashAndCash_Equi+allcargo_pl_longc_r$Curr_Invest
#calculate cash ratio
cash_ratio <- (allcargo_pl_longc_r$cash_and_sh_investment / allcargo_pl_longc_r$tot_curr_liab)

# Create a dataframe for Cash Ratio
r6_allcargo_long<- data.frame(Year = allcargo_pl_longq_r$year, Ratio = cash_ratio)

# Create ggplot for Cash Ratio
rp6_allcargo <- ggplot(r6_allcargo_long, aes(x = Year, y = Ratio)) +
  geom_point(color = "red", size = 5) +
  geom_line(aes(group = 1), color = "blue", linewidth = 2) +
  
  labs(x = "Year", y = "Cash Ratio",
       title = "Cash Ratio Over the Years",
       subtitle = "allcargo Logistics Limited (2020 - 2024)",
       caption = "Created by Pavan") +
     geom_text(aes(label = round(Ratio, 2)), vjust = -1, color = "black")+  # Display rounded values
     scale_y_continuous(
    limits = c(0, 0.5),  # Set y-axis limits
    breaks = seq(0, 0.5, by = 0.5),  # Set y-axis breaks
    labels = seq(0, 0.5, by = 0.5)  # Label y-axis
     )

# Print the plot
print(rp6_allcargo)

Cash Ratio

Strengths:

  1. A healthy cash ratio indicates that Allcargo Logistics maintains a sufficient cash reserve to cover its immediate liabilities, ensuring short-term financial stability.

  2. Effective cash management practices may allow the company to respond quickly to unexpected financial challenges or market opportunities.

Weaknesses:

  1. If the cash ratio is excessively high, it may suggest that Allcargo is not efficiently utilizing its cash for investments or growth opportunities.

  2. A low cash ratio would indicate potential liquidity concerns, meaning the company may struggle to meet its obligations if any unforeseen expenses arise.

SOLVENCY RATIO Solvency ratios measure a company’s ability to meet its long-term financial obligations and ensure it remains financially stable in the future. These ratios are important for evaluating a company’s financial health and its capacity to sustain operations over time.

#Debt Ratios

#--------------------------------------------
#7 Debt-to-Asset ratio
#Define groups from the items
total_debt <- c("Lg_TM_Borrowing","Sh_TM_Borrowings")       
total_asset <- c("Tan_Asset","Intan_Asset","Cap_Work_In_Progress","Non_Curr_Invest","DeferredTaxAsset_Net","Lg_Tm_LoansAndAdvanc","Oth_Non_Curr_ Asset","Curr_Invest","Inventories","Trade_Receiva","CashAndCash_Equi","Sh_Tm_LoansAnd Advanc","Oth_Curr_Assets")

#Finding the sum of items in each group year wise
sum_total_debt = tapply(alcargo_bs_long$Amount[alcargo_bs_long$Item %in% total_debt], alcargo_bs_long$Year[alcargo_bs_long$Item %in% total_debt], sum)
sum_total_asset = tapply(alcargo_bs_long$Amount[alcargo_bs_long$Item %in% total_asset], alcargo_bs_long$Year[alcargo_bs_long$Item %in% total_asset], sum)

#Finding the ratio of sum in each group - yearwise
debt_asset_ratio <-  sum_total_debt / sum_total_asset

#creating dataframe
r7_ratio <- (data.frame(Year=names(debt_asset_ratio),
           Ratio=unname(debt_asset_ratio)))

r7_ratio$Year <- as.numeric(r7_ratio$Year)

rp7_allcargo <- ggplot(r7_ratio, aes(x = Year, y = Ratio)) +
  geom_point(color = "black", size = 6) +
  geom_line(color = "blue", size =2) +
  labs(
    x = "Year",
    y = "Debt-to-asset ratio",
    title = "Debt-to-asset ratio for the years")+
  geom_text(aes(label = round(Ratio,2)), vjust = -1, color = "black") +  # Display numbers above points
    scale_y_continuous(
    limits = c(0, 0.5),  # Set y-axis limits
    breaks = seq(0, 0.5, by =0.10), # Set the breaks on the y-axis
    labels = seq(0, 0.5,by =0.10))

Strengths Summary: 1.The company maintains a moderate debt-to-asset ratio (under 50%), suggesting a balanced mix of debt and equity financing.
- This structure affords greater financial flexibility and lowers the risk associated with over-leverage.
2.A downward trend in the ratio, as seen in 2023, indicates a move toward a more conservative and potentially more stable capital structure.

Weaknesses Summary:
1. Despite being moderate, the existing levels of debt impose fixed financial obligations that could become problematic in adverse economic conditions.
2. The ratio is sensitive to shifts in asset values, meaning that any drop in the asset base could disproportionately affect the company’s solvency.
3. Some variability in the ratio implies potential inconsistencies in long-term asset or debt management strategies.

#--------------------------------------------
#8 Debt-to-Capital ratio
#Define groups from the items
total_debt <- c("Lg_TM_Borrowing","Sh_TM_Borrowings")       
total_capital <- c("Lg_TM_Borrowing","Sh_TM_Borrowings","Eq_ShareCap","ReserveandSurplus")

#Finding the sum of items in each group year wise
sum_total_debt = tapply(alcargo_bs_long$Amount[alcargo_bs_long$Item %in% total_debt], alcargo_bs_long$Year[alcargo_bs_long$Item %in% total_debt], sum)
sum_total_capital = tapply(alcargo_bs_long$Amount[alcargo_bs_long$Item %in% total_capital], alcargo_bs_long$Year[alcargo_bs_long$Item %in% total_capital], sum)

#Finding the ratio of sum in each group - yearwise
debt_capital_ratio <-  sum_total_debt / sum_total_capital

#creating dataframe
r8_ratio <- data.frame(
  Year = names(debt_capital_ratio),
  Ratio = as.numeric(debt_capital_ratio))

r8_ratio$Year <- as.numeric(r8_ratio$Year)

rp8_allcargo <- ggplot(r8_ratio, aes(x = Year, y = Ratio)) +
  geom_point(color = "black", size = 6) +
  geom_line(color = "blue", size =2) +
  labs(
    x = "Year",
    y = "Debt-to-Capital ratio",
  title = "Debt-to-Capital ratio")+
  geom_text(aes(label = round(Ratio,2)), vjust = -1, color = "black") +  # Display numbers above points
  scale_y_continuous(
  limits = c(0, 1),  # Set y-axis limits
  breaks = seq(0, 1, by =0.10), # Set the breaks on the y-axis
  labels = seq(0, 1,by =0.10))

Debt-to-Capital Ratio

Strengths:
1.Balanced Capital Structure: With debt-to-equity ratios well below 1 in many periods, the company is not over-leveraged. Equity financing accounts for roughly 51–58% of total assets.
2.Improved Interest Coverage: Noticeably, after a low point in 2020, the firm’s ability to cover its interest payments improved markedly in 2022 and 2023, signaling enhanced operational capacity to service debt.

Weaknesses:
1.Even though the overall gearing remains moderate, the substantial reliance on current liabilities (which appear relatively high compared to current assets) poses refinancing or rollover risks if market conditions tighten.

#--------------------------------------------
#9 Debt-to-equity ratio
#Define groups from the items
total_debt <- c("Lg_TM_Borrowing","Sh_TM_Borrowings")  
total_sh_equity  <- c("Eq_ShareCap","Bonus_Equ_Sh_Cap","Revaluation_Reserv","ReserveandSurplus")      


#Finding the sum of items in each group year wise
sum_total_debt = tapply(alcargo_bs_long$Amount[alcargo_bs_long$Item %in% total_debt], alcargo_bs_long$Year[alcargo_bs_long$Item %in% total_debt], sum)
sum_total_sh_equity = tapply(alcargo_bs_long$Amount[alcargo_bs_long$Item %in% total_sh_equity], alcargo_bs_long$Year[alcargo_bs_long$Item %in% total_sh_equity], sum)

#Finding the ratio of sum in each group - yearwise
debt_equity_ratio <- sum_total_debt / sum_total_sh_equity

#creating dataframe
r9_ratio <- data.frame(
  Year = names(debt_equity_ratio),
  Ratio = as.numeric(debt_equity_ratio))

r9_ratio$Year <- as.numeric(r9_ratio$Year)

rp9_allcargo <- ggplot(r9_ratio, aes(x = Year, y = Ratio)) +
  geom_point(color = "black", size = 6) +
  geom_line(color = "blue", size =2) +
  labs(
    x = "Year",
    y = "Debt-to-equity ratio",
    title = "Debt-to-equity ratio")+
  geom_text(aes(label = round(Ratio,2)), vjust = -1, color = "black") +  # Display numbers above points
  scale_y_continuous(
  limits = c(0, 1),  # Set y-axis limits
  breaks = seq(0, 1, by =0.10), # Set the breaks on the y-axis
  labels = seq(0, 1,by =0.10))

Debt-to-Equity Ratio

Strengths:

  1. Balanced Capital Structure: Allcargo Logistics has maintained a moderate debt-to-equity ratio, reflecting a balanced use of debt and equity to finance its operations. This ensures financial stability and growth.

  2. Leverage for Expansion: The company has strategically used debt to finance acquisitions and expand its global footprint. As a result, it has enhanced market presence while maintaining manageable debt levels.

Weaknesses:

  1. Although Allcargo has maintained a reasonable debt-to-equity ratio, further reliance on debt for future expansions could lead to increased financial risk.

  2. Rising interest rates could lead to higher interest expenses on the company’s existing debt, reducing profitability and overall financial flexibility.

#--------------------------------------------
#10 Financial Leverage
#Define groups from the items
avg_total_asset <- c("Tan_Asset","Intan_Asset","Cap_Work_In_Progress","Non_Curr_Invest","DeferredTaxAsset_Net","Lg_Tm_LoansAndAdvanc","Oth_Non_Curr_ Asset","Curr_Invest","Inventories","Trade_Receiva","CashAndCash_Equi","Sh_Tm_LoansAnd Advanc","Oth_Curr_Assets")       
avg_total_equity <- c("Eq_ShareCap","ReserveandSurplus")

#Finding the sum of items in each group year wise
sum_avg_total_asset = tapply(alcargo_bs_long$Amount[alcargo_bs_long$Item %in% avg_total_asset], alcargo_bs_long$Year[alcargo_bs_long$Item %in% avg_total_asset], sum)
sum_avg_total_equity = tapply(alcargo_bs_long$Amount[alcargo_bs_long$Item %in% avg_total_equity], alcargo_bs_long$Year[alcargo_bs_long$Item %in% avg_total_equity], sum)

#Finding the ratio of sum in each group - yearwise#Finding the ratio of sum in each group - yearwisesum
financial_leverage <-  sum_avg_total_asset / sum_avg_total_equity

#creating dataframe
r10_ratio <- data.frame(
  Year = names(financial_leverage),
  Ratio = as.numeric(financial_leverage))

r10_ratio$Year <- as.numeric(r10_ratio$Year)

rp10_allcargo <- ggplot(r10_ratio, aes(x = Year, y = Ratio)) +
  geom_point(color = "black", size = 6) +
  geom_line(color = "blue", size =2) +
  labs(
    x = "Year",
    y = "financial_leverage",
    title = "Financial Leverage")+
  geom_text(aes(label = round(Ratio,2)), vjust = -1, color = "black") +  # Display numbers above points
  scale_y_continuous(
  limits = c(1, 2),  # Set y-axis limits
  breaks = seq(1, 2, by =0.20), # Set the breaks on the y-axis
  labels = seq(1, 2,by =0.20))

Financial Leverage Strengths:

  1. The financial leverage ratio remains below 2.5, indicating that the company is not excessively relying on debt to finance assets.

  2. A decreasing trend (from 2.43 in 2020 to 1.81 in 2023) suggests the company is improving its equity base, reducing leverage risks.

Weaknesses:

  1. A slight increase in 2024 (from 1.81 in 2023 to 1.97) may indicate the company is taking on additional liabilities.

  2. If leverage increases beyond 2.5, it could signal over-reliance on borrowed funds, raising the risk of financial distress.

#Profitability Ratios

#OPERATING PROFIT MARGIN = OPERATING PROFIT/REVENUE FROM OPERATION)*100 
#11 OPERATING PROFIT = Total operating Revenue-(operating and direct expenses+Employee Benefit Expenses+depreciation+other operating cost)
allcargo_pl_long<-data.frame(year = c(2020,2021,2022,2023,2024),
                             Total_operating_revenue=c(1619.31, 1970.43, 3432.62, 2721.84, 1633.29),
                             Opr_and_dir_Exp=c(1184.83, 1534.15, 2876.27, 2310.44, 1368.54),
                             EmployeeBenefitExp=c(133.42, 127.74, 153.18, 156.15, 121.47),
                             DepAndAmortExp=c(115.05, 102.47, 90.11, 15.83, 19.15),
                             OtherExp=c(126.45, 126.45, 140.04, 93.92, 103.11))
#calculate operating profit 
allcargo_pl_long$operating_profit <- allcargo_pl_long$Total_operating_revenue-(allcargo_pl_long$Opr_and_dir_Exp
                                                                               +allcargo_pl_long$EmployeeBenefitExp
                                                                               +allcargo_pl_long$DepAndAmortExp
                                                                               +allcargo_pl_long$OtherExp)


#calculate operating profit margin
operating_pr_margin <- (allcargo_pl_long$operating_profit / allcargo_pl_long$Total_operating_revenue) * 100


# Create a dataframe for Opr pr margin Ratio
r11_allcargo_long<- data.frame(Year = allcargo_pl_longq_r$year, Ratio = operating_pr_margin)

# Create ggplot for Opr pr margin Ratio
rp11_allcargo <- ggplot(r11_allcargo_long, aes(x = Year, y = Ratio)) +
  geom_point(color = "red", size = 5) +
  geom_line(aes(group = 1), color = "blue", linewidth = 2) +
  
  labs(x = "Year", y = "OPERATING PROFIT MARGIN",
       title = "OPERATING PROFIT MARGIN Over the Years",
       subtitle = "allcargo Logistics Limited (2020 - 2024)",
       caption = "Created by Pavan") +
    geom_text(aes(label = round(Ratio, 2)), vjust = -1, color = "black") +  # Display rounded values
    scale_y_continuous(
    limits = c(0, 6),  # Set y-axis limits
    breaks = seq(0, 6, by = 1),  # Set y-axis breaks
    labels = seq(0, 6, by = 1)  # Label y-axis
    
  )

# Print the plot
print(rp11_allcargo)

Strengths: 1.Consistent Profitability: Operating profits remain positive throughout, and ROE shows that capital employed is generating respectable returns in some years exceeding average.
2.Operating Efficiency Improvements: The substantial improvement in operational efficiency improved considerably.

Weaknesses:
1.Margin Volatility: The fluctuation in operating profit margins indicates that earnings can be inconsistent, potentially tied to factors such as cost variability, temporary accounting adjustments (e.g., depreciation), or market-driven revenue pressures.
2.Earnings Stability Concerns: While profitability is evident, the apparent volatility in margins and periodic dips in ROE may signal vulnerabilities if cost pressures or revenue declines recur.

#VRL LOGISTICS

RATIOS CALCULATION #Activity ratio Activity ratios measure how effectively a company uses its assets and resources to operate and generate revenue. These ratios help businesses evaluate their efficiency in managing assets like inventory, receivables, and fixed assets. They act as indicators of how “busy” or “productive” the business is in using what it owns.

#Calculation of Trade receivable Turnover ratio
#Define groups from the items
num <-  c("revfromopr_net")  
den  <- c("Trade_Receiva")      

#Finding the sum of items in each group year wise
sum_num = tapply(vrl_pl_long$Amount[vrl_pl_long$ITEMS %in% num], vrl_pl_long$Year[vrl_pl_long$ITEMS %in% num], sum)
sum_den = tapply(vrl_bs_long$Amount[vrl_bs_long$Item %in% den], vrl_bs_long$Year[vrl_bs_long$Item %in% den], mean)

#Finding the ratio of sum in each group - year wise
trade_receivable_turnover_ratio <- sum_num / sum_den 

#creating dataframe
r1_ratio <- data.frame(
  Year = names(trade_receivable_turnover_ratio),
  Ratio = as.numeric(trade_receivable_turnover_ratio))

r1_ratio$Year <- as.numeric(r1_ratio$Year)

rp1_vrl <- ggplot(r1_ratio, aes(x = Year, y = Ratio)) +
      geom_point(color = "black", size = 6) +
      geom_line(color = "blue", size =2) +
      geom_text(aes(label = round(Ratio,2)), vjust = -1, color = "black") +  # Display numbers above points
      labs(
    x = "Year",
    y = "Trade Receivable Turnover Ratio",
    title = "Trade Receivable Turnover Ratio Over Years"
  ) +scale_y_continuous(
    limits = c(0, 50),  # Set y-axis limits
    breaks = seq(0, 50, by =10), # Set the breaks on the y-axis
    labels = seq(0, 50,by =10))
grid.arrange(rp1_allcargo, rp1_vrl, ncol = 2)

# calculation of Fixed Turnover Ratio
#Define groups from the items
nr <-  c("revfromopr_net")  
dr  <- c("FD_Asset")   

#Finding the sum of items in each group year wise
sum_nr = tapply(vrl_pl_long$Amount[vrl_pl_long$ITEMS %in% nr], vrl_pl_long$Year[vrl_pl_long$ITEMS %in% nr], sum)
sum_dr = tapply(vrl_bs_long$Amount[vrl_bs_long$Item %in% dr], vrl_bs_long$Year[vrl_bs_long$Item %in% dr], mean)

#Finding the ratio of sum in each group - year wise
fixed_asset_turnover_ratio <- sum_nr / sum_dr 

#creating dataframe
r2 = data.frame(Year=names(fixed_asset_turnover_ratio),
                Ratio=unname(fixed_asset_turnover_ratio))

#plot for ratio

rp2_vrl=ggplot(r2,aes(x=Year,y=Ratio))+
  geom_point(col="red",size=5)+
  geom_line(aes(x=Year,Ratio, group=1),
            col="blue",
            linewidth=2)+
  geom_text(aes(label = round(Ratio, 2)), vjust = -1, color = "black")+  # Rounds to 2 decimal places+  # Display numbers above points
  
  labs(x="Year",y="Fixed Turnover Ratio",
       title=" Fixed Turnover Ratio Over year",
       caption = "Created by Team Logistics",
       subtitle="vrl logistics limited (2020 - 2024)")+
  geom_text(aes(label = round(Ratio, 2)), vjust = -1, color = "black")+
  scale_y_continuous(
    limits = c(0, 3),  # Set y-axis limits
    breaks = seq(0, 3, by = 0.5),  # Set the breaks on the y-axis
    labels = seq(0, 3, by = 0.5))  # Label the y-axis with values from 100 to 500
     grid.arrange(rp2_vrl)

grid.arrange(rp2_allcargo, rp2_vrl, ncol=2)

#----------------------------------------
# Calculation of Total asset turnover
#Define groups from the items
nr1 <-  c("revfromopr_net")  
dr1  <- c("Tan_Asset","Intan_Asset","Cap_Work_In_Progress","Non_Curr_Invest","DeferredTaxAsset_Net","Lg_Tm_LoansAndAdvanc","Oth_Non_Curr_ Asset","Curr_Invest","Inventories","Trade_Receiva","CashAndCash_Equi","Sh_Tm_LoansAnd Advanc","Oth_Curr_Assets")      

#Finding the sum of items in each group year wise
sum_nr1 = tapply(vrl_pl_long$Amount[vrl_pl_long$ITEMS %in% nr1], vrl_pl_long$Year[vrl_pl_long$ITEMS %in% nr1], sum)
sum_dr1 = tapply(vrl_bs_long$Amount[vrl_bs_long$Item %in% dr1], vrl_bs_long$Year[vrl_bs_long$Item %in% dr1], sum)

#Finding the ratio of sum in each group - year wise#Finding the ratio of sum in each group - year wisesum
total_asset_turnover_ratio <- sum_nr1 / sum_dr1 

#creating dataframe
r3 = data.frame(Year=names(total_asset_turnover_ratio),
                Ratio=unname(total_asset_turnover_ratio))

rp3_vrl=ggplot(r3,aes(x=Year,y=Ratio))+
  geom_point(col="red",size=5)+
  geom_line(aes(x=Year,Ratio, group=1),
            col="blue",
            linewidth=2)+
   # Rounds to 2 decimal places+  # Display numbers above points
  
  labs(x="Year",y="Total asset turnover",
       title="Total asset turnover Over year",
       caption = "Created by Team Logistics",
       subtitle="vrl logistics limited (2020 - 2024)")+
  geom_text(aes(label = round(Ratio, 2)), vjust = -1, color = "black")+ # Rounds to 2 decimal places+  # Display numbers above points
  
  scale_y_continuous(
    limits = c(0, 3),  # Set y-axis limits
    breaks = seq(0, 3, by = 0.5),  # Set the breaks on the y-axis
    labels = seq(0, 3, by = 0.5))  # Label the y-axis with values from 100 to 500
    

 grid.arrange(rp3_vrl)

grid.arrange(rp3_allcargo, rp3_vrl, ncol = 2)

Liquidity ratio Liquidity ratios measure a company’s ability to meet its short-term financial obligations, like paying bills or repaying loans, using its liquid assets—those that can be quickly converted to cash. These ratios show how financially healthy and stable a business is in the short run.

#Calculating current ratio
#Define groups from the items
current_assets <- c("Curr_Invest","Inventories","Trade_Receiva","CashAndCash_Equi","Sh_Tm_LoansAnd Advanc","Oth_Curr_Assets")  
current_liabilities <- c("Sh_TM_Borrowings","Trade_Payables","Oth_CurR_Liab","Sh_Tm_Provi")      

#Finding the sum of items in each group year wise
sum_current_assets = tapply(vrl_bs_long$Amount[vrl_bs_long$Item %in% current_assets], vrl_bs_long$Year[vrl_bs_long$Item %in% current_assets], sum)
sum_current_liabilities = tapply(vrl_bs_long$Amount[vrl_bs_long$Item %in% current_liabilities], vrl_bs_long$Year[vrl_bs_long$Item %in% current_liabilities], sum)

#Finding the ratio of sum in each group - yearwise
current_ratio <- sum_current_assets / sum_current_liabilities

#creating dataframe
r4_ratio <- data.frame(
  Year = names(current_ratio),
  Ratio = as.numeric(current_ratio))

r4_ratio$Year <- as.numeric(r4_ratio$Year)
r4_ratio <- data.frame(
  Year = names(current_ratio),
  Ratio = as.numeric(current_ratio))

r4_ratio$Year <- as.numeric(r4_ratio$Year)

r4 = data.frame(Year=names(current_ratio),
                Ratio=unname(current_ratio))

rp4_vrl=ggplot(r4,aes(x=Year,y=Ratio))+
  geom_point(col="red",size=5)+
  geom_line(aes(x=Year,Ratio, group=1),
            col="blue",
            linewidth=2)+
   labs(x="Year",y="current ratio",
       title="current ratio Over year",
       caption = "Created by Team Logistics",
       subtitle="vrl logistics limited (2020 - 2024)")+
  geom_text(aes(label = round(Ratio, 2)), vjust = -1, color = "black")+  # Rounds to 2 decimal places+  # Display numbers above points
  scale_y_continuous(
    limits = c(0, 3),  # Set y-axis limits
    breaks = seq(0, 3, by = 0.5),  # Set the breaks on the y-axis
    labels = seq(0, 3, by = 0.5))  # Label the y-axis with values from 100 to 500

 grid.arrange(rp4_vrl)

grid.arrange(rp4_allcargo, rp4_vrl, ncol = 2)

#Calculation of Quick Ratio== (cash+short-term Marketable Investment+ receivables) / current liabilities
vrl_pl_longq_r<-data.frame(year = c(2020,2021,2022,2023,2024),
                           CashAndCash_Equi=c(13.41,18.45,14.49,75.24,18.95),
                           Curr_Invest=c(0,0,0,15.02,0),
                           Trade_Receiva=c(85.63,63.94,67.26,81.69,88.49),
                           tot_curr_liab=c(355.45,342.87,463.48,609.73,881.72))

#calculate cash and sh_t investment
vrl_pl_longq_r$cash_and_sh_invest_rec <- vrl_pl_longq_r$CashAndCash_Equi+vrl_pl_longq_r$Curr_Invest+vrl_pl_longq_r$Trade_Receiva


#calculate cash ratio
Quick_ratio <-(vrl_pl_longq_r$cash_and_sh_invest_rec  / vrl_pl_longq_r$tot_curr_liab)

# Create a dataframe for Quick Ratio
r5_vrl_long<- data.frame(Year = vrl_pl_longq_r$year, Ratio = Quick_ratio)

# Create ggplot for Quick Ratio
rp5_vrl <- ggplot(r5_vrl_long, aes(x = Year, y = Ratio)) +
  geom_point(color = "red", size = 5) +
  geom_line(aes(group = 1), color = "blue", linewidth = 2) +
  labs(x = "Year", y = "Quick Ratio",
       title = "Quick Ratio Over the Years",
       subtitle = "VRL Logistics Limited (2020 - 2024)",
       caption = "Created by Team Logistics") +
  geom_text(aes(label = round(Ratio, 2)), vjust = -1, color = "black") +  # Display rounded values
  scale_y_continuous(
    limits = c(0, 1),  # Set y-axis limits
    breaks = seq(0, 1, by = 0.2),  # Set y-axis breaks
    labels = seq(0, 1, by = 0.2))

# Print the plot

 grid.arrange(rp5_vrl)

grid.arrange(rp5_allcargo, rp5_vrl, ncol = 2)

#----------------------------------------


#Calculation of Quick Ratio== (cash+short-term Marketable Investment+ receivables) / current liabilities
vrl_pl_longq_r<-data.frame(year = c(2020,2021,2022,2023,2024),
                           CashAndCash_Equi=c(13.41,18.45,14.49,75.24,18.95),
                           Curr_Invest=c(0,0,0,15.02,0),
                           Trade_Receiva=c(85.63,63.94,67.26,81.69,88.49),
                           tot_curr_liab=c(355.45,342.87,463.48,609.73,881.72))

#calculate cash and sh_t investment
vrl_pl_longq_r$cash_and_sh_invest_rec <- vrl_pl_longq_r$CashAndCash_Equi+vrl_pl_longq_r$Curr_Invest+vrl_pl_longq_r$Trade_Receiva


#calculate cash ratio
Quick_ratio <-(vrl_pl_longq_r$cash_and_sh_invest_rec  / vrl_pl_longq_r$tot_curr_liab)

# Create a dataframe for Quick Ratio
r6_vrl_long<- data.frame(Year = vrl_pl_longq_r$year, Ratio = Quick_ratio)

# Create ggplot for Quick Ratio
rp6_vrl <- ggplot(r6_vrl_long, aes(x = Year, y = Ratio)) +
  geom_point(color = "red", size = 5) +
  geom_line(aes(group = 1), color = "blue", linewidth = 2) +
  labs(x = "Year", y = "Cash Ratio",
       title = "Cash Ratio Over the Years",
       subtitle = "VRL Logistics Limited (2020 - 2024)",
       caption = "Created by Team Logistics") +
  geom_text(aes(label = round(Ratio, 2)), vjust = -1, color = "black") +  # Display rounded values
  scale_y_continuous(
    limits = c(0, 1),  # Set y-axis limits
    breaks = seq(0, 1, by = 0.2),  # Set y-axis breaks
    labels = seq(0, 1, by = 0.2))
 grid.arrange(rp6_allcargo, rp6_vrl, ncol = 2)

SOLVENCY RATIO Solvency ratios measure a company’s ability to meet its long-term financial obligations and ensure it remains financially stable in the future. These ratios are important for evaluating a company’s financial health and its capacity to sustain operations over time.

 #----------------------------------------

# Calculation of Debt-Equity-ratio
# Define groups from the items
total_debt <- c("Lg_TM_Borrowing","Sh_TM_Borrowings")  
total_sh_equity  <- c("Eq_ShareCap","Bonus_Equ_Sh_Cap","Revaluation_Reserv","ReserveandSurplus")      

#Finding the sum of items in each group year wise
sum_total_debt = tapply(vrl_bs_long$Amount[vrl_bs_long$Item %in% total_debt], vrl_bs_long$Year[vrl_bs_long$Item %in% total_debt], sum)
sum_total_sh_equity = tapply(vrl_bs_long$Amount[vrl_bs_long$Item %in% total_sh_equity], vrl_bs_long$Year[vrl_bs_long$Item %in% total_sh_equity], sum)

#Finding the ratio of sum in each group - yearwise
debt_equity_ratio <- sum_total_debt / sum_total_sh_equity

#creating dataframe
r7=data.frame(Year=names(debt_equity_ratio),
              Ratio=unname(debt_equity_ratio))

rp7_vrl=ggplot(r7,aes(x=Year,y=Ratio))+
  geom_point(col="red",size=5)+
  geom_line(aes(x=Year,Ratio, group=1),
            col="blue",
            linewidth=2)+
 labs(x="Year",y="Debt-Equity-ratio",
       title="Debt-Equity-ratio Over year",
       caption = "Created by Team Logistics",
       subtitle="vrl logistics limited (2020 - 2024)")+
  geom_text(aes(label = round(Ratio, 2)), vjust = -1, color = "black")+  # Rounds to 2 decimal places+  # Display numbers above points
  scale_y_continuous(
    limits = c(0, 1),  # Set y-axis limits
    breaks = seq(0, 1, by = 0.2),  # Set the breaks on the y-axis
    labels = seq(0, 1, by = 0.2))  # Label the y-axis with values from 100 to 500
      grid.arrange(rp7_vrl)

grid.arrange(rp9_allcargo, rp7_vrl, ncol = 2)

#--------------------------------------------

#Calculation of Debt-asset Turnover Ratio
# Define groups from the items
total_debt <- c("Lg_TM_Borrowing","Sh_TM_Borrowings")       
total_asset <- c("Tan_Asset","Intan_Asset","Cap_Work_In_Progress","Non_Curr_Invest","DeferredTaxAsset_Net","Lg_Tm_LoansAndAdvanc","Oth_Non_Curr_ Asset","Curr_Invest","Inventories","Trade_Receiva","CashAndCash_Equi","Sh_Tm_LoansAnd Advanc","Oth_Curr_Assets")

#Finding the sum of items in each group year wise
sum_total_debt = tapply(vrl_bs_long$Amount[vrl_bs_long$Item %in% total_debt], vrl_bs_long$Year[vrl_bs_long$Item %in% total_debt], sum)
sum_total_asset = tapply(vrl_bs_long$Amount[vrl_bs_long$Item %in% total_asset], vrl_bs_long$Year[vrl_bs_long$Item %in% total_asset], sum)

#Finding the ratio of sum in each group - yearwise
debt_asset_ratio <-  sum_total_debt / sum_total_asset

#creating dataframe
r8 =  data.frame(Year=names(debt_asset_ratio),
                Ratio=unname(debt_asset_ratio))
#plot for ratio
rp8_vrl=ggplot(r8,aes(x=Year,y=Ratio))+
  geom_point(col="red",size=5)+
  geom_line(aes(x=Year,Ratio, group=1),
            col="blue",
            linewidth=2)+
 labs(x="Year",y="Debt-asset Turnover Ratio",
       title="Debt-asset Turnover Ratio Over year",
       caption = "Created by Team Logistics",
       subtitle="vrl logistics limited (2020 - 2024)")+
  geom_text(aes(label = round(Ratio, 2)), vjust = -1, color = "black")+  # Rounds to 2 decimal places+  # Display numbers above points
  scale_y_continuous(
    limits = c(0, 1),  # Set y-axis limits
    breaks = seq(0, 1, by = 0.2),  # Set the breaks on the y-axis
    labels = seq(0, 1, by = 0.2))  # Label the y-axis with values from 100 to 500
grid.arrange(rp7_allcargo, rp8_vrl, ncol = 2)

#--------------------------------------------

#Calculation of Debt-Capital Turnover Ratio
# Define groups from the items
total_debt <- c("Lg_TM_Borrowing","Sh_TM_Borrowings")       
total_asset <- c("Tan_Asset","Intan_Asset","Cap_Work_In_Progress","Non_Curr_Invest","DeferredTaxAsset_Net","Lg_Tm_LoansAndAdvanc","Oth_Non_Curr_ Asset","Curr_Invest","Inventories","Trade_Receiva","CashAndCash_Equi","Sh_Tm_LoansAnd Advanc","Oth_Curr_Assets")

#Finding the sum of items in each group year wise
sum_total_debt = tapply(vrl_bs_long$Amount[vrl_bs_long$Item %in% total_debt], vrl_bs_long$Year[vrl_bs_long$Item %in% total_debt], sum)
sum_total_asset = tapply(vrl_bs_long$Amount[vrl_bs_long$Item %in% total_asset], vrl_bs_long$Year[vrl_bs_long$Item %in% total_asset], sum)

#Finding the ratio of sum in each group - yearwise
debt_asset_ratio <-  sum_total_debt / sum_total_asset

#creating dataframe
r9 = data.frame(Year=names(debt_asset_ratio),
                Ratio=unname(debt_asset_ratio))

#plot for ratio
rp9_vrl=ggplot(r9,aes(x=Year,y=Ratio))+
  geom_point(col="red",size=5)+
  geom_line(aes(x=Year,Ratio, group=1),
            col="blue",
            linewidth=2)+
  geom_text(aes(label = round(Ratio, 2)), vjust = -1, color = "black")+  # Rounds to 2 decimal places+  # Display numbers above points
  labs(x="Year",y=" Debt-Capital Turnover Ratio",
       title=" Debt-Capital Turnover Ratio Over year",
       caption = "Created by Team Logistics",
       subtitle="vrl logistics limited (2020 - 2024)")+
  geom_text(aes(label = round(Ratio, 2)), vjust = -1, color = "black")+  # Rounds to 2 decimal places+  # Display numbers above points
  scale_y_continuous(
    limits = c(0, 1),  # Set y-axis limits
    breaks = seq(0, 1, by = 0.2),  # Set the breaks on the y-axis
    labels = seq(0, 1, by = 0.2))  # Label the y-axis with values from 100 to 500
grid.arrange(rp8_allcargo, rp9_vrl, ncol = 2)

#--------------------------------------------

#Calculation of Financial Leverage Ratio
# Define groups from the items
avg_total_asset <- c("Tan_Asset","Intan_Asset","Cap_Work_In_Progress","Non_Curr_Invest","DeferredTaxAsset_Net","Lg_Tm_LoansAndAdvanc","Oth_Non_Curr_ Asset","Curr_Invest","Inventories","Trade_Receiva","CashAndCash_Equi","Sh_Tm_LoansAnd Advanc","Oth_Curr_Assets")       
avg_total_equity <- c("Eq_ShareCap","ReserveandSurplus")

#Finding the sum of items in each group year wise
sum_avg_total_asset = tapply(vrl_bs_long$Amount[vrl_bs_long$Item %in% avg_total_asset], vrl_bs_long$Year[vrl_bs_long$Item %in% avg_total_asset], sum)
sum_avg_total_equity = tapply(vrl_bs_long$Amount[vrl_bs_long$Item %in% avg_total_equity], vrl_bs_long$Year[vrl_bs_long$Item %in% avg_total_equity], sum)

#Finding the ratio of sum in each group - yearwise#Finding the ratio of sum in each group - yearwisesum
financial_leverage <-  sum_avg_total_asset / sum_avg_total_equity

#creating dataframe
r10 = data.frame(Year=names(financial_leverage),
                 Ratio=unname(financial_leverage))
#plot of ratio
rp10_vrl=ggplot(r10,aes(x=Year,y=Ratio))+
  geom_point(col="red",size=5)+
  geom_line(aes(x=Year,Ratio, group=1),
            col="blue",
            linewidth=2)+
  labs(x="Year",y=" Financial Leverage Ratio",
       title=" Financial Leverage Ratio Over year",
       caption = "Created by Team Logistics",
       subtitle="vrl logistics limited (2020 - 2024)")+
  geom_text(aes(label = round(Ratio, 2)), vjust = -1, color = "black")+  # Rounds to 2 decimal places+  # Display numbers above points
   scale_y_continuous(
    limits = c(0, 3),  # Set y-axis limits
    breaks = seq(0, 3, by = 0.5),  # Set the breaks on the y-axis
    labels = seq(0, 3, by = 0.5))  # Label the y-axis with values from 100 to 500
grid.arrange(rp10_allcargo, rp10_vrl, ncol = 2)

PROFITABILITY RATIO Profitability ratios assess how well a company generates profit relative to its revenue, assets, or equity. These ratios are crucial for determining a company’s ability to make money and evaluating its overall financial success.

#calcualtion of operating profit margin
# Define groups from the items
#OPERATING PROFIT MARGIN = OPERATING PROFIT/REVENUE FROM OPERATION)*100 
#OPERATING PROFIT = Total operating Revenue-(operating and direct expenses+Employee Benefit Expenses+depreciation+other operating cost)
vrl_pl_long<-data.frame(year = c(2020,2021,2022,2023,2024),
                        Total_operating_revenue=c(2118.54,1762.92,2393.65,2648.52,2888.62),
                        Opr_and_dir_Exp=c(1410.20,1181.75,1591.65,1799.03,1966.75),
                        EmployeeBenefitExp=c(380.51,314.66,372.02,414.85,485.13),
                        DepAndAmortExp=c(167.53,159.79,168,159.14,216.16),
                        OtherExp=c(29.56,19.03,25.81,32.99,43.29))

#calculate operating profit 
vrl_pl_long$operating_profit <- vrl_pl_long$Total_operating_revenue-(vrl_pl_long$Opr_and_dir_Exp
                                                                     +vrl_pl_long$EmployeeBenefitExp
                                                                     +vrl_pl_long$DepAndAmortExp
                                                                     +vrl_pl_long$OtherExp)
#calculate operating profit margin
operating_profit_margin <- (vrl_pl_long$operating_profit / vrl_pl_long$Total_operating_revenue) *100

#view results
print(vrl_pl_long)
##   year Total_operating_revenue Opr_and_dir_Exp EmployeeBenefitExp
## 1 2020                 2118.54         1410.20             380.51
## 2 2021                 1762.92         1181.75             314.66
## 3 2022                 2393.65         1591.65             372.02
## 4 2023                 2648.52         1799.03             414.85
## 5 2024                 2888.62         1966.75             485.13
##   DepAndAmortExp OtherExp operating_profit
## 1         167.53    29.56           130.74
## 2         159.79    19.03            87.69
## 3         168.00    25.81           236.17
## 4         159.14    32.99           242.51
## 5         216.16    43.29           177.29
#Create a dataframe for operating profit margin 
r11_vrl_long<- data.frame(Year = vrl_pl_longq_r$year, Ratio =operating_profit_margin )

# Create ggplot for operating profit margin
rp11_vrl <- ggplot(r11_vrl_long, aes(x = Year, y = Ratio)) +
  geom_point(color = "blue", size = 5) +
  geom_line(aes(group = 1), color = "yellow", linewidth = 2) +
  labs(x = "Year", y = "OPERATING PROFIT MARGIN",
       title = "OPERATING PROFIT MARGIN Over the Years",
       subtitle = "VRL Logistics Limited (2020 - 2024)",
       caption = "Created by Team Logistics") +
  geom_text(aes(label = round(Ratio, 2)), vjust = -1, color = "red") +  # Display rounded values
  scale_y_continuous(
    limits = c(0, 10),  # Set y-axis limits
    breaks = seq(0, 10, by = 2),  # Set y-axis breaks
    labels = seq(0, 10, by = 2) )

# Print the plot

 grid.arrange(rp11_vrl)

grid.arrange(rp11_allcargo, rp11_vrl, ncol = 2)