Skip to content

Commit

Permalink
feat(invoices): add due date
Browse files Browse the repository at this point in the history
  • Loading branch information
LukeWasTakenn committed Aug 30, 2024
1 parent d32324c commit 8bdb21d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 12 deletions.
6 changes: 2 additions & 4 deletions server/accounts/db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -312,8 +312,6 @@ export async function CreateInvoice(invoice: Omit<OxAccountInvoice, 'id'>) {

if (!player?.charId) return 'no_charId';

console.log(JSON.stringify(invoice, null, 2));

const hasPermission = await player.hasAccountPermission(invoice.fromId, 'sendInvoice');

if (!hasPermission) return 'no_permission';
Expand All @@ -323,8 +321,8 @@ export async function CreateInvoice(invoice: Omit<OxAccountInvoice, 'id'>) {
if (!targetAccount) return 'no_target_account';

return db.insert(
'INSERT INTO accounts_invoices (`creatorId`, `fromId`, `toId`, `amount`, `message`) VALUES (?, ?, ?, ?, ?)',
[invoice.creatorId, invoice.fromId, invoice.toId, invoice.amount, invoice.message]
'INSERT INTO accounts_invoices (`creatorId`, `fromId`, `toId`, `amount`, `message`, `dueDate`) VALUES (?, ?, ?, ?, ?, ?)',
[invoice.creatorId, invoice.fromId, invoice.toId, invoice.amount, invoice.message, invoice.dueDate]
);
}

Expand Down
10 changes: 3 additions & 7 deletions sql/install.sql
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,9 @@ CREATE TABLE IF NOT EXISTS `accounts_invoices`
`toId` INT UNSIGNED NOT NULL,
`amount` INT UNSIGNED NOT NULL,
`message` VARCHAR(255) NULL,
`date` TIMESTAMP DEFAULT CURRENT_TIMESTAMP() NOT NULL,
`sentAt` TIMESTAMP DEFAULT CURRENT_TIMESTAMP() NOT NULL,
`dueDate` TIMESTAMP NOT NULL,
`paidAt` TIMESTAMP NULL,
CONSTRAINT `accounts_invoices_accounts_id_fk`
FOREIGN KEY (`fromId`) REFERENCES `accounts` (`id`),
CONSTRAINT `accounts_invoices_accounts_id_fk_2`
Expand All @@ -231,12 +233,6 @@ CREATE TABLE IF NOT EXISTS `accounts_invoices`
FOREIGN KEY (`creatorId`) REFERENCES `characters` (`charId`)
);







/*!40101 SET SQL_MODE=IFNULL(@OLD_SQL_MODE, '') */;

/*!40014 SET FOREIGN_KEY_CHECKS=IFNULL(@OLD_FOREIGN_KEY_CHECKS, 1) */;
Expand Down
3 changes: 2 additions & 1 deletion types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ export interface OxAccountInvoice {
toId: number;
amount: number;
message?: string;
sentAt?: number;
sentAt: number;
dueDate: number;
paidAt?: number;
}

0 comments on commit 8bdb21d

Please sign in to comment.