| | |
| | | data.put('accountid', accountid); |
| | | data.put('invoiceOrderRecoedschange',invoiceOrderRecoedschange); |
| | | data.put('attachmentRecoeds',attachmentRecoeds); |
| | | data.put('outOrderStringList',outOrderStringList); |
| | | data.put('outordercountMap',outordercountMap); |
| | | res.status = 'Success'; |
| | | res.code = 200; |
| | | System.debug('res = ' + res); |
| | |
| | | @AuraEnabled |
| | | public static ResponseBodyLWC save( |
| | | Consumable_order__c cocLwc, |
| | | String HospitalNameLwc, |
| | | String HospitalInfoLwc, |
| | | String SecondDealerLwc, |
| | | String invoiceOrderRecoedsLwc, |
| | |
| | | String reopenLwc, |
| | | String invoiceOrderRecoedschangeLwc |
| | | ) { |
| | | System.debug('enter LexConInvoiceViewController success'); |
| | | System.debug('enter LexConInvoiceViewController.save success'); |
| | | ResponseBodyLWC res = new ResponseBodyLWC(); |
| | | Map<String, object> data = new Map<String, object>(); |
| | | res.entity = data; |
| | | |
| | | coc = cocLwc; |
| | | HospitalName = HospitalNameLwc; |
| | | HospitalInfo = HospitalInfoLwc; |
| | | System.debug('HospitalInfo = ' + HospitalInfo); |
| | | SecondDealer = SecondDealerLwc; |
| | | errorMsg = ''; |
| | | deliveryId = deliveryIdLwc; |
| | | invoiceOrderRecoeds = (List<InvoiceOrderInfo>)JSON.deserialize(invoiceOrderRecoedsLwc, List<InvoiceOrderInfo>.class); |
| | | invoiceId = invoiceIdLwc; |
| | | accountid = accountidLwc; |
| | | agencyProType = agencyProTypeLwc; |
| | | reopen = reopenLwc; |
| | | invoiceOrderRecoedschange = (List<InvoiceOrderInfo>)JSON.deserialize(invoiceOrderRecoedschangeLwc, List<InvoiceOrderInfo>.class); |
| | | |
| | | List<String> chukudanID = new List<String>(); |
| | |
| | | // return null; |
| | | return new ResponseBodyLWC('Error', 500, '请录入发票日期。', ''); |
| | | } |
| | | if (String.isBlank(HospitalInfo) && SecondDealer == null) { |
| | | if (String.isBlank(HospitalInfo) && String.isBlank(SecondDealer)) { |
| | | // coc.addError('必须输入客户名或者二级经销商。'); |
| | | // return null; |
| | | return new ResponseBodyLWC('Error', 500, '必须输入客户名或者二级经销商。', ''); |
| | |
| | | upsert invoiceLinkList; |
| | | } |
| | | } else if (String.isNotBlank(reopen) && reopen.equals('isreopen') && String.isNotBlank(invoiceId)) { |
| | | System.debug('进入reopen'); |
| | | invoiceHead.Name = coc.Name; |
| | | invoiceHead.Order_type__c = '发票'; |
| | | invoiceHead.Invoice_Date__c = coc.Invoice_Date__c; |
| | |
| | | } |
| | | invoiceHead.Order_ForDealerText__c = coc.Order_ForDealerText__c; |
| | | insert invoiceHead; |
| | | System.debug('invoiceHead = ' + invoiceHead); |
| | | |
| | | List<String> updateChukudanId = new List<String>(); |
| | | //获取原发票相关联的链接表信息 |
| | |
| | | colc.Invoice_Code_link__c = invoiceHead.Id; |
| | | updateChukudanId.add(colc.Outboundorder_Code_link__c); |
| | | } |
| | | System.debug('tLinkList = ' + tLinkList); |
| | | update tLinkList; |
| | | //更新发票明细信息 |
| | | //获取出库单,设置关联关系 |
| | |
| | | cocTemp.Consumable_order__c = invoiceHead.Id; |
| | | tempCocMap.put(cocTemp.Invoicedet1_OD_link__c + cocTemp.Asset_Model_No__c, cocTemp); |
| | | } |
| | | System.debug('tempCountList = ' + tempCountList); |
| | | update tempCountList; |
| | | List<Consumable_Orderdetails__c> updateFromList = [ |
| | | SELECT |
| | |
| | | |
| | | Consumable_order__c tempcoc = new Consumable_order__c(); |
| | | tempcoc.Id = invoiceId; |
| | | System.debug('tempcoc = ' + tempcoc); |
| | | delete tempcoc; |
| | | invoiceId = invoiceHead.Id; |
| | | System.debug('updateFromList = ' + updateFromList); |
| | | update updateFromList; |
| | | //-------------------------------------------------------------------------- |
| | | for (InvoiceOrderInfo ass : invoiceOrderRecoeds) { |
| | |
| | | invoiceLinkList.add(invoiceLink); |
| | | } |
| | | } |
| | | System.debug('invoiceLinkList = ' + invoiceLinkList); |
| | | upsert invoiceLinkList; |
| | | } |
| | | //删除出库单链接表 |
| | |
| | | invoiceLinkdetList.add(colctemp); |
| | | } |
| | | } |
| | | System.debug('invoiceLinkdetList = ' + invoiceLinkdetList); |
| | | delete invoiceLinkdetList; |
| | | } |
| | | //新建发票明细1 |
| | |
| | | } else { |
| | | invoiceHead.Order_ForHospital__c = null; |
| | | } |
| | | invoiceHead.Order_ForDealer__c = SecondDealer; |
| | | invoiceHead.Order_ForDealer__c = SecondDealer == '' ? null : SecondDealer; |
| | | invoiceHead.Order_ForDealerText__c = coc.Order_ForDealerText__c; |
| | | update invoiceHead; |
| | | for (InvoiceOrderInfo ass : invoiceOrderRecoeds) { |
| | |
| | | } |
| | | System.debug('invoiceorderList1 +++++' + invoiceorderList1.size()); |
| | | Savepoint sp = Database.setSavepoint(); |
| | | System.debug('invoiceorderList1 = ' + invoiceorderList1); |
| | | if (invoiceorderList1.size() > 0) { |
| | | try { |
| | | System.debug('invoiceorderList1 = ' + invoiceorderList1); |
| | | insert invoiceorderList1; |
| | | } catch (Exception ex) { |
| | | Database.rollback(sp); |
| | |
| | | FROM Consumable_Orderdetails__c |
| | | WHERE Consumable_order__c = :value AND Invoicedet1_OD_link__c = :deleteMap.keySet() |
| | | ]; |
| | | System.debug('detInvoicedet1List = ' + detInvoicedet1List); |
| | | delete detInvoicedet1List; |
| | | } |
| | | |
| | |
| | | update detaliFrom1List; |
| | | } |
| | | |
| | | //保存ContentVersion附件 |
| | | //上传ContentVersion附件 |
| | | @AuraEnabled |
| | | public static String saveFile(Id recordId, String fileName, String base64Data) { |
| | | base64Data = EncodingUtil.urlDecode(base64Data, 'UTF-8'); |
| | |
| | | |
| | | // 保存附件 |
| | | @AuraEnabled |
| | | public static ResponseBodyLWC saveAttachment(String attachmentRecoedsLwc) { |
| | | public static ResponseBodyLWC saveAttachment(String attachmentRecoedsLwc,String invoiceId) { |
| | | System.debug('进入 saveAttachment'); |
| | | ResponseBodyLWC res = new ResponseBodyLWC(); |
| | | Map<String, object> data = new Map<String, object>(); |
| | | res.entity = data; |
| | | invoiceId = invoiceId; |
| | | attachmentRecoeds = (List<InvoiceOrderInfo>)JSON.deserialize(attachmentRecoedsLwc, List<InvoiceOrderInfo>.class); |
| | | System.debug('attachmentRecoeds = ' + attachmentRecoeds); |
| | | try { |
| | | Consumable_accessories_invoice__c attachmentdetails = new Consumable_accessories_invoice__c(); |
| | | for (InvoiceOrderInfo ass : attachmentRecoeds) { |
| | |
| | | } |
| | | } |
| | | } catch (Exception e) { |
| | | return new ResponseBodyLWC('Error', 500, e.getMessage(), ''); |
| | | return new ResponseBodyLWC('Error', 500, e.getMessage() + e.getLineNumber(), ''); |
| | | } |
| | | res.status = 'Success'; |
| | | res.code = 200; |
| | |
| | | return soql; |
| | | } |
| | | |
| | | // 删除按钮 |
| | | @AuraEnabled |
| | | public static ResponseBodyLWC deleteButton(String invoiceIdLwc,Consumable_order__c cocLwc) { |
| | | System.debug('进入 deleteButton'); |
| | | ResponseBodyLWC res = new ResponseBodyLWC(); |
| | | Map<String, object> data = new Map<String, object>(); |
| | | res.entity = data; |
| | | |
| | | coc = cocLwc; |
| | | invoiceId = invoiceIdLwc; |
| | | system.debug('====invoiceId==========>' + invoiceId); |
| | | List<Consumable_Orderdetails__c> consList = [ |
| | | SELECT id, Consumable_order__c |
| | | FROM Consumable_Orderdetails__c |
| | | WHERE Consumable_order__c = :invoiceId |
| | | ]; |
| | | try { |
| | | system.debug('====cons==========>' + consList); |
| | | delete consList; |
| | | if (coc.id == invoiceId && coc.Invoice_status__c == '草案中') { |
| | | delete coc; |
| | | } |
| | | res.status = 'Success'; |
| | | res.code = 200; |
| | | System.debug('res = ' + res); |
| | | return res; |
| | | } catch (Exception e) { |
| | | // ApexPages.addMessages(e); |
| | | // return null; |
| | | return new ResponseBodyLWC('Error', 500, e.getMessage() + ' ' + e.getLineNumber(), ''); |
| | | } |
| | | } |
| | | |
| | | // 提交按钮 |
| | | @AuraEnabled |
| | | public static ResponseBodyLWC approval(List<String> outOrderStringListLwc,Map<String, Consumable_Orderdetails__c> outordercountMapLwc,String invoiceIdLwc) { |
| | | System.debug('进入 approval'); |
| | | ResponseBodyLWC res = new ResponseBodyLWC(); |
| | | Map<String, object> data = new Map<String, object>(); |
| | | res.entity = data; |
| | | |
| | | outOrderStringList = outOrderStringListLwc; |
| | | outordercountMap = outordercountMapLwc; |
| | | invoiceId= invoiceIdLwc; |
| | | //更新发票明细2链接 |
| | | Consumable_order__c P = new Consumable_order__c(); |
| | | List<Consumable_order__c> cocinfo = new List<Consumable_order__c>(); |
| | | List<Consumable_order_details2__c> invoiceorderList2 = new List<Consumable_order_details2__c>(); |
| | | //更新出库单明细1 |
| | | List<Consumable_Orderdetails__c> outOrderdetUp1List = new List<Consumable_Orderdetails__c>(); |
| | | //需要更新出库单明细1 |
| | | List<Consumable_Orderdetails__c> outOrderdet1List = [ |
| | | SELECT |
| | | Id, |
| | | Name, |
| | | Consumable_order__c, |
| | | Consumable_order__r.Name, |
| | | Asset_Model_No__c, |
| | | Consumable_Product__r.Asset_Model_No__c, |
| | | Shipment_Count__c, |
| | | RrturnPro_count__c, |
| | | Delivery_List_RMB__c, |
| | | InvoicedProCost_RMB__c, |
| | | Invoiced_Procount__c, |
| | | Invoiced_Count__c, |
| | | Invoice_Unitprice__c, |
| | | InvoiceProNot_count__c, |
| | | Invoice_Cost_RMB__c, |
| | | Invoice_No__c, |
| | | Box_Piece__c, |
| | | Invoice_Unit__c |
| | | FROM Consumable_Orderdetails__c |
| | | WHERE Consumable_order__c IN :outOrderStringList |
| | | ]; |
| | | for (Integer i = 0; i < outOrderdet1List.size(); i++) { |
| | | if (outordercountMap.containsKey(outOrderdet1List[i].Consumable_order__c + outOrderdet1List[i].Asset_Model_No__c)) { |
| | | Consumable_Orderdetails__c invoiceUpdte1 = new Consumable_Orderdetails__c(); |
| | | invoiceUpdte1.Id = outOrderdet1List[i].Id; |
| | | invoiceUpdte1.Invoice_Unit__c = outordercountMap.get( |
| | | outOrderdet1List[i].Consumable_order__c + outOrderdet1List[i].Asset_Model_No__c |
| | | ) |
| | | .Invoice_Unit__c; |
| | | if ( |
| | | outordercountMap.get(outOrderdet1List[i].Consumable_order__c + outOrderdet1List[i].Asset_Model_No__c).Box_Piece__c == |
| | | '盒' && |
| | | outordercountMap.get(outOrderdet1List[i].Consumable_order__c + outOrderdet1List[i].Asset_Model_No__c).Invoice_Unit__c == |
| | | '个' |
| | | ) { |
| | | Decimal OldinvoicedProcount = 0; |
| | | OldinvoicedProcount = (outordercountMap.get( |
| | | outOrderdet1List[i].Consumable_order__c + outOrderdet1List[i].Asset_Model_No__c |
| | | ) |
| | | .Invoiced_Count__c / |
| | | outordercountMap.get(outOrderdet1List[i].Consumable_order__c + outOrderdet1List[i].Asset_Model_No__c) |
| | | .ProductPacking_list_manual__c) |
| | | .setScale(2); |
| | | invoiceUpdte1.Invoiced_Procount__c = outOrderdet1List[i].Invoiced_Procount__c + OldinvoicedProcount; |
| | | } else { |
| | | invoiceUpdte1.Invoiced_Procount__c = |
| | | outOrderdet1List[i].Invoiced_Procount__c + |
| | | outordercountMap.get(outOrderdet1List[i].Consumable_order__c + outOrderdet1List[i].Asset_Model_No__c) |
| | | .Invoiced_Count__c; |
| | | } |
| | | invoiceUpdte1.Invoice_Unitprice__c = outordercountMap.get( |
| | | outOrderdet1List[i].Consumable_order__c + outOrderdet1List[i].Asset_Model_No__c |
| | | ) |
| | | .Invoice_Unitprice__c; |
| | | invoiceUpdte1.InvoicedProCost_RMB__c = invoiceUpdte1.Invoiced_Procount__c * outOrderdet1List[i].Delivery_List_RMB__c; |
| | | |
| | | Decimal invoicedProcount = 0; |
| | | if ( |
| | | outordercountMap.get(outOrderdet1List[i].Consumable_order__c + outOrderdet1List[i].Asset_Model_No__c).Box_Piece__c == |
| | | '盒' && |
| | | outordercountMap.get(outOrderdet1List[i].Consumable_order__c + outOrderdet1List[i].Asset_Model_No__c).Invoice_Unit__c == |
| | | '个' |
| | | ) { |
| | | invoicedProcount = (outordercountMap.get( |
| | | outOrderdet1List[i].Consumable_order__c + outOrderdet1List[i].Asset_Model_No__c |
| | | ) |
| | | .Invoiced_Count__c / |
| | | outordercountMap.get(outOrderdet1List[i].Consumable_order__c + outOrderdet1List[i].Asset_Model_No__c) |
| | | .ProductPacking_list_manual__c) |
| | | .setScale(2); |
| | | } else { |
| | | invoicedProcount = outordercountMap.get(outOrderdet1List[i].Consumable_order__c + outOrderdet1List[i].Asset_Model_No__c) |
| | | .Invoiced_Count__c; |
| | | } |
| | | |
| | | if (outOrderdet1List[i].InvoiceProNot_count__c < invoicedProcount) { |
| | | // ApexPages.addmessage( |
| | | // new ApexPages.message( |
| | | // ApexPages.severity.Error, |
| | | // '出库单' + |
| | | // outOrderdet1List[i].Consumable_order__r.Name + |
| | | // '中,' + |
| | | // outOrderdet1List[i].Asset_Model_No__c + |
| | | // '还没开票数量小于发票数量,请确认是否有返品。' |
| | | // ) |
| | | // ); |
| | | // return null; |
| | | return new ResponseBodyLWC('Error', 500, '出库单' + outOrderdet1List[i].Consumable_order__r.Name + '中,' + outOrderdet1List[i].Asset_Model_No__c + '还没开票数量小于发票数量,请确认是否有返品。', ''); |
| | | } |
| | | |
| | | outOrderdetUp1List.add(invoiceUpdte1); |
| | | } |
| | | } |
| | | Savepoint sp = Database.setSavepoint(); |
| | | try { |
| | | //出库单明细1更新 |
| | | if (outOrderdetUp1List.size() > 0) { |
| | | ControllerUtil.updateOrderDetails1Satus(outOrderdetUp1List); |
| | | } |
| | | //发票状态更新 |
| | | cocinfo = [ |
| | | SELECT Id, Name, Invoice_status__c, Dealer_Info__c, Order_ForHospital__c, SummonsForDirction__c |
| | | FROM Consumable_order__c |
| | | WHERE Id = :invoiceId |
| | | ]; |
| | | System.debug('cocinfo = ' + cocinfo); |
| | | if (cocinfo.size() > 0) { |
| | | p = cocinfo[0]; |
| | | } |
| | | System.debug('p = ' + p); |
| | | p.Invoice_status__c = '提交'; |
| | | update p; |
| | | } catch (Exception ex) { |
| | | Database.rollback(sp); |
| | | // ApexPages.addMessages(ex); |
| | | // return null; |
| | | return new ResponseBodyLWC('Error', 500, ex.getMessage() + ' ' + ex.getLineNumber(), ''); |
| | | } |
| | | res.status = 'Success'; |
| | | res.code = 200; |
| | | System.debug('res = ' + res); |
| | | return res; |
| | | } |
| | | |
| | | class InvoiceOrderInfo implements Comparable { |
| | | @AuraEnabled |
| | | public Boolean check { get; set; } |