#' Return a new value within plus of minus delta percent of the initial value, adjusting roundings based on the initial magnitude.
#' @param amount Numeric. Value of the sales.
#' @param date Date. Date of the sale
#' @param vat Numeric. Percentage of VAT (assumed included in the amount).
#' @param dso Integer. Number of Days Sales Outstanding.
#' @return A dataframe with accounting entries for the transaction.
#' @export
record_sales <- function(amount,
date,
vat,
dso){
revenues <- round(amount / (1 + vat),2)
vatamt <- amount - revenues
newdate <- date+dso
sale <- data.frame(
date = c(date ,date ,date ,newdate,newdate),
account = c("accounts_receivable","revenues","payable_vat","cash","accounts_receivable"),
debit = c(amount ,NA ,NA ,amount,NA),
credit = c(NA ,revenues ,vatamt ,NA ,amount)
)
return(sale)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.