inventory package

Subpackages

Submodules

inventory.admin module

inventory.apps module

class inventory.apps.InventoryConfig(app_name, app_module)[source]

Bases: AppConfig

default_auto_field = 'django.db.models.BigAutoField'
name = 'inventory'

inventory.models module

class inventory.models.HistoricalInventory(id, stock_quantity, demand, datetime, inventory)[source]

Bases: Model

exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

datetime

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

demand

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

get_next_by_datetime(*, field=<django.db.models.fields.DateTimeField: datetime>, is_next=True, **kwargs)
get_previous_by_datetime(*, field=<django.db.models.fields.DateTimeField: datetime>, is_next=False, **kwargs)
id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

inventory

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

inventory_id
objects = <django.db.models.manager.Manager object>
stock_quantity

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

class inventory.models.Inventory(id, item_name, description, unit_price, stock_quantity, location, date_added, last_updated, image, procurement_officer)[source]

Bases: Model

exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

date_added

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

description

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

get_next_by_date_added(*, field=<django.db.models.fields.DateTimeField: date_added>, is_next=True, **kwargs)
get_next_by_last_updated(*, field=<django.db.models.fields.DateTimeField: last_updated>, is_next=True, **kwargs)
get_previous_by_date_added(*, field=<django.db.models.fields.DateTimeField: date_added>, is_next=False, **kwargs)
get_previous_by_last_updated(*, field=<django.db.models.fields.DateTimeField: last_updated>, is_next=False, **kwargs)
historicalinventory_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

image

Just like the FileDescriptor, but for ImageFields. The only difference is assigning the width/height to the width_field/height_field, if appropriate.

item_name

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

last_updated

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

location

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

objects = <django.db.models.manager.Manager object>
optimizedinventory

Accessor to the related object on the reverse side of a one-to-one relation.

In the example:

class Restaurant(Model):
    place = OneToOneField(Place, related_name='restaurant')

Place.restaurant is a ReverseOneToOneDescriptor instance.

procurement_officer

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

procurement_officer_id
purchaserequisition

Accessor to the related object on the reverse side of a one-to-one relation.

In the example:

class Restaurant(Model):
    place = OneToOneField(Place, related_name='restaurant')

Place.restaurant is a ReverseOneToOneDescriptor instance.

stock_quantity

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

unit_price

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

class inventory.models.OptimizedInventory(id, demand, ordering_cost, holding_cost, lead_time, service_level, safety_stock, reorder_point, shelf_life, storage_limit, eoq, inventory)[source]

Bases: Model

exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

demand

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

eoq

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

holding_cost

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

inventory

Accessor to the related object on the forward side of a one-to-one relation.

In the example:

class Restaurant(Model):
    place = OneToOneField(Place, related_name='restaurant')

Restaurant.place is a ForwardOneToOneDescriptor instance.

inventory_id
lead_time

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

objects = <django.db.models.manager.Manager object>
ordering_cost

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

reorder_point

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

safety_stock

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

service_level

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

shelf_life

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

storage_limit

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

inventory.models.create_historical_inventory(sender, instance, created, **kwargs)[source]

inventory.serializers module

class inventory.serializers.ARIMAForecastSerializer(*args, **kwargs)[source]

Bases: Serializer

class inventory.serializers.HistoricalInventorySerializer(*args, **kwargs)[source]

Bases: ModelSerializer

class Meta[source]

Bases: object

exclude = ['inventory']
model

alias of HistoricalInventory

class inventory.serializers.InventorySerializer(*args, **kwargs)[source]

Bases: ModelSerializer

class Meta[source]

Bases: object

exclude = ['procurement_officer']
model

alias of Inventory

class inventory.serializers.OptimizedInventorySerializer(*args, **kwargs)[source]

Bases: ModelSerializer

class Meta[source]

Bases: object

fields = '__all__'
model

alias of OptimizedInventory

read_only_fields = ['eoq', 'safety_stock', 'reorder_point', 'inventory']

inventory.tasks module

inventory.tests module

class inventory.tests.ARIMAForecastViewsTests(methodName='runTest')[source]

