2016-06-26 17:49:12 +02:00
|
|
|
use strict;
|
|
|
|
|
|
|
|
package TrsrDB::Credit;
|
|
|
|
use base qw/DBIx::Class::Core/;
|
|
|
|
|
|
|
|
__PACKAGE__->table('Credit');
|
2016-07-03 22:05:53 +02:00
|
|
|
__PACKAGE__->add_column("credId" => { data_type => 'INTEGER' });
|
2016-06-26 17:49:12 +02:00
|
|
|
__PACKAGE__->add_column("account");
|
|
|
|
__PACKAGE__->add_column("date" => { data_type => 'DATE' });
|
|
|
|
__PACKAGE__->add_column("purpose");
|
2017-01-29 15:57:34 +01:00
|
|
|
__PACKAGE__->add_column("category", { is_nullable => 1 });
|
2016-06-26 17:49:12 +02:00
|
|
|
__PACKAGE__->add_column("value" => { data_type => 'INTEGER' });
|
|
|
|
__PACKAGE__->add_column("spent" => { data_type => 'INTEGER', default => 0 });
|
2016-07-03 22:05:53 +02:00
|
|
|
__PACKAGE__->set_primary_key("credId");
|
2016-06-26 17:49:12 +02:00
|
|
|
|
|
|
|
__PACKAGE__->belongs_to(
|
|
|
|
account => 'TrsrDB::Account',
|
|
|
|
{ 'foreign.ID' => 'self.account' }
|
|
|
|
);
|
|
|
|
|
|
|
|
__PACKAGE__->has_many(
|
2017-01-15 16:27:22 +01:00
|
|
|
outgoings => 'TrsrDB::Transfer', 'credId'
|
2017-01-14 09:50:16 +01:00
|
|
|
);
|
|
|
|
|
|
|
|
__PACKAGE__->has_many(
|
|
|
|
income => 'TrsrDB::Debit',
|
|
|
|
{ 'foreign.targetCredit' => 'self.credId' }
|
2016-06-26 17:49:12 +02:00
|
|
|
);
|
|
|
|
|
2017-01-29 15:57:34 +01:00
|
|
|
__PACKAGE__->belongs_to(
|
|
|
|
category_row => 'TrsrDB::Category',
|
|
|
|
{ 'foreign.ID' => 'self.category' }
|
|
|
|
);
|
|
|
|
|
2016-06-26 17:49:12 +02:00
|
|
|
__PACKAGE__->many_to_many(
|
|
|
|
paid_bills => 'outgoings' => 'debit'
|
|
|
|
);
|
|
|
|
|
|
|
|
1;
|