Esempio n. 1
0
def ReadById(existing_pattern_id):
    cutting_pattern = RetailCuttingPattern.objects.get(pk = existing_pattern_id)
    outputs = RetailCuttingPatternOutput.objects.filter(retail_cutting_pattern_id = existing_pattern_id)
    primary_output = []
    secondary_outputs = []
    for output in outputs:
        retail_size = RetailSize.objects.get(pk = output.retail_size_id)
        if output.is_primary:
            primary_output.append(OutputDisplay(retail_size, output.retail_size_id, output.quantity, output.is_for_cradle, True))
        else:
            secondary_outputs.append(OutputDisplay(retail_size, output.retail_size_id, output.quantity, output.is_for_cradle, False))
    output_displays = primary_output + secondary_outputs
    pattern_display = CuttingPatternsDisplay(output_displays, existing_pattern_id, cutting_pattern.grade,\
            display.tercero_size(cutting_pattern.coating_size), cutting_pattern.coating_size, cutting_pattern.cutting_instructions, 'n/a')
    return pattern_display
Esempio n. 2
0
def review_instructions(coating_id, panel_depth_id):
    entries, sheet_id = retrieve_entries(coating_id, panel_depth_id)

    instructions = RetailCuttingSheetInstruction.objects.filter(retail_cutting_sheet_entry_id__in = \
                        entries).order_by('retail_cutting_pattern__cutting_instructions')
    output_list = []
    for instruction in instructions:
        cutting_pattern = RetailCuttingPattern.objects.get(id = \
                                instruction.retail_cutting_pattern_id)
        coating_size_id = instruction.retail_cutting_pattern.coating_size.id
        instruction_string = instruction.retail_cutting_pattern.cutting_instructions
        quantity = instruction.quantity
        cutting_pattern_id = instruction.retail_cutting_pattern_id
        outputs = RetailCuttingPatternOutput.objects.filter(retail_cutting_pattern_id = \
                            cutting_pattern_id)
        cutting_pattern = RetailCuttingPattern.objects.get(
            id=cutting_pattern_id)
        outputString = ''
        for output in outputs:
            retail_size_display = display.retail_size(
                RetailSize.objects.get(id=output.retail_size_id))
            outputString = outputString + retail_size_display + \
                (' cradled' if output.is_for_cradle else ' flat') + ' (' + str(output.quantity) + '), '

        tercero = CoatingSize.objects.get(id=coating_size_id)
        terceroDisplay = ''
        total_tercero_quantity = 0
        terceroDisplay = ', ' + instruction.retail_cutting_pattern.grade + \
                            ' (' + str(quantity) + '), '
        terceroDisplay = display.tercero_size(tercero) + terceroDisplay
        if (len(terceroDisplay) > 2):
            terceroDisplay = terceroDisplay[:(len(terceroDisplay) - 2)]
        coating_description = Coating.objects.filter(
            id=coating_id)[0].description
        panel_depth = PanelDepth.objects.get(id=panel_depth_id)
        firstI = cutting_pattern.cutting_instructions.index('I')
        instructionIndent = ''
        for i in range(0, firstI + 8):
            instructionIndent = instructionIndent + ' '
        pattern_display_string = cutting_pattern.cutting_instructions.replace(
            '___', '<br/>' + instructionIndent)
        pattern_display_string = pattern_display_string.replace(' ', '&nbsp')
        pattern_display_string = pattern_display_string.replace('->', '-&gt')
        output_list.append(RetailCuttingSheetFinalInstructionDisplay(coating_description,\
                display.small_measurement(panel_depth), terceroDisplay, outputString,\
                pattern_display_string, \
                instruction.id, quantity, cutting_pattern.id))
    return output_list