Bases: SetupClass, TestCase

setUp()[source]

Hook method for setting up the test fixture before exercising it.

test_arima_forecast_view_insufficient_data()[source]
test_arima_forecast_view_invalid_data()[source]
test_arima_forecast_view_invalid_file_type()[source]
test_arima_forecast_view_invalid_http_method()[source]
test_arima_forecast_view_invalid_token()[source]
test_arima_forecast_view_other_procurement_officer()[source]
test_arima_forecast_view_procurement_officer()[source]
test_arima_forecast_view_sufficient_data()[source]
test_arima_forecast_view_unauthenticated()[source]
test_arima_forecast_view_upload_csv_insufficient_data()[source]
test_arima_forecast_view_upload_csv_sufficient_data()[source]
test_arima_forecast_view_vendor()[source]
class inventory.tests.HistoricalInventoryViewsTests(methodName='runTest')[source]

Bases: SetupClass, TestCase

setUp()[source]

Hook method for setting up the test fixture before exercising it.

test_historical_inventory_list_view_invalid_http_method()[source]
test_historical_inventory_list_view_invalid_token()[source]
test_historical_inventory_list_view_other_procurement_officer()[source]
test_historical_inventory_list_view_procurement_officer()[source]
test_historical_inventory_list_view_unauthenticated()[source]
test_historical_inventory_list_view_vendor()[source]
class inventory.tests.InventorySignalsTests(methodName='runTest')[source]

Bases: SetupClass, TestCase

setUp()[source]

Hook method for setting up the test fixture before exercising it.

test_create_historical_inventory_on_create()[source]
test_create_historical_inventory_on_update_with_demand()[source]
test_create_historical_inventory_on_update_without_demand()[source]
test_delete_historical_inventory_on_inventory_delete()[source]
class inventory.tests.InventoryViewsTests(methodName='runTest')[source]

Bases: SetupClass, TestCase

setUp()[source]

Hook method for setting up the test fixture before exercising it.

test_historical_inventory_list_view_invalid_http_method()[source]
test_historical_inventory_list_view_invalid_token()[source]
test_historical_inventory_list_view_other_procurement_officer()[source]
test_historical_inventory_list_view_procurement_officer()[source]
test_historical_inventory_list_view_unauthenticated()[source]
test_historical_inventory_list_view_vendor()[source]
test_inventory_create_view_invalid_data()[source]
test_inventory_create_view_invalid_http_method()[source]
test_inventory_create_view_invalid_token()[source]
test_inventory_create_view_missing_data()[source]
test_inventory_create_view_procurement_officer()[source]
test_inventory_create_view_unauthenticated()[source]
test_inventory_create_view_vendor()[source]
test_inventory_delete_view_invalid_http_method()[source]
test_inventory_delete_view_invalid_token()[source]
test_inventory_delete_view_other_procurement_officer()[source]
test_inventory_delete_view_procurement_officer_own_item()[source]
test_inventory_delete_view_unauthenticated()[source]
test_inventory_delete_view_vendor()[source]
test_inventory_list_view_invalid_http_method()[source]
test_inventory_list_view_invalid_token()[source]
test_inventory_list_view_procurement_officer()[source]
test_inventory_list_view_unauthenticated()[source]
test_inventory_list_view_vendor()[source]
test_inventory_retrieve_view_invalid_http_method()[source]
test_inventory_retrieve_view_invalid_token()[source]
test_inventory_retrieve_view_other_procurement_officer()[source]
test_inventory_retrieve_view_procurement_officer_own_item()[source]
test_inventory_retrieve_view_unauthenticated()[source]
test_inventory_retrieve_view_vendor()[source]
test_inventory_update_view_invalid_data()[source]
test_inventory_update_view_invalid_http_method()[source]
test_inventory_update_view_invalid_token()[source]
test_inventory_update_view_missing_data()[source]
test_inventory_update_view_other_procurement_officer()[source]
test_inventory_update_view_procurement_officer_own_item()[source]
test_inventory_update_view_unauthenticated()[source]
test_inventory_update_view_vendor()[source]
class inventory.tests.OptimizedInventoryViewsTests(methodName='runTest')[source]

