Commit 2833b15a authored by Patrick's avatar Patrick
Browse files

More readable lists when orders are closed

parent a7bdd2db
# -*- coding: utf-8 -*-
from repanier.const import *
from django.conf import settings
from repanier.const import *
from django.core.mail import EmailMultiAlternatives
from django.utils.html import strip_tags
from django.utils import translation
from django.utils.translation import ugettext_lazy as _
from parler.models import TranslationDoesNotExist
from repanier.models import Permanence
......@@ -11,6 +12,7 @@ from repanier.tools import *
def send(permanence_id, current_site_name):
translation.activate(settings.LANGUAGES[0][0])
permanence = Permanence.objects.get(id=permanence_id)
sender_email = settings.DEFAULT_FROM_EMAIL
sender_function = ""
......
# -*- coding: utf-8 -*-
from repanier.const import *
from django.conf import settings
from repanier.const import *
from django.utils import translation
from django.core.mail import EmailMultiAlternatives
from django.utils.html import strip_tags
from django.utils.translation import ugettext_lazy as _
......@@ -12,9 +13,10 @@ from repanier.models import Producer
from repanier.models import Staff
from repanier.tools import *
from repanier.xslx import xslx_order
from repanier.settings import *
def send(permanence_id, current_site_name):
translation.activate(settings.LANGUAGES[0][0])
permanence = Permanence.objects.get(id=permanence_id)
filename = (unicode(_("Order")) + u" - " + permanence.__unicode__() + u'.xlsx').encode('ascii',
errors='replace').replace(
......@@ -42,7 +44,10 @@ def send(permanence_id, current_site_name):
board_message = ""
first_board = True
for permanenceboard in PermanenceBoard.objects.filter(
permanence=permanence_id):
permanence=permanence_id).order_by(
"permanence_role__tree_id",
"permanence_role__lft"
):
r_part = ''
m_part = ''
r = permanenceboard.permanence_role
......@@ -53,9 +58,9 @@ def send(permanence_id, current_site_name):
c = permanenceboard.customer
if c:
if c.phone2:
c_part = c.long_basket_name + ',<b>' + c.phone1 + ',' + c.phone2 + '</b>'
c_part = c.long_basket_name + ', <b>' + c.phone1 + '</b>, <b>' + c.phone2 + '</b>'
else:
c_part = c.long_basket_name + ',<b>' + c.phone1 + '</b>'
c_part = c.long_basket_name + ', <b>' + c.phone1 + '</b>'
if first_board:
board_composition += '<br/>'
board_composition += c_part + '<br/>'
......@@ -66,14 +71,14 @@ def send(permanence_id, current_site_name):
permanence=permanence_id).order_by()
for producer in producer_set:
if producer.email.upper().find("NO-SPAM.WS") < 0:
translation.activate(producer.language)
wb = xslx_order.export_producer(permanence=permanence, producer=producer, wb=None)
if wb is not None:
long_profile_name = producer.long_profile_name if producer.long_profile_name is not None else producer.short_profile_name
html_content = unicode(_('Dear')) + " " + long_profile_name + ",<br/><br/>" + unicode(
_('In attachment, you will find the detail of our order for the')) + \
" " + unicode(permanence) + ".<br/><br/>" + unicode(
_('In case of impediment for delivering the order, please advertise the preparation team :')) + \
"<br/>" + board_composition + \
_('In case of impediment for delivering the order, please advertise me :')) + \
"<br/><br/>" + signature + \
"<br/>" + sender_function + \
"<br/>" + current_site_name
......@@ -100,17 +105,24 @@ def send(permanence_id, current_site_name):
customer_set = Customer.objects.filter(
purchase__permanence=permanence_id, represent_this_buyinggroup=False).order_by().distinct()
for customer in customer_set:
wb = xslx_order.export_customer(permanence=permanence, customer=customer, wb=None)
translation.activate(customer.language)
order_amount, wb = xslx_order.export_customer(permanence=permanence, customer=customer, wb=None)
if wb is not None:
long_basket_name = customer.long_basket_name if customer.long_basket_name is not None else customer.short_baskrt_name
long_basket_name = customer.long_basket_name if customer.long_basket_name is not None else customer.short_basket_name
html_content = unicode(_('Dear')) + " " + long_basket_name + ",<br/><br/>" + unicode(
_('In attachment, you will find the detail of your order for the')) + \
" " + unicode(permanence) + ".<br/><br/>" + unicode(
_('In case of impediment for keeping your basket, please advertise the preparation team :')) + \
"<br/><br/>" + board_composition + \
"<br/><br/>" + signature + \
"<br/>" + sender_function + \
"<br/>" + current_site_name
" " + unicode(permanence) + ".<br/><br/>" + \
unicode(_('The balance of your account as of ')) + customer.date_balance.strftime('%d-%m-%Y') + \
unicode(_(' is ')) + number_format(customer.balance, 2) + ' &euro;<br/>' + \
unicode(_('The amount of your order is ')) + number_format(order_amount, 2) + ' &euro;<br/>' + \
unicode(_('Please pay ')) + number_format(order_amount - customer.balance, 2) + ' &euro; ' + \
unicode(_('to the bank account number ')) + REPANIER_BANK_ACCOUNT + \
unicode(_(' with communication ')) + customer.short_basket_name + ", " + unicode(permanence) + \
".<br/><br/>" + unicode(
_('In case of impediment for keeping your basket, please advertise me :')) + \
"<br/><br/>" + signature + \
"<br/>" + sender_function + \
"<br/>" + current_site_name
email = EmailMultiAlternatives(
unicode(_("Order")) + " - " + unicode(
permanence) + " - " + current_site_name + " - " + long_basket_name,
......@@ -132,6 +144,7 @@ def send(permanence_id, current_site_name):
wb = xslx_order.export(permanence=permanence, wb=None)
if wb is not None:
translation.activate(settings.LANGUAGES[0][0])
to_email_board = []
for permanenceboard in PermanenceBoard.objects.filter(
permanence=permanence_id).order_by():
......
This diff is collapsed.
......@@ -8,4 +8,5 @@ REPANIER_PERMANENCES_NAME = _("Closures")
# REPANIER_PERMANENCE_ON_NAME = _("Permanence on ")
REPANIER_PERMANENCE_ON_NAME = _("Closure on ")
REPANIER_DISPLAY_PRODUCERS_ON_ORDER_FORM = False
\ No newline at end of file
REPANIER_DISPLAY_PRODUCERS_ON_ORDER_FORM = False
REPANIER_BANK_ACCOUNT = "BE42 7506 5967 6954"
\ No newline at end of file
# -*- coding: utf-8 -*-
from django.conf import settings
from django.contrib import messages
from django.contrib.sites.models import get_current_site
from django.contrib.sites.models import Site
......@@ -20,8 +21,8 @@ from repanier.models import Permanence
from repanier.models import Producer
from repanier.models import Product
from repanier.models import Purchase
from repanier.tools import *
from repanier.tools import recalculate_order_amount
from repanier.tools import update_or_create_purchase
import thread
......
......@@ -98,7 +98,8 @@ def get_producer_unit(order_unit=PRODUCT_ORDER_UNIT_PC, qty=0):
def get_preparator_unit(order_unit=PRODUCT_ORDER_UNIT_PC, qty=0):
# Used when producing the preparation list.
if order_unit in [PRODUCT_ORDER_UNIT_PC, PRODUCT_ORDER_UNIT_PC_PRICE_KG, PRODUCT_ORDER_UNIT_PC_PRICE_LT, PRODUCT_ORDER_UNIT_PC_PRICE_PC]:
if order_unit in [PRODUCT_ORDER_UNIT_PC, PRODUCT_ORDER_UNIT_PC_PRICE_KG, PRODUCT_ORDER_UNIT_PC_PRICE_LT,
PRODUCT_ORDER_UNIT_PC_PRICE_PC]:
unit = unicode(_("Piece(s) :"))
elif order_unit in [PRODUCT_ORDER_UNIT_KG, PRODUCT_ORDER_UNIT_PC_KG]:
unit = unicode(_(u"€ or kg :"))
......@@ -109,8 +110,15 @@ def get_preparator_unit(order_unit=PRODUCT_ORDER_UNIT_PC, qty=0):
return unit
def get_display(qty=0, order_average_weight=0, order_unit=PRODUCT_ORDER_UNIT_PC, price=None):
unit = unicode(_(' pieces'))
def get_display(qty=0, order_average_weight=0, order_unit=PRODUCT_ORDER_UNIT_PC, price=None,
for_customer=True):
if for_customer:
if qty < 2:
unit = unicode(_(' piece'))
else:
unit = unicode(_(' pieces'))
else:
unit = " (" + unicode(_(' piece')) + " )"
magnitude = 1
if order_unit == PRODUCT_ORDER_UNIT_KG:
if qty < 1:
......@@ -125,7 +133,9 @@ def get_display(qty=0, order_average_weight=0, order_unit=PRODUCT_ORDER_UNIT_PC,
else:
unit = unicode(_(' l'))
elif order_unit in [PRODUCT_ORDER_UNIT_PC_KG, PRODUCT_ORDER_UNIT_PC_PRICE_KG]:
average_weight = order_average_weight * qty
average_weight = order_average_weight
if for_customer:
average_weight *= qty
if order_unit == PRODUCT_ORDER_UNIT_PC_KG and price is not None:
price *= order_average_weight
if average_weight < 1:
......@@ -143,12 +153,20 @@ def get_display(qty=0, order_average_weight=0, order_unit=PRODUCT_ORDER_UNIT_PC,
tilde = ''
if order_unit == PRODUCT_ORDER_UNIT_PC_KG:
tilde = '~'
if qty < 2:
unit = unicode(_(' piece')) + ' (' + tilde + number_format(average_weight, decimal) + average_weight_unit + ')'
if for_customer:
if qty < 2:
unit = unicode(_(' piece')) + ' (' + tilde + number_format(average_weight, decimal) + average_weight_unit + ')'
else:
unit = unicode(_(' pieces')) + ' (' + tilde + number_format(average_weight, decimal) + average_weight_unit + ')'
else:
unit = unicode(_(' pieces')) + ' (' + tilde + number_format(average_weight, decimal) + average_weight_unit + ')'
if qty < 2:
unit = ' (' + tilde + number_format(average_weight, decimal) + average_weight_unit + ')'
else:
unit = ' (' + tilde + number_format(average_weight, decimal) + average_weight_unit + ')'
elif order_unit == PRODUCT_ORDER_UNIT_PC_PRICE_LT:
average_weight = order_average_weight * qty
average_weight = order_average_weight
if for_customer:
average_weight *= qty
if average_weight < 1:
average_weight_unit = unicode(_(' cl'))
average_weight *= 100
......@@ -161,19 +179,29 @@ def get_display(qty=0, order_average_weight=0, order_unit=PRODUCT_ORDER_UNIT_PC,
decimal = 1
elif average_weight * 100 == int(average_weight * 100):
decimal = 2
if qty < 2:
unit = unicode(_(' piece')) + ' (' + number_format(average_weight, decimal) + average_weight_unit + ')'
if for_customer:
if qty < 2:
unit = unicode(_(' piece')) + ' (' + number_format(average_weight, decimal) + average_weight_unit + ')'
else:
unit = unicode(_(' pieces')) + ' (' + number_format(average_weight, decimal) + average_weight_unit + ')'
else:
unit = unicode(_(' pieces')) + ' (' + number_format(average_weight, decimal) + average_weight_unit + ')'
if qty < 2:
unit = ' (' + number_format(average_weight, decimal) + average_weight_unit + ')'
else:
unit = ' (' + number_format(average_weight, decimal) + average_weight_unit + ')'
elif order_unit == PRODUCT_ORDER_UNIT_PC_PRICE_PC:
average_weight = order_average_weight * qty
if average_weight < 2:
unit = unicode(_(' piece')) + ' (' + number_format(average_weight, 0) + unicode(_(' pc')) + ')'
average_weight = order_average_weight
if for_customer:
average_weight *= qty
if average_weight < 2:
unit = unicode(_(' piece')) + ' (' + number_format(average_weight, 0) + unicode(_(' pc')) + ')'
else:
unit = unicode(_(' pieces')) + ' (' + number_format(average_weight, 0) + unicode(_(' pcs')) + ')'
else:
unit = unicode(_(' pieces')) + ' (' + number_format(average_weight, 0) + unicode(_(' pcs')) + ')'
else:
if qty < 2:
unit = unicode(_(' piece'))
if average_weight < 2:
unit = ' (' + number_format(average_weight, 0) + unicode(_(' pc')) + ')'
else:
unit = ' (' + number_format(average_weight, 0) + unicode(_(' pcs')) + ')'
qty *= magnitude
decimal = 3
if qty == int(qty):
......@@ -182,7 +210,10 @@ def get_display(qty=0, order_average_weight=0, order_unit=PRODUCT_ORDER_UNIT_PC,
decimal = 1
elif qty * 100 == int(qty * 100):
decimal = 2
qty_display = number_format(qty, decimal) + unit
if for_customer:
qty_display = number_format(qty, decimal) + unit
else:
qty_display = unit
if price is not None:
price = (price * qty).quantize(TWO_DECIMALS)
price_display = " = " + number_format(price, 2)
......
......@@ -489,7 +489,9 @@ class PermanenceView(ListView):
distribution_date__gte=now,
permanence__status__lte=PERMANENCE_WAIT_FOR_SEND
).order_by(
"distribution_date", "permanence", "permanence_role"
"distribution_date", "permanence",
"permanence_role__tree_id",
"permanence_role__lft"
)
return qs
......
# -*- coding: utf-8 -*-
from django.conf import settings
from django.utils.translation import ugettext_lazy as _
from django.utils import translation
from django.http import HttpResponse
......@@ -16,13 +17,11 @@ from repanier.models import Producer
from repanier.models import Purchase
from repanier.models import Staff
from repanier.tools import get_producer_unit
from repanier.tools import get_customer_unit
from repanier.tools import get_preparator_unit
from repanier.tools import get_display
def export(permanence, wb=None):
translation.activate("fr")
translation.activate(settings.LANGUAGES[0][0])
if wb is None:
wb = Workbook()
ws = wb.get_active_sheet()
......@@ -144,16 +143,16 @@ def export(permanence, wb=None):
if row_num > 0:
ws.column_dimensions[get_column_letter(1)].width = 120
# if PERMANENCE_WAIT_FOR_SEND <= permanence.status <= PERMANENCE_SEND:
if PERMANENCE_OPENED <= permanence.status <= PERMANENCE_SEND:
# Basket check list, by customer
ws = export_customer(permanence, wb=wb)
wb = export_customer(permanence, wb=wb)
# if PERMANENCE_OPENED <= permanence.status <= PERMANENCE_SEND:
if PERMANENCE_OPENED <= permanence.status <= PERMANENCE_SEND:
# # Order adressed to our producers,
# producer_set = Producer.objects.filter(permanence=permanence).order_by("short_profile_name")
# for producer in producer_set:
# export_producer(permanence=permanence, producer=producer, wb=wb)
producer_set = Producer.objects.filter(permanence=permanence).order_by("short_profile_name")
for producer in producer_set:
wb = export_producer(permanence=permanence, producer=producer, wb=wb)
return wb
......@@ -169,23 +168,22 @@ def export_producer(permanence, producer, wb=None):
long_name_save = None
unit_price_save = 0
unit_deposit_save = 0
total_price_sum = 0
total_price_sum_sum = 0
row_start_sum_sum = 0
total_price_sum_sum_sum = 0
formula_sum_sum_sum = []
hide_column_short_basket_name = True
hide_column_unit_deposit = True
unit_save = None
hide_column_unit = True
translation.activate(producer.language)
purchase_set = Purchase.objects.filter(
permanence_id=permanence.id, producer_id=producer.id,
order_unit__lte=PRODUCT_ORDER_UNIT_DEPOSIT
order_unit__lte=PRODUCT_ORDER_UNIT_DEPOSIT,
product__translations__language_code=translation.get_language()
).exclude(quantity=0
).order_by(
"department_for_customer",
"long_name",
"department_for_customer__tree_id",
"department_for_customer__lft",
"product__translations__long_name",
"customer__short_basket_name"
)
for purchase in purchase_set:
......@@ -198,28 +196,24 @@ def export_producer(permanence, producer, wb=None):
ws = wb.create_sheet()
worksheet_setup_landscape_a4(ws, unicode(producer.short_profile_name) + unicode(_(" by product")),
unicode(permanence))
short_basket_name = ""
if long_name_save != purchase.long_name:
product_bold = True
row_start_sum = row_num
if department_for_customer_save != purchase.department_for_customer_id:
if department_for_customer_short_name_save is not None:
row_num += 1
for col_num in xrange(7):
for col_num in xrange(6):
c = ws.cell(row=row_num, column=col_num)
c.style.borders.bottom.border_style = Border.BORDER_THIN
if col_num == 2:
c.value = unicode(_("Total Price")) + " " + department_for_customer_short_name_save
c.style.number_format.format_code = NumberFormat.FORMAT_TEXT
if col_num == 6:
formula = 'SUM(G%s:G%s)' % (row_start_sum_sum + 3, row_num)
if col_num == 5:
formula = 'SUM(F%s:F%s)' % (row_start_sum_sum + 3, row_num)
c.value = '=' + formula
formula_sum_sum_sum.append(formula)
c.style.number_format.format_code = u'_ € * #,##0.00_ ;_ € * -#,##0.00_ ;_ € * "-"??_ ;_ @_ '
c.style.font.bold = True
total_price_sum_sum = 0
row_start_sum_sum = row_num
department_for_customer_save = purchase.department_for_customer_id
if purchase.department_for_customer is not None:
......@@ -248,7 +242,6 @@ def export_producer(permanence, producer, wb=None):
short_basket_name = current_site_name
qty_sum = 0
total_price_sum = 0
row_inc = 1
else:
......@@ -261,7 +254,6 @@ def export_producer(permanence, producer, wb=None):
short_basket_name = purchase.customer.short_basket_name
hide_column_short_basket_name = False
qty_sum = 0
total_price_sum = 0
row_inc = 1
else:
short_basket_name = current_site_name
......@@ -269,27 +261,26 @@ def export_producer(permanence, producer, wb=None):
qty = purchase.quantity if permanence.status < PERMANENCE_WAIT_FOR_SEND else purchase.quantity_send_to_producer
qty_sum += qty
unit_sum = get_producer_unit(order_unit=purchase.order_unit, qty=qty_sum)
a_price = (purchase.original_unit_price + purchase.unit_deposit) * qty_sum
qty_display, price_display, price = get_display(
qty_sum,
purchase.order_average_weight,
purchase.order_unit,
a_price,
False
)
if unit_save is None:
unit_save = purchase.order_unit
else:
if purchase.order_unit in [PRODUCT_ORDER_UNIT_KG, PRODUCT_ORDER_UNIT_LT]:
hide_column_unit = False
# if purchase.order_unit not in [PRODUCT_ORDER_UNIT_LOOSE_PC_KG, PRODUCT_ORDER_UNIT_NAMED_PC_KG]:
total_price_sum += purchase.original_price
total_price_sum_sum += purchase.original_price
total_price_sum_sum_sum += purchase.original_price
row = [
(unicode(_("Basket")), 20, short_basket_name, NumberFormat.FORMAT_TEXT, False),
(unicode(_("Quantity")), 10, qty_sum, '#,##0.???', True),
(unicode(_("Unit")), 12, unit_sum, NumberFormat.FORMAT_TEXT, False),
(unicode(_("Product")), 60, long_name_save, NumberFormat.FORMAT_TEXT, product_bold),
(unicode(_("Product")), 60, long_name_save + qty_display, NumberFormat.FORMAT_TEXT, product_bold),
(unicode(_("Unit Price")), 10, unit_price_save, u'_ € * #,##0.00_ ;_ € * -#,##0.00_ ;_ € * "-"??_ ;_ @_ ',
False),
(unicode(_("Deposit")), 10, unit_deposit_save, u'_ € * #,##0.00_ ;_ € * -#,##0.00_ ;_ € * "-"??_ ;_ @_ ',
False),
(unicode(_("Total Price")), 12, total_price_sum, u'_ € * #,##0.00_ ;_ € * -#,##0.00_ ;_ € * "-"??_ ;_ @_ ',
(unicode(_("Total Price")), 12, a_price, u'_ € * #,##0.00_ ;_ € * -#,##0.00_ ;_ € * "-"??_ ;_ @_ ',
False)
]
......@@ -309,13 +300,11 @@ def export_producer(permanence, producer, wb=None):
if ws is not None:
if hide_column_unit_deposit:
ws.column_dimensions[get_column_letter(6)].visible = False
if hide_column_unit:
ws.column_dimensions[get_column_letter(3)].visible = False
ws.column_dimensions[get_column_letter(5)].visible = False
if hide_column_short_basket_name:
ws.column_dimensions[get_column_letter(1)].visible = False
row_num += 1
for col_num in xrange(7):
for col_num in xrange(6):
c = ws.cell(row=row_num, column=col_num)
c.style.borders.bottom.border_style = Border.BORDER_THIN
if col_num == 2:
......@@ -324,20 +313,20 @@ def export_producer(permanence, producer, wb=None):
else:
c.value = unicode(_("Total Price"))
c.style.number_format.format_code = NumberFormat.FORMAT_TEXT
if col_num == 6:
formula = 'SUM(G%s:G%s)' % (row_start_sum_sum + 3, row_num)
if col_num == 5:
formula = 'SUM(F%s:F%s)' % (row_start_sum_sum + 3, row_num)
c.value = '=' + formula
formula_sum_sum_sum.append(formula)
c.style.number_format.format_code = u'_ € * #,##0.00_ ;_ € * -#,##0.00_ ;_ € * "-"??_ ;_ @_ '
c.style.font.bold = True
row_num += 1
for col_num in xrange(7):
for col_num in xrange(6):
c = ws.cell(row=row_num, column=col_num)
c.style.borders.bottom.border_style = Border.BORDER_THIN
if col_num == 1:
c.value = unicode(_("Total Price")) + " " + current_site_name
c.style.number_format.format_code = NumberFormat.FORMAT_TEXT
if col_num == 6:
if col_num == 5:
c.value = "=" + "+".join(formula_sum_sum_sum)
c.style.number_format.format_code = u'_ € * #,##0.00_ ;_ € * -#,##0.00_ ;_ € * "-"??_ ;_ @_ '
c.style.font.bold = True
......@@ -347,22 +336,21 @@ def export_producer(permanence, producer, wb=None):
department_for_customer_save = None
basket_save = None
total_price_sum = 0
row_start_sum = 0
total_price_sum_sum = 0
formula_sum_sum = []
hide_column_unit_deposit = True
unit_save = None
hide_column_unit = True
purchase_set = Purchase.objects.filter(
permanence_id=permanence.id, producer_id=producer.id,
order_unit__lte=PRODUCT_ORDER_UNIT_DEPOSIT
order_unit__lte=PRODUCT_ORDER_UNIT_DEPOSIT,
product__translations__language_code=translation.get_language()
).exclude(quantity=0
).order_by(
"customer__short_basket_name",
"department_for_customer",
"long_name"
"department_for_customer__tree_id",
"department_for_customer__lft",
"product__translations__long_name"
)
for purchase in purchase_set:
......@@ -380,49 +368,44 @@ def export_producer(permanence, producer, wb=None):
if basket_save is not None:
c = ws.cell(row=row_num, column=2)
c.value = unicode(_("Total Price")) + " " + basket_save
c = ws.cell(row=row_num, column=6)
formula = 'SUM(G%s:G%s)' % (row_start_sum + 2, row_num)
c = ws.cell(row=row_num, column=5)
formula = 'SUM(F%s:F%s)' % (row_start_sum + 2, row_num)
c.value = '=' + formula
formula_sum_sum.append(formula)
c.style.number_format.format_code = u'_ € * #,##0.00_ ;_ € * -#,##0.00_ ;_ € * "-"??_ ;_ @_ '
c.style.font.bold = True
row_start_sum = row_num
total_price_sum = 0
row_num += 1
basket_save = purchase.customer.short_basket_name
else:
basket_bold = False
if unit_deposit_save != 0:
if purchase.unit_deposit != 0:
hide_column_unit_deposit = False
# if purchase.order_unit not in [PRODUCT_ORDER_UNIT_LOOSE_PC_KG, PRODUCT_ORDER_UNIT_NAMED_PC_KG]:
total_price = purchase.original_price
total_price_sum += purchase.original_price
total_price_sum_sum += purchase.original_price
# else:
# total_price = 0
qty = purchase.quantity if permanence.status < PERMANENCE_WAIT_FOR_SEND else purchase.quantity_send_to_producer
unit = get_producer_unit(order_unit=purchase.order_unit, qty=qty)
a_price = ( purchase.original_unit_price + purchase.unit_deposit ) * qty
qty_display, price_display, price = get_display(
qty,
purchase.order_average_weight,
purchase.order_unit,
0,
False
)
if unit_save is None:
unit_save = purchase.order_unit
else:
if (purchase.order_unit != unit_save and purchase.order_unit < PRODUCT_ORDER_UNIT_DEPOSIT) or (
purchase.order_unit == PRODUCT_ORDER_UNIT_KG):
hide_column_unit = False
row = [
(unicode(_("Basket")), 20, purchase.customer.short_basket_name, NumberFormat.FORMAT_TEXT, basket_bold),
(unicode(_("Quantity")), 10, qty, '#,##0.???', True),
(unicode(_("Unit")), 12, unit, NumberFormat.FORMAT_TEXT, False),
(unicode(_("Product")), 60, purchase.long_name, NumberFormat.FORMAT_TEXT, True),
(unicode(_("Product")), 60, purchase.long_name + qty_display, NumberFormat.FORMAT_TEXT, True),
(unicode(_("Unit Price")), 10, purchase.original_unit_price,
u'_ € * #,##0.00_ ;_ € * -#,##0.00_ ;_ € * "-"??_ ;_ @_ ', False),
(unicode(_("Deposit")), 10, unit_deposit_save, u'_ € * #,##0.00_ ;_ € * -#,##0.00_ ;_ € * "-"??_ ;_ @_ ',
(unicode(_("Deposit")), 10, purchase.unit_deposit, u'_ € * #,##0.00_ ;_ € * -#,##0.00_ ;_ € * "-"??_ ;_ @_ ',
False),
(unicode(_("Total Price")), 12, total_price, u'_ € * #,##0.00_ ;_ € * -#,##0.00_ ;_ € * "-"??_ ;_ @_ ',
(unicode(_("Total Price")), 12, a_price, u'_ € * #,##0.00_ ;_ € * -#,##0.00_ ;_ € * "-"??_ ;_ @_ ',
False)
]
......@@ -455,27 +438,23 @@ def export_producer(permanence, producer, wb=None):
if ws is not None:
if hide_column_unit_deposit:
ws.column_dimensions[get_column_letter(6)].visible = False
if hide_column_unit:
ws.column_dimensions[get_column_letter(3)].visible = False
ws.column_dimensions[get_column_letter(5)].visible = False
c = ws.cell(row=row_num, column=2)
c.value = unicode(_("Total Price")) + " " + basket_save
c = ws.cell(row=row_num, column=6)
formula = 'SUM(G%s:G%s)' % (row_start_sum + 2, row_num)
c = ws.cell(row=row_num, column=5)
formula = 'SUM(F%s:F%s)' % (row_start_sum + 2, row_num)
c.value = '=' + formula
formula_sum_sum.append(formula)
c.style.number_format.format_code = u'_ € * #,##0.00_ ;_ € * -#,##0.00_ ;_ € * "-"??_ ;_ @_ '
c.style.font.bold = True
row_num += 1
for col_num in xrange(7):
for col_num in xrange(6):
c = ws.cell(row=row_num, column=col_num)
c.style.borders.top.border_style = Border.BORDER_THIN
c.style.borders.bottom.border_style = Border.BORDER_THIN
if col_num == 1:
c.value = unicode(_("Total Price")) + " " + current_site_name
# c.style.font.bold = True
if col_num == 6:
# c.value = total_price_sum_sum
if col_num == 5:
c.value = "=" + "+".join(formula_sum_sum)
c.style.number_format.format_code = u'_ € * #,##0.00_ ;_ € * -#,##0.00_ ;_ € * "-"??_ ;_ @_ '
c.style.font.bold = True
......@@ -484,18 +463,9 @@ def export_producer(permanence, producer, wb=None):
def export_customer(permanence, customer=None, wb=None):
if wb is None:
wb = Workbook()
ws = wb.</