Esempio n. 3
0
def create_cutting_sheet_output(sheet_data, coating_id, panel_depth_id):
    output_list = []
    for instruction, instruction_data in sheet_data.iteritems():
        for coating_size_id, data in instruction_data.iteritems():
            outputs = RetailCuttingPatternOutput.objects.filter(retail_cutting_pattern_id = \
                    data['pattern_id'])
            cutting_pattern = RetailCuttingPattern.objects.get(
                id=data['pattern_id'])

            outputString = ''
            for output in outputs:
                retail_size_display = display.retail_size(
                    RetailSize.objects.get(id=output.retail_size_id))
                outputString = outputString + retail_size_display + \
                        (' cradled' if output.is_for_cradle else ' flat') + ' (' + str(output.quantity) + '), '

            tercero = CoatingSize.objects.get(
                id=cutting_pattern.coating_size_id)
            terceroDisplay = ''
            total_tercero_quantity = 0
            for grade, quantity in data.iteritems():
                if grade is not 'pattern_id':
                    terceroDisplay = terceroDisplay +  grade + \
                            ' (' + str(quantity) + '), '
                    total_tercero_quantity = total_tercero_quantity + quantity
            terceroDisplay = display.tercero_size(tercero) + ' (' + str(
                total_tercero_quantity) + '), Grades: ' + terceroDisplay
            if (len(terceroDisplay) > 2):
                terceroDisplay = terceroDisplay[:(len(terceroDisplay) - 2)]
            coating_description = Coating.objects.filter(
                id=coating_id)[0].description
            panel_depth = PanelDepth.objects.get(id=panel_depth_id)
            instructionIndent = ''
            firstI = cutting_pattern.cutting_instructions.index('I')
            for i in range(0, firstI + 8):
                instructionIndent = instructionIndent + '&nbsp;'
            pattern_display_string = cutting_pattern.cutting_instructions.replace(
                '___', '<br/>' + instructionIndent)
            pattern_display_string = pattern_display_string.replace(
                ' ', '&nbsp')
            pattern_display_string = pattern_display_string.replace(
                '->', '-&gt')
            output_list.append(RetailCuttingSheetFinalInstructionDisplay(coating_description, \
                    display.small_measurement(panel_depth), terceroDisplay, outputString, \
                    pattern_display_string, 0, 33, cutting_pattern.id))
    return output_list
Esempio n. 4
0
def cutting_patterns(primarySizeId, isForCradle, secondarySizeId,
                     primarySizeQuantity):
    '''
    Description
    -----------
    Returns all cutting patterns that have the retail size specified by
    retailSizeId in them.  isForCradle and desiredQuantity just go along for 
    the ride so that they are persisted into WIP
    '''

    #get all desired cutting pattern outputs which are primary
    cutting_pattern_outputs = RetailCuttingPatternOutput.objects.\
            filter(retail_size_id = primarySizeId, is_primary = True,\
            is_for_cradle = conversions.bool_map[isForCradle], retail_cutting_pattern__is_active = True).\
            order_by("retail_cutting_pattern__cutting_instructions","-retail_cutting_pattern__grade")

    patterns = []
    for output in cutting_pattern_outputs:
        quantity = output.quantity
        #get the primary output's family
        output_family = RetailCuttingPatternOutput.objects.\
                        filter(retail_cutting_pattern_id = \
                        output.retail_cutting_pattern.id)
        #check to see if secondarySize is a sibling of output
        secondary_a_sibling = False
        for sibling in output_family:
            if secondarySizeId == '' or int(
                    sibling.retail_size_id) == int(secondarySizeId):
                secondary_a_sibling = True

        if secondary_a_sibling:
            output_displays = [OutputDisplay(display.retail_size(\
                           output.retail_size), output.retail_size.id, output.quantity,\
                           'c' if output.is_for_cradle else 'f', output.is_primary)]
            output_displays += [OutputDisplay(display.retail_size(\
                           sibling.retail_size), sibling.retail_size.id, sibling.quantity,\
                           'c' if sibling.is_for_cradle else 'f', sibling.is_primary)
                           for sibling in output_family if sibling.id != output.id]
            patterns.append(CuttingPatternsDisplay\
                    (output_displays, output.retail_cutting_pattern.id, output.retail_cutting_pattern.grade, \
                    display.tercero_size(output.retail_cutting_pattern.coating_size), output.retail_cutting_pattern.coating_size, \
                    format_cutting_pattern(output.retail_cutting_pattern.cutting_instructions, output.retail_cutting_pattern.coating_size),\
                    'n/a' if not primarySizeQuantity else str(int(math.\
                    ceil(float(primarySizeQuantity)/float(output.quantity)))) + ' needed'))
    return patterns
