Accounting: Equipment Debt Schedule and bank Draw - accounting

If a company is paying off an equipment debt schedule with more $ than they owe on the balance sheet . What happens with the accounting entry ?
For Example: Cash: DR 400 (a) Cr 400 (c)
Debt Schedule: DR:300 (B) CR:300 (c)
Debt/Bank: 400 (a)
A. Draw from Bank on equipment line for $400
B. Balance sheet value of $300
C. C. Debt schedule payoff $400 . What happens to the $100

When you use the money form the line credit to purchase the equipment it will be recorded as either
Dr. Cash XXXX.XX
Cr. LOC XXXX.XX
Dr. Equipment XXXX.XX
Cr. Cash XXXX.XX
or if paid directly to the vendor from the LOC
Dr. Equipment XXXX.XX
Cr. LOC XXXX.XX
When you pay off the LOC any additional amount paid would go to interest expense.
Dr.LOC XXXX.XX
Dr.Interest Exp XX.XX
Cr.Cash XXXX.XX
Cr.Cash XX.XX

Related

Product recommendation cypher

I have the following simple graph -
I wish to build a simple recommendation system on the basis of the following example:
Consider that we have invoice 1 with an Article "Apple".
We also have invoice 2 which has "Apple" and "Oranges".
Customer of invoice 1 should be recommended "Oranges".
Basically, When a customer adds an item to an invoice, we need to recommend articles that were added to another invoice with at least one of its article in the current invoice. And the recommended article not in the current invoice.
Another way to say this -
When an article A exists in Invoice 1 AND Invoice 2 also contains article A, then list all other articles in Invoice 2 provided they do not exist in Invoice 1.
However, as a complete beginner I'm unable to figure out how to write the cypher query. Any help on how to write such a query?
Something like below should work to start with:
MATCH (i:Invoice)-[]-(a:Article)-[]-(:Invoice)-[]-(b:Article)
WHERE i.invoiceNumber = 123
RETURN b;
What is does is - start from the invoice, then navigate through the articles connected to that invoice, onto other invoices (all other invoices that share this article). From there it collects all the articles connected to those invoices.
(this assumes that you are using unique Articlenodes and connecting the invoices to them)
You can use below query for a given Customer (let say Customer1), give me other customers and recommended food based on any food that Customer1 ordered and common to other customers.
MATCH (c1:Customer {name: 'Customer1'})<-[:GENERATED_FOR]-(:Invoice)<-[:ITEMIZED_IN]-(:Article)-[:TYPE]->(f:FoodArticle)
WITH c1, collect(f) as food
MATCH (c2:Customer)<-[:GENERATED_FOR]-(:Invoice)<-[:ITEMIZED_IN]-(:Article)-[:TYPE]->(f2:FoodArticle)
WHERE c1 <> c2 AND f2 in food
WITH c2, food, collect(f2) as food2
WITH c2, [fd IN food WHERE NOT fd IN food2] as recommendations
WHERE size(recommendations) > 0
RETURN c2.name, recommendations
First, get all food that customer1 has ordered
Next, find all customers that has at least one food contained in Customer1's food
List out customer2 and collect all food for this customer2
Create a list of recommended food based on those found in customer1 food list BUT NOT found in customer2 food list
Return customer2 name and recommended food but ensure that there is at least one food in Customer1 list that is not found in customer2 list (food2)

SQL - Order records by the closest value

I have created one API for product details
In this API I also need to attach similar products in response.
So for similar products scenario are like following
1) Price wise (+10 and -10)
2) Then after category wise (From same category)
e.g.
I have product with id #30 and price with $30 and category with "beer"
SO the similar products listing will be like following
First show all products beer category products which are come between range +10 and -10 of $30 (I mean b/w range 20 to 40)
Then after attach other products which are belongs from same category "beer" with closest price of $30
Suppose products price with same category are following
$10, $17, $45, $42, $50
so the products will sort as following as closet to $30
$42 ($42 - $30 = 12), $17 ($30 - $17 = 13), $45 ($45 - $30 = $15), $10 ($30 - $10 = $20), $50 ($50 - $30 = $20)
for similar products in +10 -10 range i created below query
similar_price = Product.includes(:sub_category, :brand, :product_type, :category).in_stock.where("(actual_price BETWEEN ? AND ? AND category_id = ? ) ", min_price, max_price, self.category_id)
now i need to order products with closest price.
How can fix this issue with postgres query in rails ?
Yes you can perform this operation by using just simple order query as like following
`Product.where("product.category_id = ?", "category_id").order("abs(products.price - #{your_selected_product_price})")`
The previous answer is dangerous to use if the price comes from untrusted user input, since it allows SQL injection. It also breaks if price can be nil.
The solution is to properly quote the price for the given column:
class Product < ActiveRecord::Base
scope :closest_by_price, ->(price) {
quoted_price = connection.quote(price, columns_hash["price"])
order("abs(products.price - #{quoted_price})")
}
end
Product.closest_by_price(50.0)

