Added TrsrDB::autobalance(). Renamings and fixes.
Renamed "debts" to "arrears", because of psychologically slightly more positive connotations. Renamed field "Id" of table Credit to "credId" in analogy to field "billId" of table Debit.
This commit is contained in:
@@ -12,11 +12,11 @@ __PACKAGE__->has_many(
|
||||
{ 'foreign.account' => 'self.ID' }
|
||||
);
|
||||
__PACKAGE__->has_many(
|
||||
debts => 'TrsrDB::Debit',
|
||||
debits => 'TrsrDB::Debit',
|
||||
{ 'foreign.debtor' => 'self.ID' }
|
||||
);
|
||||
__PACKAGE__->has_many(
|
||||
current_debts => 'TrsrDB::CurrentDebts',
|
||||
current_arrears => 'TrsrDB::CurrentArrears',
|
||||
{ 'foreign.debtor' => 'self.ID' }
|
||||
);
|
||||
__PACKAGE__->has_many(
|
||||
|
||||
@@ -4,8 +4,8 @@ package TrsrDB::AvailableCredits;
|
||||
use base qw/DBIx::Class::Core/;
|
||||
|
||||
__PACKAGE__->table('AvailableCredits');
|
||||
__PACKAGE__->add_columns(qw/ Id account date purpose difference /);
|
||||
__PACKAGE__->set_primary_key("Id");
|
||||
__PACKAGE__->add_columns(qw/ credId account date purpose difference /);
|
||||
__PACKAGE__->set_primary_key("credId");
|
||||
|
||||
__PACKAGE__->belongs_to(
|
||||
account => 'TrsrDB::Account',
|
||||
@@ -13,7 +13,7 @@ __PACKAGE__->belongs_to(
|
||||
);
|
||||
|
||||
__PACKAGE__->many_to_many(
|
||||
suggested_to_pay => account => 'current_debts'
|
||||
suggested_to_pay => account => 'current_arrears'
|
||||
);
|
||||
|
||||
1;
|
||||
|
||||
@@ -4,7 +4,7 @@ package TrsrDB::Balance;
|
||||
use base qw/DBIx::Class::Core/;
|
||||
|
||||
__PACKAGE__->table("Balance");
|
||||
__PACKAGE__->add_columns(qw/ID credit promised debt/);
|
||||
__PACKAGE__->add_columns(qw/ID credit promised arrears/);
|
||||
__PACKAGE__->set_primary_key("ID");
|
||||
|
||||
__PACKAGE__->belongs_to(
|
||||
|
||||
@@ -4,13 +4,13 @@ package TrsrDB::Credit;
|
||||
use base qw/DBIx::Class::Core/;
|
||||
|
||||
__PACKAGE__->table('Credit');
|
||||
__PACKAGE__->add_column("Id" => { data_type => 'INTEGER' });
|
||||
__PACKAGE__->add_column("credId" => { data_type => 'INTEGER' });
|
||||
__PACKAGE__->add_column("account");
|
||||
__PACKAGE__->add_column("date" => { data_type => 'DATE' });
|
||||
__PACKAGE__->add_column("purpose");
|
||||
__PACKAGE__->add_column("value" => { data_type => 'INTEGER' });
|
||||
__PACKAGE__->add_column("spent" => { data_type => 'INTEGER', default => 0 });
|
||||
__PACKAGE__->set_primary_key("Id");
|
||||
__PACKAGE__->set_primary_key("credId");
|
||||
|
||||
__PACKAGE__->belongs_to(
|
||||
account => 'TrsrDB::Account',
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
use strict;
|
||||
|
||||
package TrsrDB::CurrentDebts;
|
||||
package TrsrDB::CurrentArrears;
|
||||
use base qw/DBIx::Class::Core/;
|
||||
|
||||
__PACKAGE__->table('CurrentDebts');
|
||||
__PACKAGE__->table('CurrentArrears');
|
||||
__PACKAGE__->add_columns(qw/billId debtor targetCredit date purpose difference/);
|
||||
__PACKAGE__->set_primary_key("billId");
|
||||
|
||||
@@ -6,13 +6,12 @@ use base qw/DBIx::Class::Core/;
|
||||
__PACKAGE__->table('Transfer');
|
||||
__PACKAGE__->add_column("timestamp" => { data_type => 'TIMESTAMP' });
|
||||
__PACKAGE__->add_column("billId");
|
||||
__PACKAGE__->add_column("fromCredit");
|
||||
__PACKAGE__->add_column("credId" => { data_type => 'INTEGER' });
|
||||
__PACKAGE__->add_column("amount" => { data_type => 'INTEGER', nullable => 1 });
|
||||
__PACKAGE__->set_primary_key("billId", "fromCredit");
|
||||
__PACKAGE__->set_primary_key("billId", "credId");
|
||||
|
||||
__PACKAGE__->belongs_to(
|
||||
credit => 'TrsrDB::Credit',
|
||||
{ 'foreign.Id' => 'self.fromCredit' }
|
||||
credit => 'TrsrDB::Credit', 'credId'
|
||||
);
|
||||
|
||||
__PACKAGE__->belongs_to(
|
||||
|
||||
Reference in New Issue
Block a user