Esempio n. 5
0
def review_instructions(coating_id, panel_depth_id):
    entries, sheet_id = retrieve_entries(coating_id, panel_depth_id)

    instructions = RetailCuttingSheetInstruction.objects.filter(retail_cutting_sheet_entry_id__in = \
                        entries).order_by('retail_cutting_pattern__cutting_instructions')
    output_list = []
    for instruction in instructions:
        cutting_pattern = RetailCuttingPattern.objects.get(id = \
                                instruction.retail_cutting_pattern_id)
        coating_size_id = instruction.retail_cutting_pattern.coating_size.id
        instruction_string = instruction.retail_cutting_pattern.cutting_instructions
        quantity = instruction.quantity
        cutting_pattern_id = instruction.retail_cutting_pattern_id
        outputs = RetailCuttingPatternOutput.objects.filter(retail_cutting_pattern_id = \
                            cutting_pattern_id)
        cutting_pattern = RetailCuttingPattern.objects.get(id = cutting_pattern_id)
        outputString = ''
        for output in outputs:
            retail_size_display = display.retail_size(RetailSize.objects.get(id = output.retail_size_id))
            outputString = outputString + retail_size_display + \
                (' cradled' if output.is_for_cradle else ' flat') + ' (' + str(output.quantity) + '), '

        tercero = CoatingSize.objects.get(id = coating_size_id)
        terceroDisplay = ''
        total_tercero_quantity = 0
        terceroDisplay = ', ' + instruction.retail_cutting_pattern.grade + \
                            ' (' + str(quantity) + '), '
        terceroDisplay = display.tercero_size(tercero) + terceroDisplay
        if (len(terceroDisplay) > 2):
            terceroDisplay = terceroDisplay[:(len(terceroDisplay)-2)]
        coating_description = Coating.objects.filter(id = coating_id)[0].description
        panel_depth = PanelDepth.objects.get(id = panel_depth_id)
        firstI = cutting_pattern.cutting_instructions.index('I')
        instructionIndent = ''
        for i in range(0,firstI + 8):
            instructionIndent = instructionIndent + '&nbsp;'
        pattern_display_string = cutting_pattern.cutting_instructions.replace('___', '<br/>' + instructionIndent)
        pattern_display_string = pattern_display_string.replace(' ', '&nbsp')
        pattern_display_string = pattern_display_string.replace('->', '-&gt')
        output_list.append(RetailCuttingSheetFinalInstructionDisplay(coating_description,\
                display.small_measurement(panel_depth), terceroDisplay, outputString,\
                pattern_display_string, \
                instruction.id, quantity, cutting_pattern.id))
    return output_list
Esempio n. 6
0
def cutting_patterns(primarySizeId, isForCradle, secondarySizeId, primarySizeQuantity):
    '''
    Description
    -----------
    Returns all cutting patterns that have the retail size specified by
    retailSizeId in them.  isForCradle and desiredQuantity just go along for 
    the ride so that they are persisted into WIP
    '''

    #get all desired cutting pattern outputs which are primary
    cutting_pattern_outputs = RetailCuttingPatternOutput.objects.\
            filter(retail_size_id = primarySizeId, is_primary = True,\
            is_for_cradle = conversions.bool_map[isForCradle], retail_cutting_pattern__is_active = True).\
            order_by("retail_cutting_pattern__cutting_instructions","-retail_cutting_pattern__grade")

    patterns = []
    for output in cutting_pattern_outputs:
        quantity = output.quantity
        #get the primary output's family
        output_family = RetailCuttingPatternOutput.objects.\
                        filter(retail_cutting_pattern_id = \
                        output.retail_cutting_pattern.id)
        #check to see if secondarySize is a sibling of output
        secondary_a_sibling = False
        for sibling in output_family:
            if secondarySizeId == '' or int(sibling.retail_size_id) == int(secondarySizeId):
                secondary_a_sibling = True
        
        if secondary_a_sibling:
            output_displays = [OutputDisplay(display.retail_size(\
                           output.retail_size), output.retail_size.id, output.quantity,\
                           'c' if output.is_for_cradle else 'f', output.is_primary)]
            output_displays += [OutputDisplay(display.retail_size(\
                           sibling.retail_size), sibling.retail_size.id, sibling.quantity,\
                           'c' if sibling.is_for_cradle else 'f', sibling.is_primary)
                           for sibling in output_family if sibling.id != output.id]
            patterns.append(CuttingPatternsDisplay\
                    (output_displays, output.retail_cutting_pattern.id, output.retail_cutting_pattern.grade, \
                    display.tercero_size(output.retail_cutting_pattern.coating_size), output.retail_cutting_pattern.coating_size, \
                    format_cutting_pattern(output.retail_cutting_pattern.cutting_instructions, output.retail_cutting_pattern.coating_size),\
                    'n/a' if not primarySizeQuantity else str(int(math.\
                    ceil(float(primarySizeQuantity)/float(output.quantity)))) + ' needed'))
    return patterns
Esempio n. 7
0
def get_tercero_count(coating_id, panel_depth_id):
    entries, sheet_id = retrieve_entries(coating_id, panel_depth_id)
    tercero_list = []
    tercero_dict = {}
    for entry in entries:
        instructions = RetailCuttingSheetInstruction.objects.filter(retail_cutting_sheet_entry_id = entry.id)
        for instruction in instructions:
            grade = instruction.retail_cutting_pattern.grade
            tercero = instruction.retail_cutting_pattern.coating_size_id
            if tercero not in tercero_dict:
                tercero_dict[tercero] = {}
            tercero_dict[tercero][grade] = instruction.quantity if grade not in tercero_dict[tercero] else \
                    tercero_dict[tercero][grade] + instruction.quantity

    for tercero in tercero_dict.iterkeys():
        for grade, quantity in tercero_dict[tercero].iteritems():
            tercero_object = CoatingSize.objects.get(id = tercero)
            tercero_list.append(CuttingSheetTercroRequiredDisplay(display.tercero_size(tercero_object), grade, quantity))

    return tercero_list
