/*
        Copyright (c) 1996, NeXT Software, Inc.
        All rights reserved.

        You may freely copy, distribute and reuse the code in this example.
        NeXT disclaims any warranty of any kind, expressed or implied,
        as to its fitness for any particular use.
*/
#import <EOControl/EOControl.h>
#import <BusinessLogic/BusinessLogic.h>
#import <AppKit/AppKit.h>
#import "CustomerSelection.h"
#import "Transaction.h"

@implementation CustomerSelection

- (void)StartASale:(id)sender
{
    id selectedCustomer = [customerDisplayGroup selectedObject];
    EOGlobalID *customerGID;

    customerGID = [[selectedCustomer editingContext] globalIDForObject:selectedCustomer];

    if(!customerGID) {
        NSRunAlertPanel(@"Error", @"Please select a customer", @"OK", nil, nil);
        return;
    }

    if([selectedCustomer hasOverdueProducts]) {
        NSRunAlertPanel(@"Error", @"Customer cannot rent new products due to outstanding overdue rentals.", @"OK", nil, nil);
    }

    [[Transaction alloc] initWithCustomerGlobalID:customerGID];
}

@end
