looking for a simple database design for accounts receivable [closed] - sql

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 8 years ago.
Improve this question
I am in the process of adding accounts receivable to one of my webapps. Essentially, I want to be able to create sales invoices and record payments received.
The reports, I generate are
statement with balance outstanding
invoice
receipt
To create a statement, I was thinking of doing a union of receipts and invoices ordered by date.
I also need to cater for refunds/credits, which i am doing by refund = receipts with a negative amount, and credit = invoice with a negative amount.
All the invoices/receipts are exported to a full accounting package (so don't require double entry system at this end)
What i have come up with is
INVOICES
id
customer_id
total
tax_amount
reference
user_id
created
INVOICE_LINES
id
invoice_id
description
qty
unit_price
total
tax_amount
RECEIPTS
id
customer_id
reference
internal_notes
amount
user_id
created
Is there anything that i am missing?
Would a single transactions table be simpler instead of having separate invoice/receipt tables?
Another thought, is it normal to link a receipt to an invoice? what if a receipt was for multiple invoices.
Any advice appreciated (simplicity is the goal)

Look at the "Library of Free Data Models" from DatabaseAnswers.org
They have many basic designs that should inspire you.
For example "Accounting Systems"

Have a look at this similar question Database schema design for a double entry accounting system? . I came across it googling for 'bookkeeping database design' as I reckon you'll easily find free or relatively low-priced databases already exist - as you say - simplicity is the goal.

Related

Designing a database for private clinic [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 1 year ago.
Improve this question
I am using db 18C XE AND APEX 21.1. I am designing a database for private clinics. A private clinic is a place where patients get diagnosed. The clinic has only one doctor and an assistant or two. The assistant records the patients' data and visits(admission) data. The patient gets diagnosed at the first visit and get a prescription with the drugs they should take. Then a follow-up or more visits follows afterward i.e the second visit is after two weeks then a third one after a month and so on. Each follow-up has a new prescription or maybe the same prescription if the doctor thinks there is no need for a new drug. The patient could be diagnosed for a disease then gets cured after a number of visits. Then he could visit the clinic again after a year or two for a different complain. The same process occurs again. I am attaching a photo of the part of the visits, examining and follow-ups. I want to be sure if I designed it correctly.
As far as I am able understand your use case, the follow up table will record the follow up visits of the patient. Since you have columns like dose, drug_id etc in FOLLOW_UP_PRESCRIPTION table, I think there must be a patient id as well to map drugs/medicines with the patient.
Correct me if I'm missing something

SQL: how to count total of one column if one other column is there? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
Edit: it seems I have not explained well enough. I will try again
I would like to return this. If app_type equals "software update" then add up the values of bytes_received and bytes_sent.
app_type Bytes_received Bytes_sent
------------------------------------------------
software updates 10098120398214 09832140914
email 89032409 9874398
The first of below queries return and counts all the times that app_type in in the data. its a big table with 700000 entries
The second shows how much bytes_received is being used for the entry 'software updates'
end edit.
I have a table called WirelessAppData and I am trying to find work out the add up the amount of traffic being used sent and received for the data in the app_type column. I have added the things I have tried.
I really would like to return a table from highest to lowest
app_type Bytes_received Bytes_sent
------------------------------------------------
software updates 10098120398214 09832140914
email 89032409 9874398
SELECT
app_type AS ['App Type'],
COUNT (*) AS ['Top App type']
FROM
dbo.WirelessAppData
GROUP BY
app_type
ORDER BY
['Top App type'] DESC;
Uncategorized App Type 143305
Tunnel 123024
Media 85947
Facebook 66698
Search Engine 62031
Social Networking 50168
Internet Utilities 48973
Instant Messaging 40977
File Sharing 19595
Games 13432
Internal 12700
Business 9333
iTunes 9298
Microsoft 8995
Webmail 4644
Software Updates 3301
select app_type, bytes_received, bytes_sent
from WirelessAppData
where app_type = 'Software Updates'
order by bytes_received desc;
Software Updates 465108871 551
Software Updates 460464329 930
Software Updates 460271605 864
Software Updates 374041259 941
Software Updates 354425776 950
Software Updates 344554876 823
Software Updates 297851528 772
Software Updates 289410332 933
Software Updates 267913740 989
```
You can try the below -
select app_type, sum(bytes_received) as bytes_received ,sum(bytes_sent) as bytes_sent
from WirelessAppData
group by app_type
order by bytes_received desc

conceptual SQL - price per piece and price per weight [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 5 years ago.
Improve this question
This is a rather conceptual question:
I am working on a database with tables "product-information" and "buying transactions" - now the product-information table so far features "price" and the buying-transactions table features "amount".
But, some products are supposed to be paid per piece, and some have a price per weight.
Now I am unsure how to go about this without allowing decimal values for amounts.
Should I have the products have a flag if they are to be processed as price per weight and just do further calculations in the surrounding program? That seems to be rather impractical, since it makes aggregation in queries rather impossible. Or should I allow decimals but prohibit them in the user interface for things to be bought by piece, again requiring a flag?
What is the most sensible approach here?
Basically imagine a database containing receipts from groceries shopping and the appropriate information for each product. The user would insert the contents of a cart and the sum total would be calculated and spit out by the program, as well as the calculated price for each article to be paid per weight.
I'm sorry for the stupidity of the question.
Here's what we do for LedgerSMB, and I think the solution works relatively well.
Items are all priced per "unit." Items have a price per unit and a unit descriptor (human readable).
Items sold per piece have a unit of "piece". Items sold per weight have a unit like "kg", "oz", "g" or "T"
Price and quantity sold are both Numeric types without precision specified (so in PostgreSQL at least you have no precision limits).
Our table structure looks something like this (simplified for this question)
CREATE TABLE parts (
id SERIAL PRIMARY KEY,
sku VARCHAR NOT NULL,
unit BARCHAR(5) NOT NULL,
sell_price NUMERIC,
last_cost NUMERIC,
description TEXT,
obsolete BOOL
);
CREATE UNIQUE INDEX parts_sku_active_idx ON parts(sky) WHERE obsolete IS NOT TRUE;

spreadsheet/VBA to calculate multi-level marketing income [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
I am trying to help a friend who wants to set uo a MLM organisation. He needs to calculate income for everyone he will enroll.
The issue is that a top-level employee gets his own commission PLUS a percentage of everyone's commission he has enrolled...
[Do]
...these guys in turn get their own commission PLUS also a percentage of everyone's commission that they have enrolled, and this additional commission also has an upstream effect on the top level guy's percentage (this goes all the way down the line)...
[Loop]
potentially, this goes on ad-infinitum. So I can't calculate the upstream commission until I have calculated the commission right down to the bottom, but there may be hundreds of levels.
In the data I'm looking at, I know everybody's sales and I know the ID no. of the person who has enrolled them, I don't necessarily know how far down a chain they are.
How can I model this for him? I can't get my head round it.
Has anyone else ever had to work this out? Am I missing something obvious?
Thanks
You have typo error in following formula:
=SUMIFS([Upstream commision - outgoing],[Parent ID],[ID])
shoud read
=SUMIFS([Upstream commission outgoing],[Parent ID],[ID])

Count function using excel [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 9 years ago.
Improve this question
I have a table A having name of people and Table B having name of people and their membership with different organization. Is there any way I can get the total number of membership of each and every people using count function or any way?
Is there any way I can get the total number of membership of each and every people using count function or any way?
Did you try a Pivot? See screenshot below
I have taken a scenario as you mentioned in Andy G's post... with multiple memberships...
You haven't explained how SQL is involved, but if the two tables are both in Excel then you only need to count the number of times each name occurs in the second table, using COUNTIF and copying this formula down the column:
I'm assuming their membership of an organization is not repeated in the 2nd table.
Added It is more complicated knowing that the combination of person and organization repeats in the second table, but it can be done with an array formula. Use Ctrl-Shift-Enter to complete the following formula, then copy it down the column.
=SUM(IF($E$2:$E$13=A2, 1/(COUNTIFS($E$2:$E$13, A2, $F$2:$F$13, $F$2:$F$13))))
I cannot claim origination for this, a colleague of mine Rudi completed it for me.