| | |
| | | // attachmentRecoeds.add(new InvoiceOrderInfo(attachmentinfo[i])); |
| | | // } |
| | | // } |
| | | List<ContentVersion> cvInfo = [SELECT Id, Title, OwnerId,Owner.Name, CreatedDate FROM ContentVersion WHERE FirstPublishLocationId = :invoiceId]; |
| | | List<ContentVersion> cvInfo = [ |
| | | SELECT Id, Title, OwnerId, Owner.Name, CreatedDate, ContentDocumentId |
| | | FROM ContentVersion |
| | | WHERE FirstPublishLocationId = :invoiceId |
| | | ]; |
| | | if (cvInfo.size() > 0) { |
| | | for (Integer i = 0; i < cvInfo.size(); i++) { |
| | | attachmentRecoeds.add(new InvoiceOrderInfo(cvInfo[i])); |
| | |
| | | data.put('done', getdone()); |
| | | data.put('invoiceOrderdetail1Recoeds', invoiceOrderdetail1Recoeds); |
| | | data.put('accountid', accountid); |
| | | data.put('invoiceOrderRecoedschange',invoiceOrderRecoedschange); |
| | | data.put('attachmentRecoeds',attachmentRecoeds); |
| | | 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); |
| | | return 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 = ''; |
| | | invoiceOrderRecoeds = (List<InvoiceOrderInfo>)JSON.deserialize(invoiceOrderRecoedsLwc, List<InvoiceOrderInfo>.class); |
| | | deliveryId = deliveryIdLwc; |
| | | invoiceOrderRecoeds = (List<InvoiceOrderInfo>) JSON.deserialize(invoiceOrderRecoedsLwc, List<InvoiceOrderInfo>.class); |
| | | invoiceId = invoiceIdLwc; |
| | | accountid = accountidLwc; |
| | | agencyProType = agencyProTypeLwc; |
| | | invoiceOrderRecoedschange = (List<InvoiceOrderInfo>)JSON.deserialize(invoiceOrderRecoedschangeLwc, List<InvoiceOrderInfo>.class); |
| | | reopen = reopenLwc; |
| | | invoiceOrderRecoedschange = (List<InvoiceOrderInfo>) JSON.deserialize(invoiceOrderRecoedschangeLwc, List<InvoiceOrderInfo>.class); |
| | | |
| | | List<String> chukudanID = new List<String>(); |
| | | if (coc.Name == '' || coc.Name == null) { |
| | | // coc.Name.addError('请录入发票号。'); |
| | | // coc.Name.addError('请录入发票号'); |
| | | // return null; |
| | | return new ResponseBodyLWC('Error', 500, '请录入发票号。', ''); |
| | | return new ResponseBodyLWC('Error', 500, '请录入发票号', ''); |
| | | } |
| | | if (coc.Invoice_Date__c == null) { |
| | | // coc.Invoice_Date__c.addError('请录入发票日期。'); |
| | | // coc.Invoice_Date__c.addError('请录入发票日期'); |
| | | // return null; |
| | | return new ResponseBodyLWC('Error', 500, '请录入发票日期。', ''); |
| | | return new ResponseBodyLWC('Error', 500, '请录入发票日期', ''); |
| | | } |
| | | if (String.isBlank(HospitalInfo) && SecondDealer == null) { |
| | | // coc.addError('必须输入客户名或者二级经销商。'); |
| | | if (String.isBlank(HospitalInfo) && String.isBlank(SecondDealer)) { |
| | | // coc.addError('必须输入客户名或者二级经销商'); |
| | | // return null; |
| | | return new ResponseBodyLWC('Error', 500, '必须输入客户名或者二级经销商。', ''); |
| | | return new ResponseBodyLWC('Error', 500, '必须输入客户名或者二级经销商', ''); |
| | | } |
| | | if (HospitalInfo != null && HospitalInfo != '' && String.isNotEmpty(SecondDealer)) { |
| | | //coc.addError('请输入客户名、二级经销商只可输入一个。'); |
| | | errorMsg += '请输入客户名、二级经销商只可输入一个。'; |
| | | //coc.addError('请输入客户名、二级经销商只可输入一个'); |
| | | errorMsg += '请输入客户名、二级经销商只可输入一个'; |
| | | } |
| | | if (HospitalInfo != null && HospitalInfo != '') { |
| | | if (coc.Order_ForCustomerText__c == null) { |
| | | // coc.Order_ForCustomerText__c.addError('请输入科室。'); |
| | | // coc.Order_ForCustomerText__c.addError('请输入科室'); |
| | | // return null; |
| | | return new ResponseBodyLWC('Error', 500, '请输入科室。', ''); |
| | | return new ResponseBodyLWC('Error', 500, '请输入科室', ''); |
| | | } |
| | | } else { |
| | | if (coc.Order_ForCustomerText__c != null) { |
| | | // coc.Order_ForCustomerText__c.addError('不需要输入科室。'); |
| | | // coc.Order_ForCustomerText__c.addError('不需要输入科室'); |
| | | // return null; |
| | | return new ResponseBodyLWC('Error', 500, '不需要输入科室。', ''); |
| | | return new ResponseBodyLWC('Error', 500, '不需要输入科室', ''); |
| | | } |
| | | } |
| | | String shipmentAccountString = ''; |
| | |
| | | } |
| | | } else { |
| | | if (HospitalInfo != null && HospitalInfo != '') { |
| | | |
| | | System.debug('++++++++++++' + ass.esd.Order_ForHospital__c + ' ' + shipmentAccountString); |
| | | if (ass.esd.Order_ForHospital__c != shipmentAccountString) { |
| | | System.debug('HospitalInfo != null ass.esd.Order_ForHospital__c != shipmentAccountString'); |
| | |
| | | (ass.esd.Order_ForDealerText__c != null || ass.esd.Order_ForDealerText__c != '') && |
| | | ass.esd.ShipmentAccount__c != shipmentAccountString |
| | | ) { |
| | | System.debug('HospitalInfo == null && ass.esd.Order_ForDealerText__c != null ass.esd.ShipmentAccount__c != shipmentAccountString'); |
| | | System.debug( |
| | | 'HospitalInfo == null && ass.esd.Order_ForDealerText__c != null ass.esd.ShipmentAccount__c != shipmentAccountString' |
| | | ); |
| | | invoiceOrderAccountList.add(ass.esd.Name); |
| | | } |
| | | } |
| | |
| | | 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_ProType__c = agencyProType; |
| | | invoiceHead.Order_ForCustomerText__c = coc.Order_ForCustomerText__c; |
| | | //if (deliveryId != null) { |
| | | if (String.isNotBlank(deliveryId)) { |
| | | if (String.isNotBlank(deliveryId)) { |
| | | invoiceHead.Outbound_order__c = deliveryId; |
| | | } |
| | | invoiceHead.RecordTypeid = System.Label.RT_ConOrder_Invoice; |
| | | //if (SecondDealer == null) { |
| | | if (String.isBlank(SecondDealer)) { |
| | | if (String.isBlank(SecondDealer)) { |
| | | if (HospitalInfo != null && HospitalInfo != '') { |
| | | invoiceHead.Order_ForHospital__c = HospitalInfo; |
| | | } |
| | |
| | | } |
| | | 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 |
| | | System.debug('===>' + chukudanID); |
| | | System.debug('===>' + chukudanID.size()); |
| | | if (chukudanID.size() > 0) { |
| | | newinvoicedetails1(chukudanID); |
| | | } |
| | |
| | | } 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 IN :orderIdList |
| | | ]; |
| | | for (Integer i = 0; i < existLinkinfo.size(); i++) { |
| | | ordermx1defaultMap.put(existLinkinfo[i].Consumable_order__c + existLinkinfo[i].Asset_Model_No__c, 0); |
| | | } |
| | | // for (Integer i = 0; i < existLinkinfo.size(); i++) { |
| | | // ordermx1defaultMap.put(existLinkinfo[i].Consumable_order__c + existLinkinfo[i].Asset_Model_No__c, 0); |
| | | // } |
| | | } |
| | | |
| | | public static void deleteOutboundorder(Map<String, String> deleteMap, String value) { |
| | |
| | | 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; |
| | | attachmentRecoeds = (List<InvoiceOrderInfo>)JSON.deserialize(attachmentRecoedsLwc, List<InvoiceOrderInfo>.class); |
| | | 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) { |
| | | if (!String.isBlank(ass.mailSelectOptsin)) { |
| | | attachmentdetails.Id = ass.invoiceOrderId; |
| | | attachmentdetails.Attachment_ID__c = ass.cvInfo.Id; |
| | | attachmentdetails.Attachment_ID__c = ass.cvInfo.ContentDocumentId; |
| | | attachmentdetails.Accessories_type__c = ass.mailSelectOptsin; |
| | | if (String.isBlank(ass.invoiceOrderId)) { |
| | | attachmentdetails.Invoice_code__c = invoiceId; |
| | |
| | | } |
| | | } |
| | | } 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; |
| | |
| | | |
| | | // 检索(未开发票出库单) |
| | | @AuraEnabled |
| | | public static ResponseBodyLWC InvoiceorderSearch(Consumable_order__c cocLwc,String invoiceIdLwc,String accountidLwc,String userWorkLocationLwc,String agencyProTypeLwc,String HospitalInfoLwc,String SecondDealerLwc,String invoiceOrderRecoedsLwc) { |
| | | public static ResponseBodyLWC InvoiceorderSearch( |
| | | Consumable_order__c cocLwc, |
| | | String invoiceIdLwc, |
| | | String accountidLwc, |
| | | String userWorkLocationLwc, |
| | | String agencyProTypeLwc, |
| | | String HospitalInfoLwc, |
| | | String SecondDealerLwc, |
| | | String invoiceOrderRecoedsLwc |
| | | ) { |
| | | System.debug('进入 InvoiceorderSearch'); |
| | | ResponseBodyLWC res = new ResponseBodyLWC(); |
| | | Map<String, object> data = new Map<String, object>(); |
| | |
| | | HospitalInfo = HospitalInfoLwc; |
| | | SecondDealer = SecondDealerLwc; |
| | | errorMsg = ''; |
| | | invoiceOrderRecoeds = (List<InvoiceOrderInfo>)JSON.deserialize(invoiceOrderRecoedsLwc, List<InvoiceOrderInfo>.class); |
| | | invoiceOrderRecoeds = (List<InvoiceOrderInfo>) JSON.deserialize(invoiceOrderRecoedsLwc, List<InvoiceOrderInfo>.class); |
| | | invoiceId = invoiceIdLwc; |
| | | accountid = accountidLwc; |
| | | agencyProType = agencyProTypeLwc; |
| | | userWorkLocation = userWorkLocationLwc; |
| | | |
| | | |
| | | Map<String, String> invoiceOrderMap = new Map<String, String>(); |
| | | String msoql = ''; |
| | | List<InvoiceOrderInfo> invoiceOrderdetailMid = new List<InvoiceOrderInfo>(); |
| | |
| | | invoiceOrderMap.put(invoiceOrderList[i].Name, invoiceOrderList[i].Name); |
| | | } |
| | | } |
| | | data.put('invoiceOrderRecoeds',invoiceOrderRecoeds); |
| | | data.put('invoiceOrderRecoeds', invoiceOrderRecoeds); |
| | | res.status = 'Success'; |
| | | res.code = 200; |
| | | System.debug('res = ' + res); |
| | |
| | | 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; |
| | | System.debug('====>procount' + invoiceUpdte1.Invoiced_Procount__c); |
| | | System.debug('===>RMB' + outOrderdet1List[i].Delivery_List_RMB__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; |
| | | } |
| | | System.debug('发票数量===>' + outOrderdet1List[i].InvoiceProNot_count__c); |
| | | System.debug('还没发票数量===>' + invoicedProcount); |
| | | |
| | | 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; |
| | | } |
| | | @TestVisible |
| | | class InvoiceOrderInfo implements Comparable { |
| | | @AuraEnabled |
| | | public Boolean check { get; set; } |
| | |
| | | @AuraEnabled |
| | | public Attachment attach { get; set; } |
| | | @AuraEnabled |
| | | public ContentVersion cvInfo{ get; set; } |
| | | public ContentVersion cvInfo { get; set; } |
| | | @AuraEnabled |
| | | public String mailSelectOptsin { get; set; } |
| | | public List<SelectOption> mailSelectOpts { get; set; } |
| | | @AuraEnabled |
| | | public Map<String,String> mailSelectOptsMap { get; set; } |
| | | public Map<String, String> mailSelectOptsMap { get; set; } |
| | | @AuraEnabled |
| | | public String invoiceOrderId { get; set; } |
| | | @AuraEnabled |
| | |
| | | //ContentVersion |
| | | public InvoiceOrderInfo(ContentVersion cv) { |
| | | cvInfo = cv; |
| | | mailSelectOptsMap = new Map<String,String>(); |
| | | mailSelectOptsMap = new Map<String, String>(); |
| | | mailSelectOptsMap.put('发票和明细', '发票和明细'); |
| | | mailSelectOptsMap.put('发票', '发票'); |
| | | mailSelectOptsMap.put('明细', '明细'); |