-
-
Notifications
You must be signed in to change notification settings - Fork 213
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #560 from liberapay/expenses-1
Implement Invoices - Part 1
- Loading branch information
Showing
19 changed files
with
1,001 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{{ _("Invoice from {0} on Liberapay", sender_name) }} | ||
|
||
[---] text/html | ||
<p>{{ _( | ||
"{sender_name} has submitted an invoice for a payment of {amount}.", | ||
sender_name=sender_name, amount=Money(invoice.amount, 'EUR') | ||
) }}</p> | ||
|
||
<p>{{ _("Description: {0}", invoice.description) }}</p> | ||
|
||
<p><a href="{{ participant.url('invoices/%s' % invoice.id) }}" | ||
style="{{ button_style('primary') }}">{{ _("View the invoice") }}</a></p> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
-- ALTER TYPE ... ADD cannot run inside a transaction block | ||
ALTER TYPE transfer_context ADD VALUE 'expense'; | ||
|
||
BEGIN; | ||
|
||
CREATE TYPE invoice_nature AS ENUM ('expense'); | ||
|
||
CREATE TYPE invoice_status AS ENUM | ||
('pre', 'canceled', 'new', 'retracted', 'accepted', 'paid', 'rejected'); | ||
|
||
CREATE TABLE invoices | ||
( id serial PRIMARY KEY | ||
, ctime timestamptz NOT NULL DEFAULT CURRENT_TIMESTAMP | ||
, sender bigint NOT NULL REFERENCES participants | ||
, addressee bigint NOT NULL REFERENCES participants | ||
, nature invoice_nature NOT NULL | ||
, amount numeric(35,2) NOT NULL CHECK (amount > 0) | ||
, description text NOT NULL | ||
, details text | ||
, documents jsonb NOT NULL | ||
, status invoice_status NOT NULL | ||
); | ||
|
||
CREATE TABLE invoice_events | ||
( id serial PRIMARY KEY | ||
, invoice int NOT NULL REFERENCES invoices | ||
, participant bigint NOT NULL REFERENCES participants | ||
, ts timestamptz NOT NULL DEFAULT CURRENT_TIMESTAMP | ||
, status invoice_status NOT NULL | ||
, message text | ||
); | ||
|
||
ALTER TABLE participants ADD COLUMN allow_invoices boolean; | ||
|
||
ALTER TABLE transfers | ||
ADD COLUMN invoice int REFERENCES invoices, | ||
ADD CONSTRAINT expense_chk CHECK (NOT (context='expense' AND invoice IS NULL)); | ||
|
||
INSERT INTO app_conf VALUES | ||
('s3_endpoint', '""'::jsonb), | ||
('s3_public_access_key', '""'::jsonb), | ||
('s3_secret_key', '""'::jsonb), | ||
('s3_region', '"eu-west-1"'::jsonb); | ||
|
||
END; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.