Esempio n. 8
0
def ReadById(existing_pattern_id):
    cutting_pattern = RetailCuttingPattern.objects.get(pk=existing_pattern_id)
    outputs = RetailCuttingPatternOutput.objects.filter(
        retail_cutting_pattern_id=existing_pattern_id)
    primary_output = []
    secondary_outputs = []
    for output in outputs:
        retail_size = RetailSize.objects.get(pk=output.retail_size_id)
        if output.is_primary:
            primary_output.append(
                OutputDisplay(retail_size, output.retail_size_id,
                              output.quantity, output.is_for_cradle, True))
        else:
            secondary_outputs.append(
                OutputDisplay(retail_size, output.retail_size_id,
                              output.quantity, output.is_for_cradle, False))
    output_displays = primary_output + secondary_outputs
    pattern_display = CuttingPatternsDisplay(output_displays, existing_pattern_id, cutting_pattern.grade,\
            display.tercero_size(cutting_pattern.coating_size), cutting_pattern.coating_size, cutting_pattern.cutting_instructions, 'n/a')
    return pattern_display
Esempio n. 9
0
def create_cutting_sheet_output(sheet_data, coating_id, panel_depth_id):
    output_list = []
    for instruction, instruction_data in sheet_data.iteritems():
        for coating_size_id, data in instruction_data.iteritems():
            outputs = RetailCuttingPatternOutput.objects.filter(retail_cutting_pattern_id = \
                    data['pattern_id'])
            cutting_pattern = RetailCuttingPattern.objects.get(id = data['pattern_id'])

            outputString = ''
            for output in outputs:
                retail_size_display = display.retail_size(RetailSize.objects.get(id = output.retail_size_id))
                outputString = outputString + retail_size_display + \
                        (' cradled' if output.is_for_cradle else ' flat') + ' (' + str(output.quantity) + '), '

            tercero = CoatingSize.objects.get(id = cutting_pattern.coating_size_id)
            terceroDisplay = ''
            total_tercero_quantity = 0
            for grade, quantity in data.iteritems():
                if grade is not 'pattern_id':
                    terceroDisplay = terceroDisplay +  grade + \
                            ' (' + str(quantity) + '), '
                    total_tercero_quantity = total_tercero_quantity + quantity
            terceroDisplay = display.tercero_size(tercero) + ' (' + str(total_tercero_quantity) + '), Grades: ' + terceroDisplay
            if (len(terceroDisplay) > 2):
                terceroDisplay = terceroDisplay[:(len(terceroDisplay)-2)]
            coating_description = Coating.objects.filter(id = coating_id)[0].description
            panel_depth = PanelDepth.objects.get(id = panel_depth_id)
            instructionIndent = ''
            firstI = cutting_pattern.cutting_instructions.index('I')
            for i in range(0, firstI + 8):
                instructionIndent = instructionIndent + '&nbsp;'
            pattern_display_string = cutting_pattern.cutting_instructions.replace('___', '<br/>' + instructionIndent)
            pattern_display_string = pattern_display_string.replace(' ', '&nbsp')
            pattern_display_string = pattern_display_string.replace('->', '-&gt')
            output_list.append(RetailCuttingSheetFinalInstructionDisplay(coating_description, \
                    display.small_measurement(panel_depth), terceroDisplay, outputString, \
                    pattern_display_string, 0, 33, cutting_pattern.id))
    return output_list
Esempio n. 10
0
def get_tercero_count(coating_id, panel_depth_id):
    entries, sheet_id = retrieve_entries(coating_id, panel_depth_id)
    tercero_list = []
    tercero_dict = {}
    for entry in entries:
        instructions = RetailCuttingSheetInstruction.objects.filter(
            retail_cutting_sheet_entry_id=entry.id)
        for instruction in instructions:
            grade = instruction.retail_cutting_pattern.grade
            tercero = instruction.retail_cutting_pattern.coating_size_id
            if tercero not in tercero_dict:
                tercero_dict[tercero] = {}
            tercero_dict[tercero][grade] = instruction.quantity if grade not in tercero_dict[tercero] else \
                    tercero_dict[tercero][grade] + instruction.quantity

    for tercero in tercero_dict.iterkeys():
        for grade, quantity in tercero_dict[tercero].iteritems():
            tercero_object = CoatingSize.objects.get(id=tercero)
            tercero_list.append(
                CuttingSheetTercroRequiredDisplay(
                    display.tercero_size(tercero_object), grade, quantity))

    return tercero_list