Bases: SetupClass, TestCase

setUp()[source]

Hook method for setting up the test fixture before exercising it.

test_optimized_inventory_classical_eoq()[source]
test_optimized_inventory_create_view_existing_optimized_inventory()[source]
test_optimized_inventory_create_view_invalid_data()[source]
test_optimized_inventory_create_view_invalid_http_method()[source]
test_optimized_inventory_create_view_invalid_token()[source]
test_optimized_inventory_create_view_missing_data()[source]
test_optimized_inventory_create_view_other_procurement_officer()[source]
test_optimized_inventory_create_view_procurement_officer()[source]
test_optimized_inventory_create_view_read_only_fields()[source]
test_optimized_inventory_create_view_unauthenticated()[source]
test_optimized_inventory_create_view_vendor()[source]
test_optimized_inventory_delete_view_invalid_http_method()[source]
test_optimized_inventory_delete_view_invalid_token()[source]
test_optimized_inventory_delete_view_other_procurement_officer()[source]
test_optimized_inventory_delete_view_procurement_officer()[source]
test_optimized_inventory_delete_view_unauthenticated()[source]
test_optimized_inventory_delete_view_vendor()[source]
test_optimized_inventory_eoq_for_limited_storage()[source]
test_optimized_inventory_eoq_for_perishable_items()[source]
test_optimized_inventory_eoq_with_rop()[source]
test_optimized_inventory_holding_cost_equals_0()[source]
test_optimized_inventory_retrieve_view_invalid_http_method()[source]
test_optimized_inventory_retrieve_view_invalid_token()[source]
test_optimized_inventory_retrieve_view_other_procurement_officer()[source]
test_optimized_inventory_retrieve_view_procurement_officer()[source]
test_optimized_inventory_retrieve_view_unauthenticated()[source]
test_optimized_inventory_retrieve_view_vendor()[source]
test_optimized_inventory_update_view_invalid_data()[source]
test_optimized_inventory_update_view_invalid_http_method()[source]
test_optimized_inventory_update_view_invalid_token()[source]
test_optimized_inventory_update_view_missing_data()[source]
test_optimized_inventory_update_view_other_procurement_officer()[source]
test_optimized_inventory_update_view_procurement_officer()[source]
test_optimized_inventory_update_view_unauthenticated()[source]
test_optimized_inventory_update_view_vendor()[source]
class inventory.tests.SetupClass(methodName='runTest')[source]

Bases: TestCase

setUp()[source]

Hook method for setting up the test fixture before exercising it.

inventory.urls module

inventory.views module

class inventory.views.ARIMAForecastAPIView(**kwargs)[source]

Bases: GenericAPIView

get(request, inventory_id)[source]
get_queryset(inventory_id)[source]

Get the list of items for this view. This must be an iterable, and may be a queryset. Defaults to using self.queryset.

This method should always be used rather than accessing self.queryset directly, as self.queryset gets evaluated only once, and those results are cached for all subsequent requests.

You may want to override this if you need to provide different querysets depending on the incoming request.

(Eg. return a list of items that is specific to the user)

permission_classes = [<class 'rest_framework.permissions.IsAuthenticated'>, <class 'accounts.permissions.IsProcurementOfficer'>]
post(request, inventory_id)[source]
serializer_class

alias of ARIMAForecastSerializer

class inventory.views.BaseInventoryAPIView(**kwargs)[source]

Bases: GenericAPIView

get_queryset()[source]

Get the list of items for this view. This must be an iterable, and may be a queryset. Defaults to using self.queryset.

This method should always be used rather than accessing self.queryset directly, as self.queryset gets evaluated only once, and those results are cached for all subsequent requests.

You may want to override this if you need to provide different querysets depending on the incoming request.

(Eg. return a list of items that is specific to the user)

permission_classes = [<class 'rest_framework.permissions.IsAuthenticated'>, <class 'accounts.permissions.IsProcurementOfficer'>]
serializer_class

