===== Development Note ===== ===== Order Source Check ===== This technical note is written for developers, to help them solve the question of identifying the different sources of invoices/orders for the application of a partner discount. The discount must check that the current transaction falls into one of the following cases, and activate itself if the settings allow it: ==== Purchase orders "brought" by a partner through cart pre-filling: code E ==== Any invoice/transaction (local_shop\Bill object) is considered a "brought" invoice if: * The invoice "customerid" account is not the partner account associated in the local_shop\Partner object * The local_shop\Bill object is tagged (bill->record->partnerkey) with the partner key. ==== Purchase orders created under the partner customer account: code I ==== Invoices/transactions created under the partner's customer account only have to check one condition: being associated with a customerid matching the customerid associated with the Partner. Consistency is therefore needed between: Partner->customerid and Bill->customerid, ==== Purchase orders auto-generated for the partner (product activation): code A ==== Auto-generated purchase orders are invoices/purchase orders (local_shop/Bill) in which one of the order items is a product associated with a handler of type "registered_product". As the condition is rather indirect, it should be examined how it could be made more explicit. The invoice/order must also be associated with the customer "customerid" associated with the Partner object. Consistency is therefore needed between: Partner->customerid, Bill->customerid, and it must be checked that one of the products (BillItem) is of type "registered_product". In the current state of the shop, only automated transactions can buy products of type "registered_product" [[:local:shop:structure:discounts:partner|Back]]