MT#13903 fix invoices-balances relationship

make it bidirectional, otherwise DBIx complains with "Unable to resolve relationship from .. to ..: column .. .invoice_id not loaded from storage (or not passed to new() prior to insert()). Maybe you forgot to call ->discard_changes to get defaults from the db."

Change-Id: Iccf1ac66da27379844249e61f4ace1a3d2979f19
changes/27/2227/1
Rene Krenn 10 years ago
parent ac57c03e78
commit 26632809f6

@ -66,5 +66,14 @@ select bm.contract_id,max(bm.id) as actual_bm_id from billing.billing_mappings b
group by bm.contract_id
");
#__PACKAGE__->result_source_instance->view_definition("select bma.contract_id, bma.id as actual_bm_id
#from billing.billing_mappings bma
#where bma.id = (select bm.id from billing.billing_mappings bm where
#( bm.`end_date` >= now() or bm.`end_date` IS NULL )
#and ( bm.`start_date` <= now() or bm.`start_date` IS NULL )
#and bm.contract_id = bma.contract_id
#order by bm.start_date desc, bm.id desc limit 1)
#");
1;

@ -61,6 +61,13 @@ __PACKAGE__->belongs_to(
{ is_deferrable => 1, on_delete => "CASCADE", on_update => "CASCADE" },
);
__PACKAGE__->has_many(
"contract_balances",
"NGCP::Schema::Result::contract_balances",
{ "foreign.contract_id" => "self.id" },
{ cascade_copy => 0, cascade_delete => 0 },
);
sub TO_JSON {
my ($self) = @_;
return {

Loading…
Cancel
Save