Return one of each value Parse.com Query

I have a class Event. Each Event has an EventParent, and an EventName.
What I am looking to do is write a query that returns each unique EventParent once.
EventParent| EventName
NY Sports | MSG
NY Sports | Barclays
CA Sports | Staples Center
CA Sports | Oracle Arena
In the above example, I'd like to get NY Sports and CA Sports as my result. What is the best way to do this using a Parse query?

How to create a dimensional model with different metrics depending of the hierarchical level

I need to create a dimensional environment for sales analysis for a retail company.
The hierarchy that will be present in my Sales fact is:
1 - Country
1.1 - Region
1.1.1 - State
1.1.1.1 - City
1.1.1.1.1 - Neighbourhood
1.1.1.1.1.1 - Store
1.1.1.1.1.1.1 - Section
1.1.1.1.1.1.1.1 - Catgory
1.1.1.1.1.1.1.1.1 - Subcatgory
1.1.1.1.1.1.1.1.1.1 - Product
Metrics such as Number of Sales, Revenue and Medium Ticket (Revenue / Number of Sales) makes sense up to the Subcategory level, because if I reach the Product level the agreggation composition will need to change (I guess).
Also, metrics such as Productivity, which is Revenue / Number of Store Staff, won't make sense to existe in this fact table, because it only works up to the Store level (also, I guess).
I'd like to know the best solution resolve this question because all of it are about Sales, but some makes sense until a specifict level of my hierarchy and others don't.
Waiting for the reply and Thanks in advance!
You should split your hierarchy into 2 dimensions, Stores and Products
The Stores dimension is all about the Location of the sale, and you can put the number of employees in this dimension
Store_Key STORE Neighbourhood City Country Num_Staff
1 Store1 4th Street LA US 10
2 Store2 Main Street NY US 2
The products dimension looks like
Product_Key Prod_Name SubCat Category Unit_Cost
1 Cheese Sticks Diary Food $2.00
2 Timer Software Computing $25.00
The your fact table has a record for each Sale, and is keyed to the above dimensions
Store_Key Product_Key Date Quantity Tot_Amount
1 1 31/7/2014 5 $10.00 (store1 sells 5 cheese)
1 2 31/7/2014 1 $25.00 (store1 sells 1 timer)
2 1 31/7/2014 3 $6.00 (store2 sells 3 cheese)
2 2 31/7/2014 1 $25.00 (store2 sells 1 timer)
Now that your data is in place you can use your reporting tool to get the measures you need. Example SQL is something like below
SELECT store.STORE,
SUM(fact.tot_amount) as revenue,
COUNT(*) as num_sales
SUM(fact.tot_amount) / store.NumStaff as Productivity
FROM tbl_Store store, tb_Fact fact
WHERE fact.Store_key = store.Store_key
GROUP BY store.STORE
should return the following result
STORE revenue num_sales Productivity
Store1 $35.00 2 3.5
Store2 $31.00 2 15.5

Find nodes with same relationships that initial node

I have customers (id, name, type), commerces (id, name, type) and relationships between them (idcustomer, idcommerce, quantity) that indicates that a customer has bought in a commerce and the quantity.
Well, I want to achieve nodes that have same relationships that the origin node, I mean, if customer 1 bought in commerce id=10 and id=11 I want to achive other customers who have bought in exact the same commerces (at least) that customer 1 in order to recommend the rest of commerces.
Now, I have next command but it doesn't work because it returns me all customers that have bought in one of the commerce where customer 1 bought but not in all of them.
START m=node:id(id="1") MATCH (m)-[:BUY]->(commerces)<-[:BUY]-(customers) RETURN customers;
Example
Customer 1 bought commerce 10, 11
Customer 2 bought commerce 10, 3
Customer 3 bought commerce 10, 11, 4
Customer 4 bought commerce 5, 8, 10
The return that I want is Customer 3 in order to recommend commerce 4.
Thank you.
Here is one solution,
The first query gets all of the products the start node m buys, that is the collect(commerce) of the first "WITH" clause;
The second query gets all products each customer shares with the m, that is the customerCommerces of the second "With" clause;
Then the "Where" clause eliminates those customers who share only a subset of the products bought by the m, therefore returns the customers who share all of the products with the m.
START m=node:id(id="1")
Match (m)-[:BUY]->(commerce)
With collect(commerce) as mCos
START m=node:id(id="1")
Match (m)-[:BUY]->(commerce)<-[:BUY]-(customer)
with mCos, customer, collect(commerce) as customerCommerces
Where length(mCos) = length(customerCommerces)
Return customer

Resources