alias of InventorySerializer

class inventory.views.BaseOptimizedInventoryAPIView(**kwargs)[source]

Bases: GenericAPIView

get_queryset()[source]

Get the list of items for this view. This must be an iterable, and may be a queryset. Defaults to using self.queryset.

This method should always be used rather than accessing self.queryset directly, as self.queryset gets evaluated only once, and those results are cached for all subsequent requests.

You may want to override this if you need to provide different querysets depending on the incoming request.

(Eg. return a list of items that is specific to the user)

lookup_field = 'inventory_id'
permission_classes = [<class 'rest_framework.permissions.IsAuthenticated'>, <class 'accounts.permissions.IsProcurementOfficer'>]
serializer_class

alias of OptimizedInventorySerializer

class inventory.views.HistoricalInventoryListView(**kwargs)[source]

Bases: ListAPIView

get_queryset()[source]

Get the list of items for this view. This must be an iterable, and may be a queryset. Defaults to using self.queryset.

This method should always be used rather than accessing self.queryset directly, as self.queryset gets evaluated only once, and those results are cached for all subsequent requests.

You may want to override this if you need to provide different querysets depending on the incoming request.

(Eg. return a list of items that is specific to the user)

permission_classes = [<class 'rest_framework.permissions.IsAuthenticated'>, <class 'accounts.permissions.IsProcurementOfficer'>]
serializer_class

alias of HistoricalInventorySerializer

class inventory.views.InventoryCreateView(**kwargs)[source]

Bases: BaseInventoryAPIView, CreateAPIView

perform_create(serializer)[source]
queryset = <QuerySet [<Inventory: item 1>]>
class inventory.views.InventoryDeleteView(**kwargs)[source]

Bases: BaseInventoryAPIView, DestroyAPIView

destroy(request, *args, **kwargs)[source]
class inventory.views.InventoryListView(**kwargs)[source]

Bases: BaseInventoryAPIView, ListAPIView

list(request, *args, **kwargs)[source]
class inventory.views.InventoryRetrieveView(**kwargs)[source]

Bases: BaseInventoryAPIView, RetrieveAPIView

class inventory.views.InventoryUpdateView(**kwargs)[source]

Bases: BaseInventoryAPIView, UpdateAPIView

update(request, *args, **kwargs)[source]
class inventory.views.OptimizedInventoryCreateAPIView(**kwargs)[source]

Bases: CreateAPIView

perform_create(serializer)[source]
permission_classes = [<class 'rest_framework.permissions.IsAuthenticated'>, <class 'accounts.permissions.IsProcurementOfficer'>]
serializer_class

alias of OptimizedInventorySerializer

class inventory.views.OptimizedInventoryDestroyAPIView(**kwargs)[source]

Bases: BaseOptimizedInventoryAPIView, DestroyAPIView

class inventory.views.OptimizedInventoryRetrieveAPIView(**kwargs)[source]

Bases: BaseOptimizedInventoryAPIView, RetrieveAPIView

class inventory.views.OptimizedInventoryUpdateAPIView(**kwargs)[source]

Bases: UpdateAPIView

perform_update(serializer)[source]
permission_classes = [<class 'rest_framework.permissions.IsAuthenticated'>, <class 'accounts.permissions.IsProcurementOfficer'>]
serializer_class

alias of OptimizedInventorySerializer

update(request, *args, **kwargs)[source]
inventory.views.calculate_auto_arima(monthly_demand)[source]
inventory.views.calculate_eoq_classical(demand, ordering_cost, holding_cost)[source]
inventory.views.calculate_eoq_limited_storage(demand, ordering_cost, holding_cost, storage_capacity)[source]
inventory.views.calculate_eoq_perishable(demand, ordering_cost, holding_cost, shelf_life)[source]
inventory.views.calculate_eoq_with_rop(demand, ordering_cost, holding_cost, lead_time, service_level)[source]
inventory.views.calculate_safety_stock_reorder_point(demand, lead_time, service_level)[source]
inventory.views.getRoutes(request, *args, **kwargs)[source]

Module contents