Changeset 2335

Show
Ignore:
Timestamp:
11/05/08 14:58:26 (2 months ago)
Author:
rage
Message:

add change in phonepha branche

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • ecs/packages/ECS/branches/phonepha/utils/billingTools.py

    r2205 r2335  
    2323 
    2424from emencia.ecsdb import getMapping 
     25from emencia.ecsdb.boundtable import BoundTable 
     26from emencia.ecsdb.boundtable import Integer 
     27from emencia.ecsdb.boundtable import String 
     28from emencia.ecsdb.boundtable import Column 
     29from emencia.ecsdb.boundtable import ForeignKey 
     30from emencia.ecsdb.boundtable import Float 
     31from emencia.ecsdb.ecsdb import getConnector 
    2532from pyPgSQL.PgSQL import PgNumeric 
    2633 
     
    4249current_dir = os.path.dirname(__file__) 
    4350 
     51phonepha_vatvalue = BoundTable('vatvalue', getConnector(), 
     52                               Column('vat_idvat', Integer, ForeignKey('vat.id'), 
     53                                      primary_key=True), 
     54                               Column('geographicalarea_idgeographicalarea', 
     55                                      String(15), primary_key=True), 
     56                               Column('value', Float) 
     57                               ) 
     58 
    4459def prepare_data(idcom): 
    4560    """Preparing datas for bill""" 
     
    4964    order = Order({'idcommande' : idcom}) 
    5065    order.reload() 
    51     if order.payment_mode is not None: 
    52         label_payment_mode = "label_payment_mode_%s" % order.payment_mode 
    53     else: 
    54         label_payment_mode = "label_payment_mode_other" 
     66    #if order.payment_mode is not None: 
     67    #    label_payment_mode = "label_payment_mode_%s" % order.payment_mode 
     68    #else: 
     69    #    label_payment_mode = "label_payment_mode_other" 
    5570 
    5671    lang = TranslationManager() 
    57     label_payment_mode = lang.translate(label_payment_mode, 
    58                                         domain='backoffice', 
    59                                         language=language) 
     72    #label_payment_mode = lang.translate(label_payment_mode, 
     73    #                                    domain='backoffice', 
     74    #                                    language=language) 
    6075 
    6176    client = Customer({'idclient' : order.client_idclient}) 
     
    7388    bills = Bill.search(query={'commande_idcommande' : order.idcommande}) 
    7489    bill = None 
    75  
    7690    if bills: 
    7791        # XXX TZ We should not have several commands here 
    7892        # this is a bug 
    7993        bill = bills[0] 
    80         billline = BillLine.search(query={'bill_idbill' : bill['idbill']}) 
    8194    else: 
    82         bill = {'amountbill': order.products['total'], 
    83                 'deliverycostbill': order.products['delivery_price_amount'], 
    84                 'netoftaxbill': order.products['total_net_of_tax'], 
    85                 'datebill': order.datecommande, 
    86                 'referencebill': 'BC'+order.referencecommande, 
    87                 'payed': False, 
    88                 'reductionbill': order.products['total_reduction'], 
    89                 'itemnumberbill': order.products['total_quantity'], 
    90                 'deliverybill': order.delivery_price['libelle_idlibelle_translation'], 
    91                 'adresse_idadresse_livraison': order.adresse_idadresse_livraison, 
    92                 'adresse_idadresse_facturation': order.adresse_idadresse_facturation} 
    93         billline = [] 
    94         for line in order.products['products']: 
    95             line = {'unitpricebillline': line['price'], 
    96                     'quantitybillline': line['quantity'], 
    97                     'referencebillline': line['reference'], 
    98                     'labelbillline': line['libelle_idlibelle_translation'], 
    99                     'amountbillline': line['price'] * line['quantity'], 
    100                     'packagingbillline': line['conditionnement']} 
    101             billline.append(line) 
     95        return None 
    10296 
    10397    # XXX TZ : about the comment above, please explain what is the 
     
    10599 
    106100    # the above code is pretty hugly, but done for now without mapping 
     101    billline = BillLine.search(query={'bill_idbill' : bill['idbill']}) 
    107102    amountart = bill['amountbill'] - bill['deliverycostbill'] 
    108103    bill['taxbill'] = round(amountart - bill['netoftaxbill'], 2) 
    109     bill['label_payment_mode'] = label_payment_mode 
     104    #bill['label_payment_mode'] = label_payment_mode 
    110105    adrs_facts = Adresse.search(query={'idadresse' : 
    111106                                       bill['adresse_idadresse_facturation']}, 
     
    148143    for line in billline: 
    149144        product = ProductBootique.search(query={'reference': line['referencebillline']})[0] 
    150         vat_value = getMapping('vatvalue').select(vat_vat_id=product['vat_idvat'], 
    151                     geographicalzone_geographicalzone_iso=\ 
    152                     billing_country['geographicalzone_geographicalzone_iso'] 
    153                     ).fetchall()[0].value 
    154         if vat_value in total_by_vat: 
    155             total_by_vat[vat_value] += line['unitpricebillline'] * line['quantitybillline'] 
    156         else: 
    157             total_by_vat[vat_value] = line['unitpricebillline'] * line['quantitybillline'] 
    158         line['vat_value'] = vat_value 
    159         line['unitpricehtbillline'] = line['unitpricebillline'] / (1 + vat_value / 100) 
    160         line['amounthtbillline'] = line['unitpricehtbillline'] * line['quantitybillline'] 
    161         if line['packagingbillline'] == '1': 
    162             line['packagingbillline'] = '' 
    163         else: 
    164             line['packagingbillline'] = " - %sg" % line['packagingbillline'] 
     145         
     146        vat_value = phonepha_vatvalue.select(vat_vat_id=product['vat_idvat']).fetchall()[0].value 
     147        line['unitpricehtbillline'] = float(line['unitpricebillline']) / float(((100 + vat_value) / 100)) 
     148        line['amounthtbillline'] = "%.2f" % float(line['unitpricehtbillline'] * line['quantitybillline']) 
     149        line['unitpricehtbillline'] = "%.2f" % line['unitpricehtbillline'] 
     150 
    165151        for key, value in line.iteritems(): 
    166152            if isinstance(value, PgNumeric): 
     
    200186 
    201187    data = prepare_data(idcom) 
     188 
    202189    if data is None: 
    203190        return None, None 
     
    240227    xml['amountbill'] = "%.2f" % float(data['amountart'] + xml['deliverycostbill']) 
    241228    xml['lines'] = data['billline'] 
    242     xml['by_vat'] = data['by_vat'] 
     229 
     230    #xml['netoftaxbill'] = round(xml['netoftaxbill'], 2) 
     231 
    243232    xml['amounttax'] = xml['taxbill'] 
    244233    xml['customer_id'] = data['client'].idclient 
  • ecs/packages/ECS/branches/phonepha/utils/templates/Billing_pdf.pt

    r1908 r2335  
    174174          <pageGraphics> 
    175175            <image x="5mm" y="260mm" file="logo.jpg" width="300mm" height="30mm" /> 
    176             <drawCentredString x="100mm" y="1cm">AZSPORTS</drawCentredString> 
    177             <drawCentredString x="100mm" y="0.6cm">63 bd de ménilmontant - 75011 Paris</drawCentredString> 
    178             <drawCentredString x="100mm" y="0.1cm">Tél : 01 48 07 33 00 - SIRET : 443 005 103 00025</drawCentredString> 
     176            <drawCentredString x="100mm" y="1cm">TFT Souve, 71190 Thil France</drawCentredString> 
     177            <drawCentredString x="100mm" y="0.6cm">SIRET : 500 554 019</drawCentredString> 
     178            <drawCentredString x="100mm" y="0.1cm">TVA : FR25500554019</drawCentredString> 
    179179          </pageGraphics> 
    180180 
     
    195195        <pageTemplate id="others"> 
    196196          <pageGraphics> 
    197             <drawCentredString x="100mm" y="2cm">AZSPORTS</drawCentredString> 
    198             <drawCentredString x="100mm" y="1.5cm">63 bd de ménilmontant - 75011 Paris</drawCentredString> 
    199             <drawCentredString x="100mm" y="0.5cm">Tél : 01 48 07 33 11 - SIRET : 443 005 103 00025</drawCentredString> 
     197            <drawCentredString x="100mm" y="2cm">TFT Souve, 71190 Thil France</drawCentredString> 
     198            <drawCentredString x="100mm" y="1.5cm">SIRET : 500 554 019</drawCentredString> 
     199            <drawCentredString x="100mm" y="0.5cm">TVA : FR25500554019</drawCentredString> 
    200200          </pageGraphics> 
    201201          <frame id="products" x1="2mm" y1="2.5cm" width="20cm"